diff --git a/.gitattributes b/.gitattributes index 130dab4a..4429a7bf 100644 --- a/.gitattributes +++ b/.gitattributes @@ -64,3 +64,12 @@ *.sql eol=crlf merge=union /*.sql diff *.sql diff + +# linguist overrides +*.cs linguist-language=C# +*.ps1 linguist-language=Powershell +*.psd1 linguist-language=Powershell +*.psm1 linguist-language=Powershell +*.R linguist-language=R +*.sql linguist-language=TSQL + diff --git a/.github/ISSUE_TEMPLATE.md b/.github/bug_report.md similarity index 53% rename from .github/ISSUE_TEMPLATE.md rename to .github/bug_report.md index 5a127e83..cfaa64e5 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/bug_report.md @@ -1,8 +1,15 @@ -**Do you want to request a *feature* or report a *bug*?** +--- +name: Bug report +about: Create a bug report to help us improve + +--- + +Include the version number of the script you're using. +If it's not the current version, upgrade to the current version and test that before reporting a bug - we fix a lot of stuff in each new build. **What is the current behavior?** -**If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via http://sqlfiddle.com/** +**If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via http://sqlfiddle.com** **What is the expected behavior?** diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/feature_request.md similarity index 73% rename from .github/PULL_REQUEST_TEMPLATE.md rename to .github/feature_request.md index deee0696..257aee58 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/feature_request.md @@ -1,14 +1,16 @@ +--- +name: Feature request +about: Suggest an idea for this project + +--- + Fixes # . Changes proposed in this pull request: - - - - - How to test this code: - - - - - Has been tested on (remove any that don't apply): - Case-sensitive SQL Server instance @@ -17,5 +19,7 @@ Has been tested on (remove any that don't apply): - SQL Server 2012 - SQL Server 2014 - SQL Server 2016 + - SQL Server 2017 + - SQL Server 2019 - Amazon RDS - Azure SQL DB diff --git a/.github/sql_help.md b/.github/sql_help.md new file mode 100644 index 00000000..383c7685 --- /dev/null +++ b/.github/sql_help.md @@ -0,0 +1,9 @@ +--- +name: SQL HELP +about: Describe your problem and get help + +--- + +1. Operation system with detailed version (Windows, Ubuntu, Macos etc.). Example: `Microsoft Windows [Version 10.0.16299.248]` +2. Relation database type (SQL Server preferred, Orcale, MySQL, PostgreSQL, SQLite etc.) with detailed version. Example: `Microsoft SQL Server 2017 (RTM-CU1) (KB4038634) - 14.0.3006.16 (X64) ... on Windows 10 Pro 10.0` +3. Demo script (if necessary) to reproduce your problem. diff --git a/ADS/README.md b/ADS/README.md new file mode 100644 index 00000000..fc138499 --- /dev/null +++ b/ADS/README.md @@ -0,0 +1,76 @@ +# Azure Data Studio (ADS) +[Azure Data Studio](https://github.com/microsoft/azuredatastudio) is a open source cross-platform database tool for data professionals using the Microsoft family of on-premises and cloud data platforms on Windows, MacOS, and Linux. + + +## Useful Links + +- [Official ADS List of Extensions](https://github.com/microsoft/azuredatastudio/wiki/List-of-Extensions) +- [Latest Release](https://github.com/microsoft/azuredatastudio/releases/latest) + +## Download the latest Azure Data Studio release + +| Platform | Download Link | +|--------------------------|-------------------------------------------------| +| Windows User Installer | https://go.microsoft.com/fwlink/?linkid=2132348 | +| Windows System Installer | https://go.microsoft.com/fwlink/?linkid=2132347 | +| Windows ZIP | https://go.microsoft.com/fwlink/?linkid=2132518| +| macOS ZIP | https://go.microsoft.com/fwlink/?linkid=2132519 | +| Linux TAR.GZ | https://go.microsoft.com/fwlink/?linkid=2132349 | +| Linux RPM | https://go.microsoft.com/fwlink/?linkid=2132351 | +| Linux DEB | https://go.microsoft.com/fwlink/?linkid=2132350 | + + +## Azure Data Studio extensions + +| Extension | Repository Link | Release Date | Version | .vsix download link | Description | +|---------------------------------------|-----------------|--------------|----------|---------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------| +| [SQL Server Import] | [Github][1] | 2020-05-15 | 0.15.0 | [GO](https://go.microsoft.com/fwlink/?linkid=2131183) | Streamlines the data import process by providing a wizard that simplifies copying flat files (`.csv`, `.txt`, `.json`) into a SQL Server table | +| [PostgreSQL extension (preview)] | [Github][2] | 2020-03-26 | 0.2.6 | [GO](https://go.microsoft.com/fwlink/?linkid=2099772) | Enables users to connect, query, and manage Postgres databases with Azure Data Studio | +| [Query Editor Boost][3] | [Github][3] | 2020-02-17 | 0.4.1 | [Github][https://github.com/dzsquared/query-editor-boost/releases/] | This extension adds several features helpful with query writing in Azure Data Studio | +| [SQL Server Dacpac] | [Github][1] | 2020-06-04 | 1.5.0 | [GO](https://go.microsoft.com/fwlink/?linkid=2099885) | Provides an easy-to-use wizarding experience to deploy and extract [`.dacpac`] files and import and export `.bacpac` files | +| [SQL Server Profiler] | [Github][1] | 2019-12-18 | 0.11.0 | [GO](https://go.microsoft.com/fwlink/?linkid=2099574) | Provides a simple SQL Server tracing solution similar to SSMS Profiler, allowing users to create and manage traces and analyze and replay trace results | +| [SQL Server Agent] | [Github][1] | 2020-04-16 | 0.47.0 | [GO](https://go.microsoft.com/fwlink/?linkid=2099884) | Helps manage and troubleshoot SQL Server Agent jobs and configuration (early preview) | +| SQL Server Admin Pack | [Github][1] | 2019-03-14 | 0.0.2 | [GO](https://go.microsoft.com/fwlink/?linkid=2099889) | A collection of popular database administration extensions to help manage SQL Server | +| [SQL Server Schema Compare] | [Github][1] | 2020-06-17 | 1.5.0 | [GO](https://go.microsoft.com/fwlink/?linkid=2099886) | Provides an easy-to-use experience to compare the schemas from [`.dacpac`] files and databases and apply the changes from source to target | +| [PowerShell Extension] | [Github][6] | 2020-04-15 | 2020.4.0 | [GO](https://go.microsoft.com/fwlink/?linkid=2099773) | Provides rich PowerShell language support for Azure Data Studio | +| [SandDance for Azure Data Studio] | [Github][7] | 2020-06-24 | 3.0.0 | [Vsix](https://github.com/microsoft/SandDance/releases/latest) | Provides interactive visualizations that help users explore, understand, and present their data | +| [SandDance for VSCode][8] | [Github][7] | 2020-06-24 | 3.0.0 | [Vsix][8] | Provides interactive visualizations that help users explore, understand, and present their data for `.csv` or `.tsv` files | +| [Server Reports][1] | [Github][1] | 2020-04-27 | 0.2.2 | [GO][https://go.microsoft.com/fwlink/?linkid=2099768] | Provides useful information about the server's performance, such as: DB Space Usage, DB Buffer Usage, CPU Utilization, Backup Growth Trend | +| [whoisactive][1] | [Github][1] | 2020-04-27 | 0.1.4 | [GO][https://go.microsoft.com/fwlink/?linkid=2099774] | Displays insights from sp_whoisactive, a useful tool for activity monitoring and troubleshooting, as graphs and tasks inside an Azure Data Studio | +| [SQL Database Projects extension] | [Github][1] | 2020-04-27 | 0.3.0 | [GO][https://go.microsoft.com/fwlink/?linkid=2143820] | Extension for developing SQL databases in a project-based development environment | + + +## Azure Data Studio Articles + +| Title | Author | Modified | +|------------------------------------------------------------|------------------------------------------|------------| +| [Integrating Azure Data Studio with Git and GitHub] | Rajendra Gupta | 2020-07-03 | +| [Working with Git components in Azure Data Studio] | Rajendra Gupta | 2020-07-09 | + +[1]:https://github.com/Microsoft/azuredatastudio +[2]:https://github.com/microsoft/azuredatastudio-postgresql +[3]:https://github.com/dzsquared/query-editor-boost/ +[4]:https://github.com/dzsquared/query-editor-boost/releases/latest +[5]:https://github.com/microsoft/azuredatastudio-postgresql +[6]:https://github.com/PowerShell/vscode-powershell/ +[7]:https://github.com/Microsoft/SandDance +[8]:https://marketplace.visualstudio.com/items?itemName=msrvida.vscode-sanddance +[`.dacpac`]:https://docs.microsoft.com/en-us/sql/relational-databases/data-tier-applications/data-tier-applications + +[SQL Server Import]:https://docs.microsoft.com/en-us/sql/azure-data-studio/sql-server-import-extension +[PostgreSQL extension (preview)]:https://docs.microsoft.com/en-us/sql/azure-data-studio/postgres-extension +[SQL Server Dacpac]:https://docs.microsoft.com/en-us/sql/azure-data-studio/sql-server-dacpac-extension +[SQL Server Profiler]:https://docs.microsoft.com/en-us/sql/azure-data-studio/sql-server-profiler-extension +[SQL Server Agent]:https://docs.microsoft.com/en-us/sql/azure-data-studio/sql-server-agent-extension +[SQL Server Compare]:https://docs.microsoft.com/en-us/sql/azure-data-studio/schema-compare-extension +[PowerShell Extension]:https://docs.microsoft.com/en-us/sql/azure-data-studio/powershell-extension +[SandDance for Azure Data Studio]:https://docs.microsoft.com/en-us/sql/azure-data-studio/sanddance-extension +[SQL Database Projects extension]:https://docs.microsoft.com/en-gb/sql/azure-data-studio/extensions/sql-database-project-extension + +[Integrating Azure Data Studio with Git and GitHub]:https://www.sqlshack.com/integrating-azure-data-studio-with-git-and-github/ +[Working with Git components in Azure Data Studio]:https://www.sqlshack.com/working-with-git-components-in-azure-data-studio/ + + +### TODO Links + +- https://github.com/microsoft/azuredatastudio/issues/2752#issuecomment-487315692 diff --git a/Articles/Backup/The Curse and Blessings of Dynamic SQL.htm b/Articles/Backup/The Curse and Blessings of Dynamic SQL.htm index 3e709c0b..82981937 100644 --- a/Articles/Backup/The Curse and Blessings of Dynamic SQL.htm +++ b/Articles/Backup/The Curse and Blessings of Dynamic SQL.htm @@ -2,34 +2,34 @@ The Curse and Blessings of Dynamic SQL - - diff --git a/Articles/README.md b/Articles/README.md index 2ee37979..b9f58c6e 100644 --- a/Articles/README.md +++ b/Articles/README.md @@ -2,7 +2,12 @@ Articles types: - **[AZ]** Azure Articles + - **[AMZ]** Amazon AWS Articles - **[B]** Backup Articles + - **[BENCH]** Benchmarking Articles + - **[IDX]** Index Articles + - **[CLR]** [SQL Server Common Language Runtime Integration](https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql/sql-server-common-language-runtime-integration) Articles + - **[CHP]** Checkpont Articles - **[COR]** Corruption Articles - **[DAX]** Data Analysis Expressions Articles - **[DBA]** DBA Articles @@ -10,23 +15,24 @@ Articles types: - **[DM]** Database Mail - **[DBCC]** DBCC commands - **[DS]** Dynamic SQL - - **[BIDX]** Index B-Tree Articles - **[MG]** Migration Articles - **[J]** Jobs Articles - **[P]** Performance Articles - **[PS]** Powershell Articles + - **[QS]** Query Store Articles - **[R]** R Language - - **[SSIS]** [SQL Server Integration Services](https://msdn.microsoft.com/en-us/library/ms141026.aspx) + - **[SEC]** SQL Server Security Articles + - **[SSIS]** [SQL Server Integration Services](https://docs.microsoft.com/en-us/sql/integration-services/sql-server-integration-services) - **[V]** Visualization Articles - - **[X]** XML, JSON, YAML, HTML + - **[X]** XML, JSON, YAML, HTML Articles - **[XE]** [Extended events](https://docs.microsoft.com/en-us/sql/relational-databases/extended-events/extended-events) | Title | Author | Modified | Type | |-------------------------------------------------------------------------------------------------------------------------|------------------------------------------|------------|-------------| -| [SQL Server Index Design Guide] | Microsoft | ? | [BIDX] | -| [SQL Server 2012 Security Best Practices - Microsoft] | Bob Beauchemin | 2012-01-15 | | -| [Help, my database is corrupt. Now what?] | Gail Shaw | 2010-04-23 | [COR] | | [Understanding how SQL Server executes a query] | Remus Rusanu | 2016-04-15 | | +| [SQL Server Index Design Guide] | Microsoft | 1753-01-01 | [IDX] | +| [SQL Server 2012 Security Best Practices - Microsoft] | Bob Beauchemin | 2012-01-15 | [SEC] | +| [Help, my database is corrupt. Now what?] | Gail Shaw | 2010-04-23 | [COR] | | [What to Do When DBCC CHECKDB Reports Corruption] | Brent Ozar | 2016-05-19 | [COR] | | [Troubleshooting SQL Server CPU Performance Issues] | Joe Sack | 2013-05-28 | [P] | | [Knee-Jerk Performance Tuning : Incorrect Use of Temporary Tables] | Paul Randal | 2016-04-06 | [P] | @@ -38,17 +44,18 @@ Articles types: | [Slow in the Application, Fast in SSMS] | Erland Sommarskog | 2013-12-18 | | | [How to share data between stored procedures] | Erland Sommarskog | 2013-11-02 | | | [Arrays and Lists in SQL Server 2008] | Erland Sommarskog | 2016-08-21 | | -| [Giving Permissions through Stored Procedures] | Erland Sommarskog | 2011-12-31 | | -| [Error and Transaction Handling in SQL Server] | Erland Sommarskog | 2015-05-03 | | +| [Packaging Permissions in Stored Procedures] | Erland Sommarskog | 2011-12-31 | | +| [Error and Transaction Handling in SQL Server Part One – Jumpstart Error Handling] | Erland Sommarskog | 2015-05-03 | [DBA][DEV] | +| [Error and Transaction Handling in SQL Server Part Two – Commands and Mechanisms] | Erland Sommarskog | 2019-09-03 | [DBA][DEV] | +| [Error and Transaction Handling in SQL Server Part Three – Implementation] | Erland Sommarskog | 2017-05-03 | [DBA][DEV] | | [Using the Bulk-Load Tools in SQL Server] | Erland Sommarskog | 2016-12-08 | | | [Using Table-Valued Parameters in SQL Server and .NET] | Erland Sommarskog | 2016-12-08 | | | [SQL Server Columnstore Articles] | Niko Neugebauer | 2016-05-09 | | | [Documentation: It Does not Suck!] | Jes Schultz Borland | 2013-01-15 | | | [The Data Loading Performance Guide] | Thomas Kejser, Peter Carlin, Stuart Ozer | 2009-01-15 | | -| [Required Testing for Installing SQL Server Cumulative Updates and Service Packs] | Kendra Little | 2016-04-28 | | | [Stop Shrinking Your Database Files. Seriously. Now.] | Brent Ozar | 2009-08-19 | | | [How to shrink a database in 4 easy steps] | Andy Mallon | 2016-04-28 | | -| [Introduction to the Index Operational Statistics Dynamic Management Function] | Tim Ford | 2016-04-26 | [BIDX] | +| [Introduction to the Index Operational Statistics Dynamic Management Function] | Tim Ford | 2016-04-26 | [IDX] | | [Updating Statistics in SQL Server: Maintenance Questions & Answers] | Kendra Little | 2016-04-18 | | | [Overcoming Variable Limitations in SQLCmd Mode] | Robert L Davis | 2015-11-23 | | | [Contents of a Run Book] | Microsoft | 2002-11-12 | | @@ -57,9 +64,7 @@ Articles types: | [Understanding GRANT, DENY, and REVOKE in SQL Server] | K. Brian Kelley | 2013-02-27 | | | [Monitor SQL Server Transaction Log File Free Space] | Mike Eastland | 2015-05-12 | | | [Dynamically Query a 100 Million Row Table-Efficiently] | Gary Strange | 2016-05-27 | | -| [Understanding and Using Parallelism in SQL Server] | Paul White | 2011-03-03 | | -| [Diagnosing and Resolving Latch Contention on SQL Server] | Microsoft | 2014-02-28 | | -| [Parallel Execution Plans – Branches and Threads] | Paul White | 2013-10-07 | | +| [Parallel Execution Plans – Branches and Threads] | Paul White | 2013-10-07 | [DBA][DEV] | | [Nasty Fast PERCENT_RANK] | Alan Burstein | 2016-06-07 | | | [Looking at VIEWs, Close Up] | Joe Celko | 2016-05-10 | | | [SQL Server 2016: It Just Runs Faster] | Thomas LaRock | 2016-06-01 | | @@ -68,17 +73,17 @@ Articles types: | [How to transfer logins and passwords between instances of SQL Server] | Microsoft | 2013-12-07 | | | [Finding File Growths with Extended Events] | Andy Galbraith | 2016-06-13 | [XE] | | [Questions You Should Ask About the Databases You Manage] | Brent Ozar | 2016-06-16 | | -| [Clustered Indexes in SQL Server] | Derik Hammer | 2016-06-22 | [BIDX] | +| [Clustered Indexes in SQL Server] | Derik Hammer | 2016-06-22 | [IDX] | | [Triage Quiz: Is Your SQL Server Safe?] | Angie Rudduck | 2016-06-15 | | | [Why Not Just Create Statistics?] | Erik Darling | 2016-07-14 | | | [Understanding the SQL Server NOLOCK hint] | Greg Robidoux | 2011-08-16 | | -| [Recover access to a SQL Server instance] | Aaron Bertrand | 2012-08-30 | | +| [Recover access to a SQL Server instance] | Aaron Bertrand | 2012-08-30 | [SEC] | | [SQL Server 2016 Upgrade Planning] | Jen Underwood | 2016-06-28 | | | [Graphs and Graph Algorithms in T-SQL] | Hans Olav Norheim | 2010-05-22 | | -| [Episode 4: SQL Server R Services makes you a smarter T-SQL Developer] | Sanjay Mishra | 2016-07-12 | [DEV],[R] | +| [Episode 4: SQL Server R Services makes you a smarter T-SQL Developer] | Sanjay Mishra | 2016-07-12 | [DEV][R] | | [How to Set Max Degree of Parallelism in SQL Server] | Kendra Little | 2016-07-14 | | | [Undocumented Query Plans: Equality Comparisons] | Paul White | 2016-06-22 | | -| [Simplified Order Of Operations] | Michael J. Swart | 2016-07-20 | | +| [Simplified Order Of Operations] | Michael J Swart | 2016-07-20 | | | [SQL Server Statistics Basics] | Robert Sheldon | 2016-07-22 | | | [Learn to Use sp_Blitz, sp_BlitzCache, sp_BlitzFirst, and sp_BlitzIndex with These Tutorial Videos] | Brent Ozar | 2016-09-12 | | | [Where is a record really located?] | Tim Chapman | 2016-09-15 | | @@ -93,7 +98,7 @@ Articles types: | [#BackToBasics : An Updated "Kitchen Sink" Example] | Aaron Bertrand | 2016-06-01 | | | [Locking and Blocking in SQL Server] | Brent OZar | 2016-01-01 | | | [Nested Loops Prefetching] | Paul White | 2013-08-31 | | -| [Performance tuning backup and restore operations] | Derik Hammer | 2015-12-21 | [B],[P] | +| [Performance tuning backup and restore operations] | Derik Hammer | 2015-12-21 | [B][P] | | [Execution Plan Analysis: The Mystery Work Table] | Paul White | 2013-03-08 | | | [How to move data between File Groups in SQL Server] | Klaus Aschenbrenner | 2016-09-26 | | | [Optimizing Your Query Plans with the SQL Server 2014 Cardinality Estimator] | Joseph Sack | 2014-06-24 | | @@ -108,15 +113,13 @@ Articles types: | [Query Optimizer Deep Dive - Part 2] | Paul White | 2012-04-28 | | | [Query Optimizer Deep Dive - Part 3] | Paul White | 2012-04-29 | | | [Query Optimizer Deep Dive - Part 4] | Paul White | 2012-05-01 | | -| [Should You Rebuild or Reorganize Indexes on Large Tables?] | Kendra Little | 2016-10-13 | [BIDX] | +| [Should You Rebuild or Reorganize Indexes on Large Tables?] | Kendra Little | 2016-10-13 | [IDX] | | [Retrieving SQL Server Query Execution Plans] | Robert Sheldon | 2016-10-18 | | | [Introduction to Latches in SQL Server] | Klaus Aschenbrenner | 2014-06-23 | | | [Latch Coupling in SQL Server] | Klaus Aschenbrenner | 2016-10-24 | | | [Partitioned Views? A How-To Guide] | Erik Darling | 2016-09-22 | | -| [How to Choose Between RCSI and Snapshot Isolation Levels] | Kendra Little | 2016-02-18 | | | [TroubleShooting SQL Server Memory Consumption] | Satnam Singh | 2012-09-28 | | | [Time Series Algorithms in SQL Server] | Dinesh Asanka | 2015-06-01 | | -| [Heap Tables in SQL Server] | Klaus Aschenbrenner | 2015-10-19 | | | [Internals of the Seven SQL Server Sorts – Part 1] | Paul White | 2015-04-29 | | | [Internals of the Seven SQL Server Sorts – Part 2] | Paul White | 2015-05-07 | | | [The 9 Letters That Get DBAs Fired] | Brent Ozar | 2011-12-22 | | @@ -128,12 +131,11 @@ Articles types: | [Successful Anti-Patterns, Storage Requirements] | Raul Gonzalez | 2016-10-19 | | | [SQL Server table columns under the hood] | Remus Rusanu | 2011-10-20 | | | [How to analyse SQL Server performance] | Remus Rusanu | 2014-02-24 | | -| [To BLOB or Not To BLOB: Large Object Storage in a Database or a Filesystem?] | Jim Gray | 2006-04-01 | | | [Asynchronous procedure execution] | Remus Rusanu | 2009-08-05 | | | [What is the CXPACKET Wait Type, and How Do You Reduce It?] | Brent Ozar | 2013-08-27 | | -| [New indexes, hypothetically] | Kenneth Fisher | 2016-11-02 | [BIDX] | -| [Indexing Wide Keys in SQL Server] | Brent Ozar | 2013-05-08 | [BIDX] | -| [The Anatomy and (In)Security of Microsoft SQL Server Transparent Data Encryption (TDE), or How to Break TDE] | Simon McAuliffe | 2016-03-31 | | +| [New indexes, hypothetically] | Kenneth Fisher | 2016-11-02 | [IDX] | +| [Indexing Wide Keys in SQL Server] | Brent Ozar | 2013-05-08 | [IDX] | +| [The Anatomy and (In)Security of Microsoft SQL Server Transparent Data Encryption (TDE), or How to Break TDE] | Simon McAuliffe | 2016-03-31 | [SEC] | | [Correctly adding data files to tempdb] | Paul Randal | 2014-10-14 | | | [Why You Should Test Your Queries Against Bigger Data] | Erik Darling | 2016-11-01 | | | [Tally OH! An Improved SQL 8K “CSV Splitter” Function] | Jeff Moden | 2012-12-28 | | @@ -143,20 +145,19 @@ Articles types: | [Measuring Query Duration: SSMS vs SQL Sentry Plan Explorer] | Kendra Little | 2016-09-27 | | | [Inside the Statistics Histogram & Density Vector] | Klaus Aschenbrenner | 2014-01-28 | | | [Misconceptions on parameter sniffing] | Hugo Kornelis | 2016-11-03 | | -| [CAST vs. CONVERT] | Aaron Bertrand | 2016-11-02 | | -| [What Every Accidental DBA Needs to Know Now: Basics of SQL Security] | Tim Ford | 2016-10-03 | | +| [What Every Accidental DBA Needs to Know Now: Basics of SQL Security] | Tim Ford | 2016-10-03 | [SEC] | | [SQL Server Perfmon (Performance Monitor) Best Practices] | Brent Ozar | 2006-12-30 | | -| [Top 5 Overlooked Index Features] | Erik Darling | 2016-11-10 | [BIDX] | +| [Top 5 Overlooked Index Features] | Erik Darling | 2016-11-10 | [IDX] | | [A Sysadmin’s Guide to Microsoft SQL Server Memory] | Brent Ozar | 2016-09-15 | | | [Searching Strings in SQL Server is Expensive] | Brent Ozar | 2016-10-18 | | | [Altering an INT Column to a BIGINT] | Kendra Little | 2016-08-04 | | | [Query tuning 101: Problems with IN ()] | Daniel Janik | 2016-11-10 | | | [Admin: Bulkadmin vs ADMINISTER BULK OPERATIONS] | Richard A Brown | 2012-01-31 | | -| [Can Indexes My Query Doesn’t Use Help My Query?] | Erik Darling | 2016-11-09 | [BIDX] | +| [Can Indexes My Query Doesn’t Use Help My Query?] | Erik Darling | 2016-11-09 | [IDX] | | [SQL Server Audit Walkthrough] | Sadequl Hussain | 2016-01-01 | | -| [The SQL Server 2016 Query Store: Overview and Architecture] | Enrico van de Laar | 2015-11-16 | | +| [The SQL Server 2016 Query Store: Overview and Architecture] | Enrico van de Laar | 2015-11-16 | [QS] | | [Reading, Writing, and Creating SQL Server Extended Properties] | Phil Factor | 2015-10-21 | [XE] | -| [Questions About SQL Server Security and Access Control You Were Too Shy to Ask] | William Brewer | 2016-11-04 | | +| [Questions About SQL Server Security and Access Control You Were Too Shy to Ask] | William Brewer | 2016-11-04 | [SEC] | | [The Ten Commandments of SQL Server Monitoring] | Adam Machanic | 2013-04-09 | | | [Should I use NOT IN, OUTER APPLY, LEFT OUTER JOIN, EXCEPT, or NOT EXISTS?] | Adam Machanic | 2012-12-27 | | | [Parameter Sniffing, Embedding, and the RECOMPILE Options] | Paul White | 2013-08-28 | | @@ -164,7 +165,7 @@ Articles types: | [SQL Server Temporary Table Caching] | Simon Liew | 2016-08-12 | | | [Techniques to Monitor SQL Server memory usage] | Basit Farooq | 2016-08-01 | | | [Troubleshooting Query Regressions Caused By The New Cardinality Estimator] | SQL Scotsman | 2016-11-28 | | -| [Migrating Databases to Azure SQL Database] | Tim Radney | 2016-10-25 | [MG],[AZ] | +| [Migrating Databases to Azure SQL Database] | Tim Radney | 2016-10-25 | [AZ][MG] | | [Solve Common SQL Server Restore Issues] | Sergey Gigoyan | 2015-04-12 | | | [Spills SQL Server Doesn’t Warn You About] | Erik Darling | 2016-11-30 | | | [How often should I run DBCC CHECKDB?] | Erik Darling | 2016-02-25 | | @@ -172,13 +173,13 @@ Articles types: | [Downgrading the SQL Server Edition of a Dev Environment] | Kendra Little | 2016-11-15 | | | [Date Math In The WHERE Clause] | Erik Darling | 2016-12-01 | | | [Why is This Partitioned Query Slower?] | Kendra Little | 2015-09-01 | | -| [A Beginner’s Guide to the True Order of SQL Operations] | JOOQ | 2016-12-09 | | +| [A Beginner’s Guide to the True Order of SQL Operations] | Lukas Eder | 2016-12-09 | | | [Logical Query Processing: What It Is And What It Means to You] | Itzik Ben-Gan | 2016-01-15 | | | [Forcing a Parallel Query Execution Plan] | Paul White | 2011-12-23 | | | [Join Containment Assumption and CE Model Variation] | Dmitri Pilugin | 2014-05-04 | | | [Table Variable Tip] | Itzik Ben-Gan | 2015-02-08 | | | [Heap tables in SQL Server] | Derik Hammer | 2016-04-13 | | -| [The ‘B’ in B-Tree – Indexing in SQL Server] | Derik Hammer | 2016-04-04 | [BIDX] | +| [The ‘B’ in B-Tree – Indexing in SQL Server] | Derik Hammer | 2016-04-04 | [IDX] | | [How to read the SQL Server Database Transaction Log] | Manvendra Singh | 2013-10-31 | | | [Filtered Statistics Follow-up] | Erik Darling | 2016-12-22 | | | [SQL Server Query Optimization: No Unknown Unknowns] | Itzik Ben-Gan | 2015-10-13 | | @@ -187,7 +188,7 @@ Articles types: | [Troubleshooting SQL Server backup and restore operations] | Microsoft | 2016-07-23 | [B] | | [SQL Server 2016: Getting tempdb a little more right] | Aaron Bertrand | 2015-09-30 | | | [Practical uses of binary types] | Daniel Hutmacher | 2017-01-09 | | -| [Backing Up SQL Server Databases is Easier in PowerShell than T-SQL] | Aaron Nelson | 2017-01-12 | | +| [Backing Up SQL Server Databases is Easier in PowerShell than T-SQL] | Aaron Nelson | 2017-01-12 | [PS] | | [Creating, detaching, re-attaching, and fixing a SUSPECT database] | Paul Randal | 2008-08-29 | | | [Modifying Tables Online – Part 1: Migration Strategy] | Michael J Swart | 2012-04-16 | [MG] | | [Modifying Tables Online – Part 2: Implementation Example] | Michael J Swart | 2012-04-17 | [MG] | @@ -203,15 +204,15 @@ Articles types: | [Avoid Unnecessary Lookups when Using ROW_NUMBER for Paging] | Itzik Ben-Gan | 2014-12-11 | | | [Migrating a Disk-Based Table to a Memory-Optimized Table in SQL Server] | Alex Grinberg | 2017-02-26 | [MG] | | [SQL Server Hardware Optimization] | Basit Farooq | 2016-06-01 | | -| [Index Types Heaps, Primary Keys, Clustered and Nonclustered Indexes] | Kendra Little | 2017-02-02 | [BIDX] | +| [Index Types Heaps, Primary Keys, Clustered and Nonclustered Indexes] | Kendra Little | 2017-02-02 | [IDX] | | [Identifying Existence of Intersections in Intervals] | Itzik Ben-Gan | 2017-02-08 | | | [Cheat Sheet How to Configure TempDB for Microsoft SQL Server] | Brent Ozar | 2016-01-14 | | | [A Tourist’s Guide to the sp_Blitz Source Code, Part 1: The Big Picture] | Brent Ozar | 2017-02-09 | | | [SQL Server Default Configurations That You Should Change] | Pio Balistoy | 2017-02-06 | | | [Decoding Key and Page WaitResource for Deadlocks and Blocking] | Kendra Little | 2016-10-17 | | -| [Security in the CLR World Inside SQL Server] | Kiely Don | 1990-01-01 | | +| [Security in the CLR World Inside SQL Server] | Kiely Don | 1990-01-01 | [CLR][SEC] | | [On the Advantages of DateTime2(n) over DateTime] | William Assaf | 2012-12-04 | | -| [Build Your Own Tools] | Michael J. Swart | 2016-09-23 | | +| [Build Your Own Tools] | Michael J Swart | 2016-09-23 | | | [Enhanced T-SQL Error Handling With Extended Events] | Dave Mason | 2016-09-14 | [XE] | | [Compression and its Effects on Performance] | Erin Stellato | 2017-01-20 | | | [Does Truncate Table Reset Statistics] | Kendra Little | 2016-12-08 | | @@ -228,21 +229,20 @@ Articles types: | [SQLskills SQL101: Dealing with SQL Server corruption] | Paul Randal | 2017-02-28 | [COR] | | [Advanced Analytics with R & SQL: Part I - R Distributions] | Frank A. Banin | 2016-10-31 | [R] | | [T-SQL Tuesday #85 STOP! Restore Time!] | Derik Hammer | 2016-12-13 | | -| [Filtered Indexes: Rowstore vs Nonclustered Columnstore] | Kendra Little | 2016-11-10 | [BIDX] | +| [Filtered Indexes: Rowstore vs Nonclustered Columnstore] | Kendra Little | 2016-11-10 | [IDX] | | [ALTER SCHEMA TRANSFER for Zero Downtime Database Upgrades] | Dave Wentzel | 2013-05-21 | | | [Delayed Durability in SQL Server 2014] | Aaron Bertrand | 2014-04-28 | | | [Daylight Savings end affects not only you, but your SQL Server too] | Aaron Bertrand | 2014-04-28 | | -| [Searching Strings in SQL Server is Expensive] | Brent Ozar | 2016-10-18 | | -| [Let’s Corrupt a SQL Server Database Together, Part 1: Clustered Indexes] | Brent Ozar | 2017-02-22 | [COR][BIDX] | -| [Let’s Corrupt a Database Together, Part 2: Nonclustered Indexes] | Brent Ozar | 2017-02-28 | [COR][BIDX] | +| [Let’s Corrupt a SQL Server Database Together, Part 1: Clustered Indexes] | Brent Ozar | 2017-02-22 | [COR][IDX] | +| [Let’s Corrupt a Database Together, Part 2: Nonclustered Indexes] | Brent Ozar | 2017-02-28 | [COR][IDX] | | [The Guide SQL Server Installation Checklist (settings that increase SQL Server Performance)] | Mark Varnas | 2017-03-03 | | | [SQL Browser, what is it good for? Absolutely something!] | Chris Sommer | 2017-03-01 | | | [PowerShell Getting More From Generic Error Messages] | Shane O'Neill | 2017-03-02 | [PS] | | [#BackToBasics : Common Table Expressions (CTEs)] | Aaron Bertrand | 2016-01-06 | | | [SQL VNext sp_configure on Windows and Linux with dbatools] | Rob Sewell | 2017-03-02 | [PS] | -| [Adding a T-SQL Job Step to a SQL Agent Job with PowerShell] | Rob Sewell | 2017-02-20 | [PS],[J] | +| [Adding a T-SQL Job Step to a SQL Agent Job with PowerShell] | Rob Sewell | 2017-02-20 | [PS][J] | | [Setting up Database Mail to use my Gmail account] | Mat Hayward | 2017-03-01 | [DM] | -| [Using DBCC CLONEDATABASE and Query Store for Testing] | Erin Stellato | 2017-02-22 | [DBCC] | +| [Using DBCC CLONEDATABASE and Query Store for Testing] | Erin Stellato | 2017-02-22 | [DBCC][QS] | | [Getting Started with Natural Earth — A SQL Server Shapefile Alternative (Geospatial Resource)] | Jeff Pries | 2017-02-17 | [V] | | [SQL Server Temporal Tables: How-To Recipes] | Alex Grinberg | 2017-02-10 | [DEV] | | [The Migration Checklist] | Steve Jones | 2017-03-08 | [MG] | @@ -251,9 +251,8 @@ Articles types: | [Representing Hierarchical Data for Mere Mortals] | Phil Factor | 2016-10-06 | [DEV] | | [KPIs For DBAs to Show Their CIOs] | Thomas Larock | 2017-03-08 | [DBA] | | [How To Forecast Database Disk Capacity If You Don’t Have A Monitoring Tool] | Edwin M Sarmiento | 2015-07-31 | [DBA] | -| [Statistical Sampling for Verifying Database Backups] | Thomas Larock | 2010-05-13 | [DBA],[B] | -| [Inside The Storage Engine GAM, SGAM, PFS and other allocation maps] | Paul Randal | 2008-03-04 | [DBA] | -| [Using dbatools for automated restore and CHECKDB] | Anthony Nocentino | 2017-03-04 | [DBA],[PS] | +| [Statistical Sampling for Verifying Database Backups] | Thomas Larock | 2010-05-13 | [B][DBA] | +| [Using dbatools for automated restore and CHECKDB] | Anthony Nocentino | 2017-03-04 | [DBA][PS] | | [Bad Habits Revival] | Aaron Bertrand | 2017-01-26 | [DBA] | | [Deploying Multiple SSIS Projects via PowerShell] | Nat Sundar | 2017-02-27 | [SSIS,][PS] | | [Determining the Cost Threshold for Parallelism] | Grant Fritchey | 2017-02-28 | [DBA] | @@ -262,17 +261,17 @@ Articles types: | [Why PFS pages cannot be repaired] | Paul Randal | 2017-03-05 | [DBA] | | [ERRORLOG records max out at 2049 characters] | Cody Konior | 2017-03-02 | [DEV] | | [How to Build a SQL Server Disaster Recovery Plan with Google Compute Engine] | Tara Kizer | 2017-03-10 | [DBA] | -| [SQL Server Performance Tuning in Google Compute Engine] | Erik Darling | 2017-03-09 | [DBA],[P] | -| [Configuring R on SQL Server 2016] | Ginger Grant | 2016-12-06 | [DBA],[R] | -| [Knee-Jerk PerfMon Counters: Page Life Expectancy] | Paul Randal | 2014-10-20 | [DBA],[P] | +| [SQL Server Performance Tuning in Google Compute Engine] | Erik Darling | 2017-03-09 | [DBA][P] | +| [Configuring R on SQL Server 2016] | Ginger Grant | 2016-12-06 | [DBA][R] | +| [Knee-Jerk PerfMon Counters: Page Life Expectancy] | Paul Randal | 2014-10-20 | [DBA][P] | | [Change Management Template for SQL Server DBAs and Developers] | Kendra Little | 2016-04-12 | [DBA] | -| [Performance Myths: Clustered vs. Non-Clustered Indexes] | Aaron Bertrand | 2017-03-17 | [BIDX] | +| [Performance Myths: Clustered vs. Non-Clustered Indexes] | Aaron Bertrand | 2017-03-17 | [IDX] | | [Bad habits: Counting rows the hard way] | Aaron Bertrand | 2014-10-30 | [DEV] | | [Why Cost Threshold For Parallelism Shouldn’t Be Set To 5] | Erik Darling | 2017-03-14 | [DBA] | | [Join Performance, Implicit Conversions, and Residuals] | Paul White | 2011-07-18 | [DEV] | | [Implicit Conversions that cause Index Scans] | Jonathan Kehayias | 2011-04-11 | [DEV] | | [When Is It Appropriate To Store JSON in SQL Server?] | Bert Wagner | 2017-03-14 | [DEV] | -| [The Performance Penalty of Bookmark Lookups in SQL Server] | Klaus Aschenbrenner | 2017-03-17 | [BIDX] | +| [The Performance Penalty of Bookmark Lookups in SQL Server] | Klaus Aschenbrenner | 2017-03-17 | [IDX] | | [Why You Should Change the Cost Threshold for Parallelism] | Grant Fritchey | 2017-03-13 | [DBA] | | [Why Update Statistics can cause an IO storm] | Kendra Little | 2014-01-29 | [DBA] | | [SQLskills SQL101 Temporary table misuse] | Paul White | 2017-03-13 | [DEV] | @@ -296,12 +295,12 @@ Articles types: | [Resolving Key Lookup Deadlocks with Plan Explorer] | Greg Gonzalez | 2017-03-21 | [DEV] | | [Why ROWLOCK Hints Can Make Queries Slower and Blocking Worse in SQL Server] | Kendra Little | 2016-02-04 | [DEV] | | [Does a Clustered Index really physically store the rows in key order] | Wayne Sheffield | 2012-10-21 | [DEV] | -| [Ugly Pragmatism For The Win] | Michael J. Swart | 2016-02-11 | [DEV] | +| [Ugly Pragmatism For The Win] | Michael J Swart | 2016-02-11 | [DEV] | | [Architecting Microsoft SQL Server on VMware vSphere] | Niran Even-Chen | 2017-03-15 | [DBA] | | [Hiding tables in SSMS Object Explorer] | Kenneth Fisher | 2017-04-03 | [DEV] | | [Clustered columnstore: on-disk vs. in-mem] | Ned Otter | 2017-03-21 | [DBA] | | [Generating Plots Automatically From PowerShell and SQL Server Using Gnuplot] | Phil Factor | 2017-03-27 | [DEV] | -| [How to Benchmark Alternative SQL Queries to Find the Fastest Query] | Luka Seder | 2017-03-29 | [DEV] | +| [How to Benchmark Alternative SQL Queries to Find the Fastest Query] | Luka Seder | 2017-03-29 | [BENCH] | | [Checking for Strange Client Settings with sys.dm_exec_sessions] | Brent Ozar | 2017-03-31 | [DEV] | | [Decrypting Insert Query Plans] | Eric Darling | 2017-03-30 | [DEV] | | [SQLskills SQL101: Partitioning] | Kimberly Tripp | 2017-03-27 | [DBA] | @@ -311,16 +310,14 @@ Articles types: | [Hack-Attaching a SQL Server database with NORECOVERY] | Argenis Fernandez | 2016-01-24 | [DBA] | | [Switch in Staging Tables Instead of sp_rename] | Kendra Little | 2017-01-19 | [DBA] | | [Performance Myths: Table variables are always in-memory] | Derik Hammer | 2017-04-04 | [DEV] | -| [Questions About SQL Server Collations You Were Too Shy to Ask] | Robert Sheldon | 2017-04-06 | [DBA],[DEV] | +| [Questions About SQL Server Collations You Were Too Shy to Ask] | Robert Sheldon | 2017-04-06 | [DBA][DEV] | | [NULL - The database's black hole] | Hugo Kornelis | 2007-07-06 | [DEV] | -| [Inside the Storage Engine: Using DBCC PAGE and DBCC IND to find out if page splits ever roll back] | Paul Randal | 2007-10-01 | [DEV] | -| [Inside the Storage Engine: Anatomy of a page] | Paul Randal | 2007-10-03 | [DEV] | | [For The Better Developer: SQL Server Indexes] | Davide Mauri | 2017-04-02 | [DEV] | | [#EntryLevel: Compression & Data Types] | Melissa Connors | 2016-04-17 | [DEV] | | [Cardinality Estimation for a Predicate on a COUNT Expression] | Paul White | 2017-04-12 | [DEV] | | [Changing SQL Server Collation After Installation] | Douglas P. Castilho | 2015-02-19 | [DBA] | | [Does a TempDB spill mean statistics are out of date?] | Brent Ozar | 2017-04-12 | [DEV] | -| [Transaction log growth during BACKUP] | Andy Mallon | 2017-04-10 | [DBA] | +| [Transaction log growth during BACKUP] | Andy Mallon | 2017-04-10 | [B][DBA] | | [When is a SQL function not a function?] | Rob Farley | 2011-11-08 | [DEV] | | [Introducing Batch Mode Adaptive Joins] | Joseph Sack | 2017-04-19 | [DEV] | | [Investigating the proportional fill algorithm] | Paul Randal | 2016-10-04 | [DBA] | @@ -332,172 +329,1169 @@ Articles types: | [Disabling ROW and PAGE Level Locks in SQL Server] | Klaus Aschenbrenner | 2016-10-31 | [DEV] | | [Fixing Cardinality Estimation Errors with Filtered Statistics] | Klaus Aschenbrenner | 2013-10-29 | [DEV] | | [Cardinality Estimation for Multiple Predicates] | Paul Randal | 2014-01-15 | [DEV] | -| [Weaning yourself off of SQL Profiler (Part 1)] | Wayne Sheffield | 2017-04-19 | [DBA],[DEV] | +| [Weaning yourself off of SQL Profiler (Part 1)] | Wayne Sheffield | 2017-04-19 | [DBA][DEV] | | [Properly Persisted Computed Columns] | Paul White | 2017-05-25 | [DEV] | | [A SQL Server DBA myth a day: (17/30) page checksums] | Paul Randal | 2010-04-17 | [DBA] | | [What are different ways to replace ISNULL() in a WHERE clause that uses only literal values?] | Eric Darling | 2017-05-27 | [DEV] | -| [Weaning yourself off of SQL Profiler (Part 1)] | Wayne Sheffield | 2017-04-19 | [DEV] | -| [SQL Server 2016 enhancements – Truncate Table and Table Partitioning] | Prashanth Jayaram | 2017-04-18 | [DBA],[DEV] | +| [SQL Server 2016 enhancements – Truncate Table and Table Partitioning] | Prashanth Jayaram | 2017-04-18 | [DBA][DEV] | | [SQL Server Mysteries: The Case of the Not 100% RESTORE…] | Bob Ward | 2017-04-21 | [DBA] | | [Transactional Replication and Stored Procedure Execution: Silver Bullet or Poison Pill?] | Drew Furgiuele | 2017-04-11 | [DBA] | -| [STOPAT And Date Formats] | Dave Mason | 2017-07-12 | [DBA],[XE] | +| [STOPAT And Date Formats] | Dave Mason | 2017-07-12 | [DBA][XE] | | [Row-count Estimates when there are no Statistics] | Matthew McGiffen | 2017-06-28 | [DEV] | | [SQL Server DBA On-Boarding Checklist] | Svetlana Golovko | 2017-06-20 | [DBA] | | [Be Wary of Date Formatting in T-SQL] | Randolph West | 2017-07-12 | [DEV] | -| [The ultimate guide to the datetime datatypes] | Tibor Karaszi | 2010-01-01 | [DEV] | | [Statistics and Cardinality Estimation] | Matthew McGiffen | 2017-06-20 | [DEV] | | [Message queues for the DBA: sending data out into the world] | Drew Furgiuele | 2017-07-21 | [DBA] | | [Schema-Based Access Control for SQL Server Databases] | Phil Factor | 2017-04-09 | [DBA] | | [SQL Server: large RAM and DB Checkpointing] | Guillaume Fourrat | 2017-06-29 | [DBA] | -| [Handling SQL Server Deadlocks With Event Notifications] | Dave Mason | 2017-07-17 | [R],[XE] | -| [SQL Server R Services: Digging into the R Language] | Robert Sheldon | 2017-06-29 | [DBA],[DEV] | +| [Handling SQL Server Deadlocks With Event Notifications] | Dave Mason | 2017-07-17 | [R][XE] | +| [SQL Server R Services: Digging into the R Language] | Robert Sheldon | 2017-06-29 | [DBA][DEV] | | [Investigating the Cause of SQL Server High CPU Load Conditions When They Happen] | Laerte Junior | 2017-07-17 | [DBA] | | [In-Memory Engine DURABILITY = SCHEMA_ONLY And Transaction Rollback] | Chris Adkin | 2017-07-17 | [DEV] | -| [Builder Day: Doing a Point-in-Time Restore in Azure SQL DB] | Brent Ozar | 2017-06-20 | [DBA],[AZ] | +| [Builder Day: Doing a Point-in-Time Restore in Azure SQL DB] | Brent Ozar | 2017-06-20 | [DBA][AZ] | | [Creating Continuous Integration Build Pipelines With Jenkins, Docker and SQL Server] | Chris Adkin | 2017-07-18 | [DBA] | | [Scale-able Windows Aggregate Functions With Row Store Object] | Chris Adkin | 2017-07-24 | [DEV] | -| [Azure DWH part 11: Data Warehouse Migration Utility] | Daniel Calbimonte | 2017-07-17 | [DBA], [AZ] | +| [Azure DWH part 11: Data Warehouse Migration Utility] | Daniel Calbimonte | 2017-07-17 | [AZ][MG] | | [Representing a simple hierarchical list in SQL Server with JSON, YAML, XML and HTML] | William Brewer | 2017-07-18 | [DEV], [X] | | [Advanced Analytics with R and SQL Part II - Data Science Scenarios] | Frank A. Banin | 2017-07-27 | [DEV], [R] | | [Think twice before using table variables] | Matthew McGiffen | 2017-07-11 | [DEV] | | [ColumnStore Indexes And Recursive CTEs] | Erik Darling | 2017-07-27 | [DEV] | | [CCIs and String Aggregation] | Joe Obbish | 2017-07-03 | [DEV] | | [Brad’s Sure DBA Checklist] | Brad McGehee | 2010-01-20 | [DBA] | -| [Query Store and Parameterization Problems] | Dennes Torres | 2017-07-06 | [DEV] | -| [SQL Server Event Handling: Event Notifications] | Dave Mason | 2016-11-30 | [DBA],[XE] | -| [Identifying Deprecated Feature Usage (Part 1)] | Dave Mason | 2017-07-20 | [DBA],[XE] | -| [Let’s Corrupt a Database Together, Part 3: Detecting Corruption] | Brent Ozar | 2017-07-25 | [DBA],[COR] | -| [XML vs JSON Shootout: Which is Superior in SQL Server 2016?] | Bert Wagner | 2017-05-16 | [DEV],[X] | -| [One SQL Cheat Code For Amazingly Fast JSON Queries] | Bert Wagner | 2017-05-09 | [DEV],[X] | -| [The Ultimate SQL Server JSON Cheat Sheet] | Bert Wagner | 2017-03-07 | [DEV],[X] | +| [Query Store and Parameterization Problems] | Dennes Torres | 2017-07-06 | [QS] | +| [SQL Server Event Handling: Event Notifications] | Dave Mason | 2016-11-30 | [DBA][XE] | +| [Identifying Deprecated Feature Usage (Part 1)] | Dave Mason | 2017-07-20 | [DBA][XE] | +| [Let’s Corrupt a Database Together, Part 3: Detecting Corruption] | Brent Ozar | 2017-07-25 | [DBA][COR] | +| [XML vs JSON Shootout: Which is Superior in SQL Server 2016?] | Bert Wagner | 2017-05-16 | [DEV][X] | +| [One SQL Cheat Code For Amazingly Fast JSON Queries] | Bert Wagner | 2017-05-09 | [DEV][X] | +| [The Ultimate SQL Server JSON Cheat Sheet] | Bert Wagner | 2017-03-07 | [DEV][X] | | [Are your indexes being thwarted by mismatched datatypes?] | Bert Wagner | 2017-08-01 | [DEV] | -| [Why Missing Index Recommendations Aren’t Perfect] | Brent Ozar | 2017-08-02 | [DBA],[DEV] | -| [Top 5 Misleading SQL Server Performance Counters] | Kendra Little | 2017-06-05 | [DBA],[DEV] | +| [Why Missing Index Recommendations Aren’t Perfect] | Brent Ozar | 2017-08-02 | [DBA][DEV] | | [The Case of the Space at the End] | Adam St. Pierre | 2017-07-24 | [DEV] | | [SELECT…INTO in SQL Server 2017] | Andrew Pruski | 2017-08-02 | [DEV] | | [Your Service Level Agreement is a Disaster] | Jennifer McCown | 2017-07-24 | [DBA] | | [SQLskills SQL101: REBUILD vs. REORGANIZE] | Paul Randal | 2017-08-03 | [DBA] | | [Where do the Books Online index fragmentation thresholds come from?] | Paul Randal | 2009-12-08 | [DBA] | -| [The SQL Hall of Shame] | Adam Machanic | 2017-06-14 | [DBA],[DEV] | +| [The SQL Hall of Shame] | Adam Machanic | 2017-06-14 | [DBA][DEV] | | [A Better Way To Select Star] | Erik Darling | 2017-07-05 | [DEV] | | [UDP vs TCP] | Kenneth Fisher | 2017-06-07 | [DBA] | -| [When a Nonclustered Index and Statistics Make a Query Slower] | Kendra Little | 2017-03-24 | [DBA],[DEV] | | [Lipoaspiration in your SQL Server Database] | Fabiano Amorim | 2011-03-03 | [DEV] | -| [13 Things You Should Know About Statistics and the Query Optimizer] | Fabiano Amorim | 2010-01-07 | [DBA],[DEV] | -| [Creating R Stored Procedures in SQL Server 2016 Using sqlrutils] | Niels Berglund | 2017-06-25 | [DEV],[R] | +| [13 Things You Should Know About Statistics and the Query Optimizer] | Fabiano Amorim | 2010-01-07 | [DBA][DEV] | +| [Creating R Stored Procedures in SQL Server 2016 Using sqlrutils] | Niels Berglund | 2017-06-25 | [DEV][R] | | [A Quick start Guide to Managing SQL Server 2017 on CentOS/RHEL Using the SSH Protocol] | Prashanth Jayaram | 2017-08-08 | [DEV] | | [SQL Server v.Next : STRING_AGG Performance, Part 2] | Aaron Bertrand | 2017-01-06 | [DEV] | -| [Why Parameter Sniffing Is Making Your Queries Receive Sub-Optimal Execution Plans] | Bert Wagner | 2017-08-08 | [DEV] | +| [Why Parameter Sniffing Isn’t Always A Bad Thing (But Usually Is)] | Bert Wagner | 2017-08-08 | [DEV] | | [Persisting statistics sampling rate] | Pedro Lopes | 2017-08-11 | [DBA] | -| [All about locking in SQL Server] | Nikola Dimitrijevic | 2017-06-16 | [DBA],[DEV] | -| [All about Latches in SQL Server] | Nikola Dimitrijevic | 2017-08-10 | [DBA],[DEV] | -| [All about SQL Server spinlocks] | Nikola Dimitrijevic | 2017-08-23 | [DBA],[DEV] | -| [How to monitor object space growth in SQL Server] | Jefferson Elias | 2017-08-16 | [DBA],[DEV] | -| [How to Read a Transaction Log Backup] | Greg Larsen | 2017-07-03 | [DBA] | +| [All about locking in SQL Server] | Nikola Dimitrijevic | 2017-06-16 | [DBA][DEV] | +| [All about Latches in SQL Server] | Nikola Dimitrijevic | 2017-08-10 | [DBA][DEV] | +| [All about SQL Server spinlocks] | Nikola Dimitrijevic | 2017-08-23 | [DBA][DEV] | +| [How to monitor object space growth in SQL Server] | Jefferson Elias | 2017-08-16 | [DBA][DEV] | +| [How to Read a Transaction Log Backup] | Greg Larsen | 2017-07-03 | [B][DBA] | | [How to Find Out Which Database Object Got Deleted] | Greg Larsen | 2017-07-03 | [DBA] | -| [In-Memory OLTP Enhancements in SQL Server 2016] | Ahmad Yaseen | 2017-08-22 | [DBA],[DEV] | -| [Sync SQL Logins and Jobs] | Ryan J. Adams | 2017-08-21 | [DBA] | -| [The Trillion Row Table] | Joe Obbish | 2017-08-16 | [DEV] | +| [In-Memory OLTP Enhancements in SQL Server 2016] | Ahmad Yaseen | 2017-08-22 | [DBA][DEV] | +| [Sync SQL Logins and Jobs] | Ryan J. Adams | 2017-08-21 | [DBA][J] | +| [The Trillion Row Table] | Joe Obbish | 2017-08-16 | [BENCH] | | [Dynamic Data Unmasking] | Joe Obbish | 2017-08-25 | [DEV] | | [Why is My Database Application so Slow?] | Dan Turner | 2017-08-24 | [DEV] | -| [Generating Concurrent Activity] | Michael J Swart | 2017-01-23 | [DBA],[DEV] | +| [Generating Concurrent Activity] | Michael J Swart | 2017-01-23 | [DBA][DEV] | | [Required Testing for Installing SQL Server Cumulative Updates and Service Packs] | Kendra Little | 2017-04-28 | [DBA] | -| [Microsoft SQL Server R Services - Internals X] | Niels Berglund | 2017-08-29 | [DEV],[R] | -| [Clustered columnstore: on-disk vs. in-mem] | Ned Otter | 2017-08-29 | [DBA],[DEV] | -| [Hands on Full-Text Search in SQL Server] | Jefferson Elias | 2017-08-25 | [DBA],[DEV] | -| [SQL Code Smells] | Phil Factor | 2017-08-31 | [DBA],[DEV] | -| [Corruption demo databases and scripts] | Paul Randal | 2013-01-08 | [DBA],[COR] | -| [Understanding Cross-Database Transactions in SQL Server] | Grahaeme Ross | 2015-04-11 | [DBA],[DEV] | -| [Optional Parameters and Missing Index Requests] | Brent OZar | 2017-09-14 | [DBA],[DEV] | -| [Uniquifier is a rather unique word isn’t it?] | Kenneth Fisher | 2017-09-18 | [DBA],[DEV] | +| [Microsoft SQL Server R Services - Internals X] | Niels Berglund | 2017-08-29 | [DEV][R] | +| [Clustered columnstore: on-disk vs. in-mem] | Ned Otter | 2017-08-29 | [DBA][DEV] | +| [Hands on Full-Text Search in SQL Server] | Jefferson Elias | 2017-08-25 | [DBA][DEV] | +| [SQL Code Smells] | Phil Factor | 2017-08-31 | [DBA][DEV] | +| [Corruption demo databases and scripts] | Paul Randal | 2013-01-08 | [DBA][COR] | +| [Understanding Cross-Database Transactions in SQL Server] | Grahaeme Ross | 2015-04-11 | [DBA][DEV] | +| [Optional Parameters and Missing Index Requests] | Brent OZar | 2017-09-14 | [DBA][DEV] | +| [Uniquifier is a rather unique word isn’t it?] | Kenneth Fisher | 2017-09-18 | [DBA][DEV] | | [Importance of proper transaction log size management] | Paul Randal | 2009-04-10 | [DEV] | -| [#TSQL2sDay – Starting Out with PowerShell] | Rob Sewell | 2017-09-12 | [DBA],[PS] | +| [#TSQL2sDay – Starting Out with PowerShell] | Rob Sewell | 2017-09-12 | [DBA][PS] | | [Using native compilation to insert parent/child tables] | Ned Otter | 2017-09-11 | [DEV] | | [Questions About RDS SQL Server You Were Too Shy to Ask] | Laerte Junior | 2017-09-13 | [DEV] | | [Active Directory Authentication with SQL Server on Ubuntu] | Drew Furgiuele | 2017-09-19 | [DBA] | | [Temporary Tables in Stored Procedures] | Paul Randal | 2012-08-15 | [DEV] | -| [SQLCLR in Practice: Creating a Better Way of Sending Email from SQL Server] | Darko Martinović | 2017-07-17 | [DEV] | -| [T-SQL commands performance comparison – NOT IN vs NOT EXISTS vs LEFT JOIN vs EXCEPT] | Ahmad Yaseen | 2017-09-22 | [DBA],[DEV] | -| [Clustered vs Nonclustered: Index Fundamentals You Need To Know] | Bert Wagner | 2017-09-26 | [DBA],[DEV] | -| [How to Write Efficient TOP N Queries in SQL] | JOOQ | 2017-09-22 | [DEV] | +| [SQLCLR in Practice: Creating a Better Way of Sending Email from SQL Server] | Darko Martinović | 2017-07-17 | [CLR] | +| [T-SQL commands performance comparison – NOT IN vs NOT EXISTS vs LEFT JOIN vs EXCEPT] | Ahmad Yaseen | 2017-09-22 | [DBA][DEV] | +| [Clustered vs Nonclustered: Index Fundamentals You Need To Know] | Bert Wagner | 2017-09-26 | [DBA][DEV] | +| [How to Write Efficient TOP N Queries in SQL] | Lukas Eder | 2017-09-22 | [DEV] | | [Checklist: DR Plan Sanity Check] | Robert Davis | 2017-09-04 | [DBA] | | [Table level recovery for selected SQL Server tables] | Tibor Nagy | 2012-11-30 | [DEV] | -| [SQL Mirroring, Preserving the Log Chain During Database Migrations] | SQL Undercover | 2017-01-21 | [DBA] | +| [SQL Mirroring, Preserving the Log Chain During Database Migrations] | SQL Undercover | 2017-01-21 | [DBA][MG] | | [How NOLOCK Will Block Your Queries] | Bert Wagner | 2017-10-10 | [DEV] | -| [8 Ways to Export SQL Results To a Text File] | Daniel Calbimonte | 2017-10-06 | [DBA],[DEV] | -| [SQL Server Installation Failed Due to Pending Restart of Server?] | thelonedba | 2017-09-18 | [DBA],[DEV] | +| [8 Ways to Export SQL Results To a Text File] | Daniel Calbimonte | 2017-10-06 | [DBA][DEV] | +| [SQL Server Installation Failed Due to Pending Restart of Server?] | thelonedba | 2017-09-18 | [DBA][DEV] | | [Six Scary SQL Surprises] | Brent Ozar | 2017-09-06 | [DEV] | | [How the rowversion datatype works when adding and deleting columns] | Louis Davidson | 2017-09-26 | [DEV] | | [Quick! What's the difference between RANK, DENSE_RANK, and ROW_NUMBER?] | Douglas Kline | 2017-10-01 | [DEV] | | [A Serial Parallel Query] | Joe Obbish | 2017-10-20 | [DEV] | -| [Add or Remove IDENTITY Property From an Existing Column Efficiently] | Dan Guzman | 2017-04-16 | [DBA],[DEV] | +| [Add or Remove IDENTITY Property From an Existing Column Efficiently] | Dan Guzman | 2017-04-16 | [DBA][DEV] | | [How Do I Analyze a SQL Server Execution Plan?] | Kendra Little | 2017-09-22 | [DEV] | | [A Subtle Difference Between COALESCE and ISNULL] | Shaneis | 2017-10-09 | [DEV] | | [Puzzle Challenge: Graph Matching with T-SQL Part 1-Concepts] | Itzik Ben-Gan | 2017-08-08 | [DEV] | | [Graph Matching with T-SQL Part 3: Maximum Matching] | Itzik Ben-Gan | 2017-10-12 | [DEV] | | [Running PowerShell in a SQL Agent Job] | Derik Hammer | 2017-03-04 | [PS] | | [Line-Continuation in T-SQL] | Solomon Rutzky | 2017-10-27 | [DEV] | -| [SQL Server 2017: Making Backups Great Again!] | John Sterrett | 2017-10-31 | [DBA],[DEV] | -| [Say NO to Venn Diagrams When Explaining JOINs] | JOOQ | 2016-07-05 | [DBA],[DEV] | +| [SQL Server 2017: Making Backups Great Again!] | John Sterrett | 2017-10-31 | [B][DBA] | +| [Say NO to Venn Diagrams When Explaining JOINs] | Lukas Eder | 2016-07-05 | [DBA][DEV] | | [Surprise Delta Stores] | Joe Obbish | 2017-11-07 | [DEV] | -| [SQL 2014 Clustered Columnstore index rebuild and maintenance considerations] | Denzil Ribeiro | 2015-07-08 | [DBA],[DEV] | -| [The Case of the Weirdly Long COLUMNSTORE_BUILD_THROTTLE Wait] | Kendra Little | 2017-11-09 | [DEV] | -| [Multiple Output Datasets With R and SQL Server] | Kendra Little | 2017-11-06 | [DEV],[R] | -| [How to Avoid Excessive Sorts in Window Functions] | JOOQ | 2017-11-06 | [DEV] | +| [SQL 2014 Clustered Columnstore index rebuild and maintenance considerations] | Denzil Ribeiro | 2015-07-08 | [DBA][DEV] | +| [Multiple Output Datasets With R and SQL Server] | Kendra Little | 2017-11-06 | [DEV][R] | +| [How to Avoid Excessive Sorts in Window Functions] | Lukas Eder | 2017-11-06 | [DEV] | | [Extracting a DAX Query Plan With Analysis Services 2016 Extended Events] | Koen Verbeeck | 2017-10-03 | [DAX], [XE] | -| [What impact can different cursor options have?] | Aaron Bertrand | 2012-09-10 | [DBA],[DEV] | -| [SQL Smackdown!!! Cursors VS Loops] | SQL Undercover | 2017-11-16 | [DBA],[DEV] | -| [Using the OPTION (RECOMPILE) option for a statement] | Kimberly Tripp | 2010-04-15 | [DBA],[DEV] | -| [Execution Plan Caching and Reuse] | Brett Shearer | 2015-02-12 | [DBA],[DEV] | -| [Buffer Management] | Microsoft | ? | [DBA],[DEV] | -| [RECOMPILE Hints and Execution Plan Caching] | Kendra Little | 2017-12-17 | [DBA],[DEV] | -| [Improving query performance with OPTION (RECOMPILE), Constant Folding and avoiding Parameter Sniffing issues] | Robin Lester | 2016-08-10 | [DBA],[DEV] | -| [Eight Different Ways to Clear the SQL Server Plan Cache] | Glenn Berry | 2016-03-26 | [DBA],[DEV] | -| [Introduction and FAQs about Microsoft Azure technologies] | Daniel Calbimonte | 2017-10-13 | [AZ],[DEV] | -| [Inside the XEvent Profiler] | Derik Hammer | 2017-10-11 | [DBA],[DEV] | -| [Does The Join Order of My Tables Matter?] | Bert Wagner | 2017-11-21 | [DBA],[DEV] | +| [What impact can different cursor options have?] | Aaron Bertrand | 2012-09-10 | [DBA][DEV] | +| [SQL Smackdown!!! Cursors VS Loops] | SQL Undercover | 2017-11-16 | [DBA][DEV] | +| [Using the OPTION (RECOMPILE) option for a statement] | Kimberly Tripp | 2010-04-15 | [DBA][DEV] | +| [Execution Plan Caching and Reuse] | Microsoft | 2015-02-12 | [DBA][DEV] | +| [Buffer Management] | Microsoft | 1753-01-01 | [DBA][DEV] | +| [RECOMPILE Hints and Execution Plan Caching] | Kendra Little | 2017-12-17 | [DBA][DEV] | +| [Improving query performance with OPTION (RECOMPILE), Constant Folding and avoiding Parameter Sniffing issues] | Robin Lester | 2016-08-10 | [DBA][DEV] | +| [Eight Different Ways to Clear the SQL Server Plan Cache] | Glenn Berry | 2016-03-26 | [DBA][DEV] | +| [Introduction and FAQs about Microsoft Azure technologies] | Daniel Calbimonte | 2017-10-13 | [AZ][DEV] | +| [Inside the XEvent Profiler] | Derik Hammer | 2017-10-11 | [DBA][DEV] | +| [Does The Join Order of My Tables Matter?] | Bert Wagner | 2017-11-21 | [DBA][DEV] | | [Encrypting SQL Server connections with Let’s Encrypt certificates] | Derik Hammer | 2017-11-12 | [DBA] | | [Start SQL Server without tempdb] | Kenneth Fisher | 2016-01-20 | [DBA] | | [How to configure database mail in SQL Server] | Bojan Petrovic | 2017-11-22 | [DBA] | -| [Understanding SQL server memory grant] | Jay Choe | 2010-02-16 | [DBA],[DEV] | +| [Understanding SQL server memory grant] | Jay Choe | 2010-02-16 | [DBA][DEV] | | [Cleanly Uninstalling Stubborn SQL Server Components] | Aaron Bertrand | 2015-10-06 | [DBA] | | [Hey! What's the deal with SQL Server NOCOUNT and T-SQL WHILE loops?] | @sqL_handLe | 2017-17-30 | [DEV] | -| [Query Store Settings] | Erin Stellato | 2010-11-28 | [DBA],[DEV] | +| [Query Store Settings] | Erin Stellato | 2010-11-28 | [QS] | | [Using Plan Explorer with Entity Framework] | Jason Hall | 2010-11-28 | [DEV] | -| [Overview of Encryption Tools in SQL Server] | Matthew McGiffen | 2017-12-05 | [DBA],[DEV] | -| [Clustered Index Uniquifier Existence and Size] | Solomon Rutzky | 2017-09-18 | [DBA],[DEV] | -| [Understanding Logging and Recovery in SQL Server] | Paul Randal | 2009-02-01 | [DBA],[B] | -| [Understanding SQL Server Backups] | Paul Randal | 2009-07-01 | [DBA],[B] | -| [Recovering from Disasters Using Backups] | Paul Randal | 2009-11-01 | [DBA],[B] | +| [Overview of Encryption Tools in SQL Server] | Matthew McGiffen | 2017-12-05 | [DBA][DEV] | +| [Clustered Index Uniquifier Existence and Size] | Solomon Rutzky | 2017-09-18 | [DBA][DEV] | +| [Understanding Logging and Recovery in SQL Server] | Paul Randal | 2009-02-01 | [DBA][B] | +| [Understanding SQL Server Backups] | Paul Randal | 2009-07-01 | [B][DBA] | +| [Recovering from Disasters Using Backups] | Paul Randal | 2009-11-01 | [B][DBA] | | [Simple SQL: Handling Location Datatypes] | Joe Celko | 2017-10-19 | [DEV] | -| [Improve SQL Server Performance by Looking at Plan Cache (Part 1)] | Thomas LaRock | 2014-10-30 | [DBA],[DEV] | -| [Improve SQL Server Performance by Looking at Plan Cache (Part 2)] | Thomas LaRock | 2014-10-30 | [DBA],[DEV] | -| [Improve SQL Server Performance by Looking at Plan Cache (Part 3)] | Thomas LaRock | 2014-10-30 | [DBA],[DEV] | -| [Take Care When Scripting Batches] | Michael J Swart | 2014-09-09 | [DBA],[DEV] | -| [When Measuring Timespans, try DATEADD instead of DATEDIFF] | Michael J Swart | 2017-12-20 | [DBA],[DEV] | -| [Which user function do I use?] | Kenneth Fisher | 2015-06-24 | [DBA],[DEV] | -| [What’s So Bad About Shrinking Databases with DBCC SHRINKDATABASE?] | Brent Ozar | 2017-12-29 | [DBA],[DEV] | -| [Which Collation is Used to Convert NVARCHAR to VARCHAR in a WHERE Condition? (Part A of 2: “Duck”)] | Solomon Rutzky | 2017-12-08 | [DBA],[DEV] | -| [Which Collation is Used to Convert NVARCHAR to VARCHAR in a WHERE Condition? (Part B of 2: “Rabbit”)] | Solomon Rutzky | 2017-12-11 | [DBA],[DEV] | -| [Current State of the NewSQL/NoSQL Cloud Arena] | Warner Chaves | 2017-11-27 | [DBA],[DEV] | +| [Improve SQL Server Performance by Looking at Plan Cache (Part 1)] | Thomas LaRock | 2014-10-30 | [DBA][DEV] | +| [Improve SQL Server Performance by Looking at Plan Cache (Part 2)] | Thomas LaRock | 2014-10-30 | [DBA][DEV] | +| [Improve SQL Server Performance by Looking at Plan Cache (Part 3)] | Thomas LaRock | 2014-10-30 | [DBA][DEV] | +| [Take Care When Scripting Batches] | Michael J Swart | 2014-09-09 | [DBA][DEV] | +| [When Measuring Timespans, try DATEADD instead of DATEDIFF] | Michael J Swart | 2017-12-20 | [DBA][DEV] | +| [Which user function do I use?] | Kenneth Fisher | 2015-06-24 | [DBA][DEV] | +| [What’s So Bad About Shrinking Databases with DBCC SHRINKDATABASE?] | Brent Ozar | 2017-12-29 | [DBA][DEV] | +| [Which Collation is Used to Convert NVARCHAR to VARCHAR in a WHERE Condition? (Part A of 2: “Duck”)] | Solomon Rutzky | 2017-12-08 | [DBA][DEV] | +| [Which Collation is Used to Convert NVARCHAR to VARCHAR in a WHERE Condition? (Part B of 2: “Rabbit”)] | Solomon Rutzky | 2017-12-11 | [DBA][DEV] | +| [Current State of the NewSQL/NoSQL Cloud Arena] | Warner Chaves | 2017-11-27 | [DBA][DEV] | +| [SQL Server 2017: JSON] | Sergey Syrovatchenko | 2017-11-17 | [X] | +| [Simulating Bad Networks to Test SQL Server Replication] | John Paul Cook | 2018-01-02 | [DBA] | +| [How to Turn on Instant File Initialization] | Greg Larsen | 2017-12-04 | [DBA] | +| [Bad Idea Jeans: Finding Undocumented Trace Flags] | Brent Ozar | 2017-10-04 | [DEV] | +| [A Method to Find Trace Flags] | Joe Obbish | 2018-01-16 | [DEV] | +| [Using Windows stored credentials to connect to SQL in containers] | Andrew Pruski | 2018-01-17 | [DEV] | +| [Step by Step Guide to Migrate SQL Server Data to SQL Server 2017] | Anoop Kumar | 2017-12-21 | [DBA][MG] | +| [Nasty Fast PERCENT_RANK] | Alan Burstein | 2018-01-05 | [DEV] | +| [Administrative Logins and Users] | Kenneth Fisher | 2015-11-02 | [DEV] | +| [Parallelism in Hekaton (In-Memory OLTP)] | Niko Neugebauer | 2018-01-20 | [DEV] | +| [Troubleshooting THREADPOOL Waits] | Klaus Aschenbrenner · | 2015-10-20 | [DEV] | +| [Andy’s Excellent SSIS-in-the-Cloud Adventure, Part 1 – Build an ADFv2 IR Instance] | Andy Leonard · | 2018-01-28 | [AZ][SSIS] | +| [PRINT vs. RAISERROR] | sqlity.net · | 2012-05-27 | [DEV] | +| [Without ORDER BY, You Can’t Depend On the Order of Results] | Michael J Swart · | 2013-09-13 | [DEV] | +| [Query Store and “in memory”] | Erin Stellato · | 2018-01-31 | [QS] | +| [Setting and Identifying Row Goals in Execution Plans] | Paul White · | 2018-02-12 | [DEV] | +| [Azure and Windows PowerShell: The Basics] | Nicolas Prigent · | 2017-12-29 | [AZ] | +| [Auditing Linked Servers] | Thomas LaRock | 2018-02-08 | [DEV] | +| [An alternative to data masking] | Daniel Hutmacher | 2018-02-05 | [DEV] | +| [Safely and Easily Use High-Level Permissions Without Granting Them to Anyone: Server-level] | Solomon Rutzky | 2018-02-15 | [DBA] | +| [PLEASE, Please, please Stop Using Impersonation, TRUSTWORTHY, and Cross-DB Ownership Chaining] | Solomon Rutzky | 2018-12-30 | [DBA] | +| [Indexing and Partitioning] | DBA From The Cold | 2018-02-21 | [DEV] | +| [Schema Compare for SQL Server] | Thomas Larock | 2018-02-14 | [DEV] | +| [How to change SQL Server ERRORLOG location] | Mark Varnas | 2018-03-04 | [DBA] | +| [The Uni-Code: The Search for the True List of Valid Characters for T-SQL Regular Identifiers, Part 1] | Solomon Rutzky | 2018-04-02 | [DBA][DEV] | +| [The Uni-Code: The Search for the True List of Valid Characters for T-SQL Regular Identifiers, Part 2] | Solomon Rutzky | 2018-04-04 | [DBA][DEV] | +| [What’s in a Name?: Inside the Wacky World of T-SQL Identifiers] | Solomon Rutzky | 2018-04-09 | [DBA][DEV] | +| [Programming SQL Server with SQL Server Management Objects Framework] | Darko Martinović | 2018-04-09 | [DEV] | +| [Interval Queries in SQL Server] | Itzik Ben-Gan | 2013-06-12 | [DEV] | +| [Dealing with date and time instead of datetime] | Rob Farley | 2018-03-29 | [DEV] | +| [Insight into the SQL Server buffer cache] | Ed Pollack | 2018-02-18 | [DBA][DEV] | +| [A concrete example of migration between an Oracle Database and SQL Server using Microsoft Data Migration Assistant] | Jefferson Elias | 2018-04-12 | [DBA][DEV] | +| [Audit SQL Server stop, start, restart] | Steve Keeler | 2018-03-12 | [DBA] | +| [Query tuning: Apply yourself] | Daniel Janik | 2018-04-06 | [DEV] | +| [How to identify and monitor unused indexes in SQL Server] | Nikola Dimitrijevic | 2018-04-17 | [IDX] | +| [Benchmarking: 1-TB table population (part 1: the baseline)] | Paul Randal | 2010-01-21 | [BENCH] | +| [Benchmarking: 1-TB table population (part 2: optimizing log block IO size and how log IO works)] | Paul Randal | 2010-01-27 | [BENCH] | +| [An overview of SQL Server database migration tools provided by Microsoft] | Jefferson Elias | 2018-03-16 | [DBA][MG] | +| [Calling Http endpoints in T-SQL using CURL extension] | Jovan Popovic | 2018-04-17 | [CLR] | +| [Why Table Join Orders In Relational Databases] | Bert Wagner | 2018-04-16 | [DEV] | +| [Finding overlapping ranges of data] | Louis Davidson | 2018-04-18 | [DEV] | +| [Avoid use of the MONEY and SMALLMONEY datatypes] | Phil Factor | 2018-04-18 | [DEV] | +| [Provisioning SQL Server Instances with Docker] | Laerte Junior | 2018-04-18 | [DBA] | +| [Understanding the graphical representation of the SQL Server Deadlock Graph] | Minette Steynberg | 2016-08-16 | [DBA][DEV] | +| [Digitally Signing a Stored Procedure To Allow It To Run With Elevated Permissions] | SQL Undercover | 2018-05-02 | [DBA][DEV] | +| [NOLOCK and Top Optimization] | Dmitry Piliugin | 2018-04-12 | [DEV] | +| [Operator Precedence versus the Confusing Constraint Translation] | Louis Davidson | 2018-04-30 | [DEV] | +| [Interval Queries in SQL Server] | Itzik Ben-Gan | 2013-06-13 | [DEV] | +| [Query Trace Column Values] | Dmitry Piliugin | 2018-04-23 | [XE] | +| [Concurrency Week: How to Delete Just Some Rows from a Really Big Table] | Brent Ozar | 2018-04-27 | [DEV] | +| [Break large delete operations into chunks] | Aaron Bertrand | 2013-03-13 | [DBA][DEV] | +| [How to perform a page level restore in SQL Server - Jayaram] | Prashanth Jayaram | 2018-08-18 | [DBA][DEV] | +| [Grouping dates without blocking operators] | Daniel Hutmacher | 2018-05-14 | [DEV] | +| [What’s CHECKDB doing in my database restore?] | Mike Fal | 2018-04-10 | [DBA] | +| [How To Hide An Instance Of SQL Server] | Thomas Larock | 2018-04-10 | [DBA] | +| [Troubleshooting Parameter Sniffing Issues the Right Way: Part 1] | Tara Kizer | 2018-03-06 | [DEV] | +| [Troubleshooting Parameter Sniffing Issues the Right Way: Part 2] | Tara Kizer | 2018-03-07 | [DEV] | +| [Troubleshooting Parameter Sniffing Issues the Right Way: Part 3] | Tara Kizer | 2018-03-06 | [DEV] | +| [When to use the SELECT…INTO statement] | Phil Factor | 2018-03-19 | [DEV] | +| [Temp Tables In SSIS] | Tim Mitchel | 2018-05-29 | [SSIS] | +| [Changing the Collation of the Instance, the Databases, and All Columns in All User Databases] | Solomon Rutzky | 2018-06-11 | [DBA] | +| [10 Cool SQL Optimisations That do not Depend on the Cost Model] | Lukas Eder | 2017-09-28 | [DBA][DEV] | +| [Scheduling powershell tasks with sql agent] | Chrissy Lemaire | 2017-09-26 | [J][PS] | +| [Three ways to track logins using dbatools] | Chrissy Lemaire | 2018-04-10 | [PS] | +| [Impact of Fragmentation on Execution Plans] | Jonathan Kehayias | 2017-12-18 | [DEV] | +| [How to “debug” a Linked Server from SQL Server to an Oracle Database instance] | Jefferson Elias | 2018-06-11 | [DEV] | +| [How to implement error handling in SQL Server] | Bojan Petrovic | 2018-06-15 | [DEV] | +| [SQL Server Closure Tables] | Phil Factor | 2018-04-10 | [DEV] | +| [Deadlock victim choice in SQL Server - an exception?] | Josh Darnell | 2018-05-10 | [DBA][DEV] | +| [Azure and Windows PowerShell: The Basics] | Nicolas Prigent | 2017-12-29 | [AZ][PS] | +| [Azure and Windows PowerShell: Getting Information] | Nicolas Prigent | 2018-06-26 | [AZ][PS] | +| [Be our guest, be our guest, put our database to the test] | Kenneth Fisher | 2018-06-25 | [DBA] | +| [Finding code smells using SQL Prompt: the SET NOCOUNT problem (PE008 and PE009)] | Phil Factor | 2018-01-04 | [DEV] | +| [DATABASES 101 guide for the non-technical professional] | Thomas LaRock | 2018-07-05 | [DBA][DEV] | +| [Understanding your Azure EA Billing Data and Building a Centralized Data Storage Solution] | Feodor Georgiev | 2018-07-17 | [AZ] | +| [READ COMMITTED SNAPSHOT ISOLATION and High version_ghost_record_count] | Uwe Ricken | 2018-03-06 | [DBA][DEV] | +| [In-Memory OLTP Indexes – Part 1: Recommendations.] | Kunal Karoth | 2017-11-02 | [IDX] | +| [In-Memory OLTP Indexes – Part 2: Performance Troubleshooting Guide.] | Kunal Karoth | 2017-11-14 | [IDX] | +| [Optimization Thresholds – Grouping and Aggregating Data, Part 1] | Itzik Ben-Gan | 2018-04-10 | [DEV] | +| [Optimization Thresholds – Grouping and Aggregating Data, Part 2] | Itzik Ben-Gan | 2018-05-09 | [DEV] | +| [Optimization Thresholds – Grouping and Aggregating Data, Part 3] | Itzik Ben-Gan | 2018-06-13 | [DEV] | +| [Optimization Thresholds – Grouping and Aggregating Data, Part 4] | Itzik Ben-Gan | 2018-07-11 | [DEV] | +| [Optimization Thresholds – Grouping and Aggregating Data, Part 5] | Itzik Ben-Gan | 2018-08-08 | [DEV] | +| [When DBCC OpenTran doesn’t list all open transactions] | Mohamed | 2013-02-17 | [DBA] | +| [How I spot not-yet-documented features in SQL Server CTPs] | Aaron Bertrand | 2015-12-02 | [DBA] | +| [More ways to discover changes in new versions of SQL Server] | Aaron Bertrand | 2016-03-30 | [DBA] | +| [Tail-Log Backup and Restore in SQL Server] | Prashanth Jayaram | 2018-05-31 | [B][DBA] | +| [Database Filegroup(s) and Piecemeal restores in SQL Server] | Prashanth Jayaram | 2018-06-22 | [DBA] | +| [Updating Statistics with Ola Hallengren’s Script] | Erin Stellato | 2018-06-22 | [DBA] | +| [Interview questions on SQL Server database backups, restores and recovery – Part I] | Prashanth Jayaram | 2018-07-25 | [B][DBA] | +| [Interview questions on SQL Server database backups, restores and recovery – Part II] | Prashanth Jayaram | 2018-07-25 | [B][DBA] | +| [Interview questions on SQL Server database backups, restores and recovery – Part III] | Prashanth Jayaram | 2018-07-25 | [B][DBA] | +| [Can Rowstore Compression Beat Columnstore Compression?] | Joe Obbish | 2018-06-28 | [DBA][DEV] | +| [Inside the Storage Engine: Anatomy of a record] | Paul Randal | 2007-09-30 | [DBA][DEV] | +| [Inside the Storage Engine: Using DBCC PAGE and DBCC IND to find out if page splits ever roll back] | Paul Randal | 2007-10-01 | [DBA][DEV] | +| [Inside the Storage Engine: Anatomy of a page] | Paul Randal | 2007-10-03 | [DBA][DEV] | +| [Inside the Storage Engine: Anatomy of an extent] | Paul Randal | 2007-10-03 | [DBA][DEV] | +| [Inside the Storage Engine: IAM pages, IAM chains, and allocation units] | Paul Randal | 2007-10-04 | [DBA][DEV] | +| [Inside The Storage Engine: GAM, SGAM, PFS and other allocation maps] | Paul Randal | 2008-03-14 | [DBA][DEV] | +| [Disaster recovery 101: fixing a broken boot page] | Paul Randal | 2015-06-23 | [DBA][DEV] | +| [How to download a sqlservr.pdb symbol file] | Paul Randal | 2011-04-13 | [DBA][DEV] | +| [A cause of high-duration ASYNC_IO_COMPLETION waits] | Paul Randal | 2014-03-19 | [DBA][DEV] | +| [How to solve the Identity Crisis in SQL Server] | Ed Pollack | 2017-11-14 | [DBA][DEV] | +| [Azure SQL Database Performance and Service Tiers Explained] | Glenn Berry | 2018-08-01 | [AZ] | +| [What To Do When Wait Stats Don’t Help] | Joe Obbish | 2018-07-20 | [DEV] | +| [SQL Server Brute Force Attack Detection: Part 1] | Ryan G Conrad | 2018-03-26 | [DBA] | +| [SQL Server Brute Force Attack Detection: Part 2] | Ryan G Conrad | 2018-03-26 | [DBA] | +| [SQL Server Brute Force Attack Detection: Part 3] | Ryan G Conrad | 2018-03-26 | [DBA] | +| [SQLCLR vs SQL Server 2017, Part 8: Is SQLCLR Deprecated in Favor of Python or R (sp_execute_external_script)?] | Solomon Rutzky | 2018-08-09 | [DBA][DEV] | +| [Sql Server Agent For Azure Sql Database, Azure Elastic Database Pools & Azure Managed Instance] | ? | 2018-07-20 | [AZ] | +| [Storage performance best practices and considerations for Azure SQL DB Managed Instance (General Purpose)] | Dimitri Furman | 2018-07-20 | [AZ] | +| [T-SQL Tuesday #017: APPLY: It Slices! It Dices! It Does It All!] | Brad Schulz | 2011-04-12 | [DEV] | +| [SQL Server Encryption, What’s The Key Hierarchy All About?] | David Fowler | 2018-08-12 | [DBA][DEV] | +| [Overview of the SQLCMD utility in SQL Server] | Prashanth Jayaram | 2018-08-13 | [DBA][DEV] | +| [The BCP (Bulk Copy Program) command in action] | Prashanth Jayaram | 2018-08-13 | [DBA][DEV] | +| [Measuring Query Execution Time] | Grant Fritchey | 2018-08-13 | [DBA][DEV] | +| [How to Check Performance on a New SQL Server] | Brent Ozar | 2018-08-03 | [DBA][DEV] | +| [Questions About Kerberos and SQL Server That You Were Too Shy to Ask] | Kathi Kellenberger | 2018-08-21 | [DBA] | +| [SQL Server Execution Plans overview] | Ahmad Yaseen | 2018-07-04 | [DBA][DEV] | +| [SQL Server Execution Plans types] | Ahmad Yaseen | 2018-07-23 | [DBA][DEV] | +| [How to Analyze SQL Execution Plan Graphical Components] | Ahmad Yaseen | 2018-09-07 | [DBA][DEV] | +| [Query optimization techniques in SQL Server: the basics] | Ed Pollack | 2018-05-30 | [DBA][DEV] | +| [Query optimization techniques in SQL Server: tips and tricks] | Ed Pollack | 2018-06-19 | [DBA][DEV] | +| [Query optimization techniques in SQL Server: Database Design and Architecture] | Ed Pollack | 2018-07-13 | [DBA][DEV] | +| [SQL Query Optimization Techniques in SQL Server: Parameter Sniffing] | Ed Pollack | 2018-09-04 | [DBA][DEV] | +| [Similarities and Differences among RANK, DENSE_RANK and ROW_NUMBER Functions] | Ben Richardson | 2018-08-20 | [DBA][DEV] | +| [Temporal Tables Under The Covers] | Randolph West | 2015-11-17 | [DBA][DEV] | +| [Faking Temporal Tables with Triggers] | Bert Wagner | 2018-09-11 | [DBA][DEV] | +| [SQL queries to manage hierarchical or parent-child relational rows in SQL Server] | Dipon Roy | 2014-09-16 | [DBA][DEV] | +| [Choosing Between Table Variables and Temporary Tables] | Phil Factor | 2018-05-11 | [DBA][DEV] | +| [What's New in the First Public CTP of SQL Server 2019] | Aaron Bertrand | 2018-09-24 | [DBA][DEV] | +| [SQL Server support for TLS 1.2 – Read This First!] | Aaron Bertrand | 2016-03-03 | [DBA][DEV] | +| [Misconceptions in SQL Server: A Trio of table variables] | Gail Shaw | 2010-10-12 | [DBA][DEV] | +| [Using the Same Column Twice in a SQL UPDATE Statement] | SQL Theater | 2018-09-13 | [DBA][DEV] | +| [How to perform a performance test against a SQL Server instance] | Jefferson Elias | 2018-09-14 | [DBA][DEV] | +| [The Black Art Of Spatial Index Tuning In SQL Server] | Todd Jackson | 2011-04-26 | [DEV] | +| [Patching SQL Server on Windows notes from the field] | Kevin Chant | 2019-01-10 | [DBA] | +| [Availability Group Readable Secondaries – Just Say No] | Jonathan Kehayias | 2019-01-10 | [DBA] | +| [Finding the Slowest Query in a Stored Procedure] | Erin Stellato | 2018-12-13 | [DBA][DEV] | +| [A Monumental Migration to SQL Server 2016 – Part 1] | Andy Levy | 2019-01-07 | [DBA][MG] | +| [A Monumental Migration to SQL Server 2016 – Part 2] | Andy Levy | 2019-01-09 | [DBA][MG] | +| [A unique review of SQL Server index types] | Kevin Chant | 2019-10-18 | [DBA][DEV] | +| [Don’t Just Rely on Query Execution Stats for T-SQL Execution] | Kevin Chant | 2018-09-18 | [DBA][DEV] | +| [Posting SQL Server notifications to Slack] | Alessandro Alpi | 2018-09-19 | [DBA][DEV] | +| [How to create DACPAC file?] | Kamil Nowinski | 2018-10-31 | [DBA][DEV] | +| [Find the Next Non-NULL Row in a Series With SQL] | Lukas Eder | 2018-09-03 | [DEV] | +| [Calculate Percentiles to Learn About Data Set Skew in SQL] | Lukas Eder | 2019-01-22 | [DEV] | +| [Comparing multiple rows insert vs single row insert with three data load methods] | Phil Factor | 2013-02-21 | [DBA][DEV] | +| [The Cause of Every Deadlock in SQL Server] | Thomas Larock | 2018-09-19 | [DBA][DEV] | +| [Deadlock Troubleshooting, Part 1] | Bart Dunkan | 2006-09-08 | [DBA][DEV] | +| [Deadlock Troubleshooting, Part 2] | Bart Dunkan | 2006-09-12 | [DBA][DEV] | +| [Deadlock Troubleshooting, Part 3] | Bart Dunkan | 2006-09-08 | [DBA][DEV] | +| [The Good, the Bad and the Ugly of Table Variable Deferred Compilation – Part 1] | Milosra Divojevic | 2018-10-04 | [DBA][DEV] | +| [The Good, the Bad and the Ugly of Table Variable Deferred Compilation – Part 2] | Milosra Divojevic | 2018-10-05 | [DBA][DEV] | +| [The Good, the Bad and the Ugly of Table Variable Deferred Compilation – Part 3] | Milosra Divojevic | 2018-10-08 | [DBA][DEV] | +| [Creating a SQL Server 2019 Demo Environment in a Docker Container] | Cathrine Wilhelmsen | 2018-12-02 | [DBA][DEV] | +| [Overview of Data Compression in SQL Server] | Prashanth Jayaram | 2018-12-06 | [DBA][DEV] | +| [SQL Server Hash Match Operator] | Hugo Kornelis | 2018-06-01 | [DBA][DEV] | +| [How to use Microsoft Assessment and Planning (MAP) Toolkit for SQL Server] | Musab Umair | 2017-03-31 | [DBA] | +| [Improve the Performance of Your Azure SQL Database (and Save Money!) with Automatic Tuning] | Monica Rathbun | 2019-01-30 | [AZ][DBA] | +| [The Importance of Database Compatibility Level in SQL Server] | Glenn Berry | 2019-01-14 | [DBA] | +| [Azure Managed vs Unmanaged disks : The choice] | Samir Farhat | 2017-05-31 | [AZ] | +| [Storage options for SQL Server database files in Azure] | James Serra | 2019-01-29 | [AZ] | +| [The Performance of Window Aggregates Revisited with SQL Server 2019] | Kathi Kellenberger | 2019-02-11 | [DEV] | +| [Super Scaling Singleton Inserts] | Chris Adkin | 2015-02-19 | [DEV] | +| [Preparation for SQL Server Installation] | Michal Sadowski | 2018-12-12 | [DBA] | +| [Executing xp_cmdshell with Non SysAdmin Account] | Lucas Kartawidjaja | 2019-01-04 | [DBA] | +| [Generating SQL using Biml (T-SQL Tuesday #110)] | Cathrine Wilhelmsen | 2019-01-08 | [DEV] | +| [Using Temporary Procedures] | Phil Factor | 2019-02-08 | [DBA][DEV] | +| [Introduction to SQL Server Security — Part 1] | Robert Sheldon | 2018-12-31 | [SEC] | +| [Introduction to SQL Server Security — Part 2] | Robert Sheldon | 2019-01-28 | [SEC] | +| [Introduction to SQL Server Security — Part 3] | Robert Sheldon | 2019-02-25 | [SEC] | +| [Introduction to SQL Server Security — Part 4] | Robert Sheldon | 2019-03-26 | [SEC] | +| [Introduction to T-SQL Window Functions] | Kathi Kellenberger | 2018-07-13 | [DBA][DEV] | +| [Intro to Debugging a Memory Dump] | Adam W. Saxton | 2012-03-15 | [DBA][DEV] | +| [Considering Security with SQL Bulk Insert] | Timothy Smith | 2019-01-17 | [SEC] | +| [SQL Server 2012 AlwaysOn – Part 11 – Performance Aspects and Performance Monitoring I] | Juergen Thomas | 2013-04-21 | [DBA] | +| [SQL Server 2012 AlwaysOn – Part 11 – Performance Aspects and Performance Monitoring II] | Juergen Thomas | 2013-04-24 | [DBA] | +| [Data Compression Internals] | Jess Pomfret | 2019-02-19 | [DBA][DEV] | +| [SQL Server Data Compression – Crunch Time!] | Jeff Mlakar | 2019-02-22 | [DBA][DEV] | +| [Create a slipstream installer for SQL Server on Windows] | Randolph West | 2018-10-24 | [DBA] | +| [Temporary Tables in SQL Server] | Phil Factor | 2011-09-01 | [DBA][DEV] | +| [SQL unit testing with the tSQLt framework for beginners] | Esat Erkec | 2019-03-19 | [DEV] | +| [Oracle vs. SQL Server Architecture] | Kellyn Pot'vin-Gorman | 2019-03-20 | [DBA][DEV] | +| [Oracle RAC vs. SQL Server AG] | Kellyn Pot'vin-Gorman | 2019-03-28 | [DBA][DEV] | +| [SSIS vs. Oracle GG] | Kellyn Pot'vin-Gorman | 2019-04-10 | [DBA][DEV] | +| [Analysis Services Telemetry: What information does SSAS submit? and how has it changed in SSAS 2019?] | Shabnam Watson | 2019-04-13 | [DBA] | +| [The Curious Case of… how to find FILESTREAM info from an MDF] | Paul Randal | 2019-04-18 | [DBA] | +| [Does index fragmentation matter?] | Tibor Karaszi | 2019-04-05 | [DBA][DEV] | +| [How to perform a Page Level Restore in SQL Server] | Klaus Aschenbrenner | 2015-10-13 | [DBA] | +| [How Much Memory Does SSIS Need?] | Tim Mitchell | 2019-05-02 | [SSIS] | +| [The Curious Case of… trying to find an MDF file in a RAW disk] | Paul Randal | 2019-04-30 | [DBA] | +| [Understanding the SQL Server NOLOCK hint] | Greg Robidoux | 2019-04-29 | [DBA][DEV] | +| [Methods to Insert Data into SQL Server] | Ed Pollack | 2019-04-10 | [DBA][DEV] | +| [Batching data manipulation is great as long as you do it correctly] | Jeff Iannucci | 2018-09-15 | [DBA][DEV] | +| [Azure and Windows PowerShell: Using VM Extensions] | Nicolas Prigent | 2018-10-09 | [PS] | +| [Reloading fact tables with zero downtime] | Daniel Hutmacher | 2014-08-24 | [DBA][DEV] | +| [Transferring Data Efficiently by Using Partition Switching] | Microsoft Docs | 2012-04-10 | [DBA][DEV] | +| [Another Difference between N'' and '' in SQL Server] | Shane O'Neill | 2018-10-24 | [DBA][DEV] | +| [Ignoring NULLs with FIRST_VALUE] | Bert Wagner | 2018-08-28 | [DEV] | +| [Shortchanged with International Money in SQL Server] | Bert Wagner | 2018-09-25 | [DEV] | +| [Understanding database recovery with SQL Server 2016 Extended Events] | Rajendra Gupta | 2016-07-05 | [DBA] | +| [SQL Server 2019: Batch Mode on Rowstore] | Dmitri Pilugin | 2018-10-04 | [DBA][DEV] | +| [Using Indexing To Solve Blocking and Deadlocking Issues] | David Fowler | 2019-03-15 | [DBA][DEV] | +| [Change collation of existing Azure SQL database] | Fonseca Sergio | 2018-11-09 | [AZ] | +| [Creating Database Maintenance Plans] | Nisarg Upadhyay | 2018-11-09 | [DBA] | +| [SQL Server Upgrade Checklist] | Mike Walsh | 2019-03-07 | [DBA] | +| [Failing a PowerShell Sql Agent step] | Stuart Moore | 2019-03-04 | [PS] | +| [The Curse of Cursor Options] | Brent Ozar | 2018-11-02 | [DBA][DEV] | +| [Accelerated Database Recovery; Instant Rollback and Database Recovery] | Rajendra Gupta | 2019-03-12 | [DBA] | +| [Accelerated Database Recovery and Long Running Transactions with Transaction Log Growth] | Rajendra Gupta | 2019-03-21 | [DBA] | +| [Using docker named volumes to persist databases in SQL Server] | Andrew Pruski | 2019-03-21 | [DBA][DEV] | +| [T-SQL bugs, pitfalls, and best practices – determinism] | Itzik Ben-Gan | 2019-03-13 | [DBA][DEV] | +| [Grouped Concatenation in SQL Server] | Aaron Bertrand | 2014-08-06 | [DBA][DEV] | +| [Working with tempdb in SQL Server 2005] | Microsoft Docs | 2010-01-28 | [DBA][DEV] | +| [SQLskills SQL101: Temporary table misuse] | Paul Randal | 2017-03-13 | [DBA][DEV] | +| [Running SQL Server on Linux on your own laptop] | Kevin Chant | 2019-03-26 | [DBA][DEV] | +| [SSIS and Pentaho – A Quick Comparison] | Koen Verbeeck | 2018-10-17 | [SSIS] | +| [WinDbg and SQL Server Fun] | Shane O'Neill | 2017-06-14 | [DBA][DEV] | +| [Certificates, Proxies and Jobs! Oh My!] | Kenneth Fisher | 2016-04-27 | [DBA][J] | +| [SQL Server: Diagnosing Intermittent Connectivity Issues] | Mitch Wheat | 2019-04-12 | [DBA][DEV] | +| [Difference between Identity & Sequence in SQL Server] | Ben Richardson | 2018-08-15 | [DBA][DEV] | +| [Does the Rowmodctr Update for Non-Updating Updates?] | Brent Ozar | 2019-05-20 | [DBA][DEV] | +| [An Intro To Data Modeling] | JBOSEMS | 2019-04-12 | [DBA][DEV] | +| [On telemetry and other data collected by SQL Server] | Aaron Bertrand | 2016-04-04 | [DBA][DEV] | +| [Purging data with batched deletes] | Andy Mallon | 2019-04-03 | [DBA][DEV] | +| [Don’t Forget RoboCopy] | John Morehouse | 2019-03-03 | [DBA] | +| [Understanding the XML description of the Deadlock Graph in SQL Server] | Minette Steynberg | 2016-04-26 | [DBA][DEV] | +| [What Is The Difference Between Checkpoint And Lazy Writer] | Saurabh Sinha | 2012-10-01 | [DBA] | +| [Efficiently Indexing Long Character Strings] | Jon Seigel | 2013-07-13 | [DBA][DEV] | +| [SQL Server Read-only tables] | Kenneth Fisher | 2019-01-21 | [DBA] | +| [Slow inserts across a linked server?] | Max Vernon | 2019-04-25 | [DBA][DEV] | +| [Using IGNORE NULLS With SQL Window Functions to Fill Gaps] | Lukas Eder | 2019-04-24 | [DBA][DEV] | +| [SQL Server Logical Reads] | Ami Levin | 2008-01-01 | [DBA][DEV] | +| [Two Words For Faster Scalar Functions] | Bert Wagner | 2018-12-04 | [DBA][DEV] | +| [How to Get SQL Server Dates and Times Horribly Wrong] | Robert Sheldon | 2015-05-28 | [DBA][DEV] | +| [Diagnosing and Resolving Spinlock Contention on SQL Server] | Ewan Fairweather, Mike Ruthruff | 2011-06-01 | [DBA][DEV] | +| [Diagnosing and Resolving Latch Contention on SQL Server] | Ewan Fairweather, Mike Ruthruff | 2011-06-01 | [DBA][DEV] | +| [Advanced Nutanix: SQL Server on Nutanix Best Practices Released!] | Steven Poitras | 2013-11-09 | [DBA] | +| [Gaps and Islands Across Date Ranges] | Bert Wagner | 2019-03-12 | [DBA] | +| [NOT NULL Persisted Computed Columns (And What They Allow)] | Louis Davidson | 2019-06-01 | [DBA][DEV] | +| [How many ways are there to sort GUIDs? How much time do you have?] | Raymond Chen | 2019-04-26 | [DBA][DEV] | +| [How do I force a SQL Login to change it’s password on next login] | Kenneth Fisher | 2019-06-05 | [DBA] | +| [SQL Server Performance Benchmarking with Patterns] | Paul Brewer | 2017-10-19 | [BENCH] | +| [SQL Server function to convert integer date to datetime format] | Tim Ford | 2019-05-24 | [DBA][DEV] | +| [Storing Utc Is Not A Silver Bullet] | Jon Skeet | 2019-03-27 | [DBA][DEV] | +| [Logical Query Processing Part 8 : SELECT and ORDER BY] | Itzik Ben-Gan | 2016-11-15 | [DBA][DEV] | +| [SQL Server Common Table Expression vs Temp Table] | Rick Dobson | 2019-05-22 | [DBA][DEV] | +| [Which Query Used The Most Cpu? Implementing Extended Events] | Grant Fritchey | 2019-06-03 | [XE] | +| [SQL Server Plan Cache Limits] | Erin Stellato | 2019-05-28 | [DBA] | +| [SQL Server and ReFS: Part 1 – DBCC and In Memory OLTP] | swasheck | 2014-11-11 | [DBA] | +| [SQL Server and ReFS: Part 2 – FIO Benchmarking NTFS vs. ReFS] | swasheck | 2014-12-18 | [DBA] | +| [Why Rolling back inserts with Identity columns is a bad idea] | Adrian Buckman | 2019-04-11 | [DBA][DEV] | +| [What’s Better, CTEs or Temp Tables?] | Brent Ozar | 2019-06-06 | [DBA][DEV] | +| [The Difference Between SQL’s JOIN .. ON Clause and the Where Clause] | Lukas Eder | 2019-04-09 | [DBA][DEV] | +| [My IT department installed an antivirus with SQL Server] | Randolph West | 2019-06-05 | [DBA] | +| [An Experiment with Deadlocks - ROWLOCK hint myth] | Jason Brimhall | 2019-03-25 | [DBA][DEV] | +| [Adding a New Transaction Log File when the Existing Log is Full] | Max Vernon | 2019-03-19 | [DBA] | +| [Transactions Don't Start At BEGIN TRAN] | Josh Darnell | 2019-06-05 | [DBA][DEV] | +| [CAST/CONVERT makes expressions nullable] | Daniel Hutmacher | 2019-06-05 | [DBA][DEV] | +| [Deciding between COALESCE and ISNULL in SQL Server] | Aaron Bertrand | 2012-04-30 | [DBA][DEV] | +| [How do you choose which columns to include in your SQL Server clustered index?] | agilesql | 2019-06-01 | [DBA][DEV] | +| [A ever-increasing Clustered Key value doesn’t scale] | Klaus Aschenbrenner | 2014-04-15 | [DBA][DEV] | +| [SQL Server Bit reversion] | Rick | 2011-10-03 | [DBA][DEV] | +| [Troubleshooting a renamed SQL Server] | Jamie Wick | 2019-06-05 | [DBA] | +| [Are Differential Backups Necessary?] | Jamie Wick | 2019-04-02 | [B][DBA] | +| [Updating Statistics on Secondary Replicas of the Availability Groups] | Niko Neugebauer | 2019-06-20 | [DBA] | +| [It’s interesting how an OR short circuits] | Kenneth Fisher | 2019-06-17 | [DBA][DEV] | +| [SQL Server NOLOCK Anomalies, Issues and Inconsistencies] | Aaron Bertrand | 2019-06-18 | [DBA][DEV] | +| [Choosing a Database for Serverless Applications] | Alex DeBrie | 2019-06-22 | [DEV] | +| [SQL Server On Linux: Forced Unit Access (Fua) Internals] | Robert Dorr | 2018-12-18 | [DBA] | +| [Socrates: The New SQL Server in the Cloud] | Microsoft | 2019-05-01 | [DBA][DEV] | +| [What permissions do temp stored procedures use?] | Kenneth Fisher | 2019-06-19 | [DBA][DEV] | +| [Common SQL Server Mishaps] | Tim Radney | 2019-06-21 | [DBA] | +| [SQL Server Agent for SQL Express on Linux] | Thom Andrews | 2019-06-18 | [DBA] | +| [Trailing Spaces in SQL Server] | Bert Wagner | 2019-06-18 | [DEV] | +| [Troubleshooting a Change in Query Performance] | Erin Stellato | 2019-06-20 | [P] | +| [The Silent Bug I Find in Most Triggers] | Brent Ozar | 2019-05-06 | [DBA][DEV] | +| [How to Copy a Table in SQL Server to Another Database] | Pablo Echeverria | 2019-05-14 | [DBA][DEV] | +| [Configuration of SQL Server instance] | Michal Sadowski | 2019-06-18 | [DBA] | +| [What is the SQL Server Virtual Log file and how to monitor it] | Musab Umair | 2017-04-26 | [DBA] | +| [Important change to VLF creation algorithm in SQL Server 2014] | Paul Randal | 2015-01-06 | [DBA] | +| [SQL Server Transaction Log Fragmentation: a Primer] | Greg Larsen | 2012-04-26 | [DBA] | +| [8 Steps to better Transaction Log throughput] | Kimberly Tripp | 2019-01-01 | [DBA] | +| [Joins With OR Clauses = 💔] | Erik Darling | 2019-06-04 | [DBA][DEV] | +| [Thoughts on MAXDOP] | Erik Darling | 2019-06-18 | [DBA][DEV] | +| [What the Arrow Sizes in Query Plans Really Mean] | Brent Ozar | 2019-06-21 | [DBA][DEV] | +| [Query Store Best Practices] | Erin Stellato | 2019-06-25 | [DBA][DEV] | +| [Introduction to Data Normalization: A Database "Best" Practice] | Scott Wambler | 2019-01-01 | [DBA][DEV] | +| [Dr. OUTPUT or: How I Learned to Stop Worrying and Love the MERGE] | Adam Machanic | 2009-08-24 | [DBA][DEV] | +| [SQL Server Tipping Games – Why Non-Clustered Indexes are just ignored!] | Klaus Aschenbrenner | 2013-06-12 | [DBA][DEV] | +| [SQL Server Guide To NULL Handling] | Gavin Draper | 2018-11-29 | [DBA][DEV] | +| [Living with SQL’s 900 Byte Index Key Length Limit] | Bart Duncan | 2011-01-06 | [DBA][DEV] | +| [Memory-Optimized TempDB Metadata in SQL Server 2019 - SQLHack] | Ed Pollack | 2019-07-10 | [DBA][DEV] | +| [Forcing A Plan That Has A Plan Guide] | Grant Fritchey | 2018-11-26 | [DBA][DEV] | +| [Remember the Default Window] | Steve Jones | 2018-08-23 | [DBA][DEV] | +| [The Impact of Non-Updating Updates] | Paul Randal | 2010-08-11 | [DBA][DEV] | +| [What are Columnstore Indexes?] | Monica Rathbun | 2019-07-22 | [DBA][DEV] | +| [PolyBase in SQL Server 2019 – The End of ETL?] | Benjamin Weissman | 2019-07-23 | [DBA][DEV] | +| [Overview of Service Principal Name and Kerberos authentication in SQL Server] | Rajendra Gupta | 2019-07-18 | [DBA] | +| [Data Transfer Strategies between MongoDB and SQL Server] | Phil Factor | 2019-07-22 | [DBA][DEV] | +| [SQL Server and Excel Hierarchyid Example for Organization Charts] | Rick Dobson | 2019-07-04 | [DEV] | +| [Difference between sp_execute and sp_executesql and exec] | Prasad Sahoo | 2015-02-09 | [DBA][DEV] | +| [EXEC and sp_executesql – how are they different?] | Kimberly Tripp | 2010-04-05 | [DBA][DEV] | +| [Little Bobby Tables, SQL Injection and EXECUTE AS] | Kimberly Tripp | 2010-04-04 | [DBA][DEV] | +| [Examining the Performance Impact of an Adhoc Workload] | Erin Stellato | 2019-05-22 | [BENCH] | +| [Backup to URL] | Jon Gurgul | 2019-01-01 | [B][DBA] | +| [Spotting Unauthorized Configuration Settings in SQL Server] | Phil Factor | 2018-09-30 | [DBA][DEV] | +| [Window Functions in SQL Server] | Fabiano Amorim | 2011-10-27 | [DBA][DEV] | +| [Window Functions in SQL Server: Part 2-The Frame] | Fabiano Amorim | 2011-11-24 | [DBA][DEV] | +| [An Intro to SQL Window Functions] | Neal Barnett | 2019-07-07 | [DBA][DEV] | +| [SQL Database Performance Tuning for Developers] | Rodrigo Koch | 1753-01-01 | [P] | +| [“But NOLOCK Is Okay When The Data Isn’t Changing, Right?”] | Brent Ozar | 2019-08-05 | [DBA][DEV] | +| [tempdb Enhancements in SQL Server 2019] | Erin Stellato | 2019-08-02 | [BENCH] | +| [Feature Restrictions in SQL Server 2019 are Worse Than Useless: a False Sense of Security And Wasted Opportunity] | Solomon Rutzky | 2019-08-05 | [SEC] | +| [How to get SQL Server Sysadmin Privileges as a Local Admin with PowerUpSQL] | Scott Sutherland | 2017-05-23 | [PS][SEC] | +| [Views of the Same Problem: Network Admin, DBA, and Developer] | Kyle Brandt | 2011-03-16 | [DBA][DEV] | +| [Finding Max Concurrent Operations With T-SQL (Part 1)] | Kevin Feasel | 2019-01-02 | [DEV] | +| [Finding Max Concurrent Operations With T-SQL (Part 2)] | Kevin Feasel | 2019-01-03 | [DEV] | +| [Stack Overflow: The Architecture - 2016 Edition] | Nick Craver | 2019-02-17 | [DBA][DEV] | +| [Stack Overflow: The Hardware - 2016 Edition] | Nick Craver | 2016-03-29 | [DBA] | +| [Stack Overflow: How We Do Deployment - 2016 Edition] | Nick Craver | 2016-05-03 | [DBA][DEV] | +| [Stack Overflow: How We Do Monitoring - 2018 Edition] | Nick Craver | 2018-11-29 | [DBA][DEV] | +| [Stack Overflow: How We Do App Caching - 2019 Edition] | Nick Craver | 2019-08-06 | [DBA][DEV] | +| [Adding a Missing Index Killed Performance] | Jeffry Schwartz | 2019-08-15 | [DBA][DEV] | +| [Corruption in TempDB] | Steve Stedman | 2019-08-12 | [COR][DBA] | +| [Corruption recovery using DBCC WRITEPAGE] | Paul Randal | 2014-02-13 | [COR][DBA] | +| [Why DBCC CHECKDB can miss memory corruption] | Paul Randal | 2017-07-19 | [COR][DBA] | +| [Fixing Cardinality Estimation Errors with Filtered Statistics] | Klaus Aschenbrenner | 2013-10-29 | [DBA][DEV] | +| [Plan Stitch: Harnessing the Best of Many Plans] | Bailu Ding, Sudipto Das Wentao … | 2018-07-01 | [DBA][DEV] | +| [Query and Resource Optimization: Bridging the Gap] | Lalitha Viswanathan, Alekh Jindal … | 2018-02-01 | [DBA][DEV] | +| [Cuttlefish: A Lightweight Primitive for Adaptive Query Processing] | Tomer Kaftan, Magdalena Balazinska … | 2018-02-01 | [DBA][DEV] | +| [Leveraging Re-costing for Online Optimization of Parameterized Queries with Guarantees] | Anshuman Dutt, Vivek Narasayya … | 2017-05-01 | [DBA][DEV] | +| [How to choose antivirus software to run on computers that are running SQL Server] | Microsoft | 2018-10-31 | [DBA][SEC] | +| [Why is SYSDATETIME() slower than SYSUTCDATETIME()?] | Erik Darling | 2019-05-28 | [DBA][DEV] | +| [Constant Time Recovery in Azure SQL Database] | Panagiotis Antonopoulos, Peter Byrne … | 2019-06-01 | [AZ] | +| [Improving Optimistic Concurrency Control Through Transaction Batching and Operation Reordering] | Bailu Ding, Lucja Kot, Johannes Gehrke | 2019-01-01 | [DBA][DEV] | +| [An Empirical Evaluation of In-Memory Multi-Version Concurrency Control] | Yingjun Wu, Joy Arulraj, Jiexi Lin … | 2019-01-01 | [DBA][DEV] | +| [Automatically Indexing Millions of Databases in Microsoft Azure SQL Database] | Sudipto Das, Miroslav Grbic, Igor Ilic … | 2019-01-01 | [AZ][IDX] | +| [Adding a Column with a Default Constraint] | Matthew Mcgiffen | 2019-07-16 | [DBA][DEV] | +| [A Hidden Value Of Apply] | Erik Darling | 2019-06-24 | [DEV] | +| [Improve Performance of UDFs with NULL ON NULL INPUT] | Jonathan Kehayias | 2018-12-27 | [DEV] | +| [The ‘= NULL’ Mistake and other SQL NULL Heresies] | Phill Factor | 2019-06-17 | [DBA][DEV] | +| [How to Corrupt a Database] | Max Vernon | 2019-07-29 | [DBA][COR] | +| [SQL Server Page Types] | John Huang | 2011-10-31 | [DBA][DEV] | +| [SQL Server Index Maintenance – You’re Doing It Wrong] | Sean Gallardy | 2019-09-01 | [DBA][DEV] | +| [Stop Worrying About SQL Server Fragmentation] | Brent Ozar | 2012-08-14 | [DBA] | +| [How much will it cost or save to rebuild that index?] | Jeff Moden | 2019-09-03 | [DBA][DEV] | +| [To BLOB or Not To BLOB: Large Object Storage in a Database or a Filesystem?] | Russell Sears2, Catharine van Ingen … | 2019-04-01 | [DBA][DEV] | +| [SQL Server UPSERT Patterns and Antipatterns] | Michael J Swart | 2017-07-20 | [DBA][DEV] | +| [Use Caution with SQL Server's MERGE Statement] | Aaron Bertrand | 2018-07-24 | [DBA][DEV] | +| [“UPSERT” Race Condition With MERGE] | Dan Guzman | 2009-01-31 | [DBA][DEV] | +| [Checking for potential constraint violations before entering SQL Server TRY and CATCH logic] | Aaron Bertrand | 2012-02-18 | [DBA][DEV] | +| [Performance impact of different error handling techniques] | Aaron Bertrand | 2012-08-12 | [DBA][DEV] | +| [Backup and Restore Databases with CHECKSUM and VERIFYONLY] | Lori Brown | 2019-08-29 | [B][DBA] | +| [dm_db_database_page_allocations] | Max Vernon | 2019-08-01 | [DBA][DEV] | +| [Compress Big Tables] | Max Vernon | 2019-08-22 | [DBA][DEV] | +| [Hardening SQL Server Security] | Mitch Wheat | 2019-08-21 | [DBA][SEC] | +| [Splitting Strings With OPENJSON] | Dave Mason | 2019-05-06 | [DEV][X] | +| [How to migrate to Amazon RDS for SQL Server using transactional replication] | Richard Waymire | 2018-05-17 | [AMZ][MG] | +| [The Hardest Part Of Query Tuning: Logical Equivalence] | Erik Darling | 2019-08-13 | [DBA][DEV] | +| [SQL Injection: What is it? Causes and exploits] | Ed Pollack | 2019-08-30 | [SEC] | +| [SQL Injection: Detection and prevention] | Ed Pollack | 2019-08-30 | [SEC] | +| [Some T-SQL INSERTs DO Follow the Fill Factor!] | Jeff Moden | 2019-08-08 | [DBA][DEV] | +| [Install SQL Server 2019 Big Data Cluster using Azure Data Studio] | Niels Berglund | 2019-09-11 | [DBA][DEV] | +| [Indirect Checkpoint and tempdb – the good, the bad and the non-yielding scheduler] | Parikshit Savjani | 2018-09-14 | [DBA] | +| [Ghost Records in SQL Server… Now whats that ????] | Sachin Nandanwar | 2011-04-10 | [DBA] | +| [Transaction Isolation Levels and sp_executesql] | Max Vernon | 2019-08-19 | [DBA][DEV] | +| [Batch Mode Bitmaps in SQL Server] | Paul White | 2019-08-23 | [DBA][DEV] | +| [Transparent Data Encryption (TDE) on Azure SQL database] | Ranga Babu | 2019-09-13 | [DBA][AZ] | +| [Analyzing Estimates from the CSelCalcAscendingKeyFilter Calculator] | Josh Darnell | 2019-08-21 | [DEV] | +| [Building Storage for SQL Server (and other database) Virtual Machines in the Cloud] | Joey Dantoni | 2019-09-18 | [AZ] | +| [SQL Server Simple and Forced Parameterization] | Brady Upton | 2013-04-23 | [DBA][DEV] | +| [How to use a SQL Server Plan Guide to Tune Queries] | Armando Prato | 2018-06-02 | [DBA][DEV] | +| [Neglecting to Use, or Misusing, the RETURN Keyword (BP016)] | Phil Factor | 2019-08-14 | [DBA][DEV] | +| [Defensive Error Handling] | Alex Kuznetsov | 2010-10-08 | [DBA][DEV] | +| [A Self-Tuning Fill Factor Technique for SQL Server – Part 1] | Mike Byrd | 2019-08-20 | [DBA][DEV] | +| [A Self-Tuning Fill Factor Technique for SQL Server – Part 2] | Mike Byrd | 2019-08-27 | [DBA][DEV] | +| [SQL: Been told you can't access master database system views in Azure SQL Database? Not true!] | Greg Low | 2019-09-17 | [AZ] | +| [How to increase SQL Database Full Backup speed using compression and Solid State Disks] | Henk | 2010-01-15 | [DBA] | +| [Troubleshooting NUMA Node Imbalance Problems (HammerDB Benchmark)] | Klaus Aschenbrenner | 2019-09-23 | [BENCH] | +| [SQL Server Unequal NUMA CPU engagement] | @sqL_handLe | 2019-09-19 | [DBA] | +| [SSIS Connection Managers: OLE DB vs ODBC vs ADO.NET] | Hadi Fadlallah | 2019-10-04 | [SSIS] | +| [SSIS Data Flows – ADO.NET vs. OLE DB vs. ODBC] | Ross at Datatell | 2015-01-13 | [SSIS] | +| [SSIS – Fastest data flow task item for transferring data over the network] | Gilbert Quevauvilliers | 2013-01-19 | [SSIS] | +| [The Case of the Vanishing Index Compression] | Louis Davidson | 2019-09-30 | [DBA][IDX] | +| [Migrating from MSSQL to PostgreSQL - What You Should Know] | Severalnines | 2018-11-05 | [DEV] | +| [Difference between Identity and Sequence in SQL Server 2012] | Muhammad Imran | 2012-05-01 | [DEV] | +| [Sequence vs Identity – Performance Comparison] | Bill Anton | 2012-09-02 | [DEV] | +| [Read Excel File in SQL Server with OPENROWSET or OPENDATASOURCE] | Diana Moldovan | 2019-10-10 | [DBA][DEV] | +| [Upgrading SQL Server using Availability Groups – Checklist] | Thomas Rushton | 2019-10-17 | [DBA] | +| [Using indexed views? WITH (NOEXPAND) for Standard Edition] | Randolph West | 2019-10-09 | [DEV][IDX] | +| [Using indexed views? What is an imprecise or non-deterministic convert?] | Randolph West | 2019-10-16 | [DEV][IDX] | +| [JSON in your Azure SQL Database? Let’s benchmark some options!] | Silvano Coriani | 2019-10-15 | [X] | +| [Looking for strange - addition to system_health XE] | Tibor Karaszi's | 1753-01-01 | [DBA][XE] | +| [What's new in SQL Server version x] | Tibor Karaszi's | 1753-01-01 | [DBA][DEV] | +| [The ultimate guide to the datetime datatypes] | Tibor Karaszi's | 2010-01-01 | [DBA][DEV] | +| [Some numbers that you will know by heart if you have been working with SQL Server for a while] | Unknown | 2019-03-20 | [DBA][DEV] | +| [#TSQL2sday: How Much Plan Cache History Do You Have?] | Brent Ozar | 2018-07-10 | [DBA][DEV] | +| [Fixing SQL Server Management Studio’s Tab Text] | Brent Ozar | 2011-06-07 | [DBA][DEV] | +| [An overview of the SQL table variable] | Rajendra Gupta | 2019-10-16 | [DBA][DEV] | +| [Performance Impact of Small Queries] | Forrest McDaniel | 2019-06-15 | [DBA][DEV] | +| [How we use SQL Server as a Document Store] | Paul Stovell | 2019-03-24 | [DBA][DEV] | +| [Overlooked T-SQL Gems] | Itzik Ben-Gan | 2019-10-09 | [DBA][DEV] | +| [Are SQL Server database triggers evil?] | Daniel Calbimonte | 2017-01-25 | [DBA][DEV] | +| [Configuration Best Practices for SQL Server Tempdb–Initial Sizing] | Christian Bolton, Justin Langford … | 2013-02-12 | [DBA] | +| [Sql Server Extended Events Trace Overhead] | Nenad Noveljic | 2018-09-04 | [DBA] | +| [Measuring "Observer Overhead" of SQL Trace vs. Extended Events] | Jonathan Kehayias | 2012-10-23 | [DBA][XE] | +| [Performance overhead of tracing with Extended Event targets vs SQL Trace under CPU Load] | Andreas Wolter | 2013-07-01 | [DBA][XE] | +| [Fragmentation, the final installment] | Tibor Karaszi's | 2019-10-18 | [DBA][IX] | +| [Atomic Durability - How do databases recover from a crash ?] | Pedro Ramalhete | 2019-10-01 | [DBA][DEV] | +| [Truth First, or Why You Should Mostly Implement Database First Designs] | Lukas Eder | 2018-06-06 | [DEV] | +| [SQL Server CHECKPOINT, Lazy Writer, Eager Writer and Dirty Pages in SQL Server] | Rajendra Gupta | 2019-08-22 | [DBA] | +| [T-SQL bugs, pitfalls, and best practices – window functions] | Itzik Ben-Gan | 2019-08-14 | [DBA][DEV] | +| [#BackToBasics: Why I use lower case for data type names (now)] | Aaron Bertrand | 2016-10-04 | [DBA][DEV] | +| [New high availability and disaster recovery benefits for SQL Server] | Amit Banerjee | 2019-10-30 | [DBA] | +| [Because Your Index Maintenance Script Is Measuring The Wrong Thing] | Eric Darling | 2019-10-28 | [DBA][IDX] | +| [Memory-Optimized TempDB Metadata] | Niko Neugebauer | 2019-10-30 | [DBA][BENCH]| +| [Build a SQL Cluster Lab Part 1] | Ryan Adams | 2019-10-28 | [DBA] | +| [There is no Such Thing as Object-Relational Impedance Mismatch] | Lukas Eder | 2015-08-26 | [DEV] | +| [ORMs Under the Hood] | Patrycja Dybka | 2015-08-18 | [DEV] | +| [EMERGENCY-mode repair: the very, very last resort] | Paul Randal | 2007-10-02 | [DBA] | +| [Scalar functions and improvements in SQL Server 2019] | Tibor Karaszi's | 2019-11-07 | [DEV] | +| [Scalar functions in SQL server 2019, part 2] | Tibor Karaszi's | 2019-11-07 | [DEV] | +| [Dos and Don'ts of Dynamic SQL] | Thom Andrews | 2019-04-29 | [DEV][DBA] | +| [Differences Between Sql Server TEXT and VARCHAR(MAX) Data Type] | Basavaraj Biradar | 2016-05-11 | [DEV][DBA] | +| [VARBINARY(MAX) Tames the BLOB] | Michael Otey | 2006-08-22 | [DEV][DBA] | +| [Query Store Options in SSMS 18.4] | Erin Stellato | 2019-11-12 | [DBA][QS] | +| [Query Store Performance Overhead: What you need to know] | Erin Stellato | 2018-11-06 | [DBA][QS] | +| [How to fork a GitHub repository and contribute to an open source project] | Rob Sewell | 2019-11-29 | [DBA][DEV] | +| [But I Need To Compare Two Date Columns In My Where Clause] | Eric Darling | 2019-11-27 | [DBA][IDX] | +| [The Difference Between Fault Tolerance, High Availability, & Disaster Recovery] | Patrick Benson | 2014-02-25 | [DBA][DEV] | +| [Why LOB data makes shrink run slooooowly] | Paul Randal | 2010-05-11 | [DBA] | +| [SQL Server 2019 Scalar UDF inlining - out of memory in some cases] | @sqL_handLe | 2019-11-19 | [DBA][DEV] | +| [Is it true that editing a single row in Management Studio empties and reloads the entire table?] | Randolph West | 2019-11-27 | [DBA][DEV] | +| [A Guide to SQL Naming Conventions] | Lukas Eder | 2019-10-29 | [DBA][DEV] | +| [Stop Mapping Stuff in Your Middleware. Use SQL’s XML or JSON Operators Instead] | Lukas Eder | 2019-11-13 | [DBA][DEV] | +| [How Does Accelerated Database Recovery Work] | Forrest McDaniel | 2019-11-26 | [DBA] | +| [Recover SQL Server Resource Database] | Daniel Farina | 2019-10-25 | [DBA] | +| [What’s in that database? Getting information about routines] | Phil Factor | 2019-11-04 | [DBA][DEV] | +| [The Gloop: An Easier way of Managing SQL Server Documentation] | Phil Factor | 2019-12-03 | [DBA][DEV] | +| [The SQL of Gaps and Islands in Sequences] | Dwain Camps | 2013-07-25 | [DEV] | +| [Drop Database Objects Practically Risk-Free!] | Pamela Mooney | 2019-04-17 | [DBA] | +| [Predicate Pushdown and why should I care?] | Pedro Lopes | 2018-07-06 | [DBA][DEV] | +| [Stack Overflow Demo Database Column Store Edition: Downloads And Links] | Eric Darling | 2019-11-11 | [DBA][DEV] | +| [Stack Overflow Demo Database Column Store Edition: Exploring Relationships] | Eric Darling | 2019-11-14 | [DBA][DEV] | +| [Stack Overflow Demo Database Column Store Edition: Helpful Links] | Eric Darling | 2019-11-15 | [DBA][DEV] | +| [Online, Resumable, and WAIT_AT_LOW_PRIORITY operations in SQL Server] | Kendra Little | 2019-12-09 | [DBA][DEV] | +| [How filtered indexes could be a more powerful feature] | Aaron Bertrand | 2013-04-24 | [IDX] | +| [How Forced Parameterization in SQL Server Affects Filtered Indexes] | Aaron Bertrand | 2019-09-19 | [IDX] | +| [Filtered Indexes and Forced Parameterization (redux)] | Aaron Bertrand | 2019-12-03 | [IDX] | +| [Interpreting SQL Server 2019 DBCC MEMORYSTATUS output -- Part 1] | @sqL_handLe | 2019-12-15 | [DBA] | +| [Invisible tempdb Killer] | Josh Darnell | 2019-12-18 | [DBA][DEV] | +| [Batch Mode On Row Store Is Fickle] | Eric Darling | 2019-12-19 | [DBA][DEV] | +| [Use Azure To Store Sql Server Backups Offsite] | Sander Stad | 2019-12-18 | [AZ][B] | +| [Handling Data Returned from a SQL Stored Procedure] | Drew | 2019-12-20 | [DBA][DEV] | +| [When QUERY_OPTIMIZER_COMPATIBILITY_LEVEL_140 does not follow CL 140 rules] | Milos Radivojevic | 2019-12-20 | [DBA][DEV] | +| [SQL Server–HOW-TO: quickly retrieve accurate row count for table] | martijnh1 | 2010-07-15 | [DBA][DEV] | +| [Do You Have REFERENCES?] | Joe Celko | 2019-12-03 | [DBA][DEV] | +| [Fun with (columnstore) compression on a very large table – part 1] | Aaron Bertrand | 2019-12-27 | [DBA] | +| [How to Make SELECT COUNT(*) Queries Crazy Fast] | Brent Ozar | 2019-12-26 | [DBA][DEV] | +| [SSISDB Catalog Defaults Best Practices] | Steve Rezhener | 2019-12-26 | [DBA][DEV] | +| [Temporal Tables, and how to deal with computed columns] | Randolph West | 2019-12-25 | [DBA][DEV] | +| [Cardinality Estimation for Disjunctive Predicates in SQL Server 2014] | Paul White | 2014-04-15 | [DBA][DEV] | +| [Create Distributed Availability Group in Sql Server Linux(Redhat) --- step by step] | Liwei | 2019-11-14 | [DBA] | +| [Connection options in SSMS] | Kenneth Fisher | 2013-11-18 | [DBA][DEV] | +| [A Script To Automatically Align Columnstore Indexes To Enhance Segment Elimination (and Hence Performances)] | Emanuele Meazzo | 2018-06-04 | [DBA][IDX] | +| [Issues with SQLCMD when using special characters] | Daniel Farina | 2018-01-11 | [DBA][DEV] | +| [Encrypting passwords with Python Scripts in SQL Notebooks of Azure Data Studio] | Rajendra Gupta | 2020-01-06 | [DBA][DEV] | +| [Fun with (columnstore) compression on a very large table – part 2] | Aaron Bertrand | 2020-01-07 | [DBA][IDX] | +| [The curious case of the sqlcmd password] | Randolph West | 2020-01-08 | [DBA][DEV] | +| [Setting up Management Studio for remote SQL Server] | aveek22 | 2020-01-06 | [DBA][DEV] | +| [SQL Server Security Best Practices for an Application Installed on SQL Server] | Svetlana Golovko | 2019-12-08 | [DBA][SEC] | +| [PCI Best Practices Guide for SQL Server DBAs] | Tibor Nagy | 2015-05-08 | [DBA][SEC] | +| [SQL Server Security Checklist] | Tibor Nagy | 2014-02-06 | [DBA][SEC] | +| [Replace Model SQL Server Database with a User Database] | Daniel Farina | 2019-12-13 | [DBA] | +| [SQL Server Linux installation for Amazon EC2 instance with Red Hat OS] | Rajendra Gupta | 2020-01-09 | [AMZ | +| [Departure of a SQL Server Administrator – What to Check?] | Thomas Rushton | 2020-01-03 | [DBA] | +| [The Curious Case of… transactions rolling back during DBCC CHECKDB] | Paul Randal | 2020-01-15 | [DBA] | +| [Don’t install SQL Server from a mounted ISO] | Randolph West | 2020-01-15 | [DBA] | +| [NULL complexities – Part 1] | Itzik Ben-Gan | 2019-12-11 | [DBA][DEV] | +| [NULL complexities – Part 2] | Itzik Ben-Gan | 2020-01-08 | [DBA][DEV] | +| [NULL complexities – Part 3] | Itzik Ben-Gan | 2020-02-12 | [DBA][DEV] | +| [How to fix the “Agent XPs disabled” error] | Nisarg Upadhyay | 2019-12-27 | [DBA][DEV] | +| [Number of Rows Read / Actual Rows Read warnings in Plan Explorer] | Rob Farley | 2016-06-02 | [DBA][DEV] | +| [Data Compression + Backup Compression = Double Compression?] | Jess Pomfret | 2019-08-12 | [B][DBA] | +| [How Many Bytes Per Character in SQL Server: a Completely Complete Guide] | Solomon Rutzky | 2019-11-12 | [DBA][DEV] | +| [Storage 101: Welcome to the Wonderful World of Storage] | Robert Sheldon | 2019-12-03 | [DBA][DEV] | +| [How to detect and prevent unexpected growth of the TempDB database] | Ahmad Yaseen | 2020-01-13 | [DBA] | +| [Understanding the SQL Server Proportional fill algorithm] | Ahmad Yaseen | 2016-11-22 | [DBA] | +| [VALUES() and Long Parameter Lists] | Joe Celko | 2010-07-22 | [DBA][DEV] | +| [Going Serverless with Azure SQL Database] | John Miner | 2019-12-20 | [DBA][DEV] | +| [SQLskills SQL101: Why are Statistics so Important?] | Kimberly Tripp | 2020-01-20 | [DBA][DEV] | +| [Configuring SQL Server Express edition as SQL witness server in Database Mirroring] | Nisarg Upadhyay | 2020-01-20 | [DBA] | +| [The Half Apply Query] | Forrest McDaniel | 2020-01-20 | [DBA][DEV] | +| [Import JSON data into SQL Server] | Rajendra Gupta | 2020-01-17 | [X] | +| [Auditing in AWS RDS SQL Server] | Rajendra Gupta | 2020-01-20 | [DBA] | +| [Types of SQL Server Indexes] | Ben Snaidero | 2019-12-24 | [IDX] | +| [Use SQL Server's UNPIVOT operator to help normalize output] | Aaron Bertrand | 2013-07-12 | [DBA][DEV] | +| [Prevent SSMS from seeing the server's file system] | Randi Vertongen | 2019-09-02 | [DBA] | +| [Add the ability to disable or enable a few new DMVs and DMFs introduced in SQL Server 2017] | Microsoft | 2017-11-08 | [DBA] | +| [Actual Difference Between EXISTS(SELECT 1 …), EXISTS(SELECT * …), and EXISTS(SELECT column …)] | Solomon Rutzky | 2020-01-24 | [DBA][DEV] | +| [Why Wait Stats Alone Are Not Enough] | Greg Gonzalez | 2020-01-24 | [DBA][DEV] | +| [Estimating AWS RDS SQL Server costs] | Rajendra Gupta | 2020-01-23 | [DEV] | +| [SQL Server Performance Tuning Using Wait Statistics: A Beginner’s Guide] | Jonathan Kehayias, Erin Stellato | 2014-04-01 | [DBA][DEV] | +| [sys.xp_delete_files and ‘allow filesystem enumeration’: two new undocumented items in SQL Server 2019] | Solomon Rutzky | 2020-01-26 | [DBA][DEV] | +| [Why Database Monitoring Tools Are So Hard to Interpret] | Brent Ozar | 2020-01-27 | [DBA] | +| [Extended Events Misperceptions: Profiler Is Easier] | Grant Fritchey | 2020-01-20 | [DBA][DEV] | +| [Extended Events Misperceptions: Profiler Is Easier, Part 2] | Grant Fritchey | 2020-01-27 | [DBA][DEV] | +| [Automate SFTP File Transfer with SQL Server Agent and WinSCP] | Joe Gavin | 2020-01-16 | [DBA][DEV] | +| [Running Database Console Commands (DBCCs) on Azure SQL Database] | Marcin Policht | 2020-01-20 | [AZ] | +| [How to Remove Times from Dates in SQL Server] | Brent Ozar | 2020-01-29 | [DBA][DEV] | +| [Export/Import Data using BCP - SQL Server on Linux] | Carlos Robles | 2020-01-30 | [DBA][DEV] | +| [Prevent SQL Server Blocking using Lock_Timeout] | Bhavesh Patel | 2020-01-07 | [DBA][DEV] | +| [Bin Packing Problems: The SQL] | Joe Celko | 2012-03-22 | [DBA][DEV] | +| [Causation, Correlation and Crackpots] | Joe Celko | 2009-09-15 | [DBA][DEV] | +| [What Events are in a Trace?] | Erin Stellato | 2020-01-23 | [DBA] | +| [What Are Soft Deletes, and How Are They Implemented?] | Brent Ozar | 2020-02-04 | [DBA][DEV] | +| [Why You Should Switch in Staging Tables Instead of Renaming Them (Dear SQL DBA Episode 26)] | Kendra Little | 2017-01-19 | [DBA][DEV] | +| [Changing a column from int to bigint, without downtime] | Andy Mallon | 2019-12-11 | [DBA][DEV] | +| [I hate sp_estimate_data_compression_savings] | Andy Mallon | 2019-12-17 | [DBA][DEV] | +| [Testing as another user…without their password - impersonate the other user] | Andy Mallon | 2019-12-18 | [DBA][DEV] | +| [How does a database RESTORE affect plan cache?] | Andy Mallon | 2019-10-24 | [DBA] | +| [Recovery of database is 0% complete (approximately 1000000 seconds remain)] | Andy Mallon | 2019-10-12 | [DBA] | +| [Code to purge data based on creation date] | Andy Mallon | 2019-04-04 | [DBA] | +| [Blocking with OBJECT_NAME()] | Andy Mallon | 2019-12-24 | [DBA] | +| [Performance Myths: The query result cache] | Andy Mallon | 2018-07-23 | [DBA][DEV] | +| [Fun with (columnstore) compression on a very large table – part 3] | Aaron Bertrand | 2020-02-03 | [DBA][DEV] | +| [Indexing basics] | Daniel Hutmacher | 2013-02-19 | [IDX] | +| [Working with covering indexes] | Daniel Hutmacher | 2013-02-19 | [IDX] | +| [Using Erik Darling’s sp_pressure_detector to resolve CPU issues] | Jeff Iannucci | 2020-01-28 | [DBA][DEV] | +| [The Accidental DBA (Day 16 of 30): General Security] | Jonathan Kehayias | 2013-01-16 | [DBA][SEC] | +| [Securing Data in SQL Server] | Jonathan Kehayias | 2020-01-27 | [DBA][SEC] | +| [Performance Testing SQL 2008's Transparent Data Encryption] | Rob Garrison | 2009-04-20 | [DBA] | +| [Common SQL Server Security Issues and Solutions] | Paul Randal | 2016-10-04 | [DBA][SEC] | +| [Chaos Engineering and SQL Server] | Andrew Pruski | 2020-01-29 | [DBA] | +| [Different methods to attach SQL Server MDF files] | Nisarg Upadhyay | 2020-02-07 | [DBA] | +| [Learn SQL: How to Write a Complex SELECT Query] | Emil Drkusic | 2020-02-04 | [DBA][DEV] | +| [Filling In Missing Values Using the T-SQL Window Frame] | Dwain Camps | 2014-09-18 | [DBA][DEV] | +| [Select * in a view] | Reitse Eskens | 2020-02-20 | [DBA][DEV] | +| [T-SQL TUESDAY #123: Aggregates of Aggregates using Windowing Functions] | James Mcgillivray | 2020-02-20 | [DBA][DEV] | +| [SQL Server Statistics: Explained] | Krishna Golla | 2012-09-04 | [DBA][DEV] | +| [How to Pass a List of Values Into a Stored Procedure] | Brent Ozar | 2020-02-13 | [DBA][DEV] | +| [What's the difference between a temp table and table variable in SQL Server?] | Paul White | 2019-05-04 | [DBA][DEV] | +| [Be Mindful of SQL Server Tempdb Use (aka Tempdb Parasites!)] | Jason Hall | 2020-01-28 | [DBA][DEV] | +| [Robyn Page’s SQL Server Cursor Workbench (Quirky Update)] | Robyn Page | 2007-01-24 | [DBA][DEV] | +| [Solving the Running Total and Ordinal Rank Problems (Rewritten) (Quirky Update)] | Jeff Moden | 2012-01-27 | [DBA][DEV] | +| [Running totals in “Denali” CTP3 (Quirky Update)] | Wayne Sheffield | 2011-08-23 | [DBA][DEV] | +| [WHERE GETDATE() BETWEEN StartDate AND EndDate Is Hard to Tune.] | Brent Ozar | 2020-02-18 | [DBA][DEV] | +| [WHERE GETDATE() BETWEEN StartDate AND COALESCE(CancelDate, EndDate) Is Even Harder to Tune.] | Brent Ozar | 2020-02-19 | [DBA][DEV] | +| [How to solve the SQL Identity Crisis in SQL Server] | Ed Pollack | 2017-11-14 | [DBA][DEV] | +| [Significant SQL Server 2019 licensing changes] | Kevin Chant | 2020-02-17 | [DBA] | +| [Indexed View Maintenance Is Only As Bad As Your Indexes] | Erik Darling | 2020-02-19 | [DBA][DEV] | +| [Why Design Impacts Performance on Microsoft SQL Server] | Kevin Kline | 2020-01-29 | [DBA][DEV] | +| [Apply versus Nested Loops Join] | Paul White | 2019-06-09 | [DBA][DEV] | +| [Inside the Optimizer: Constructing a Plan - Part 1] | Paul White | 2010-07-29 | [DBA][DEV] | +| [Inside the Optimizer: Constructing a Plan - Part 2] | Paul White | 2010-07-29 | [DBA][DEV] | +| [Inside the Optimizer: Constructing a Plan - Part 3] | Paul White | 2010-07-31 | [DBA][DEV] | +| [Inside the Optimizer: Constructing a Plan - Part 4] | Paul White | 2010-07-31 | [DBA][DEV] | +| [Tips for dealing with large SQL Server scripts] | Kevin Chant | 2020-02-24 | [DBA][DEV] | +| [Database Normalization in SQL with Examples] | Gouri Shankar | 2020-02-18 | [DBA][DEV] | +| [Why SQL Server May Not Parallelize a Query] | SolarWinds | 2015-10-30 | [DBA][DEV] | +| [Parallelism in SQL Server Execution Plan] | Ahmad Yaseen | 2018-03-30 | [DBA][DEV] | +| [An XEvent a Day (26 of 31) – Configuring Session Options] | Jonathan Kehayias | 2010-12-26 | [XE] | +| [Azure SQL Managed Instance Performance Considerations] | Tim Radney | 2020-02-26 | [AZ] | +| [The Curious Case of… whether corruption can propagate to secondary databases] | Paul Randal | 2020-02-26 | [COR][DBA] | +| [Stop and Think Before You Shrink – Shrinking a SQL Server Database] | Jeff Mlakar | 2018-09-25 | [DBA] | +| [How to Analyze the SQL Server Error Log] | Jeff Mlakar | 2018-11-02 | [DBA] | +| [Converting SQL Trace to Extended Events in SQL Server 2012] | Jonathan Kehayias | 2012-04-04 | [DBA] | +| [What event information can I get by default from SQL Server?] | Aaron Bertrand | 2019-03-28 | [DBA] | +| [Removing the default trace – Part 1] | Aaron Bertrand | 2020-03-02 | [DBA] | +| [Removing the default trace – Part 2] | Aaron Bertrand | 2020-03-02 | [DBA] | +| [Removing the default trace – Part 3] | Aaron Bertrand | 2020-03-02 | [DBA] | +| [Keeping DRY in SQL Server with Scalar User Defined Functions – Part 1] | Adrian Hills | 2020-02-20 | [DBA][DEV] | +| [Different Ways to Monitor SQL Server AlwaysOn Availability Groups] | Nisarg Upadhyay | 2020-02-21 | [DBA] | +| [SQL Server internals: Is Order of Column in the table important?] | Ronen Ariely | 2018-08-11 | [DBA][DEV] | +| [Code: Order of columns in table might impact the size of the table/database and even related to errors] | Ronen Ariely | 2019-10-13 | [DBA][DEV] | +| [SQL Server Internals: Getting the data of deleted column] | Ronen Ariely | 2018-11-28 | [DBA][DEV] | +| [Queue table issues with Availability Groups in SQL Server] | Aaron Bertrand | 2020-01-29 | [DBA] | +| [Transact-SQL: openjson hierarchy solution] | Ronen Ariely | 2019-09-29 | [DBA][DEV] | +| [CREATE DLL TRIGGER ON CREATE_LOGIN to configure default parameters for any new LOGIN] | Ronen Ariely | 2019-10-12 | [DBA][DEV] | +| [SQL Server Internals: Getting the data of deleted column] | Ronen Ariely | 2018-08-11 | [DBA][DEV] | +| [SQL varchar data type deep dive] | Gauri Mahajan | 2019-05-29 | [DBA][DEV] | +| [What is the datatype SQL_VARIANT] | Kenneth Fisher | 2020-04-16 | [DBA][DEV] | +| [An Introduction to Asynchronous Processing with Service Broker] | Jonathan Kehayias | 2014-03-18 | [DBA][DEV] | +| [Detecting and Alerting on SQL Server Agent Missed Jobs] | Ed Pollack | 2019-02-21 | [DBA][J] | +| [Execute multiple jobs Synchronously from in a main job] | Ronen Ariely | 2020-04-11 | [J] | +| [Why Ordering Isn’t Guaranteed Without an ORDER BY] | Brent Ozar | 2020-04-22 | [DBA][DEV] | +| [How to Attach a SQL Server Database without a Transaction Log and with Open Transactions] | Daniel Farina | 2020-04-29 | [COR] | +| [SQL 2016 - It Just Runs Faster: Indirect Checkpoint Default] | Ryan Stonecipher, Peter Byrne, Bob Dorr | 2016-04-12 | [DBA][CHP] | +| [How do checkpoints work and what gets logged] | Paul Randal | 2009-09-27 | [DBA][CHP] | +| [Inside the Storage Engine: What’s in the buffer pool?] | Paul Randal | 2008-08-26 | [DBA] | +| [What does checkpoint do for tempdb?] | Paul Randal | 2009-10-07 | [DBA][CHP] | +| [Performance issues from wasted buffer pool memory] | Paul Randal | 2011-06-01 | [DBA] | +| [How It Works: When is the FlushCache message added to SQL Server Error Log?] | Bob Dorr | 2012-01-06 | [DBA] | +| [Negative identity values don’t suck] | Randolph West | 2020-05-06 | [DBA][DEV] | +| [How SQL Server stores data types: integers and decimals] | Randolph West | 2020-05-13 | [DBA][DEV] | +| [How SQL Server stores data types: DATETIME, DATE, TIME, and DATETIME2] | Randolph West | 2020-04-22 | [DBA][DEV] | +| [Cross Database Transactions on One Server] | Michael J Swart | 2020-05-15 | [DBA][DEV] | +| [Your Views Aren’t The Problem. Your Code Is.] | Brent Ozar | 2020-05-06 | [DBA][DEV] | +| [Can I Offload DBCC CHECKDB To Another Server?] | Brent Ozar | 2020-05-19 | [DBA] | +| [Negative (-) is an operator and will affect the order of operations.] | Kenneth Fisher | 2020-05-18 | [DBA][DEV] | +| ["0 to 60" : Switching to indirect checkpoints] | Aaron Bertrand | 2020-05-01 | [DBA][CHP] | +| [Parallelism Can Make Queries Perform Worse.] | Brent Ozar | 2020-05-20 | [DBA][DEV] | +| [A SQL Server DBA myth a day: (15/30) checkpoint only writes pages from committed transactions] | Paul Randal | 2010-04-15 | [DBA][CHP] | +| [Can You Use NVARCHAR As a Universal Parameter? Almost.] | Brent Ozar | 2020-04-30 | [DBA][DEV] | +| [The Learner’s Guide to SQL Server Performance Triage] | Kendra Little | 2020-03-19 | [DBA] | +| [Learner’s Guide to SQL Server Query Tuning] | Kendra Little | 2020-05-01 | [DBA][DEV] | +| [How to Get Better Estimates for Modification Queries] | Brent Ozar | 2020-04-27 | [DBA][DEV] | +| [SSMS: Prevent Copy and Paste of Text in “Messages” tab (Cruel Joke #2)] | Solomon Rutzky | 2020-05-22 | [DBA][DEV] | +| [Compare the Best SQL Server Performance Monitoring Tools] | SentryOne | 2020-01-01 | [DBA][DEV] | +| [Minimal Logging with INSERT…SELECT into Heap Tables] | Paul White | 2020-05-01 | [DBA][DEV] | +| [Minimal Logging with INSERT…SELECT into Empty Clustered Tables] | Paul White | 2020-05-16 | [DBA][DEV] | +| [Minimal Logging with INSERT…SELECT and Fast Load Context] | Paul White | 2020-05-19 | [DBA][DEV] | +| [Avoiding SQL Server Upgrade Performance Issues] | Glenn Berry | 2020-02-05 | [DBA][DEV] | +| [Compatibility Levels and Cardinality Estimation Primer] | Glenn Berry | 2020-01-29 | [DBA][DEV] | +| [An approach to index tuning – Part 1] | Erin Stellato | 2020-03-26 | [DBA][DEV] | +| [An approach to index tuning – Part 2] | Erin Stellato | 2020-04-13 | [DBA][DEV] | +| [Moving A Database to New Storage With No Downtime] | Bob Pusateri | 2013-03-12 | [DBA] | +| [RESOURCE_GOVERNOR_IDLE in Azure] | Josh Darnell | 2020-06-15 | [AZ] | +| [Automated Backup Tuning] | Nicholas Cain | 2012-12-13 | [B] | +| [Optimizing Database Restores] | Nicholas Cain | 2011-09-26 | [DBA] | +| [AVAILABILITY_REPLICA - The Deception of the Log Reuse Wait Type] | Nicholas Cain | 2020-05-19 | [DBA] | +| [Changing an INT to a BIGINT with no downtime] | Michael J Swart | 2020-06-19 | [DBA] | +| [New Metadata-Only Column Changes in SQL Server 2016] | Paul White | 2020-04-17 | [DBA][DEV] | +| [Bandwidth-friendly Query Profiling for Azure SQL Database] | Greg Gonzalez | 2020-04-15 | [AZ][XE] | +| [Column scope and binding order in subqueries] | Gail Shaw | 2019-04-23 | [DBA][DEV] | +| [Improve SQL Server Extended Events system_health Session] | Aaron Bertrand | 2020-06-17 | [DBA][DEV] | +| [Page Life Expectancy Doesn’t Mean Jack, and You Should Stop Looking At It.] | Brent Ozar | 2020-06-17 | [DBA][DEV] | +| [Unsupported but working versions of SQL Server on Windows Server 2019] | Randolph West | 2020-06-24 | [DBA][DEV] | +| [Bad Idea Jeans: Building Big Query Plans] | Brent Ozar | 2020-06-23 | [DBA][DEV] | +| [SQL Server performance tuning – RESOURCE_SEMAPHORE waits] | Timothy Smith | 2020-06-16 | [DBA][DEV] | +| [Use session_context to create a “variable” that lasts between batches.] | Kenneth Fisher | 2020-05-26 | [DBA][DEV] | +| [Phase out CONTEXT_INFO() in SQL Server 2016 with SESSION_CONTEXT()] | Aaron Bertrand | 2015-11-19 | [DBA][DEV] | +| [How to Balance SQL Server Core Licenses Across NUMA Nodes] | Glenn Berry | 2020-06-25 | [DBA] | +| [What is the Difference Between Physical Sockets, Physical Cores, and Logical Cores?] | Glenn Berry | 2019-12-18 | [DBA] | +| [What is the Difference Between Physical Sockets, Physical Cores, and Logical Cores?] | Kevin Kline | 2020-06-01 | [DBA][DEV] | +| [The 201 Buckets Problem, Part 1: Why You Still Don’t Get Accurate Estimates] | Brent Ozar | 2020-07-07 | [DBA][DEV] | +| [The 201 Buckets Problem, Part 2: How Bad Estimates Backfire As Your Data Grows] | Brent Ozar | 2020-07-08 | [DBA][DEV] | +| [Sql Server — Widely Random Query Exec Times (cxconsumer Wait/cxpacket) & Possible Remediation] | VIKTOR | 2020-06-26 | [DBA][DEV] | +| [How MAXDOP Really Works] | Paul White | 2020-06-07 | [DBA][DEV] | +| [What is MaxDOP controlling?] | Pedro Lopes | 2020-07-07 | [DBA][DEV] | +| [What If You Really DO Need to Shrink a Database?] | Brent Ozar | 2020-07-14 | [DBA] | +| [Everything I Never Wanted to Know About Collation] | Kendra Little | 2020-07-16 | [DBA][DEV] | +| [Comparing SSIS And Azure Data Factory] | Tim Mitchell | 2020-07-16 | [AZ][SSIS] | +| [sp_Blitz for All Servers] | Garry Bargsley | 2020-07-14 | [DBA] | +| [Where is the SQL Server Community Networking Online?] | Brent Ozar | 2020-07-13 | [DBA][DEV] | +| [Make the most out of your Azure Disks using Storage Pools] | Roberto Marras | 2020-07-01 | [AZ][DBA] | +| [SQL Server High Availability Solutions on Azure VMs] | Marco Obinu | 2020-07-12 | [AZ][DBA] | +| [How to Get Started with SQL Server Management Studio] | Brent Ozar | 2020-07-21 | [DBA][DEV] | +| [How should I store currency values in SQL Server?] | Randolph West | 2020-06-03 | [DBA][DEV] | +| [Read committed isolation level doesn’t guarantee much…] | Paul Randal | 2010-04-17 | [DBA][DEV] | +| [Prevent Unexpected Failovers When Patching AGs] | Josh Darnell | 2010-05-21 | [DBA] | +| [Updating Statistics Causes Parameter Sniffing] | Brent Ozar | 2010-06-02 | [DBA][DEV] | +| [The Ascending Key Problem in Fact Tables– Part one: Pain!] | Thomas Kejser | 2011-01-01 | [DBA][DEV] | +| [The Ascending Key Problem In Fact Tables –Part Two: Stat Job!] | Thomas Kejser | 2011-07-07 | [DBA][DEV] | +| [Are Statistics Being Used for inserted and deleted tables and table variables?] | Deborah Melkin | 2020-05-05 | [DBA][DEV] | +| [Tackling Imperial and US Customary Measurements in Databases] | Phil Factor | 2020-05-06 | [DBA][DEV] | +| [In-Memory OLTP Best Practices – Part 1] | Jon Guerin, Daniel Taylor | 2020-03-11 | [DBA][DEV] | +| [In-Memory OLTP Best Practices – Part 2] | Jon Guerin, Daniel Taylor | 2020-05-06 | [DBA][DEV] | +| [Things I Wished More Developers Knew About Databases] | Jaana Dogan | 2020-04-21 | [DBA][DEV] | +| [Online migrations at scale] | Jacqueline Xu | 2017-02-02 | [DBA] | +| [The Dirty (Baker’s) Dozen of SQL Server Technical Debt] | Andy Jones | 2020-06-01 | [DBA][DEV] | +| [15 SQL Server Performance Counters to Monitor In 2020] | Allen White | 2020-05-05 | [DBA][DEV] | +| [Pulling Group By Above a Join] | Paul White | 2020-05-31 | [DBA][DEV] | +| [SQLskills SQL101: Running out of ints and bigints] | Paul Randal | 2017-10-03 | [DBA][DEV] | +| [Understanding and Using Parallelism in SQL Server] | Paul White | 2011-03-03 | [DBA][DEV] | +| [Top Asked Availability Group Questions… and Maybe Some Helpful Tidbits as Answers] | Sean Gallardy | 2020-06-16 | [DBA] | +| [Encrypting SQL Server Database Backups] | David Fowler | 2018-04-04 | [DBA] | +| [Using Track Causality to Understand Query Execution] | Erin Stellato | 2019-01-04 | [DBA][DEV] | +| [Understanding SQL Server Backup Types] | Prashanth Jayaram | 2018-04-19 | [B][DBA] | +| [Scripting the Description of Database Tables Using Extended Properties] | Phil Factor | 2020-03-03 | [DBA][DEV] | +| [The Table Variable in SQL Server] | Esat Erkec | 2019-12-03 | [DBA][DEV] | +| [Multiple Plans for an "Identical" Query] | Aaron Bertrand | 2014-11-20 | [DBA][DEV] | +| [Another argument for stored procedures versus ORM versus Add Hoc Queries] | Aaron Bertrand | 2013-05-17 | [DBA][DEV] | +| [Bad habits to kick : avoiding the schema prefix] | Aaron Bertrand | 2019-09-12 | [DBA][DEV] | +| [How not to call Hekaton natively-compiled stored procedures] | Aaron Bertrand | 2015-06-05 | [DBA][DEV] | +| [A One-Slide Summary of the Differences Between TDE and Always Encrypted] | Brent Ozar | 2020-07-31 | [SEC] | +| [Remember “Nothing Stops a Hekaton Transaction?” Yeah, About That.] | Brent Ozar | 2020-07-29 | [DBA][DEV] | +| [Finding & Downloading Required SQL Server Updates] | Andy Levy | 2020-07-21 | [DBA] | +| [SQLskills SQL101: Why do some wait types need to be ignored?] | Paul Randal | 2018-05-23 | [DBA][DEV] | +| [What is the SOS_WORK_DISPATCHER Wait Type? (Or how to work with Call Stacks in SQL Server)] | Joe Obbish | 2018-09-27 | [DBA][DEV] | +| [SQL Server 2019 Aggregate Splitting] | Paul White | 2020-08-04 | [DBA][DEV] | +| [Security Best Practice: dny and revoke permissions granted to All Users by default - HIGHLY IMPORTANT!] | Ronen Ariely | 2019-10-13 | [DBA][SEC] | +| [The Trillion Row Table] | Joe Obbish | 2020-08-12 | [BENCH] | +| [Temporal Tables and Table Partitioning: Not If You Like Switching Partitions] | Erik Darlling | 2020-03-03 | [DBA][DEV] | +| [Long Running Query on Read-Only Replica that takes moments on the Primary] | Sean Gallardy,Joe Obbish | 2019-09-05 | [DBA][DEV] | +| [Date Tables are Great for Users, but Not So Great for Performance] | Brent Ozar | 2020-08-05 | [DBA][DEV] | +| [Should I install SSMS on a server running SQL Server?] | Andy Mallon | 2020-04-14 | [DBA][DEV] | +| [Finding a table name from a page ID] | Paul Randal | 2014-09-25 | [DBA][DEV] | +| [Finding Distinct Values Quickly] | Paul White | 2020-04-17 | [DBA][DEV] | +| [Can You Fail To Spill To tempdb?] | Josh Darnell | 2019-07-17 | [DBA][DEV] | +| [Migrating SQL workloads to Microsoft Azure: Databases Trip to Azure SQL Database] | Ahmad Yaseen | 2020-08-03 | [AZ][DBA] | +| [How It Works: Bob Dorr's SQL Server I/O Presentation] | Bob Dorr | 2010-03-24 | [DBA][DEV] | +| [Who does SQL Server run xp_cmdshell command as?] | Steve Stedman | 2020-04-14 | [DBA][DEV] | +| [Transaction Modes in SQL Server] | Kevin Feasel | 2020-08-10 | [DBA][DEV] | +| [Working Effectively with Legacy SQL] | Kevin Feasel | 2015-03-15 | [DBA][DEV] | +| [A SQL Server DBA myth a day: (26/30) nested transactions are real] | Paul Randal | 2010-04-26 | [DBA][DEV] | +| [dbatools multithreading commands with PoshRSJob module] | Kin | 2019-01-04 | [DBA][PS] | +| [SQL Server Debugging with WinDbg – an Introduction] | Klaus Aschenbrenner | 2014-05-05 | [DBA][DEV] | +| [Looking deeper into SQL Server using Minidumps] | Thomas Kejser | 2009-09-11 | [DBA][DEV] | +| [Anatomy of a spool operators in SQL Server execution plans] | Hugo Kornelis | 2020-01-01 | [DBA][DEV] | +| [CAST v/s CONVERT – Is there a difference as far as SQL Server is concerned? Which is better?] | Nakul Vachhrajani | 2011-07-18 | [DBA][DEV] | +| [#BackToBasics: CAST vs. CONVERT] | Aaron Bertrand | 2016-11-02 | [DBA][DEV] | +| [Productivity Hacks: Migrate in Minutes to the Most Current Version of SQL Server] | Chris Lumnah | 2020-07-29 | [DBA] | +| [Database alias in Microsoft SQL Server] | Bohumír Kubík | 2011-01-11 | [DBA][DEV] | +| [The Curious Case of… the 8060-byte row size limit] | Paul Randal | 2020-03-11 | [DBA][DEV] | +| [.NET TransactionScope Considered Annoying - Default Isolation Level is Serializable] | Josh Darnell | 2020-07-27 | [DBA][DEV] | +| [Parameter Sniffing, Embedding, and the RECOMPILE Options] | Paul White | 2013-08-28 | [DBA][DEV] | +| [Why You’re Tuning Stored Procedures Wrong (the Problem with Local Variables)] | Kendra Little | 2020-05-06 | [DBA][DEV] | +| [Yet Another Post About Local Variables] | Erik Darlling | 2020-03-31 | [DBA][DEV] | +| [Cleaning up Backups from Azure Blob Storage] | Niko Neugebauer | 2020-03-30 | [AZ][B] | +| [Temporary Table Caching Explained] | Paul White | 2012-08-17 | [DBA][DEV] | +| [SQL Server Temporary Object Caching] | Paul White | 2017-05-02 | [DBA][DEV] | +| [3 Ways to Run DBCC CHECKDB Faster] | Brent Ozar | 2020-08-27 | [DBA][DEV] | +| [Back Up SQL Server 43%-67% Faster by Writing to Multiple Files] | Brent Ozar | 2020-08-23 | [DBA][DEV] | +| [Bad Habits to Kick : Using SELECT * / omitting the column list] | Aaron Bertrand | 2009-10-10 | [DBA][DEV] | +| [All The Problems With Select *] | Erik Darlling | 2019-12-10 | [DBA][DEV] | +| [When Select * Doesn’t Matter] | Erik Darlling | 2019-11-18 | [DBA][DEV] | +| [HT Waits – Explained and Animated] | Forrest McDaniel | 2020-08-12 | [DBA][DEV] | +| [SQL Server 100% Online Deployments] | Michael J Swart | 2018-01-05 | [DBA] | +| [The Curious Case of… setting up a server for DBCC CHECKDB] | Paul Randal | 2020-08-24 | [DBA] | +| [When should a primary key be declared non-clustered?] | Paul White | 2012-12-01 | [IDX] | +| [Guid vs INT - Which is better as a primary key?] | Sandeep Kumar M | 2011-01-05 | [DBA][DEV] | +| [Control SQL Jobs based on HADR Role – Taking it to the Next Level] | Eitan Blumin | 2020-05-26 | [DBA][J] | +| [SQL Friday #16: Eitan Blumin on “How to HADR Your SQL Jobs”] | Eitan Blumin | 2020-07-31 | [DBA][J] | +| [Choosing the Correct Azure VM Size for Your Workload] | Eric Smith | 2020-09-09 | [AZ][DBA] | +| [Table Partitioning in SQL Server – The Basics] | Cathrine Wilhelmsen | 2015-04-12 | [AZ][DBA] | +| [Table Partitioning in SQL Server – Partition Switching] | Cathrine Wilhelmsen | 2015-04-19 | [AZ][DBA] | +| [TempDB in SQL Server] | SentryOne | 2020-09-15 | [DBA] | +| [SQL Server’s Cost Threshold for Parallelism] | Kendra Little | 2014-11-20 | [DBA][DEV] | +| [How many CPUs is my parallel query using in SQL Server?] | Kendra Little | 2014-05-04 | [DBA][DEV] | +| [Protecting your data against unauthorised reads on SQL Server] | Monin | 2020-06-24 | [SEC] | +| [SET IMPLICIT_TRANSACTIONS ON Is One Hell of a Bad Idea] | Brent Ozar | 2019-05-06 | [DBA][DEV] | +| [Tempdb: The Ghost Of Version Store] | Stijn Wynants | 2015-11-09 | [DBA][DEV] | +| [When Tempdb Becomes Permanentdb (In-memory tempdb metadata and Resource governor problems)] | Glenn Boonen | 2020-05-07 | [DBA][DEV] | +| [The Best Medium-Hard Data Analyst SQL Interview Questions] | Zachary Thomas | 2020-01-01 | [DBA][DEV] | +| [Starting SQL: Why Not Make Everything Dynamic?] | Eric Darling | 2020-09-28 | [DBA][DEV] | +| [dbatools multithreading commands] | Kin | 2019-01-04 | [PS] | +| [Preventing Brute Force Attacks in SQL Server] | Raul Gonzalez | 2020-01-01 | [SEC] | +| [Asynchronous T-SQL Execution Without Service Broker] | Oleg Vorkunov | 2008-09-15 | [CLR] | +| [Using hash values in SSIS to determine when to insert or update rows] | Koen Verbeeck | 2019-10-15 | [SSIS] | +| [Capturing Queries Can Be A Pain] | Grant Fritchey | 2020-08-03 | [XE] | +| [Building full-text indexes using the Sphinx search engine] | Hadi Fadlallah | 2020-08-04 | [DBA][DEV] | +| [Starting SQL: Measuring A Query] | Eric Darling | 2020-09-28 | [DBA][DEV] | +| [When to use SET vs SELECT when assigning values to variables in SQL Server] | Atif Shehzad | 2009-11-25 | [DBA][DEV] | +| [What is the difference between SET and SELECT when assigning values to variables, in T-SQL?] | Narayana Vyas Kondreddi | 2005-10-29 | [DBA][DEV] | +| [CHECKDB From Every Angle: How long will CHECKDB take to run?] | Paul Randal | 2007-11-15 | [DBA] | +| [CHECKDB From Every Angle: Consistency Checking Options for a VLDB] | Paul Randal | 2007-11-19 | [DBA] | +| [Minimizing the impact of DBCC CHECKDB : DOs and DON'Ts] | Aaron Bertrand | 2012-11-29 | [DBA] | +| [A faster CHECKDB – Part II] | Bob Ward | 2012-02-23 | [DBA] | +| [A faster CHECKDB – Part III] | Bob Dorr | 2014-11-10 | [DBA] | +| [A faster CHECKDB – Part III] | Bob Dorr | 2015-01-26 | [DBA] | +| [A faster CHECKDB – Part IV (SQL CLR UDTs)] | Bob Dorr | 2015-01-26 | [DBA] | +| [Minimize performance impact of SQL Server DBCC CHECKDB] | Robert Pearl | 2011-06-02 | [DBA] | +| [Starting SQL: A Little More Fun With Logging Dynamic SQL] | Eric Darling | 2020-10-01 | [DBA][DEV] | +| [Allocation Order Scans] | Paul White | 2015-01-23 | [DBA][DEV] | +| [Parameter Sniffing in SQL Server 2019: Air_Quote_Actual Plans] | Brent Ozar | 2020-05-26 | [DBA][DEV] | +| [Guide For Set Up Of Telegraf For Monitoring Sql Server Xplat] | Tracy Boggiano | 2018-02-24 | [DBA] | +| [Azure Table Storage Tips for the RDBMS Developer] | Adrian Hills | 2020-10-21 | [AZ] | +| [sql_handle and the SQL Server batch text hash] | Paul White | 2020-10-11 | [DBA][DEV] | +| [Navigating DBCC CHECKDB for VLDB] | Aaron Bertrand | 2020-11-05 | [DBA] | +| [Hidden Formatting Troubles with STR() (SQL Spackle)] | Jeff Moden | 2019-04-26 | [DBA][DEV] | +| [The What, Why, When, and How of Incremental Loads] | Tim Mitchell | 2020-07-23 | [DBA][DEV] | +| [How Do I Know If My Query Is Good Enough for Production?] | Brent Ozar | 2020-08-12 | [DBA][DEV] | +| [How to Find Out Whose Queries are Using The Most CPU] | Brent Ozar | 2020-08-10 | [DBA][DEV] | +| [Limitations of SQL Server Native Backup and Restore in Amazon RDS] | Sadequl Hussain | 2017-08-23 | [AMZ][B] | +| [SQL Server Native Backup and Restore in Amazon RDS] | Sadequl Hussain | 2017-08-18 | [AMZ][B] | +| [What Is the SQL Server CEIP Service (telemetry)?] | Brent Ozar | 2020-10-07 | [DBA] | +| [Maximum Simultaneous User Connections] | Michael J Swart | 2020-10-16 | [DBA] | +| [Find Database Connection Leaks in Your Application] | Michael J Swart | 2017-07-07 | [DBA][DEV] | +| [How to Troubleshoot THREADPOOL Waits and Deadlocked Schedulers] | Eitan Blumin | 2020-10-05 | [DBA][DEV] | +| [Prevent Lock Escalation On Indexed Views] | Thomas Costers | 2019-10-30 | [DBA][DEV] | +| [Concatenating Strings in SQL Server] | Guy Glantser | 2020-11-30 | [DBA][DEV] | +| [Why Full Text’s CONTAINS Queries Are So Slow] | Brent Ozar | 2020-11-07 | [DBA][DEV] | +| [Migrating SSIS to Azure – an Overview] | Koen Verbeeck | 2020-11-03 | [AZ][MG] | +| [A Parameterization Puzzle With TOP: Part 1] | Eric Darling | 2020-10-21 | [DBA][DEV] | +| [A Parameterization Puzzle With TOP: Part 2] | Eric Darling | 2020-10-22 | [DBA][DEV] | +| [T-SQL: Get The Text Between Two Delimiters] | Eric Darling | 2020-10-22 | [DBA][DEV] | +| [Explore dynamic management views for monitoring SQL Server Always On Availability Groups] | Rajendra Gupta | 2020-11-16 | [DBA] | +| [Deploy SQLWATCH to SQL Server using GitHub Actions] | Kevin Chant | 2020-11-17 | [DBA] | +| [SQL Server table hints – WITH (NOLOCK) best practices] | Ahmad Yaseen | 2018-02-24 | [DBA][DEV] | +| [Memory-Optimized TempDB Metadata in SQL Server 2019] | Aaron Bertrand | 2020-02-14 | [DBA] | +| [SQLskills SQL101: Should you kill that long-running transaction?] | Paul Randal | 2020-10-10 | [DBA][DEV] | +| [A quick and dirty scan of a list of instances using a dynamic linked server] | Kenneth Fisher | 2020-11-12 | [DBA] | +| [sp_whoisactive: Analyzing Tempdb Contention] | Adam Machanic | 2017-01-01 | [DBA][DEV] | +| [How to Choose Between RCSI and Snapshot Isolation Levels] | Little Kendra | 2018-02-18 | [DBA][DEV] | +| [Explore the SQL query table hint READPAST] | Rajendra Gupta | 2020-11-14 | [DBA][DEV] | +| [How Bad Statistics Cause Bad SQL Server Query Performance] | Brent Ozar | 2020-11-14 | [DBA][DEV] | +| [How Scalar User-Defined Functions Slow Down Queries] | Brent Ozar | 2020-11-14 | [DBA][DEV] | +| [Could verifying your backups be costing you money?] | Matt Robertshaw | 2020-01-01 | [AZ][B] | +| [Extended Events: System_health And A Long Running Query] | Grant Fritchey | 2020-05-09 | [XE] | +| [Altering an indexed view in SQL Server drops all indexes] | Little Kendra | 2020-03-02 | [DBA][DEV] | +| [Deprecated and discontinued features in SQL Server] | Randolph West | 2020-03-04 | [DBA][DEV] | +| [Query Store, Plan Forcing, And Drop/create] | Grant Fritchey | 2020-03-02 | [QS] | +| [Uncommon SQL in SQL Server] | Shane O'Neill | 2020-11-20 | [DBA][DEV] | +| [Configure SQL Server Replication between AWS RDS SQL Server and On-premises SQL Server] | Rajendra Gupta | 2020-11-12 | [AMZ] | +| [Import data into Azure SQL database from AWS Redshift] | Rahul Mehta | 2020-11-10 | [AMZ][AZ] | +| [When You’re Troubleshooting Blocking, Look at Query #2, Too.] | Brent Ozar | 2020-11-19 | [DBA][DEV] | +| [Finding the One Query to Tune in a Multi-Query Batch] | Brent Ozar | 2020-11-23 | [DBA][DEV] | +| [Recursion in SQL Explained Visually] | Denis Lukichev | 2020-11-22 | [DBA][DEV] | +| [Viva la Famiglia! Stored procedure for created recursive family tree] | Brad Schulz | 2020-10-01 | [DEV] | +| [How to Set & Get the Next ID Without Serializable Isolation] | Brent Ozar | 2020-11-25 | [DBA][DEV] | +| [Discovering Three or Four Part Names in SQL Server Database Code] | Louis Davidson | 2019-03-08 | [DBA][DEV] | +| [Troubleshooting RESOURCE_SEMAPHORE_QUERY_COMPILE Helper Queries] | Eric Darling | 2020-11-24 | [DBA][DEV] | +| [When Do I Need to Use DESC in Indexes?] | Brent Ozar | 2020-11-30 | [DBA][DEV] | +| [Export Power BI Desktop data to SQL Server] | Rui Romano | 2016-04-21 | [DBA][DEV] | +| [Exploring errors to reveal unauthorized information] | Fabiano Amorim | 2020-10-19 | [SEC] | +| [How to run your CTE just once, and re-use the output] | Daniel Hutmacher | 2020-12-01 | [DBA][DEV] | +| [Documenting SSIS Packages using Sequence Diagrams] | Aveek Das | 2020-11-25 | [SSIS] | +| [Performance testing with DBCC DROPCLEANBUFFERS] | Dan Guzman | 2018-07-29 | [P] | +| [Optimizing memory settings in Analysis Services] | Marco Russo | 2020-12-07 | [DBA] | +| [VMware and SQL Server Best Practices] | Mike Walsh | 2020-12-02 | [DBA] | +| [Autoparameterized Trivial Queries May Not Get Partition Elimination] | Brent Ozar | 2020-11-26 | [DBA][DEV] | +| [Trigram Wildcard String Search in SQL Server] | Paul White | 2017-09-08 | [DBA][DEV] | +| [Which Locks Count Toward Lock Escalation?] | Kendra Little | 2017-04-03 | [DBA][DEV] | +| [The challenge is on! Community call for creating the fastest number series generator] | Itzik Ben-Gan | 2020-12-09 | [DBA][DEV] | +| [SQL Injection Prevention Cheat Sheet] | OWASP | 2020-07-14 | [SEC] | +| [A cheat sheet for isolation levels in SQL Server] | Dan Jackson | 2020-01-01 | [DBA][DEV] | +| [Don't Fear the Trace] | Greg Gonzalez | 2011-04-26 | [DBA][DEV] | +| [Which sp_configure Options Clear the Plan Cache?] | Brent Ozar | 2017-05-26 | [DBA][DEV] | +| [The danger of HADR_SYNC_COMMIT wait and synchronous replication in AlwaysOn Availability Groups] | Dmitri Korotkevitch | 2016-06-26 | [DBA][DEV] | +| [Faster SQL Pagination with Keysets, Continued] | Lukas Eder | 2013-11-18 | [DBA][DEV] | +| [We need tool support for keyset pagination] | Markus Winand | 2014-08-16 | [DBA][DEV] | +| [Insight into the SQL Server buffer cache] | Ed Pollack | 2016-02-18 | [DBA][DEV] | +| [Index-Only Scan: Avoiding Table Access] | Markus Winand | 2014-01-01 | [DBA][DEV] | +| [The two top performance problems caused by ORM tool] | Markus Winand | 2013-04-23 | [DBA][DEV] | +| [Nested loops join and n1 problem in ORM] | Markus Winand | 2013-01-01 | [DBA][DEV] | +| [Hash join partial objects] | Markus Winand | 2013-01-01 | [DBA][DEV] | +| [Myth: Select * (asterisk) is bad] | Markus Winand | 2013-11-03 | [DBA][DEV] | +| [Indexing LIKE Filters] | Markus Winand | 2013-01-01 | [DBA][DEV] | +| [Date and time conditions causing SQL performance problems] | Markus Winand | 2013-01-01 | [DBA][DEV] | +| [Dates and Times in SQL Server: more functions you should never use] | Randolph West | 2018-05-16 | [DBA][DEV] | +| [Dates and Times in SQL Server: T-SQL functions to get the current date and time] | Randolph West | 2018-04-25 | [DBA][DEV] | +| [Super Scaling Queues Using the LMax Disruptor Pattern And The In-Memory OLTP Engine] | Chris Adkin | 2016-01-18 | [DBA][DEV] | +| [Early History of SQL] | Donald D. Chamberlin | 2012-01-01 | [DBA][DEV] | +| [Is it a bad practice to always create a transaction?] | Kin Shah | 2013-09-06 | [DBA][DEV] | +| [Incomplete checkpoints and recovery] | Paul Randal | 2015-03-18 | [DBA] | +| [4 SQL Injection Techniques For Stealing Data] | Bert Wagner | 2018-11-20 | [DBA][DEV] | +| [Towards Safer Dynamic SQL] | Eric Darling | 2020-10-11 | [DBA][DEV] | +| [Setting the timezone to anything other than UTC] | Yeller | 2015-01-12 | [DBA][DEV] | +| [Advanced Service Broker Sample: Multi-Threading] | Eitan Blumin | 2018-10-31 | [DBA][DEV] | +| [Copy a SQL Server database with just the objects and no data] | Jeffrey Yao | 2017-02-01 | [DBA][DEV] | +| [QOMPLX Knowledge: Kerberoasting Attacks Explained] | QOMPLX | 2020-01-01 | [SEC] | +| [How to create a SQL dependency diagram in SQL Server] | Marko Zivkovic | 2018-09-24 | [DBA][DEV] | +| [Query Memory Grants and Resource Semaphores in SQL Server] | Klaus Aschenbrenner | 2018-10-16 | [DBA][DEV] | +| [Using a Table of Numbers (or a Table of Dates, Months etc)] | Erland Sommarskog | 2020-09-16 | [DBA][DEV] | +| [SQL Server MDF and NDF files] | SQL Recovery | 2020-01-01 | [DBA][DEV] | +| [The SQL Standard ANSI ISO is Public!] | Markus Winand | 2020-01-01 | [DBA][DEV] | +| [SQL Server Full Backup] | Alexandr Omelchenko | 2015-10-28 | [DBA][DEV] | +| [Import data from PDF files using R Scripts SQL Server] | Rajendra Gupta | 2020-12-08 | [R] | +| [Adding Additional Data Files To The TempDB Database In SQL Server] | Jack Worthen | 2017-08-24 | [DBA] | +| [SQL Server Isolation Levels: A Series] | Paul White | 2014-07-01 | [DBA][DEV] | +| [SQL Server Isolation Levels: The ACID Properties of Statements & Transactions] | Paul White | 2014-02-27 | [DBA][DEV] | +| [SQL Server Isolation Levels: The Serializable Isolation Level] | Paul White | 2014-04-10 | [DBA][DEV] | +| [SQL Server Isolation Levels: The Repeatable Read Isolation Level] | Paul White | 2014-04-15 | [DBA][DEV] | +| [SQL Server Isolation Levels: The Read Committed Isolation Level] | Paul White | 2014-04-22 | [DBA][DEV] | +| [SQL Server Isolation Levels: Read Committed Snapshot Isolation] | Paul White | 2014-05-07 | [DBA][DEV] | +| [SQL Server Isolation Levels: Data Modifications under Read Committed Snapshot Isolation] | Paul White | 2014-05-14 | [DBA][DEV] | +| [SQL Server Isolation Levels: The SNAPSHOT Isolation Level] | Paul White | 2014-06-30 | [DBA][DEV] | +| [SQL Server Isolation Levels: The Read Uncommitted Isolation Level] | Paul White | 2015-04-23 | [DBA][DEV] | +| [The OUTPUT Clause for the MERGE Statements] | Amarendra Reddy Thummeti | 2019-03-08 | [DBA][DEV] | +| [SQLskills SQL101: Query plans based on what’s in memory] | Paul Randal | 2017-03-03 | [DBA][DEV] | +| [Performance: String Concatenation in SQL Server] | Steve Stedman | 2021-01-25 | [DBA][DEV] | +| [Performance: Faster way to concatenate longer string] | Steve Stedman | 2021-01-26 | [DBA][DEV] | +| [Identifying Cost-Saving Opportunities in Azure DevOps] | Eric Smith | 2020-04-28 | [Az] | +| [One wide index or multiple narrow indexes?] | Gail Shaw | 2010-09-14 | [DBA][DEV] | +| [The Hidden Danger of Readable Secondaries in SQL Server AlwaysOn Availability Groups] | Dmitri Korotkevitch | 2018-09-04 | [DBA] | +| [When a Columnstore Index Makes Your Query Fail - 1/0 error] | Brent Ozar | 2020-06-08 | [DBA] | +| [Poor Man’s Resource Governor: Database-Scoped Configurations] | Brent Ozar | 2020-09-26 | [DBA] | +| [SQL Server Suddenly Frozen? You Might Be Snapshotting Too Many Databases.] | Brent Ozar | 2020-11-27 | [DBA] | +| [How to Batch Updates A Few Thousand Rows at a Time] | Brent Ozar | 2020-12-17 | [DBA][DEV] | +| [Using Amazon Fsx For Sql Server Failover Cluster Instances – What You Need To Know!] | Dave Berm | 2020-01-24 | [AMZ] | +| [Sometimes you CAN upsize a column in-place] | Aaron Bertrand | 2020-08-19 | [DBA] | +| [Which Microsoft Certification Should You Get?] | Brent Ozar | 2021-01-04 | [DBA][DEV] | +| [SQL Server RAISERROR Cheatsheet] | Chad Baldwin | 2021-01-15 | [DBA][DEV] | +| [Want to Avoid Deployment Downtime? Replication Probably Isn’t the Answer.] | Brent Ozar | 2021-01-06 | [DBA][DEV] | +| [“But Surely NOLOCK Is Okay If No One’s Changing Data, Right?”] | Brent Ozar | 2021-01-25 | [DBA][DEV] | +| [Why Multiple Plans for One Query Are Bad] | Brent Ozar | 2018-01-17 | [DBA][DEV] | +| [Partitioned Tables Cause Longer Plan Compilation Times.] | Brent Ozar | 2021-02-26 | [DBA][DEV] | +| [Query Hints You Can Use to Avoid Blocking] | Brent Ozar | 2021-01-21 | [DBA][DEV] | +| [Changing Statistics Cause Longer Compilation Times] | Brent Ozar | 2021-02-13 | [DBA][DEV] | +| [Understanding Execution Plan Operator Timings] | Paul White | 2021-03-08 | [DBA][DEV] | +| [What Does a Database Administrator Actually Do?] | Brent Ozar | 2021-03-20 | [DBA] | +| [How Useful Is Column Store In Standard Edition?] | Erik Darling | 2021-03-17 | [DBA] | +| [Task Manager’s CPU numbers are all but meaningless] | Aaron Margosis | 2021-03-25 | [DBA] | +| [Global temporary tables are almost never the answer in SQL Server] | Greg Low | 2021-02-04 | [DBA][DEV] | +| [Never, Ever, Ever Start T-SQL Comments with Two Dashes] | Brent Ozar | 2021-04-05 | [DBA][DEV] | +| [Why All My Servers Have an 8GB Empty File] | Brian Schrader | 2021-03-25 | [DBA] | +| [Incorrect Results with Parallel Eager Spools and Batch Mode] | Paul White | 2021-03-24 | [DBA][DEV] | +| [Deprecated features to take out of your toolbox – Part 1] | Aaron Bertrand | 2021-02-22 | [DBA][DEV] | +| [Deprecated features to take out of your toolbox – Part 2] | Aaron Bertrand | 2021-03-15 | [DBA][DEV] | +| [Deprecated features to take out of your toolbox – Part 3] | Aaron Bertrand | 2021-07-01 | [DBA][DEV] | +| [Troubleshooting Security Cache Issues: USERSTORE_TOKENPERM And TokenAndPermUserStore] | Erik Darling | 2021-04-19 | [DBA] | +| [Execution Plans Don’t Have the Yellow Bang They Really Need.] | Brent Ozar | 2021-04-29 | [DBA][DEV] | +| [The Curious Case of… the un-killable thread] | Paul Randal | 2021-04-20 | [DBA] | +| [olved steries #1 – SQL FCI Failovers] | Sean Gallardy | 2021-04-29 | [DBA] | +| [Possible configuration error: 1000000 IO requests allocated] | Sean Gallardy | 2021-05-23 | [DBA] | +| [Availability Group Long Failover Times] | Sean Gallardy | 2021-04-18 | [DBA] | +| [Testing Backups and Offloading CheckDB] | Taryn Pratt | 2021-04-19 | [DBA] | +| [Fighting with Deadlocks] | Taryn Pratt | 2021-04-09 | [DBA][DEV] | +| [Syncing Logins Between Availability Group Replicas] | Taryn Pratt | 2020-12-18 | [DBA] | +| [SQL JOINs and UNIONs] | Austin Smith | 2020-03-13 | [DBA][DEV] | +| [Some opinionated thoughts on SQL databases] | Nelson Elhage | 2020-03-30 | [DBA][DEV] | +| [How MERGE on two different rows can still deadlock you] | Daniel Hutmacher | 2021-05-04 | [DBA][DEV] | +| [Auto-failover Groups for Azure – Grace Period With Data Loss Hours] | Taiob Ali | 2021-03-31 | [AZ][DBA] | +| [How Parallel Plans Start Up – Part 1] | Paul White | 2021-03-30 | [DBA][DEV] | +| [How Parallel Plans Start Up – Part 2] | Paul White | 2021-04-08 | [DBA][DEV] | +| [How Parallel Plans Start Up – Part 3] | Paul White | 2021-04-20 | [DBA][DEV] | +| [How Parallel Plans Start Up – Part 4] | Paul White | 2021-05-06 | [DBA][DEV] | +| [How Parallel Plans Start Up – Part 5] | Paul White | 2021-05-17 | [DBA][DEV] | +| [Iterators, Query Plans, and Why They Run Backwards] | Paul White | 2010-08-05 | [DBA][DEV] | +| [What account is xp_cmdshell using?] | Kenneth Fisher | 2021-05-25 | [DBA] | +| [Hammer Part 1 -What is HammerDB and why would I use it?] | Tom Wilson | 2021-04-17 | [BENCH][P] | +| [Hammer Part 2 -Let the Nail see the Hammer!] | Tom Wilson | 2021-05-26 | [BENCH][P] | +| [Fun with DATETIME Arithmetics] | Eitan Blumin | 2021-04-27 | [DBA][DEV] | +| [Even more fun with DATETIME arithmetics!] | Eitan Blumin | 2021-06-17 | [DBA][DEV] | +| [I learned to love WHILE (true) and you should too] | Eitan Blumin | 2021-02-16 | [DBA][DEV] | +| [Troubleshooting Long-Running SHRINK Operations] | Eitan Blumin | 2020-04-07 | [DBA] | +| [The Ultimate Compression Savings Estimation Script for an Entire Database] | Eitan Blumin | 2020-02-18 | [DBA] | +| [The Complete Guide to Temporary Tables and Table Variables - Part 1] | Guy Glanster | 2021-04-08 | [DBA][DEV] | +| [Store Files in a File System, Not a Relational Database.] | Brent Ozar | 2021-07-01 | [DBA][DEV] | +| [Most (XML) and Least (SQL_VARIANT) Favorite Data Type] | Eitan Blumin | 2021-03-09 | [DBA][DEV] | +| [What should the CPU usage be of a fully-loaded CPU that has been throttled?] | Raymond | 2021-06-29 | [DBA][DEV] | +| [Fixing Queues with Watermarks] | Forrest Daniel | 2021-06-30 | [DBA][DEV] | +| [How to Patch SQL Server] | Brent Ozar | 2021-06-04 | [DBA] | +| [“I’m getting index seeks. Why are my row estimates still wrong?”] | Brent Ozar | 2021-06-06 | [DBA][DEV] | +| [OLAP != OLAP Cube] | Cedric Chin | 2020-02-06 | [DBA][DEV] | +| [Connecting a SQL Server client on Linux using Active Directory authentication] | Daniel Hutmacher | 2021-04-15 | [DBA][DEV] | +| [Is a sort faster when the data is already sorted?] | Daniel Hutmacher | 2021-02-15 | [DBA][DEV] | +| [Connect using Windows authentication across domains] | Daniel Hutmacher | 2021-02-05 | [DBA][DEV] | +| [The uncorrelated correlated subquery] | Daniel Hutmacher | 2020-12-21 | [DBA][DEV] | +| [How to fix rounding errors] | Daniel Hutmacher | 2020-12-15 | [DBA][DEV] | +| [The curious case of the Top N Sort] | Daniel Hutmacher | 2020-12-08 | [DBA][DEV] | +| [Consolidating grouped transactions into evenly sized batches] | Daniel Hutmacher | 2020-07-13 | [DBA][DEV] | +| [A “shock absorber” pattern for high-performance data ingestion] | Daniel Hutmacher | 2021-07-15 | [P] | +| [Why Are Linked Server Queries So Bad?] | Brent Ozar | 2021-07-15 | [DBA][DEV] | +| [Fundamentals of table expressions, Part 1] | Itzik Ben-Gan | 2020-04-08 | [DBA][DEV] | +| [Fundamentals of table expressions, Part 2 – Derived tables, logical considerations] | Itzik Ben-Gan | 2020-05-13 | [DBA][DEV] | +| [Fundamentals of table expressions, Part 3 – Derived tables, optimization considerations] | Itzik Ben-Gan | 2020-06-10 | [DBA][DEV] | +| [Fundamentals of table expressions, Part 4 – Derived tables, optimization considerations, continued] | Itzik Ben-Gan | 2020-07-08 | [DBA][DEV] | +| [Fundamentals of table expressions, Part 5 – CTEs, logical considerations] | Itzik Ben-Gan | 2020-08-12 | [DBA][DEV] | +| [Fundamentals of table expressions, Part 6 – Recursive CTEs] | Itzik Ben-Gan | 2020-09-09 | [DBA][DEV] | +| [Fundamentals of table expressions, Part 7 – CTEs, optimization considerations] | Itzik Ben-Gan | 2020-10-14 | [DBA][DEV] | +| [Fundamentals of table expressions, Part 8 – CTEs, optimization considerations continued] | Itzik Ben-Gan | 2020-11-11 | [DBA][DEV] | +| [Fundamentals of table expressions, Part 9 – Views, compared with derived tables and CTEs] | Itzik Ben-Gan | 2021-06-09 | [DBA][DEV] | +| [Fundamentals of table expressions, Part 10 – Views, SELECT *, and DDL changes] | Itzik Ben-Gan | 2021-07-14 | [DBA][DEV] | +| [Understanding xp_fileexist and its usage] | Nisarg Upadhyay | 2021-07-09 | [DBA][DEV] | +| [SQL Server Restore Database Options and Examples] | Joe Gavin | 2021-06-21 | [DBA] | +| [SQL Server Database RESTORE WITH MOVE or not WITH MOVE] | Mike Eastland | 2013-11-22 | [DBA] | +| [Getting exclusive access to restore SQL Server database] | Greg Robidoux | 2021-02-21 | [DBA] | +| [How to migrate a SQL Server database to a lower version] | Basit Farooq | 2019-08-05 | [DBA] | +| [Make Network Path Visible For SQL Server Backup and Restore in SSMS] | Ahmad Yaseen | 2015-03-03 | [DBA] | +| [T-SQL bugs, pitfalls, and best practices – pivoting and unpivoting] | Itzik Ben-Gan | 2019-09-12 | [DBA][DEV] | +| [How to Prep a SQL Server Availability Group for VM-Level DR Replication] | David Klee | 2021-02-08 | [DBA] | +| [Special Agent Jenkins] | Kirill Kravtsov | 2018-03-03 | [J] | +| [What To Avoid If You Want To Use MERGE] | Michael J Swart | 2021-08-04 | [DBA][DEV] | +| [Solving Gaps and Islands with Enhanced Window] | Itzik Ben-Gan | 2012-09-20 | [DBA][DEV] | +| [How to choose between SQL and NoSQL databases] | Robert Sheldon | 2021-04-13 | [DBA][DEV] | +| [SQL Server plan cache mining – Plan attributes] | Edward Pollack | 2021-04-26 | [DBA][DEV] | +| [How to Prep a SQL Server Availability Group for VM-Level DR Replication] | David Klee | 2021-02-08 | [DBA] | +| [How to create an autonomous transaction in SQL Server 2008] | SQL-Server-Team | 2021-02-08 | [DBA][DEV] | +| [Cloud Comparison: AWS vs. Azure vs. GCP] | Troy Blake | 2021-03-24 | [DBA][DEV] | +| [New VLF status value] | Troy Blake | 2021-03-24 | [DBA][DEV] | +| [The Simplest Alternative to sp_MSforeachdb] | Eitan Blumin | 2021-08-05 | [DBA][DEV] | +| [Your database connection deserves a name] | Andy Grunwald | 2021-07-25 | [DBA][DEV] | +| [Renaming a Database Table In-Flight] | Arvind Paul | 2021-01-01 | [DBA][DEV] | +| [Upgrading/Migrating Large Replicated Databases Without Reinitializing] | Jonathan Kehayias | 2021-08-12 | [DBA][DEV] | +| [TempDB configuration for people in a hurry] | Jeff Iannucci | 2021-07-03 | [DBA][DEV] | +| [Help! My tempdb database won’t shrink!] | Jeff Iannucci | 2018-06-22 | [DBA][DEV] | +| [SQL Server Checkpoint Monitoring with Extended Events] | Aaron Bertrand | 2020-02-17 | [DBA][DEV] | +| ["0 to 60" : Switching to indirect checkpoints] | Aaron Bertrand | 2020-05-01 | [DBA][DEV] | +| [A case against using Basic and Standard (S0 & S1) tiers in Azure SQL Databases] | Niko Neugebauer | 2021-02-09 | [AZ] | +| [Experiment: Does sp_recompile on a table update associated views.] | Kenneth Fisher | 2021-08-17 | [DBA][DEV] | +| [On index key size, index depth, and performance] | Paul Radal | 2015-10-23 | [DBA][DEV] | +| [SQL Server Hierarchyid Data Type Overview and Examples] | Rick Dobson | 2019-06-21 | [DBA][DEV] | +| [Make It Easier for the DBA: Give SQL Connections the Application’s Name!] | Ben Gribaudo | 2017-06-23 | [DBA][DEV] | +| [You Probably Shouldn’t Index Your Temp Tables.] | Brent Ozar | 2021-08-17 | [DBA][DEV] | +| [SQL Server Error Handling Gotchas] | Niels Berglund | 2016-12-31 | [DBA][DEV] | +| [B-Trees: More Than I Thought I'd Want to Know] | Ben Congdon | 2021-08-17 | [DBA][DEV] | +| [Wait Stats During Hash Spills] | Eric Darling | 2021-09-21 | [DBA][DEV] | +| [Shrinking The tempdb System Database Without Restarting SQL Server] | Jack Worthen | 2016-06-02 | [DBA][DEV] | +| [Graphing SQL Server wait stats on Prometheus and Grafana] | David Barbarin | 2021-09-09 | [M] | +| [Transition from SSMS to DataGrip: 10 tips] | Maksim Sobolevskiy | 2021-08-19 | [DBA][DEV] | +| [Query Store Hints] | Erin Stellato | 2021-06-09 | [DBA][DEV] | +| [Announcing SSIS Framework Manager, v1] | Andy Leonard | 2021-06-09 | [SSIS] | +| [Improving The Performance of RBAR Modifications] | Erik Darling | 2021-02-15 | [DBA][DEV] | +| [Minimal Logging with INSERT…SELECT into Empty Clustered Tables] | Paul White | 2019-05-16 | [DBA][DEV] | +| [What Is a Cost-Based Optimizer?] | Brent Ozar | 2021-09-17 | [DBA][DEV] | +| [Unusual Parameter Sniffing: Big Problems with Small Data] | Brent Ozar | 2021-02-03 | [DBA][DEV] | +| [Rowcount estimates when there are no Statistics] | Matthew Mcgiffen | 2021-01-26 | [DBA][DEV] | +| [Processing Data Queues in SQL Server with READPAST and UPDLOCK] | Armando Prato | 2007-06-04 | [DBA][DEV] | +| [Can You Get Parameter Sniffing on Updates and Deletes?] | Brent Ozar | 2021-01-27 | [DBA][DEV] | +| [An Empirical Look at Key Lookups] | Forrest mc Daniel | 2020-12-30 | [DBA][DEV] | +| [Please stop using this UPSERT anti-pattern] | Aaron Bertrand | 2020-09-02 | [DBA][DEV] | +| [The Curious Case of… the failing differential restore] | Paul Randal | 2021-01-18 | [DBA] | +| [Starting SQL: Compensating For Lock Waits] | Erik Darling | 2020-01-31 | [DBA][DEV] | +| [Finding & Downloading Required SQL Server Updates] | Andy Levy | 2020-07-21 | [DBA] | +| [Quick SQL Server CPU Comparison Tests] | Joe Obbish | 2021-09-22 | [DBA][DEV] | +| [Using fn_dblog, fn_dump_dblog, and restoring with STOPBEFOREMARK to an LSN] | Paul Randal | 2012-05-17 | [DBA][DEV] | +[Understanding how SQL Server executes a query]:http://rusanu.com/2013/08/01/understanding-how-sql-server-executes-a-query/ [SQL Server Index Design Guide]:https://technet.microsoft.com/en-us/library/jj835095.aspx [SQL Server 2012 Security Best Practices - Microsoft]:http://download.microsoft.com/download/8/f/a/8fabacd7-803e-40fc-adf8-355e7d218f4c/sql_server_2012_security_best_practice_whitepaper_apr2012.docx [Help, my database is corrupt. Now what?]:http://www.sqlservercentral.com/articles/Corruption/65804/ [What to Do When DBCC CHECKDB Reports Corruption]:https://www.brentozar.com/archive/2016/05/dbcc-checkdb-reports-corruption/ -[Understanding how SQL Server executes a query]:http://rusanu.com/2013/08/01/understanding-how-sql-server-executes-a-query/ [Troubleshooting SQL Server CPU Performance Issues]:http://sqlperformance.com/2013/05/io-subsystem/cpu-troubleshooting [Knee-Jerk Performance Tuning : Incorrect Use of Temporary Tables]:http://sqlperformance.com/2016/04/t-sql-queries/knee-jerk-temporary-tables [High Performance T-SQL using Code Patterns]:https://dwaincsql.com/2015/05/27/high-performance-t-sql-using-code-patterns/ [SQL Server Database Corruption Repair]:http://stevestedman.com/2015/08/sql-server-database-corruption-repair/ [Basic SQL Server Performance Troubleshooting For Developers]:https://www.simple-talk.com/sql/performance/basic-sql-server-performance-troubleshooting-for-developers/ [The Curse and Blessings of Dynamic SQL]:http://sommarskog.se/dynamic_sql.html -[Dynamic Search Conditions in T-SQL]:http://www.sommarskog.se/dynamic_sql.html +[Dynamic Search Conditions in T-SQL]:http://www.sommarskog.se/dyn-search.html [Slow in the Application, Fast in SSMS]:http://www.sommarskog.se/query-plan-mysteries.html [How to share data between stored procedures]:http://www.sommarskog.se/share_data.html [Arrays and Lists in SQL Server 2008]:http://www.sommarskog.se/arrays-in-sql-2008.html -[Giving Permissions through Stored Procedures]:http://www.sommarskog.se/grantperm.html -[Error and Transaction Handling in SQL Server]:http://www.sommarskog.se/error_handling/Part1.html +[Packaging Permissions in Stored Procedures]:http://www.sommarskog.se/grantperm.html +[Error and Transaction Handling in SQL Server Part One – Jumpstart Error Handling]:http://www.sommarskog.se/error_handling/Part1.html +[Error and Transaction Handling in SQL Server Part Two – Commands and Mechanisms]:http://www.sommarskog.se/error_handling/Part2.html +[Error and Transaction Handling in SQL Server Part Three – Implementation]:http://www.sommarskog.se/error_handling/Part3.html [Using the Bulk-Load Tools in SQL Server]:http://www.sommarskog.se/bulkload.html [Using Table-Valued Parameters in SQL Server and .NET]:http://www.sommarskog.se/arrays-in-sql-2008.html [SQL Server Columnstore Articles]:http://www.nikoport.com/columnstore/ @@ -516,7 +1510,6 @@ Articles types: [Monitor SQL Server Transaction Log File Free Space]:https://www.mssqltips.com/sqlservertip/3617/monitor-sql-server-transaction-log-file-free-space/ [Dynamically Query a 100 Million Row Table-Efficiently]:http://www.sqlservercentral.com/articles/T-SQL/121906/ [Understanding and Using Parallelism in SQL Server]:https://www.simple-talk.com/sql/learn-sql-server/understanding-and-using-parallelism-in-sql-server/ -[Diagnosing and Resolving Latch Contention on SQL Server]:https://www.microsoft.com/en-us/download/details.aspx?id=26665 [Parallel Execution Plans – Branches and Threads]:http://sqlperformance.com/2013/10/sql-plan/parallel-plans-branches-threads [Nasty Fast PERCENT_RANK]:http://www.sqlservercentral.com/articles/PERCENT_RANK/141532/ [Looking at VIEWs, Close Up]:https://www.simple-talk.com/sql/t-sql-programming/looking-at-views,-close-up/ @@ -535,7 +1528,7 @@ Articles types: [Graphs and Graph Algorithms in T-SQL]:http://www.hansolav.net/sql/graphs.html [Episode 4: SQL Server R Services makes you a smarter T-SQL Developer]:https://blogs.msdn.microsoft.com/sqlcat/2016/07/12/sqlsweet16-episode-4-sql-server-r-services-makes-you-a-smarter-t-sql-developer/ [How to Set Max Degree of Parallelism in SQL Server]:http://www.littlekendra.com/2016/07/14/max-degree-of-parallelism-cost-threshold-for-parallelism/ -[Undocumented Query Plans: Equality Comparisons]:http://sqlblog.com/blogs/paul_white/archive/2011/06/22/undocumented-query-plans-equality-comparisons.aspx +[Undocumented Query Plans: Equality Comparisons]:https://www.sql.kiwi/2011/06/undocumented-query-plans-equality-comparisons.html [Simplified Order Of Operations]:http://michaeljswart.com/2016/07/simplified-order-of-operations/ [SQL Server Statistics Basics]:https://www.simple-talk.com/sql/performance/sql-server-statistics-basics/ [Learn to Use sp_Blitz, sp_BlitzCache, sp_BlitzFirst, and sp_BlitzIndex with These Tutorial Videos]:https://www.brentozar.com/archive/2016/09/learn-use-sp_blitz-sp_blitzcache-sp_blitzfirst-sp_blitzindex-tutorial-videos/ @@ -548,33 +1541,31 @@ Articles types: [How To Fix Forwarded Records]:https://www.brentozar.com/archive/2016/07/fix-forwarded-records/ [Should I Automate my Windows Updates for SQL Server?]:http://www.littlekendra.com/2016/07/28/should-i-automate-my-windows-updates-for-sql-server-dear-sql-dba-episode-10/ [Finding the Right Path]:http://jasonbrimhall.info/2016/08/24/finding-the-right-path/ -[#BackToBasics : An Updated "Kitchen Sink" Example]:https://blogs.sqlsentry.com/aaronbertrand/backtobasics-updated-kitchen-sink-example/ +[#BackToBasics : An Updated "Kitchen Sink" Example]:https://www.sentryone.com/blog/aaronbertrand/backtobasics-updated-kitchen-sink-example [Locking and Blocking in SQL Server]:https://www.brentozar.com/sql/locking-and-blocking-in-sql-server/ -[Nested Loops Prefetching]:http://sqlblog.com/blogs/paul_white/archive/2013/08/31/sql-server-internals-nested-loops-prefetching.aspx +[Nested Loops Prefetching]:https://www.sql.kiwi/2013/08/sql-server-internals-nested-loops-prefetching.html [Performance tuning backup and restore operations]:http://www.sqlhammer.com/performance-tuning-backup-restore-operations/ -[Execution Plan Analysis: The Mystery Work Table]:http://sqlblog.com/blogs/paul_white/archive/2013/03/08/execution-plan-analysis-the-mystery-work-table.aspx +[Execution Plan Analysis: The Mystery Work Table]:https://www.sql.kiwi/2013/03/execution-plan-analysis-the-mystery-work-table.html [How to move data between File Groups in SQL Server]:http://www.sqlpassion.at/archive/2016/09/26/how-to-move-data-between-file-groups-in-sql-server/ -[Optimizing Your Query Plans with the SQL Server 2014 Cardinality Estimator]:https://msdn.microsoft.com/en-us/library/dn673537.aspx +[Optimizing Your Query Plans with the SQL Server 2014 Cardinality Estimator]:https://docs.microsoft.com/en-us/previous-versions/dn673537(v=msdn.10)?redirectedfrom=MSDN [Parallelism in SQL Server Query Tuning]:http://sqlmag.com/sql-server/parallelism-sql-server-query-tuning [What You Need to Know about the Batch Mode Window Aggregate Operator in SQL Server 2016: Part 1]:http://sqlmag.com/sql-server/what-you-need-know-about-batch-mode-window-aggregate-operator-sql-server-2016-part-1 [What To Do If sp_BlitzFirst Warns About High Compilations]:https://www.brentozar.com/archive/2016/09/what-to-do-if-sp_blitzfirst-warns-about-high-compilations/ [Questions You Should Be Asking About Your Backups]:https://www.brentozar.com/archive/2016/10/questions-asking-backups/ [Evolutionary Database Design]:http://martinfowler.com/articles/evodb.html [Implementing a custom sort]:https://sqlperformance.com/2016/10/sql-plan/implementing-custom-sort -[Deletes that Split Pages and Forwarded Ghosts]:http://sqlblog.com/blogs/paul_white/archive/2012/08/31/deletes-that-split-pages-and-forwarded-ghosts.aspx -[Query Optimizer Deep Dive - Part 1]:http://sqlblog.com/blogs/paul_white/archive/2012/04/28/query-optimizer-deep-dive-part-1.aspx -[Query Optimizer Deep Dive - Part 2]:http://sqlblog.com/blogs/paul_white/archive/2012/04/28/query-optimizer-deep-dive-part-2.aspx -[Query Optimizer Deep Dive - Part 3]:http://sqlblog.com/blogs/paul_white/archive/2012/04/29/query-optimizer-deep-dive-part-3.aspx -[Query Optimizer Deep Dive - Part 4]:http://sqlblog.com/blogs/paul_white/archive/2012/05/01/query-optimizer-deep-dive-part-4.aspx +[Deletes that Split Pages and Forwarded Ghosts]:https://www.sql.kiwi/2012/08/deletes-that-split-pages-and-forwarded-ghosts.html +[Query Optimizer Deep Dive - Part 1]:https://www.sql.kiwi/2012/04/query-optimizer-deep-dive-part-1.html +[Query Optimizer Deep Dive - Part 2]:https://www.sql.kiwi/2012/04/query-optimizer-deep-dive-part-2.html +[Query Optimizer Deep Dive - Part 3]:https://www.sql.kiwi/2012/04/query-optimizer-deep-dive-part-3.html +[Query Optimizer Deep Dive - Part 4]:https://www.sql.kiwi/2012/05/query-optimizer-deep-dive-part-4.html [Should You Rebuild or Reorganize Indexes on Large Tables?]:https://www.littlekendra.com/2016/10/13/should-you-rebuild-or-reorganize-indexes-on-large-tables-dear-sql-dba-episode-19/ [Retrieving SQL Server Query Execution Plans]:https://www.simple-talk.com/sql/database-administration/retrieving-sql-server-query-execution-plans/ [Introduction to Latches in SQL Server]:http://www.sqlpassion.at/archive/2014/06/23/introduction-to-latches-in-sql-server/ [Latch Coupling in SQL Server]:https://www.sqlpassion.at/archive/2016/10/24/latch-coupling-in-sql-server/ [Partitioned Views? A How-To Guide]:https://www.brentozar.com/archive/2016/09/partitioned-views-guide/ -[How to Choose Between RCSI and Snapshot Isolation Levels]:https://www.littlekendra.com/2016/02/18/how-to-choose-rcsi-snapshot-isolation-levels/ [TroubleShooting SQL Server Memory Consumption]:http://www.sql-server-performance.com/2016/trouble-shooting-sql-server-ra-memory-consumption/ [Time Series Algorithms in SQL Server]:http://www.sql-server-performance.com/2015/time-series-algorithms-sql-server/ -[Heap Tables in SQL Server]:http://www.sqlpassion.at/archive/2015/10/19/heap-tables-in-sql-server/ [Internals of the Seven SQL Server Sorts – Part 1]:https://sqlperformance.com/2015/04/sql-plan/internals-of-the-seven-sql-server-sorts-part-1 [Internals of the Seven SQL Server Sorts – Part 2]:https://sqlperformance.com/2015/05/sql-plan/internals-of-the-seven-sql-server-sorts-part-2 [The 9 Letters That Get DBAs Fired]:https://www.brentozar.com/archive/2011/12/letters-that-get-dbas-fired/ @@ -586,7 +1577,6 @@ Articles types: [Successful Anti-Patterns, Storage Requirements]:http://www.sqldoubleg.com/2016/10/19/successful-anti-patterns-storage-requirements/ [SQL Server table columns under the hood]:http://rusanu.com/2011/10/20/sql-server-table-columns-under-the-hood/ [How to analyse SQL Server performance]:http://rusanu.com/2014/02/24/how-to-analyse-sql-server-performance/ -[To BLOB or Not To BLOB: Large Object Storage in a Database or a Filesystem?]:https://www.microsoft.com/en-us/research/publication/to-blob-or-not-to-blob-large-object-storage-in-a-database-or-a-filesystem/ [Asynchronous procedure execution]:http://rusanu.com/2009/08/05/asynchronous-procedure-execution/ [What is the CXPACKET Wait Type, and How Do You Reduce It?]:https://www.brentozar.com/archive/2013/08/what-is-the-cxpacket-wait-type-and-how-do-you-reduce-it/ [New indexes, hypothetically]:https://sqlstudies.com/2016/11/02/new-indexes-hypothetically/ @@ -597,11 +1587,10 @@ Articles types: [Tally OH! An Improved SQL 8K “CSV Splitter” Function]:http://www.sqlservercentral.com/articles/Tally+Table/72993/ [Set Statistics… Profile?]:https://www.brentozar.com/archive/2016/10/set-statistics-profile/ [Hierarchies on Steroids #1: Convert an Adjacency List to Nested Sets]:http://www.sqlservercentral.com/articles/Hierarchy/94040/ -[Optimizing T-SQL queries that change data]:http://sqlblog.com/blogs/paul_white/archive/2013/01/26/optimizing-t-sql-queries-that-change-data.aspx +[Optimizing T-SQL queries that change data]:https://www.sql.kiwi/2013/01/optimizing-t-sql-queries-that-change-data.html [Measuring Query Duration: SSMS vs SQL Sentry Plan Explorer]:https://www.littlekendra.com/2016/09/27/measuring-query-duration-ssms-vs-sql-sentry-plan-explorer/ [Inside the Statistics Histogram & Density Vector]:http://www.sqlpassion.at/archive/2014/01/28/inside-the-statistics-histogram-density-vector/ -[Misconceptions on parameter sniffing]:http://sqlblog.com/blogs/hugo_kornelis/archive/2016/11/03/misconceptions-on-parameter-sniffing.aspx -[CAST vs. CONVERT]:https://blogs.sentryone.com/aaronbertrand/backtobasics-cast-vs-convert/ +[Misconceptions on parameter sniffing]:https://sqlserverfast.com/blog/hugo/2016/11/misconceptions-on-parameter-sniffing/ [What Every Accidental DBA Needs to Know Now: Basics of SQL Security]:http://sqlmag.com/database-security/what-every-accidental-dba-needs-know-now-basics-sql-security [SQL Server Perfmon (Performance Monitor) Best Practices]:https://www.brentozar.com/archive/2006/12/dba-101-using-perfmon-for-sql-performance-tuning/ [Top 5 Overlooked Index Features]:https://www.brentozar.com/archive/2016/11/top-5-overlooked-index-features/ @@ -632,7 +1621,7 @@ Articles types: [Why is This Partitioned Query Slower?]:https://www.brentozar.com/archive/2015/09/why-is-this-partitioned-query-slower/ [A Beginner’s Guide to the True Order of SQL Operations]:https://blog.jooq.org/2016/12/09/a-beginners-guide-to-the-true-order-of-sql-operations/ [Logical Query Processing: What It Is And What It Means to You]:http://sqlmag.com/sql-server/logical-query-processing-what-it-and-what-it-means-you -[Forcing a Parallel Query Execution Plan]:http://sqlblog.com/blogs/paul_white/archive/2011/12/23/forcing-a-parallel-query-execution-plan.aspx +[Forcing a Parallel Query Execution Plan]:https://www.sql.kiwi/2011/12/forcing-a-parallel-query-execution-plan.html [Join Containment Assumption and CE Model Variation]:http://www.queryprocessor.com/ce_join_base_containment_assumption/ [Table Variable Tip]:http://sqlmag.com/t-sql/table-variable-tip [Heap tables in SQL Server]:http://www.sqlhammer.com/heaps-in-microsoft-sql-server/ @@ -643,7 +1632,7 @@ Articles types: [Sync Vs Async Statistics: The Old Debate]:https://sqlserverscotsman.wordpress.com/2016/12/10/sync-vs-async-statistics-the-old-debate/ [Recommended updates and configuration options for SQL Server 2012 and SQL Server 2014 with high-performance workloads]:https://support.microsoft.com/en-gb/kb/2964518 [Troubleshooting SQL Server backup and restore operations]:https://support.microsoft.com/en-us/kb/224071 -[SQL Server 2016: Getting tempdb a little more right]:https://blogs.sentryone.com/aaronbertrand/sql-server-2016-tempdb-fixes/ +[SQL Server 2016: Getting tempdb a little more right]:https://www.sentryone.com/blog/aaronbertrand/sql-server-2016-tempdb-fixes [Practical uses of binary types]:https://sqlsunday.com/2017/01/09/binary-types/ [Backing Up SQL Server Databases is Easier in PowerShell than T-SQL]:http://www.sqlservercentral.com/articles/PowerShell/151510/ [Creating, detaching, re-attaching, and fixing a SUSPECT database]:http://www.sqlskills.com/blogs/paul/creating-detaching-re-attaching-and-fixing-a-suspect-database/ @@ -677,8 +1666,8 @@ Articles types: [New SQL Server Database Request Questionnaire and Checklist]:https://www.mssqltips.com/sqlservertip/3523/new-sql-server-database-request-questionnaire-and-checklist/ [Adding Partitions to the Lower End of a Left Based Partition Function]:https://www.littlekendra.com/2017/02/21/adding-partitions-to-the-lower-end-of-a-left-based-partition-function/ [Don't Panic Busting a File Space Myth]:http://sqlmag.com/database-administration/dont-panic-busting-file-space-myth -[#BackToBasics : Dating Responsibly]:https://blogs.sentryone.com/aaronbertrand/backtobasics-dating-responsibly/ -[#BackToBasics : Common Table Expressions (CTEs)]:https://blogs.sentryone.com/aaronbertrand/backtobasics-ctes/ +[#BackToBasics : Dating Responsibly]:https://www.sentryone.com/blog/aaronbertrand/backtobasics-dating-responsibly/ +[#BackToBasics : Common Table Expressions (CTEs)]:https://www.sentryone.com/blog/aaronbertrand//backtobasics-ctes/ [How to Establish Dedicated Admin Connection (DAC) to SQL Server]:https://www.codeproject.com/tips/1136361/how-to-establish-dedicated-admin-connection-dac-to [SQL and SQL only Best Practice]:http://strictlysql.blogspot.ru/search/label/Best%20Practices [There Is No Difference Between Table Variables, Temporary Tables, and Common Table Expressions]:https://dzone.com/articles/there-is-no-difference-between-table-variables-tem @@ -691,7 +1680,6 @@ Articles types: [ALTER SCHEMA TRANSFER for Zero Downtime Database Upgrades]:http://www.davewentzel.com/content/alter-schema-transfer-zero-downtime-database-upgrades [Delayed Durability in SQL Server 2014]:https://sqlperformance.com/2014/04/io-subsystem/delayed-durability-in-sql-server-2014 [Daylight Savings end affects not only you, but your SQL Server too]:http://www.sqldoubleg.com/2015/10/28/daylight-savings-end-affects-not-only-you-but-your-sql-server-too/ -[Searching Strings in SQL Server is Expensive]:https://www.brentozar.com/archive/2016/10/searching-strings-sql-server-expensive/ [Let’s Corrupt a SQL Server Database Together, Part 1: Clustered Indexes]:https://www.brentozar.com/archive/2017/02/lets-corrupt-sql-server-database-together/ [Let’s Corrupt a Database Together, Part 2: Nonclustered Indexes]:https://www.brentozar.com/archive/2017/02/lets-corrupt-database-together-part-2-nonclustered-indexes/ [The Guide SQL Server Installation Checklist (settings that increase SQL Server Performance)]:https://red9.com/blog/sql-server-installation-checklist/ @@ -705,15 +1693,13 @@ Articles types: [SQL Server Temporal Tables: How-To Recipes]:https://www.simple-talk.com/sql/sql-training/sql-server-temporal-tables-recipes/ [The Migration Checklist]:http://www.sqlservercentral.com/articles/Editorial/154033/ [Upgrading to SQL Server 2014: A Dozen Things to Check]:https://thomaslarock.com/2014/06/upgrading-to-sql-server-2014-a-dozen-things-to-check/ -[Number of Rows Read / Actual Rows Read warnings in Plan Explorer]:https://sqlperformance.com/2016/06/sql-indexes/actual-rows-read-warnings-plan-explorer [Introducing the Set-based Loop]:http://www.sqlservercentral.com/articles/set-based+loop/127670/ [Representing Hierarchical Data for Mere Mortals]:https://www.simple-talk.com/sql/database-administration/representing-hierarchical-data-for-mere-mortals/ [KPIs For DBAs to Show Their CIOs]:https://thomaslarock.com/2017/03/kpis-dbas-show-cios/ [How To Forecast Database Disk Capacity If You Don’t Have A Monitoring Tool]:http://www.edwinmsarmiento.com/how-to-forecast-database-disk-capacity-if-you-dont-have-a-monitoring-tool/ [Statistical Sampling for Verifying Database Backups]:https://www.simple-talk.com/sql/database-administration/statistical-sampling-for-verifying-database-backups/ -[Inside The Storage Engine GAM, SGAM, PFS and other allocation maps]:https://www.sqlskills.com/blogs/paul/inside-the-storage-engine-gam-sgam-pfs-and-other-allocation-maps/ [Using dbatools for automated restore and CHECKDB]:http://www.centinosystems.com/blog/sql/using-dbatools-for-automated-restore-and-checkdb/ -[Bad Habits Revival]:https://blogs.sentryone.com/aaronbertrand/bad-habits-revival/ +[Bad Habits Revival]:https://www.sentryone.com/blog/aaronbertrand/bad-habits-revival/ [Deploying Multiple SSIS Projects via PowerShell]:https://www.simple-talk.com/sql/ssis/deploying-multiple-ssis-projects-via-powershell/ [Determining the Cost Threshold for Parallelism]:http://www.scarydba.com/2017/02/28/determining-the-cost-threshold-for-parallelism/ [Identifying a row’s physical location]:http://blog.waynesheffield.com/wayne/archive/2017/03/identifying-rows-physical-location/ @@ -728,9 +1714,9 @@ Articles types: [Performance Myths: Clustered vs. Non-Clustered Indexes]:https://sqlperformance.com/2017/03/sql-indexes/performance-myths-clustered-vs-non-clustered [Bad habits: Counting rows the hard way]:https://sqlperformance.com/2014/10/t-sql-queries/bad-habits-count-the-hard-way [Why Cost Threshold For Parallelism Shouldn’t Be Set To 5]:https://www.brentozar.com/archive/2017/03/why-cost-threshold-for-parallelism-shouldnt-be-set-to-5/ -[Join Performance, Implicit Conversions, and Residuals]:http://sqlblog.com/blogs/paul_white/archive/2011/07/19/join-performance-implicit-conversions-and-residuals.aspx +[Join Performance, Implicit Conversions, and Residuals]:https://www.sql.kiwi/2011/07/join-performance-implicit-conversions-and-residuals.html [Implicit Conversions that cause Index Scans]:https://www.sqlskills.com/blogs/jonathan/implicit-conversions-that-cause-index-scans/ -[When Is It Appropriate To Store JSON in SQL Server?]:https://blog.bertwagner.com/when-is-it-appropriate-to-store-json-in-sql-server-8ed1eed1520d#.s7ntvsyd0?utm_source=DBW&utm_medium=pubemail +[When Is It Appropriate To Store JSON in SQL Server?]:https://bertwagner.com/2017/03/14/when-is-it-appropriate-to-store-json-in-sql-server/ [The Performance Penalty of Bookmark Lookups in SQL Server]:http://www.sqlpassion.at/archive/2017/03/13/the-performance-penalty-of-bookmark-lookups-in-sql-server/ [Why You Should Change the Cost Threshold for Parallelism]:http://www.scarydba.com/2017/03/13/change-the-cost-threshold-for-parallelism/ [Why Update Statistics can cause an IO storm]:https://www.brentozar.com/archive/2014/01/update-statistics-the-secret-io-explosion/ @@ -752,7 +1738,7 @@ Articles types: [Why Is This Query Sometimes Fast and Sometimes Slow]:https://www.brentozar.com/archive/2016/11/query-sometimes-fast-sometimes-slow/ [Using Plan Guides to Remove OPTIMIZE FOR UNKNOWN Hints]:https://www.brentozar.com/archive/2016/11/using-plan-guides-remove-optimize-unknown-hints/ [ETL Best Practices]:https://www.timmitchell.net/etl-best-practices/ -[Resolving Key Lookup Deadlocks with Plan Explorer]:https://blogs.sentryone.com/greggonzalez/key-lookup-deadlocks-plan-explorer/ +[Resolving Key Lookup Deadlocks with Plan Explorer]:https://www.sentryone.com/blog/greggonzalez/key-lookup-deadlocks-plan-explorer/ [Why ROWLOCK Hints Can Make Queries Slower and Blocking Worse in SQL Server]:https://www.littlekendra.com/2016/02/04/why-rowlock-hints-can-make-queries-slower-and-blocking-worse-in-sql-server/ [Does a Clustered Index really physically store the rows in key order]:http://www.sqlservercentral.com/blogs/discussionofsqlserver/2012/10/21/does-a-clustered-index-really-physically-store-the-rows-in-key-order/ [Ugly Pragmatism For The Win]:http://michaeljswart.com/2016/02/ugly-pragmatism-for-the-win/ @@ -771,20 +1757,20 @@ Articles types: [Switch in Staging Tables Instead of sp_rename]:https://www.littlekendra.com/2017/01/19/why-you-should-switch-in-staging-tables-instead-of-renaming/ [Performance Myths: Table variables are always in-memory]:https://sqlperformance.com/2017/04/performance-myths/table-variables-in-memory [Questions About SQL Server Collations You Were Too Shy to Ask]:https://www.simple-talk.com/sql/sql-development/questions-sql-server-collations-shy-ask/ -[NULL - The database's black hole]:http://sqlblog.com/blogs/hugo_kornelis/archive/2007/07/06/null-ndash-the-database-rsquo-s-black-hole.aspx +[NULL - The database's black hole]:https://sqlserverfast.com/blog/hugo/2007/07/null-the-databases-black-hole/ [Inside the Storage Engine: Using DBCC PAGE and DBCC IND to find out if page splits ever roll back]:http://www.sqlskills.com/blogs/paul/inside-the-storage-engine-using-dbcc-page-and-dbcc-ind-to-find-out-if-page-splits-ever-roll-back/ [Inside the Storage Engine: Anatomy of a page]:http://www.sqlskills.com/blogs/paul/inside-the-storage-engine-anatomy-of-a-page/ -[For The Better Developer: SQL Server Indexes]:http://sqlblog.com/blogs/davide_mauri/archive/2017/04/02/for-the-better-developer-sql-server-indexes.aspx -[#EntryLevel: Compression & Data Types]:https://blogs.sentryone.com/melissaconnors/entry-level-compression/ +[For The Better Developer: SQL Server Indexes]:https://medium.com/sql-server-for-the-better-developer/know-your-data-base-affd6241bcac +[#EntryLevel: Compression & Data Types]:https://www.sentryone.com/blog/melissaconnors/entry-level-compression/ [Cardinality Estimation for a Predicate on a COUNT Expression]:https://sqlperformance.com/2017/04/sql-optimizer/cardinality-count [Changing SQL Server Collation After Installation]:https://www.mssqltips.com/sqlservertip/3519/changing-sql-server-collation-after-installation/ [Does a TempDB spill mean statistics are out of date?]:https://www.brentozar.com/archive/2017/04/tempdb-spill-mean-statistics-date/ [Transaction log growth during BACKUP]:https://www.am2.co/2017/04/transaction-log-growth-backup/ -[When is a SQL function not a function?]:http://sqlblog.com/blogs/rob_farley/archive/2011/11/08/when-is-a-sql-function-not-a-function.aspx +[When is a SQL function not a function?]:http://blogs.lobsterpot.com.au/2011/11/08/when-is-a-sql-function-not-a-function/ [Introducing Batch Mode Adaptive Joins]:https://blogs.msdn.microsoft.com/sqlserverstorageengine/2017/04/19/introducing-batch-mode-adaptive-joins/ [Investigating the proportional fill algorithm]:https://www.sqlskills.com/blogs/paul/investigating-the-proportional-fill-algorithm/ [Understanding Logging and Recovery in SQL Server]:https://technet.microsoft.com/en-us/library/2009.02.logging.aspx -[Bad Habits to Kick: Using shorthand with date/time operations]:http://sqlblog.com/blogs/aaron_bertrand/archive/2011/09/20/bad-habits-to-kick-using-shorthand-with-date-time-operations.aspx +[Bad Habits to Kick: Using shorthand with date/time operations]:https://sqlblog.org/2011/09/20/bad-habits-to-kick-using-shorthand-with-date-time-operations [Generating Charts and Drawings in SQL Server Management Studio]:http://sqlmag.com/t-sql/generating-charts-and-drawings-sql-server-management-studio [How expensive are column-side Implicit Conversions?]:https://sqlperformance.com/2013/04/t-sql-queries/implicit-conversion-costs [Execution Plan Basics]:https://www.simple-talk.com/sql/performance/execution-plan-basics/ @@ -795,7 +1781,6 @@ Articles types: [Properly Persisted Computed Columns]:https://sqlperformance.com/2017/05/sql-plan/properly-persisted-computed-columns [A SQL Server DBA myth a day: (17/30) page checksums]:https://www.sqlskills.com/blogs/paul/a-sql-server-dba-myth-a-day-1730-page-checksums/ [What are different ways to replace ISNULL() in a WHERE clause that uses only literal values?]:https://dba.stackexchange.com/questions/168276/what-are-different-ways-to-replace-isnull-in-a-where-clause-that-uses-only-lit -[Weaning yourself off of SQL Profiler (Part 1)]:http://blog.waynesheffield.com/wayne/archive/2017/04/weaning-yourself-off-sql-profiler/ [SQL Server 2016 enhancements – Truncate Table and Table Partitioning]:https://www.sqlshack.com/sql-server-2016-enhancements-truncate-table-table-partitioning [SQL Server Mysteries: The Case of the Not 100% RESTORE…]:https://blogs.msdn.microsoft.com/sql_server_team/sql-server-mysteries-the-case-of-the-not-100-restore/ [Transactional Replication and Stored Procedure Execution: Silver Bullet or Poison Pill?]:http://port1433.com/2017/04/11/transactional-replication-and-stored-procedure-execution-silver-bullet-or-poison-pill/ @@ -803,7 +1788,6 @@ Articles types: [Row-count Estimates when there are no Statistics]:http://www.sqlservercentral.com/blogs/matthew-mcgiffen-dba/2017/06/28/row-count-estimates-when-there-are-no-statistics/ [SQL Server DBA On-Boarding Checklist]:https://www.mssqltips.com/sqlservertip/4871/sql-server-dba-onboarding-checklist/ [Be Wary of Date Formatting in T-SQL]:https://bornsql.ca/2017/07/wary-date-formatting-t-sql/ -[The ultimate guide to the datetime datatypes]:http://www.karaszi.com/SQLServer/info_datetime.asp [Statistics and Cardinality Estimation]:http://www.sqlservercentral.com/blogs/matthew-mcgiffen-dba/2017/06/20/statistics-and-cardinality-estimation/ [Message queues for the DBA: sending data out into the world]:http://port1433.com/2017/07/21/messaging-queuing-for-the-dba-sending-data-out-into-the-world/ [Schema-Based Access Control for SQL Server Databases]:https://www.red-gate.com/simple-talk/sql/sql-training/schema-based-access-control-for-sql-server-databases/ @@ -826,27 +1810,25 @@ Articles types: [SQL Server Event Handling: Event Notifications]:https://itsalljustelectrons.blogspot.ru/2016/11/SQL-Server-Event-Handling-Event-Notifications.html [Identifying Deprecated Feature Usage (Part 1)]:https://itsalljustelectrons.blogspot.ru/2017/07/Identifying-Deprecated-Feature-Usage-pt1.html [Let’s Corrupt a Database Together, Part 3: Detecting Corruption]:https://www.brentozar.com/archive/2017/07/lets-corrupt-database-together-part-3-detecting-corruption/ -[XML vs JSON Shootout: Which is Superior in SQL Server 2016?]:https://blog.bertwagner.com/xml-vs-json-shootout-which-is-superior-in-sql-server-2016-b97bf7766ef2 -[One SQL Cheat Code For Amazingly Fast JSON Queries]:https://blog.bertwagner.com/one-sql-cheat-code-for-amazingly-fast-json-queries-1c2402b4b0d2 -[The Ultimate SQL Server JSON Cheat Sheet]:https://blog.bertwagner.com/the-ultimate-sql-server-json-cheat-sheet-2fbb98049a37 -[Are your indexes being thwarted by mismatched datatypes?]:https://blog.bertwagner.com/are-your-indexes-being-thwarted-by-mismatched-datatypes-d3985375e528 +[XML vs JSON Shootout: Which is Superior in SQL Server 2016?]:https://bertwagner.com/2017/05/16/xml-vs-json-shootout-which-is-superior-in-sql-server-2016/ +[One SQL Cheat Code For Amazingly Fast JSON Queries]:https://bertwagner.com/2017/05/09/one-sql-cheat-code-for-amazingly-fast-json-queries/ +[The Ultimate SQL Server JSON Cheat Sheet]:https://bertwagner.com/2017/03/07/the-ultimate-sql-server-json-cheat-sheet/ +[Are your indexes being thwarted by mismatched datatypes?]:https://bertwagner.com/2017/08/01/are-your-indexes-being-thwarted-by-mismatched-datatypes/ [Why Missing Index Recommendations Aren’t Perfect]:https://www.brentozar.com/archive/2017/08/missing-index-recommendations-arent-perfect/ -[Top 5 Misleading SQL Server Performance Counters]:https://sqlworkbooks.com/2017/06/top-5-misleading-sql-server-performance-counters/ [The Case of the Space at the End]:http://www.sqlservercentral.com/articles/ANSI_PADDING/157467/ [SELECT…INTO in SQL Server 2017]:https://dbafromthecold.com/2017/08/02/select-into-in-sql-server-2017/ [Your Service Level Agreement is a Disaster]:http://minionware.net/service-level-agreement-disaster/ [SQLskills SQL101: REBUILD vs. REORGANIZE]:https://www.sqlskills.com/blogs/paul/sqlskills-sql101-rebuild-vs-reorganize/ [Where do the Books Online index fragmentation thresholds come from?]:https://www.sqlskills.com/blogs/paul/where-do-the-books-online-index-fragmentation-thresholds-come-from/ -[The SQL Hall of Shame]:http://sqlblog.com/blogs/adam_machanic/archive/2017/06/14/the-sql-hall-of-shame.aspx +[The SQL Hall of Shame]:http://dataeducation.com/the-sql-hall-of-shame/ [A Better Way To Select Star]:https://www.brentozar.com/archive/2017/07/better-way-select-star/ [UDP vs TCP]:https://sqlstudies.com/2017/06/07/udp-vs-tcp/ -[When a Nonclustered Index and Statistics Make a Query Slower]:https://sqlworkbooks.com/2017/05/when-a-nonclustered-index-and-statistics-make-a-query-slower/ [Lipoaspiration in your SQL Server Database]:https://www.red-gate.com/simple-talk/sql/performance/lipoaspiration-in-your-sql-server-database/ [13 Things You Should Know About Statistics and the Query Optimizer]:https://www.red-gate.com/simple-talk/sql/t-sql-programming/13-things-you-should-know-about-statistics-and-the-query-optimizer/ [Creating R Stored Procedures in SQL Server 2016 Using sqlrutils]:http://www.nielsberglund.com/2017/06/25/creating-r-stored-procedures-in-sql-server-2016-using-sqlrutils/ [A Quick start Guide to Managing SQL Server 2017 on CentOS/RHEL Using the SSH Protocol]:https://www.sqlshack.com/quick-start-guide-managing-sql-server-2017-centosrhel-using-ssh-protocol/ [SQL Server v.Next : STRING_AGG Performance, Part 2]:https://sqlperformance.com/2017/01/sql-performance/sql-server-v-next-string_agg-performance-part-2 -[Why Parameter Sniffing Is Making Your Queries Receive Sub-Optimal Execution Plans]:https://blog.bertwagner.com/why-parameter-sniffing-isnt-always-a-bad-thing-but-usually-is-ba6a62a97b68 +[Why Parameter Sniffing Isn’t Always A Bad Thing (But Usually Is)]:https://bertwagner.com/2017/08/08/why-parameter-sniffing-isnt-always-a-bad-thing-but-usually-is/ [Persisting statistics sampling rate]:https://blogs.msdn.microsoft.com/sql_server_team/persisting-statistics-sampling-rate/ [All about locking in SQL Server]:https://www.sqlshack.com/locking-sql-server/ [All about Latches in SQL Server]:https://www.sqlshack.com/all-about-latches-in-sql-server/ @@ -860,9 +1842,7 @@ Articles types: [Dynamic Data Unmasking]:https://orderbyselectnull.com/2017/08/25/dynamic-data-unmasking/ [Why is My Database Application so Slow?]:https://www.red-gate.com/simple-talk/dotnet/net-performance/database-application-slow/ [Generating Concurrent Activity]:http://michaeljswart.com/2014/01/generating-concurrent-activity/ -[Required Testing for Installing SQL Server Cumulative Updates and Service Packs]:http://littlekendra.com/2016/04/28/required-testing-for-installing-sql-server-cumulative-updates-and-service-packs/ [Microsoft SQL Server R Services - Internals X]:http://www.nielsberglund.com/2017/08/29/microsoft-sql-server-r-services-internals-x/ -[Clustered columnstore: on-disk vs. in-mem]:http://nedotter.com/archive/2017/03/clustered-columnstore-on-disk-vs-in-mem/ [Hands on Full-Text Search in SQL Server]:https://www.sqlshack.com/hands-full-text-search-sql-server/ [SQL Code Smells]:https://www.red-gate.com/simple-talk/sql/t-sql-programming/sql-code-smells/ [Corruption demo databases and scripts]:https://www.sqlskills.com/blogs/paul/corruption-demo-databases-and-scripts/ @@ -874,7 +1854,7 @@ Articles types: [Using native compilation to insert parent/child tables]:http://nedotter.com/archive/2017/09/using-native-compilation-to-insert-parentchild-tables/ [Questions About RDS SQL Server You Were Too Shy to Ask]:https://www.red-gate.com/simple-talk/cloud/cloud-data/questions-rds-sql-server-shy-ask/ [Active Directory Authentication with SQL Server on Ubuntu]:http://port1433.com/2017/09/19/active-directory-authentication-with-sql-server-on-ubuntu/ -[Temporary Tables in Stored Procedures]:http://sqlblog.com/blogs/paul_white/archive/2012/08/15/temporary-tables-in-stored-procedures.aspx +[Temporary Tables in Stored Procedures]:https://www.sql.kiwi/2012/08/temporary-tables-in-stored-procedures.html [SQLCLR in Practice: Creating a Better Way of Sending Email from SQL Server]:https://www.red-gate.com/simple-talk/sql/sql-development/sqlclr-practice-creating-better-way-sending-email-sql-server/ [T-SQL commands performance comparison – NOT IN vs NOT EXISTS vs LEFT JOIN vs EXCEPT]:https://www.sqlshack.com/t-sql-commands-performance-comparison-not-vs-not-exists-vs-left-join-vs-except/ [Clustered vs Nonclustered: Index Fundamentals You Need To Know]:https://bertwagner.com/2017/09/26/clustered-vs-nonclustered-index-fundamentals-you-need-to-know/ @@ -900,7 +1880,6 @@ Articles types: [Say NO to Venn Diagrams When Explaining JOINs]:https://blog.jooq.org/2016/07/05/say-no-to-venn-diagrams-when-explaining-joins/ [Surprise Delta Stores]:https://orderbyselectnull.com/2017/11/07/delta-stores/ [SQL 2014 Clustered Columnstore index rebuild and maintenance considerations]:https://blogs.msdn.microsoft.com/sqlcat/2015/07/08/sql-2014-clustered-columnstore-index-rebuild-and-maintenance-considerations/ -[The Case of the Weirdly Long COLUMNSTORE_BUILD_THROTTLE Wait]:https://sqlworkbooks.com/2017/11/the-case-of-the-weirdly-long-columnstore_build_throttle-wait/ [Multiple Output Datasets With R and SQL Server]:https://itsalljustelectrons.blogspot.ru/2017/11/Multiple-Output-Datasets-with-R-and-SQL-Server.html [How to Avoid Excessive Sorts in Window Functions]:https://blog.jooq.org/2017/11/06/how-to-avoid-excessive-sorts-in-window-functions/ [Extracting a DAX Query Plan With Analysis Services 2016 Extended Events]:https://www.mssqltips.com/sqlservertip/5106/extracting-a-dax-query-plan-with-analysis-services-2016-extended-events/ @@ -914,7 +1893,7 @@ Articles types: [Eight Different Ways to Clear the SQL Server Plan Cache]:https://www.sqlskills.com/blogs/glenn/eight-different-ways-to-clear-the-sql-server-plan-cache/ [Introduction and FAQs about Microsoft Azure technologies]:https://www.sqlshack.com/introduction-faqs-microsoft-azure-technologies/ [Inside the XEvent Profiler]:https://www.sqlhammer.com/inside-xevent-profiler/ -[Does The Join Order of My Tables Matter?]:https://blog.bertwagner.com/does-the-join-order-of-my-tables-matter-e091afb2e385 +[Does The Join Order of My Tables Matter?]:https://bertwagner.com/2017/11/21/does-the-join-order-of-my-tables-matter/ [Encrypting SQL Server connections with Let’s Encrypt certificates]:https://sqlsunday.com/2017/11/22/encrypting-tds-with-letsencrypt/ [Start SQL Server without tempdb]:https://sqlstudies.com/2016/01/20/start-sql-server-without-tempdb/ [How to configure database mail in SQL Server]:https://www.sqlshack.com/configure-database-mail-sql-server/ @@ -922,11 +1901,10 @@ Articles types: [Cleanly Uninstalling Stubborn SQL Server Components]:https://www.mssqltips.com/sqlservertip/4050/cleanly-uninstalling-stubborn-sql-server-components/ [Hey! What's the deal with SQL Server NOCOUNT and T-SQL WHILE loops?]:http://sql-sasquatch.blogspot.ru/2017/11/hey-whats-deal-with-nocount-and-t-sql.html [Query Store Settings]:https://www.sqlskills.com/blogs/erin/query-store-settings/ -[Using Plan Explorer with Entity Framework]:https://blogs.sentryone.com/jasonhall/using-plan-explorer-entity-framework/ +[Using Plan Explorer with Entity Framework]:https://www.sentryone.com/blog/jasonhall/using-plan-explorer-entity-framework/ [Overview of Encryption Tools in SQL Server]:https://matthewmcgiffen.com/2017/12/05/overview-of-encryption-tools-in-sql-server/ [Clustered Index Uniquifier Existence and Size]:https://sqlquantumleap.com/2017/09/18/clustered-index-uniquifier-existence-and-size/ -[Understanding Logging and Recovery in SQL Server]:https://technet.microsoft.com/en-us/library/2009.02.logging.aspx -[Understanding SQL Server Backups]:https://technet.microsoft.com/en-us/library/2009.07.sqlbackup.aspx +[Understanding SQL Server Backups]:https://docs.microsoft.com/en-us/previous-versions/technet-magazine/dd822915(v=msdn.10) [Recovering from Disasters Using Backups]:https://technet.microsoft.com/en-us/library/ee677581.aspx [Simple SQL: Handling Location Datatypes]:https://www.red-gate.com/simple-talk/sql/t-sql-programming/simple-sql-handling-location-datatypes/ [Improve SQL Server Performance by Looking at Plan Cache (Part 1)]:https://logicalread.com/sql-server-minimize-single-use-plans-tl01/ @@ -939,3 +1917,994 @@ Articles types: [Which Collation is Used to Convert NVARCHAR to VARCHAR in a WHERE Condition? (Part A of 2: “Duck”)]:https://sqlquantumleap.com/2017/12/08/which-collation-is-used-to-convert-nvarchar-to-varchar-in-a-where-condition-part-a-of-2-duck/ [Which Collation is Used to Convert NVARCHAR to VARCHAR in a WHERE Condition? (Part B of 2: “Rabbit”)]:https://sqlquantumleap.com/2017/12/11/which-collation-is-used-to-convert-nvarchar-to-varchar-in-a-where-condition-part-b-of-2-rabbit/#comments [Current State of the NewSQL/NoSQL Cloud Arena]:https://www.red-gate.com/simple-talk/cloud/cloud-data/current-state-newsqlnosql-cloud-arena/ +[SQL Server 2017: JSON]:http://db-devs.com/blog/archive/sql-server-2017-json/ +[Simulating Bad Networks to Test SQL Server Replication]:https://www.red-gate.com/simple-talk/blogs/simulating-bad-networks-test-sql-server-replication/ +[How to Turn on Instant File Initialization]:https://www.databasejournal.com/tips/how-to-turn-on-instant-file-initialization.html +[Bad Idea Jeans: Finding Undocumented Trace Flags]:https://rebrand.ly/brent-finding-undocumented-trace-flags +[A Method to Find Trace Flags]:https://rebrand.ly/joe-finding-undocumented-trace-flags +[Using Windows stored credentials to connect to SQL in containers]:https://dbafromthecold.com/2018/01/17/using-windows-stored-credentials-to-connect-to-sql-in-containers/ +[Step by Step Guide to Migrate SQL Server Data to SQL Server 2017]:https://www.databasejournal.com/features/mssql/step-by-step-guide-to-migrate-sql-server-data-to-sql-server-2017.html +[Administrative Logins and Users]:https://sqlstudies.com/2015/11/02/administrative-logins-and-users/ +[Parallelism in Hekaton (In-Memory OLTP)]:http://www.nikoport.com/2018/01/20/parallelism-in-hekaton-in-memory-oltp/ +[Troubleshooting THREADPOOL Waits]:https://www.sqlpassion.at/archive/2011/10/25/troubleshooting-threadpool-waits/ +[Andy’s Excellent SSIS-in-the-Cloud Adventure, Part 1 – Build an ADFv2 IR Instance]:https://andyleonard.blog/2018/01/andys-excellent-ssis-in-the-cloud-adventure-part-1/ +[PRINT vs. RAISERROR]:http://sqlity.net/en/984/print-vs-raiserror/ +[Without ORDER BY, You Can’t Depend On the Order of Results]:http://michaeljswart.com/2013/09/without-order-by-you-cant-depend-on-the-order-of-results/ +[Query Store and “in memory”]:https://www.sqlskills.com/blogs/erin/query-store-and-in-memory/ +[Setting and Identifying Row Goals in Execution Plans]:https://sqlperformance.com/2018/02/sql-plan/setting-and-identifying-row-goals +[Azure and Windows PowerShell: The Basics]:https://www.red-gate.com/simple-talk/sysadmin/powershell/azure-windows-powershell-basics/ +[Auditing Linked Servers]:https://thomaslarock.com/2018/02/auditing-linked-servers/ +[An alternative to data masking]:https://sqlsunday.com/2018/02/05/an-alternative-to-data-masking/ +[Safely and Easily Use High-Level Permissions Without Granting Them to Anyone: Server-level]:https://sqlquantumleap.com/2018/02/15/safely-and-easily-use-high-level-permissions-without-granting-them-to-anyone-server-level/ +[PLEASE, Please, please Stop Using Impersonation, TRUSTWORTHY, and Cross-DB Ownership Chaining]:https://sqlquantumleap.com/2017/12/30/please-please-please-stop-using-impersonation-execute-as/ +[Indexing and Partitioning]:https://dbafromthecold.com/2018/02/21/indexing-and-partitioning/ +[Schema Compare for SQL Server]:https://thomaslarock.com/2018/02/schema-compare-for-sql-server/ +[How to change SQL Server ERRORLOG location]:https://red9.com/sql-server-error-log-location/ +[What’s in a Name?: Inside the Wacky World of T-SQL Identifiers]:https://sqlquantumleap.com/2018/04/09/whats-in-a-name-inside-the-wacky-world-of-t-sql-identifiers/ +[The Uni-Code: The Search for the True List of Valid Characters for T-SQL Regular Identifiers, Part 1]:https://sqlquantumleap.com/2018/04/02/the-uni-code-the-search-for-the-true-list-of-valid-characters-for-t-sql-regular-identifiers-part-1/ +[The Uni-Code: The Search for the True List of Valid Characters for T-SQL Regular Identifiers, Part 2]:https://sqlquantumleap.com/2018/04/04/the-uni-code-the-search-for-the-true-list-of-valid-characters-for-t-sql-regular-identifiers-part-2/ +[Programming SQL Server with SQL Server Management Objects Framework]:https://www.red-gate.com/simple-talk/dotnet/c-programming/programming-sql-server-sql-server-management-objects-framework/ +[Interval Queries in SQL Server]:http://www.itprotoday.com/software-development/interval-queries-sql-server +[Dealing with date and time instead of datetime]:https://sqlperformance.com/2018/03/sql-optimizer/dealing-with-date-and-time +[Insight into the SQL Server buffer cache]:https://www.sqlshack.com/insight-into-the-sql-server-buffer-cache/ +[A concrete example of migration between an Oracle Database and SQL Server using Microsoft Data Migration Assistant]:https://www.sqlshack.com/a-concrete-example-of-migration-between-an-oracle-database-and-sql-server-using-microsoft-data-migration-assistant/ +[Audit SQL Server stop, start, restart]:https://blogs.msdn.microsoft.com/skeeler/2018/03/audit-sql-server-stop-start-restart/ +[Query tuning: Apply yourself]:https://sqltechblog.com/2018/04/06/query-tuning-apply-yourself/ +[How to identify and monitor unused indexes in SQL Server]:https://www.sqlshack.com/how-to-identify-and-monitor-unused-indexes-in-sql-server/ +[Benchmarking: 1-TB table population (part 1: the baseline)]:https://www.sqlskills.com/blogs/paul/benchmarking-1-tb-table-population-part-1-the-baseline/ +[Benchmarking: 1-TB table population (part 2: optimizing log block IO size and how log IO works)]:https://www.sqlskills.com/blogs/paul/benchmarking-1-tb-table-population-part-2-optimizing-log-block-io-size-and-how-log-io-works/ +[An overview of SQL Server database migration tools provided by Microsoft]:https://www.sqlshack.com/an-overview-of-sql-server-database-migration-tools-provided-by-microsoft/ +[Calling Http endpoints in T-SQL using CURL extension]:https://blogs.msdn.microsoft.com/sqlserverstorageengine/2018/04/17/calling-http-endpoints-in-t-sql-using-curl-extension/ +[Why Table Join Orders In Relational Databases]:https://hackernoon.com/why-table-join-orders-in-relational-databases-dont-matter-6de3a35f2959 +[Finding overlapping ranges of data]:https://www.red-gate.com/simple-talk/blogs/finding-overlapping-ranges-data/ +[Avoid use of the MONEY and SMALLMONEY datatypes]:https://www.red-gate.com/hub/product-learning/sql-prompt/avoid-use-money-smallmoney-datatypes +[Provisioning SQL Server Instances with Docker]:https://www.red-gate.com/simple-talk/sysadmin/containerization/provisioning-sql-server-instances-docker/ +[Understanding the graphical representation of the SQL Server Deadlock Graph]:https://www.sqlshack.com/understanding-graphical-representation-sql-server-deadlock-graph/ +[Digitally Signing a Stored Procedure To Allow It To Run With Elevated Permissions]:https://sqlundercover.com/2018/05/02/digitally-signing-a-stored-procedure-to-allow-it-to-run-with-elevated-permissions/ +[NOLOCK and Top Optimization]:https://www.sqlshack.com/nolock-and-top-optimization/ +[Operator Precedence versus the Confusing Constraint Translation]:https://www.red-gate.com/simple-talk/blogs/operator-precedence-versus-confusing-constraint-translation/ +[Query Trace Column Values]:https://www.sqlshack.com/query-trace-column-values/ +[Concurrency Week: How to Delete Just Some Rows from a Really Big Table]:https://www.brentozar.com/archive/2018/04/how-to-delete-just-some-rows-from-a-really-big-table/ +[Break large delete operations into chunks]:https://sqlperformance.com/2013/03/io-subsystem/chunk-deletes +[How to perform a page level restore in SQL Server - Jayaram]:https://www.sqlshack.com/how-to-perform-a-page-level-restore-in-sql-server/ +[Grouping dates without blocking operators]:https://sqlsunday.com/2018/05/14/grouping-dates-without-blocking-operators/ +[What’s CHECKDB doing in my database restore?]:http://www.mikefal.net/2018/04/10/whats-checkdb-doing-in-my-database-restore/ +[How To Hide An Instance Of SQL Server]:https://thomaslarock.com/2018/04/how-to-hide-an-instance-of-sql-server/ +[Troubleshooting Parameter Sniffing Issues the Right Way: Part 1]:https://www.brentozar.com/archive/2018/03/troubleshooting-parameter-sniffing-issues-the-right-way-part-1/ +[Troubleshooting Parameter Sniffing Issues the Right Way: Part 2]:https://www.brentozar.com/archive/2018/03/troubleshooting-parameter-sniffing-issues-right-way-part-2/ +[Troubleshooting Parameter Sniffing Issues the Right Way: Part 3]:https://www.brentozar.com/archive/2018/03/troubleshooting-parameter-sniffing-issues-the-right-way-part-3/ +[When to use the SELECT…INTO statement]:https://www.red-gate.com/hub/product-learning/sql-prompt/use-selectinto-statement +[Temp Tables In SSIS]:https://www.timmitchell.net/post/2018/05/29/temp-tables-in-ssis/ +[Changing the Collation of the Instance, the Databases, and All Columns in All User Databases]:https://sqlquantumleap.com/2018/06/11/changing-the-collation-of-the-instance-and-all-columns-across-all-user-databases-what-could-possibly-go-wrong/ +[10 Cool SQL Optimisations That do not Depend on the Cost Model]:https://blog.jooq.org/2017/09/28/10-cool-sql-optimisations-that-do-not-depend-on-the-cost-model/ +[Scheduling powershell tasks with sql agent]:https://dbatools.io/agent/ +[Three ways to track logins using dbatools]:https://dbatools.io/track-logins/ +[Impact of Fragmentation on Execution Plans]:https://sqlperformance.com/2017/12/sql-indexes/impact-fragmentation-plans +[How to “debug” a Linked Server from SQL Server to an Oracle Database instance]:https://www.sqlshack.com/how-to-debug-a-linked-server-from-sql-server-to-an-oracle-database-instance/ +[How to implement error handling in SQL Server]:https://www.sqlshack.com/how-to-implement-error-handling-in-sql-server/ +[SQL Server Closure Tables]:https://www.red-gate.com/simple-talk/sql/t-sql-programming/sql-server-closure-tables/ +[Deadlock victim choice in SQL Server - an exception?]:http://joshthecoder.com/2018/05/10/deadlock-victim-choice-an-exception.html +[Azure and Windows PowerShell: Getting Information]:https://www.red-gate.com/simple-talk/sysadmin/powershell/azure-and-windows-powershell-getting-information/ +[Be our guest, be our guest, put our database to the test]:https://sqlstudies.com/2018/06/25/be-our-guest-be-our-guest-put-our-database-to-the-test/ +[Finding code smells using SQL Prompt: the SET NOCOUNT problem (PE008 and PE009)]:https://www.red-gate.com/hub/product-learning/sql-prompt/finding-code-smells-using-sql-prompt-set-nocount-problem-pe008-pe009 +[DATABASES 101 guide for the non-technical professional]:https://thomaslarock.com/2018/07/databases-101/ +[Understanding your Azure EA Billing Data and Building a Centralized Data Storage Solution]:https://www.red-gate.com/simple-talk/cloud/cloud-data/understanding-your-azure-ea-billing-data-and-building-a-centralized-data-storage-solution/ +[READ COMMITTED SNAPSHOT ISOLATION and High version_ghost_record_count]:https://www.red-gate.com/simple-talk/sql/performance/read-committed-snapshot-isolation-high-version_ghost_record_count/ +[In-Memory OLTP Indexes – Part 1: Recommendations.]:https://blogs.msdn.microsoft.com/sqlserverstorageengine/2017/11/02/in-memory-oltp-indexes-part-1-recommendations/ +[In-Memory OLTP Indexes – Part 2: Performance Troubleshooting Guide.]:https://blogs.msdn.microsoft.com/sqlserverstorageengine/2017/11/14/in-memory-oltp-indexes-part-2-performance-troubleshooting-guide/ +[Optimization Thresholds – Grouping and Aggregating Data, Part 1]:https://sqlperformance.com/2018/04/sql-plan/grouping-and-aggregating-part-1 +[Optimization Thresholds – Grouping and Aggregating Data, Part 2]:https://sqlperformance.com/2018/05/sql-plan/grouping-and-aggregating-part-2 +[Optimization Thresholds – Grouping and Aggregating Data, Part 3]:https://sqlperformance.com/2018/06/sql-plan/grouping-and-aggregating-part-3 +[Optimization Thresholds – Grouping and Aggregating Data, Part 4]:https://sqlperformance.com/2018/07/sql-performance/grouping-and-aggregating-part-4 +[Optimization Thresholds – Grouping and Aggregating Data, Part 5]:https://sqlperformance.com/2018/08/sql-performance/grouping-and-aggregating-part-5 +[When DBCC OpenTran doesn’t list all open transactions]:https://blogs.msdn.microsoft.com/mosharaf/2013/02/17/when-dbcc-opentran-doesnt-list-all-open-transactions/ +[How I spot not-yet-documented features in SQL Server CTPs]:https://www.sentryone.com/blog/aaronbertrand/fishing-for-features-in-ctps/ +[More ways to discover changes in new versions of SQL Server]:https://www.sentryone.com/blog/aaronbertrand/more-changes-sql-server/ +[Tail-Log Backup and Restore in SQL Server]:https://www.sqlshack.com/tail-log-backup-and-restore-in-sql-server/ +[Database Filegroup(s) and Piecemeal restores in SQL Server]:https://www.sqlshack.com/database-filegroups-and-piecemeal-restores-in-sql-server/ +[Updating Statistics with Ola Hallengren’s Script]:https://www.sqlskills.com/blogs/erin/updating-statistics-with-ola-hallengrens-script/ +[Interview questions on SQL Server database backups, restores and recovery – Part I]:https://www.sqlshack.com/interview-questions-on-sql-server-database-backups-restores-and-recovery-part-i/ +[Interview questions on SQL Server database backups, restores and recovery – Part II]:https://www.sqlshack.com/interview-questions-on-sql-server-database-backups-restores-and-recovery-part-ii/ +[Interview questions on SQL Server database backups, restores and recovery – Part III]:https://www.sqlshack.com/interview-questions-on-sql-server-database-backups-restores-and-recovery-part-iii/ +[Can Rowstore Compression Beat Columnstore Compression?]:https://orderbyselectnull.com/2018/06/28/can-rowstore-compression-beat-columnstore-compression/ +[Inside the Storage Engine: Anatomy of a record]:https://www.sqlskills.com/blogs/paul/inside-the-storage-engine-anatomy-of-a-record/ +[Inside the Storage Engine: Anatomy of an extent]:https://www.sqlskills.com/blogs/paul/inside-the-storage-engine-anatomy-of-an-extent/ +[Inside the Storage Engine: IAM pages, IAM chains, and allocation units]:https://www.sqlskills.com/blogs/paul/inside-the-storage-engine-iam-pages-iam-chains-and-allocation-units/ +[Inside The Storage Engine: GAM, SGAM, PFS and other allocation maps]:https://www.sqlskills.com/blogs/paul/inside-the-storage-engine-gam-sgam-pfs-and-other-allocation-maps/ +[Disaster recovery 101: fixing a broken boot page]:https://www.sqlskills.com/blogs/paul/disaster-recovery-101-fixing-a-broken-boot-page/ +[How to download a sqlservr.pdb symbol file]:https://www.sqlskills.com/blogs/paul/how-to-download-a-sqlservr-pdb-symbol-file/ +[A cause of high-duration ASYNC_IO_COMPLETION waits]:https://www.sqlskills.com/blogs/paul/cause-high-duration-async_io_completion-waits/ +[How to solve the Identity Crisis in SQL Server]:https://www.sqlshack.com/solve-identity-crisis-sql-server/ +[Azure SQL Database Performance and Service Tiers Explained]:https://sqlperformance.com/2018/08/sql-performance/azure-sql-database-tiers +[What To Do When Wait Stats Don’t Help]:https://orderbyselectnull.com/2018/07/20/what-to-do-when-wait-stats-dont-help/ +[SQL Server Brute Force Attack Detection: Part 1]:https://www.codeproject.com/Articles/1231882/SQL-Server-Brute-Force-Attack-Detection +[SQL Server Brute Force Attack Detection: Part 2]:https://www.codeproject.com/Articles/1236461/SQL-Server-Brute-Force-Attack-Detection-Part-2 +[SQL Server Brute Force Attack Detection: Part 3]:https://www.codeproject.com/Articles/1232491/SQL-Server-Brute-Force-Attack-Detection-Part-2 +[SQLCLR vs SQL Server 2017, Part 8: Is SQLCLR Deprecated in Favor of Python or R (sp_execute_external_script)?]:https://sqlquantumleap.com/2018/08/09/sqlclr-vs-sql-server-2017-part-8-is-sqlclr-deprecated-in-favor-of-python-or-r-sp_execute_external_script/ +[Sql Server Agent For Azure Sql Database, Azure Elastic Database Pools & Azure Managed Instance]:https://swyssql.wordpress.com/2018/07/20/sql-server-agent-for-azure-sql-database-azure-elastic-database-pools-azure-managed-instance/ +[Storage performance best practices and considerations for Azure SQL DB Managed Instance (General Purpose)]:https://blogs.msdn.microsoft.com/sqlcat/2018/07/20/storage-performance-best-practices-and-considerations-for-azure-sql-db-managed-instance-general-purpose/ +[T-SQL Tuesday #017: APPLY: It Slices! It Dices! It Does It All!]:http://bradsruminations.blogspot.com/2011/04/t-sql-tuesday-017-it-slices-it-dices-it.html +[SQL Server Encryption, What’s The Key Hierarchy All About?]:https://sqlundercover.com/2018/08/09/sql-server-encryption-whats-the-key-hierarchy-all-about/ +[Overview of the SQLCMD utility in SQL Server]:https://www.sqlshack.com/overview-of-the-sqlcmd-utility-in-sql-server/ +[The BCP (Bulk Copy Program) command in action]:https://www.sqlshack.com/bcp-bulk-copy-program-command-in-action/ +[Measuring Query Execution Time]:https://www.scarydba.com/2018/08/13/measuring-query-execution-time/ +[How to Check Performance on a New SQL Server]:https://www.brentozar.com/archive/2018/08/how-to-check-performance-on-a-new-sql-server/ +[Questions About Kerberos and SQL Server That You Were Too Shy to Ask]:https://www.red-gate.com/simple-talk/sql/database-administration/questions-about-kerberos-and-sql-server-that-you-were-too-shy-to-ask/ +[SQL Server Execution Plans overview]:https://www.sqlshack.com/sql-server-execution-plans-overview/ +[SQL Server Execution Plans types]:https://www.sqlshack.com/sql-server-execution-plans-types/ +[How to Analyze SQL Execution Plan Graphical Components]:https://www.sqlshack.com/how-to-analyze-sql-execution-plan-graphical-components/ +[Query optimization techniques in SQL Server: the basics]:https://www.sqlshack.com/query-optimization-techniques-in-sql-server-the-basics/ +[Query optimization techniques in SQL Server: tips and tricks]:https://www.sqlshack.com/query-optimization-techniques-in-sql-server-tips-and-tricks/ +[Query optimization techniques in SQL Server: Database Design and Architecture]:https://www.sqlshack.com/query-optimization-techniques-in-sql-server-database-design-and-architecture/ +[SQL Query Optimization Techniques in SQL Server: Parameter Sniffing]:https://www.sqlshack.com/query-optimization-techniques-in-sql-server-parameter-sniffing/ +[Similarities and Differences among RANK, DENSE_RANK and ROW_NUMBER Functions]:https://codingsight.com/similarities-and-differences-among-rank-dense_rank-and-row_number-functions/ +[Temporal Tables Under The Covers]:https://bornsql.ca/blog/temporal-tables-under-the-covers/ +[Faking Temporal Tables with Triggers]:https://bertwagner.com/2018/09/11/faking-temporal-tables-with-triggers/ +[SQL queries to manage hierarchical or parent-child relational rows in SQL Server]:https://www.codeproject.com/Articles/818694/SQL-queries-to-manage-hierarchical-or-parent-child +[Choosing Between Table Variables and Temporary Tables]:https://www.red-gate.com/hub/product-learning/sql-prompt/choosing-table-variables-temporary-tables +[What's New in the First Public CTP of SQL Server 2019]:https://www.mssqltips.com/sqlservertip/5710/whats-new-in-the-first-public-ctp-of-sql-server-2019/ +[SQL Server support for TLS 1.2 – Read This First!]:https://www.sentryone.com/blog/aaronbertrand/tls-1-2-support-read-first/ +[Misconceptions in SQL Server: A Trio of table variables]:https://sqlinthewild.co.za/index.php/2010/10/12/a-trio-of-table-variables/ +[Using the Same Column Twice in a SQL UPDATE Statement]:https://www.sqltheater.com/blog/using-the-same-column-twice-in-an-update-statement/ +[How to perform a performance test against a SQL Server instance]:https://www.sqlshack.com/how-to-perform-a-performance-test-against-a-sql-server-instance/ +[The Black Art Of Spatial Index Tuning In SQL Server]:http://boomphisto.blogspot.com/2011/04/black-art-of-spatial-index-tuning-in.html +[Patching SQL Server on Windows notes from the field]:https://www.kevinrchant.com/2019/01/10/patching-sql-server-on-windows-notes-from-the-field/ +[Availability Group Readable Secondaries – Just Say No]:https://www.sqlskills.com/blogs/jonathan/availability-group-readable-secondaries-just-say-no/ +[Finding the Slowest Query in a Stored Procedure]:https://www.sqlskills.com/blogs/erin/slowest-query-in-a-stored-procedure/ +[A Monumental Migration to SQL Server 2016 – Part 1]:https://flxsql.com/monumental-migration-sql-server-2016-part-1/ +[A Monumental Migration to SQL Server 2016 – Part 2]:https://flxsql.com/monumental-migration-sql-server-2016-part-2/ +[A unique review of SQL Server index types]:https://www.kevinrchant.com/2018/10/18/a-unique-review-of-sql-server-index-types/ +[Don’t Just Rely on Query Execution Stats for T-SQL Execution]:https://matthewmcgiffen.com/2018/09/18/dont-just-rely-on-query-execution-stats-for-t-sql-execution/ +[Posting SQL Server notifications to Slack]:https://alessandroalpi.blog/2018/09/19/posting-sql-server-notifications-to-slack/ +[How to create DACPAC file?]:https://sqlplayer.net/2018/10/how-to-create-dacpac-file/ +[Find the Next Non-NULL Row in a Series With SQL]:https://blog.jooq.org/2018/09/03/find-the-next-non-null-row-in-a-series-with-sql/ +[Calculate Percentiles to Learn About Data Set Skew in SQL]:https://blog.jooq.org/2019/01/22/calculate-percentiles-to-learn-about-data-set-skew-in-sql/ +[Comparing multiple rows insert vs single row insert with three data load methods]:https://www.red-gate.com/simple-talk/sql/performance/comparing-multiple-rows-insert-vs-single-row-insert-with-three-data-load-methods/ +[The Cause of Every Deadlock in SQL Server]:https://thomaslarock.com/2018/09/the-cause-of-every-deadlock-in-sql-server/ +[Deadlock Troubleshooting, Part 1]:https://blogs.msdn.microsoft.com/bartd/2006/09/08/deadlock-troubleshooting-part-1/ +[Deadlock Troubleshooting, Part 2]:https://blogs.msdn.microsoft.com/bartd/2006/09/12/deadlock-troubleshooting-part-2/ +[Deadlock Troubleshooting, Part 3]:https://blogs.msdn.microsoft.com/bartd/2006/09/25/deadlock-troubleshooting-part-3/ +[The Good, the Bad and the Ugly of Table Variable Deferred Compilation – Part 1]:https://milossql.wordpress.com/2018/10/04/the-good-the-bad-and-the-ugly-of-table-variable-deferred-compilation-part-1/ +[The Good, the Bad and the Ugly of Table Variable Deferred Compilation – Part 2]:https://milossql.wordpress.com/2018/10/05/the-good-the-bad-and-the-ugly-of-table-variable-deferred-compilation-part-2/ +[The Good, the Bad and the Ugly of Table Variable Deferred Compilation – Part 3]:https://milossql.wordpress.com/2018/10/08/the-good-the-bad-and-the-ugly-of-table-variable-deferred-compilation-part-3/ +[Creating a SQL Server 2019 Demo Environment in a Docker Container]:https://www.cathrinewilhelmsen.net/2018/12/02/sql-server-2019-docker-container/ +[Overview of Data Compression in SQL Server]:https://codingsight.com/overview-of-data-compression-in-sql-server/ +[SQL Server Hash Match Operator]:https://sqlserverfast.com/epr/hash-match/ +[How to use Microsoft Assessment and Planning (MAP) Toolkit for SQL Server]:https://www.sqlshack.com/how-to-use-microsoft-assessment-and-planning-map-toolkit-for-sql-server/ +[Improve the Performance of Your Azure SQL Database (and Save Money!) with Automatic Tuning]:https://www.red-gate.com/simple-talk/sql/azure-sql-database/improve-the-performance-of-your-azure-sql-database-and-save-money-with-automatic-tuning/ +[The Importance of Database Compatibility Level in SQL Server]:https://www.sqlskills.com/blogs/glenn/the-importance-of-database-compatibility-level-in-sql-server/ +[Azure Managed vs Unmanaged disks : The choice]:https://buildwindows.wordpress.com/2017/05/31/azure-managed-vs-unmanaged-disks-the-choice/ +[Storage options for SQL Server database files in Azure]:https://www.jamesserra.com/archive/2019/01/storage-options-for-sql-server-database-files-in-azure/ +[The Performance of Window Aggregates Revisited with SQL Server 2019]:https://www.red-gate.com/simple-talk/sql/t-sql-programming/the-performance-of-window-aggregates-revisited-with-sql-server-2019/ +[Super Scaling Singleton Inserts]:https://chrisadkin.io/2015/02/19/super-scaling-singleton-inserts/ +[Preparation for SQL Server Installation]:https://sqlplayer.net/2018/12/preparation-for-sql-server-installation/ +[Executing xp_cmdshell with Non SysAdmin Account]:http://www.lucasnotes.com/2019/01/executing-xpcmdshell-with-non-sysadmin.html +[Generating SQL using Biml (T-SQL Tuesday #110)]:https://www.cathrinewilhelmsen.net/2019/01/08/generating-sql-using-biml/ +[Using Temporary Procedures]:https://www.red-gate.com/simple-talk/blogs/using-temporary-procedures/ +[Introduction to SQL Server Security — Part 1]:https://www.red-gate.com/simple-talk/sysadmin/data-protection-and-privacy/introduction-to-sql-server-security-part-1/ +[Introduction to SQL Server Security — Part 2]:https://www.red-gate.com/simple-talk/sysadmin/data-protection-and-privacy/introduction-to-sql-server-security-part-2/ +[Introduction to SQL Server Security — Part 3]:https://www.red-gate.com/simple-talk/sysadmin/data-protection-and-privacy/introduction-to-sql-server-security-part-3/ +[Introduction to SQL Server Security — Part 4]:https://www.red-gate.com/simple-talk/sysadmin/data-protection-and-privacy/introduction-to-sql-server-security-part-4/ +[Introduction to T-SQL Window Functions]:https://www.red-gate.com/simple-talk/sql/t-sql-programming/introduction-to-t-sql-window-functions/ +[Intro to Debugging a Memory Dump]:https://blogs.msdn.microsoft.com/psssql/2012/03/15/intro-to-debugging-a-memory-dump/ +[Considering Security with SQL Bulk Insert]:https://www.sqlshack.com/considering-security-with-sql-bulk-insert/ +[SQL Server 2012 AlwaysOn – Part 11 – Performance Aspects and Performance Monitoring I]:https://blogs.msdn.microsoft.com/saponsqlserver/2013/04/21/sql-server-2012-alwayson-part-11-performance-aspects-and-performance-monitoring-i/ +[SQL Server 2012 AlwaysOn – Part 11 – Performance Aspects and Performance Monitoring II]:https://blogs.msdn.microsoft.com/saponsqlserver/2013/04/24/sql-server-2012-alwayson-part-12-performance-aspects-and-performance-monitoring-ii/ +[Data Compression Internals]:https://jesspomfret.com/data-compression-internals/ +[SQL Server Data Compression – Crunch Time!]:https://www.mlakartechtalk.com/sql-server-data-compression-crunch-time/ +[Create a slipstream installer for SQL Server on Windows]:https://bornsql.ca/blog/create-a-slipstream-installer-for-sql-server-on-windows/ +[Temporary Tables in SQL Server]:https://www.red-gate.com/simple-talk/sql/t-sql-programming/temporary-tables-in-sql-server/ +[SQL unit testing with the tSQLt framework for beginners]:https://www.sqlshack.com/sql-unit-testing-with-the-tsqlt-framework-for-beginners/ +[Oracle vs. SQL Server Architecture]:https://dbakevlar.com/2019/03/oracle-vs-sql-server-architecture/ +[Oracle RAC vs. SQL Server AG]:https://dbakevlar.com/2019/03/oracle-rac-vs-sql-server-ag/ +[SSIS vs. Oracle GG]:https://dbakevlar.com/2019/04/ssis-vs-oracle-gg/ +[Analysis Services Telemetry: What information does SSAS submit? and how has it changed in SSAS 2019?]:https://shabnamwatson.wordpress.com/2019/04/13/analysis-services-telemetry-what-information-does-ssas-submit-and-how-has-it-changed-in-ssas-2019/ +[The Curious Case of… how to find FILESTREAM info from an MDF]:https://www.sqlskills.com/blogs/paul/the-curious-case-of-how-to-find-filestream-info-from-an-md +[Does index fragmentation matter?]:http://sqlblog.karaszi.com/does-index-fragmentation-matter/ +[How to perform a Page Level Restore in SQL Server]:https://sqlperfmon.blogspot.com/2016/07/how-to-perform-page-level-restore-in.html +[How Much Memory Does SSIS Need?]:https://www.timmitchell.net/post/2019/05/02/how-much-memory-does-ssis-need/ +[The Curious Case of… trying to find an MDF file in a RAW disk]:https://www.sqlskills.com/blogs/paul/the-curious-case-of-trying-to-find-an-mdf-file-in-a-raw-disk/ +[Methods to Insert Data into SQL Server]:https://www.sqlshack.com/methods-to-insert-data-into-sql-server/ +[Batching data manipulation is great as long as you do it correctly]:http://desertdba.com/batching-data-manipulation-is-great/ +[Azure and Windows PowerShell: Using VM Extensions]:https://www.red-gate.com/simple-talk/sysadmin/powershell/azure-and-windows-powershell-using-vm-extensions/ +[Reloading fact tables with zero downtime]:https://sqlsunday.com/2014/08/24/reloading-fact-tables-with-zero-downtime/ +[Transferring Data Efficiently by Using Partition Switching]:https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2008-r2/ms191160(v=sql.105) +[Another Difference between N'' and '' in SQL Server]:https://nocolumnname.blog/2018/10/24/another-difference-between-n-and-in-sql-server/ +[Ignoring NULLs with FIRST_VALUE]:https://bertwagner.com/2018/08/28/ignoring-nulls-with-first-value/ +[Shortchanged with International Money in SQL Server]:https://bertwagner.com/2018/09/25/try-parse-convert-strings-to-numbers/ +[Understanding database recovery with SQL Server 2016 Extended Events]:https://www.mssqltips.com/sqlservertip/4339/understanding-database-recovery-with-sql-server-2016-extended-events/ +[SQL Server 2019: Batch Mode on Rowstore]:http://www.queryprocessor.com/batch-mode-on-row-store/ +[Using Indexing To Solve Blocking and Deadlocking Issues]:https://sqlundercover.com/2019/03/05/using-indexing-to-solve-blocking-and-deadlocking-issues/ +[Change collation of existing Azure SQL database]:https://blogs.msdn.microsoft.com/azuresqldbsupport/2018/11/09/change-collation-of-existing-azure-sql-database/ +[Creating Database Maintenance Plans]:https://codingsight.com/creating-database-maintenance-plans/ +[SQL Server Upgrade Checklist]:https://straightpathsql.com/archives/2019/03/sql-server-upgrade-checklist/ +[Failing a PowerShell Sql Agent step]:https://stuart-moore.com/failing-a-powershell-sql-agent-step/ +[The Curse of Cursor Options]:https://www.brentozar.com/archive/2018/11/the-curse-of-cursor-options/ +[Accelerated Database Recovery; Instant Rollback and Database Recovery]:https://www.sqlshack.com/accelerated-database-recovery-instant-rollback-and-database-recovery/ +[Accelerated Database Recovery and Long Running Transactions with Transaction Log Growth]:https://www.sqlshack.com/accelerated-database-recovery-and-long-running-transactions-with-transaction-log-growth/ +[Using docker named volumes to persist databases in SQL Server]:https://dbafromthecold.com/2019/03/21/using-docker-named-volumes-to-persist-databases-in-sql-server/ +[T-SQL bugs, pitfalls, and best practices – determinism]:https://sqlperformance.com/2019/03/t-sql-queries/bugs-pitfalls-best-practices-determinism +[Grouped Concatenation in SQL Server]:https://sqlperformance.com/2014/08/t-sql-queries/sql-server-grouped-concatenation +[Working with tempdb in SQL Server 2005]:https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2005/administrator/cc966545(v%3dtechnet.10) +[SQLskills SQL101: Temporary table misuse]:https://www.sqlskills.com/blogs/paul/sqlskills-sql101-temporary-table-misuse/ +[Running SQL Server on Linux on your own laptop]:https://www.kevinrchant.com/2019/03/26/running-sql-server-on-linux-on-your-own-laptop/ +[SSIS and Pentaho – A Quick Comparison]:https://sqlkover.com/ssis-and-pentaho-a-quick-comparison/ +[WinDbg and SQL Server Fun]:https://blobeater.blog/2017/06/14/windbg-and-sql-server-fun/ +[Certificates, Proxies and Jobs! Oh My!]:https://sqlstudies.com/2016/04/27/certificates-proxies-and-jobs-oh-my/ +[SQL Server: Diagnosing Intermittent Connectivity Issues]:https://mitchwheat.com/2019/04/12/sql-server-diagnosing-intermittent-connectivity-issues/ +[Difference between Identity & Sequence in SQL Server]:https://www.sqlshack.com/difference-between-identity-sequence-in-sql-server/ +[Does the Rowmodctr Update for Non-Updating Updates?]:https://www.brentozar.com/archive/2019/05/does-the-rowmodctr-update-for-non-updating-updates/ +[An Intro To Data Modeling]:https://donedifferent.data.blog/2019/04/12/an-intro-to-data-modeling/ +[On telemetry and other data collected by SQL Server]:https://www.sentryone.com/blog/aaronbertrand/sql-server-telemetry/ +[Purging data with batched deletes]:https://am2.co/2019/04/purging-data-with-batched-deletes/ +[Don’t Forget RoboCopy]:https://sqlrus.com/2019/05/dont-forget-robocopy/ +[Understanding the XML description of the Deadlock Graph in SQL Server]:https://www.sqlshack.com/understanding-the-xml-description-of-the-deadlock-graph-in-sql-server/ +[What Is The Difference Between Checkpoint And Lazy Writer]:https://saurabhsinhainblogs.blogspot.com/2012/10/interview-question-checkpoint-and-lazy.html?m=1 +[Efficiently Indexing Long Character Strings]:https://voluntarydba.com/2013/07/30/efficiently-indexing-long-character-strings/ +[SQL Server Read-only tables]:https://sqlstudies.com/2019/01/21/read-only-tables/ +[Slow inserts across a linked server?]:https://www.sqlserverscience.com/performance/slow-inserts-across-linked-server/ +[Using IGNORE NULLS With SQL Window Functions to Fill Gaps]:https://blog.jooq.org/2019/04/24/using-ignore-nulls-with-sql-window-functions-to-fill-gaps/ +[SQL Server Logical Reads]:http://www.sql-server-performance.com/logical-reads/ +[Two Words For Faster Scalar Functions]:https://bertwagner.com/2018/12/04/two-words-for-faster-scalar-functions/ +[How to Get SQL Server Dates and Times Horribly Wrong]:https://www.red-gate.com/simple-talk/sql/t-sql-programming/how-to-get-sql-server-dates-and-times-horribly-wrong/ +[Diagnosing and Resolving Spinlock Contention on SQL Server]:http://download.microsoft.com/download/D/A/A/DAAD63AF-B06F-4F29-AF1D-68A78102ABF4/SQLServerSpinlockContention.pdf +[Diagnosing and Resolving Latch Contention on SQL Server]:http://download.microsoft.com/download/B/9/E/B9EDF2CD-1DBF-4954-B81E-82522880A2DC/SQLServerLatchContention.pdf +[Advanced Nutanix: SQL Server on Nutanix Best Practices Released!]:http://stevenpoitras.com/2013/11/advanced-nutanix-sql-server-nutanix-best-practices-released/ +[Gaps and Islands Across Date Ranges]:https://bertwagner.com/2019/03/12/gaps-and-islands/ +[NOT NULL Persisted Computed Columns (And What They Allow)]:https://www.red-gate.com/simple-talk/blogs/not-null-persisted-computed-columns-and-what-they-allow/ +[How many ways are there to sort GUIDs? How much time do you have?]:https://devblogs.microsoft.com/oldnewthing/20190426-00/?p=102450 +[How do I force a SQL Login to change it’s password on next login]:https://sqlstudies.com/2019/06/05/how-do-i-force-a-sql-login-to-change-its-password-on-next-login/ +[SQL Server Performance Benchmarking with Patterns]:https://www.sqlservercentral.com/articles/sql-server-performance-benchmarking-with-patterns +[SQL Server function to convert integer date to datetime format]:https://www.mssqltips.com/sqlservertip/1712/sql-server-function-to-convert-integer-date-to-datetime-format/ +[Storing Utc Is Not A Silver Bullet]:https://codeblog.jonskeet.uk/2019/03/27/storing-utc-is-not-a-silver-bullet/ +[Logical Query Processing Part 8 : SELECT and ORDER BY]:https://www.itprotoday.com/sql-server/logical-query-processing-part-8-select-and-order +[SQL Server Common Table Expression vs Temp Table]:https://www.mssqltips.com/sqlservertip/6040/sql-server-common-table-expression-vs-temp-table/ +[Which Query Used The Most Cpu? Implementing Extended Events]:https://www.scarydba.com/2019/06/03/which-query-used-the-most-cpu-implementing-extended-events/ +[SQL Server Plan Cache Limits]:https://www.sqlskills.com/blogs/erin/sql-server-plan-cache-limits/ +[SQL Server and ReFS: Part 1 – DBCC and In Memory OLTP]:https://swasheck.wordpress.com/2014/11/11/sql-server-and-refs-part-1-dbcc-and-in-memory-oltp/ +[SQL Server and ReFS: Part 2 – FIO Benchmarking NTFS vs. ReFS]:https://swasheck.wordpress.com/2014/12/18/sql-server-and-refs-part-2-fio-benchmarking-ntfs-vs-refs/ +[Why Rolling back inserts with Identity columns is a bad idea]:https://sqlundercover.com/2019/04/11/rolling-back-inserts-with-identity-columns/ +[What’s Better, CTEs or Temp Tables?]:https://www.brentozar.com/archive/2019/06/whats-better-ctes-or-temp-tables/ +[The Difference Between SQL’s JOIN .. ON Clause and the Where Clause]:https://blog.jooq.org/2019/04/09/the-difference-between-sqls-join-on-clause-and-the-where-clause/ +[My IT department installed an antivirus with SQL Server]:https://bornsql.ca/blog/my-it-department-installed-an-antivirus-with-sql-server/ +[An Experiment with Deadlocks - ROWLOCK hint myth]:http://jasonbrimhall.info/2019/03/25/an-experiment-with-deadlocks/ +[Adding a New Transaction Log File when the Existing Log is Full]:https://www.sqlserverscience.com/internals/adding-new-transaction-log-file-when-existing-log-full/ +[Transactions Don't Start At BEGIN TRAN]:https://www.joshthecoder.com/2019/06/05/transactions-dont-start-at-begin-tran.html +[CAST/CONVERT makes expressions nullable]:https://sqlsunday.com/2019/06/05/cast-convert-makes-expressions-nullable/ +[Deciding between COALESCE and ISNULL in SQL Server]:https://www.mssqltips.com/sqlservertip/2689/deciding-between-coalesce-and-isnull-in-sql-server/] +[How do you choose which columns to include in your SQL Server clustered index?]:https://the.agilesql.club/2019/06/how-do-you-choose-which-columns-to-include-in-your-sql-server-clustered-index/ +[A ever-increasing Clustered Key value doesn’t scale]:https://www.sqlpassion.at/archive/2014/04/15/an-ever-increasing-clustered-key-value-doesnt-scale/ +[SQL Server Bit reversion]:https://dangerousdba.blogspot.com/2011/10/bit-reversion.html +[Troubleshooting a renamed SQL Server]:https://blog.wicktech.net/troubleshooting-a-renamed-sql-server/ +[Are Differential Backups Necessary?]:https://blog.wicktech.net/differential-backups/ +[Updating Statistics on Secondary Replicas of the Availability Groups]:http://www.nikoport.com/2019/06/20/updating-statistics-on-secondary-replicas-of-the-availability-groups/ +[It’s interesting how an OR short circuits]:https://sqlstudies.com/2019/06/17/its-interesting-how-an-or-short-circuits/ +[SQL Server NOLOCK Anomalies, Issues and Inconsistencies]:https://www.mssqltips.com/sqlservertip/6072/sql-server-nolock-anomalies-issues-and-inconsistencies/ +[Choosing a Database for Serverless Applications]:https://serverless.com/blog/choosing-a-database-with-serverless/ +[SQL Server On Linux: Forced Unit Access (Fua) Internals]:http://bobsql.com/sql-server-on-linux-forced-unit-access-fua-internals/ +[Socrates: The New SQL Server in the Cloud]:https://www.microsoft.com/en-us/research/uploads/prod/2019/05/socrates.pdf +[What permissions do temp stored procedures use?]:https://sqlstudies.com/2019/06/19/what-permissions-do-temp-stored-procedures-use/ +[Common SQL Server Mishaps]:https://sqlperformance.com/2019/06/sql-performance/common-sql-server-mishaps +[SQL Server Agent for SQL Express on Linux]:https://www.sqlservercentral.com/articles/sql-server-agent-for-sql-express-on-linux +[Trailing Spaces in SQL Server]:https://bertwagner.com/2019/06/18/trailing-spaces-in-sql-server/ +[Troubleshooting a Change in Query Performance]:https://www.sqlskills.com/blogs/erin/troubleshooting-a-change-in-query-performance/ +[The Silent Bug I Find in Most Triggers]:https://www.brentozar.com/archive/2019/05/the-silent-bug-i-find-in-most-triggers/ +[How to Copy a Table in SQL Server to Another Database]:https://www.mssqltips.com/sqlservertip/6009/how-to-copy-a-table-in-sql-server-to-another-database/ +[Configuration of SQL Server instance]:https://sqlplayer.net/2019/06/configuration-of-sql-server-instance/ +[What is the SQL Server Virtual Log file and how to monitor it]:https://www.sqlshack.com/what-is-sql-server-virtual-log-file-and-how-to-monitor-it/ +[Important change to VLF creation algorithm in SQL Server 2014]:https://www.sqlskills.com/blogs/paul/important-change-vlf-creation-algorithm-sql-server-2014/ +[SQL Server Transaction Log Fragmentation: a Primer]:https://www.red-gate.com/simple-talk/sql/database-administration/sql-server-transaction-log-fragmentation-a-primer/ +[8 Steps to better Transaction Log throughput]:https://www.sqlskills.com/blogs/kimberly/8-steps-to-better-transaction-log-throughput/ +[Joins With OR Clauses = 💔]:https://erikdarlingdata.com/2019/06/joins-with-or-clauses-%F0%9F%92%94/ +[Thoughts on MAXDOP]:https://erikdarlingdata.com/2019/06/thoughts-on-maxdop/ +[What the Arrow Sizes in Query Plans Really Mean]:https://www.brentozar.com/archive/2019/06/what-the-arrow-sizes-in-query-plans-really-mean/ +[Query Store Best Practices]:https://www.sqlskills.com/blogs/erin/query-store-best-practices/ +[Introduction to Data Normalization: A Database "Best" Practice]:http://agiledata.org/essays/dataNormalization.html +[Dr. OUTPUT or: How I Learned to Stop Worrying and Love the MERGE]:http://dataeducation.com/dr-output-or-how-i-learned-to-stop-worrying-and-love-the-merge/ +[SQL Server Tipping Games – Why Non-Clustered Indexes are just ignored!]:https://www.sqlpassion.at/archive/2013/06/12/sql-server-tipping-games-why-non-clustered-indexes-are-just-ignored/ +[SQL Server Guide To NULL Handling]:https://gavindraper.com//2018/11/29/SQL-Server-Guide-To-NULL-Handling/ +[Living with SQL’s 900 Byte Index Key Length Limit]:https://blogs.msdn.microsoft.com/bartd/2011/01/06/living-with-sqls-900-byte-index-key-length-limit/ +[Memory-Optimized TempDB Metadata in SQL Server 2019 - SQLHack]:https://www.sqlshack.com/memory-optimized-tempdb-metadata-in-sql-server-2019/ +[Forcing A Plan That Has A Plan Guide]:https://www.scarydba.com/2018/11/26/forcing-a-plan-that-has-a-plan-guide/ +[Remember the Default Window]:https://voiceofthedba.com/2018/08/23/remember-the-default-window/ +[The Impact of Non-Updating Updates]:https://www.sql.kiwi/2010/08/the-impact-of-non-updating-updates.html +[What are Columnstore Indexes?]:https://www.red-gate.com/simple-talk/sql/sql-development/what-are-columnstore-indexes/ +[PolyBase in SQL Server 2019 – The End of ETL?]:https://www.red-gate.com/simple-talk/sql/data-platform/polybase-in-sql-server-2019-the-end-of-etl/ +[Overview of Service Principal Name and Kerberos authentication in SQL Server]:https://www.sqlshack.com/overview-of-service-principal-name-and-kerberos-authentication-sql-server/ +[Data Transfer Strategies between MongoDB and SQL Server]:https://www.sqlservercentral.com/articles/data-transfer-strategies-between-mongodb-and-sql-server +[SQL Server and Excel Hierarchyid Example for Organization Charts]:https://www.mssqltips.com/sqlservertip/6054/sql-server-and-excel-hierarchyid-example-for-organization-charts/ +[Difference between sp_execute and sp_executesql and exec]:https://www.sqlindia.com/difference-between-sp_execute-sp_executesql-exec/ +[EXEC and sp_executesql – how are they different?]:https://www.sqlskills.com/blogs/kimberly/exec-and-sp_executesql-how-are-they-different/ +[Little Bobby Tables, SQL Injection and EXECUTE AS]:https://www.sqlskills.com/blogs/kimberly/little-bobby-tables-sql-injection-and-execute-as/ +[Examining the Performance Impact of an Adhoc Workload]:https://sqlperformance.com/2019/05/sql-plan/perf-impact-adhoc-workload +[Backup to URL]:https://blog.coeo.com/backup-to-url +[Spotting Unauthorized Configuration Settings in SQL Server]:https://www.red-gate.com/hub/product-learning/sql-monitor/spotting-unauthorized-configuration-settings-sql-server +[Window Functions in SQL Server]:https://www.red-gate.com/simple-talk/sql/learn-sql-server/window-functions-in-sql-server/ +[Window Functions in SQL Server: Part 2-The Frame]:https://www.red-gate.com/simple-talk/sql/learn-sql-server/window-functions-in-sql-server-part-2-the-frame/ +[An Intro to SQL Window Functions]:https://www.toptal.com/sql/intro-to-sql-windows-functions +[SQL Database Performance Tuning for Developers]:https://www.toptal.com/sql-server/sql-database-tuning-for-developers +[“But NOLOCK Is Okay When The Data Isn’t Changing, Right?”]:https://www.brentozar.com/archive/2019/08/but-nolock-is-okay-when-the-data-isnt-changing-right/ +[tempdb Enhancements in SQL Server 2019]:https://sqlperformance.com/2019/08/tempdb/tempdb-enhancements-in-sql-server-2019 +[Feature Restrictions in SQL Server 2019 are Worse Than Useless: a False Sense of Security And Wasted Opportunity]:https://sqlquantumleap.com/2019/08/05/feature-restrictions-in-sql-server-2019-are-worse-than-useless-a-false-sense-of-security-and-wasted-opportunity/ +[How to get SQL Server Sysadmin Privileges as a Local Admin with PowerUpSQL]:https://blog.netspi.com/get-sql-server-sysadmin-privileges-local-admin-powerupsql/ +[Views of the Same Problem: Network Admin, DBA, and Developer]:https://blog.serverfault.com/2011/03/16/views-of-the-same-problem-network-admin-dba-and-developer/ +[Finding Max Concurrent Operations With T-SQL (Part 1)]:https://36chambers.wordpress.com/2019/01/02/finding-max-concurrent-operations-with-t-sql-part-1/ +[Finding Max Concurrent Operations With T-SQL (Part 2)]:https://36chambers.wordpress.com/2019/01/03/finding-max-concurrent-operations-with-t-sql-part-2/ +[Stack Overflow: The Architecture - 2016 Edition]:https://nickcraver.com/blog/2016/02/17/stack-overflow-the-architecture-2016-edition/ +[Stack Overflow: The Hardware - 2016 Edition]:https://nickcraver.com/blog/2016/03/29/stack-overflow-the-hardware-2016-edition/ +[Stack Overflow: How We Do Deployment - 2016 Edition]:https://nickcraver.com/blog/2016/05/03/stack-overflow-how-we-do-deployment-2016-edition/ +[Stack Overflow: How We Do Monitoring - 2018 Edition]:https://nickcraver.com/blog/2018/11/29/stack-overflow-how-we-do-monitoring/ +[Stack Overflow: How We Do App Caching - 2019 Edition]:https://nickcraver.com/blog/2019/08/06/stack-overflow-how-we-do-app-caching/ +[Adding a Missing Index Killed Performance]:https://www.sqlrx.com/missing-index-killed-performance/ +[Corruption in TempDB]:https://stevestedman.com/2019/08/corruption-in-tempdb/ +[Corruption recovery using DBCC WRITEPAGE]:https://www.sqlskills.com/blogs/paul/corruption-recovery-using-dbcc-writepage/ +[Why DBCC CHECKDB can miss memory corruption]:https://www.sqlskills.com/blogs/paul/sqlskills-sql101-why-dbcc-checkdb-can-miss-memory-corruption/ +[Plan Stitch: Harnessing the Best of Many Plans]:https://www.microsoft.com/en-us/research/publication/plan-stitch-harnessing-the-best-of-many-plans-2/ +[Query and Resource Optimization: Bridging the Gap]:https://www.microsoft.com/en-us/research/publication/query-resource-optimization-bridging-gap/ +[Cuttlefish: A Lightweight Primitive for Adaptive Query Processing]:https://www.microsoft.com/en-us/research/publication/cuttlefish-a-lightweight-primitive-for-adaptive-query-processing/ +[Leveraging Re-costing for Online Optimization of Parameterized Queries with Guarantees]:https://www.microsoft.com/en-us/research/publication/leveraging-re-costing-online-optimization-parameterized-queries-guarantees/ +[How to choose antivirus software to run on computers that are running SQL Server]:https://support.microsoft.com/help/309422 +[Why is SYSDATETIME() slower than SYSUTCDATETIME()?]:https://erikdarlingdata.com/2019/05/why-is-sysdatetime-slower-than-sysutcdatetime/ +[Constant Time Recovery in Azure SQL Database]:https://www.microsoft.com/en-us/research/publication/constant-time-recovery-in-azure-sql-database/ +[Improving Optimistic Concurrency Control Through Transaction Batching and Operation Reordering]:https://www.microsoft.com/en-us/research/publication/improving-optimistic-concurrency-control-through-transaction-batching-and-operation-reordering/ +[An Empirical Evaluation of In-Memory Multi-Version Concurrency Control]:https://www.cs.cmu.edu/~pavlo/papers/p781-wu.pdf +[Automatically Indexing Millions of Databases in Microsoft Azure SQL Database]:https://www.microsoft.com/en-us/research/publication/automatically-indexing-millions-of-databases-in-microsoft-azure-sql-database/ +[Adding a Column with a Default Constraint]:https://matthewmcgiffen.com/2019/07/16/adding-a-column-with-a-default-constraint/ +[A Hidden Value Of Apply]:https://erikdarlingdata.com/2019/06/a-hidden-value-of-apply/ +[Improve Performance of UDFs with NULL ON NULL INPUT]:https://sqlperformance.com/2018/12/sql-performance/improve-udfs-null-on-null-input +[The ‘= NULL’ Mistake and other SQL NULL Heresies]:https://www.red-gate.com/hub/product-learning/sql-prompt/the-null-mistake-and-other-sql-null-heresies +[How to Corrupt a Database]:https://www.sqlserverscience.com/tools/how-to-corrupt-a-database/ +[SQL Server Page Types]:http://www.sqlnotes.info/2011/10/31/page-type/ +[SQL Server Index Maintenance – You’re Doing It Wrong]:http://www.seangallardy.com/sql-server-index-maintenance-youre-doing-it-wrong/ +[Stop Worrying About SQL Server Fragmentation]:https://www.brentozar.com/archive/2012/08/sql-server-index-fragmentation/ +[How much will it cost or save to rebuild that index?]:https://www.sqlservercentral.com/articles/rebuild-index +[To BLOB or Not To BLOB: Large Object Storage in a Database or a Filesystem?]:https://www.microsoft.com/en-us/research/wp-content/uploads/2006/04/tr-2006-45.pdf +[SQL Server UPSERT Patterns and Antipatterns]:https://michaeljswart.com/2017/07/sql-server-upsert-patterns-and-antipatterns/ +[“UPSERT” Race Condition With MERGE]:https://weblogs.sqlteam.com/dang/2009/01/31/upsert-race-condition-with-merge/ +[Use Caution with SQL Server's MERGE Statement]:https://www.mssqltips.com/sqlservertip/3074/use-caution-with-sql-servers-merge-statement/ +[Checking for potential constraint violations before entering SQL Server TRY and CATCH logic]:https://www.mssqltips.com/sqlservertip/2632/checking-for-potential-constraint-violations-before-entering-sql-server-try-and-catch-logic/ +[Performance impact of different error handling techniques]:https://sqlperformance.com/2012/08/t-sql-queries/error-handling +[Backup and Restore Databases with CHECKSUM and VERIFYONLY]:https://www.sqlrx.com/backup-and-restore-databases-with-checksum-and-verifyonly/ +[dm_db_database_page_allocations]:https://www.sqlserverscience.com/sys/dm_db_database_page_allocations/ +[Compress Big Tables]:https://www.sqlserverscience.com/performance/compress-big-tables/ +[Hardening SQL Server Security]:https://mitchwheat.com/2019/08/21/hardening-sql-server-security/ +[Splitting Strings With OPENJSON]:https://itsalljustelectrons.blogspot.com/2019/05/Splitting-Strings-With-OPENJSON.html +[How to migrate to Amazon RDS for SQL Server using transactional replication]:https://aws.amazon.com/ru/blogs/database/how-to-migrate-to-amazon-rds-for-sql-server-using-transactional-replication/ +[The Hardest Part Of Query Tuning: Logical Equivalence]:https://erikdarlingdata.com/2019/08/the-hardest-part-of-query-tuning-logical-equivalence/ +[SQL Injection: What is it? Causes and exploits]:https://www.sqlshack.com/sql-injection-what-is-it-causes-and-exploits/ +[SQL Injection: Detection and prevention]:https://www.sqlshack.com/sql-injection-detection-and-prevention/ +[Some T-SQL INSERTs DO Follow the Fill Factor!]:https://www.sqlservercentral.com/articles/some-t-sql-inserts-do-follow-the-fill-factor-sql-oolie +[Install SQL Server 2019 Big Data Cluster using Azure Data Studio]:https://nielsberglund.com/2019/09/11/install-sql-server-2019-big-data-cluster-using-azure-data-studio/ +[Ghost Records in SQL Server… Now whats that ????]:https://www.sqlservergeeks.com/sql-server-ghost-records-in-sql-server-now-whats-that/ +[Transaction Isolation Levels and sp_executesql]:https://www.sqlserverscience.com/basics/stored-procedure-dynamic-sql-execute-as/ +[Batch Mode Bitmaps in SQL Server]:https://sqlperformance.com/2019/08/sql-performance/batch-mode-bitmaps-in-sql-server +[Transparent Data Encryption (TDE) on Azure SQL database]:https://www.sqlshack.com/transparent-data-encryption-tde-on-the-azure-sql-database/ +[Analyzing Estimates from the CSelCalcAscendingKeyFilter Calculator]:https://www.joshthecoder.com/2019/08/21/analyzing-estimates-cselcalcascendingkeyfilter-calculator.html +[Building Storage for SQL Server (and other database) Virtual Machines in the Cloud]:https://joeydantoni.com/2019/09/18/building-storage-for-sql-server-and-other-database-virtual-machines-in-the-cloud/ +[SQL Server Simple and Forced Parameterization]:https://www.mssqltips.com/sqlservertip/2935/sql-server-simple-and-forced-parameterization/ +[How to use a SQL Server Plan Guide to Tune Queries]:https://www.mssqltips.com/sqlservertip/1630/how-to-use-a-sql-server-plan-guide-to-tune-queries/ +[Neglecting to Use, or Misusing, the RETURN Keyword (BP016)]:https://www.red-gate.com/hub/product-learning/sql-prompt/neglecting-to-use-or-misusing-the-return-keyword-bp016 +[Defensive Error Handling]:https://www.red-gate.com/simple-talk/sql/t-sql-programming/defensive-error-handling/ +[A Self-Tuning Fill Factor Technique for SQL Server – Part 1]:https://www.sqlservercentral.com/articles/a-self-tuning-fill-factor-technique-for-sql-server-part-1 +[A Self-Tuning Fill Factor Technique for SQL Server – Part 2]:https://www.sqlservercentral.com/articles/a-self-tuning-fill-factor-technique-for-sql-server-part-2 +[SQL: Been told you can't access master database system views in Azure SQL Database? Not true!]:https://blog.greglow.com/2019/09/17/sql-told-cannot-access-master-database-system-views-azure-sql-database-not-true/ +[How to increase SQL Database Full Backup speed using compression and Solid State Disks]:http://henkvandervalk.com/how-to-increase-sql-database-full-backup-speed-using-compression-and-solid-state-disks +[Troubleshooting NUMA Node Imbalance Problems (HammerDB Benchmark)]:https://www.sqlpassion.at/archive/2019/09/23/troubleshooting-numa-node-inbalance-problems/ +[SQL Server Unequal NUMA CPU engagement]:https://sql-sasquatch.blogspot.com/2019/09/sql-server-numa-cpu-engagement.html +[SSIS Connection Managers: OLE DB vs ODBC vs ADO.NET]:https://www.sqlshack.com/ssis-connection-managers-ole-db-vs-odbc-vs-ado-net/ +[SSIS Data Flows – ADO.NET vs. OLE DB vs. ODBC]:https://datatellblog.wordpress.com/2015/01/13/ssis-data-flows-ado-net-vs-ole-db-vs-odbc/ +[SSIS – Fastest data flow task item for transferring data over the network]:https://gqbi.wordpress.com/2013/06/19/ssis-fastest-data-flow-task-item-for-transferring-data-over-the-network/ +[The Case of the Vanishing Index Compression]:red-gate.com/simple-talk/blogs/the-case-of-the-vanishing-index-compression/ +[Migrating from MSSQL to PostgreSQL - What You Should Know]:https://severalnines.com/database-blog/migrating-mssql-postgresql-what-you-should-know +[Difference between Identity and Sequence in SQL Server 2012]:https://raresql.com/2012/05/01/difference-between-identity-and-sequence/ +[Sequence vs Identity – Performance Comparison]:http://byobi.com/2012/09/sequence-vs-identity-performance-comparison/ +[Read Excel File in SQL Server with OPENROWSET or OPENDATASOURCE]:https://www.mssqltips.com/sqlservertip/6178/read-excel-file-in-sql-server-with-openrowset-or-opendatasource/ +[Upgrading SQL Server using Availability Groups – Checklist]:https://thelonedba.wordpress.com/2019/10/17/upgrading-sql-server-using-availability-groups-checklist/ +[Using indexed views? WITH (NOEXPAND) for Standard Edition]:https://bornsql.ca/blog/using-indexed-views-dont-forget-this-important-tip/ +[Using indexed views? What is an imprecise or non-deterministic convert?]:https://bornsql.ca/blog/using-indexed-views-what-is-an-imprecise-or-non-deterministic-convert/ +[JSON in your Azure SQL Database? Let’s benchmark some options!]:https://techcommunity.microsoft.com/t5/SQL-Customer-Success-Engineering/JSON-in-your-Azure-SQL-Database-Let-s-benchmark-some-options/ba-p/909131 +[Looking for strange - addition to system_health XE]:https://karaszi.com/looking-for-strange +[What's new in SQL Server version x]:https://karaszi.com/new-in-version-x +[The ultimate guide to the datetime datatypes]:https://karaszi.com/the-ultimate-guide-to-the-datetime-datatypes +[Some numbers that you will know by heart if you have been working with SQL Server for a while]:https://sqlservercode.blogspot.com/2019/03/some-numbers-that-you-will-know-by.html +[#TSQL2sday: How Much Plan Cache History Do You Have?]:https://www.brentozar.com/archive/2018/07/tsql2sday-how-much-plan-cache-history-do-you-have/ +[Fixing SQL Server Management Studio’s Tab Text]:https://www.brentozar.com/archive/2011/06/fixing-sql-server-management-studios-tab-text/ +[An overview of the SQL table variable]:https://www.sqlshack.com/an-overview-of-the-sql-table-variable/ +[Performance Impact of Small Queries]:https://forrestmcdaniel.com/2019/06/25/performance-impact-of-small-queries/ +[How we use SQL Server as a Document Store]:https://octopus.com/blog/sql-as-document-store +[Overlooked T-SQL Gems]:https://sqlperformance.com/2019/10/t-sql-queries/overlooked-t-sql-gems +[Are SQL Server database triggers evil?]:https://www.sqlshack.com/are-sql-server-database-triggers-evil/ +[Configuration Best Practices for SQL Server Tempdb–Initial Sizing]:https://logicalread.com/2013/02/12/sql-server-tempdb-best-practices-initial-sizing-w01/ +[Sql Server Extended Events Trace Overhead]:https://nenadnoveljic.com/blog/sql-server-extended-events-trace-overhead/ +[Measuring "Observer Overhead" of SQL Trace vs. Extended Events]:https://sqlperformance.com/2012/10/sql-trace/observer-overhead-trace-extended-events +[Performance overhead of tracing with Extended Event targets vs SQL Trace under CPU Load]:http://andreas-wolter.com/en/performance-overhead-of-tracing-with-extended-event-targets-vs-sql-trace-under-cpu-load/ +[Fragmentation, the final installment]:http://sqlblog.karaszi.com/fragmentation-the-final-installment/ +[Atomic Durability - How do databases recover from a crash ?]:https://concurrencyfreaks.blogspot.com/2019/10/atomic-durability-how-do-databases.html +[Truth First, or Why You Should Mostly Implement Database First Designs]:https://blog.jooq.org/2018/06/06/truth-first-or-why-you-should-mostly-implement-database-first-designs/ +[SQL Server CHECKPOINT, Lazy Writer, Eager Writer and Dirty Pages in SQL Server]:https://www.sqlshack.com/sql-server-checkpoint-lazy-writer-eager-writer-and-dirty-pages-in-sql-server/ +[T-SQL bugs, pitfalls, and best practices – window functions]:https://sqlperformance.com/2019/08/sql-performance/t-sql-bugs-pitfalls-and-best-practices-window-functions +[#BackToBasics: Why I use lower case for data type names (now)]:https://www.sentryone.com/blog/aaronbertrand/backtobasics-lower-case-data-types +[New high availability and disaster recovery benefits for SQL Server]:https://cloudblogs.microsoft.com/sqlserver/2019/10/30/new-high-availability-and-disaster-recovery-benefits-for-sql-server/ +[Because Your Index Maintenance Script Is Measuring The Wrong Thing]:https://www.erikdarlingdata.com/2019/10/because-your-index-maintenance-script-is-measuring-the-wrong-thing/ +[Memory-Optimized TempDB Metadata]:http://www.nikoport.com/2019/10/30/memory-optimized-tempdb-metadata/ +[Build a SQL Cluster Lab Part 1]:https://www.ryanjadams.com/2019/10/build-a-sql-cluster-lab-part-1/ +[There is no Such Thing as Object-Relational Impedance Mismatch]:https://blog.jooq.org/2015/08/26/there-is-no-such-thing-as-object-relational-impedance-mismatch/ +[ORMs Under the Hood]:https://www.vertabelo.com/blog/orms-under-the-hood/ +[EMERGENCY-mode repair: the very, very last resort]:https://www.sqlskills.com/blogs/paul/checkdb-from-every-angle-emergency-mode-repair-the-very-very-last-resort/ +[Scalar functions and improvements in SQL Server 2019]:http://sqlblog.karaszi.com/scalar-functions-and-improvements-in-sql-server-2019/ +[Scalar functions in SQL server 2019, part 2]:http://sqlblog.karaszi.com/scalar-functions-in-sql-server-2019-part-2/ +[Dos and Don'ts of Dynamic SQL]:https://www.sqlservercentral.com/articles/dos-and-donts-of-dynamic-sql +[Differences Between Sql Server TEXT and VARCHAR(MAX) Data Type]:https://sqlhints.com/2016/05/11/differences-between-sql-server-text-and-varcharmax-data-type/ +[VARBINARY(MAX) Tames the BLOB]:https://www.itprotoday.com/microsoft-visual-studio/varbinarymax-tames-blob +[Query Store Options in SSMS 18.4]:https://www.sqlskills.com/blogs/erin/query-store-options-in-ssms-18-4/ +[Query Store Performance Overhead: What you need to know]:https://www.sqlskills.com/blogs/erin/query-store-performance-overhead/ +[How to fork a GitHub repository and contribute to an open source project]:https://sqldbawithabeard.com/2019/11/29/how-to-fork-a-github-repository-and-contribute-to-an-open-source-project/ +[But I Need To Compare Two Date Columns In My Where Clause]:https://www.erikdarlingdata.com/2019/11/but-i-need-to-compare-two-date-columns-in-my-where-clause/ +[The Difference Between Fault Tolerance, High Availability, & Disaster Recovery]:http://www.pbenson.net/2014/02/the-difference-between-fault-tolerance-high-availability-disaster-recovery/ +[Why LOB data makes shrink run slooooowly]:https://www.sqlskills.com/blogs/paul/why-lob-data-makes-shrink-run-slooooowly-t-sql-tuesday-006/ +[SQL Server 2019 Scalar UDF inlining - out of memory in some cases]:https://sql-sasquatch.blogspot.com/2019/11/sql-server-2019-udf-inlining-oom-in.html +[Is it true that editing a single row in Management Studio empties and reloads the entire table?]:https://bornsql.ca/blog/is-it-true-that-editing-a-single-row-in-management-studio-empties-and-reloads-the-entire-table/ +[A Guide to SQL Naming Conventions]:https://blog.jooq.org/2019/10/29/a-guide-to-sql-naming-conventions/ +[Stop Mapping Stuff in Your Middleware. Use SQL’s XML or JSON Operators Instead]:https://blog.jooq.org/2019/11/13/stop-mapping-stuff-in-your-middleware-use-sqls-xml-or-json-operators-instead/ +[How Does Accelerated Database Recovery Work]:https://www.red-gate.com/simple-talk/sql/database-administration/how-does-accelerated-database-recovery-work/ +[Recover SQL Server Resource Database]:https://www.mssqltips.com/sqlservertip/6194/recover-sql-server-resource-database/ +[What’s in that database? Getting information about routines]:https://www.red-gate.com/simple-talk/blogs/whats-in-that-database-getting-information-about-routines/ +[The Gloop: An Easier way of Managing SQL Server Documentation]:https://www.red-gate.com/simple-talk/blogs/the-gloop-an-easier-way-of-managing-sql-server-documentation/ +[The SQL of Gaps and Islands in Sequences]:https://www.red-gate.com/simple-talk/sql/t-sql-programming/the-sql-of-gaps-and-islands-in-sequences/ +[Drop Database Objects Practically Risk-Free!]:https://thenonclutteredindex.com/2019/04/17/drop-database-objects-practically-risk-free/ +[Predicate Pushdown and why should I care?]:https://techcommunity.microsoft.com/t5/SQL-Server/Predicate-Pushdown-and-why-should-I-care/bc-p/1045243#M1406 +[Stack Overflow Demo Database Column Store Edition: Downloads And Links]:https://www.erikdarlingdata.com/2019/11/stack-overflow-demo-database-column-store-edition-downloads-and-links/ +[Stack Overflow Demo Database Column Store Edition: Exploring Relationships]:https://www.erikdarlingdata.com/2019/11/stack-overflow-demo-database-column-store-edition-exploring-relationships/ +[Stack Overflow Demo Database Column Store Edition: Helpful Links]:https://www.erikdarlingdata.com/2019/11/stack-overflow-demo-database-column-store-edition-helpful-links/ +[Online, Resumable, and WAIT_AT_LOW_PRIORITY operations in SQL Server]:https://littlekendra.com/2019/12/09/online-resumable-and-wait_at_low_priority-operations-in-sql-server/ +[How filtered indexes could be a more powerful feature]:https://sqlperformance.com/2013/04/t-sql-queries/filtered-indexes +[How Forced Parameterization in SQL Server Affects Filtered Indexes]:https://www.mssqltips.com/sqlservertip/6139/how-forced-parameterization-in-sql-server-affects-filtered-indexes/ +[Filtered Indexes and Forced Parameterization (redux)]:https://sqlperformance.com/2019/12/t-sql-queries/filtered-indexes-forced-parameterization +[Interpreting SQL Server 2019 DBCC MEMORYSTATUS output -- Part 1]:https://sql-sasquatch.blogspot.com/2019/12/interpreting-sql-server-2019-dbcc.html +[Invisible tempdb Killer]:https://www.joshthecoder.com/2019/12/18/invisible-tempdb-killer.html +[Batch Mode On Row Store Is Fickle]:https://www.erikdarlingdata.com/2019/12/batch-mode-on-row-store-is-fickle/ +[Use Azure To Store Sql Server Backups Offsite]:https://www.sqlstad.nl/sql-server/use-azure-to-store-sql-server-backups-offsite/ +[Handling Data Returned from a SQL Stored Procedure]:https://www.drewsk.tech/2019/12/20/handling-data-returned-from-a-sql-stored-procedure/ +[When QUERY_OPTIMIZER_COMPATIBILITY_LEVEL_140 does not follow CL 140 rules]:https://milossql.wordpress.com/2019/12/20/query_optimizer_compatibility_level_140/ +[SQL Server–HOW-TO: quickly retrieve accurate row count for table]:https://blogs.msdn.microsoft.com/martijnh/2010/07/15/sql-serverhow-to-quickly-retrieve-accurate-row-count-for-table/ +[Do You Have REFERENCES?]:https://www.red-gate.com/simple-talk/sql/t-sql-programming/do-you-have-references/ +[Fun with (columnstore) compression on a very large table – part 1]:https://sqlperformance.com/2019/12/columnstore/fun-with-compression-very-large-table-1 +[How to Make SELECT COUNT(*) Queries Crazy Fast]:https://www.brentozar.com/archive/2019/12/how-to-make-select-count-queries-crazy-fast/ +[SSISDB Catalog Defaults Best Practices]:https://datasteve.com/2019/12/06/ssisdb-catalog-defaults-best-practices/ +[Temporal Tables, and how to deal with computed columns]:https://bornsql.ca/blog/temporal-tables-and-how-to-deal-with-computed-columns/ +[Cardinality Estimation for Disjunctive Predicates in SQL Server 2014]:https://www.sql.kiwi/2014/04/cardinality-estimation-for-disjunctive-predicates-in-2014.html +[Create Distributed Availability Group in Sql Server Linux(Redhat) --- step by step]:https://techcommunity.microsoft.com/t5/sql-server-support/create-distributed-availability-group-in-sql-server-linux-redhat/ba-p/1003471 +[Connection options in SSMS]:https://sqlstudies.com/2013/11/18/connection-options-in-ssms/ +[A Script To Automatically Align Columnstore Indexes To Enhance Segment Elimination (and Hence Performances)]:https://tsql.tech/a-script-to-automatically-align-columnstore-indexes-to-enhance-segment-elimination-and-hence-performances/ +[Issues with SQLCMD when using special characters]:https://www.mssqltips.com/sqlservertip/5132/issues-with-sqlcmd-when-using-special-characters/ +[Encrypting passwords with Python Scripts in SQL Notebooks of Azure Data Studio]:https://www.sqlshack.com/encrypting-passwords-with-python-scripts-in-sql-notebooks-of-azure-data-studio/ +[Fun with (columnstore) compression on a very large table – part 2]:https://sqlperformance.com/2020/01/columnstore/fun-with-compression-very-large-table-2 +[The curious case of the sqlcmd password]:https://bornsql.ca/blog/the-curious-case-of-the-sqlcmd-password/ +[Setting up Management Studio for remote SQL Server]:https://www.sqlservercentral.com/articles/setting-up-management-studio-for-remote-sql-server +[SQL Server Security Best Practices for an Application Installed on SQL Server]:https://www.mssqltips.com/sqlservertip/6266/sql-server-security-best-practices-for-an-application-installed-on-sql-server/ +[PCI Best Practices Guide for SQL Server DBAs]:https://www.mssqltips.com/sqlservertip/3609/pci-best-practices-guide-for-sql-server-dbas/ +[SQL Server Security Checklist]:https://www.mssqltips.com/sqlservertip/3159/sql-server-security-checklist/ +[Replace Model SQL Server Database with a User Database]:https://www.mssqltips.com/sqlservertip/6154/replace-model-sql-server-database-with-a-user-database/ +[SQL Server Linux installation for Amazon EC2 instance with Red Hat OS]:https://www.sqlshack.com/sql-server-linux-installation-for-amazon-ec2-instance-with-red-hat-os/ +[Departure of a SQL Server Administrator – What to Check?]:https://thelonedba.wordpress.com/2020/01/03/departure-of-a-sql-server-administrator-what-to-check/ +[The Curious Case of… transactions rolling back during DBCC CHECKDB]:https://www.sqlskills.com/blogs/paul/the-curious-case-of-transactions-rolling-back-during-dbcc-checkdb/ +[Don’t install SQL Server from a mounted ISO]:https://bornsql.ca/blog/dont-install-sql-server-from-a-mounted-iso/ +[NULL complexities – Part 1]:https://sqlperformance.com/2019/12/t-sql-queries/null-complexities-part-1 +[NULL complexities – Part 2]:https://sqlperformance.com/2020/01/t-sql-queries/null-complexities-part-2 +[NULL complexities – Part 3]:https://sqlperformance.com/2020/02/t-sql-queries/null-complexities-part-3-missing-standard-features-and-t-sql-alternatives +[How to fix the “Agent XPs disabled” error]:https://www.sqlshack.com/how-to-fix-the-agent-xps-disabled-error/ +[Number of Rows Read / Actual Rows Read warnings in Plan Explorer]:https://sqlperformance.com/2016/06/sql-indexes/actual-rows-read-warnings-plan-explorer +[Data Compression + Backup Compression = Double Compression?]:https://jesspomfret.com/double-compression/ +[How Many Bytes Per Character in SQL Server: a Completely Complete Guide]:https://sqlquantumleap.com/2019/11/22/how-many-bytes-per-character-in-sql-server-a-completely-complete-guide/ +[Storage 101: Welcome to the Wonderful World of Storage]:https://www.red-gate.com/simple-talk/sql/database-administration/storage-101-welcome-to-the-wonderful-world-of-storage/ +[How to detect and prevent unexpected growth of the TempDB database]:https://www.sqlshack.com/how-to-detect-and-prevent-unexpected-growth-of-the-tempdb-database/ +[Understanding the SQL Server Proportional fill algorithm]:https://www.sqlshack.com/understanding-sql-server-proportional-fill-algorithm/ +[VALUES() and Long Parameter Lists]:https://www.red-gate.com/simple-talk/sql/learn-sql-server/values-and-long-parameter-lists/ +[Going Serverless with Azure SQL Database]:https://www.mssqltips.com/sqlservertip/6273/going-serverless-with-azure-sql-database/ +[SQLskills SQL101: Why are Statistics so Important?]:https://www.sqlskills.com/blogs/kimberly/sql101_whystatisticsareimportant/ +[Configuring SQL Server Express edition as SQL witness server in Database Mirroring]:https://www.sqlshack.com/configuring-sql-server-express-edition-as-sql-witness-server-in-database-mirroring/ +[The Half Apply Query]:https://forrestmcdaniel.com/2020/01/20/the-half-apply-query/ +[Import JSON data into SQL Server]:https://www.sqlshack.com/import-json-data-into-sql-server/ +[Auditing in AWS RDS SQL Server]:https://www.sqlshack.com/auditing-in-aws-rds-sql-server/ +[Types of SQL Server Indexes]:https://www.mssqltips.com/sqlservertip/6274/types-of-sql-server-indexes/ +[Use SQL Server's UNPIVOT operator to help normalize output]:https://www.mssqltips.com/sqlservertip/3000/use-sql-servers-unpivot-operator-to-help-normalize-output/ +[Prevent SSMS from seeing the server's file system]:https://dba.stackexchange.com/a/246783/107045 +[Add the ability to disable or enable a few new DMVs and DMFs introduced in SQL Server 2017]:https://support.microsoft.com/help/4046638/ +[Actual Difference Between EXISTS(SELECT 1 …), EXISTS(SELECT * …), and EXISTS(SELECT column …)]:https://sqlquantumleap.com/2020/01/24/actual-difference-between-existsselect-1-existsselect-and-existsselect-column/ +[Why Wait Stats Alone Are Not Enough]:https://sqlperformance.com/2020/01/sql-performance/why-waits-alone-are-not-enough +[Estimating AWS RDS SQL Server costs]:https://www.sqlshack.com/estimating-aws-rds-sql-server-costs/ +[SQL Server Performance Tuning Using Wait Statistics: A Beginner’s Guide]:https://www.sqlskills.com/wp-content/uploads/2014/04/sql-server-performance-tuning-using-wait-statistics-whitepaper.pdf +[sys.xp_delete_files and ‘allow filesystem enumeration’: two new undocumented items in SQL Server 2019]:https://sqlquantumleap.com/2020/01/26/sys-xp_delete_files-and-allow-filesystem-enumeration-two-new-undocumented-items-in-sql-server-2019/ +[Why Database Monitoring Tools Are So Hard to Interpret]:https://www.brentozar.com/archive/2020/01/why-database-monitoring-tools-are-so-hard-to-interpret/ +[Extended Events Misperceptions: Profiler Is Easier]:https://www.scarydba.com/2020/01/20/extended-events-misperceptions-profiler-is-easier/ +[Extended Events Misperceptions: Profiler Is Easier, Part 2]:https://www.scarydba.com/2020/01/27/extended-events-misperceptions-profiler-is-easier-part-2/ +[Automate SFTP File Transfer with SQL Server Agent and WinSCP]:https://www.mssqltips.com/sqlservertip/6285/automate-sftp-file-transfer-with-sql-server-agent-and-winscp/ +[Running Database Console Commands (DBCCs) on Azure SQL Database]:https://www.databasejournal.com/features/mssql/running-database-console-commands-dbccs-on-azure-sql-database.html +[How to Remove Times from Dates in SQL Server]:https://www.brentozar.com/archive/2020/01/how-to-remove-times-from-dates-in-sql-server/ +[Export/Import Data using BCP - SQL Server on Linux]:https://www.sqlservercentral.com/articles/export-import-data-using-bcp-sql-server-on-linux +[Prevent SQL Server Blocking using Lock_Timeout]:https://www.mssqltips.com/sqlservertip/6279/prevent-sql-server-blocking-using-locktimeout/ +[Bin Packing Problems: The SQL]:https://www.red-gate.com/simple-talk/sql/t-sql-programming/bin-packing-problems-the-sql/ +[Causation, Correlation and Crackpots]:https://www.red-gate.com/simple-talk/sql/t-sql-programming/causation-correlation-and-crackpots/ +[What Events are in a Trace?]:https://www.sqlskills.com/blogs/erin/what-events-are-in-a-trace/ +[What Are Soft Deletes, and How Are They Implemented?]:https://www.brentozar.com/archive/2020/02/what-are-soft-deletes-and-how-are-they-implemented/ +[Why You Should Switch in Staging Tables Instead of Renaming Them (Dear SQL DBA Episode 26)]:https://littlekendra.com/2017/01/19/why-you-should-switch-in-staging-tables-instead-of-renaming/ +[Changing a column from int to bigint, without downtime]:https://am2.co/2019/12/changing-a-column-from-int-to-bigint-without-downtime/ +[I hate sp_estimate_data_compression_savings]:https://am2.co/2019/12/i-hate-sp_estimate_data_compression_savings/ +[Testing as another user…without their password - impersonate the other user]:https://am2.co/2019/12/testing-as-another-user-without-their-password/ +[How does a database RESTORE affect plan cache?]:https://am2.co/2019/10/how-does-a-database-restore-affect-plan-cache/ +[Recovery of database is 0% complete (approximately 1000000 seconds remain)]:https://am2.co/2019/10/recovery-of-database-is-0-complete-approximately-1000000-seconds-remain/ +[Code to purge data based on creation date]:https://am2.co/2019/04/code-to-purge-data-on-creation-date/ +[Blocking with OBJECT_NAME()]:https://am2.co/2019/12/blocking-with-object_name/ +[Performance Myths: The query result cache]:https://sqlperformance.com/2018/07/performance-myths/query-result-cache +[Fun with (columnstore) compression on a very large table – part 3]:https://sqlperformance.com/2020/02/columnstore/fun-with-columnstore-compression-on-a-very-large-table-part-3 +[Indexing basics]:https://sqlsunday.com/2013/02/19/indexing-basics/ +[Working with covering indexes]:https://sqlsunday.com/2013/02/24/covering-indexes/ +[Using Erik Darling’s sp_pressure_detector to resolve CPU issues]:https://desertdba.com/using-erik-darlings-sp_pressure_detector-to-resolve-cpu-issues/ +[The Accidental DBA (Day 16 of 30): General Security]:https://www.sqlskills.com/blogs/jonathan/the-accidental-dba-day-16-of-30-general-security/ +[Securing Data in SQL Server]:https://www.sqlskills.com/blogs/jonathan/securing-data-in-sql-server/ +[Performance Testing SQL 2008's Transparent Data Encryption]:https://www.databasejournal.com/features/mssql/article.php/3815501/Performance-Testing-SQL-2008146s-Transparent-Data-Encryption.htm +[Common SQL Server Security Issues and Solutions]:https://docs.microsoft.com/en-us/previous-versions/technet-magazine/dd637114(v=msdn.10) +[Chaos Engineering and SQL Server]:https://dbafromthecold.com/2020/01/29/chaos-engineering-and-sql-server/ +[Different methods to attach SQL Server MDF files]:https://www.sqlshack.com/different-methods-to-attach-sql-server-mdf-files/ +[Learn SQL: How to Write a Complex SELECT Query]:https://www.sqlshack.com/learn-sql-how-to-write-a-complex-select-query/ +[Filling In Missing Values Using the T-SQL Window Frame]:https://www.red-gate.com/simple-talk/sql/t-sql-programming/filling-in-missing-values-using-the-t-sql-window-frame/ +[Select * in a view]:https://sqlreitse.home.blog/2020/02/12/select-in-a-view/ +[T-SQL TUESDAY #123: Aggregates of Aggregates using Windowing Functions]:https://jimbabwe.co.za/2020/02/12/t-sql-tuesday-123-life-hacking-by-opening-windows/ +[SQL Server Statistics: Explained]:https://blogs.msdn.microsoft.com/srgolla/2012/09/04/sql-server-statistics-explained/ +[How to Pass a List of Values Into a Stored Procedure]:https://www.brentozar.com/archive/2020/02/how-to-pass-a-list-of-values-into-a-stored-procedure/ +[What's the difference between a temp table and table variable in SQL Server?]:https://dba.stackexchange.com/a/16386/107045 +[Be Mindful of SQL Server Tempdb Use (aka Tempdb Parasites!)]:https://www.sentryone.com/blog/be-mindful-of-sql-server-tempdb-use-aka-tempdb-parasites +[Robyn Page’s SQL Server Cursor Workbench (Quirky Update)]:https://www.red-gate.com/simple-talk/sql/learn-sql-server/robyn-pages-sql-server-cursor-workbench/ +[Solving the Running Total and Ordinal Rank Problems (Rewritten) (Quirky Update)]:https://www.sqlservercentral.com/articles/solving-the-running-total-and-ordinal-rank-problems-rewritten +[Running totals in “Denali” CTP3 (Quirky Update)]:https://blog.waynesheffield.com/wayne/archive/2011/08/running-totals-in-denali-ctp3/ +[WHERE GETDATE() BETWEEN StartDate AND EndDate Is Hard to Tune.]:https://www.brentozar.com/archive/2020/02/where-getdate-between-startdate-and-enddate-is-hard-to-tune/ +[WHERE GETDATE() BETWEEN StartDate AND COALESCE(CancelDate, EndDate) Is Even Harder to Tune.]:https://www.brentozar.com/archive/2020/02/where-getdate-between-startdate-and-coalescecanceldate-enddate-is-even-harder-to-tune/ +[How to solve the SQL Identity Crisis in SQL Server]:https://www.sqlshack.com/solve-identity-crisis-sql-server/ +[Significant SQL Server 2019 licensing changes]:https://www.kevinrchant.com/2020/02/17/significant-sql-server-2019-licensing-changes/ +[Indexed View Maintenance Is Only As Bad As Your Indexes]:https://www.erikdarlingdata.com/2020/02/indexed-view-maintenance-is-only-as-bad-as-your-indexes/ +[Why Design Impacts Performance on Microsoft SQL Server]:https://www.sentryone.com/blog/why-design-impacts-performance-microsoft-sql-server +[Apply versus Nested Loops Join]:https://www.sql.kiwi/2019/06/apply-versus-nested-loops-join.html +[Inside the Optimizer: Constructing a Plan - Part 1]:https://www.sql.kiwi/2010/07/inside-the-optimiser-constructing-a-plan.html +[Inside the Optimizer: Constructing a Plan - Part 2]:https://www.sql.kiwi/2010/07/inside-the-optimiser-constructing-a-plan-ii.html +[Inside the Optimizer: Constructing a Plan - Part 3]:https://www.sql.kiwi/2010/07/inside-the-optimiser-constructing-a-plan-part-3.html +[Inside the Optimizer: Constructing a Plan - Part 4]:https://www.sql.kiwi/2010/07/inside-the-optimiser-constructing-a-plan-part-4.html +[Tips for dealing with large SQL Server scripts]:https://www.kevinrchant.com/2020/02/24/tips-for-dealing-with-large-sql-server-scripts/ +[Database Normalization in SQL with Examples]:https://www.sqlservercentral.com/articles/database-normalization-in-sql-with-examples +[Why SQL Server May Not Parallelize a Query]:https://logicalread.com/2015/10/30/sql-server-query-parallelizing-mc11/ +[Parallelism in SQL Server Execution Plan]:https://www.mssqltips.com/sqlservertip/5404/parallelism-in-sql-server-execution-plan/ +[An XEvent a Day (26 of 31) – Configuring Session Options]:https://www.sqlskills.com/blogs/jonathan/an-xevent-a-day-26-of-31-configuring-session-options/ +[Azure SQL Managed Instance Performance Considerations]:https://sqlperformance.com/2020/02/azure/sql-managed-instance-performance-considerations +[The Curious Case of… whether corruption can propagate to secondary databases]:https://www.sqlskills.com/blogs/paul/the-curious-case-of-whether-corruption-can-propagate-to-secondary-databases/ +[Stop and Think Before You Shrink – Shrinking a SQL Server Database]:https://www.mlakartechtalk.com/stop-and-think-before-you-shrink-shrinking-a-sql-server-database/ +[How to Analyze the SQL Server Error Log]:https://www.mlakartechtalk.com/how-to-analyze-the-sql-server-error-log/ +[Converting SQL Trace to Extended Events in SQL Server 2012]:https://www.sqlskills.com/blogs/jonathan/converting-sql-trace-to-extended-events-in-sql-server-2012/ +[What event information can I get by default from SQL Server?]:https://dba.stackexchange.com/a/48053/107045 +[Removing the default trace – Part 1]:https://sqlperformance.com/2020/03/extended-events/removing-default-trace-1 +[Removing the default trace – Part 2]:https://sqlperformance.com/2020/04/extended-events/removing-default-trace-2 +[Removing the default trace – Part 3]:https://sqlperformance.com/2020/04/extended-events/removing-default-trace-3 +[Keeping DRY in SQL Server with Scalar User Defined Functions – Part 1]:https://www.sentryone.com/blog/keeping-dry-in-sql-server-with-scalar-user-defined-functions-part-1 +[Different Ways to Monitor SQL Server AlwaysOn Availability Groups]:https://codingsight.com/different-ways-to-monitor-sql-server-alwayson-availability-groups/ +[SQL Server internals: Is Order of Column in the table important?]:http://ariely.info/Blog/tabid/83/EntryId/219/SQL-Server-internals-Is-Order-of-Column-in-the-table-important.aspx +[Code: Order of columns in table might impact the size of the table/database and even related to errors]:http://ariely.info/Blog/tabid/83/EntryId/243/Code-Order-of-columns-in-table-might-impact-the-size-of-the-table-database-and-even-related-to-errors.aspx +[SQL Server Internals: Getting the data of deleted column]:http://ariely.info/Blog/tabid/83/EntryId/213/SQL-Server-Internals-Getting-the-data-of-deleted-column.aspx +[Queue table issues with Availability Groups in SQL Server]:mssqltips.com/sqlservertip/6284/queue-table-issues-with-availability-groups-in-sql-server/ +[Transact-SQL: openjson hierarchy solution]:http://ariely.info/Blog/tabid/83/EntryId/239/Transact-SQL-openjson-hierarchy-solution.aspx +[CREATE DLL TRIGGER ON CREATE_LOGIN to configure default parameters for any new LOGIN]:http://ariely.info/Blog/tabid/83/EntryId/240/CREATE-DLL-TRIGGER-ON-CREATE_LOGIN-to-configure-default-parameters-for-any-new-LOGIN.aspx +[SQL varchar data type deep dive]:https://www.sqlshack.com/sql-varchar-data-type-deep-dive/ +[What is the datatype SQL_VARIANT]:https://sqlstudies.com/2020/04/16/what-is-the-datatype-sql_varient/ +[An Introduction to Asynchronous Processing with Service Broker]:https://sqlperformance.com/2014/03/sql-performance/intro-to-service-broker +[Detecting and Alerting on SQL Server Agent Missed Jobs]:https://www.sqlshack.com/detecting-and-alerting-on-sql-server-agent-missed-jobs-2/ +[Execute multiple jobs Synchronously from in a main job]:http://ariely.info/Blog/tabid/83/EntryId/250/Execute-multiple-jobs-Synchronously-from-in-a-main-job.aspx +[Why Ordering Isn’t Guaranteed Without an ORDER BY]:https://www.brentozar.com/archive/2020/04/why-ordering-isnt-guaranteed-without-an-order-by/ +[How to Attach a SQL Server Database without a Transaction Log and with Open Transactions]:https://www.mssqltips.com/sqlservertip/3579/how-to-attach-a-sql-server-database-without-a-transaction-log-and-with-open-transactions/ +[SQL 2016 - It Just Runs Faster: Indirect Checkpoint Default]:https://docs.microsoft.com/en-gb/archive/blogs/psssql/sql-2016-it-just-runs-faster-indirect-checkpoint-default +[SQL Server : large RAM and DB Checkpointing]:https://docs.microsoft.com/en-us/archive/blogs/psssql/sql-server-large-ram-and-db-checkpointing +[Indirect Checkpoint and tempdb – the good, the bad and the non-yielding scheduler]:https://docs.microsoft.com/en-gb/archive/blogs/sql_server_team/indirect-checkpoint-and-tempdb-the-good-the-bad-and-the-non-yielding-scheduler +[How do checkpoints work and what gets logged]:https://www.sqlskills.com/blogs/paul/how-do-checkpoints-work-and-what-gets-logged/ +[Inside the Storage Engine: What’s in the buffer pool?]:https://www.sqlskills.com/blogs/paul/inside-the-storage-engine-whats-in-the-buffer-pool/ +[What does checkpoint do for tempdb?]:https://www.sqlskills.com/blogs/paul/what-does-checkpoint-do-for-tempdb/ +[Performance issues from wasted buffer pool memory]:https://www.sqlskills.com/blogs/paul/performance-issues-from-wasted-buffer-pool-memory/ +[How It Works: When is the FlushCache message added to SQL Server Error Log?]:https://docs.microsoft.com/en-us/archive/blogs/psssql/how-it-works-when-is-the-flushcache-message-added-to-sql-server-error-log +[Cross Database Transactions on One Server]:https://michaeljswart.com/2020/05/cross_database_transactions/ +[Your Views Aren’t The Problem. Your Code Is.]:https://www.brentozar.com/archive/2020/05/your-views-arent-the-problem-your-code-is/ +[Negative identity values don’t suck]:https://bornsql.ca/blog/negative-identity-values-dont-suck/ +[How SQL Server stores data types: integers and decimals]:https://bornsql.ca/blog/how-sql-server-stores-data-types-integers-and-decimals/ +[How SQL Server stores data types: DATETIME, DATE, TIME, and DATETIME2]:https://bornsql.ca/blog/how-sql-server-stores-data-types-datetime-date-time-and-datetime2/ +[Can I Offload DBCC CHECKDB To Another Server?]:https://www.brentozar.com/archive/2020/05/can-i-offload-dbcc-checkdb-to-another-server/ +[Negative (-) is an operator and will affect the order of operations.]:https://sqlstudies.com/2020/05/18/negative-is-an-operator-and-will-effect-the-order-of-operations/ +["0 to 60" : Switching to indirect checkpoints]:https://sqlperformance.com/2020/05/system-configuration/0-to-60-switching-to-indirect-checkpoints +[Parallelism Can Make Queries Perform Worse.]:https://www.brentozar.com/archive/2020/05/parallelism-can-make-queries-perform-worse/ +[A SQL Server DBA myth a day: (15/30) checkpoint only writes pages from committed transactions]:https://www.sqlskills.com/blogs/paul/a-sql-server-dba-myth-a-day-1530-checkpoint-only-writes-pages-from-committed-transactions/ +[Can You Use NVARCHAR As a Universal Parameter? Almost.]:https://www.brentozar.com/archive/2020/04/can-you-use-nvarchar-as-a-universal-parameter-almost/ +[The Learner’s Guide to SQL Server Performance Triage]:https://littlekendra.com/2020/03/19/the-learners-guide-to-sql-server-performance-triage/ +[Learner’s Guide to SQL Server Query Tuning]:https://littlekendra.com/2020/05/01/learners-guide-to-sql-server-query-tuning/ +[How to Get Better Estimates for Modification Queries]:https://www.brentozar.com/archive/2020/04/how-to-get-better-estimates-for-modification-queries/ +[SSMS: Prevent Copy and Paste of Text in “Messages” tab (Cruel Joke #2)]:https://sqlquantumleap.com/2020/05/22/ssms-prevent-copy-and-paste-of-text-in-messages-tab-cruel-joke-2/s +[Compare the Best SQL Server Performance Monitoring Tools]:https://www.sentryone.com/compare-best-sql-server-monitoring-tools +[Minimal Logging with INSERT…SELECT into Heap Tables]:https://sqlperformance.com/2019/05/sql-performance/minimal-logging-insert-select-heap +[Minimal Logging with INSERT…SELECT into Empty Clustered Tables]:https://sqlperformance.com/2019/05/sql-performance/minimal-logging-empty-clustered +[Minimal Logging with INSERT…SELECT and Fast Load Context]:https://sqlperformance.com/2019/05/sql-performance/minimal-logging-fast-load-context +[Avoiding SQL Server Upgrade Performance Issues]:https://www.sqlskills.com/blogs/glenn/avoid-sql-server-upgrade-performance-issues/ +[Compatibility Levels and Cardinality Estimation Primer]:https://sqlperformance.com/2019/01/sql-performance/compatibility-levels-and-cardinality-estimation-primer +[An approach to index tuning – Part 1]:https://sqlperformance.com/2020/03/sql-indexes/an-approach-to-index-tuning-part-1 +[An approach to index tuning – Part 2]:https://sqlperformance.com/2020/04/sql-indexes/an-approach-to-index-tuning-part-2 +[Moving A Database to New Storage With No Downtime]:https://www.bobpusateri.com/archive/2013/03/moving-a-database-to-new-storage-with-no-downtime/ +[RESOURCE_GOVERNOR_IDLE in Azure]:https://joshthecoder.com/2020/06/15/resource-governor-idle-in-azure.html +[Automated Backup Tuning]:https://sirsql.net/2012/12/13/20121212automated-backup-tuning/ +[Optimizing Database Restores]:https://sirsql.net/2011/09/26/2011926optimizing-database-restores-html/ +[AVAILABILITY_REPLICA - The Deception of the Log Reuse Wait Type]:https://sirsql.net/2020/05/19/the-deception-of-the-log-reuse-wait-type/ +[Changing an INT to a BIGINT with no downtime]:https://michaeljswart.com/2020/06/problem-solving-by-cheating/ +[New Metadata-Only Column Changes in SQL Server 2016]:https://sqlperformance.com/2020/04/database-design/new-metadata-column-changes-sql-server-2016 +[Bandwidth-friendly Query Profiling for Azure SQL Database]:https://sqlperformance.com/2020/04/sql-performance/bandwidth-friendly-query-profiling-azure-sql-database +[When a Columnstore Index Makes Your Query Fail - 1/0 error]:https://www.brentozar.com/archive/2020/06/when-a-columnstore-index-makes-your-query-fail/ +[Column scope and binding order in subqueries]:https://sqlinthewild.co.za/index.php/2019/04/23/no-this-is-not-a-bug-in-t-sql/ +[Improve SQL Server Extended Events system_health Session]:https://www.mssqltips.com/sqlservertip/6456/improve-sql-server-extended-events-systemhealth-session/ +[Page Life Expectancy Doesn’t Mean Jack, and You Should Stop Looking At It.]:https://www.brentozar.com/archive/2020/06/page-life-expectancy-doesnt-mean-jack-and-you-should-stop-looking-at-it/ +[Unsupported but working versions of SQL Server on Windows Server 2019]:https://bornsql.ca/blog/unsupported-but-working-versions-of-sql-server-on-windows-server-2019/ +[Bad Idea Jeans: Building Big Query Plans]:https://www.brentozar.com/archive/2020/06/bad-idea-jeans-building-big-query-plans/ +[SQL Server performance tuning – RESOURCE_SEMAPHORE waits]:https://www.sqlshack.com/sql-server-performance-tuning-resource_semaphore-waits/ +[Use session_context to create a “variable” that lasts between batches.]:https://sqlstudies.com/2020/05/26/use-session_context-to-create-a-variable-that-lasts-between-batches/ +[Phase out CONTEXT_INFO() in SQL Server 2016 with SESSION_CONTEXT()]:https://www.mssqltips.com/sqlservertip/4094/phase-out-contextinfo-in-sql-server-2016-with-sessioncontext/ +[How to Balance SQL Server Core Licenses Across NUMA Nodes]:https://glennsqlperformance.com/2020/06/25/how-to-balance-sql-server-core-licenses-across-numa-nodes/ +[What is the Difference Between Physical Sockets, Physical Cores, and Logical Cores?]:https://glennsqlperformance.com/2019/12/18/what-is-the-difference-between-physical-sockets-physical-cores-and-logical-cores/ +[Troubleshooting SQL Server Wait Stats]:https://www.sentryone.com/white-papers/troubleshooting-sql-server-wait-stats +[The 201 Buckets Problem, Part 1: Why You Still Don’t Get Accurate Estimates]:https://www.brentozar.com/archive/2020/07/the-201-buckets-problem-part-1-why-you-still-dont-get-accurate-estimates/ +[The 201 Buckets Problem, Part 2: How Bad Estimates Backfire As Your Data Grows]:https://www.brentozar.com/archive/2020/07/the-201-buckets-problem-part-2-how-bad-estimates-backfire-as-your-data-grows/ +[Sql Server — Widely Random Query Exec Times (cxconsumer Wait/cxpacket) & Possible Remediation]:https://viktorsrandomposts.wordpress.com/2020/06/26/sql-server-widely-random-query-exec-times-cxconsumer-wait-possible-remediation/ +[How MAXDOP Really Works]:https://www.sql.kiwi/2020/07/how-maxdop-really-works.html +[What is MaxDOP controlling?]:https://techcommunity.microsoft.com/t5/sql-server/what-is-maxdop-controlling/ba-p/1505968 +[What If You Really DO Need to Shrink a Database?]:https://www.brentozar.com/archive/2020/07/what-if-you-really-do-need-to-shrink-a-database/ +[Everything I Never Wanted to Know About Collation]:https://littlekendra.com/2020/07/16/everything-i-never-wanted-to-know-about-collation-14-minute-video-podcast-episode/ +[Comparing SSIS And Azure Data Factory]:https://www.timmitchell.net/post/2020/07/16/comparing-ssis-and-azure-data-factory/ +[sp_Blitz for All Servers]:https://garrybargsley.com/2020/07/14/sp_blitz-for-all-servers/ +[Where is the SQL Server Community Networking Online?]:https://www.brentozar.com/archive/2020/07/where-is-the-sql-server-community-networking-online/ +[Make the most out of your Azure Disks using Storage Pools]:https://blog.coeo.com/make-the-most-out-of-your-azure-disks-using-storage-pools +[SQL Server High Availability Solutions on Azure VMs]:https://www.brentozar.com/archive/2020/07/where-is-the-sql-server-community-networking-online/ +[How to Get Started with SQL Server Management Studio]:https://www.brentozar.com/archive/2020/07/how-to-get-started-with-sql-server-management-studio/ +[How should I store currency values in SQL Server?]:https://bornsql.ca/blog/how-should-i-store-currency-values-in-sql-server/ +[Read committed isolation level doesn’t guarantee much…]:https://www.sqlskills.com/blogs/paul/read-committed-doesnt-guarantee-much/ +[Prevent Unexpected Failovers When Patching AGs]:https://joshthecoder.com/2020/05/21/prevent-unexpected-failovers-when-patching-ags.html +[Updating Statistics Causes Parameter Sniffing]:https://www.brentozar.com/archive/2020/06/updating-statistics-causes-parameter-sniffing/ +[The Ascending Key Problem in Fact Tables– Part one: Pain!]:https://kejserbi.wordpress.com/2011/07/01/the-ascending-key-problem-in-fact-tables-part-one-pain/ +[The Ascending Key Problem In Fact Tables –Part Two: Stat Job!]:http://blog.kejser.org/the-ascending-column-problem-in-fact-tables-part-two-stat-job/ +[Are Statistics Being Used for inserted and deleted tables and table variables?]:https://community.idera.com/database-tools/blog/b/community_blog/posts/are-statistics-being-used +[Tackling Imperial and US Customary Measurements in Databases]:https://www.red-gate.com/simple-talk/blogs/tackling-imperial-and-us-customary-measurements-in-databases/ +[In-Memory OLTP Best Practices – Part 1]:https://devblogs.microsoft.com/premier-developer/in-memory-oltp-best-practices-part-1/ +[In-Memory OLTP Best Practices – Part 2]:https://devblogs.microsoft.com/premier-developer/in-memory-oltp-best-practices-part-2/ +[Things I Wished More Developers Knew About Databases]:https://medium.com/@rakyll/things-i-wished-more-developers-knew-about-databases-2d0178464f78 +[Online migrations at scale]:https://stripe.com/blog/online-migrations +[The Dirty (Baker’s) Dozen of SQL Server Technical Debt]:https://blog.coeo.com/the-dirty-bakers-dozen-of-sql-server-technical-debt +[15 SQL Server Performance Counters to Monitor In 2020]:https://www.sentryone.com/blog/allenwhite/sql-server-performance-counters-to-monitor +[Pulling Group By Above a Join]:https://www.sql.kiwi/2020/05/pulling-group-by-above-join.html +[SQLskills SQL101: Running out of ints and bigints]:https://www.sqlskills.com/blogs/paul/sqlskills-sql101-running-out-of-ints-and-bigints/ +[Top Asked Availability Group Questions… and Maybe Some Helpful Tidbits as Answers]:https://www.seangallardy.com/top-asked-availability-group-questions-and-maybe-some-helpful-tidbits-as-answers/ +[Encrypting SQL Server Database Backups]:https://sqlundercover.com/2018/04/04/encrypting-sql-server-database-backups/ +[Using Track Causality to Understand Query Execution]:https://sqlperformance.com/2019/01/extended-events/using-track-causality-to-understand-query-execution +[Understanding SQL Server Backup Types]:https://www.sqlshack.com/understanding-sql-server-backup-types/ +[Scripting the Description of Database Tables Using Extended Properties]:https://www.red-gate.com/simple-talk/sql/database-delivery/scripting-description-database-tables-using-extended-properties/ +[The Table Variable in SQL Server]:https://www.sqlshack.com/the-table-variable-in-sql-server/ +[Multiple Plans for an "Identical" Query]:https://sqlperformance.com/2014/11/t-sql-queries/multiple-plans-identical-query +[Another argument for stored procedures versus ORM versus Add Hoc Queries]:https://sqlperformance.com/2013/05/t-sql-queries/another-argument-for-stored-procedures +[Bad habits to kick : avoiding the schema prefix]:https://sqlblog.org/2019/09/12/bad-habits-to-kick-avoiding-the-schema-prefix +[How not to call Hekaton natively-compiled stored procedures]:https://sqlperformance.com/2015/06/t-sql-queries/how-not-to-call-hekaton-procedures +[A One-Slide Summary of the Differences Between TDE and Always Encrypted]:https://www.brentozar.com/archive/2020/07/a-one-slide-summary-of-the-differences-between-tde-and-always-encrypted/ +[Remember “Nothing Stops a Hekaton Transaction?” Yeah, About That.]:https://www.brentozar.com/archive/2020/07/remember-nothing-stops-a-hekaton-transaction-yeah-about-that/ +[Finding & Downloading Required SQL Server Updates]:https://flxsql.com/downloading-latest-sql-server-updates/ +[SQLskills SQL101: Why do some wait types need to be ignored?]:https://www.sqlskills.com/blogs/paul/sqlskills-sql101-why-do-some-wait-types-need-to-be-ignored/ +[What is the SOS_WORK_DISPATCHER Wait Type? (Or how to work with Call Stacks in SQL Server)]:https://orderbyselectnull.com/2018/09/27/what-is-the-sos_work_dispatcher-wait-type/ +[SQL Server 2019 Aggregate Splitting]:https://www.sql.kiwi/2020/08/sql-server-2019-aggregate-splitting.html +[Security Best Practice: dny and revoke permissions granted to All Users by default - HIGHLY IMPORTANT!]:https://ariely.info/Blog/tabid/83/EntryId/241/Security-Best-Practice-dny-and-revoke-permissions-granted-to-All-Users-by-default-HIGHLY-IMPORTANT.aspx +[The Trillion Row Operator]:https://www.erikdarlingdata.com/2020/08/the-trillion-row-operator/ +[Temporal Tables and Table Partitioning: Not If You Like Switching Partitions]:https://www.erikdarlingdata.com/sql-server/temporal-tables-and-table-partitioning-not-if-you-like-switching-partitions/ +[Long Running Query on Read-Only Replica that takes moments on the Primary]:https://dba.stackexchange.com/questions/237671/long-running-query-on-read-only-replica-that-takes-moments-on-the-primary/ +[Date Tables are Great for Users, but Not So Great for Performance]:https://www.brentozar.com/archive/2020/08/date-tables-are-great-for-users-but-not-so-great-for-performance/ +[Should I install SSMS on a server running SQL Server?]:https://am2.co/2020/04/should-i-install-ssms-on-a-server-running-sql-server/ +[Finding a table name from a page ID]:https://www.sqlskills.com/blogs/paul/finding-table-name-page-id/ +[Finding Distinct Values Quickly]:https://sqlperformance.com/2020/03/sql-performance/finding-distinct-values-quickly +[Can You Fail To Spill To tempdb?]:https://www.joshthecoder.com/2019/07/17/can-you-fail-to-spill-to-tempdb.html +[Migrating SQL workloads to Microsoft Azure: Databases Trip to Azure SQL Database]:https://www.sqlshack.com/migrate-sql-workloads-to-microsoft-azure-databases-trip-to-azure-sql-database/ +[How It Works: Bob Dorr's SQL Server I/O Presentation]:https://techcommunity.microsoft.com/t5/sql-server-support/how-it-works-bob-dorr-s-sql-server-i-o-presentation/ba-p/316031 +[Who does SQL Server run xp_cmdshell command as?]:https://stevestedman.com/2020/04/who-does-sql-server-run-xp_cmdshell-command-as/ +[Transaction Modes in SQL Server]:https://36chambers.wordpress.com/2020/08/10/transaction-modes-in-sql-server/ +[Working Effectively with Legacy SQL]:https://www.catallaxyservices.com/presentations/legacy-sql/ +[A SQL Server DBA myth a day: (26/30) nested transactions are real]:https://www.sqlskills.com/blogs/paul/a-sql-server-dba-myth-a-day-2630-nested-transactions-are-real/ +[dbatools multithreading commands with PoshRSJob module]:https://dbatools.io/multithread/ +[SQL Server Debugging with WinDbg – an Introduction]:https://www.sqlpassion.at/archive/2014/05/05/sql-server-debugging-with-windbg-an-introduction/ +[Looking deeper into SQL Server using Minidumps]:https://docs.microsoft.com/en-gb/archive/blogs/sqlcat/looking-deeper-into-sql-server-using-minidumps +[Anatomy of a spool operators in SQL Server execution plans]:https://sqlserverfast.com/articles/anatomy-of-a-spool/ +[CAST v/s CONVERT – Is there a difference as far as SQL Server is concerned? Which is better?]:https://nakulvachhrajani.com/2011/07/18/cast-vs-convert-is-there-a-difference-as-far-as-sql-server-is-concerned-which-is-better/ +[#BackToBasics: CAST vs. CONVERT]:https://www.sentryone.com/blog/aaronbertrand/backtobasics-cast-vs-convert +[Productivity Hacks: Migrate in Minutes to the Most Current Version of SQL Server]:https://www.rubrik.com/blog/migrate-quickly-current-version-sql-server/ +[Database alias in Microsoft SQL Server]:http://www.baud.cz/blog/database-alias-in-microsoft-sql-server +[The Curious Case of… the 8060-byte row size limit]:https://www.sqlskills.com/blogs/paul/the-curious-case-of-the-8060-byte-row-size-limit/ +[.NET TransactionScope Considered Annoying - Default Isolation Level is Serializable]:https://joshthecoder.com/2020/07/27/transactionscope-considered-annoying.html +[Why You’re Tuning Stored Procedures Wrong (the Problem with Local Variables)]:https://www.brentozar.com/archive/2014/06/tuning-stored-procedures-local-variables-problems/ +[Yet Another Post About Local Variables]:https://www.erikdarlingdata.com/sql-server/yet-another-post-about-local-variables/ +[Cleaning up Backups from Azure Blob Storage]:http://www.nikoport.com/2020/03/30/cleaning-up-backups-from-azure-blob-storage/ +[Temporary Table Caching Explained]:https://www.sql.kiwi/2012/08/temporary-object-caching-explained.html +[SQL Server Temporary Object Caching]:https://sqlperformance.com/2017/05/sql-performance/sql-server-temporary-object-caching +[3 Ways to Run DBCC CHECKDB Faster]:https://www.brentozar.com/archive/2020/08/3-ways-to-run-dbcc-checkdb-faster/ +[Back Up SQL Server 43%-67% Faster by Writing to Multiple Files]:https://www.brentozar.com/archive/2020/08/back-up-sql-server-43-67-faster-by-writing-to-multiple-files/ +[Bad Habits to Kick : Using SELECT * / omitting the column list]:https://sqlblog.org/2009/10/10/bad-habits-to-kick-using-select-omitting-the-column-list +[All The Problems With Select *]:https://www.erikdarlingdata.com/sql-server/all-the-problems-with-select/ +[When Select * Doesn’t Matter]:https://www.erikdarlingdata.com/sql-server/when-select-doesnt-matter/ +[HT Waits – Explained and Animated]:https://forrestmcdaniel.com/2020/08/12/ht-waits-explained-and-animated/ +[SQL Server 100% Online Deployments]:https://michaeljswart.com/2018/01/100-online-deployments/ +[The Curious Case of… setting up a server for DBCC CHECKDB]:https://www.sqlskills.com/blogs/paul/the-curious-case-of-setting-up-a-server-for-dbcc-checkdb/ +[When should a primary key be declared non-clustered?]:https://dba.stackexchange.com/q/7741/107045 +[Guid vs INT - Which is better as a primary key?]:https://dba.stackexchange.com/q/264/107045 +[Control SQL Jobs based on HADR Role – Taking it to the Next Level]:https://eitanblumin.com/2020/05/26/sql-jobs-based-on-hadr-role-next-level/ +[SQL Friday #16: Eitan Blumin on “How to HADR Your SQL Jobs”]:https://sqlfriday.net/past-sql-friday-sessions/sql-friday-16-eitan-blumin-on-how-to-hadr-your-sql-jobs/ +[Choosing the Correct Azure VM Size for Your Workload]:https://www.sentryone.com/blog/choosing-the-correct-azure-vm-size-for-your-workload +[Table Partitioning in SQL Server – The Basics]:https://www.cathrinewilhelmsen.net/2015/04/12/table-partitioning-in-sql-server/ +[Table Partitioning in SQL Server – Partition Switching]:https://www.cathrinewilhelmsen.net/2015/04/19/table-partitioning-in-sql-server-partition-switching/ +[TempDB in SQL Server]:https://www.sentryone.com/tempdb-in-sql-server +[SQL Server’s Cost Threshold for Parallelism]:https://www.brentozar.com/archive/2014/11/sql-server-cost-threshold-for-parallelism/ +[How many CPUs is my parallel query using in SQL Server?]:https://www.brentozar.com/archive/2014/11/many-cpus-parallel-query-using-sql-server/ +[Protecting your data against unauthorised reads on SQL Server]:https://monin-it.be/2020/06/23/protectingyourdata/ +[SET IMPLICIT_TRANSACTIONS ON Is One Hell of a Bad Idea]:https://www.brentozar.com/archive/2018/02/set-implicit_transactions-one-hell-bad-idea/ +[Tempdb: The Ghost Of Version Store]:https://kohera.be/blog/sql-server/tempdb-the-ghost-of-version-store/ +[Row Versioning Concurrency in SQL Server]:https://www.red-gate.com/simple-talk/sql/t-sql-programming/row-versioning-concurrency-in-sql-server/ +[When Tempdb Becomes Permanentdb (In-memory tempdb metadata and Resource governor problems)]:https://kohera.be/blog/sql-server/when-tempdb-becomes-permanentdb/ +[The Best Medium-Hard Data Analyst SQL Interview Questions]:https://quip.com/2gwZArKuWk7W +[Starting SQL: Why Not Make Everything Dynamic?]:https://www.erikdarlingdata.com/starting-sql/starting-sql-why-not-make-everything-dynamic/ +[dbatools multithreading commands]:https://dbatools.io/multithread/ +[Preventing Brute Force Attacks in SQL Server]:https://blog.coeo.com/preventing-brute-force-attacks-in-sql-server +[Asynchronous T-SQL Execution Without Service Broker]:https://www.codeproject.com/Articles/29356/Asynchronous-T-SQL-Execution-Without-Service-Broke +[Using hash values in SSIS to determine when to insert or update rows]:https://www.mssqltips.com/sqlservertip/3170/using-hash-values-in-ssis-to-determine-when-to-insert-or-update-rows/ +[Capturing Queries Can Be A Pain]:https://www.scarydba.com/2020/08/03/capturing-queries-can-be-a-pain/ +[Building full-text indexes using the Sphinx search engine]:https://www.sqlshack.com/building-full-text-indexes-using-the-sphinx-search-engine/ +[Starting SQL: Measuring A Query]:https://www.erikdarlingdata.com/starting-sql/starting-sql-measuring-a-query/ +[When to use SET vs SELECT when assigning values to variables in SQL Server]:https://www.mssqltips.com/sqlservertip/1888/when-to-use-set-vs-select-when-assigning-values-to-variables-in-sql-server/ +[What is the difference between SET and SELECT when assigning values to variables, in T-SQL?]:http://vyaskn.tripod.com/differences_between_set_and_select.htm +[CHECKDB From Every Angle: How long will CHECKDB take to run?]:https://www.sqlskills.com/blogs/paul/checkdb-from-every-angle-how-long-will-checkdb-take-to-run/ +[CHECKDB From Every Angle: Consistency Checking Options for a VLDB]:https://www.sqlskills.com/blogs/paul/checkdb-from-every-angle-consistency-checking-options-for-a-vldb/ +[Minimizing the impact of DBCC CHECKDB : DOs and DON'Ts]:https://sqlperformance.com/2012/11/io-subsystem/minimize-impact-of-checkdb +[A faster CHECKDB – Part II]:https://web.archive.org/web/20150315173540/http://blogs.msdn.com/b/psssql/archive/2012/02/23/a-faster-checkdb-part-ii.aspx +[A faster CHECKDB – Part III]:https://web.archive.org/web/20150206201933/http://blogs.msdn.com/b/psssql/archive/2014/11/10/a-faster-checkdb-part-iii.aspx +[A faster CHECKDB – Part IV (SQL CLR UDTs)]:https://web.archive.org/web/20150205043737/http://blogs.msdn.com/b/psssql/archive/2015/01/26/a-faster-checkdb-part-iv-sql-clr-udts.aspx +[Minimize performance impact of SQL Server DBCC CHECKDB]:https://www.mssqltips.com/sqlservertip/2399/minimize-performance-impact-of-sql-server-dbcc-checkdb/ +[Starting SQL: A Little More Fun With Logging Dynamic SQL]:https://www.erikdarlingdata.com/starting-sql/starting-sql-a-little-more-fun-with-logging-dynamic-sql/ +[Allocation Order Scans]:https://sqlperformance.com/2015/01/t-sql-queries/allocation-order-scans +[Parameter Sniffing in SQL Server 2019: Air_Quote_Actual Plans]:https://www.brentozar.com/archive/2019/04/parameter-sniffing-in-sql-server-2019-air_quote_actual-plans/ +[Guide For Set Up Of Telegraf For Monitoring Sql Server Xplat]:https://tracyboggiano.com/archive/2018/02/setup-of-telegraf/ +[Azure Table Storage Tips for the RDBMS Developer]:https://www.sentryone.com/blog/azure-table-storage-tips-for-the-rdbms-developer +[sql_handle and the SQL Server batch text hash]:https://www.sql.kiwi/2020/10/sqlhandle-and-sql-server-batch-text-hash.html +[Navigating DBCC CHECKDB for VLDB]:https://sqlblog.org/2020/11/05/navigating-dbcc-checkdb-for-vldb +[Hidden Formatting Troubles with STR() (SQL Spackle)]:https://www.sqlservercentral.com/articles/hidden-formatting-troubles-with-str-sql-spackle +[The What, Why, When, and How of Incremental Loads]:https://www.timmitchell.net/post/2020/07/23/incremental-loads/ +[How Do I Know If My Query Is Good Enough for Production?]:https://www.brentozar.com/archive/2020/08/how-do-i-know-if-my-query-is-good-enough-for-production/ +[How to Find Out Whose Queries are Using The Most CPU]:https://www.brentozar.com/archive/2020/08/how-to-find-out-whose-queries-are-using-the-most-cpu/ +[Limitations of SQL Server Native Backup and Restore in Amazon RDS]:https://www.mssqltips.com/sqlservertip/5042/limitations-of-sql-server-native-backup-and-restore-in-amazon-rds/ +[SQL Server Native Backup and Restore in Amazon RDS]:https://www.mssqltips.com/sqlservertip/5041/sql-server-native-backup-and-restore-in-amazon-rds/ +[What Is the SQL Server CEIP Service (telemetry)?]:https://www.brentozar.com/archive/2020/10/what-is-the-sql-server-ceip-service/ +[Maximum Simultaneous User Connections]:http://www.sqlnuggets.com/blog/disable-telemetry-on-multiple-sql-servers-with-powershell/ +[Find Database Connection Leaks in Your Application]:https://sqlperformance.com/2017/07/sql-performance/find-database-connection-leaks +[How to Troubleshoot THREADPOOL Waits and Deadlocked Schedulers]:https://eitanblumin.com/2020/10/05/how-to-troubleshoot-threadpool-waits-and-deadlocked-schedulers/ +[Prevent Lock Escalation On Indexed Views]:https://kohera.be/blog/sql-server/prevent-lock-escalation-on-indexed-views/ +[Concatenating Strings in SQL Server]:https://www.madeiradata.com/post/concatenating-strings +[Why Full Text’s CONTAINS Queries Are So Slow]:https://www.brentozar.com/archive/2020/11/why-full-texts-contains-queries-are-so-slow/ +[Migrating SSIS to Azure – an Overview]:https://sqlkover.com/migrating-ssis-to-azure-an-overview/ +[(Video) How to Troubleshoot Someone Else’s Temp Table Contents]:https://www.brentozar.com/archive/2020/11/video-how-to-troubleshoot-someone-elses-temp-table-contents/ +[A Parameterization Puzzle With TOP: Part 1]:https://www.erikdarlingdata.com/execution-plans/a-parameterization-puzzle-with-top-part-1/ +[A Parameterization Puzzle With TOP: Part 2]:https://www.erikdarlingdata.com/execution-plans/a-parameterization-puzzle-with-top-part-2/ +[T-SQL: Get The Text Between Two Delimiters]:https://www.erikdarlingdata.com/sql-server/t-sql-get-the-text-between-two-delimiters/ +[Explore dynamic management views for monitoring SQL Server Always On Availability Groups]:https://www.sqlshack.com/explore-dynamic-management-views-for-monitoring-sql-server-always-on-availability-groups/ +[Deploy SQLWATCH to SQL Server using GitHub Actions]:https://www.kevinrchant.com/2020/11/17/deploy-sqlwatch-to-sql-server-using-github-actions/ +[SQL Server table hints – WITH (NOLOCK) best practices]:https://www.sqlshack.com/understanding-impact-clr-strict-security-configuration-setting-sql-server-2017/ +[Memory-Optimized TempDB Metadata in SQL Server 2019]:https://www.mssqltips.com/sqlservertip/6230/memoryoptimized-tempdb-metadata-in-sql-server-2019/ +[SQLskills SQL101: Should you kill that long-running transaction?]:https://www.sqlskills.com/blogs/paul/sqlskills-sql101-should-you-kill-that-long-running-transaction/ +[A quick and dirty scan of a list of instances using a dynamic linked server]:https://sqlstudies.com/2020/11/12/a-quick-and-dirty-scan-of-a-list-of-instances-using-a-dynamic-linked-server/ +[sp_whoisactive: Analyzing Tempdb Contention]:http://whoisactive.com/docs/21_tempdb/ +[How to Choose Between RCSI and Snapshot Isolation Levels]:https://littlekendra.com/2016/02/18/how-to-choose-rcsi-snapshot-isolation-levels/ +[Explore the SQL query table hint READPAST]:https://www.sqlshack.com/explore-the-sql-query-table-hint-readpast/ +[How Bad Statistics Cause Bad SQL Server Query Performance]:https://www.brentozar.com/archive/2020/11/how-bad-statistics-cause-bad-sql-server-query-performance/ +[How Scalar User-Defined Functions Slow Down Queries]:https://www.brentozar.com/archive/2020/11/how-scalar-user-defined-functions-slow-down-queries/ +[Could verifying your backups be costing you money?]:https://blog.coeo.com/verifying-backups-cost +[Extended Events: System_health And A Long Running Query]:https://www.scarydba.com/2020/03/09/extended-events-system_health-and-a-long-running-query/ +[Altering an indexed view in SQL Server drops all indexes]:https://littlekendra.com/2020/03/02/altering-an-indexed-view-in-sql-server-drops-all-indexes/ +[Deprecated and discontinued features in SQL Server]:https://bornsql.ca/blog/deprecated-and-discontinued-features-in-sql-server/ +[Query Store, Plan Forcing, And Drop/create]:https://www.scarydba.com/2020/03/02/query-store-plan-forcing-and-drop-create/ +[Uncommon SQL in SQL Server]:https://nocolumnname.blog/2020/11/20/uncommon-sql/ +[Configure SQL Server Replication between AWS RDS SQL Server and On-premises SQL Server]:https://www.sqlshack.com/configure-sql-server-replication-between-aws-rds-sql-server-and-on-premises-sql-server/ +[Import data into Azure SQL database from AWS Redshift]:https://www.sqlshack.com/import-data-into-azure-sql-database-from-aws-redshift/ +[When You’re Troubleshooting Blocking, Look at Query #2, Too.]:https://www.brentozar.com/archive/2020/11/when-youre-troubleshooting-blocking-look-at-query-2-too/ +[Finding the One Query to Tune in a Multi-Query Batch]:https://www.brentozar.com/archive/2020/11/finding-the-one-query-to-tune-in-a-multi-query-batch/ +[Recursion in SQL Explained Visually]:https://medium.com/swlh/recursion-in-sql-explained-graphically-679f6a0f143b +[Viva la Famiglia! Stored procedure for created recursive family tree]:https://bradsruminations.blogspot.com/2009/10/viva-la-famiglia.html +[How to Set & Get the Next ID Without Serializable Isolation]:https://www.brentozar.com/archive/2020/11/how-to-set-get-the-next-id-without-serializable-isolation/ +[Discovering Three or Four Part Names in SQL Server Database Code]:https://www.red-gate.com/simple-talk/blogs/discovering-three-or-four-part-names-in-sql-server-database-code/ +[Troubleshooting RESOURCE_SEMAPHORE_QUERY_COMPILE Helper Queries]:https://www.erikdarlingdata.com/sql-server/troubleshooting-resource_semaphore_query_compile-helper-queries/ +[When Do I Need to Use DESC in Indexes?]:https://www.brentozar.com/archive/2020/11/when-do-i-need-to-use-desc-in-indexes/ +[Export Power BI Desktop data to SQL Server]:https://ruiromanoblog.wordpress.com/2016/04/21/use-power-bi-desktop-as-an-etl-tool/ +[Exploring errors to reveal unauthorized information]:https://www.red-gate.com/simple-talk/sql/database-administration/exploring-errors-to-reveal-unauthorized-information/ +[How to run your CTE just once, and re-use the output]:https://sqlsunday.com/2020/12/01/run-your-cte-just-once-and-reuse-output/ +[Documenting SSIS Packages using Sequence Diagrams]:https://www.sqlshack.com/documenting-ssis-packages-using-sequence-diagrams-2/ +[Performance testing with DBCC DROPCLEANBUFFERS]:https://www.dbdelta.com/performance-testing-with-dbcc-dropcleanbuffers/ +[Optimizing memory settings in Analysis Services]:https://www.sqlbi.com/articles/optimizing-memory-settings-in-analysis-services/ +[VMware and SQL Server Best Practices]:https://straightpathsql.com/archives/2020/12/vmware-and-sql-server-best-practices/ +[Autoparameterized Trivial Queries May Not Get Partition Elimination]:https://www.brentozar.com/archive/2020/12/autoparameterized-trivial-queries-may-not-get-partition-elimination/ +[Trigram Wildcard String Search in SQL Server]:https://sqlperformance.com/2017/09/sql-performance/sql-server-trigram-wildcard-search +[Which Locks Count Toward Lock Escalation?]:https://littlekendra.com/2017/04/03/which-locks-count-toward-lock-escalation/ +[The challenge is on! Community call for creating the fastest number series generator]:https://sqlperformance.com/2020/12/t-sql-queries/number-series-challenge +[SQL Injection Prevention Cheat Sheet]:https://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html +[A cheat sheet for isolation levels in SQL Server]:https://blog.coeo.com/a-cheat-sheet-for-isolation-levels-in-sql-server +[Don't Fear the Trace]:https://www.sentryone.com/blog/dont-fear-the-trace +[Which sp_configure Options Clear the Plan Cache?]:https://www.brentozar.com/archive/2017/09/sp_configure-options-clear-plan-cache/ +[The danger of HADR_SYNC_COMMIT wait and synchronous replication in AlwaysOn Availability Groups]:https://aboutsqlserver.com/2019/06/09/hadr-sync-commit/ +[Faster SQL Pagination with Keysets, Continued]:https://blog.jooq.org/2013/11/18/faster-sql-pagination-with-keysets-continued/ +[We need tool support for keyset pagination]:https://use-the-index-luke.com/no-offset +[Index-Only Scan: Avoiding Table Access]:https://use-the-index-luke.com/sql/clustering/index-only-scan-covering-index +[The two top performance problems caused by ORM tool]:https://use-the-index-luke.com/blog/2013-04/the-two-top-performance-problems-caused-by-ORM-tools +[Nested loops join and n1 problem in ORM]:https://use-the-index-luke.com/sql/join/nested-loops-join-n1-problem +[Hash join partial objects]:https://use-the-index-luke.com/sql/join/hash-join-partial-objects +[Myth: Select * (asterisk) is bad]:https://use-the-index-luke.com/blog/2013-08/its-not-about-the-star-stupid +[Indexing LIKE Filters]:https://use-the-index-luke.com/sql/where-clause/searching-for-ranges/like-performance-tuning +[Date and time conditions causing SQL performance problems]:https://use-the-index-luke.com/sql/where-clause/obfuscation/dates +[Dates and Times in SQL Server: more functions you should never use]:https://bornsql.ca/blog/dates-and-times-in-sql-server-more-functions-you-should-never-use/ +[Dates and Times in SQL Server: T-SQL functions to get the current date and time]:https://bornsql.ca/blog/dates-times-sql-server-t-sql-functions-get-current-date-time/ +[Super Scaling Queues Using the LMax Disruptor Pattern And The In-Memory OLTP Engine]:https://chrisadkin.io/2016/01/18/super-scaling-queues-using-the-lmax-disruptor-pattern-and-the-in-memory-oltp-engine/ +[Early History of SQL]:https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=6359709 +[Is it a bad practice to always create a transaction?]:https://dba.stackexchange.com/a/43256 +[Incomplete checkpoints and recovery]:https://www.sqlskills.com/blogs/paul/incomplete-checkpoints-and-recovery/ +[4 SQL Injection Techniques For Stealing Data]:https://bertwagner.com/posts/4-sql-injection-techniques-for-stealing-data/ +[Towards Safer Dynamic SQL]:https://www.erikdarlingdata.com/sql-server/towards-safer-dynamic-sql/ +[Setting the timezone to anything other than UTC]:http://yellerapp.com/posts/2015-01-12-the-worst-server-setup-you-can-make.html +[Advanced Service Broker Sample: Multi-Threading]:https://eitanblumin.com/2018/10/31/advanced-service-broker-sample-multi-threading/ +[Copy a SQL Server database with just the objects and no data]:https://www.mssqltips.com/sqlservertip/4664/copy-a-sql-server-database-with-just-the-objects-and-no-data/ +[QOMPLX Knowledge: Kerberoasting Attacks Explained]:https://www.qomplx.com/qomplx-knowledge-kerberoasting-attacks-explained/ +[How to create a SQL dependency diagram in SQL Server]:https://www.sqlshack.com/how-to-create-a-sql-dependency-diagram-in-sql-server/ +[Query Memory Grants and Resource Semaphores in SQL Server]:https://www.sqlpassion.at/archive/2018/10/16/query-memory-grants-and-resource-semaphores-in-sql-server/ +[Using a Table of Numbers (or a Table of Dates, Months etc)]:https://www.sommarskog.se/Short%20Stories/table-of-numbers.html +[SQL Server MDF and NDF files]:https://www.sqlrecoverysoftware.net/sql-server-mdf-file/recover-mdf-ndf.html +[The SQL Standard ANSI ISO is Public!]:https://modern-sql.com/standard +[SQL Server Full Backup]:https://sqlbak.com/academy/full-backup +[Import data from PDF files using R Scripts SQL Server]:https://www.sqlshack.com/import-data-from-pdf-files-using-r-scripts-sql-server/ +[Adding Additional Data Files To The TempDB Database In SQL Server]:https://jackworthen.com/2017/08/24/adding-additional-data-files-to-the-tempdb-database-in-sql-server/ +[SQL Server Isolation Levels: A Series]:https://sqlperformance.com/2014/07/t-sql-queries/isolation-levels +[SQL Server Isolation Levels: The ACID Properties of Statements & Transactions]:https://sqlperformance.com/2014/02/t-sql-queries/confusion-caused-by-trusting-acid +[SQL Server Isolation Levels: The Serializable Isolation Level]:https://sqlperformance.com/2014/04/t-sql-queries/the-serializable-isolation-level +[SQL Server Isolation Levels: The Repeatable Read Isolation Level]:https://sqlperformance.com/2014/04/t-sql-queries/the-repeatable-read-isolation-level +[SQL Server Isolation Levels: The Read Committed Isolation Level]:https://sqlperformance.com/2014/04/t-sql-queries/the-read-committed-isolation-level +[SQL Server Isolation Levels: Read Committed Snapshot Isolation]:https://sqlperformance.com/2014/05/t-sql-queries/read-committed-snapshot-isolation +[SQL Server Isolation Levels: Data Modifications under Read Committed Snapshot Isolation]:https://sqlperformance.com/2014/05/t-sql-queries/data-modifications-under-rcsi +[SQL Server Isolation Levels: The SNAPSHOT Isolation Level]:https://sqlperformance.com/2014/06/sql-performance/the-snapshot-isolation-level +[SQL Server Isolation Levels: The Read Uncommitted Isolation Level]:https://sqlperformance.com/2015/04/t-sql-queries/the-read-uncommitted-isolation-level +[The OUTPUT Clause for the MERGE Statements]:https://www.sqlservercentral.com/articles/the-output-clause-for-the-merge-statements +[SQLskills SQL101: Query plans based on what’s in memory]:https://www.sqlskills.com/blogs/paul/sqlskills-sql101-query-plans-based-on-whats-in-memory/ +[Performance: String Concatenation in SQL Server]:https://stevestedman.com/2021/01/performance-string-concatenation-in-sql-server/ +[Performance: Faster way to concatenate longer string]:https://stevestedman.com/2021/01/performance-faster-way-to-concatenate-longer-string/ +[Identifying Cost-Saving Opportunities in Azure DevOps]:https://www.sentryone.com/blog/cost-savings-in-azuredevops +[One wide index or multiple narrow indexes?]:https://sqlinthewild.co.za/index.php/2010/09/14/one-wide-index-or-multiple-narrow-indexes/ +[The Hidden Danger of Readable Secondaries in SQL Server AlwaysOn Availability Groups]:https://www.apress.com/de/blog/all-blog-posts/readable-secondaries-in-sql-server/16064064 +[Poor Man’s Resource Governor: Database-Scoped Configurations]:https://www.brentozar.com/archive/2020/10/poor-mans-resource-governor-database-scoped-configurations/ +[SQL Server Suddenly Frozen? You Might Be Snapshotting Too Many Databases.]:https://www.brentozar.com/archive/2020/09/sql-server-suddenly-frozen-you-might-be-snapshotting-too-many-databases/ +[How to Batch Updates A Few Thousand Rows at a Time]:https://www.brentozar.com/archive/2020/12/how-to-batch-updates-a-few-thousand-rows-at-a-time/ +[USING AMAZON FSX FOR SQL SERVER FAILOVER CLUSTER INSTANCES – WHAT YOU NEED TO KNOW!]:https://clusteringformeremortals.com/2021/01/08/using-amazon-fsx-for-sql-server-failover-cluster-instances-what-you-need-to-know/ +[Sometimes you CAN upsize a column in-place]:https://sqlperformance.com/2020/08/sql-indexes/upsize-column-in-place +[Which Microsoft Certification Should You Get?]:https://www.brentozar.com/archive/2021/01/which-microsoft-certification-should-you-get/ +[SQL Server RAISERROR Cheatsheet]:https://chadbaldwin.net/2021/01/15/raiserror-cheatsheet.html +[Want to Avoid Deployment Downtime? Replication Probably Isn’t the Answer.]:https://www.brentozar.com/archive/2021/01/want-to-avoid-deployment-downtime-replication-probably-isnt-the-answer/ +[“But Surely NOLOCK Is Okay If No One’s Changing Data, Right?”]:https://www.brentozar.com/archive/2021/01/but-surely-nolock-is-okay-if-no-ones-changing-data-right/ +[Why Multiple Plans for One Query Are Bad]:https://www.brentozar.com/archive/2018/03/why-multiple-plans-for-one-query-are-bad/ +[Partitioned Tables Cause Longer Plan Compilation Times.]:https://www.brentozar.com/archive/2021/02/partitioned-tables-cause-longer-plan-compilation-times/ +[Query Hints You Can Use to Avoid Blocking]:https://www.brentozar.com/archive/2021/01/query-hints-you-can-use-to-avoid-blocking/ +[Changing Statistics Cause Longer Compilation Times]:https://www.brentozar.com/archive/2021/02/changing-statistics-cause-longer-compilation-times/ +[Understanding Execution Plan Operator Timings]:https://sqlperformance.com/2021/03/sql-performance/execution-plan-timings +[What Does a Database Administrator Actually Do?]:https://www.brentozar.com/archive/2021/03/what-does-a-database-administrator-actually-do/ +[How Useful Is Column Store In Standard Edition?]:https://www.erikdarlingdata.com/sql-server/how-useful-is-column-store-in-standard-edition/ +[Task Manager’s CPU numbers are all but meaningless]:https://aaron-margosis.medium.com/task-managers-cpu-numbers-are-all-but-meaningless-2d165b421e43 +[Global temporary tables are almost never the answer in SQL Server]:https://blog.greglow.com/2021/02/04/sql-global-temporary-tables-are-almost-never-the-answer-in-sql-server/ +[Never, Ever, Ever Start T-SQL Comments with Two Dashes]:https://www.brentozar.com/archive/2021/04/never-ever-ever-start-t-sql-comments-with-two-dashes/ +[Why All My Servers Have an 8GB Empty File]:https://brianschrader.com/archive/why-all-my-servers-have-an-8gb-empty-file/ +[Incorrect Results with Parallel Eager Spools and Batch Mode]:https://www.sql.kiwi/2021/03/spools-batch-mode-hp.html +[Deprecated features to take out of your toolbox – Part 1]:https://sqlperformance.com/2021/02/sql-performance/deprecated-features-1 +[Deprecated features to take out of your toolbox – Part 2]:https://sqlperformance.com/2021/03/sql-performance/deprecated-features-2 +[Deprecated features to take out of your toolbox – Part 3]:https://sqlperformance.com/2021/07/sql-performance/deprecated-features-3 +[Troubleshooting Security Cache Issues: USERSTORE_TOKENPERM And TokenAndPermUserStore]:https://www.erikdarlingdata.com/sql-server/troubleshooting-security-cache-issues-userstore_tokenperm-and-tokenandpermuserstore/ +[Execution Plans Don’t Have the Yellow Bang They Really Need.]:https://www.brentozar.com/archive/2021/04/execution-plans-dont-have-the-yellow-bang-they-really-need/ +[The Curious Case of… the un-killable thread]:https://www.sqlskills.com/blogs/paul/the-curious-case-of-the-un-killable-thread/ +[olved steries #1 – SQL FCI Failovers]:https://www.seangallardy.com/olved-steries-1-sql-fci-failovers/ +[Possible configuration error: 1000000 IO requests allocated]:https://www.seangallardy.com/possible-configuration-error-1000000-io-requests-allocated/ +[Availability Group Long Failover Times]:https://www.seangallardy.com/availability-group-long-failover-times/ +[Testing Backups and Offloading CheckDB]:https://www.tarynpivots.com/post/2021/testing-backups-offload-dbcc-checkdb/ +[Fighting with Deadlocks]:https://www.tarynpivots.com/post/2021/fighting-with-deadlocks/ +[Syncing Logins Between Availability Group Replicas]:https://www.tarynpivots.com/post/2020/syncing-logins-between-availablity-group-replicas/ +[SQL JOINs and UNIONs]:https://levelup.gitconnected.com/sql-joins-2cc89babb6f9 +[Some opinionated thoughts on SQL databases]:https://blog.nelhage.com/post/some-opinionated-sql-takes/ +[How MERGE on two different rows can still deadlock you]:https://sqlsunday.com/2021/05/04/how-merge-can-deadlock-you/ +[Auto-failover Groups for Azure – Grace Period With Data Loss Hours]:https://sqlworldwide.com/auto-failover-groups-graceperiodwithdatalosshours/ +[How Parallel Plans Start Up – Part 1]:https://sqlperformance.com/2021/03/sql-performance/parallel-plans-start-1 +[How Parallel Plans Start Up – Part 2]:https://sqlperformance.com/2021/04/sql-performance/parallel-plans-start-2 +[How Parallel Plans Start Up – Part 3]:https://sqlperformance.com/2021/04/sql-performance/parallel-plans-start-3 +[How Parallel Plans Start Up – Part 4]:https://sqlperformance.com/2021/05/sql-performance/parallel-plans-start-4 +[How Parallel Plans Start Up – Part 5]:https://sqlperformance.com/2021/05/sql-performance/parallel-plans-start-5 +[Iterators, Query Plans, and Why They Run Backwards]:https://www.sql.kiwi/2010/08/iterators-query-plans-and-why-they-run-backwards.html +[What account is xp_cmdshell using?]:https://sqlstudies.com/2021/05/25/what-account-is-xp_cmdshell-using/ +[Hammer Part 1 -What is HammerDB and why would I use it?]:https://t101wilson.wordpress.com/2021/04/17/hammer-part-1-what-is-hammerdb-and-why-would-i-use-it/ +[Hammer Part 2 -Let the Nail see the Hammer!]:https://t101wilson.wordpress.com/2021/05/26/hammer-part-2-let-the-nail-see-the-hammer/ +[Fun with DATETIME Arithmetics]:https://eitanblumin.com/2021/04/27/fun-with-datetime-arithmetics/ +[Even more fun with DATETIME arithmetics!]:https://eitanblumin.com/2021/06/17/even-more-fun-with-datetime-arithmetics/ +[I learned to love WHILE (true) and you should too]:https://eitanblumin.com/2021/02/16/i-learned-to-love-while-true-and-you-should-too/ +[Troubleshooting Long-Running SHRINK Operations]:https://eitanblumin.com/2020/04/07/troubleshooting-long-running-shrink-operations/ +[The Ultimate Compression Savings Estimation Script for an Entire Database]:https://eitanblumin.com/2020/02/18/ultimate-compression-savings-estimation-script-entire-database/ +[The Complete Guide to Temporary Tables and Table Variables - Part 1]:https://www.madeiradata.com/post/the-complete-guide-to-temporary-tables-and-table-variables-part-1 +[Store Files in a File System, Not a Relational Database.]:https://www.brentozar.com/archive/2021/07/store-files-in-a-file-system-not-a-relational-database/ +[Most (XML) and Least (SQL_VARIANT) Favorite Data Type]:https://eitanblumin.com/2021/03/09/t-sql-tuesday-136-most-and-least-favorite-data-type/ +[What should the CPU usage be of a fully-loaded CPU that has been throttled?]:https://devblogs.microsoft.com/oldnewthing/20210629-00/?p=105378 +[Fixing Queues with Watermarks]:https://forrestmcdaniel.com/2021/06/30/fixing-queues-with-watermarks/ +[How to Patch SQL Server]:https://www.brentozar.com/archive/2021/06/how-to-patch-sql-server/ +[“I’m getting index seeks. Why are my row estimates still wrong?”]:https://www.brentozar.com/archive/2021/06/how-can-index-seeks-get-inaccurate-row-estimates/ +[OLAP != OLAP Cube]:https://www.holistics.io/blog/olap-is-not-olap-cube/ +[Connecting a SQL Server client on Linux using Active Directory authentication]:https://sqlsunday.com/2021/04/15/connecting-linux-using-ad-authentication/ +[Is a sort faster when the data is already sorted?]:https://sqlsunday.com/2021/02/15/is-a-sort-faster-when-data-already-sorted/ +[Connect using Windows authentication across domains]:https://sqlsunday.com/2021/02/05/connect-using-windows-authentication-across-domains/ +[The uncorrelated correlated subquery]:https://sqlsunday.com/2020/12/21/the-uncorrelated-correlated-subquery/ +[How to fix rounding errors]:https://sqlsunday.com/2020/12/15/how-to-fix-rounding-errors/ +[The curious case of the Top N Sort]:https://sqlsunday.com/2020/12/08/the-curious-case-of-the-top-n-sort/ +[Consolidating grouped transactions into evenly sized batches]:https://sqlsunday.com/2020/07/13/grouping-into-evenly-sized-batches/ +[A “shock absorber” pattern for high-performance data ingestion]:https://sqlsunday.com/2021/07/15/a-shock-absorber-pattern-for-high-performance-data-ingest/ +[Why Are Linked Server Queries So Bad?]:https://www.brentozar.com/archive/2021/07/why-are-linked-server-queries-so-bad/ +[Fundamentals of table expressions, Part 1]:https://sqlperformance.com/2020/04/t-sql-queries/table-expressions-part-1 +[Fundamentals of table expressions, Part 2 – Derived tables, logical considerations]:https://sqlperformance.com/2020/04/t-sql-queries/table-expressions-part-2 +[Fundamentals of table expressions, Part 3 – Derived tables, optimization considerations]:https://sqlperformance.com/2020/06/t-sql-queries/table-expressions-part-3 +[Fundamentals of table expressions, Part 4 – Derived tables, optimization considerations, continued]:https://sqlperformance.com/2020/07/t-sql-queries/table-expressions-part-4 +[Fundamentals of table expressions, Part 5 – CTEs, logical considerations]:https://sqlperformance.com/2020/08/t-sql-queries/table-expressions-part-5 +[Fundamentals of table expressions, Part 6 – Recursive CTEs]:https://sqlperformance.com/2020/09/t-sql-queries/fundamentals-of-table-expressions-part-6-recursive-ctes +[Fundamentals of table expressions, Part 7 – CTEs, optimization considerations]:https://sqlperformance.com/2020/10/t-sql-queries/table-expressions-part-7 +[Fundamentals of table expressions, Part 8 – CTEs, optimization considerations continued]:https://sqlperformance.com/2020/11/t-sql-queries/table-expressions-part-8 +[Fundamentals of table expressions, Part 9 – Views, compared with derived tables and CTEs]:https://sqlperformance.com/2021/06/t-sql-queries/table-expressions-part-9 +[Fundamentals of table expressions, Part 10 – Views, SELECT *, and DDL changes]:https://sqlperformance.com/2021/07/t-sql-queries/table-expressions-part-10 +[Understanding xp_fileexist and its usage]:https://www.sqlshack.com/understanding-xp_fileexist-and-its-usage/ +[SQL Server Restore Database Options and Examples]:https://www.mssqltips.com/sqlservertip/6893/restore-database-sql-server-options-examples/ +[SQL Server Database RESTORE WITH MOVE or not WITH MOVE]:https://www.mssqltips.com/sqlservertip/3113/sql-server-database-restore-with-move-or-not-with-move/ +[Getting exclusive access to restore SQL Server database]:https://www.mssqltips.com/sqlservertip/1407/getting-exclusive-access-to-restore-sql-server-database/ +[How to migrate a SQL Server database to a lower version]:https://www.mssqltips.com/sqlservertip/2810/how-to-migrate-a-sql-server-database-to-a-lower-version/ +[Make Network Path Visible For SQL Server Backup and Restore in SSMS]:https://www.mssqltips.com/sqlservertip/3499/make-network-path-visible-for-sql-server-backup-and-restore-in-ssms/ +[T-SQL bugs, pitfalls, and best practices – pivoting and unpivoting]:https://sqlperformance.com/2019/09/t-sql-queries/t-sql-pitfalls-pivoting-unpivoting +[How to Prep a SQL Server Availability Group for VM-Level DR Replication]:https://www.davidklee.net/2021/02/08/how-to-prep-a-sql-server-availability-group-for-vm-level-dr-replication/ +[Special Agent Jenkins]:https://nvarscar.wordpress.com/2018/05/03/special-agent-jenkins/ +[What To Avoid If You Want To Use MERGE]:https://michaeljswart.com/2021/08/what-to-avoid-if-you-want-to-use-merge/ +[Solving Gaps and Islands with Enhanced Window]:https://www.itprotoday.com/sql-server/solving-gaps-and-islands-enhanced-window-functions +[How to choose between SQL and NoSQL databases]:https://www.red-gate.com/simple-talk/databases/nosql/how-to-choose-between-sql-and-nosql-databases/ +[SQL Server plan cache mining – Plan attributes]:https://www.red-gate.com/simple-talk/homepage/sql-server-plan-cache-mining-plan-attributes/ +[How to Prep a SQL Server Availability Group for VM-Level DR Replication]:https://www.davidklee.net/2021/02/08/how-to-prep-a-sql-server-availability-group-for-vm-level-dr-replication/ +[How to create an autonomous transaction in SQL Server 2008]:https://techcommunity.microsoft.com/t5/sql-server/how-to-create-an-autonomous-transaction-in-sql-server-2008/ba-p/383471 +[Cloud Comparison: AWS vs. Azure vs. GCP]:https://seniordba.wordpress.com/2021/05/24/cloud-comparison-aws-vs-azure-vs-gcp/ +[New VLF status value]:https://www.sqlskills.com/blogs/paul/new-vlf-status-value/ +[The Simplest Alternative to sp_MSforeachdb]:https://eitanblumin.com/2021/08/05/simplest-alternative-to-sp_msforeachdb/ +[Your database connection deserves a name]:https://andygrunwald.com/blog/your-database-connection-deserves-a-name/ +[Renaming a Database Table In-Flight]:https://engineering.outschool.com/posts/renaming-database-table/ +[Upgrading/Migrating Large Replicated Databases Without Reinitializing]:https://www.sqlskills.com/blogs/jonathan/upgrading-migrating-large-replicated-databases-without-reinitializing/ +[TempDB configuration for people in a hurry]:https://desertdba.com/tempdb-configuration-for-people-in-a-hurry/ +[Help! My tempdb database won’t shrink!]:https://desertdba.com/help-my-tempdb-database-wont-shrink/ +[SQL Server Checkpoint Monitoring with Extended Events]:https://www.mssqltips.com/sqlservertip/6319/sql-server-checkpoint-monitoring-with-extended-events/ +["0 to 60" : Switching to indirect checkpoints]:https://sqlperformance.com/2020/05/system-configuration/0-to-60-switching-to-indirect-checkpoints +[A case against using Basic and Standard (S0 & S1) tiers in Azure SQL Databases]:https://www.nikoport.com/2021/02/09/a-case-against-using-basic-and-standard-s0-s1-tiers-in-azure-sql-databases/ +[Experiment: Does sp_recompile on a table update associated views.]:https://sqlstudies.com/2021/08/17/experiment-does-sp_recompile-on-a-table-update-associated-views/ +[On index key size, index depth, and performance]:https://www.sqlskills.com/blogs/paul/on-index-key-size-index-depth-and-performance/ +[SQL Server Hierarchyid Data Type Overview and Examples]:https://www.mssqltips.com/sqlservertip/6048/sql-server-hierarchyid-data-type-overview-and-examples/ +[Make It Easier for the DBA: Give SQL Connections the Application’s Name!]:https://bengribaudo.com/blog/2017/06/23/3657/give-sql-connections-the-applications-name +[You Probably Shouldn’t Index Your Temp Tables.]:https://www.brentozar.com/archive/2021/08/you-probably-shouldnt-index-your-temp-tables/ +[SQL Server Error Handling Gotchas]:https://nielsberglund.com/2016/12/31/sql-server-error-handling-gotchas/ +[B-Trees: More Than I Thought I'd Want to Know]:https://benjamincongdon.me/blog/2021/08/17/B-Trees-More-Than-I-Thought-Id-Want-to-Know/ +[Wait Stats During Hash Spills]:https://www.erikdarlingdata.com/sql-server/wait-stats-during-hash-spills/ +[Shrinking The tempdb System Database Without Restarting SQL Server]:https://jackworthen.com/2016/06/02/shrinking-the-tempdb-system-database-without-restarting-sql-server/ +[Graphing SQL Server wait stats on Prometheus and Grafana]:https://blog.developpez.com/mikedavem/p13209/devops/graphing-sql-server-wait-stats-on-prometheus-and-grafana +[Transition from SSMS to DataGrip: 10 tips]:https://blog.jetbrains.com/datagrip/2021/08/19/transition-from-ssms-to-datagrip-10-tips/ +[Query Store Hints]:https://www.sqlskills.com/blogs/erin/query-store-hints/ +[Announcing SSIS Framework Manager, v1]:https://andyleonard.blog/2021/06/announcing-ssis-framework-manager-v1/ +[Improving The Performance of RBAR Modifications]:https://www.erikdarlingdata.com/sql-server/improving-the-performance-of-rbar-modifications/ +[Minimal Logging with INSERT…SELECT into Empty Clustered Tables]:https://sqlperformance.com/2019/05/sql-performance/minimal-logging-empty-clustered +[What Is a Cost-Based Optimizer?]:https://www.brentozar.com/archive/2021/09/what-is-a-cost-based-optimizer/ +[Unusual Parameter Sniffing: Big Problems with Small Data]:https://www.brentozar.com/archive/2021/02/unusual-parameter-sniffing-big-problems-with-small-data/ +[Rowcount estimates when there are no Statistics]:https://matthewmcgiffen.com/2021/01/26/rowcount-estimates-when-there-are-no-statistics/ +[Processing Data Queues in SQL Server with READPAST and UPDLOCK]:https://www.mssqltips.com/sqlservertip/1257/processing-data-queues-in-sql-server-with-readpast-and-updlock/ +[Can You Get Parameter Sniffing on Updates and Deletes?]:https://www.brentozar.com/archive/2021/01/can-you-get-parameter-sniffing-on-updates-and-deletes/ +[An Empirical Look at Key Lookups]:https://forrestmcdaniel.com/2020/12/30/an-empirical-look-at-key-lookups/ +[Please stop using this UPSERT anti-pattern]:https://sqlperformance.com/2020/09/locking/upsert-anti-pattern +[The Curious Case of… the failing differential restore]:https://www.sqlskills.com/blogs/paul/the-curious-case-of-the-failing-differential-restore/ +[Starting SQL: Compensating For Lock Waits]:https://www.erikdarlingdata.com/starting-sql/starting-sql-compensating-for-lock-waits/ +[Finding & Downloading Required SQL Server Updates]:https://www.flxsql.com/downloading-latest-sql-server-updates/ +[Quick SQL Server CPU Comparison Tests]:https://www.erikdarlingdata.com/sql-server/quick-sql-server-cpu-comparison-tests/ +[Using fn_dblog, fn_dump_dblog, and restoring with STOPBEFOREMARK to an LSN]:https://www.sqlskills.com/blogs/paul/using-fn_dblog-fn_dump_dblog-and-restoring-with-stopbeforemark-to-an-lsn/ diff --git a/CLR/README.md b/CLR/README.md index f08fe38c..9363be84 100644 --- a/CLR/README.md +++ b/CLR/README.md @@ -6,7 +6,7 @@ Useful links: - [CLR User-Defined Types](https://msdn.microsoft.com/en-us/library/ms131120(SQL.100).aspx) - [CLR Stored Procedures](https://msdn.microsoft.com/en-us/library/ms131094(SQL.100).aspx) - [CLR Triggers](https://msdn.microsoft.com/en-us/library/ms131093(SQL.100).aspx) - - [SQL# CLR functions](http://www.sqlsharp.com/) (by Sql Quantum Lift) + - [SQL# CLR functions](https://SQLsharp.com/) (by Sql Quantum Lift) The common language runtime (CLR) is the heart of the Microsoft .NET Framework and provides the execution environment for all .NET Framework code. Code that runs within the CLR is referred to as managed code. The CLR provides various functions and services required for program execution, including just-in-time (JIT) compilation, allocating and managing memory, enforcing type safety, exception handling, thread management, and security. @@ -15,9 +15,7 @@ With the CLR hosted in Microsoft SQL Server (called CLR integration), you can au Enabling CLR Integration: ```tsql -sp_configure 'clr enabled', 1; -GO - +EXEC sp_configure 'clr enabled', 1; RECONFIGURE; GO ``` diff --git a/Errors/Identity_gap_sql_server_2012.sql b/Errors/Identity_gap_sql_server_2012.sql index eb90ddae..3465f56e 100644 --- a/Errors/Identity_gap_sql_server_2012.sql +++ b/Errors/Identity_gap_sql_server_2012.sql @@ -3,12 +3,12 @@ DROP TABLE t1; GO CREATE TABLE t1 ( - col1 INTEGER IDENTITY(1,1), + col1 INTEGER IDENTITY(1,1), col2 VARCHAR(10), - col3 CHAR(10), - col4 NCHAR(10), - col5 TINYINT, - col6 BIGINT + col3 CHAR(10), + col4 NCHAR(10), + col5 TINYINT, + col6 BIGINT ); GO @@ -34,15 +34,15 @@ SELECT *, LEN(col1) AS integer_len, LEN(col2) AS varchar_len, LEN(col3) AS char_len, - LEN(col4) AS nchar_len, - LEN(col5) AS tinyint_len, - LEN(col6) AS bigint_len, - DATALENGTH(col1) AS integer_datalength, - DATALENGTH(col2) AS varchar_datalength, - DATALENGTH(col3) AS char_datalength, - DATALENGTH(col4) AS nchar_datalength, - DATALENGTH(col5) AS tinyint_datalength, - DATALENGTH(col6) AS bigint_datalength + LEN(col4) AS nchar_len, + LEN(col5) AS tinyint_len, + LEN(col6) AS bigint_len, + DATALENGTH(col1) AS integer_datalength, + DATALENGTH(col2) AS varchar_datalength, + DATALENGTH(col3) AS char_datalength, + DATALENGTH(col4) AS nchar_datalength, + DATALENGTH(col5) AS tinyint_datalength, + DATALENGTH(col6) AS bigint_datalength FROM t1; -- DBCC CHECKIDENT('t1', 'RESEED', 5); @@ -55,14 +55,14 @@ GO BEGIN TRY SELECT --/* CAST(-1 AS tinyint), - 1/0 + 1/0 --*/ * FROM t1; END TRY BEGIN CATCH SELECT ERROR_NUMBER() AS ERROR_NUMBER, ERROR_SEVERITY() AS ERROR_SEVERITY, - ERROR_STATE() AS ERROR_STATE, - ERROR_PROCEDURE() AS ERROR_PROCEDURE, + ERROR_STATE() AS ERROR_STATE, + ERROR_PROCEDURE() AS ERROR_PROCEDURE, ERROR_MESSAGE() AS ERROR_MESSAGE, - ERROR_LINE() AS ERROR_LINE; -END CATCH; \ No newline at end of file + ERROR_LINE() AS ERROR_LINE; +END CATCH; diff --git a/Errors/PDB/README.md b/Errors/PDB/README.md new file mode 100644 index 00000000..52624419 --- /dev/null +++ b/Errors/PDB/README.md @@ -0,0 +1,22 @@ +# SQL Server Debugging + +- [Obtaining symbol files (.PDB) for SQL Server Releases](https://github.com/arvindshmicrosoft/SQLCallStackResolver/wiki/Scripts-to-download-symbols-for-SQL-Server-2019) +- [What is the SOS_WORK_DISPATCHER Wait Type?](https://orderbyselectnull.com/2018/09/27/what-is-the-sos_work_dispatcher-wait-type/) +- [An XEvent a Day (24 of 31) – What is the callstack?](https://www.sqlskills.com/blogs/jonathan/an-xevent-a-day-24-of-31-what-is-the-callstack/) + +This section contains PowerShell scripts which automate the download and extraction of `.PDB` files corresponding to major releases of SQL Server. + +For running any of these scripts, please note the following: +- You must run them within PowerShell, preferably within Windows +- You must have Internet access from the machine running the PowerShell script +- You might want to replace the $outputFolder placeholder with a different folder path (for example, `N:\sqlsymbols\SQL2016SP1`) +- The script will automatically create the folder where the downloaded PDB files are stored. + +Please click on one of the links below depending on the major version of SQL Server that you are looking at: +- [SQL Server 2019](SQL-Server-2019.md) +- [SQL Server 2017](SQL-Server-2017.md) +- [SQL Server 2016](SQL-Server-2016.md) +- [SQL Server 2014](SQL-Server-2014.md) +- [SQL Server 2012](SQL-Server-2012.md) +- [SQL Server 2008 R2](SQL-Server-2008-R2.md) +- [SQL Server 2008](SQL-Server-2008.md) diff --git a/Errors/PDB/SQL-Server-2008-R2.md b/Errors/PDB/SQL-Server-2008-R2.md new file mode 100644 index 00000000..c3fce980 --- /dev/null +++ b/Errors/PDB/SQL-Server-2008-R2.md @@ -0,0 +1,100 @@ +# SQL Server 2008 R2 SP3 Security update January 6, 2018 - 10.50.6560.0 - x64 (4057113) +``` powershell +# SQL Server 2008 R2 SP3 Security update January 6, 2018 - 10.50.6560.0 - x64 (4057113) +$outputFolder = 'c:\sqlsyms\10.50.6560.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/b981ac9f18d144989cdc934947f492811/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2009.0100.6560.00 ((KJ_SP3_QFE-OD).171228-1456 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/9e7a839d91dd474a8631dfef6abca4501/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2009.0100.6560.00 ((KJ_SP3_QFE-OD).171228-1456 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/cc4bfc0743fc46b392fa0fdb7c7826452/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2009.0100.6560.00 ((KJ_SP3_QFE-OD).171228-1456 ) +``` + +# SQL Server 2008 R2 SP3 Security update January 6, 2018 - 10.50.6560.0 - x86 (4057113) +``` powershell +# SQL Server 2008 R2 SP3 Security update January 6, 2018 - 10.50.6560.0 - x86 (4057113) +$outputFolder = 'c:\sqlsyms\10.50.6560.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/ef09e694a6c54677a0e350aa61328a851/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2009.0100.6560.00 ((KJ_SP3_QFE-OD).171228-1537 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/a0dd581a069a4f46892922b421e679d41/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2009.0100.6560.00 ((KJ_SP3_QFE-OD).171228-1537 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/31933e3ce06745e1a57659e51088a0082/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2009.0100.6560.00 ((KJ_SP3_QFE-OD).171228-1537 ) +``` + +# SQL Server 2008 R2 SP3 Hotfix KB 3146034 - 10.50.6542.0 - x64 (3146034) +``` powershell +# SQL Server 2008 R2 SP3 Hotfix KB 3146034 - 10.50.6542.0 - x64 (3146034) +$outputFolder = 'c:\sqlsyms\10.50.6542.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/4f088282518843b79e0478994de908221/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2009.0100.6542.00 ((KJ_SP3_QFE-OD).160222-1803 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/ded28d8ceae641748aec32fb45cb2b451/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2009.0100.6542.00 ((KJ_SP3_QFE-OD).160222-1803 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/1efb80e5273747c397f6185ab6670c9d2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2009.0100.6542.00 ((KJ_SP3_QFE-OD).160222-1803 ) +``` + +# SQL Server 2008 R2 SP3 Hotfix KB 3146034 - 10.50.6542.0 - x86 (3146034) +``` powershell +# SQL Server 2008 R2 SP3 Hotfix KB 3146034 - 10.50.6542.0 - x86 (3146034) +$outputFolder = 'c:\sqlsyms\10.50.6542.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/989ad268055f459aa1fd4d1eea34c6ae1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2009.0100.6542.00 ((KJ_SP3_QFE-OD).160222-1804 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/569d9d76538b4106a8c414bf7dcdbe511/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2009.0100.6542.00 ((KJ_SP3_QFE-OD).160222-1804 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/33f28fb385a04fd5afdc44264428efcb2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2009.0100.6542.00 ((KJ_SP3_QFE-OD).160222-1804 ) +``` + +# SQL Server 2008 R2 SP3 MS15-058: Security update QFE: July 14, 2015 - 10.50.6529.0 - x64 (3045314) +``` powershell +# SQL Server 2008 R2 SP3 MS15-058: Security update QFE: July 14, 2015 - 10.50.6529.0 - x64 (3045314) +$outputFolder = 'c:\sqlsyms\10.50.6529.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/6fd8bc7e6da241f9acfef95aa7529e671/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2009.0100.6529.00 ((KJ_SP3_QFE-OD).150319-1313 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/afa19b0c44e54bef8028f5aae687c1751/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2009.0100.6529.00 ((KJ_SP3_QFE-OD).150319-1313 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/282885315f3e4925a0753fdd1e2eae612/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2009.0100.6529.00 ((KJ_SP3_QFE-OD).150319-1313 ) +``` + +# SQL Server 2008 R2 SP3 MS15-058: Security update QFE: July 14, 2015 - 10.50.6529.0 - x86 (3045314) +``` powershell +# SQL Server 2008 R2 SP3 MS15-058: Security update QFE: July 14, 2015 - 10.50.6529.0 - x86 (3045314) +$outputFolder = 'c:\sqlsyms\10.50.6529.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/57832ff449b14214bfbb5b3976147d2c1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2009.0100.6529.00 ((KJ_SP3_QFE-OD).150319-1314 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/bb45c06675b04636aeaa71423c08c0bd1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2009.0100.6529.00 ((KJ_SP3_QFE-OD).150319-1314 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/37b52eaf08284c23bdfda05c7b5bd0f52/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2009.0100.6529.00 ((KJ_SP3_QFE-OD).150319-1314 ) +``` + +# SQL Server 2008 R2 SP3 Hotfix KB3033860 - 10.50.6525.0 - x64 (3033860) +``` powershell +# SQL Server 2008 R2 SP3 Hotfix KB3033860 - 10.50.6525.0 - x64 (3033860) +$outputFolder = 'c:\sqlsyms\10.50.6525.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/fd1e350610034849822cdb74a90e3f4a1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2009.0100.6525.00 ((KJ_SP3_QFE-OD).150123-1315 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/8e5d923c1e744b2395d0faebb7b27aed1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2009.0100.6525.00 ((KJ_SP3_QFE-OD).150123-1315 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/a80a08b5910a4b7c81bca4f7ea5737cb2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2009.0100.6525.00 ((KJ_SP3_QFE-OD).150123-1315 ) +``` + +# SQL Server 2008 R2 SP3 Hotfix KB3033860 - 10.50.6525.0 - x86 (3033860) +``` powershell +# SQL Server 2008 R2 SP3 Hotfix KB3033860 - 10.50.6525.0 - x86 (3033860) +$outputFolder = 'c:\sqlsyms\10.50.6525.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/5705adbab9074c1a8aa3f8086b0b9e351/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2009.0100.6525.00 ((KJ_SP3_QFE-OD).150123-1339 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/24b6b9fb3e3248459032337981a515701/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2009.0100.6525.00 ((KJ_SP3_QFE-OD).150123-1339 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/41239188b6494cedb627d7bb0a7bd2a12/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2009.0100.6525.00 ((KJ_SP3_QFE-OD).150123-1339 ) +``` + +# SQL Server 2008 R2 SP3 SP3 - 10.50.6000.34 - x64 (2979597) +``` powershell +# SQL Server 2008 R2 SP3 SP3 - 10.50.6000.34 - x64 (2979597) +$outputFolder = 'c:\sqlsyms\10.50.6000.34\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/bf37a41b8a974a9a90ac6aaef464011a1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2009.0100.6000.034 ((KJ_SP3).140819-1214 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/21cf8932b0184570858de406b79475031/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2009.0100.6000.034 ((KJ_SP3).140819-1214 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/293c90c8918b4aaaa39ea16237b39eff2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2009.0100.6000.034 ((KJ_SP3).140819-1214 ) +``` + +# SQL Server 2008 R2 SP3 SP3 - 10.50.6000.34 - x86 (2979597) +``` powershell +# SQL Server 2008 R2 SP3 SP3 - 10.50.6000.34 - x86 (2979597) +$outputFolder = 'c:\sqlsyms\10.50.6000.34\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/2a05437dc1204cff970a2275d6335ada1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2009.0100.6000.034 ((KJ_SP3).140819-1213 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/682d729f9e6e43f3a47a9c158e905e171/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2009.0100.6000.034 ((KJ_SP3).140819-1213 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/5b7a3d00503e4924bd365f20b6ea87642/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2009.0100.6000.034 ((KJ_SP3).140819-1213 ) +``` + diff --git a/Errors/PDB/SQL-Server-2008.md b/Errors/PDB/SQL-Server-2008.md new file mode 100644 index 00000000..2a10815a --- /dev/null +++ b/Errors/PDB/SQL-Server-2008.md @@ -0,0 +1,120 @@ +# SQL Server 2008 SP4 Security update January 6, 2018 - 10.0.6556.0 - x64 (4057114) +``` powershell +# SQL Server 2008 SP4 Security update January 6, 2018 - 10.0.6556.0 - x64 (4057114) +$outputFolder = 'c:\sqlsyms\10.0.6556.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/eaa1a756484a4f95bc6896b8529c11701/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2007.0100.6556.00 ((Katmai_SP4_QFE-OD).171228-1515 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/2155ad0fe0a045e38b33e3f36bdb6a211/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2007.0100.6556.00 ((Katmai_SP4_QFE-OD).171228-1515 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/48e9083d8d21441fb77939286bcc001d2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2007.0100.6556.00 ((Katmai_SP4_QFE-OD).171228-1515 ) +``` + +# SQL Server 2008 SP4 Security update January 6, 2018 - 10.0.6556.0 - x86 (4057114) +``` powershell +# SQL Server 2008 SP4 Security update January 6, 2018 - 10.0.6556.0 - x86 (4057114) +$outputFolder = 'c:\sqlsyms\10.0.6556.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/1401bf04646b4e409d7b7a4fc0644fa81/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2007.0100.6556.00 ((Katmai_SP4_QFE-OD).171228-1515 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/dacb0afbc1334010a573e48736ba72ad1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2007.0100.6556.00 ((Katmai_SP4_QFE-OD).171228-1515 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/bd167760b8344d3f90608a2c18cf40092/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2007.0100.6556.00 ((Katmai_SP4_QFE-OD).171228-1515 ) +``` + +# SQL Server 2008 SP4 Hotfix KB3146034 - 10.0.6547.0 - x64 (3146034) +``` powershell +# SQL Server 2008 SP4 Hotfix KB3146034 - 10.0.6547.0 - x64 (3146034) +$outputFolder = 'c:\sqlsyms\10.0.6547.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/e5191b6b180941edb5a20276f9a0384e1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2007.0100.6547.00 ((Katmai_SP4_QFE-OD).160222-1900 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/8fc01c8d34354aa088a13f9c071ebb611/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2007.0100.6547.00 ((Katmai_SP4_QFE-OD).160222-1900 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/3b1145daf61646efbfb3d93ef8948e612/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2007.0100.6547.00 ((Katmai_SP4_QFE-OD).160222-1900 ) +``` + +# SQL Server 2008 SP4 Hotfix KB3146034 - 10.0.6547.0 - x86 (3146034) +``` powershell +# SQL Server 2008 SP4 Hotfix KB3146034 - 10.0.6547.0 - x86 (3146034) +$outputFolder = 'c:\sqlsyms\10.0.6547.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/b37439c8c52c4952845b150ffd7732af1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2007.0100.6547.00 ((Katmai_SP4_QFE-OD).160222-1901 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/d1c5577343cb4ed8bbc36832eb826afc1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2007.0100.6547.00 ((Katmai_SP4_QFE-OD).160222-1901 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/5bd7009e0fcf4b74b69a23467963dfb42/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2007.0100.6547.00 ((Katmai_SP4_QFE-OD).160222-1901 ) +``` + +# SQL Server 2008 SP4 QFE for MS15-058 - 10.0.6535.0 - x64 (3045308) +``` powershell +# SQL Server 2008 SP4 QFE for MS15-058 - 10.0.6535.0 - x64 (3045308) +$outputFolder = 'c:\sqlsyms\10.0.6535.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/2e97b3df36eb4e7fb0ec16f0ba82bd031/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2007.0100.6535.00 ((Katmai_SP4_QFE-OD).150417-1943 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/9bea90cfba544af19a1cf11d034abc001/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2007.0100.6535.00 ((Katmai_SP4_QFE-OD).150417-1943 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/b579d44345e44607a12a9d0d448b7ab42/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2007.0100.6535.00 ((Katmai_SP4_QFE-OD).150417-1943 ) +``` + +# SQL Server 2008 SP4 QFE for MS15-058 - 10.0.6535.0 - x86 (3045308) +``` powershell +# SQL Server 2008 SP4 QFE for MS15-058 - 10.0.6535.0 - x86 (3045308) +$outputFolder = 'c:\sqlsyms\10.0.6535.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/33fe9f06c7b944668d174d77d64fd2051/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2007.0100.6535.00 ((Katmai_SP4_QFE-OD).150417-2008 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/688c68ac33c5460894783989531e65431/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2007.0100.6535.00 ((Katmai_SP4_QFE-OD).150417-2008 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/7b8f66e87c4c4afd995254a5b2e5083a2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2007.0100.6535.00 ((Katmai_SP4_QFE-OD).150417-2008 ) +``` + +# SQL Server 2008 SP4 Hotfix KB3034373 - 10.0.6526.0 - x64 (3034373) +``` powershell +# SQL Server 2008 SP4 Hotfix KB3034373 - 10.0.6526.0 - x64 (3034373) +$outputFolder = 'c:\sqlsyms\10.0.6526.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/85dd188f10df47c0a6b57c70ead0b5c01/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2007.0100.6526.00 ((Katmai_SP4_QFE-OD).150123-1208 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/7c4f51489d884394b902225c7f2b80891/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2007.0100.6526.00 ((Katmai_SP4_QFE-OD).150123-1208 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/422c51381bc04a7fa2b9bd7fe9b04ca32/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2007.0100.6526.00 ((Katmai_SP4_QFE-OD).150123-1208 ) +``` + +# SQL Server 2008 SP4 Hotfix KB3034373 - 10.0.6526.0 - x86 (3034373) +``` powershell +# SQL Server 2008 SP4 Hotfix KB3034373 - 10.0.6526.0 - x86 (3034373) +$outputFolder = 'c:\sqlsyms\10.0.6526.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/913da3830d16455eadff72481f3179401/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2007.0100.6526.00 ((Katmai_SP4_QFE-OD).150123-1211 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/901456d096344ca5bd6a117025a412461/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2007.0100.6526.00 ((Katmai_SP4_QFE-OD).150123-1211 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/3b31c12ff4134cc3afb773e8a830896b2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2007.0100.6526.00 ((Katmai_SP4_QFE-OD).150123-1211 ) +``` + +# SQL Server 2008 SP4 Security Update MS15-058 July 14, 2015 - 10.0.6241.0 - x64 (3045311) +``` powershell +# SQL Server 2008 SP4 Security Update MS15-058 July 14, 2015 - 10.0.6241.0 - x64 (3045311) +$outputFolder = 'c:\sqlsyms\10.0.6241.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/f667598776444a32942ee049bcb442241/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2007.0100.6241.00 ((Katmai_SP4_GDR).150417-1051 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/de19a5bdf857430d9c4a6650dd7667401/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2007.0100.6241.00 ((Katmai_SP4_GDR).150417-1051 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/8d79f55153d444be9a35cc7969cd4c702/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2007.0100.6241.00 ((Katmai_SP4_GDR).150417-1051 ) +``` + +# SQL Server 2008 SP4 Security Update MS15-058 July 14, 2015 - 10.0.6241.0 - x86 (3045311) +``` powershell +# SQL Server 2008 SP4 Security Update MS15-058 July 14, 2015 - 10.0.6241.0 - x86 (3045311) +$outputFolder = 'c:\sqlsyms\10.0.6241.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/7ad87780f3a54788a6fd32f946f1e4751/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2007.0100.6241.00 ((Katmai_SP4_GDR).150417-1052 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/257c88a2ab974c1abcb621bd9f7854ad1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2007.0100.6241.00 ((Katmai_SP4_GDR).150417-1052 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/20ee497f35de471ab067178d8fcfb3572/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2007.0100.6241.00 ((Katmai_SP4_GDR).150417-1052 ) +``` + +# SQL Server 2008 SP4 SP4 - 10.0.6000.29 - x64 (2979597) +``` powershell +# SQL Server 2008 SP4 SP4 - 10.0.6000.29 - x64 (2979597) +$outputFolder = 'c:\sqlsyms\10.0.6000.29\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/fc69079383a34f3b9338254f34b07e531/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2007.0100.6000.029 ((Katmai_SP4).140903-0405) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/116e643b4d7d48dd9c987a2570bf124b1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2007.0100.6000.029 ((Katmai_SP4).140902-2248 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/d7f4aeaf89544a098f18dbaa4405a1802/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2007.0100.6000.029 ((Katmai_SP4).140903-0405) +``` + +# SQL Server 2008 SP4 SP4 - 10.0.6000.29 - x86 (2979597) +``` powershell +# SQL Server 2008 SP4 SP4 - 10.0.6000.29 - x86 (2979597) +$outputFolder = 'c:\sqlsyms\10.0.6000.29\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/220547919ebf4ea4a9dc6ad770f2a97b1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2007.0100.6000.029 ((Katmai_SP4).140902-2247 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/8967aa50a6e147858de6bdf0ca51712b1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2007.0100.6000.029 ((Katmai_SP4).140902-2247 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/1c4ac2e980b444129c6512bc9c9377802/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2007.0100.6000.029 ((Katmai_SP4).140902-2247 ) +``` + diff --git a/Errors/PDB/SQL-Server-2012.md b/Errors/PDB/SQL-Server-2012.md new file mode 100644 index 00000000..15af7196 --- /dev/null +++ b/Errors/PDB/SQL-Server-2012.md @@ -0,0 +1,1020 @@ +# SQL Server 2012 SP4 Security update - 11.0.7493.4 - x64 (4532098) +``` powershell +# SQL Server 2012 SP4 Security update - 11.0.7493.4 - x64 (4532098) +$outputFolder = 'c:\sqlsyms\11.0.7493.4\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/480435d60ca54ce381ec0e8a0a0d76a02/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.7493.04 ((SQL11_SP4_QFE-OD).191224-1917 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/e6c9aa0810194fa6b574b7215b217af72/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.7493.04 ((SQL11_SP4_QFE-OD).191224-1917 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/7a4a97665c58401780368d29ee631ccd2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.7493.04 ((SQL11_SP4_QFE-OD).191224-1917 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/43b4e82b3c66419e8b35da8d9257b3ff2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.7493.04 ((SQL11_SP4_QFE-OD).191224-1917 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/295ba2e5d3194ca5b61b7b31d7c079c11/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.7493.04 ((SQL11_SP4_QFE-OD).191224-1917 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/ae89899ab121405083d262de6e8846961/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.7493.04 ((SQL11_SP4_QFE-OD).191224-1917 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/d20221dff4c941c087921649121052281/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.7493.04 ((SQL11_SP4_QFE-OD).191224-1917 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/b08ffbd94e4b4e17bb1e39045f524abb1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.7493.04 ((SQL11_SP4_QFE-OD).191224-1917 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/da346c631b6e46e7b56825f235d89c561/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.7493.04 ((SQL11_SP4_QFE-OD).191224-1917 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/50c405e5402b43e7a5ef91788f6ef43f2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.7493.04 ((SQL11_SP4_QFE-OD).191224-1917 ) +``` + +# SQL Server 2012 SP4 Security update - 11.0.7493.4 - x86 (4532098) +``` powershell +# SQL Server 2012 SP4 Security update - 11.0.7493.4 - x86 (4532098) +$outputFolder = 'c:\sqlsyms\11.0.7493.4\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/ba8f818630714eb7b381ec0649b061302/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.7493.04 ((SQL11_SP4_QFE-OD).191224-2006 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/7e0415dd919840948ef712d61810daec2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.7493.04 ((SQL11_SP4_QFE-OD).191224-2006 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/68d681fcf4c64f9b883f8512ccdfd05e2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.7493.04 ((SQL11_SP4_QFE-OD).191224-2006 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/30dd863e703c4fa8b9cafd898a9495cf2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.7493.04 ((SQL11_SP4_QFE-OD).191224-2006 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/de5513fd8b1c4fb6b91efe477704b14a1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.7493.04 ((SQL11_SP4_QFE-OD).191224-2006 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/96552da4ca10465c9c33b981bde24ccb1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.7493.04 ((SQL11_SP4_QFE-OD).191224-2006 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/1b99718314a84b3fa7f5d532b463f1701/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.7493.04 ((SQL11_SP4_QFE-OD).191224-2006 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/e5470f778c574450bcdfff21a91b739f1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.7493.04 ((SQL11_SP4_QFE-OD).191224-2006 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/ade3c305ff2c46cd845c19b14deb5aff1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.7493.04 ((SQL11_SP4_QFE-OD).191224-2006 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/339831825ec24abcb2fc18813066d2e82/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.7493.04 ((SQL11_SP4_QFE-OD).191224-2006 ) +``` + +# SQL Server 2012 SP4 Hotfix 4091266 - 11.0.7469.6 - x64 (4091266) +``` powershell +# SQL Server 2012 SP4 Hotfix 4091266 - 11.0.7469.6 - x64 (4091266) +$outputFolder = 'c:\sqlsyms\11.0.7469.6\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/0f91402cd2414afc9a2e81c7af9af9f32/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.7469.06 ((SQL11_PCU_Main).180228-1732 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/514d1b21c758466fa5812d26da1b58de2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.7469.06 ((SQL11_PCU_Main).180228-1732 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/398932bbfb424772b785fed83bae34442/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.7469.06 ((SQL11_PCU_Main).180228-1732 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/c7875e26c11e47b2809ce5aa66cbb7662/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.7469.06 ((SQL11_PCU_Main).180228-1732 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/9b08807bc3514172b8d1a18707f257ca1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.7469.06 ((SQL11_PCU_Main).180228-1732 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/57a1333981da48e5be28cd275e871d811/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.7469.06 ((SQL11_PCU_Main).180228-1732 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/2b1e43f05e0547cfb3217e369e0ed18d1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.7469.06 ((SQL11_PCU_Main).180228-1732 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/d244e857cc9e4109b38ae22f6fb04fe71/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.7469.06 ((SQL11_PCU_Main).180228-1732 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/94e0b5323ed6420ba2baef29da5dba1e1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.7469.06 ((SQL11_PCU_Main).180228-1732 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/64a2e4d6a3b64ea28cca819f9e247d7c2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.7469.06 ((SQL11_PCU_Main).180228-1732 ) +``` + +# SQL Server 2012 SP4 Hotfix 4091266 - 11.0.7469.6 - x86 (4091266) +``` powershell +# SQL Server 2012 SP4 Hotfix 4091266 - 11.0.7469.6 - x86 (4091266) +$outputFolder = 'c:\sqlsyms\11.0.7469.6\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/a95e440af92540b7a0216cca28c2e8b62/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.7469.06 ((SQL11_PCU_Main).180228-1732 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/db6f725509df4ae384ffdca7d0b9eae32/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.7469.06 ((SQL11_PCU_Main).180228-1732 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/ef46921b8c7b447a8c115beb669e311c2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.7469.06 ((SQL11_PCU_Main).180228-1732 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/f0fe075e9ebd4c29af2de0a8e1b1158e2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.7469.06 ((SQL11_PCU_Main).180228-1732 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/d888cccc0fc440eeab4c46a2501cd7521/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.7469.06 ((SQL11_PCU_Main).180228-1732 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/0715c52891824ecb88d15cb3786666211/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.7469.06 ((SQL11_PCU_Main).180228-1732 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/2f26128d326c4a6cbb38596802231c491/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.7469.06 ((SQL11_PCU_Main).180228-1732 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/398336b2642b40a4bf1c2b5cc2a7b6bf1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.7469.06 ((SQL11_PCU_Main).180228-1732 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/10d83224d37e4629908ef64a9724085b1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.7469.06 ((SQL11_PCU_Main).180228-1732 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/b423cb4eaac6424a9c4006d044788cc82/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.7469.06 ((SQL11_PCU_Main).180228-1732 ) +``` + +# SQL Server 2012 SP4 Security update - 11.0.7462.6 - x64 (4057116) +``` powershell +# SQL Server 2012 SP4 Security update - 11.0.7462.6 - x64 (4057116) +$outputFolder = 'c:\sqlsyms\11.0.7462.6\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/97bc282def8043728f8e03d389c56c852/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.7462.06 ((SQL11_PCU_Main).180105-2156 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/91c7c41bb798485595f5be3f1b3125e92/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.7462.06 ((SQL11_PCU_Main).180105-2156 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/c31145b788cb4a25b9afbc0907f55d722/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.7462.06 ((SQL11_PCU_Main).180105-2156 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/93e6f4ad739547b786cfddf1ead5f54f2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.7462.06 ((SQL11_PCU_Main).180105-2156 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/d33e11ce15dc404d815419cc6dcae2ec1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.7462.06 ((SQL11_PCU_Main).180105-2156 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/9bccf357c8564d61bebfd5cdaeddf9231/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.7462.06 ((SQL11_PCU_Main).180105-2156 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/a2f77318440043c2a75db65201a507911/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.7462.06 ((SQL11_PCU_Main).180105-2156 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/169fdc950daa4b918c5f998625fe01861/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.7462.06 ((SQL11_PCU_Main).180105-2156 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/73dab384b2554d8792c8540ff7a066cb1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.7462.06 ((SQL11_PCU_Main).180105-2156 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/9f5d751b247a4d8884a6c9a5e582dffa2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.7462.06 ((SQL11_PCU_Main).180105-2156 ) +``` + +# SQL Server 2012 SP4 Security update - 11.0.7462.6 - x86 (4057116) +``` powershell +# SQL Server 2012 SP4 Security update - 11.0.7462.6 - x86 (4057116) +$outputFolder = 'c:\sqlsyms\11.0.7462.6\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/31d8d73fc89d494481d3ea3bc23d664c2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.7462.06 ((SQL11_PCU_Main).180105-2153 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/dc4b8738e9c040dca6bda5c19fa15d782/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.7462.06 ((SQL11_PCU_Main).180105-2153 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/9148265be6de4d2f9cbc17085dfd2d252/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.7462.06 ((SQL11_PCU_Main).180105-2153 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/3e0a1ca4d3c343bfbb273258041819952/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.7462.06 ((SQL11_PCU_Main).180105-2153 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/cdf3c5fdc15b43f98eb1a8da3c73c7e31/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.7462.06 ((SQL11_PCU_Main).180105-2153 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/1ebe506aeb6b47b38cc5e514fff18f821/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.7462.06 ((SQL11_PCU_Main).180105-2153 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/47e45abe752b453b833d5bed81c4ce231/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.7462.06 ((SQL11_PCU_Main).180105-2153 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/837fc489e2924037a2c108fd7bf90ffa1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.7462.06 ((SQL11_PCU_Main).180105-2153 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/f6e02bcf4295487995a04701333076431/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.7462.06 ((SQL11_PCU_Main).180105-2153 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/ede3587ca5ea4080a4bf758895d0fdb82/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.7462.06 ((SQL11_PCU_Main).180105-2153 ) +``` + +# SQL Server 2012 SP4 SP4 - 11.0.7001.0 - x64 (4018073) +``` powershell +# SQL Server 2012 SP4 SP4 - 11.0.7001.0 - x64 (4018073) +$outputFolder = 'c:\sqlsyms\11.0.7001.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/d037a5a441e9428386cb7b6ccda51df82/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.7001.00 ((SQL11_PCU_Main).170815-1011 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/61a529bd489946bf98c89d9f471a16032/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.7001.00 ((SQL11_PCU_Main).170815-1011 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/0a1268b6e5ad41e6948f59c193c952d52/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.7001.00 ((SQL11_PCU_Main).170815-1011 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/ab769d65e88c454f9cf7bfb804bc3be12/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.7001.00 ((SQL11_PCU_Main).170815-1011 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/cc41b4cad8244f08ab3662e2572863e61/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.7001.00 ((SQL11_PCU_Main).170815-1011 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/b55075b250fe4c2190f26dd98b740c091/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.7001.00 ((SQL11_PCU_Main).170815-1011 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/f360c904a13349cab685811cc7eb5f1b1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.7001.00 ((SQL11_PCU_Main).170815-1011 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/90455f51040c4fccb89a9664c3cba4191/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.7001.00 ((SQL11_PCU_Main).170815-1011 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/c87b18fbc7da4990a51487628770c54e1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.7001.00 ((SQL11_PCU_Main).170815-1011 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/2d2b68a253924aeea6931cd5801d56b52/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.7001.00 ((SQL11_PCU_Main).170815-1011 ) +``` + +# SQL Server 2012 SP4 SP4 - 11.0.7001.0 - x86 (4018073) +``` powershell +# SQL Server 2012 SP4 SP4 - 11.0.7001.0 - x86 (4018073) +$outputFolder = 'c:\sqlsyms\11.0.7001.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/1f36dddd3d7d43eb9626cc5adbaa603c2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.7001.00 ((SQL11_PCU_Main).170815-1005 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/f82f4ae4a2e74ae59338143499fdfd7a2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.7001.00 ((SQL11_PCU_Main).170815-1005 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/11692631f68842a3b597ba39bef3c2432/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.7001.00 ((SQL11_PCU_Main).170815-1005 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/ab9f6918064040508165482354a196de2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.7001.00 ((SQL11_PCU_Main).170815-1005 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/52059b5d64564a1b935825899d6a09511/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.7001.00 ((SQL11_PCU_Main).170815-1005 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/7fbd676ecf644930ab812a23884186861/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.7001.00 ((SQL11_PCU_Main).170815-1005 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/79bd0035ebe24240b8b71405d0e9fc3f1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.7001.00 ((SQL11_PCU_Main).170815-1005 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/82c1e0b607b547f4a81d2dfe719c4cba1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.7001.00 ((SQL11_PCU_Main).170815-1005 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/039700e384e2462d9a74eeae3864859d1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.7001.00 ((SQL11_PCU_Main).170815-1005 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/fbc3c51cbd1149ecbd8fcfb23aeee3b62/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.7001.00 ((SQL11_PCU_Main).170815-1005 ) +``` + +# SQL Server 2012 SP3 CU9 - 11.0.6598.0 - x64 (4016762) +``` powershell +# SQL Server 2012 SP3 CU9 - 11.0.6598.0 - x64 (4016762) +$outputFolder = 'c:\sqlsyms\11.0.6598.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/109c9b322c6c41aaad2d6361ed344ad02/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.6598.00 ((SQL11_SP3_QFE-CU).170418-1648 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/e734e7142f47477eac0a02a531dffe772/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.6598.00 ((SQL11_SP3_QFE-CU).170418-1648 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/5c5a450a77764195a5f87d2aeffd8bd12/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.6598.00 ((SQL11_SP3_QFE-CU).170418-1648 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/7e4bfbdc22c1487cb147642e9d46f8c02/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.6598.00 ((SQL11_SP3_QFE-CU).170418-1648 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/bb02986cda794e5ca7cb081fc9bad8c21/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.6598.00 ((SQL11_SP3_QFE-CU).170418-1648 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/d3eeb1dd8e65453a91ac3ca57199fa231/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.6598.00 ((SQL11_SP3_QFE-CU).170418-1648 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/fd9f36440ccb405aa49a1d713b1f46431/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.6598.00 ((SQL11_SP3_QFE-CU).170418-1648 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/1e76ae5f488f4e249247bcc0a7c951c01/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.6598.00 ((SQL11_SP3_QFE-CU).170418-1648 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/c11a2afc0ae9480db528fc501f88f73a1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.6598.00 ((SQL11_SP3_QFE-CU).170418-1648 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/d82c7ee189224510a7b11cbab2acc87a2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.6598.00 ((SQL11_SP3_QFE-CU).170418-1648 ) +``` + +# SQL Server 2012 SP3 CU9 - 11.0.6598.0 - x86 (4016762) +``` powershell +# SQL Server 2012 SP3 CU9 - 11.0.6598.0 - x86 (4016762) +$outputFolder = 'c:\sqlsyms\11.0.6598.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/708b17ec74154260be962ee64c2c9f7e2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.6598.00 ((SQL11_SP3_QFE-CU).170418-1707 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/45fca01235c64d0f91cf52c1b2c7b6682/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.6598.00 ((SQL11_SP3_QFE-CU).170418-1707 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/6e4b601d5f804d759f96a435d76a062b2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.6598.00 ((SQL11_SP3_QFE-CU).170418-1707 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/b3795d33240a4a27a70c2221f1f5b91f2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.6598.00 ((SQL11_SP3_QFE-CU).170418-1707 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/f4140814836d4d5284231a6d242860381/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.6598.00 ((SQL11_SP3_QFE-CU).170418-1707 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/b3254f3a7f6f4d548b7a2587b420fb681/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.6598.00 ((SQL11_SP3_QFE-CU).170418-1707 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/d3ec35abc942485580a9d1673071e1b31/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.6598.00 ((SQL11_SP3_QFE-CU).170418-1707 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/85152ea7467b4c35971b9799e7f030831/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.6598.00 ((SQL11_SP3_QFE-CU).170418-1707 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/347f6b20b1a5478781c229edc12b2cf41/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.6598.00 ((SQL11_SP3_QFE-CU).170418-1707 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/4b8824881bc7405588c795aa867da2472/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.6598.00 ((SQL11_SP3_QFE-CU).170418-1707 ) +``` + +# SQL Server 2012 SP3 CU7 - 11.0.6579.0 - x64 (3205051) +``` powershell +# SQL Server 2012 SP3 CU7 - 11.0.6579.0 - x64 (3205051) +$outputFolder = 'c:\sqlsyms\11.0.6579.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/28783150f1ee4dbf92e0499225b7590c2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.6579.00 ((SQL11_SP3_QFE-CU).161222-1109 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/b35286f6930c49498baee55c30e567e12/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.6579.00 ((SQL11_SP3_QFE-CU).161222-1109 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/a4af12434c9a45f4af825680e48e5bc22/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.6579.00 ((SQL11_SP3_QFE-CU).161222-1109 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/2202396e27904e5db4fcd4d60aebdd772/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.6579.00 ((SQL11_SP3_QFE-CU).161222-1109 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/32a77bfd1d1b4845883d79c8419052921/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.6579.00 ((SQL11_SP3_QFE-CU).161222-1109 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/100c11aaf13440b680b44057155c2ef21/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.6579.00 ((SQL11_SP3_QFE-CU).161222-1109 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/cb2b6dce02bd40c996cd811ce13ea91a1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.6579.00 ((SQL11_SP3_QFE-CU).161222-1109 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/5c5db77e2d364209a0f61fda02088cf21/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.6579.00 ((SQL11_SP3_QFE-CU).161222-1109 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/fa9e7bd3ef9343f5b5fcca1334992d431/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.6579.00 ((SQL11_SP3_QFE-CU).161222-1109 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/c5b83c833f6a4c7281841b945028f8782/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.6579.00 ((SQL11_SP3_QFE-CU).161222-1109 ) +``` + +# SQL Server 2012 SP3 CU7 - 11.0.6579.0 - x86 (3205051) +``` powershell +# SQL Server 2012 SP3 CU7 - 11.0.6579.0 - x86 (3205051) +$outputFolder = 'c:\sqlsyms\11.0.6579.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/8a904b0b2b754631a46c28eb44dd2efe2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.6579.00 ((SQL11_SP3_QFE-CU).161222-1119 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/661d636bc116485dbf546433cff31f072/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.6579.00 ((SQL11_SP3_QFE-CU).161222-1119 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/a2bbab93772a4b8b8a4000861e06f5b12/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.6579.00 ((SQL11_SP3_QFE-CU).161222-1119 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/c8e36c6acc1d4447a68859546378d0dd2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.6579.00 ((SQL11_SP3_QFE-CU).161222-1119 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/33976bc0acee45e6a5e6d085068c93f31/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.6579.00 ((SQL11_SP3_QFE-CU).161222-1119 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/18c8de6253374d52aad36a38b127f8661/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.6579.00 ((SQL11_SP3_QFE-CU).161222-1119 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/ae64e50371214599be4a3415deb52fbf1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.6579.00 ((SQL11_SP3_QFE-CU).161222-1119 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/ff1efd45c7b64eed9b641ac980799e6b1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.6579.00 ((SQL11_SP3_QFE-CU).161222-1119 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/5d6dcb597aec4881b9ee9a7a6bf96ba71/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.6579.00 ((SQL11_SP3_QFE-CU).161222-1119 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/b2a6eff3ff774b2e82486d092883df462/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.6579.00 ((SQL11_SP3_QFE-CU).161222-1119 ) +``` + +# SQL Server 2012 SP3 CU6 - 11.0.6567.0 - x64 (3194992) +``` powershell +# SQL Server 2012 SP3 CU6 - 11.0.6567.0 - x64 (3194992) +$outputFolder = 'c:\sqlsyms\11.0.6567.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/bb6184470be14d70a6171a0abf7ff4142/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.6567.00 ((SQL11_SP3_QFE-CU).161010-1832 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/59c4ce23af154338a104308ac0cce6232/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.6567.00 ((SQL11_SP3_QFE-CU).161010-1832 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/add423f0ae3d49d195ce1edd7942d3ed2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.6567.00 ((SQL11_SP3_QFE-CU).161010-1832 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/e618e626a6594d009564091cabd9bc262/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.6567.00 ((SQL11_SP3_QFE-CU).161010-1832 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/ac3e5d1c334f413080dd816bf9d1467e1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.6567.00 ((SQL11_SP3_QFE-CU).161010-1832 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/8b09e558e267408eaeaf87a3a2ee37e71/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.6567.00 ((SQL11_SP3_QFE-CU).161010-1832 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/4f2f41869ac54e899e7ff39319663a651/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.6567.00 ((SQL11_SP3_QFE-CU).161010-1832 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/5c78860cf3644c0d89d0699bf3773bf11/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.6567.00 ((SQL11_SP3_QFE-CU).161010-1832 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/db583d5603bc474b8651922e71e401dc1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.6567.00 ((SQL11_SP3_QFE-CU).161010-1832 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/307d6d9eed7c4d5a953f485db595d2de2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.6567.00 ((SQL11_SP3_QFE-CU).161010-1832 ) +``` + +# SQL Server 2012 SP3 CU6 - 11.0.6567.0 - x86 (3194992) +``` powershell +# SQL Server 2012 SP3 CU6 - 11.0.6567.0 - x86 (3194992) +$outputFolder = 'c:\sqlsyms\11.0.6567.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/6830ed55a6d6494b80e8f5b71fd30d8d2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.6567.00 ((SQL11_SP3_QFE-CU).161010-1959 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/913bea3e2f604ac6b5f2fb46bca63fd22/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.6567.00 ((SQL11_SP3_QFE-CU).161010-1959 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/6bedeb07e9c449cdb0018a92727ced2e2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.6567.00 ((SQL11_SP3_QFE-CU).161010-1959 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/faf3de3ef8714e8a89b7e385a57510412/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.6567.00 ((SQL11_SP3_QFE-CU).161010-1959 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/c266fee436644990b265e7e9151c488f1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.6567.00 ((SQL11_SP3_QFE-CU).161010-1959 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/55260b1f426c40c997183184a77c768e1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.6567.00 ((SQL11_SP3_QFE-CU).161010-1959 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/69f53ff9d9e14a0fbb07e0e80678e3181/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.6567.00 ((SQL11_SP3_QFE-CU).161010-1959 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/4223e10e9d3546a795480e990cc148f31/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.6567.00 ((SQL11_SP3_QFE-CU).161010-1959 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/a813fa0504b6441e81a3be6f20c0bc541/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.6567.00 ((SQL11_SP3_QFE-CU).161010-1959 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/6bef5361c8b84cdfa2cdb9731708a2cb2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.6567.00 ((SQL11_SP3_QFE-CU).161010-1959 ) +``` + +# SQL Server 2012 SP3 CU5 - 11.0.6544.0 - x64 (3180915) +``` powershell +# SQL Server 2012 SP3 CU5 - 11.0.6544.0 - x64 (3180915) +$outputFolder = 'c:\sqlsyms\11.0.6544.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/b3a2c45b9cd04194ad768faff2dd480e1/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2011.0110.6544.00 ((SQL11_SP3_QFE-CU).160829-1346 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/e8b5df585c394779a2ff88a39458ebfa1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.6544.00 ((SQL11_SP3_QFE-CU).160829-1346 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/54542e47b335481cbedba3ad6aca9e9c1/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.6544.00 ((SQL11_SP3_QFE-CU).160829-1346 ) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/02526e38efd34a22892561485c3e93331/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2011.0110.6544.00 ((SQL11_SP3_QFE-CU).160829-1346 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/25eee25e365c452fafba7d762dcb5e211/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.6544.00 ((SQL11_SP3_QFE-CU).160829-1346 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/75c6111e1cc1449bad2112e15cd3302c1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.6544.00 ((SQL11_SP3_QFE-CU).160829-1346 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/d50d043ce4fe402e90a622a378ec8add1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.6544.00 ((SQL11_SP3_QFE-CU).160829-1346 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/7009006d3e944eaa82f52532647ce2651/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.6544.00 ((SQL11_SP3_QFE-CU).160829-1346 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/8e119547cbb34fddafba8c65733b36131/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.6544.00 ((SQL11_SP3_QFE-CU).160829-1346 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/3d8457edc2c348ee870e2df8e0ffb5591/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.6544.00 ((SQL11_SP3_QFE-CU).160829-1346 ) +``` + +# SQL Server 2012 SP3 CU5 - 11.0.6544.0 - x86 (3180915) +``` powershell +# SQL Server 2012 SP3 CU5 - 11.0.6544.0 - x86 (3180915) +$outputFolder = 'c:\sqlsyms\11.0.6544.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/58621a8e7f424ceaaf82b6a8621ad5ae2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.6544.00 ((SQL11_SP3_QFE-CU).160829-1356 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/b5cfcf4e10fc47c9b1c57156d868ea882/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.6544.00 ((SQL11_SP3_QFE-CU).160829-1356 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/7bacebdbc3ef47338dcba37b2d5d42012/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.6544.00 ((SQL11_SP3_QFE-CU).160829-1356 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/c5bf5f4f707a4b86bf1d9ce281f7bc142/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.6544.00 ((SQL11_SP3_QFE-CU).160829-1356 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/f662a0c9bba14a7aa62df4a06b8657271/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.6544.00 ((SQL11_SP3_QFE-CU).160829-1356 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/73b2ad756d314c55814d8d03fc8b7b6c1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.6544.00 ((SQL11_SP3_QFE-CU).160829-1356 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/c06729d83eb1457084c51e25542252781/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.6544.00 ((SQL11_SP3_QFE-CU).160829-1356 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/ee5eff6976704286b8be419395371aac1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.6544.00 ((SQL11_SP3_QFE-CU).160829-1356 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/3f5943d18bf84c9189322c1d5aca2a9a1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.6544.00 ((SQL11_SP3_QFE-CU).160829-1356 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/78d4fff0f00047728cb50cb4211c493d2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.6544.00 ((SQL11_SP3_QFE-CU).160829-1356 ) +``` + +# SQL Server 2012 SP3 CU4 - 11.0.6540.0 - x64 (3165264) +``` powershell +# SQL Server 2012 SP3 CU4 - 11.0.6540.0 - x64 (3165264) +$outputFolder = 'c:\sqlsyms\11.0.6540.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/05130a8e03694effbf4ee0a5d93d6f022/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.6540.00 ((SQL11_SP3_QFE-CU).160623-1731 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/d91b0bd2f080497d8898ca7dc13564e12/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.6540.00 ((SQL11_SP3_QFE-CU).160623-1731 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/ee95fd17ecc14e49a85fcf6d693011042/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.6540.00 ((SQL11_SP3_QFE-CU).160623-1731 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/6b39164c29804cc6b7609f81e04c8bb62/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.6540.00 ((SQL11_SP3_QFE-CU).160623-1731 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/e81c72c3de764c97b5615f32b3d10b5f1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.6540.00 ((SQL11_SP3_QFE-CU).160623-1731 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/c363526150464be9a52a234e681f31ed1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.6540.00 ((SQL11_SP3_QFE-CU).160623-1731 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/b5b55e52e8e04520a7c81e3fd8c1aeeb1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.6540.00 ((SQL11_SP3_QFE-CU).160623-1731 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/971700e9f5c24edb979e7aa0820b71981/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.6540.00 ((SQL11_SP3_QFE-CU).160623-1731 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/13788a023dd542da9822e3eea228db7b1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.6540.00 ((SQL11_SP3_QFE-CU).160623-1731 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/031265bbe1a14ada8f4078c6705f7c4c2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.6540.00 ((SQL11_SP3_QFE-CU).160623-1731 ) +``` + +# SQL Server 2012 SP3 CU4 - 11.0.6540.0 - x86 (3165264) +``` powershell +# SQL Server 2012 SP3 CU4 - 11.0.6540.0 - x86 (3165264) +$outputFolder = 'c:\sqlsyms\11.0.6540.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/7abb3b2c641e462d99e832cfaa77b5022/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.6540.00 ((SQL11_SP3_QFE-CU).160623-1729 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/a3440669ec5541c8a7aafd6b6a7e5c152/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.6540.00 ((SQL11_SP3_QFE-CU).160623-1729 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/b031eefe7864472ab762aa98e16b11142/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.6540.00 ((SQL11_SP3_QFE-CU).160623-1729 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/765547fd40cc4aef80ec1b3dd8f0a9292/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.6540.00 ((SQL11_SP3_QFE-CU).160623-1729 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/7651776a76644a30b6a8d7ecdd1d24d11/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.6540.00 ((SQL11_SP3_QFE-CU).160623-1729 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/1de5f51195b54e5eb12f2f56f6237a041/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.6540.00 ((SQL11_SP3_QFE-CU).160623-1729 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/2cc47be0bc3e4cf7b0c0aebac03b08a11/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.6540.00 ((SQL11_SP3_QFE-CU).160623-1729 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/2f3cb78d00b54698824e73ac44b2f9bc1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.6540.00 ((SQL11_SP3_QFE-CU).160623-1729 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/18bb1bb91f9a4ba78e00ea92bc40fe121/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.6540.00 ((SQL11_SP3_QFE-CU).160623-1729 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/b14e40ff51364430b7bed58f8b44cef72/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.6540.00 ((SQL11_SP3_QFE-CU).160623-1729 ) +``` + +# SQL Server 2012 SP3 CU3 - 11.0.6537.0 - x64 (3152635) +``` powershell +# SQL Server 2012 SP3 CU3 - 11.0.6537.0 - x64 (3152635) +$outputFolder = 'c:\sqlsyms\11.0.6537.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/784b2d2a11f4459784a98a777a61e39e2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.6537.00 ((SQL11_SP3_QFE-CU).160428-1744 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/41074d77469a4e0e9217c8e29cb4ed772/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.6537.00 ((SQL11_SP3_QFE-CU).160428-1744 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/a01672c248514057a59d13e89ce93b0f2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.6537.00 ((SQL11_SP3_QFE-CU).160428-1744 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/d5d1a87d5e764f29b202493cbcba3d082/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.6537.00 ((SQL11_SP3_QFE-CU).160428-1744 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/cf422a9dbb8340a5b5000ab5dbd4f4e91/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.6537.00 ((SQL11_SP3_QFE-CU).160428-1744 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/a803eeca499b45fbb53081e01c86e0571/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.6537.00 ((SQL11_SP3_QFE-CU).160428-1744 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/7335b11661aa48f298d976a2448c6f6a1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.6537.00 ((SQL11_SP3_QFE-CU).160428-1744 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/b027f13eb4994ee99ecc152c282fbb581/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.6537.00 ((SQL11_SP3_QFE-CU).160428-1744 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/c99210c7d2ff447c98494bb5c241af8c1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.6537.00 ((SQL11_SP3_QFE-CU).160428-1744 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/dcdc7cc5bfba4aa38c320285a6cdcbaa2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.6537.00 ((SQL11_SP3_QFE-CU).160428-1744 ) +``` + +# SQL Server 2012 SP3 CU3 - 11.0.6537.0 - x86 (3152635) +``` powershell +# SQL Server 2012 SP3 CU3 - 11.0.6537.0 - x86 (3152635) +$outputFolder = 'c:\sqlsyms\11.0.6537.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/87293ca873904ed2b56237e34e3e1f1a2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.6537.00 ((SQL11_SP3_QFE-CU).160428-1744 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/e43071f0910a4ea7bf86b1d5ccc3fd3a2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.6537.00 ((SQL11_SP3_QFE-CU).160428-1744 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/c8f9372146b044febc8ccce8b3c2b1c12/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.6537.00 ((SQL11_SP3_QFE-CU).160428-1744 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/0270b86f2c75487194f651d075a34e5c2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.6537.00 ((SQL11_SP3_QFE-CU).160428-1744 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/4341ceb14e534bb5924ea613956c20361/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.6537.00 ((SQL11_SP3_QFE-CU).160428-1744 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/85fe76a3ab4547f1b1cfad36f43712371/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.6537.00 ((SQL11_SP3_QFE-CU).160428-1744 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/b62e092daed64119808aa2f71fdf41051/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.6537.00 ((SQL11_SP3_QFE-CU).160428-1744 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/91e900c8fc1b4d7f81cbc2e79afbfadc1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.6537.00 ((SQL11_SP3_QFE-CU).160428-1744 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/d39bca94636a4cf0bbeffedf2073f5551/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.6537.00 ((SQL11_SP3_QFE-CU).160428-1744 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/6065f2fd7ce6477bb93ff9dd4b74897a2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.6537.00 ((SQL11_SP3_QFE-CU).160428-1744 ) +``` + +# SQL Server 2012 SP3 CU2 - 11.0.6523.0 - x64 (3137746) +``` powershell +# SQL Server 2012 SP3 CU2 - 11.0.6523.0 - x64 (3137746) +$outputFolder = 'c:\sqlsyms\11.0.6523.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/fcafe44179a349b4b1a42e17631445382/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.6523.00 ((SQL11_SP3_QFE-CU).160302-2113 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/04ab05307b834b1e93aaa5957b68ce492/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.6523.00 ((SQL11_SP3_QFE-CU).160302-2113 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/10d09d86092f400aac076647eeca36492/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.6523.00 ((SQL11_SP3_QFE-CU).160302-2113 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/af7848b84c93447291909dd6fed24bfa2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.6523.00 ((SQL11_SP3_QFE-CU).160302-2113 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/79347e6e63ee4aa7a267ddb157777b3c1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.6523.00 ((SQL11_SP3_QFE-CU).160302-2113 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/7a3302ffc3a643eab7a0eb0a777222d01/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.6523.00 ((SQL11_SP3_QFE-CU).160302-2113 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/d12619783d1247e29e210143f65ebd4f1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.6523.00 ((SQL11_SP3_QFE-CU).160302-2113 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/74204f690ddd470aa8ba6d534f4b07441/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.6523.00 ((SQL11_SP3_QFE-CU).160302-2113 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/0045a36c9f7e4dca997063b212dc62291/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.6523.00 ((SQL11_SP3_QFE-CU).160302-2113 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/86c28146977b477e8bc99340ad0107ff2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.6523.00 ((SQL11_SP3_QFE-CU).160302-2113 ) +``` + +# SQL Server 2012 SP3 CU2 - 11.0.6523.0 - x86 (3137746) +``` powershell +# SQL Server 2012 SP3 CU2 - 11.0.6523.0 - x86 (3137746) +$outputFolder = 'c:\sqlsyms\11.0.6523.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/68a1704d4c60484abdab611a4011ebd22/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.6523.00 ((SQL11_SP3_QFE-CU).160302-2116 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/2b713f51cb3a475c8a0ade5063d183c52/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.6523.00 ((SQL11_SP3_QFE-CU).160302-2116 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/a9139393e7d148949351243a6f2e60372/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.6523.00 ((SQL11_SP3_QFE-CU).160302-2116 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/84966d1d5e904eeda26c06b58e1d8dbb2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.6523.00 ((SQL11_SP3_QFE-CU).160302-2116 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/de7fcca82fa446358962e3106fa609be1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.6523.00 ((SQL11_SP3_QFE-CU).160302-2116 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/39a1b26dcdea427fb467b9aefff863f51/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.6523.00 ((SQL11_SP3_QFE-CU).160302-2116 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/c5f85db1be474d0dbf027a0374de6e9a1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.6523.00 ((SQL11_SP3_QFE-CU).160302-2116 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/49835c6b775c4d9db7d3415b2b59ca741/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.6523.00 ((SQL11_SP3_QFE-CU).160302-2116 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/d74fca8456884c6a9b58acd70da167251/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.6523.00 ((SQL11_SP3_QFE-CU).160302-2116 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/e1d2fd01359645a69447f78c6a39beda2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.6523.00 ((SQL11_SP3_QFE-CU).160302-2116 ) +``` + +# SQL Server 2012 SP3 CU1 - 11.0.6518.0 - x64 (3123299) +``` powershell +# SQL Server 2012 SP3 CU1 - 11.0.6518.0 - x64 (3123299) +$outputFolder = 'c:\sqlsyms\11.0.6518.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/a311f07702a44e019573de6bc28d9a802/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.6518.00 ((SQL11_SP3_QFE-CU).160107-1429 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/122248fa6f9643ffaa1d4b98a8b852892/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.6518.00 ((SQL11_SP3_QFE-CU).160107-1429 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/9d9fff96ee2d47fb8d4a1694bf0bc01a2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.6518.00 ((SQL11_SP3_QFE-CU).160107-1429 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/007a1b4b3ac941cab55a979ce199b3cd2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.6518.00 ((SQL11_SP3_QFE-CU).160107-1429 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/8419c4bbf0b844879129f25d50eda11d1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.6518.00 ((SQL11_SP3_QFE-CU).160107-1429 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/ab53bf1c7c5b415489b8dad9527aaef71/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.6518.00 ((SQL11_SP3_QFE-CU).160107-1429 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/f6d8f219eb804aeeb61e15c17855fa351/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.6518.00 ((SQL11_SP3_QFE-CU).160107-1429 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/d6e72bc2815a411e803c12d5a757e6c21/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.6518.00 ((SQL11_SP3_QFE-CU).160107-1429 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/5f78f36cf3c64d4d8bbf5ae5b8506a5d1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.6518.00 ((SQL11_SP3_QFE-CU).160107-1429 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/466c40a06fe8457a88ac5b2ac31bb8012/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.6518.00 ((SQL11_SP3_QFE-CU).160107-1429 ) +``` + +# SQL Server 2012 SP3 CU1 - 11.0.6518.0 - x86 (3123299) +``` powershell +# SQL Server 2012 SP3 CU1 - 11.0.6518.0 - x86 (3123299) +$outputFolder = 'c:\sqlsyms\11.0.6518.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/85e2f9abea704a94a052cfe9a6dee0572/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.6518.00 ((SQL11_SP3_QFE-CU).160107-1429 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/1522388b2b31493585a6e2b4f2624aa12/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.6518.00 ((SQL11_SP3_QFE-CU).160107-1429 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/2ada5d3381bf4c93aeb02541e200f17b2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.6518.00 ((SQL11_SP3_QFE-CU).160107-1429 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/70b02e6179e54640b5dcc09743e445ee2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.6518.00 ((SQL11_SP3_QFE-CU).160107-1429 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/92fe1e276d4f424988cce512111d09151/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.6518.00 ((SQL11_SP3_QFE-CU).160107-1429 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/a704e7ede8b04298b150daaa93ba4d8f1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.6518.00 ((SQL11_SP3_QFE-CU).160107-1429 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/9040b150117a4e44a073e50d38297c051/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.6518.00 ((SQL11_SP3_QFE-CU).160107-1429 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/2599461ed95c4636bf1b1b4467a5d1e21/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.6518.00 ((SQL11_SP3_QFE-CU).160107-1429 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/9b6afd69a5674b42b6876b28a79d8c161/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.6518.00 ((SQL11_SP3_QFE-CU).160107-1429 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/799ab84cc9fe4b8a9cff76c808c5669c2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.6518.00 ((SQL11_SP3_QFE-CU).160107-1429 ) +``` + +# SQL Server 2012 SP3 SP3 - 11.0.6020.0 - x64 (3072779) +``` powershell +# SQL Server 2012 SP3 SP3 - 11.0.6020.0 - x64 (3072779) +$outputFolder = 'c:\sqlsyms\11.0.6020.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/8c2548391c41414994a23eb9e1ffbc5d2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.6020.00 ((SQL11_PCU_Main).151020-1526 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/8bcf882af198453eae955b7af05df27a2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.6020.00 ((SQL11_PCU_Main).151020-1526 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/3811dbbc84c44f0d979c674cd571926a2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.6020.00 ((SQL11_PCU_Main).151020-1526 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/eb85f8ee377f43f9afed8cd2e9c932192/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.6020.00 ((SQL11_PCU_Main).151020-1526 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/a017c07601cf4596a671f7b35a4119bd1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.6020.00 ((SQL11_PCU_Main).151020-1526 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/b287171e30de46d48bc5e4f50d321d511/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.6020.00 ((SQL11_PCU_Main).151020-1526 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/50aca007a677401f99a7ad15b4631f101/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.6020.00 ((SQL11_PCU_Main).151020-1526 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/cebe10126c694f9089577dc49f71d20e1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.6020.00 ((SQL11_PCU_Main).151020-1526 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/ae66568baac84d068167d6a4a1cd7b001/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.6020.00 ((SQL11_PCU_Main).151020-1526 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/d7c6e98402ea495fa3da17f1aecb29ba2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.6020.00 ((SQL11_PCU_Main).151020-1526 ) +``` + +# SQL Server 2012 SP3 SP3 - 11.0.6020.0 - x86 (3072779) +``` powershell +# SQL Server 2012 SP3 SP3 - 11.0.6020.0 - x86 (3072779) +$outputFolder = 'c:\sqlsyms\11.0.6020.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/9c88c47ad634432f947247b93a4c437a2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.6020.00 ((SQL11_PCU_Main).151020-1525 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/70e38bc1d979482ab3577c81191a07892/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.6020.00 ((SQL11_PCU_Main).151020-1525 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/a71c6013ff7e4b4188afe07b47e9d5112/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.6020.00 ((SQL11_PCU_Main).151020-1525 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/fe998ea9010c43c090935a171585c9152/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.6020.00 ((SQL11_PCU_Main).151020-1525 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/1066d39f48fb4eefbd1096712687a1811/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.6020.00 ((SQL11_PCU_Main).151020-1525 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/b4529742a01b4ee88d17228b861439c21/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.6020.00 ((SQL11_PCU_Main).151020-1525 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/49a2aab10cb04420b666377d96ec5b731/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.6020.00 ((SQL11_PCU_Main).151020-1525 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/5894cb69e99141c1b730209ff772dcb81/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.6020.00 ((SQL11_PCU_Main).151020-1525 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/21ae50d9944c4af2b2868123b95b46591/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.6020.00 ((SQL11_PCU_Main).151020-1525 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/12ddb13831544b28b5f8a4c017d0efa92/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.6020.00 ((SQL11_PCU_Main).151020-1525 ) +``` + +# SQL Server 2012 SP2 CU16 - 11.0.5678.0 - x64 (3205054) +``` powershell +# SQL Server 2012 SP2 CU16 - 11.0.5678.0 - x64 (3205054) +$outputFolder = 'c:\sqlsyms\11.0.5678.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/db25800662db4aa5abc2fe3b1dfa40892/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5678.00 ((SQL11_SP2_QFE-CU).161216-1503 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/c2962322b56545e18fdd1947d7a3f5552/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5678.00 ((SQL11_SP2_QFE-CU).161216-1503 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/26e55d51a2524f8f9c3eb14a9c0a5e7f2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5678.00 ((SQL11_SP2_QFE-CU).161216-1503 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/3f7c15db3e80428d842dc6577dbe957b2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5678.00 ((SQL11_SP2_QFE-CU).161216-1503 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/102484c88a7a454e94a5b6fd7baf00a11/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5678.00 ((SQL11_SP2_QFE-CU).161216-1503 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/6ccba8f0e4194a70a33c5969a18ee7a41/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5678.00 ((SQL11_SP2_QFE-CU).161216-1503 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/5006d5458a6049588ec4c1e0043b13a61/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5678.00 ((SQL11_SP2_QFE-CU).161216-1503 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/c30cda3d5e9f47378676888347f958991/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5678.00 ((SQL11_SP2_QFE-CU).161216-1503 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/8979dfe9d46a474a9c4ceba886d148071/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5678.00 ((SQL11_SP2_QFE-CU).161216-1503 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/a62693b04bed4018829db79c6e9014242/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5678.00 ((SQL11_SP2_QFE-CU).161216-1503 ) +``` + +# SQL Server 2012 SP2 CU16 - 11.0.5678.0 - x86 (3205054) +``` powershell +# SQL Server 2012 SP2 CU16 - 11.0.5678.0 - x86 (3205054) +$outputFolder = 'c:\sqlsyms\11.0.5678.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/c7c7b2fbe65140d48fbfb488363088822/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5678.00 ((SQL11_SP2_QFE-CU).161216-1502 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/b4a31b7568c54b6db1e29cfd4a8c62a12/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5678.00 ((SQL11_SP2_QFE-CU).161216-1502 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/05099346226d439f95d2dc50d23f84042/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5678.00 ((SQL11_SP2_QFE-CU).161216-1502 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/b1228bc7d3284c2bb2716e659b542b5f2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5678.00 ((SQL11_SP2_QFE-CU).161216-1502 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/e3c2403ccac246f7945b28cf1636d68b1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5678.00 ((SQL11_SP2_QFE-CU).161216-1502 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/f9706bb17f8b42128c9a74895ba068091/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5678.00 ((SQL11_SP2_QFE-CU).161216-1502 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/6aad5ebf336a4352be93b0cd1283f3901/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5678.00 ((SQL11_SP2_QFE-CU).161216-1502 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/7ce1f1a9129c489e9358e13dbd8dd6d51/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5678.00 ((SQL11_SP2_QFE-CU).161216-1502 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/08ec37d9396e469a97fa1884e4f3126b1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5678.00 ((SQL11_SP2_QFE-CU).161216-1502 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/cf639729d8724367a1e99d7dce200cc82/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5678.00 ((SQL11_SP2_QFE-CU).161216-1502 ) +``` + +# SQL Server 2012 SP2 CU15 - 11.0.5676.0 - x64 (3205416) +``` powershell +# SQL Server 2012 SP2 CU15 - 11.0.5676.0 - x64 (3205416) +$outputFolder = 'c:\sqlsyms\11.0.5676.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/dd1ba68516834e3eac8754e0c3f763a62/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5676.00 ((SQL11_SP2_QFE-CU).161010-1819 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/d4489a41a7864f41a583d818941820bb2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5676.00 ((SQL11_SP2_QFE-CU).161010-1819 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/96ba3b4dada540baae72f7ac5d372c562/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5676.00 ((SQL11_SP2_QFE-CU).161010-1819 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/58ff259b5717420199bdca05ad6475fa2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5676.00 ((SQL11_SP2_QFE-CU).161010-1819 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/243641435747432bb7cb32747fbb096e1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5676.00 ((SQL11_SP2_QFE-CU).161010-1819 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/d972cc8d2f0c47ec8f219ea7d4152cca1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5676.00 ((SQL11_SP2_QFE-CU).161010-1819 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/5b9529c4d43b4f79ae09b990a453ef2e1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5676.00 ((SQL11_SP2_QFE-CU).161010-1819 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/1e8ddd5ae37c49c98e758b3fd246d4971/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5676.00 ((SQL11_SP2_QFE-CU).161010-1819 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/06783190c3eb47438d51e209b2b15b4a1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5676.00 ((SQL11_SP2_QFE-CU).161010-1819 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/acab102088fb4de3aea8154c3d3073c22/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5676.00 ((SQL11_SP2_QFE-CU).161010-1819 ) +``` + +# SQL Server 2012 SP2 CU15 - 11.0.5676.0 - x86 (3205416) +``` powershell +# SQL Server 2012 SP2 CU15 - 11.0.5676.0 - x86 (3205416) +$outputFolder = 'c:\sqlsyms\11.0.5676.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/c5dce76c002d40228af8b7f4334c43382/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5676.00 ((SQL11_SP2_QFE-CU).161010-1819 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/f9ca6e1c1c5a48509ef17541f440110d2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5676.00 ((SQL11_SP2_QFE-CU).161010-1819 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/a65a7dbefb534977862075b5592cbea22/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5676.00 ((SQL11_SP2_QFE-CU).161010-1819 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/2d77fbddcd3c461788cbbc876813d8672/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5676.00 ((SQL11_SP2_QFE-CU).161010-1819 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/3350d6c06cda4237b5522c0ce229d61e1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5676.00 ((SQL11_SP2_QFE-CU).161010-1819 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/08912861adab4657b566a71ce625b5df1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5676.00 ((SQL11_SP2_QFE-CU).161010-1819 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/591d683835904ed6936cc8c15d53bb271/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5676.00 ((SQL11_SP2_QFE-CU).161010-1819 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/beb991341db6464ba3e901e618e4141c1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5676.00 ((SQL11_SP2_QFE-CU).161010-1819 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/01e137606c424aaea4b7ad65fda59f4a1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5676.00 ((SQL11_SP2_QFE-CU).161010-1819 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/afaeeb6537af486eba72087380814b682/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5676.00 ((SQL11_SP2_QFE-CU).161010-1819 ) +``` + +# SQL Server 2012 SP2 CU14 - 11.0.5657.0 - x64 (3180914) +``` powershell +# SQL Server 2012 SP2 CU14 - 11.0.5657.0 - x64 (3180914) +$outputFolder = 'c:\sqlsyms\11.0.5657.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/25d44c4a218a45e69440f64a6c2f39022/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5657.00 ((SQL11_SP2_QFE-CU).160825-1743 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/4ef82375cf4e42a8be639daea082a4c52/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5657.00 ((SQL11_SP2_QFE-CU).160825-1743 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/ca2d467f8210454ea0b0f9e80185f22a2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5657.00 ((SQL11_SP2_QFE-CU).160825-1743 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/d89b853ec00c4ef4a2ff7439eebe952c2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5657.00 ((SQL11_SP2_QFE-CU).160825-1743 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/87f21dcc1cd04ac3b90b4a6ae1e428201/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5657.00 ((SQL11_SP2_QFE-CU).160825-1743 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/e5104d3be08248348393b672b2a9bb0a1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5657.00 ((SQL11_SP2_QFE-CU).160825-1743 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/ac3edf92e6ec4a12bb6533025087bf2f1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5657.00 ((SQL11_SP2_QFE-CU).160825-1743 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/821c2909862a40bdb68783eb23929cc31/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5657.00 ((SQL11_SP2_QFE-CU).160825-1743 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/d1c8cae724694f6bb2962cdc83f4329e1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5657.00 ((SQL11_SP2_QFE-CU).160825-1743 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/a4a3c0bd71ad4f85bb1e8b97eb7b18862/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5657.00 ((SQL11_SP2_QFE-CU).160825-1743 ) +``` + +# SQL Server 2012 SP2 CU14 - 11.0.5657.0 - x86 (3180914) +``` powershell +# SQL Server 2012 SP2 CU14 - 11.0.5657.0 - x86 (3180914) +$outputFolder = 'c:\sqlsyms\11.0.5657.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/ce78955c784c48afa622c25baf31d45b2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5657.00 ((SQL11_SP2_QFE-CU).160825-1749 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/213855c2ec884f97896f2de644073c0e2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5657.00 ((SQL11_SP2_QFE-CU).160825-1749 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/6aba2304025c482694789dfa59caa53d2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5657.00 ((SQL11_SP2_QFE-CU).160825-1749 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/140309b667144067ab36b0dbd619c6592/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5657.00 ((SQL11_SP2_QFE-CU).160825-1749 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/c3de962144364bee8d4f28ef8a9244911/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5657.00 ((SQL11_SP2_QFE-CU).160825-1749 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/1ceb4d2de2a44439a8704ea70320c65e1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5657.00 ((SQL11_SP2_QFE-CU).160825-1749 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/73272f461ea94ba19eab4f80bad006f01/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5657.00 ((SQL11_SP2_QFE-CU).160825-1749 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/4326574b01f6436a833579f838b757e21/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5657.00 ((SQL11_SP2_QFE-CU).160825-1749 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/8b38568a4a9f49c8b3aec36e8b5a71f41/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5657.00 ((SQL11_SP2_QFE-CU).160825-1749 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/bf3d3e6661b04901834ca05fc19a44352/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5657.00 ((SQL11_SP2_QFE-CU).160825-1749 ) +``` + +# SQL Server 2012 SP2 CU13 - 11.0.5655.0 - x64 (3165266) +``` powershell +# SQL Server 2012 SP2 CU13 - 11.0.5655.0 - x64 (3165266) +$outputFolder = 'c:\sqlsyms\11.0.5655.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/a433571fbd0c41f5ac4d33283de127002/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5655.00 ((SQL11_SP2_QFE-CU).160705-1418 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/960013cc86c5408f9808f8378e2da08a2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5655.00 ((SQL11_SP2_QFE-CU).160705-1418 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/171ddb83c0474edf824711de922e0a172/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5655.00 ((SQL11_SP2_QFE-CU).160705-1418 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/4747e8ca27484a8199bb39b14f211c302/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5655.00 ((SQL11_SP2_QFE-CU).160705-1418 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/69db5fdaa93f408890a49893da554dbb1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5655.00 ((SQL11_SP2_QFE-CU).160705-1418 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/2e74440521ea4986a0b4eb23a776f3d01/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5655.00 ((SQL11_SP2_QFE-CU).160705-1418 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/8b3231d270724bdc997c398a178833891/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5655.00 ((SQL11_SP2_QFE-CU).160705-1418 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/a730d9127fc74a9b9ab5c74334bebfe71/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5655.00 ((SQL11_SP2_QFE-CU).160705-1418 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/9c5081d580624480aab3f8894169a9581/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5655.00 ((SQL11_SP2_QFE-CU).160705-1418 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/519331463ede472796ee00b4dbd637042/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5655.00 ((SQL11_SP2_QFE-CU).160705-1418 ) +``` + +# SQL Server 2012 SP2 CU13 - 11.0.5655.0 - x86 (3165266) +``` powershell +# SQL Server 2012 SP2 CU13 - 11.0.5655.0 - x86 (3165266) +$outputFolder = 'c:\sqlsyms\11.0.5655.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/a40567d01f594052a94636f0cd569c541/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2011.0110.5655.00 ((SQL11_SP2_QFE-CU).160705-1417 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/6f33217e9aa04118a60392866667a4dd1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5655.00 ((SQL11_SP2_QFE-CU).160705-1417 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/a082374fd27f42d8aeb194286aa2f6051/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5655.00 ((SQL11_SP2_QFE-CU).160705-1417 ) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/8877e5f396644ace9da54a50dd1d9e621/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2011.0110.5655.00 ((SQL11_SP2_QFE-CU).160705-1417 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/28f1fa69afaf411b9febdf147cd1175a1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5655.00 ((SQL11_SP2_QFE-CU).160705-1417 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/3d0122e1b8b845c3a2e8aba23fe95f521/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5655.00 ((SQL11_SP2_QFE-CU).160705-1417 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/4ba3538fcd764fc18b0042deb7c698781/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5655.00 ((SQL11_SP2_QFE-CU).160705-1417 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/d06fc9adef414529902a650201013aa21/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5655.00 ((SQL11_SP2_QFE-CU).160705-1417 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/0f5b5abc62a743e3bbd0782075ef62371/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5655.00 ((SQL11_SP2_QFE-CU).160705-1417 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/67f36d2c92b743e5aff3dc36ae129fc41/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5655.00 ((SQL11_SP2_QFE-CU).160705-1417 ) +``` + +# SQL Server 2012 SP2 CU12 - 11.0.5649.0 - x64 (3152637) +``` powershell +# SQL Server 2012 SP2 CU12 - 11.0.5649.0 - x64 (3152637) +$outputFolder = 'c:\sqlsyms\11.0.5649.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/3b91a33f51794e3caa45dae0a72e3c9e2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5649.00 ((SQL11_SP2_QFE-CU).160424-0952 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/8981f04bfc6b49b1bc366fdbba7ac9bc2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5649.00 ((SQL11_SP2_QFE-CU).160424-0952 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/ff6907a9682d4b2c8211be8b09ca3cb42/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5649.00 ((SQL11_SP2_QFE-CU).160424-0952 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/b7f62a1ca0024f608c64c70ab25f49e32/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5649.00 ((SQL11_SP2_QFE-CU).160424-0952 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/20533819d052436b9f11657e00a25c3e1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5649.00 ((SQL11_SP2_QFE-CU).160424-0952 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/4aad9e292bf548faae06ff8ae1d430b31/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5649.00 ((SQL11_SP2_QFE-CU).160424-0952 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/0fa56d3b36df453db62d14d6baf90bb41/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5649.00 ((SQL11_SP2_QFE-CU).160424-0952 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/454c0beb41f946d99f097261b0177c841/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5649.00 ((SQL11_SP2_QFE-CU).160424-0952 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/c8f5be043d814c118f23709c4a1ad1181/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5649.00 ((SQL11_SP2_QFE-CU).160424-0952 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/44f0c5b99ab343e28ab8711fa9bb2a272/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5649.00 ((SQL11_SP2_QFE-CU).160424-0952 ) +``` + +# SQL Server 2012 SP2 CU12 - 11.0.5649.0 - x86 (3152637) +``` powershell +# SQL Server 2012 SP2 CU12 - 11.0.5649.0 - x86 (3152637) +$outputFolder = 'c:\sqlsyms\11.0.5649.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/0a81fe91a80c4005abc46c2263f09c4c2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5649.00 ((SQL11_SP2_QFE-CU).160424-1132 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/e3044265c315485f8812fef56a7e73b72/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5649.00 ((SQL11_SP2_QFE-CU).160424-1132 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/334ddc7a968042d58e7f62f9a365c1852/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5649.00 ((SQL11_SP2_QFE-CU).160424-1132 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/76854cf991784573858a7b60962f93232/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5649.00 ((SQL11_SP2_QFE-CU).160424-1132 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/d1dde76542a9427ebecb65f2468b91ce1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5649.00 ((SQL11_SP2_QFE-CU).160424-1132 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/29d1f01b3bb84da780dddb33213dbcf31/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5649.00 ((SQL11_SP2_QFE-CU).160424-1132 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/9de157e8d6f54db7b98a7502b94577641/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5649.00 ((SQL11_SP2_QFE-CU).160424-1132 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/e8541edbbfc0410d9b82e6ab78fc2ef01/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5649.00 ((SQL11_SP2_QFE-CU).160424-1132 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/f31f3117b463455688edb8b0f8163a401/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5649.00 ((SQL11_SP2_QFE-CU).160424-1132 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/e3318525756c429c81667cb043abadba2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5649.00 ((SQL11_SP2_QFE-CU).160424-1132 ) +``` + +# SQL Server 2012 SP2 CU11 - 11.0.5646.0 - x64 (3137745) +``` powershell +# SQL Server 2012 SP2 CU11 - 11.0.5646.0 - x64 (3137745) +$outputFolder = 'c:\sqlsyms\11.0.5646.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/cd7a679d23ce4318ae4f9bd42021a1712/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5646.00 ((SQL11_SP2_QFE-CU).160226-1734 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/90d74a8ca29a4f30944f5fdfaba0c83c2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5646.00 ((SQL11_SP2_QFE-CU).160226-1734 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/14a616d4d2fe48f293fdb04ccae512bd2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5646.00 ((SQL11_SP2_QFE-CU).160226-1734 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/a91a9c36928443ab880573c213736a0b2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5646.00 ((SQL11_SP2_QFE-CU).160226-1734 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/40dd4867eec84f79bc2e0b16c8a88f121/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5646.00 ((SQL11_SP2_QFE-CU).160226-1734 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/3a605746326140df8f9996070fe654b11/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5646.00 ((SQL11_SP2_QFE-CU).160226-1734 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/c9718e636e7c4b4e8c0353b5a5a9deae1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5646.00 ((SQL11_SP2_QFE-CU).160226-1734 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/eb2f543f9569417e9664bdae69d903ac1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5646.00 ((SQL11_SP2_QFE-CU).160226-1734 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/f16396e855d64f2b9db73963a1f31e591/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5646.00 ((SQL11_SP2_QFE-CU).160226-1734 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/856db9275d4b49bea827cbdd41a9afe42/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5646.00 ((SQL11_SP2_QFE-CU).160226-1734 ) +``` + +# SQL Server 2012 SP2 CU11 - 11.0.5646.0 - x86 (3137745) +``` powershell +# SQL Server 2012 SP2 CU11 - 11.0.5646.0 - x86 (3137745) +$outputFolder = 'c:\sqlsyms\11.0.5646.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/1747440228a742e590232cb45d5be3b72/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5646.00 ((SQL11_SP2_QFE-CU).160226-1735 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/95cfc60f73d24ed7b89a90a7ebbbaeef2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5646.00 ((SQL11_SP2_QFE-CU).160226-1735 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/0c6c10d175a6457d8d7c6ffad717539d2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5646.00 ((SQL11_SP2_QFE-CU).160226-1735 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/05b4ccc988ff4e5ebcc0702b5833f2db2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5646.00 ((SQL11_SP2_QFE-CU).160226-1735 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/5452aac59a3148ee8502ba3f365c7f501/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5646.00 ((SQL11_SP2_QFE-CU).160226-1735 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/018af0e7122742feb5a7332e671946771/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5646.00 ((SQL11_SP2_QFE-CU).160226-1735 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/8b0d9d31c92147c2a83d337704ddd4641/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5646.00 ((SQL11_SP2_QFE-CU).160226-1735 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/56d0425cc87a4fcbb066efb003b8f9fc1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5646.00 ((SQL11_SP2_QFE-CU).160226-1735 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/ee1d6435917a4f9885af79e50b4d37321/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5646.00 ((SQL11_SP2_QFE-CU).160226-1735 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/6fa82e53cc59482a9fa430a99730f6222/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5646.00 ((SQL11_SP2_QFE-CU).160226-1735 ) +``` + +# SQL Server 2012 SP2 CU10 - 11.0.5644.2 - x64 (3120313) +``` powershell +# SQL Server 2012 SP2 CU10 - 11.0.5644.2 - x64 (3120313) +$outputFolder = 'c:\sqlsyms\11.0.5644.2\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/d8768549cb5345399f4fe1cea88794752/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5644.02 ((SQL11_SP2_QFE-CU).160107-2337 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/2cfeaeeffde843899bf0085a1fe229fc2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5644.02 ((SQL11_SP2_QFE-CU).160107-2337 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/9255e9211d0f41edb184f4c128e449062/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5644.02 ((SQL11_SP2_QFE-CU).160107-2337 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/1f9672b7fd7e4c04a13e4623c116288c2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5644.02 ((SQL11_SP2_QFE-CU).160107-2337 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/65527fa7b46a4ba48843ac5ca4f6c91a1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5644.02 ((SQL11_SP2_QFE-CU).160107-2337 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/aec37a7322154ab0a71d747d9318ad461/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5644.02 ((SQL11_SP2_QFE-CU).160107-2337 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/3c1d262015bf4d089e3dd11a7735ce971/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5644.02 ((SQL11_SP2_QFE-CU).160107-2337 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/998be39e1a234448be37b1e13fe86d7e1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5644.02 ((SQL11_SP2_QFE-CU).160107-2337 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/9ce5afd549134784a502ca2c56a422ea1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5644.02 ((SQL11_SP2_QFE-CU).160107-2337 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/e3a30191df804683ace74857f09b14582/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5644.02 ((SQL11_SP2_QFE-CU).160107-2337 ) +``` + +# SQL Server 2012 SP2 CU10 - 11.0.5644.2 - x86 (3120313) +``` powershell +# SQL Server 2012 SP2 CU10 - 11.0.5644.2 - x86 (3120313) +$outputFolder = 'c:\sqlsyms\11.0.5644.2\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/7826cfcc93bd484fabcb123fb93136b72/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5644.02 ((SQL11_SP2_QFE-CU).160107-2309 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/030e8e2257cc4ca6a2e48a05ce239b412/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5644.02 ((SQL11_SP2_QFE-CU).160107-2309 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/94778bf7d845444cb650904ec51e75442/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5644.02 ((SQL11_SP2_QFE-CU).160107-2309 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/7b2d129b95e040ebbb027cef893c7f332/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5644.02 ((SQL11_SP2_QFE-CU).160107-2309 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/d7c79fd24b5e456dad7ec1547ddc46821/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5644.02 ((SQL11_SP2_QFE-CU).160107-2309 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/ba92ea50bd6a44f28a8fd9559f5394d81/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5644.02 ((SQL11_SP2_QFE-CU).160107-2309 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/c0db7d5acd534245b1bd9c10c425335f1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5644.02 ((SQL11_SP2_QFE-CU).160107-2309 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/d7942859fe6849968b3b484e5c17a03b1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5644.02 ((SQL11_SP2_QFE-CU).160107-2309 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/7f570e9d52e1447ab60d9b9fa8354e761/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5644.02 ((SQL11_SP2_QFE-CU).160107-2309 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/dbd7a81924634685b9cffd5c3cb533a62/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5644.02 ((SQL11_SP2_QFE-CU).160107-2309 ) +``` + +# SQL Server 2012 SP2 CU9 - 11.0.5641.0 - x64 (3098512) +``` powershell +# SQL Server 2012 SP2 CU9 - 11.0.5641.0 - x64 (3098512) +$outputFolder = 'c:\sqlsyms\11.0.5641.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/a521723dc40a41ae90e5d3f588fa0ccf2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5641.00 ((SQL11_SP2_QFE-CU).151020-1624 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/8321e31318604a69993a346d0006baa02/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5641.00 ((SQL11_SP2_QFE-CU).151020-1624 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/9d8402c7dd2a49b0b16ed33e0a4beb322/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5641.00 ((SQL11_SP2_QFE-CU).151020-1624 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/00ebaef66b3e4232a2e59b4cb1b0f0de2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5641.00 ((SQL11_SP2_QFE-CU).151020-1624 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/b1d05b1c84dd431a8f41ffb65bb657021/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5641.00 ((SQL11_SP2_QFE-CU).151020-1624 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/22bc0604c1d54b8c8d826ee74708cc431/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5641.00 ((SQL11_SP2_QFE-CU).151020-1624 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/6aa02f4cf90e431e96f5ed3610a5c8561/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5641.00 ((SQL11_SP2_QFE-CU).151020-1624 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/19b09216c02f4f79954d0bc4dd86deb31/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5641.00 ((SQL11_SP2_QFE-CU).151020-1624 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/63f7a395d7c345f182d3cb93ce1065f61/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5641.00 ((SQL11_SP2_QFE-CU).151020-1624 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/33a6114f99434ff0b67b421c6ba8bf872/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5641.00 ((SQL11_SP2_QFE-CU).151020-1624 ) +``` + +# SQL Server 2012 SP2 CU9 - 11.0.5641.0 - x86 (3098512) +``` powershell +# SQL Server 2012 SP2 CU9 - 11.0.5641.0 - x86 (3098512) +$outputFolder = 'c:\sqlsyms\11.0.5641.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/90707b52346e4f2081ee4b57991465f02/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5641.00 ((SQL11_SP2_QFE-CU).151020-1623 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/dadbef50fe024e9fa2ab29facd23364e2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5641.00 ((SQL11_SP2_QFE-CU).151020-1623 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/848be43da62b4654962c76ac0817f4d52/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5641.00 ((SQL11_SP2_QFE-CU).151020-1623 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/d3ead1ac747046bf95ce1fb24d26414b2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5641.00 ((SQL11_SP2_QFE-CU).151020-1623 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/6d4960a06b9e449189135a1f8cfe486d1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5641.00 ((SQL11_SP2_QFE-CU).151020-1623 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/fc7864bea8ae4450af4c100b03106cbc1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5641.00 ((SQL11_SP2_QFE-CU).151020-1623 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/ab2ca7efbd604bc2a98d334a6e8e85051/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5641.00 ((SQL11_SP2_QFE-CU).151020-1623 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/1aaa39cfe07242669c6f1fd909a40e141/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5641.00 ((SQL11_SP2_QFE-CU).151020-1623 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/8987ad9ed15145209fc028ceae4267041/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5641.00 ((SQL11_SP2_QFE-CU).151020-1623 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/9166856bbe0d4752b138d4aef51afa7f2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5641.00 ((SQL11_SP2_QFE-CU).151020-1623 ) +``` + +# SQL Server 2012 SP2 CU8 - 11.0.5634.1 - x64 (3082561) +``` powershell +# SQL Server 2012 SP2 CU8 - 11.0.5634.1 - x64 (3082561) +$outputFolder = 'c:\sqlsyms\11.0.5634.1\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/61ef98bf0c944d27bdcdcbe956a71f532/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5634.01 ((SQL11_SP2_QFE-CU).150903-1845 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/e32a770828b441ea83876963f8915c642/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5634.01 ((SQL11_SP2_QFE-CU).150903-1845 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/82d71733ddda4f63b0c0c587bea3e5b52/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5634.01 ((SQL11_SP2_QFE-CU).150903-1845 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/3d8d115280c343e79ffda9d5e13914ca2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5634.01 ((SQL11_SP2_QFE-CU).150903-1845 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/df6d6664b8b343b5822f404ca1c71e961/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5634.01 ((SQL11_SP2_QFE-CU).150903-1845 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/afdf9896ee5f454da131c41d186ed2381/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5634.01 ((SQL11_SP2_QFE-CU).150903-1845 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/d24c170faa1d4b66a72dee2f6905bda41/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5634.01 ((SQL11_SP2_QFE-CU).150903-1845 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/6be320158f64485fb39edc54657cc9691/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5634.01 ((SQL11_SP2_QFE-CU).150903-1845 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/4a7653322ccd491db5e3319fe11fd1e11/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5634.01 ((SQL11_SP2_QFE-CU).150903-1845 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/ff7b48cc7d4845009f4219b2ea8ed7af2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5634.01 ((SQL11_SP2_QFE-CU).150903-1845 ) +``` + +# SQL Server 2012 SP2 CU8 - 11.0.5634.1 - x86 (3082561) +``` powershell +# SQL Server 2012 SP2 CU8 - 11.0.5634.1 - x86 (3082561) +$outputFolder = 'c:\sqlsyms\11.0.5634.1\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/eaf68945f2a744b49102874620c553442/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5634.01 ((SQL11_SP2_QFE-CU).150903-1831 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/62d91f546d724970a297824753b247a62/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5634.01 ((SQL11_SP2_QFE-CU).150903-1831 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/0cee6b19c69a45a79cc9ba2576d203802/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5634.01 ((SQL11_SP2_QFE-CU).150903-1831 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/3595e13882f2488dad33b5b42b6de7022/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5634.01 ((SQL11_SP2_QFE-CU).150903-1831 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/5d1ce58362004146a03b9a203f716bcc1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5634.01 ((SQL11_SP2_QFE-CU).150903-1831 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/7ec8ca29f61b41c99ebc77df6f3641dc1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5634.01 ((SQL11_SP2_QFE-CU).150903-1831 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/32f2862ef89d49b29bfa4935a8cb5da81/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5634.01 ((SQL11_SP2_QFE-CU).150903-1831 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/64249ed7e3394edfa60825e07327feab1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5634.01 ((SQL11_SP2_QFE-CU).150903-1831 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/41763cddfdd84bdeae6a9d2f7f93a23a1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5634.01 ((SQL11_SP2_QFE-CU).150903-1831 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/839d3b40fcbb4c94b8bc3b9e91581f962/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5634.01 ((SQL11_SP2_QFE-CU).150903-1831 ) +``` + +# SQL Server 2012 SP2 CU7 - 11.0.5623.0 - x64 (3072100) +``` powershell +# SQL Server 2012 SP2 CU7 - 11.0.5623.0 - x64 (3072100) +$outputFolder = 'c:\sqlsyms\11.0.5623.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/ae8dca071dd14b8588f8c1e8355750c42/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5623.00 ((SQL11_SP2_QFE-CU).150709-1152 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/e7c57dfa80174541b048819804823b642/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5623.00 ((SQL11_SP2_QFE-CU).150709-1152 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/ff4277e6a21e48fb9e04cc4e2c80ba0f2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5623.00 ((SQL11_SP2_QFE-CU).150709-1152 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/88abae217a834ae18b5754feecda13012/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5623.00 ((SQL11_SP2_QFE-CU).150709-1152 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/7d92e63eb71a45809ce78c14ffaf09d81/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5623.00 ((SQL11_SP2_QFE-CU).150709-1152 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/b5fb3509642c4690a5c45749035333051/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5623.00 ((SQL11_SP2_QFE-CU).150709-1152 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/8072e1fb97424fdc98269196785f7fbe1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5623.00 ((SQL11_SP2_QFE-CU).150709-1152 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/fca6c8e72e5e42ecb99207f194bef9191/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5623.00 ((SQL11_SP2_QFE-CU).150709-1152 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/31bac03868374db896288d1c1a856bf91/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5623.00 ((SQL11_SP2_QFE-CU).150709-1152 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/48708388ca2f4e6c9c9a286887fc6bda2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5623.00 ((SQL11_SP2_QFE-CU).150709-1152 ) +``` + +# SQL Server 2012 SP2 CU7 - 11.0.5623.0 - x86 (3072100) +``` powershell +# SQL Server 2012 SP2 CU7 - 11.0.5623.0 - x86 (3072100) +$outputFolder = 'c:\sqlsyms\11.0.5623.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/473e800d9eeb4e4097e87652ab5aaa052/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5623.00 ((SQL11_SP2_QFE-CU).150709-1156 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/19adc0aa5e1249238e244b5ba9e0f2492/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5623.00 ((SQL11_SP2_QFE-CU).150709-1156 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/58fc60e3bbd5448bb466dc8f753683b62/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5623.00 ((SQL11_SP2_QFE-CU).150709-1156 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/49c28e17e982469bb1092e77901d168b2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5623.00 ((SQL11_SP2_QFE-CU).150709-1156 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/cc65b11dda20409a8879339d384bd9491/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5623.00 ((SQL11_SP2_QFE-CU).150709-1156 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/1a58faf830674e18a3aeb22c4f0818211/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5623.00 ((SQL11_SP2_QFE-CU).150709-1156 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/49fd8984505e468590ca91dda1dc99d41/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5623.00 ((SQL11_SP2_QFE-CU).150709-1156 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/3ba93675da7c476c979fd0b7cecbbdab1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5623.00 ((SQL11_SP2_QFE-CU).150709-1156 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/3d6472408ed74f41bb58f30027ba9e421/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5623.00 ((SQL11_SP2_QFE-CU).150709-1156 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/ee5bb2170a2347978420200f22fb85592/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5623.00 ((SQL11_SP2_QFE-CU).150709-1156 ) +``` + +# SQL Server 2012 SP2 CU6 - 11.0.5592.0 - x64 (3052468) +``` powershell +# SQL Server 2012 SP2 CU6 - 11.0.5592.0 - x64 (3052468) +$outputFolder = 'c:\sqlsyms\11.0.5592.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/a9e46f8055ae4cb5aa344fb96e73ca7e2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5592.00 ((SQL11_SP2_QFE-CU).150417-1509 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/cf97aed844944105b2d8ed9a933dc1522/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5592.00 ((SQL11_SP2_QFE-CU).150417-1509 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/d3bcd6c8911b48a491bcf8e18841ba3b2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5592.00 ((SQL11_SP2_QFE-CU).150417-1509 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/92ea2d549256436c83154e05e769d26f2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5592.00 ((SQL11_SP2_QFE-CU).150417-1509 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/0ddbf5e6c62c483eab519b300e41aa131/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5592.00 ((SQL11_SP2_QFE-CU).150417-1509 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/253e36a0d02942189ed1205210163d8a1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5592.00 ((SQL11_SP2_QFE-CU).150417-1509 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/ae5a1adb5bf94b38b3ebb35270da6bb71/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5592.00 ((SQL11_SP2_QFE-CU).150417-1509 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/11acb1f2f7cf4498a3a8594014e4a5491/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5592.00 ((SQL11_SP2_QFE-CU).150417-1509 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/7ff78655e62d42d3862242c04816400d1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5592.00 ((SQL11_SP2_QFE-CU).150417-1509 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/c68000bb1ce7439ca573a54d17c73ab52/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5592.00 ((SQL11_SP2_QFE-CU).150417-1509 ) +``` + +# SQL Server 2012 SP2 CU6 - 11.0.5592.0 - x86 (3052468) +``` powershell +# SQL Server 2012 SP2 CU6 - 11.0.5592.0 - x86 (3052468) +$outputFolder = 'c:\sqlsyms\11.0.5592.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/90b88bf18b2b483bbb76862b88cce4032/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5592.00 ((SQL11_SP2_QFE-CU).150417-1510 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/ade94be306d74bdea416c6d4efd8d8482/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5592.00 ((SQL11_SP2_QFE-CU).150417-1510 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/fc93e429e1454118b9be2831ac8539602/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5592.00 ((SQL11_SP2_QFE-CU).150417-1510 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/27a72ca6e4604cc8bdd4b0362751e82e2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5592.00 ((SQL11_SP2_QFE-CU).150417-1510 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/7aa7de50535a41d4b28f1437981bb3401/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5592.00 ((SQL11_SP2_QFE-CU).150417-1510 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/73f81b7d9c4240de8339ad241becf98f1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5592.00 ((SQL11_SP2_QFE-CU).150417-1510 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/4b749317568942e383ee42a9eb2cf1f41/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5592.00 ((SQL11_SP2_QFE-CU).150417-1510 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/3c59c6073f7d48df91b7abd1828db0c51/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5592.00 ((SQL11_SP2_QFE-CU).150417-1510 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/7f22862851fc4bdca72990a66edb51991/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5592.00 ((SQL11_SP2_QFE-CU).150417-1510 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/e36a38ed3a6146fbaf6216025b206d802/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5592.00 ((SQL11_SP2_QFE-CU).150417-1510 ) +``` + +# SQL Server 2012 SP2 CU5 - 11.0.5582.0 - x64 (3037255) +``` powershell +# SQL Server 2012 SP2 CU5 - 11.0.5582.0 - x64 (3037255) +$outputFolder = 'c:\sqlsyms\11.0.5582.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/8badafbcc6334b139d67b83c61e1ad632/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5582.00 ((SQL11_SP2_QFE-CU).150227-1800 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/c736d839f6f54501a94ccd22ec14d3552/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5582.00 ((SQL11_SP2_QFE-CU).150227-1800 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/d4ed0467cc1944e19589685f554793482/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5582.00 ((SQL11_SP2_QFE-CU).150227-1800 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/4534514aec274addb9f4bacefda3799e2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5582.00 ((SQL11_SP2_QFE-CU).150227-1800 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/556a0a2b1d5d4757aac0242c56f798551/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5582.00 ((SQL11_SP2_QFE-CU).150227-1800 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/3cceaa5cf5684811a0386e715a6aecca1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5582.00 ((SQL11_SP2_QFE-CU).150227-1800 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/b1bc02bf82844ba886d35e2f3dadd38d1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5582.00 ((SQL11_SP2_QFE-CU).150227-1800 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/f4538786cdca4eb789acedeb918639401/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5582.00 ((SQL11_SP2_QFE-CU).150227-1800 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/8358c5a13ecf438890f62b23d94a30f51/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5582.00 ((SQL11_SP2_QFE-CU).150227-1800 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/ae3adbf271aa479fb5256880e575fed22/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5582.00 ((SQL11_SP2_QFE-CU).150227-1800 ) +``` + +# SQL Server 2012 SP2 CU5 - 11.0.5582.0 - x86 (3037255) +``` powershell +# SQL Server 2012 SP2 CU5 - 11.0.5582.0 - x86 (3037255) +$outputFolder = 'c:\sqlsyms\11.0.5582.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/3a47214af54f43b494f0ea53b36d1a3a2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5582.00 ((SQL11_SP2_QFE-CU).150227-1813 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/8b32b6454ee742eb98916880e92325292/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5582.00 ((SQL11_SP2_QFE-CU).150227-1813 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/9bd5f790568b408fa093d1ac93ad5dd92/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5582.00 ((SQL11_SP2_QFE-CU).150227-1813 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/9920c94073c94b9b9334cfac3233e2e92/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5582.00 ((SQL11_SP2_QFE-CU).150227-1813 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/7bd272d1179e4fbd92b9c5863a0133791/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5582.00 ((SQL11_SP2_QFE-CU).150227-1813 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/0ddb45c56e3b41d99a71af72332e241f1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5582.00 ((SQL11_SP2_QFE-CU).150227-1813 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/c3ba2ddbe9f143788b703f9d2d8c7a2c1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5582.00 ((SQL11_SP2_QFE-CU).150227-1813 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/ecce36e5bb034047998a2bd085889c841/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5582.00 ((SQL11_SP2_QFE-CU).150227-1813 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/cb343262158a462f92b23f68d2ae7ac21/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5582.00 ((SQL11_SP2_QFE-CU).150227-1813 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/5a1bf2e1647e44f0815b022eb13ff9232/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5582.00 ((SQL11_SP2_QFE-CU).150227-1813 ) +``` + +# SQL Server 2012 SP2 CU4 - 11.0.5569.0 - x64 (3007556) +``` powershell +# SQL Server 2012 SP2 CU4 - 11.0.5569.0 - x64 (3007556) +$outputFolder = 'c:\sqlsyms\11.0.5569.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/362c792ee0e84038a70ca60e9d73670d2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5569.00 ((SQL11_SP2_QFE-CU).150109-1123 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/a0ca918076554d4c933045287d5096ed2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5569.00 ((SQL11_SP2_QFE-CU).150109-1123 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/77c344284abe4a1886d727f7552e9c952/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5569.00 ((SQL11_SP2_QFE-CU).150109-1123 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/a30fa17e3c414464afa91913f0833c122/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5569.00 ((SQL11_SP2_QFE-CU).150109-1123 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/7fc8dd4807bb420fbc055771e64b95321/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5569.00 ((SQL11_SP2_QFE-CU).150109-1123 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/183074ed7e6a4bb9a13c48ad2a00c3411/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5569.00 ((SQL11_SP2_QFE-CU).150109-1123 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/3984af0d59e8459d83be5e3215e151b91/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5569.00 ((SQL11_SP2_QFE-CU).150109-1123 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/79ebc6f96e85467090f16ccd6efa5f6a1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5569.00 ((SQL11_SP2_QFE-CU).150109-1123 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/384a0f1d64a749e9bac4a0b0d8d203d91/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5569.00 ((SQL11_SP2_QFE-CU).150109-1123 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/99ebd3f774364d7cbd4679ed474886ae2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5569.00 ((SQL11_SP2_QFE-CU).150109-1123 ) +``` + +# SQL Server 2012 SP2 CU4 - 11.0.5569.0 - x86 (3007556) +``` powershell +# SQL Server 2012 SP2 CU4 - 11.0.5569.0 - x86 (3007556) +$outputFolder = 'c:\sqlsyms\11.0.5569.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/0f05bf5e3ab14d13a90d394d10fb3ee32/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5569.00 ((SQL11_SP2_QFE-CU).150109-1126 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/0467323f452c4c889bb8c03eb9245e482/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5569.00 ((SQL11_SP2_QFE-CU).150109-1126 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/8d05289fe8d740979420b0fd5a7676e92/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5569.00 ((SQL11_SP2_QFE-CU).150109-1126 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/29ae6e87132b46b4b78e7965ea7ada3c2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5569.00 ((SQL11_SP2_QFE-CU).150109-1126 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/9fa2ee33584d4ed78ec81f31b1b600481/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5569.00 ((SQL11_SP2_QFE-CU).150109-1126 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/405d1f73f6c94e88a32c71a53ecd1e8e1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5569.00 ((SQL11_SP2_QFE-CU).150109-1126 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/0db139cf45c246d3913b3c3605ec2f651/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5569.00 ((SQL11_SP2_QFE-CU).150109-1126 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/50b739fdeaea477589c02536e8cab5cf1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5569.00 ((SQL11_SP2_QFE-CU).150109-1126 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/ccb38bba52fa4568bc85256b6039d9531/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5569.00 ((SQL11_SP2_QFE-CU).150109-1126 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/3f9b337dac5a40559d2c1d53f33b4dd62/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5569.00 ((SQL11_SP2_QFE-CU).150109-1126 ) +``` + +# SQL Server 2012 SP2 CU3 - 11.0.5556.0 - x64 (3002049) +``` powershell +# SQL Server 2012 SP2 CU3 - 11.0.5556.0 - x64 (3002049) +$outputFolder = 'c:\sqlsyms\11.0.5556.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/d1a00b8b404a457b9d366e7db692612c2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5556.00 ((SQL11_SP2_QFE-CU).141031-1640 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/caa84e0b43e5423dabd502cf51fcef3a2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5556.00 ((SQL11_SP2_QFE-CU).141031-1640 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/692932d983ac4d0cb8b4c5280484f7ee2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5556.00 ((SQL11_SP2_QFE-CU).141031-1640 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/eb5aa259e39446cd8eaf7e75c20ccad22/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5556.00 ((SQL11_SP2_QFE-CU).141031-1640 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/0d5bd32496a14c1db5d2bf51ac4c1e0a1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5556.00 ((SQL11_SP2_QFE-CU).141031-1640 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/c25697387b484c97b22b5f447bb3ac1f1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5556.00 ((SQL11_SP2_QFE-CU).141031-1640 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/ad1f8b1a883a4339a75f54c8dc57fdb31/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5556.00 ((SQL11_SP2_QFE-CU).141031-1640 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/22376adfcdfb44f5af969adecba164911/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5556.00 ((SQL11_SP2_QFE-CU).141031-1640 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/931ba4aa04ce4f42a0fc4d464091f18a1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5556.00 ((SQL11_SP2_QFE-CU).141031-1640 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/ce308e7fe1024a62ac491cf474cec82c2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5556.00 ((SQL11_SP2_QFE-CU).141031-1640 ) +``` + +# SQL Server 2012 SP2 CU3 - 11.0.5556.0 - x86 (3002049) +``` powershell +# SQL Server 2012 SP2 CU3 - 11.0.5556.0 - x86 (3002049) +$outputFolder = 'c:\sqlsyms\11.0.5556.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/5918d9b7678849c49bbb3f5da4e3a0282/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5556.00 ((SQL11_SP2_QFE-CU).141031-1639 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/00b4161353c44d8e8a3f856e666b09162/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5556.00 ((SQL11_SP2_QFE-CU).141031-1639 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/dd70fb9e4d4e45d2b05ab68c33586bdf2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5556.00 ((SQL11_SP2_QFE-CU).141031-1639 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/8a3d1406ad4b4d81a996bc92df9ebcfe2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5556.00 ((SQL11_SP2_QFE-CU).141031-1639 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/de2557533cb84d6c8fb44bd721bc09ca1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5556.00 ((SQL11_SP2_QFE-CU).141031-1639 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/99a6e3ff0cb84daa83b2c919ac45bf3f1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5556.00 ((SQL11_SP2_QFE-CU).141031-1639 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/d8c9218704ce483ea64cb50ae2bc08f11/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5556.00 ((SQL11_SP2_QFE-CU).141031-1639 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/5ffe4b28d77f4236b72eba2f4c36c4901/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5556.00 ((SQL11_SP2_QFE-CU).141031-1639 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/87cd133d6de14b83a0fc51fd0c6731731/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5556.00 ((SQL11_SP2_QFE-CU).141031-1639 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/750a2c62762c42a5bd832b7334954b822/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5556.00 ((SQL11_SP2_QFE-CU).141031-1639 ) +``` + +# SQL Server 2012 SP2 CU2 - 11.0.5548.0 - x64 (2983175) +``` powershell +# SQL Server 2012 SP2 CU2 - 11.0.5548.0 - x64 (2983175) +$outputFolder = 'c:\sqlsyms\11.0.5548.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/99205f110e104780bcd50b13b8b2ef602/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5548.00 ((SQL11_SP2_QFE-CU).140906-1703 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/cae73ab941a5449bb04d577b8ac0ee2e2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5548.00 ((SQL11_SP2_QFE-CU).140906-1703 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/5b7ccbfa58b54a8d80d9fe76d86eead32/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5548.00 ((SQL11_SP2_QFE-CU).140906-1703 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/35f5dd06512c4dae8339badc7b32f1a02/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5548.00 ((SQL11_SP2_QFE-CU).140906-1703 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/07c56b468964456996e7fffcc033ba561/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5548.00 ((SQL11_SP2_QFE-CU).140906-1703 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/f8b575102d5e4845bb73a4713fbd27281/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5548.00 ((SQL11_SP2_QFE-CU).140906-1703 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/f48d51269e1a44bf917c04e47fd3497f1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5548.00 ((SQL11_SP2_QFE-CU).140906-1703 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/380cdbf633f94b8e9f7a15c4a0f05e9c1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5548.00 ((SQL11_SP2_QFE-CU).140906-1703 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/a10eeceb16684e2f97e7bf5b048556ae1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5548.00 ((SQL11_SP2_QFE-CU).140906-1703 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/c7371ee128084547b8cc44cf23daf6322/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5548.00 ((SQL11_SP2_QFE-CU).140906-1703 ) +``` + +# SQL Server 2012 SP2 CU2 - 11.0.5548.0 - x86 (2983175) +``` powershell +# SQL Server 2012 SP2 CU2 - 11.0.5548.0 - x86 (2983175) +$outputFolder = 'c:\sqlsyms\11.0.5548.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/3e037ba29b3e4225ae410c337d79bd8c2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5548.00 ((SQL11_SP2_QFE-CU).140906-1802 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/b45cf018f0f54771a95e71eaaa28a88e2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5548.00 ((SQL11_SP2_QFE-CU).140906-1802 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/a76a804ec0ba4b76ba58f380668012da2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5548.00 ((SQL11_SP2_QFE-CU).140906-1802 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/54c5a385aba743edb15be3e62a137c832/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5548.00 ((SQL11_SP2_QFE-CU).140906-1802 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/3165959521524b8eaed9ece7ff68571d1/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5548.00 ((SQL11_SP2_QFE-CU).140906-1802 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/1a52c14e68fa418188349ed428ed814a1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5548.00 ((SQL11_SP2_QFE-CU).140906-1802 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/c4534dd553ae4e1da2fdbb4df151981c1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5548.00 ((SQL11_SP2_QFE-CU).140906-1802 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/a6e6cca281ff419291ad2ce6e8c536881/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5548.00 ((SQL11_SP2_QFE-CU).140906-1802 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/01e271d3affe4c5197beedb3189b46541/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5548.00 ((SQL11_SP2_QFE-CU).140906-1802 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/9d08d936dc3f4b259d73b86191fcd0d32/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5548.00 ((SQL11_SP2_QFE-CU).140906-1802 ) +``` + +# SQL Server 2012 SP2 CU1 - 11.0.5532.0 - x64 (2976982) +``` powershell +# SQL Server 2012 SP2 CU1 - 11.0.5532.0 - x64 (2976982) +$outputFolder = 'c:\sqlsyms\11.0.5532.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/cbf110ac14d94a8cb27f29d7def6e2832/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5532.00 ((SQL11_SP2_QFE-CU).140714-1446 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/5ef74be1c5314aa38320fa24e34e51c72/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5532.00 ((SQL11_SP2_QFE-CU).140714-1446 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/ffb5d83cafba46faa6816b8e6491c4b12/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5532.00 ((SQL11_SP2_QFE-CU).140714-1446 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/5078a04f329147b7978220b06bb870192/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5532.00 ((SQL11_SP2_QFE-CU).140714-1446 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/d7952e1acc294862bda55dd7e4d3e8211/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5532.00 ((SQL11_SP2_QFE-CU).140714-1446 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/5a95d568bac94867b8e0840fd91e50c51/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5532.00 ((SQL11_SP2_QFE-CU).140714-1446 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/6639b1da0ba34639811d5bec9aff80371/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5532.00 ((SQL11_SP2_QFE-CU).140714-1446 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/a8c29cbda99e41fe8e103298736b6a4b1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5532.00 ((SQL11_SP2_QFE-CU).140714-1446 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/da3edb6b439f4e028581352ace87953f1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5532.00 ((SQL11_SP2_QFE-CU).140714-1446 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/427d00997e8b428bbb7a3e5258acb0f72/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5532.00 ((SQL11_SP2_QFE-CU).140714-1446 ) +``` + +# SQL Server 2012 SP2 CU1 - 11.0.5532.0 - x86 (2976982) +``` powershell +# SQL Server 2012 SP2 CU1 - 11.0.5532.0 - x86 (2976982) +$outputFolder = 'c:\sqlsyms\11.0.5532.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/35685e9861dd48aaae7cc5b16bd328122/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5532.00 ((SQL11_SP2_QFE-CU).140714-1449 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/894411a3cde84440964e7d15e54a42f22/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5532.00 ((SQL11_SP2_QFE-CU).140714-1449 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/b8e311cfe83844efbfa836d7edd0a4c92/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5532.00 ((SQL11_SP2_QFE-CU).140714-1449 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/4dde9c04fa9e48aa8dd99f6253ddde802/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5532.00 ((SQL11_SP2_QFE-CU).140714-1449 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/bc9c1b0188ad4c4694e3fc2b2cc003f51/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5532.00 ((SQL11_SP2_QFE-CU).140714-1449 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/f4e0f97f61954596a55a9127841a84ad1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5532.00 ((SQL11_SP2_QFE-CU).140714-1449 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/27494563474d41a9b38acc20ae538cae1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5532.00 ((SQL11_SP2_QFE-CU).140714-1449 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/3c69ca79dab742ffa5fd044f1300bbe11/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5532.00 ((SQL11_SP2_QFE-CU).140714-1449 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/4081f3e32c334fb8b9164529b87ccf601/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5532.00 ((SQL11_SP2_QFE-CU).140714-1449 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/4b32834628184e4fa4f9848fa401a19c2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5532.00 ((SQL11_SP2_QFE-CU).140714-1449 ) +``` + +# SQL Server 2012 SP2 SP2 - 11.0.5058.0 - x64 (2958429) +``` powershell +# SQL Server 2012 SP2 SP2 - 11.0.5058.0 - x64 (2958429) +$outputFolder = 'c:\sqlsyms\11.0.5058.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/ee0459385983426284e7a607384e4bf62/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5058.00 ((SQL11_PCU_Main).140514-1820 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/fbafcdb326434a41a09d549fbf6e8f062/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5058.00 ((SQL11_PCU_Main).140514-1820 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/587ed8597e30437a8028d1ee025c75d12/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5058.00 ((SQL11_PCU_Main).140514-1820 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/d7a22e5762bd4c94bc2c0af2fc63a1372/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5058.00 ((SQL11_PCU_Main).140514-1820 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/017fa06efaf641d4bba760a5258be5741/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5058.00 ((SQL11_PCU_Main).140514-1820 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/32a91c0b60204fffa1374cf3492a88a01/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5058.00 ((SQL11_PCU_Main).140514-1820 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/0452878b0b30401f814aab0fa4ac74661/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5058.00 ((SQL11_PCU_Main).140514-1820 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/389e963e00f040079eff7b8e2ccc3c911/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5058.00 ((SQL11_PCU_Main).140514-1820 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/0ef93093d4ea4f9d90a21e79f602919d1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5058.00 ((SQL11_PCU_Main).140514-1820 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/12ec0b5836ca41429c5bce95a1653eaf2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5058.00 ((SQL11_PCU_Main).140514-1820 ) +``` + +# SQL Server 2012 SP2 SP2 - 11.0.5058.0 - x86 (2958429) +``` powershell +# SQL Server 2012 SP2 SP2 - 11.0.5058.0 - x86 (2958429) +$outputFolder = 'c:\sqlsyms\11.0.5058.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/9a6c2fb9f9ad46b7b240b1cd3f7782312/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2011.0110.5058.00 ((SQL11_PCU_Main).140514-1623 ) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/1c6fd82d91f84e9b9ebca1a6a1bfb80d2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2011.0110.5058.00 ((SQL11_PCU_Main).140514-1623 ) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/c7c06ee472184be7a264d1450b683ef52/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2011.0110.5058.00 ((SQL11_PCU_Main).140514-1623 ) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/004a42376b6e41af95b7280c65021add2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2011.0110.5058.00 ((SQL11_PCU_Main).140514-1623 ) +if (-not (Test-Path "$outputFolder\SqlAccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlAccess.pdb/15004f64c18c48e1b5b1573836f2a7931/SqlAccess.pdb' -OutFile "$outputFolder\SqlAccess.pdb" } # File version 2011.0110.5058.00 ((SQL11_PCU_Main).140514-1623 ) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/d5064f709c6f4124a7423ab6fa0ed7f71/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2011.0110.5058.00 ((SQL11_PCU_Main).140514-1623 ) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/74570a2c5655462e859fe5f6358603ef1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2011.0110.5058.00 ((SQL11_PCU_Main).140514-1623 ) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/895b174b37d9498496b464b2600219a31/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2011.0110.5058.00 ((SQL11_PCU_Main).140514-1623 ) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/366970ac611340e4bd1e6c244d2b30e71/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2011.0110.5058.00 ((SQL11_PCU_Main).140514-1623 ) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/a4ca976e0f84491eafe73b3195b39c6a2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2011.0110.5058.00 ((SQL11_PCU_Main).140514-1623 ) +``` + diff --git a/Errors/PDB/SQL-Server-2014.md b/Errors/PDB/SQL-Server-2014.md new file mode 100644 index 00000000..38963da2 --- /dev/null +++ b/Errors/PDB/SQL-Server-2014.md @@ -0,0 +1,1650 @@ +# SQL Server 2014 SP3 Security update - 12.0.6372.1 - x64 (KB4535288) +``` powershell +# SQL Server 2014 SP3 Security update - 12.0.6372.1 - x64 (KB4535288) +$outputFolder = 'c:\sqlsyms\12.0.6372.1\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/58e64a3a589647efb0962ea0b54a4f802/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.6372.01 ((SQL14_SP3_QFE-OD).191212-1438) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/4c0bcc7afda04998a4cb7e0bfdb736792/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.6372.01 ((SQL14_SP3_QFE-OD).191212-1438) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/7c6006d90ec04c61ba245a22fba604112/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.6372.01 ((SQL14_SP3_QFE-OD).191212-1438) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/34148353e4e245728f03ab52442361702/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.6372.01 ((SQL14_SP3_QFE-OD).191212-1438) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/fdbeff4d6d474008a694cd69c38acff72/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.6372.01 ((SQL14_SP3_QFE-OD).191212-1438) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/e82e0bf323c44a328f1dff97e18643ea2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.6372.01 ((SQL14_SP3_QFE-OD).191212-1438) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/ee0aebf1bb054cf7bf1a02b9967cb1941/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.6372.01 ((SQL14_SP3_QFE-OD).191212-1438) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/37659ab76c0746f59df1383528780d091/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.6372.01 ((SQL14_SP3_QFE-OD).191212-1438) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/d5b8297e63ee412bacb678e15142c6e61/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.6372.01 ((SQL14_SP3_QFE-OD).191212-1438) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/e541cd3097054c21bae4d0f56206a5d81/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.6372.01 ((SQL14_SP3_QFE-OD).191212-1438) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/9d8cfaa7d57c414eb326f3d248345f4a2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.6372.01 ((SQL14_SP3_QFE-OD).191212-1438) +``` + +# SQL Server 2014 SP3 Security update - 12.0.6372.1 - x86 (KB4535288) +``` powershell +# SQL Server 2014 SP3 Security update - 12.0.6372.1 - x86 (KB4535288) +$outputFolder = 'c:\sqlsyms\12.0.6372.1\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/293ea0a0c7424b899d5bcd915253d8671/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.6372.01 ((SQL14_SP3_QFE-OD).191212-1438) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/bcf38756effd4ebc810aa6e146c6a1bf1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.6372.01 ((SQL14_SP3_QFE-OD).191212-1438) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/a59d30393cae4117a8fb17f54e1b6fff1/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.6372.01 ((SQL14_SP3_QFE-OD).191212-1438) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/19fe1f9fe3c84751a09fb1916c1d1ab31/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.6372.01 ((SQL14_SP3_QFE-OD).191212-1438) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/ed1d0cdedb2247d9b67ba5b7df4247ad2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.6372.01 ((SQL14_SP3_QFE-OD).191212-1438) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/f3647da71cd84c81a409357f4e3823b01/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.6372.01 ((SQL14_SP3_QFE-OD).191212-1438) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/1e54810c09ff4222889ac0220924754a1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.6372.01 ((SQL14_SP3_QFE-OD).191212-1438) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/eb15a63849fd464484aadb058f6cceee1/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.6372.01 ((SQL14_SP3_QFE-OD).191212-1438) +``` + +# SQL Server 2014 SP3 CU4 - 12.0.6329.1 - x64 (KB4500181) +``` powershell +# SQL Server 2014 SP3 CU4 - 12.0.6329.1 - x64 (KB4500181) +$outputFolder = 'c:\sqlsyms\12.0.6329.1\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/d8fb694123ba4677bee6145b83b62cff2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.6329.01 ((SQL14_SP3_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/1b6e19734d074c9890f13ff5ea5d4c912/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.6329.01 ((SQL14_SP3_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/f95e3773af054cc7a3bf4b6085f6c1d12/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.6329.01 ((SQL14_SP3_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/84e90c67c25b46419a58c11eea0a9a4a2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.6329.01 ((SQL14_SP3_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/1e7f7c728a8f41049e73e89d313fcf852/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.6329.01 ((SQL14_SP3_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/4f2b4eda1143444bb7963507c9f9ea232/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.6329.01 ((SQL14_SP3_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/530c0de276fb40ceab73fb117b038d601/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.6329.01 ((SQL14_SP3_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/d6708b4bf5854985b6fa2ef0d44508a11/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.6329.01 ((SQL14_SP3_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/6c202059075a4fab90806f205caa070a1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.6329.01 ((SQL14_SP3_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/63a4742459624df0938bf06b948771ad1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.6329.01 ((SQL14_SP3_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/0f334a75cf294a6aa2be0b46f824b4902/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.6329.01 ((SQL14_SP3_QFE-CU).190720-2034) +``` + +# SQL Server 2014 SP3 CU4 - 12.0.6329.1 - x86 (KB4500181) +``` powershell +# SQL Server 2014 SP3 CU4 - 12.0.6329.1 - x86 (KB4500181) +$outputFolder = 'c:\sqlsyms\12.0.6329.1\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/890448d8cb7045b393f8d1e2414899681/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.6329.01 ((SQL14_SP3_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/54428dd07fed4d92a44af191b64b93931/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.6329.01 ((SQL14_SP3_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/1b72f20b65754e08a1b1afa6a1afa4111/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.6329.01 ((SQL14_SP3_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/648fb8d142124a79ba2427d7afa6e0b11/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.6329.01 ((SQL14_SP3_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/494b3def7c474707a36f396d3376c4862/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.6329.01 ((SQL14_SP3_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/1fffeae543a04025affdb7835ea77d271/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.6329.01 ((SQL14_SP3_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/f5d000569d74429ea2403fa65f7e782d1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.6329.01 ((SQL14_SP3_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/37ed1fbf4c114534bc53be649d38a4931/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.6329.01 ((SQL14_SP3_QFE-CU).190720-2034) +``` + +# SQL Server 2014 SP3 CU3 - 12.0.6259.0 - x64 (KB4491539) +``` powershell +# SQL Server 2014 SP3 CU3 - 12.0.6259.0 - x64 (KB4491539) +$outputFolder = 'c:\sqlsyms\12.0.6259.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/509f1673a650493eaf6e0609be36b3492/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.6259.00 ((SQL14_SP3_QFE-CU).190401-2139) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/9d0ed648ab3943148311d78972c4dcdf2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.6259.00 ((SQL14_SP3_QFE-CU).190401-2139) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/93f36eaccaf74bb49b33f830aa6225302/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.6259.00 ((SQL14_SP3_QFE-CU).190401-2139) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/59a4d543c0184372b51935541c2900152/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.6259.00 ((SQL14_SP3_QFE-CU).190401-2139) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/1836c6d5c554455c8b477142ba1c27552/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.6259.00 ((SQL14_SP3_QFE-CU).190401-2139) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/aefccb0a87ff43b6aa36c438baf6d1c42/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.6259.00 ((SQL14_SP3_QFE-CU).190401-2139) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/aa90299262cb4b118067c2df8703c9b91/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.6259.00 ((SQL14_SP3_QFE-CU).190401-2139) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/806e98d642074181978524533a9ef6531/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.6259.00 ((SQL14_SP3_QFE-CU).190401-2139) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/afbaa234358740998f706fd39e87a54e1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.6259.00 ((SQL14_SP3_QFE-CU).190401-2139) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/dd07d2aa7b2d4a528ffb3446711c9f321/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.6259.00 ((SQL14_SP3_QFE-CU).190401-2139) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/9a8dc77df3fc40f0a74375aa505eccfa2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.6259.00 ((SQL14_SP3_QFE-CU).190401-2139) +``` + +# SQL Server 2014 SP3 CU3 - 12.0.6259.0 - x86 (KB4491539) +``` powershell +# SQL Server 2014 SP3 CU3 - 12.0.6259.0 - x86 (KB4491539) +$outputFolder = 'c:\sqlsyms\12.0.6259.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/eb6a68e1d0a24f9a9334f21aa15921651/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.6259.00 ((SQL14_SP3_QFE-CU).190401-2139) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/e70ca276fe4043b19187d6d11dc8b8191/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.6259.00 ((SQL14_SP3_QFE-CU).190401-2139) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/6961ef7185e6403b8f45a2f02afaf21d1/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.6259.00 ((SQL14_SP3_QFE-CU).190401-2139) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/43b2f5430e244bfdbebf88fe85f6c9dc1/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.6259.00 ((SQL14_SP3_QFE-CU).190401-2139) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/549544362bc8490f9d315b111ae5b6952/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.6259.00 ((SQL14_SP3_QFE-CU).190401-2139) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/ce9855d8b6af4d45a14edb618dae86be1/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.6259.00 ((SQL14_SP3_QFE-CU).190401-2139) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/1c741bb277204482be593a294bc80dc71/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.6259.00 ((SQL14_SP3_QFE-CU).190401-2139) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/48abe955b32c43c2a8d38d8a0b706de51/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.6259.00 ((SQL14_SP3_QFE-CU).190401-2139) +``` + +# SQL Server 2014 SP3 CU2 - 12.0.6214.1 - x64 (KB4482960) +``` powershell +# SQL Server 2014 SP3 CU2 - 12.0.6214.1 - x64 (KB4482960) +$outputFolder = 'c:\sqlsyms\12.0.6214.1\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/10e693af20a345548cab5cc0d5bb9e5f2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.6214.01 ((SQL14_SP3_QFE-CU).190202-0024) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/277e791468d84fd3ac5134bfcb8b00292/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.6214.01 ((SQL14_SP3_QFE-CU).190202-0024) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/8c63860792c440eb997bbc9c3da54eb72/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.6214.01 ((SQL14_SP3_QFE-CU).190202-0024) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/860593c8a27d4f609d1f139775b445862/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.6214.01 ((SQL14_SP3_QFE-CU).190202-0024) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/0170e47e2ba046e0b2726300345d4dfc2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.6214.01 ((SQL14_SP3_QFE-CU).190202-0024) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/cf29ef995a5545ed8f8af7ddd180b7802/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.6214.01 ((SQL14_SP3_QFE-CU).190202-0024) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/4d1d0ae8debb488496086b48820cae8c1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.6214.01 ((SQL14_SP3_QFE-CU).190202-0024) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/a3671b7f7c5a457186f91951c24bae1c1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.6214.01 ((SQL14_SP3_QFE-CU).190202-0024) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/d7cc5f9c29834c34ac417d1237cc631c1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.6214.01 ((SQL14_SP3_QFE-CU).190202-0024) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/187d57d685f644f79c937544e990dbb81/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.6214.01 ((SQL14_SP3_QFE-CU).190202-0024) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/5c5e9a47919c4d6884d480d8f1c2d0762/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.6214.01 ((SQL14_SP3_QFE-CU).190202-0024) +``` + +# SQL Server 2014 SP3 CU2 - 12.0.6214.1 - x86 (KB4482960) +``` powershell +# SQL Server 2014 SP3 CU2 - 12.0.6214.1 - x86 (KB4482960) +$outputFolder = 'c:\sqlsyms\12.0.6214.1\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/754b0cc922a745aa8602712ee9aa1db11/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.6214.01 ((SQL14_SP3_QFE-CU).190202-0024) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/3841b412fc874fb99ca1f27156227aba1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.6214.01 ((SQL14_SP3_QFE-CU).190202-0024) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/ed56dba006f74b929b23cac11986d8d51/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.6214.01 ((SQL14_SP3_QFE-CU).190202-0024) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/ec53723220f14149a92352787915d8cf1/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.6214.01 ((SQL14_SP3_QFE-CU).190202-0024) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/a13d5a4be3234606bcfdbdfbf99ca8352/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.6214.01 ((SQL14_SP3_QFE-CU).190202-0024) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/f3338a3416cc4c9faa6f0f2dd08873761/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.6214.01 ((SQL14_SP3_QFE-CU).190202-0024) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/b113633a9a3f4819b125a6fd84cc4b2f1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.6214.01 ((SQL14_SP3_QFE-CU).190202-0024) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/40e7e956e6b64b3390093d7fed7996711/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.6214.01 ((SQL14_SP3_QFE-CU).190202-0024) +``` + +# SQL Server 2014 SP3 CU1 - 12.0.6205.1 - x64 (KB4470220) +``` powershell +# SQL Server 2014 SP3 CU1 - 12.0.6205.1 - x64 (KB4470220) +$outputFolder = 'c:\sqlsyms\12.0.6205.1\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/d81e66c5bbd8441aa42d3120f29de3942/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.6205.01 ((SQL14_SP3_QFE-CU).181130-0218) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/531883113186498cba06afb246bd12172/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.6205.01 ((SQL14_SP3_QFE-CU).181130-0218) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/093905727fd6498fac8991daed83fcde2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.6205.01 ((SQL14_SP3_QFE-CU).181130-0218) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/810559511add437f9da77ec6c227c3fb2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.6205.01 ((SQL14_SP3_QFE-CU).181130-0218) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/fff69d6bafab400fbafb9bfdd6fb52ff2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.6205.01 ((SQL14_SP3_QFE-CU).181130-0218) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/5cac176280bf4ab2af8033571dac19112/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.6205.01 ((SQL14_SP3_QFE-CU).181130-0218) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/b6bdfa6c96e74ef5ae6996e1733a432f1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.6205.01 ((SQL14_SP3_QFE-CU).181130-0218) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/8be7ae0b97464e56889d44760e5991771/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.6205.01 ((SQL14_SP3_QFE-CU).181130-0218) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/452b00505e9c4459877311b2a5296de01/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.6205.01 ((SQL14_SP3_QFE-CU).181130-0218) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/aa1470bb4a5c4687aef9d015e876685d1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.6205.01 ((SQL14_SP3_QFE-CU).181130-0218) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/2fe2b89405d644e8859b099da8827acb2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.6205.01 ((SQL14_SP3_QFE-CU).181130-0218) +``` + +# SQL Server 2014 SP3 CU1 - 12.0.6205.1 - x86 (KB4470220) +``` powershell +# SQL Server 2014 SP3 CU1 - 12.0.6205.1 - x86 (KB4470220) +$outputFolder = 'c:\sqlsyms\12.0.6205.1\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/cbcf0fbe53e54dacab354777d0dd5c2f1/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.6205.01 ((SQL14_SP3_QFE-CU).181130-0218) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/4f2576c7baa640d894aa0bf5d12fcf5f1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.6205.01 ((SQL14_SP3_QFE-CU).181130-0218) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/ac9f63e413d74fc5b1685806550265ae1/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.6205.01 ((SQL14_SP3_QFE-CU).181130-0218) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/fd21a26df72c47e29b96652c800806001/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.6205.01 ((SQL14_SP3_QFE-CU).181130-0218) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/75e51827bfcf435bae782ec8b7a4e3d82/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.6205.01 ((SQL14_SP3_QFE-CU).181130-0218) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/1a1dabe18df94874ba8bf28b429a8e6e1/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.6205.01 ((SQL14_SP3_QFE-CU).181130-0218) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/6cc29ac330c64c0a97461b778a1ba63d1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.6205.01 ((SQL14_SP3_QFE-CU).181130-0218) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/64addefbdce84bdd97198a54d80939e71/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.6205.01 ((SQL14_SP3_QFE-CU).181130-0218) +``` + +# SQL Server 2014 SP3 SP3 - 12.0.6024.0 - x64 (KB4022619) +``` powershell +# SQL Server 2014 SP3 SP3 - 12.0.6024.0 - x64 (KB4022619) +$outputFolder = 'c:\sqlsyms\12.0.6024.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/41b862dddc464a7e8fb435d80ef36d452/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.6024.00 ((SQL14_PCU_Main).180907-0056) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/8bc7a14bc8374bd0a9bcba71d608c2ef2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.6024.00 ((SQL14_PCU_Main).180907-0056) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/d1b5af4c4bcb41aebdae55654c0abc172/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.6024.00 ((SQL14_PCU_Main).180907-0056) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/a84fba616c964fdb849bb61878d368312/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.6024.00 ((SQL14_PCU_Main).180907-0056) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/cd96b0931624429a8b38b968078fad6c2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.6024.00 ((SQL14_PCU_Main).180907-0056) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/5e9cea18178c471b98c01da45892cc142/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.6024.00 ((SQL14_PCU_Main).180907-0056) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/c9163d437f9e473a91690d6a7fae07531/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.6024.00 ((SQL14_PCU_Main).180907-0056) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/f97a0a9518ea47d3ad13d09e1c6cbc8e1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.6024.00 ((SQL14_PCU_Main).180907-0056) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/1915e0ba4f764b49806e8bcefe9bdd351/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.6024.00 ((SQL14_PCU_Main).180907-0056) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/9b9535d5b46442d7a75246220c243ad91/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.6024.00 ((SQL14_PCU_Main).180907-0056) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/15291da2ad56424ab3f1a7e97809ec602/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.6024.00 ((SQL14_PCU_Main).180907-0056) +``` + +# SQL Server 2014 SP3 SP3 - 12.0.6024.0 - x86 (KB4022619) +``` powershell +# SQL Server 2014 SP3 SP3 - 12.0.6024.0 - x86 (KB4022619) +$outputFolder = 'c:\sqlsyms\12.0.6024.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/63c453d94e884e719f71611dd86e41f71/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.6024.00 ((SQL14_PCU_Main).180907-0056) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/6b94239f60d04638ac56d2d915054ae11/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.6024.00 ((SQL14_PCU_Main).180907-0056) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/d2bd8b4899db4627a49dcf39f275681a1/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.6024.00 ((SQL14_PCU_Main).180907-0056) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/e42c910a8207417ebfe95904c7aca3c01/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.6024.00 ((SQL14_PCU_Main).180907-0056) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/65c5722bca2e4384b8abdd8e7f57d00b2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.6024.00 ((SQL14_PCU_Main).180907-0056) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/f0ce2870ba1c4a759c01ee8c9366fa5d1/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.6024.00 ((SQL14_PCU_Main).180907-0056) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/b1c25cca32ca4d6391442eb096c2e71b1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.6024.00 ((SQL14_PCU_Main).180907-0056) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/370cc1865d654a908a912aca9de0156d1/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.6024.00 ((SQL14_PCU_Main).180907-0056) +``` + +# SQL Server 2014 SP2 CU18 - 12.0.5687.1 - x64 (KB4500180) +``` powershell +# SQL Server 2014 SP2 CU18 - 12.0.5687.1 - x64 (KB4500180) +$outputFolder = 'c:\sqlsyms\12.0.5687.1\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/bc12ecf9b0b543b196f0b7ed938283452/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.5687.01 ((SQL14_SP2_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/1b75aed94f92493dbba724cdc1f7c36d2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5687.01 ((SQL14_SP2_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/ff83ee2c46a7487686e8e1130887ced12/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5687.01 ((SQL14_SP2_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/b1044002158745fa8df8cce82b12f6ae2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.5687.01 ((SQL14_SP2_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/e8b1bf15c88342efbc82d32362ea64702/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5687.01 ((SQL14_SP2_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/e6d23fe6f42648418edc7c96c8619fd12/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5687.01 ((SQL14_SP2_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/abbcda6f1fb844bab401cd2ec5ec95471/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.5687.01 ((SQL14_SP2_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/f1f51c0ee2bb40dea8c9cc16917f52981/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.5687.01 ((SQL14_SP2_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/1d23807267c543f9a3fe48d69ef3d13e1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.5687.01 ((SQL14_SP2_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/801dddbf3b0849d9b0b1d15219dadad81/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5687.01 ((SQL14_SP2_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/e53cbbfca1d94580b8d4a7d511bb56e22/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5687.01 ((SQL14_SP2_QFE-CU).190720-2034) +``` + +# SQL Server 2014 SP2 CU18 - 12.0.5687.1 - x86 (KB4500180) +``` powershell +# SQL Server 2014 SP2 CU18 - 12.0.5687.1 - x86 (KB4500180) +$outputFolder = 'c:\sqlsyms\12.0.5687.1\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/1f1ebd01257f4aa5861d1ba6bd5eef381/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.5687.01 ((SQL14_SP2_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/b7fdb65668ae43cbac516c04d7fcddfb1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5687.01 ((SQL14_SP2_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/f4b5dc917b9a4b578e83a63c98914bdb1/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5687.01 ((SQL14_SP2_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/dd4f41c29b454453b9dadd60a3cf988e1/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.5687.01 ((SQL14_SP2_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/a8c3b381308647ab9a765b681f92e08f2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5687.01 ((SQL14_SP2_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/77dc64a2c02c41c3921c183c76ca39d51/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5687.01 ((SQL14_SP2_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/afe089cbd86947c6b1fe8796ded5a75e1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5687.01 ((SQL14_SP2_QFE-CU).190720-2034) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/897c55ca4ff84510ae2c1ac75f918e771/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5687.01 ((SQL14_SP2_QFE-CU).190720-2034) +``` + +# SQL Server 2014 SP2 CU17 - 12.0.5632.1 - x64 (KB4491540) +``` powershell +# SQL Server 2014 SP2 CU17 - 12.0.5632.1 - x64 (KB4491540) +$outputFolder = 'c:\sqlsyms\12.0.5632.1\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/7cec2abd211d44449ec0f3e94e1a78202/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.5632.01 ((SQL14_SP2_QFE-CU).190401-2109) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/093aba20ce644768bb722dfc74216a672/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5632.01 ((SQL14_SP2_QFE-CU).190401-2109) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/429635c72df34811b063bfbdc4fd30d72/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5632.01 ((SQL14_SP2_QFE-CU).190401-2109) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/3e544ec2f85b4e27b3d23c8316125f262/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.5632.01 ((SQL14_SP2_QFE-CU).190401-2109) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/f5e5a5a404464f80b46f6449a2dfa6a02/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5632.01 ((SQL14_SP2_QFE-CU).190401-2109) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/b5f8b9ae3a364402ac1b8bab1c3732512/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5632.01 ((SQL14_SP2_QFE-CU).190401-2109) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/cf46f2edea064dae95f6a457ba1ae1ef1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.5632.01 ((SQL14_SP2_QFE-CU).190401-2109) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/8a0ea19b90b84d7799d99bb3b751399d1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.5632.01 ((SQL14_SP2_QFE-CU).190401-2109) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/fa60812c91384eaf82bd97d59a2ff4e61/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.5632.01 ((SQL14_SP2_QFE-CU).190401-2109) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/310541c655dc434c9d834d1a6a196cfd1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5632.01 ((SQL14_SP2_QFE-CU).190401-2109) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/2de8f5bc87ff4a8390a0f454faf810282/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5632.01 ((SQL14_SP2_QFE-CU).190401-2109) +``` + +# SQL Server 2014 SP2 CU17 - 12.0.5632.1 - x86 (KB4491540) +``` powershell +# SQL Server 2014 SP2 CU17 - 12.0.5632.1 - x86 (KB4491540) +$outputFolder = 'c:\sqlsyms\12.0.5632.1\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/748fe7f884084be6bd64e1e9448d0ffe1/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.5632.01 ((SQL14_SP2_QFE-CU).190401-2109) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/545779f8eb8547d4abdd811f28c7f3f61/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5632.01 ((SQL14_SP2_QFE-CU).190401-2109) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/36d26ada3cf949229fda088acadabd831/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5632.01 ((SQL14_SP2_QFE-CU).190401-2109) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/478b047f2f8044b7b33aeded194ebfee1/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.5632.01 ((SQL14_SP2_QFE-CU).190401-2109) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/0466eb809cbe4386b49402ad9004229d2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5632.01 ((SQL14_SP2_QFE-CU).190401-2109) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/066f353a8df34b8c8bc789d6e27c5a321/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5632.01 ((SQL14_SP2_QFE-CU).190401-2109) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/6ac1205c109b49ae850f9ded968ffecb1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5632.01 ((SQL14_SP2_QFE-CU).190401-2109) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/eed60d89729949198006ca2352abf51f1/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5632.01 ((SQL14_SP2_QFE-CU).190401-2109) +``` + +# SQL Server 2014 SP2 CU16 - 12.0.5626.1 - x64 (KB4482967) +``` powershell +# SQL Server 2014 SP2 CU16 - 12.0.5626.1 - x64 (KB4482967) +$outputFolder = 'c:\sqlsyms\12.0.5626.1\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/7090b9b360f644bda3ac44b853a206d82/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.5626.01 ((SQL14_SP2_QFE-CU).190208-0024) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/6c9e5d6da1dd488d89eb0ae333b1c5eb2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5626.01 ((SQL14_SP2_QFE-CU).190208-0024) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/ea9b053430534dfc8f0dce4807a484682/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5626.01 ((SQL14_SP2_QFE-CU).190208-0024) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/98a4a92f370d402188b910a7435ba3f72/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.5626.01 ((SQL14_SP2_QFE-CU).190208-0024) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/d535d53ebf624bb29f5557ffbf0a5efc2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5626.01 ((SQL14_SP2_QFE-CU).190208-0024) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/54f79487ed6d40ea86bbcc67ff82b6e82/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5626.01 ((SQL14_SP2_QFE-CU).190208-0024) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/ea86d5e8467f4f289207290bec941f7a1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.5626.01 ((SQL14_SP2_QFE-CU).190208-0024) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/1d2496b66ea54f22851739b58fcd1d371/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.5626.01 ((SQL14_SP2_QFE-CU).190208-0024) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/70eb1fd8363e42419e5e5ee4a23d7af31/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.5626.01 ((SQL14_SP2_QFE-CU).190208-0024) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/0ceb3b389ce54506b0198b62af03a7a81/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5626.01 ((SQL14_SP2_QFE-CU).190208-0024) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/44cde1fe0341418cabb84df6877e072f2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5626.01 ((SQL14_SP2_QFE-CU).190208-0024) +``` + +# SQL Server 2014 SP2 CU16 - 12.0.5626.1 - x86 (KB4482967) +``` powershell +# SQL Server 2014 SP2 CU16 - 12.0.5626.1 - x86 (KB4482967) +$outputFolder = 'c:\sqlsyms\12.0.5626.1\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/b78052c424754a1e9f08450f02cf15261/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.5626.01 ((SQL14_SP2_QFE-CU).190208-0024) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/273a5267830d42a7aa3f38a52bc210cb1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5626.01 ((SQL14_SP2_QFE-CU).190208-0024) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/5256c66a20844f00876972b91c7606d01/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5626.01 ((SQL14_SP2_QFE-CU).190208-0024) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/f755234510654e88b5a922721ea8f8071/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.5626.01 ((SQL14_SP2_QFE-CU).190208-0024) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/dcbe2aea271c41d08af7f2ee653651c72/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5626.01 ((SQL14_SP2_QFE-CU).190208-0024) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/2c2f8b012a19446b80ca5f21ca91700c1/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5626.01 ((SQL14_SP2_QFE-CU).190208-0024) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/e59649446ebc4f07a5aa23edc78b5af11/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5626.01 ((SQL14_SP2_QFE-CU).190208-0024) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/d0b73290904841ca94d10ec14ad456ab1/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5626.01 ((SQL14_SP2_QFE-CU).190208-0024) +``` + +# SQL Server 2014 SP2 CU15 - 12.0.5605.1 - x64 (KB4469137) +``` powershell +# SQL Server 2014 SP2 CU15 - 12.0.5605.1 - x64 (KB4469137) +$outputFolder = 'c:\sqlsyms\12.0.5605.1\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/117240f0c59848f8afe7069fadb2be382/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.5605.01 ((SQL14_SP2_QFE-CU).181130-0132) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/876f1d479cf34b3cbcef15246fff9b2b2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5605.01 ((SQL14_SP2_QFE-CU).181130-0132) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/3204a130bbab4542902c7a8a2d83fa512/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5605.01 ((SQL14_SP2_QFE-CU).181130-0132) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/9d04ea3232d645d88d2918112a86965b2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.5605.01 ((SQL14_SP2_QFE-CU).181130-0132) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/271f77960efa4e848183c41e045ed28b2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5605.01 ((SQL14_SP2_QFE-CU).181130-0132) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/05287b373d6848818fed57489cb723882/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5605.01 ((SQL14_SP2_QFE-CU).181130-0132) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/37871400f6ba41cb87953ea6dee1679b1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.5605.01 ((SQL14_SP2_QFE-CU).181130-0132) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/a150b67635d9449e9cb1e54dc04057091/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.5605.01 ((SQL14_SP2_QFE-CU).181130-0132) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/729bc522263b44bf9d76c05c86d60aa71/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.5605.01 ((SQL14_SP2_QFE-CU).181130-0132) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/0efb398f50ac46a095e3db1d063494b71/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5605.01 ((SQL14_SP2_QFE-CU).181130-0132) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/8c1f27f1610d4083b6cfc03d8464e9702/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5605.01 ((SQL14_SP2_QFE-CU).181130-0132) +``` + +# SQL Server 2014 SP2 CU15 - 12.0.5605.1 - x86 (KB4469137) +``` powershell +# SQL Server 2014 SP2 CU15 - 12.0.5605.1 - x86 (KB4469137) +$outputFolder = 'c:\sqlsyms\12.0.5605.1\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/b80aa4d26d824d51a1b2821b3bd3c9df1/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.5605.01 ((SQL14_SP2_QFE-CU).181130-0132) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/a167e470217c45f8990402872693763c1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5605.01 ((SQL14_SP2_QFE-CU).181130-0132) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/8624d05eb3114058bb16484bb5b270f41/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5605.01 ((SQL14_SP2_QFE-CU).181130-0132) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/fbacb139597e46f5b710e865a66de6401/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.5605.01 ((SQL14_SP2_QFE-CU).181130-0132) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/5de0309257254890b30958eddac74d692/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5605.01 ((SQL14_SP2_QFE-CU).181130-0132) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/7c97495f85d545ec97e160ec95e08a051/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5605.01 ((SQL14_SP2_QFE-CU).181130-0132) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/8a2c37cc83db491095f9452840c70a5e1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5605.01 ((SQL14_SP2_QFE-CU).181130-0132) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/0ed0bd2de748480cae7a6fb8c9c720eb1/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5605.01 ((SQL14_SP2_QFE-CU).181130-0132) +``` + +# SQL Server 2014 SP2 CU14 - 12.0.5600.1 - x64 (KB4459860) +``` powershell +# SQL Server 2014 SP2 CU14 - 12.0.5600.1 - x64 (KB4459860) +$outputFolder = 'c:\sqlsyms\12.0.5600.1\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/2438e40ce685447eac9e01d2173b146d2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.5600.01 ((SQL14_SP2_QFE-CU).180927-2111) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/93a50030edc54ab2805e7324b5c5867e2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5600.01 ((SQL14_SP2_QFE-CU).180927-2111) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/b0b41b9743964fe2874cf90433ef7c9a2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5600.01 ((SQL14_SP2_QFE-CU).180927-2111) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/5e129aa1bde341ef9cd43882060582eb2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.5600.01 ((SQL14_SP2_QFE-CU).180927-2111) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/250c631ea1f249fdabc901273e8f7c452/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5600.01 ((SQL14_SP2_QFE-CU).180927-2111) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/e6f37c85e8004bfc8c74ccba69e5ce642/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5600.01 ((SQL14_SP2_QFE-CU).180927-2111) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/73600a8dc74945059ccf2d99ca8a377b1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.5600.01 ((SQL14_SP2_QFE-CU).180927-2111) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/c357ccbf716b47e29b48073179a6a2a81/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.5600.01 ((SQL14_SP2_QFE-CU).180927-2111) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/f925b1c9695d4dd28360ceb7e2976a581/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.5600.01 ((SQL14_SP2_QFE-CU).180927-2111) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/8ae4a300b56c475095d8ec409dbc31221/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5600.01 ((SQL14_SP2_QFE-CU).180927-2111) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/1b685a50036e4af388ff9f1fab8a795f2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5600.01 ((SQL14_SP2_QFE-CU).180927-2111) +``` + +# SQL Server 2014 SP2 CU14 - 12.0.5600.1 - x86 (KB4459860) +``` powershell +# SQL Server 2014 SP2 CU14 - 12.0.5600.1 - x86 (KB4459860) +$outputFolder = 'c:\sqlsyms\12.0.5600.1\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/c6575e4e12d94e4ba30764806d0577061/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.5600.01 ((SQL14_SP2_QFE-CU).180927-2111) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/61c9b48dd8af443780ba4556f948816d1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5600.01 ((SQL14_SP2_QFE-CU).180927-2111) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/88e4973a9b8548909a0ab9b691936ed31/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5600.01 ((SQL14_SP2_QFE-CU).180927-2111) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/62a1d5b32fc9473daeb6a9e21b76bf101/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.5600.01 ((SQL14_SP2_QFE-CU).180927-2111) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/ceebbde0de164cf985ce91e4e28d96862/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5600.01 ((SQL14_SP2_QFE-CU).180927-2111) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/5963ceed5f9b435d853a2c11315f11521/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5600.01 ((SQL14_SP2_QFE-CU).180927-2111) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/5cc038bc384c45578d1485fb3370f81c1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5600.01 ((SQL14_SP2_QFE-CU).180927-2111) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/441a2d9da7a2414f999efcac59e8da3d1/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5600.01 ((SQL14_SP2_QFE-CU).180927-2111) +``` + +# SQL Server 2014 SP2 CU13 - 12.0.5590.1 - x64 (KB4456287) +``` powershell +# SQL Server 2014 SP2 CU13 - 12.0.5590.1 - x64 (KB4456287) +$outputFolder = 'c:\sqlsyms\12.0.5590.1\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/f22828ad8cd143b98690f3d5308405a72/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.5590.01 ((SQL14_SP2_QFE-CU).180801-0048) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/38f99ac2329e4ee1a630dd928660bf8c2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5590.01 ((SQL14_SP2_QFE-CU).180801-0048) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/26704fbb534d46b49653205984de35ca2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5590.01 ((SQL14_SP2_QFE-CU).180801-0048) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/b9bbf018d2d24d3088f300f40de6569f2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.5590.01 ((SQL14_SP2_QFE-CU).180801-0048) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/7760942524a04b989b969dc6db24bba12/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5590.01 ((SQL14_SP2_QFE-CU).180801-0048) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/4d0c5e89bcee412c9100b8d694214c402/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5590.01 ((SQL14_SP2_QFE-CU).180801-0048) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/17b16aabe9944c3a83febffb78cbd6811/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.5590.01 ((SQL14_SP2_QFE-CU).180801-0048) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/c9216aed6e7645d39c0825a977c5a6f31/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.5590.01 ((SQL14_SP2_QFE-CU).180801-0048) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/9d9eadc9e8f8484eb83eb557687c059f1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.5590.01 ((SQL14_SP2_QFE-CU).180801-0048) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/3d021aaa04a8473abb5965725950c4ab1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5590.01 ((SQL14_SP2_QFE-CU).180801-0048) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/407d631b6e454fd0b0c041c33c345fd22/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5590.01 ((SQL14_SP2_QFE-CU).180801-0048) +``` + +# SQL Server 2014 SP2 CU13 - 12.0.5590.1 - x86 (KB4456287) +``` powershell +# SQL Server 2014 SP2 CU13 - 12.0.5590.1 - x86 (KB4456287) +$outputFolder = 'c:\sqlsyms\12.0.5590.1\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/33e588094276460b8038432fad3db2661/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.5590.01 ((SQL14_SP2_QFE-CU).180801-0048) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/629dce7389c24992a825468bd5191eae1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5590.01 ((SQL14_SP2_QFE-CU).180801-0048) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/5b493a35686047f1ba71f7ce7b3a90751/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5590.01 ((SQL14_SP2_QFE-CU).180801-0048) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/f7a83574ae43421b8468a07d493246ef1/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.5590.01 ((SQL14_SP2_QFE-CU).180801-0048) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/f158728bc8404e1aa43fe38433e4e6f82/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5590.01 ((SQL14_SP2_QFE-CU).180801-0048) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/1f241b8adf9748bca47525e287ae42451/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5590.01 ((SQL14_SP2_QFE-CU).180801-0048) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/bc679557623041a48db99e6ab3c27f691/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5590.01 ((SQL14_SP2_QFE-CU).180801-0048) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/f6f9e9d0148d47d7ad3abfc75f8bb31b1/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5590.01 ((SQL14_SP2_QFE-CU).180801-0048) +``` + +# SQL Server 2014 SP2 CU12 - 12.0.5589.7 - x64 (KB4130489) +``` powershell +# SQL Server 2014 SP2 CU12 - 12.0.5589.7 - x64 (KB4130489) +$outputFolder = 'c:\sqlsyms\12.0.5589.7\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/9cf25aee69fe4936b6d5dbc0a2864e562/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.5589.07 ((SQL14_SP2_QFE-CU).180609-1032) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/56bc64bb80724cbe9e73e3baf373ac5e2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5589.07 ((SQL14_SP2_QFE-CU).180609-1032) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/bfd1994080f84d2b832dc738a74466d62/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5589.07 ((SQL14_SP2_QFE-CU).180609-1032) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/c4b5a5ca9822464386d76070dc0b16c52/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.5589.07 ((SQL14_SP2_QFE-CU).180609-1032) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/69363948fbbe4b37a1942a397c28ac9a2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5589.07 ((SQL14_SP2_QFE-CU).180609-1032) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/7d1172991d104f70985859b8f5c1ca122/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5589.07 ((SQL14_SP2_QFE-CU).180609-1032) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/2ba38b2b5dc84ea29ba150f79b52c9b31/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.5589.07 ((SQL14_SP2_QFE-CU).180609-1032) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/f7947a9995b34b38bffe3a086f9ed3341/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.5589.07 ((SQL14_SP2_QFE-CU).180609-1032) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/d97a5e01a698460d9641e2017990f2ba1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.5589.07 ((SQL14_SP2_QFE-CU).180609-1032) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/bf808d6229bd4fe69562c672359a61b81/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5589.07 ((SQL14_SP2_QFE-CU).180609-1032) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/5abf57238fc44199bc9b494c7391a94a2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5589.07 ((SQL14_SP2_QFE-CU).180609-1032) +``` + +# SQL Server 2014 SP2 CU12 - 12.0.5589.7 - x86 (KB4130489) +``` powershell +# SQL Server 2014 SP2 CU12 - 12.0.5589.7 - x86 (KB4130489) +$outputFolder = 'c:\sqlsyms\12.0.5589.7\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/a17e4ed617604e1f93cb7043a7b061af1/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.5589.07 ((SQL14_SP2_QFE-CU).180609-1032) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/f1d22c428ec941b3ab6cf84b970013d21/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5589.07 ((SQL14_SP2_QFE-CU).180609-1032) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/3df9de6f254540598dd9da4852d8797d1/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5589.07 ((SQL14_SP2_QFE-CU).180609-1032) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/8a70299c32844f529bf7af758400e1a61/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.5589.07 ((SQL14_SP2_QFE-CU).180609-1032) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/c8053d2959e24d70bc2820ef3d183c4a2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5589.07 ((SQL14_SP2_QFE-CU).180609-1032) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/a2e7016632da4d79a7ffc36ec94956c21/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5589.07 ((SQL14_SP2_QFE-CU).180609-1032) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/0dd5355ca33a4d49a27401e7bed2e4241/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5589.07 ((SQL14_SP2_QFE-CU).180609-1032) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/bb53084f1e9c448db50e72d30284890d1/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5589.07 ((SQL14_SP2_QFE-CU).180609-1032) +``` + +# SQL Server 2014 SP2 CU11 - 12.0.5579.0 - x64 (KB4077063) +``` powershell +# SQL Server 2014 SP2 CU11 - 12.0.5579.0 - x64 (KB4077063) +$outputFolder = 'c:\sqlsyms\12.0.5579.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/0aea57c255f340f6b268422d36c9b5462/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.5579.00 ((SQL14_SP2_QFE-CU).180221-1111) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/8f7a73cfc7ae40b69cedfb56c478c8a42/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5579.00 ((SQL14_SP2_QFE-CU).180221-1111) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/6f3a59d764d34c1c9506c1cbb799ce282/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5579.00 ((SQL14_SP2_QFE-CU).180221-1111) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/5e23ac5ca0a441cea1043b92cc7db19d2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.5579.00 ((SQL14_SP2_QFE-CU).180221-1111) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/90418b6bc2dd41469db8c20a64cd6b082/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5579.00 ((SQL14_SP2_QFE-CU).180221-1111) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/4355cf52f7e54f1abd0d6545276e31242/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5579.00 ((SQL14_SP2_QFE-CU).180221-1111) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/6eacc2b3b2b54beba5e1e47ccf312c691/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.5579.00 ((SQL14_SP2_QFE-CU).180221-1111) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/43312b84f24d461582340aa0d3706e0f1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.5579.00 ((SQL14_SP2_QFE-CU).180221-1111) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/f88d3bc891cf4a66a06ab20db6a2f4111/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.5579.00 ((SQL14_SP2_QFE-CU).180221-1111) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/1a52dc5348f24ec98371fc0191786fa31/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5579.00 ((SQL14_SP2_QFE-CU).180221-1111) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/f9963e6eb1a34e019caf757ff0bdf2762/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5579.00 ((SQL14_SP2_QFE-CU).180221-1111) +``` + +# SQL Server 2014 SP2 CU11 - 12.0.5579.0 - x86 (KB4077063) +``` powershell +# SQL Server 2014 SP2 CU11 - 12.0.5579.0 - x86 (KB4077063) +$outputFolder = 'c:\sqlsyms\12.0.5579.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/2a38a3f0f77b410b8ab96959ec07f43f1/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.5579.00 ((SQL14_SP2_QFE-CU).180221-1111) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/ad85bbc382b94bc4b6d28c94bea7b09f1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5579.00 ((SQL14_SP2_QFE-CU).180221-1111) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/2c9ba43db9924d71be6599ef2ddfb6fa1/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5579.00 ((SQL14_SP2_QFE-CU).180221-1111) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/8b5208e65b4d420884a73dca82dfb5c61/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.5579.00 ((SQL14_SP2_QFE-CU).180221-1111) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/fd4511ab526d47b7ae5f18fa15dcb2ee2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5579.00 ((SQL14_SP2_QFE-CU).180221-1111) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/ace3687338a64ee99b1ddad95e5b5a611/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5579.00 ((SQL14_SP2_QFE-CU).180221-1111) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/ae50d44983714260bc12cb539b3ae6481/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5579.00 ((SQL14_SP2_QFE-CU).180221-1111) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/6524dc9692f44f0a954ebc34fba6566e1/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5579.00 ((SQL14_SP2_QFE-CU).180221-1111) +``` + +# SQL Server 2014 SP2 CU10 - 12.0.5571.0 - x64 (KB4052725) +``` powershell +# SQL Server 2014 SP2 CU10 - 12.0.5571.0 - x64 (KB4052725) +$outputFolder = 'c:\sqlsyms\12.0.5571.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/1f838ce4d2314a679d95f581ba5cfca72/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.5571.00 ((SQL14_SP2_QFE-CU).180110-1458) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/eb5287194386470bb6ed9be5cfa913032/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5571.00 ((SQL14_SP2_QFE-CU).180110-1458) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/187bfc99dd6142ed912b9b0a16971ba92/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5571.00 ((SQL14_SP2_QFE-CU).180110-1458) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/4a0d1ac8b530440581e5ee96278215352/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.5571.00 ((SQL14_SP2_QFE-CU).180110-1458) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/2a491b79a3534daaba1fdaee3ef28d412/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5571.00 ((SQL14_SP2_QFE-CU).180110-1458) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/88fe4b4b23a64afd804553959161691a2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5571.00 ((SQL14_SP2_QFE-CU).180110-1458) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/1dd40e165b074b0784aa0fa5c7225ce11/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.5571.00 ((SQL14_SP2_QFE-CU).180110-1458) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/42629264c38e41829734aca5e2c32b851/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.5571.00 ((SQL14_SP2_QFE-CU).180110-1458) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/9ff125ff36e841719e28e54c59d81e8a1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.5571.00 ((SQL14_SP2_QFE-CU).180110-1458) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/195069bf1697410789e1c320dcff547e1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5571.00 ((SQL14_SP2_QFE-CU).180110-1458) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/4ea18a049c454b7fab49fa3af4d747652/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5571.00 ((SQL14_SP2_QFE-CU).180110-1458) +``` + +# SQL Server 2014 SP2 CU10 - 12.0.5571.0 - x86 (KB4052725) +``` powershell +# SQL Server 2014 SP2 CU10 - 12.0.5571.0 - x86 (KB4052725) +$outputFolder = 'c:\sqlsyms\12.0.5571.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/7388785bb378492eae7399ead30a62bd1/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.5571.00 ((SQL14_SP2_QFE-CU).180110-1458) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/9ae111fc7f1b45789253f4d3910106c81/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5571.00 ((SQL14_SP2_QFE-CU).180110-1458) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/655a1096c0074f94b7ffbbf9b233ea5a1/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5571.00 ((SQL14_SP2_QFE-CU).180110-1458) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/cf11f8ed6ff04de7b823930a8451701b1/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.5571.00 ((SQL14_SP2_QFE-CU).180110-1458) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/273a0ff6e91b4a8da2bee5298a5dd61f2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5571.00 ((SQL14_SP2_QFE-CU).180110-1458) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/fa6377a396864fb2918b6a596d4beb711/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5571.00 ((SQL14_SP2_QFE-CU).180110-1458) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/464ae4327e2f4dc3b17e8f3a771ff18c1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5571.00 ((SQL14_SP2_QFE-CU).180110-1458) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/7cb655624af24ccc85f4389fb0c901241/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5571.00 ((SQL14_SP2_QFE-CU).180110-1458) +``` + +# SQL Server 2014 SP2 CU9 - 12.0.5563.0 - x64 (KB4055557) +``` powershell +# SQL Server 2014 SP2 CU9 - 12.0.5563.0 - x64 (KB4055557) +$outputFolder = 'c:\sqlsyms\12.0.5563.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/b9c9830b1bcc4092bd2bb4f51bf81cf52/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.5563.00 ((SQL14_SP2_QFE-CU).171207-0002) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/7032c53e91934abdbf6bad9fac99066c2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5563.00 ((SQL14_SP2_QFE-CU).171207-0002) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/bbfb8d689ab34f56b443d662c7b9336e2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5563.00 ((SQL14_SP2_QFE-CU).171207-0002) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/1143c59b5fee4cb9a86a2fa2978285562/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.5563.00 ((SQL14_SP2_QFE-CU).171207-0002) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/a5dfb5b4a0c041539cd6312fd52d8b2c2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5563.00 ((SQL14_SP2_QFE-CU).171207-0002) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/d0d7ae41d21e404694ddef3b58b555102/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5563.00 ((SQL14_SP2_QFE-CU).171207-0002) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/03fd2ef25c1540819c499476aa797f5a1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.5563.00 ((SQL14_SP2_QFE-CU).171207-0002) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/ffa799b2d4d2478186b883fe71edf34e1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.5563.00 ((SQL14_SP2_QFE-CU).171207-0002) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/a56ee479b9024d47bde320de941d1ad81/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.5563.00 ((SQL14_SP2_QFE-CU).171207-0002) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/0917fd5803fe42e9b8fcdbac6b428edb1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5563.00 ((SQL14_SP2_QFE-CU).171207-0002) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/d194fc1a9c914898b99235221a474a522/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5563.00 ((SQL14_SP2_QFE-CU).171207-0002) +``` + +# SQL Server 2014 SP2 CU9 - 12.0.5563.0 - x86 (KB4055557) +``` powershell +# SQL Server 2014 SP2 CU9 - 12.0.5563.0 - x86 (KB4055557) +$outputFolder = 'c:\sqlsyms\12.0.5563.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/06301e600c9448b49312e41cc75d51401/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.5563.00 ((SQL14_SP2_QFE-CU).171207-0002) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/3d79c403b6534fa3a1850e0f8e5cb71b1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5563.00 ((SQL14_SP2_QFE-CU).171207-0002) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/13d944a09a6b4075bec01634bb3c5ba61/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5563.00 ((SQL14_SP2_QFE-CU).171207-0002) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/57fbfa47c5064fdfbaa81ce84725cfd91/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.5563.00 ((SQL14_SP2_QFE-CU).171207-0002) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/fe70fe593a974da09e5170edc376b0622/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5563.00 ((SQL14_SP2_QFE-CU).171207-0002) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/cbecde3234164a3c871dd3a45649152b1/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5563.00 ((SQL14_SP2_QFE-CU).171207-0002) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/06186cc6b2eb40dab968c484987b96c41/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5563.00 ((SQL14_SP2_QFE-CU).171207-0002) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/3fa4e4db8ea34b0a86118d3b83e1a1721/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5563.00 ((SQL14_SP2_QFE-CU).171207-0002) +``` + +# SQL Server 2014 SP2 CU8 - 12.0.5557.0 - x64 (KB4037356) +``` powershell +# SQL Server 2014 SP2 CU8 - 12.0.5557.0 - x64 (KB4037356) +$outputFolder = 'c:\sqlsyms\12.0.5557.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/e7152ca5bb5641cabadc516f5de4448e2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.5557.00 ((SQL14_SP2_QFE-CU).171003-1352) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/976df45212de41739cfb5401b5395f032/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5557.00 ((SQL14_SP2_QFE-CU).171003-1352) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/d5029367d82748b08723648d64ea340c2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5557.00 ((SQL14_SP2_QFE-CU).171003-1352) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/1095950d7a964eca94e27667eec14dd22/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.5557.00 ((SQL14_SP2_QFE-CU).171003-1352) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/0b310c825aca4a7abef7b902667467e62/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5557.00 ((SQL14_SP2_QFE-CU).171003-1352) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/96dbb1b774234407bbfaa17da1e2538a2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5557.00 ((SQL14_SP2_QFE-CU).171003-1352) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/6aa802a2e06f497b86358cfbef459f031/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.5557.00 ((SQL14_SP2_QFE-CU).171003-1352) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/2d7ae65a5e784e3e9c8e06a697a64b6b1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.5557.00 ((SQL14_SP2_QFE-CU).171003-1352) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/f23892f30b094ded9d4b88ca2aab338b1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.5557.00 ((SQL14_SP2_QFE-CU).171003-1352) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/e7dfaaf012694a6db4eae23dc3b319e31/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5557.00 ((SQL14_SP2_QFE-CU).171003-1352) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/0d6e87edec3d4a5bb55a6f86db91f3112/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5557.00 ((SQL14_SP2_QFE-CU).171003-1352) +``` + +# SQL Server 2014 SP2 CU8 - 12.0.5557.0 - x86 (KB4037356) +``` powershell +# SQL Server 2014 SP2 CU8 - 12.0.5557.0 - x86 (KB4037356) +$outputFolder = 'c:\sqlsyms\12.0.5557.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/1c82caaaa09e48eba283def9ee6a77041/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.5557.00 ((SQL14_SP2_QFE-CU).171003-1352) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/981f442e7b8a4ff4b016c222f897ec1e1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5557.00 ((SQL14_SP2_QFE-CU).171003-1352) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/bd794c7b740e447cbff73748980a6f1b1/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5557.00 ((SQL14_SP2_QFE-CU).171003-1352) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/383f44422d364daab6360a0dbd8961481/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.5557.00 ((SQL14_SP2_QFE-CU).171003-1352) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/7e546ae16c48449396f2a6c30dc8d35b2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5557.00 ((SQL14_SP2_QFE-CU).171003-1352) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/4daecbd75bfd4b6f9af8fce5ec09aa9d1/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5557.00 ((SQL14_SP2_QFE-CU).171003-1352) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/9fa6bf9d3fb54bb98a5f0124bfb3e14e1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5557.00 ((SQL14_SP2_QFE-CU).171003-1352) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/d04a9e96c37045e98b5c7b3b8b81096d1/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5557.00 ((SQL14_SP2_QFE-CU).171003-1352) +``` + +# SQL Server 2014 SP2 CU5 - 12.0.5546.0 - x64 (KB4013098) +``` powershell +# SQL Server 2014 SP2 CU5 - 12.0.5546.0 - x64 (KB4013098) +$outputFolder = 'c:\sqlsyms\12.0.5546.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/50741efef953472e93c9c4449641b7b12/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.5546.00 ((SQL14_SP2_QFE-CU).170403-1355) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/eba63b27a035483d8aa8328a1ae4e5032/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5546.00 ((SQL14_SP2_QFE-CU).170403-1355) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/5cf0fb086a51465eae2224c47d6929a12/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5546.00 ((SQL14_SP2_QFE-CU).170403-1355) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/e261efec946a49d8bd60ad2d2d0d4f412/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.5546.00 ((SQL14_SP2_QFE-CU).170403-1355) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/4e1c24324a24404db55cab70549295842/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5546.00 ((SQL14_SP2_QFE-CU).170403-1355) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/b4f8f667b3d14a67b4d6603088e655742/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5546.00 ((SQL14_SP2_QFE-CU).170403-1355) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/236b638fded8473898894137c7838d5c1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.5546.00 ((SQL14_SP2_QFE-CU).170403-1355) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/7ac0b64a624249d9b29869bc24c71bb91/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.5546.00 ((SQL14_SP2_QFE-CU).170403-1355) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/dab7c2d4a1d74357a7e35e4823c201241/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.5546.00 ((SQL14_SP2_QFE-CU).170403-1355) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/6ba2f0c99aac4edfb5f1154130a28aff1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5546.00 ((SQL14_SP2_QFE-CU).170403-1355) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/d4afa77c6b874237bef59d288e3502712/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5546.00 ((SQL14_SP2_QFE-CU).170403-1355) +``` + +# SQL Server 2014 SP2 CU5 - 12.0.5546.0 - x86 (KB4013098) +``` powershell +# SQL Server 2014 SP2 CU5 - 12.0.5546.0 - x86 (KB4013098) +$outputFolder = 'c:\sqlsyms\12.0.5546.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/7cc57429e0ec49fbbb5a7e0bde3ed2f51/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.5546.00 ((SQL14_SP2_QFE-CU).170403-1355) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/0b763c98cd3540cc87fbae90dd4d293e1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5546.00 ((SQL14_SP2_QFE-CU).170403-1355) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/faebc6f4ea6f4aa9b51dd320a99cdf6a1/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5546.00 ((SQL14_SP2_QFE-CU).170403-1355) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/df2f1f29a7ee42209c3d1083a539cdab1/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.5546.00 ((SQL14_SP2_QFE-CU).170403-1355) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/4e548597f1554021a96df9a125e321c12/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5546.00 ((SQL14_SP2_QFE-CU).170403-1355) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/1c1ab29dd2684425be41d15d14f82eda1/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5546.00 ((SQL14_SP2_QFE-CU).170403-1355) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/52aa8ba5e2dc47a3b05441a95feaaad41/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5546.00 ((SQL14_SP2_QFE-CU).170403-1355) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/41250386e94f4b749067a8bdf653fad31/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5546.00 ((SQL14_SP2_QFE-CU).170403-1355) +``` + +# SQL Server 2014 SP2 CU4 - 12.0.5540.0 - x64 (KB4010394) +``` powershell +# SQL Server 2014 SP2 CU4 - 12.0.5540.0 - x64 (KB4010394) +$outputFolder = 'c:\sqlsyms\12.0.5540.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/327f327fa575417cafb328a77700579b2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.5540.00 ((SQL14_SP2_QFE-CU).170126-2112) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/b33973d4b2b84e898cf5fdbcc0cbfdda2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5540.00 ((SQL14_SP2_QFE-CU).170126-2112) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/7c3b4d37cd874b8b9046197faa764b8a2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5540.00 ((SQL14_SP2_QFE-CU).170126-2112) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/5c620c62165d4d6c929c48fbf285ecee2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.5540.00 ((SQL14_SP2_QFE-CU).170126-2112) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/573e711ad5ff4306afcf4ead17f3ccd32/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5540.00 ((SQL14_SP2_QFE-CU).170126-2112) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/134dec74500e4623ac8395fd0f7b39002/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5540.00 ((SQL14_SP2_QFE-CU).170126-2112) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/efafa5fc3ed741138011d67be2e0956e1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.5540.00 ((SQL14_SP2_QFE-CU).170126-2112) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/322ab5e1bdb44d00b01fadf709cedb591/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.5540.00 ((SQL14_SP2_QFE-CU).170126-2112) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/2e34b42cd60244c18d4d932740df1fba1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.5540.00 ((SQL14_SP2_QFE-CU).170126-2112) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/5fa1d5a4f5184d8a96340d50ca49b8f91/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5540.00 ((SQL14_SP2_QFE-CU).170126-2112) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/15a01dcd6514423dabf05a79ddbc260c2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5540.00 ((SQL14_SP2_QFE-CU).170126-2112) +``` + +# SQL Server 2014 SP2 CU4 - 12.0.5540.0 - x86 (KB4010394) +``` powershell +# SQL Server 2014 SP2 CU4 - 12.0.5540.0 - x86 (KB4010394) +$outputFolder = 'c:\sqlsyms\12.0.5540.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/3b24410a96fc4557937d8680025104781/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.5540.00 ((SQL14_SP2_QFE-CU).170126-2112) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/de2cbe9a066b4ca683edb111b07e98fe1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5540.00 ((SQL14_SP2_QFE-CU).170126-2112) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/65d8e8258a7d425b919ff886fef2a46e1/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5540.00 ((SQL14_SP2_QFE-CU).170126-2112) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/a55b0dba79c145579d868184299943121/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.5540.00 ((SQL14_SP2_QFE-CU).170126-2112) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/a45a2e2de940478cb4da26c83ed480c02/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5540.00 ((SQL14_SP2_QFE-CU).170126-2112) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/91505e4ffbab42b0bb9fce392119d2a31/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5540.00 ((SQL14_SP2_QFE-CU).170126-2112) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/51b204af39e4418e8e436b505def119d1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5540.00 ((SQL14_SP2_QFE-CU).170126-2112) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/c8cdb62c1d024e1ebcd1167ea4e408fd1/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5540.00 ((SQL14_SP2_QFE-CU).170126-2112) +``` + +# SQL Server 2014 SP2 CU3 - 12.0.5538.0 - x64 (KB3204388) +``` powershell +# SQL Server 2014 SP2 CU3 - 12.0.5538.0 - x64 (KB3204388) +$outputFolder = 'c:\sqlsyms\12.0.5538.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/3b2ec8a276c44fdc906942cd4a1f69182/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.5538.00 ((SQL14_SP2_QFE-CU).161215-1705) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/a2983d6c8beb482197eea282afd09f502/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5538.00 ((SQL14_SP2_QFE-CU).161215-1705) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/f15dfc2d86f545358f47d7963137b3772/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5538.00 ((SQL14_SP2_QFE-CU).161215-1705) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/51c7e960bc594a57948755163fc43a492/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.5538.00 ((SQL14_SP2_QFE-CU).161215-1705) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/d11bb61c53bf4b68a2c3ba2527bd73bc2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5538.00 ((SQL14_SP2_QFE-CU).161215-1705) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/bd27195567bb4bf8a03bb27ceec1b7432/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5538.00 ((SQL14_SP2_QFE-CU).161215-1705) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/e48b584befcc4a70adb8046bcf451a2e1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.5538.00 ((SQL14_SP2_QFE-CU).161215-1705) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/b580840b77684d8a8f6eda6fc85965451/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.5538.00 ((SQL14_SP2_QFE-CU).161215-1705) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/94c127c2d37e4e489484c51a03884ac11/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.5538.00 ((SQL14_SP2_QFE-CU).161215-1705) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/7ccaba5c7002409fa220d36307fc2b8b1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5538.00 ((SQL14_SP2_QFE-CU).161215-1705) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/8e5ff8ec981943338edc6cd886bd8fb82/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5538.00 ((SQL14_SP2_QFE-CU).161215-1705) +``` + +# SQL Server 2014 SP2 CU3 - 12.0.5538.0 - x86 (KB3204388) +``` powershell +# SQL Server 2014 SP2 CU3 - 12.0.5538.0 - x86 (KB3204388) +$outputFolder = 'c:\sqlsyms\12.0.5538.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/baa30c554cb44fa09d0bdfbed39e5a791/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.5538.00 ((SQL14_SP2_QFE-CU).161215-1705) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/3dd488b8d441453dbd8745f0a544e7a61/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5538.00 ((SQL14_SP2_QFE-CU).161215-1705) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/47108c8b37424ae8851820cfe82c9e121/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5538.00 ((SQL14_SP2_QFE-CU).161215-1705) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/b8d1890d88e746a998e86b2f3c74364c1/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.5538.00 ((SQL14_SP2_QFE-CU).161215-1705) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/848570152cb8402aa9d6fada8beb0c202/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5538.00 ((SQL14_SP2_QFE-CU).161215-1705) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/dde9b5fc95434bcdaf74b851a180a39a1/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5538.00 ((SQL14_SP2_QFE-CU).161215-1705) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/f57e00c99b1542da9050e3c79e4fc0751/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5538.00 ((SQL14_SP2_QFE-CU).161215-1705) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/ad0a17bd74a343c68885438c5a1667261/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5538.00 ((SQL14_SP2_QFE-CU).161215-1705) +``` + +# SQL Server 2014 SP2 CU2 - 12.0.5522.0 - x64 (KB3188778) +``` powershell +# SQL Server 2014 SP2 CU2 - 12.0.5522.0 - x64 (KB3188778) +$outputFolder = 'c:\sqlsyms\12.0.5522.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/85619806cd0c4d7f80b7d9c39ec0c55d2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.5522.00 ((SQL14_PCU_main).160921-2323) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/b7c764dde62d4501ad899b44155266f42/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5522.00 ((SQL14_PCU_main).160921-2323) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/42c45987637146d9b0b6a18b3c16b4ed2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5522.00 ((SQL14_PCU_main).160921-2323) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/a0718d2fb2484e6a9690d00a513a7ec22/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.5522.00 ((SQL14_PCU_main).160921-2323) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/925f17833290448e8a4a1981956919f72/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5522.00 ((SQL14_PCU_main).160921-2323) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/f8b1d43023e94a69ad0ebdbdef8184262/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5522.00 ((SQL14_PCU_main).160921-2323) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/cec32d3f65ae45e8a01456021c1965331/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.5522.00 ((SQL14_PCU_main).160921-2323) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/e5b418e31d1e4c7288dce466806e4a651/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.5522.00 ((SQL14_PCU_main).160921-2323) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/e0a453b334904529a2b117ea1654e0071/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.5522.00 ((SQL14_PCU_main).160921-2323) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/46ca775ce2b347cf9a0497239589b9891/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5522.00 ((SQL14_PCU_main).160921-2323) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/944350d206c94698a2d2836213aa3cd42/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5522.00 ((SQL14_PCU_main).160921-2323) +``` + +# SQL Server 2014 SP2 CU2 - 12.0.5522.0 - x86 (KB3188778) +``` powershell +# SQL Server 2014 SP2 CU2 - 12.0.5522.0 - x86 (KB3188778) +$outputFolder = 'c:\sqlsyms\12.0.5522.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/84f5af3698d149afa148b2a0cd3f4f581/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.5522.00 ((SQL14_PCU_main).160921-2323) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/213e8207dbe444d0909729961a287bd11/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5522.00 ((SQL14_PCU_main).160921-2323) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/4bc737f7ee4c42ddabdc2dbd286531231/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5522.00 ((SQL14_PCU_main).160921-2323) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/b288a2b59dc74ac7b41ab91de6c4fc761/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.5522.00 ((SQL14_PCU_main).160921-2323) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/ffa4bbede27e459680aa2c3492dc76de2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5522.00 ((SQL14_PCU_main).160921-2323) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/cff1f891748b4e46975bff972020c88d1/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5522.00 ((SQL14_PCU_main).160921-2323) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/68063a6d27944efc9b396708c391443a1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5522.00 ((SQL14_PCU_main).160921-2323) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/50ee2c4f4dba45cbabed0418e30529771/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5522.00 ((SQL14_PCU_main).160921-2323) +``` + +# SQL Server 2014 SP2 CU1 - 12.0.5511.0 - x64 (KB3178925) +``` powershell +# SQL Server 2014 SP2 CU1 - 12.0.5511.0 - x64 (KB3178925) +$outputFolder = 'c:\sqlsyms\12.0.5511.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/955297012f084a879c084982baeb90802/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.5511.00 ((SQL14_PCU_main).160819-1335) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/6c97245a05ce4bb99d73b38531d5c1fd2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5511.00 ((SQL14_PCU_main).160819-1335) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/115b0bf758864697975c5a790169856e2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5511.00 ((SQL14_PCU_main).160819-1335) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/512c482f3fb045bda66e04e34964fb3a2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.5511.00 ((SQL14_PCU_main).160819-1335) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/f769c28a891e437a9c794fc1ec7472752/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5511.00 ((SQL14_PCU_main).160819-1335) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/f143a40c5a8440bf8478537feeee5d642/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5511.00 ((SQL14_PCU_main).160819-1335) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/b17b7a8868cb42579bae8551a8c7e0591/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.5511.00 ((SQL14_PCU_main).160819-1335) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/e2182fd204d84ab99011cccd1949e9c11/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.5511.00 ((SQL14_PCU_main).160819-1335) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/27105a4614ac45c2ae4efbf8702e3afc1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.5511.00 ((SQL14_PCU_main).160819-1335) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/40b6d2eebb0d495ca7712c349427f5de1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5511.00 ((SQL14_PCU_main).160819-1335) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/5f5f15692fa448e79427eb55f742b9512/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5511.00 ((SQL14_PCU_main).160819-1335) +``` + +# SQL Server 2014 SP2 CU1 - 12.0.5511.0 - x86 (KB3178925) +``` powershell +# SQL Server 2014 SP2 CU1 - 12.0.5511.0 - x86 (KB3178925) +$outputFolder = 'c:\sqlsyms\12.0.5511.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/7cfba95f3823488aac2461a3e97e896f1/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.5511.00 ((SQL14_PCU_main).160819-1335) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/da9e2bc4951043bd81090ae40dede7a11/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5511.00 ((SQL14_PCU_main).160819-1335) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/aeff84391a5b452fbfcde0f4a892c5a11/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5511.00 ((SQL14_PCU_main).160819-1335) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/5939ac9c2ded4145bcf7770744fd2bce1/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.5511.00 ((SQL14_PCU_main).160819-1335) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/29a54a98b892439391394e42b0b5db512/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5511.00 ((SQL14_PCU_main).160819-1335) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/ed2df1c1d06e4545bdf23aaaaf209acc1/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5511.00 ((SQL14_PCU_main).160819-1335) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/e1cccd08ad4847b7b40a5d54d95e458e1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5511.00 ((SQL14_PCU_main).160819-1335) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/8ca704ad75a147c083468e8128a8d1c71/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5511.00 ((SQL14_PCU_main).160819-1335) +``` + +# SQL Server 2014 SP2 SP2 - 12.0.5000.0 - x64 (KB3171021) +``` powershell +# SQL Server 2014 SP2 SP2 - 12.0.5000.0 - x64 (KB3171021) +$outputFolder = 'c:\sqlsyms\12.0.5000.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/9b03bed67fb8409cb0790cc7b223dad92/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.5000.00 ((SQL14_PCU_main).160617-1804) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/d06bb22769e2403894634bf47dced50d2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5000.00 ((SQL14_PCU_main).160617-1804) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/4505a8d6fda14645ba80e4c411ed63512/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5000.00 ((SQL14_PCU_main).160617-1804) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/421f256c2b694c9f997cc27b691db8e82/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.5000.00 ((SQL14_PCU_main).160617-1804) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/581e38dca5b2499ea574ffc0173d6bb12/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5000.00 ((SQL14_PCU_main).160617-1804) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/ca529b22f161423c9266aa03928136612/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5000.00 ((SQL14_PCU_main).160617-1804) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/16d952f37ecc4c839f06fc3f0a8e858b1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.5000.00 ((SQL14_PCU_main).160617-1804) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/49e9ae321a004d859a4844a1881682fd1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.5000.00 ((SQL14_PCU_main).160617-1804) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/e2bbf32382d24e16a4567c49dffedc1a1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.5000.00 ((SQL14_PCU_main).160617-1804) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/bdcaa196c0824ba38ddec076b5fd89521/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5000.00 ((SQL14_PCU_main).160617-1804) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/cc3cd23e34174332ae8778d4e4b7991f2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5000.00 ((SQL14_PCU_main).160617-1804) +``` + +# SQL Server 2014 SP2 SP2 - 12.0.5000.0 - x86 (KB3171021) +``` powershell +# SQL Server 2014 SP2 SP2 - 12.0.5000.0 - x86 (KB3171021) +$outputFolder = 'c:\sqlsyms\12.0.5000.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/3520a09c560647b0be4af33b838bb70f1/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.5000.00 ((SQL14_PCU_main).160617-1804) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/d0a102b60e2d4138a7435f98d7305ed21/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.5000.00 ((SQL14_PCU_main).160617-1804) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/739a59d06bce47de8b1bf3d77899ba601/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.5000.00 ((SQL14_PCU_main).160617-1804) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/34d38d0ff9ad490cb7c02c96ee741a651/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.5000.00 ((SQL14_PCU_main).160617-1804) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/16e45d5242524db7a022a600e0a58bd12/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.5000.00 ((SQL14_PCU_main).160617-1804) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/3105a463134247deb442c42904dd6af61/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.5000.00 ((SQL14_PCU_main).160617-1804) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/f54482c3160047a0bffd5ee829fc930c1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.5000.00 ((SQL14_PCU_main).160617-1804) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/4ef9cb8fd3c141bcb4f1af7c26cbf7571/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.5000.00 ((SQL14_PCU_main).160617-1804) +``` + +# SQL Server 2014 SP1 CU12 - 12.0.4511.0 - x64 (KB4017793) +``` powershell +# SQL Server 2014 SP1 CU12 - 12.0.4511.0 - x64 (KB4017793) +$outputFolder = 'c:\sqlsyms\12.0.4511.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/5194020c2bb54e35b975fb4b822687822/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.4511.00 ((SQL14_SP1_QFE-CU).170330-2026) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/c3e92c0187324b64902b44eb0d2e42ed2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4511.00 ((SQL14_SP1_QFE-CU).170330-2026) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/828309d8e65a4661bef26612e6c66da12/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4511.00 ((SQL14_SP1_QFE-CU).170330-2026) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/d17b6b1b84b74212b072a8b5bdd573b92/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.4511.00 ((SQL14_SP1_QFE-CU).170330-2026) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/15ed0973c9214f76b84dce1924c47f2c2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4511.00 ((SQL14_SP1_QFE-CU).170330-2026) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/5347b58cfec447408dea4ef359a7fee82/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4511.00 ((SQL14_SP1_QFE-CU).170330-2026) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/63966ccc66c6484197a1c5472f9ffba61/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.4511.00 ((SQL14_SP1_QFE-CU).170330-2026) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/15bee1647bc8463e9222aae1c310334a1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.4511.00 ((SQL14_SP1_QFE-CU).170330-2026) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/b8e0b1f00b4c47c3817d8d3211bd97eb1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.4511.00 ((SQL14_SP1_QFE-CU).170330-2026) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/7f74ffbfb5634301908b7c0a815e1e811/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4511.00 ((SQL14_SP1_QFE-CU).170330-2026) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/c0bb53c9d4624637846157dcba6945322/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4511.00 ((SQL14_SP1_QFE-CU).170330-2026) +``` + +# SQL Server 2014 SP1 CU12 - 12.0.4511.0 - x86 (KB4017793) +``` powershell +# SQL Server 2014 SP1 CU12 - 12.0.4511.0 - x86 (KB4017793) +$outputFolder = 'c:\sqlsyms\12.0.4511.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/1716ba550f704b47be04801c46ddd2271/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.4511.00 ((SQL14_SP1_QFE-CU).170330-2026) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/b07fe01e0c1d4fafadf3b3ae1198b23c1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4511.00 ((SQL14_SP1_QFE-CU).170330-2026) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/5b2e3ff1f9ea426bb60c065573ba35851/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4511.00 ((SQL14_SP1_QFE-CU).170330-2026) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/06525a5e3eb34b839bfc1af702354c0f1/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.4511.00 ((SQL14_SP1_QFE-CU).170330-2026) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/5b0356ce9df44d3ebc3aaf4752c4dbc42/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4511.00 ((SQL14_SP1_QFE-CU).170330-2026) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/cfe4d232673d4feca1536f22af5d7da01/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4511.00 ((SQL14_SP1_QFE-CU).170330-2026) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/1638c8bafaa4484f8115dc810f65688c1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4511.00 ((SQL14_SP1_QFE-CU).170330-2026) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/0cb40d6a5aee4627a803997293d2bc9f1/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4511.00 ((SQL14_SP1_QFE-CU).170330-2026) +``` + +# SQL Server 2014 SP1 CU11 - 12.0.4502.0 - x64 (KB4010392) +``` powershell +# SQL Server 2014 SP1 CU11 - 12.0.4502.0 - x64 (KB4010392) +$outputFolder = 'c:\sqlsyms\12.0.4502.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/6511e1af7762429a824f8d9413f8185b2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.4502.00 ((SQL14_SP1_QFE-CU).170126-2035) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/0855528f0c094a8d9ddaa082dc6273892/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4502.00 ((SQL14_SP1_QFE-CU).170126-2035) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/2d502c894cf145449e35bb27b9e723632/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4502.00 ((SQL14_SP1_QFE-CU).170126-2035) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/4e718d4e6aaa4267a812e7a96d96e4192/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.4502.00 ((SQL14_SP1_QFE-CU).170126-2035) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/e3bc90eb56494cef8d0bb1c27630e7e82/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4502.00 ((SQL14_SP1_QFE-CU).170126-2035) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/79e86271788b4ad8a73585aca0712a572/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4502.00 ((SQL14_SP1_QFE-CU).170126-2035) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/74b685c445be4b0abc1e40a39b1ce15e1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.4502.00 ((SQL14_SP1_QFE-CU).170126-2035) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/fdad2621c0fd4be18f295ef7666f71541/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.4502.00 ((SQL14_SP1_QFE-CU).170126-2035) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/fead2b11478e4f16957015b1c716dbf51/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.4502.00 ((SQL14_SP1_QFE-CU).170126-2035) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/2fef4d7e355741078263ba0359236cb51/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4502.00 ((SQL14_SP1_QFE-CU).170126-2035) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/baa3f42ceb4441f0a0362400473a45a32/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4502.00 ((SQL14_SP1_QFE-CU).170126-2035) +``` + +# SQL Server 2014 SP1 CU11 - 12.0.4502.0 - x86 (KB4010392) +``` powershell +# SQL Server 2014 SP1 CU11 - 12.0.4502.0 - x86 (KB4010392) +$outputFolder = 'c:\sqlsyms\12.0.4502.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/05c3adbed7b94c678abd5818fb1df1981/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.4502.00 ((SQL14_SP1_QFE-CU).170126-2035) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/4e38ef962bd44249a4374f46e4918e491/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4502.00 ((SQL14_SP1_QFE-CU).170126-2035) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/1f790bbb27d94e7d8f76905be4ea8a8a1/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4502.00 ((SQL14_SP1_QFE-CU).170126-2035) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/118dcefd951242c2b376ce23b8ca149d1/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.4502.00 ((SQL14_SP1_QFE-CU).170126-2035) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/16bba5c457c24f71816590513599284d2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4502.00 ((SQL14_SP1_QFE-CU).170126-2035) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/1c2171f6e4c942a78d884a965ca2c2311/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4502.00 ((SQL14_SP1_QFE-CU).170126-2035) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/b2e5cdea0e254b88aec4f52ff7d81bce1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4502.00 ((SQL14_SP1_QFE-CU).170126-2035) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/22ff6b3197a54e6d8e424fb153ee85291/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4502.00 ((SQL14_SP1_QFE-CU).170126-2035) +``` + +# SQL Server 2014 SP1 CU10 - 12.0.4491.0 - x64 (KB3204399) +``` powershell +# SQL Server 2014 SP1 CU10 - 12.0.4491.0 - x64 (KB3204399) +$outputFolder = 'c:\sqlsyms\12.0.4491.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/9d45c0ca9ff84210bd26d27a1db957b32/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.4491.00 ((SQL14_SP1_QFE-CU).161209-1421) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/fed498da893e422cac5e804b2b7a4c242/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4491.00 ((SQL14_SP1_QFE-CU).161209-1421) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/2ad37367352148f6979dfdc99264bead2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4491.00 ((SQL14_SP1_QFE-CU).161209-1421) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/9d0d6af6a3844491ba66db3b3a0e41992/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.4491.00 ((SQL14_SP1_QFE-CU).161209-1421) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/cdb4ecf4e5554b98963cfc8713f18def2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4491.00 ((SQL14_SP1_QFE-CU).161209-1421) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/f524bcc24a0a4a09aeac95cdd7ff44cc2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4491.00 ((SQL14_SP1_QFE-CU).161209-1421) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/018fb92048554db0b8ce8d938f36c1af1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.4491.00 ((SQL14_SP1_QFE-CU).161209-1421) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/6f4088e11c2141038659ad6f5d75d67e1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.4491.00 ((SQL14_SP1_QFE-CU).161209-1421) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/ef95d5619182441cba33ee5fcc0db2a11/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.4491.00 ((SQL14_SP1_QFE-CU).161209-1421) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/e6bbf5f834c248888873d9a1a9644be91/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4491.00 ((SQL14_SP1_QFE-CU).161209-1421) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/ed041be3c310451d8c409219c552e7f32/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4491.00 ((SQL14_SP1_QFE-CU).161209-1421) +``` + +# SQL Server 2014 SP1 CU10 - 12.0.4491.0 - x86 (KB3204399) +``` powershell +# SQL Server 2014 SP1 CU10 - 12.0.4491.0 - x86 (KB3204399) +$outputFolder = 'c:\sqlsyms\12.0.4491.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/d2366262dd7941978da45d5e683f7c101/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.4491.00 ((SQL14_SP1_QFE-CU).161209-1421) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/d800a487ae16476aad1a1d3a6000b3d81/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4491.00 ((SQL14_SP1_QFE-CU).161209-1421) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/47e138b038f94533b40e4cda75009dd11/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4491.00 ((SQL14_SP1_QFE-CU).161209-1421) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/ea65c57da53241919f6b2c099baddf6b1/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.4491.00 ((SQL14_SP1_QFE-CU).161209-1421) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/300035b8a93d4361bb955f88c14a9ec02/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4491.00 ((SQL14_SP1_QFE-CU).161209-1421) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/5d479ce08c8f4a3189fc00cb7d96396f1/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4491.00 ((SQL14_SP1_QFE-CU).161209-1421) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/8b12d29053264fc798fb8b7312f457a61/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4491.00 ((SQL14_SP1_QFE-CU).161209-1421) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/40548e898f644819908b614970e763f51/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4491.00 ((SQL14_SP1_QFE-CU).161209-1421) +``` + +# SQL Server 2014 SP1 CU9 - 12.0.4474.0 - x64 (KB3186964) +``` powershell +# SQL Server 2014 SP1 CU9 - 12.0.4474.0 - x64 (KB3186964) +$outputFolder = 'c:\sqlsyms\12.0.4474.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/ed3eb06f842543d287a3f4b7976a290e2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.4474.00 ((SQL14_SP1_QFE-CU).160921-2215) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/f68fd847991e45efb467567f043365c92/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4474.00 ((SQL14_SP1_QFE-CU).160921-2215) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/f39da543554a46fa9f66356d10ae25ba2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4474.00 ((SQL14_SP1_QFE-CU).160921-2215) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/4e632d1dba694b07b1420d42203131fb2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.4474.00 ((SQL14_SP1_QFE-CU).160921-2215) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/e6b6452458da4bfb90b095db670835ba2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4474.00 ((SQL14_SP1_QFE-CU).160921-2215) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/459d7854b8b442f7a7d16164e13d223e2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4474.00 ((SQL14_SP1_QFE-CU).160921-2215) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/dbbebce79710422da003b9b362db90471/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.4474.00 ((SQL14_SP1_QFE-CU).160921-2215) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/039cb07174774ae984a6c127254d699b1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.4474.00 ((SQL14_SP1_QFE-CU).160921-2215) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/cd5d4f223a81432b9a94c70f090bdbfa1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.4474.00 ((SQL14_SP1_QFE-CU).160921-2215) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/587aafcade5c4befb8a21f74a0472f991/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4474.00 ((SQL14_SP1_QFE-CU).160921-2215) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/40263aec90934578b565fd5738ab0fe82/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4474.00 ((SQL14_SP1_QFE-CU).160921-2215) +``` + +# SQL Server 2014 SP1 CU9 - 12.0.4474.0 - x86 (KB3186964) +``` powershell +# SQL Server 2014 SP1 CU9 - 12.0.4474.0 - x86 (KB3186964) +$outputFolder = 'c:\sqlsyms\12.0.4474.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/a2983e7c5b434d9fbc6828950649cd531/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.4474.00 ((SQL14_SP1_QFE-CU).160921-2215) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/814705e58f2a452282645ab653b330771/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4474.00 ((SQL14_SP1_QFE-CU).160921-2215) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/d29ed6114bab459499a99eb2aa5c9d901/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4474.00 ((SQL14_SP1_QFE-CU).160921-2215) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/5577ca7998974f91a2830c9130544b4b1/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.4474.00 ((SQL14_SP1_QFE-CU).160921-2215) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/f5a4f8db221443c88c6c01c2097d5f012/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4474.00 ((SQL14_SP1_QFE-CU).160921-2215) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/8addcf093cf549e5b363e7bc4c1ff3d21/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4474.00 ((SQL14_SP1_QFE-CU).160921-2215) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/7ab2c10294bc42ba84947f929ef553501/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4474.00 ((SQL14_SP1_QFE-CU).160921-2215) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/9256f9eed09947189e79d8d088a780771/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4474.00 ((SQL14_SP1_QFE-CU).160921-2215) +``` + +# SQL Server 2014 SP1 CU8 - 12.0.4468.0 - x64 (KB3174038) +``` powershell +# SQL Server 2014 SP1 CU8 - 12.0.4468.0 - x64 (KB3174038) +$outputFolder = 'c:\sqlsyms\12.0.4468.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/3d92fd2a73794d07b455ae4e5889a5132/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.4468.00 ((SQL14_SP1_QFE-CU).160807-1306) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/b3729fa94bef405fb2cb87260238c9f42/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4468.00 ((SQL14_SP1_QFE-CU).160807-1306) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/5ce178c1c5d64b0c87dfe545697274d42/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4468.00 ((SQL14_SP1_QFE-CU).160807-1306) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/3cad76e8bd284c3d843ddf72eebdeb6f2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.4468.00 ((SQL14_SP1_QFE-CU).160807-1306) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/690748ff94a84fe2a84415950be20d8b2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4468.00 ((SQL14_SP1_QFE-CU).160807-1306) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/c96238046bc24361b06e16837730d61a2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4468.00 ((SQL14_SP1_QFE-CU).160807-1306) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/2a89258be7de4ce9b48dbb73a55d324d1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.4468.00 ((SQL14_SP1_QFE-CU).160807-1306) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/95e6fa8b9aee433684c70867ff60a4e61/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.4468.00 ((SQL14_SP1_QFE-CU).160807-1306) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/0c553a702c974f208644a405b541f85c1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.4468.00 ((SQL14_SP1_QFE-CU).160807-1306) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/db5a292a8769461583541a15ebe202611/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4468.00 ((SQL14_SP1_QFE-CU).160807-1306) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/13c47c3e18bb421fa3249689a54a71102/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4468.00 ((SQL14_SP1_QFE-CU).160807-1306) +``` + +# SQL Server 2014 SP1 CU8 - 12.0.4468.0 - x86 (KB3174038) +``` powershell +# SQL Server 2014 SP1 CU8 - 12.0.4468.0 - x86 (KB3174038) +$outputFolder = 'c:\sqlsyms\12.0.4468.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/65f204610ef64b91a0fd8794150b94291/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.4468.00 ((SQL14_SP1_QFE-CU).160807-1306) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/1a01ea9849824b6c9d89022a9165081d1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4468.00 ((SQL14_SP1_QFE-CU).160807-1306) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/acfc80b3b2b14e0e8c44bb5638a59e011/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4468.00 ((SQL14_SP1_QFE-CU).160807-1306) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/a1112b3c01de49d3bf7df61d9421bb671/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.4468.00 ((SQL14_SP1_QFE-CU).160807-1306) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/d3657353614f4ee8adb22730dcb9dd0f2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4468.00 ((SQL14_SP1_QFE-CU).160807-1306) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/633bdb5f043c4d5eb8ab475398f1d6b31/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4468.00 ((SQL14_SP1_QFE-CU).160807-1306) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/8142bc3f8c344dd2a3f6a5f9b8accbc91/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4468.00 ((SQL14_SP1_QFE-CU).160807-1306) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/d5882b2e79e648a880c48dbf9aa04b751/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4468.00 ((SQL14_SP1_QFE-CU).160807-1306) +``` + +# SQL Server 2014 SP1 CU7 - 12.0.4459.0 - x64 (KB3162659) +``` powershell +# SQL Server 2014 SP1 CU7 - 12.0.4459.0 - x64 (KB3162659) +$outputFolder = 'c:\sqlsyms\12.0.4459.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/9e6af119e0f34e8284af02aeb6c2aed32/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.4459.00 ((SQL14_SP1_QFE-CU).160527-1445) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/2be68cda7aca40769bedc7911c47199e2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4459.00 ((SQL14_SP1_QFE-CU).160527-1445) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/51a3a33ea06c4b6fa7ba5f3a872f475b2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4459.00 ((SQL14_SP1_QFE-CU).160527-1445) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/e90c807a4c35455a820c37c0d50b4b232/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.4459.00 ((SQL14_SP1_QFE-CU).160527-1445) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/b61b9c7dcab24b45922994aca824ef672/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4459.00 ((SQL14_SP1_QFE-CU).160527-1445) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/619dd10c6677476c9b9d849815196fa32/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4459.00 ((SQL14_SP1_QFE-CU).160527-1445) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/433c6e1e9a8945498db235a0b52cde5e1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.4459.00 ((SQL14_SP1_QFE-CU).160527-1445) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/fa3d2944dc8846d3bcc61c2e7ee065281/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.4459.00 ((SQL14_SP1_QFE-CU).160527-1445) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/58c10d6cf94142c985df4771e46cb2371/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.4459.00 ((SQL14_SP1_QFE-CU).160527-1445) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/a27d505e013f4048877030aa5e518ea51/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4459.00 ((SQL14_SP1_QFE-CU).160527-1445) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/f27d6b48d60d41b685ab306cdd9a51ac2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4459.00 ((SQL14_SP1_QFE-CU).160527-1445) +``` + +# SQL Server 2014 SP1 CU7 - 12.0.4459.0 - x86 (KB3162659) +``` powershell +# SQL Server 2014 SP1 CU7 - 12.0.4459.0 - x86 (KB3162659) +$outputFolder = 'c:\sqlsyms\12.0.4459.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/6fff44d1682f4a9495ec0d87165558441/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.4459.00 ((SQL14_SP1_QFE-CU).160527-1445) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/92d19dff78a545049ba60ecbb778e1b81/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4459.00 ((SQL14_SP1_QFE-CU).160527-1445) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/ad454e7f63754f3f8ea5182420e1a95c1/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4459.00 ((SQL14_SP1_QFE-CU).160527-1445) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/9228212f994f44d5b53f3ab7dd3356cc1/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.4459.00 ((SQL14_SP1_QFE-CU).160527-1445) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/8578316b4f5d4354a53ec2cfd55481022/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4459.00 ((SQL14_SP1_QFE-CU).160527-1445) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/bd487adc6b904a848c1231663606b3f31/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4459.00 ((SQL14_SP1_QFE-CU).160527-1445) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/1832bee682d6478cadcc049a8e7f667c1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4459.00 ((SQL14_SP1_QFE-CU).160527-1445) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/274a8b7eca104af493f554023e54b1511/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4459.00 ((SQL14_SP1_QFE-CU).160527-1445) +``` + +# SQL Server 2014 SP1 CU6 - 12.0.4457.0 - x64 (KB3167392) +``` powershell +# SQL Server 2014 SP1 CU6 - 12.0.4457.0 - x64 (KB3167392) +$outputFolder = 'c:\sqlsyms\12.0.4457.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/0d205c1fa08b4e30be8d57b0b66f7aad2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.4457.00 ((SQL14_SP_QFE-OD).160526-2301) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/ca933e39df4a4a06877ec27e0ca8635c2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4457.00 ((SQL14_SP_QFE-OD).160526-2301) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/73bb9ef1b6d444949ec88857e9ad1a282/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4457.00 ((SQL14_SP_QFE-OD).160526-2301) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/8405542cc1254c03a666cb742da51ea72/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.4457.00 ((SQL14_SP_QFE-OD).160526-2301) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/95315aebcf874ef0bb34618350d666432/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4457.00 ((SQL14_SP_QFE-OD).160526-2301) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/c6bebcd7804e461f9efd30cabf8e8f8a2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4457.00 ((SQL14_SP_QFE-OD).160526-2301) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/79d2d1bdc00b4d4eba2870d71a3dd2d61/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.4457.00 ((SQL14_SP_QFE-OD).160526-2301) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/a8ccc254a9e6493295a6bca4bfaa61401/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.4457.00 ((SQL14_SP_QFE-OD).160526-2301) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/fae429df4a7f4b2fb2654331aed0ac171/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.4457.00 ((SQL14_SP_QFE-OD).160526-2301) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/b950a8b8c82d4963b5c9dd17c8d278d41/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4457.00 ((SQL14_SP_QFE-OD).160526-2301) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/f44520516b3d4f4eba97077627392c722/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4457.00 ((SQL14_SP_QFE-OD).160526-2301) +``` + +# SQL Server 2014 SP1 CU6 - 12.0.4457.0 - x86 (KB3167392) +``` powershell +# SQL Server 2014 SP1 CU6 - 12.0.4457.0 - x86 (KB3167392) +$outputFolder = 'c:\sqlsyms\12.0.4457.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/e20a40c355fc4e44a73ebc5e6f9aedff1/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.4457.00 ((SQL14_SP_QFE-OD).160526-2301) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/46bbfbc5d91f42e49d4787fdb099ac611/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4457.00 ((SQL14_SP_QFE-OD).160526-2301) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/4fc6d961f7114c9b99d7a889580a49451/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4457.00 ((SQL14_SP_QFE-OD).160526-2301) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/205de64132184b59aae89e227e12d54d1/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.4457.00 ((SQL14_SP_QFE-OD).160526-2301) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/10f36fe6efa44624bd46211d0d8cb4202/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4457.00 ((SQL14_SP_QFE-OD).160526-2301) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/349d89ce6e074117afa7cf153ccc510c1/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4457.00 ((SQL14_SP_QFE-OD).160526-2301) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/b0785ae48497462bac6fd725dfb8517f1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4457.00 ((SQL14_SP_QFE-OD).160526-2301) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/71d4f69079d846b192583ae1293d14c91/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4457.00 ((SQL14_SP_QFE-OD).160526-2301) +``` + +# SQL Server 2014 SP1 CU6 (Deprecated) - 12.0.4449.0 - x64 (KB3144524) +``` powershell +# SQL Server 2014 SP1 CU6 (Deprecated) - 12.0.4449.0 - x64 (KB3144524) +$outputFolder = 'c:\sqlsyms\12.0.4449.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/541dc558cad74e0694256b9a79761f922/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.4449.00 ((SQL14_SP1_QFE-CU).160413-1153) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/8a5052b8ff7345599f6f242cf4f3e09f2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4449.00 ((SQL14_SP1_QFE-CU).160413-1153) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/8a62d7af769a4f2c864d2b808ab81dfe2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4449.00 ((SQL14_SP1_QFE-CU).160413-1153) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/251fdfd9e8454621b19032d327a2fbbf2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.4449.00 ((SQL14_SP1_QFE-CU).160413-1153) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/6cf73332314548c29f5d02b19d98963b2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4449.00 ((SQL14_SP1_QFE-CU).160413-1153) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/55742e7e85204da4818d8a730a2f70852/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4449.00 ((SQL14_SP1_QFE-CU).160413-1153) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/1a20c516b71c4ee9a74d40cd5b3597631/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.4449.00 ((SQL14_SP1_QFE-CU).160413-1153) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/db864229a8b14fce99322d74a808b8d61/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.4449.00 ((SQL14_SP1_QFE-CU).160413-1153) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/db0d700ed8dd45349808c9c8078f7c1d1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.4449.00 ((SQL14_SP1_QFE-CU).160413-1153) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/42213ff00a944645a6752810210b9c4f1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4449.00 ((SQL14_SP1_QFE-CU).160413-1153) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/bba4a2d05f6b4a7da8cb248ae45a322a2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4449.00 ((SQL14_SP1_QFE-CU).160413-1153) +``` + +# SQL Server 2014 SP1 CU6 (Deprecated) - 12.0.4449.0 - x86 (KB3144524) +``` powershell +# SQL Server 2014 SP1 CU6 (Deprecated) - 12.0.4449.0 - x86 (KB3144524) +$outputFolder = 'c:\sqlsyms\12.0.4449.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/ff6fa640813246d6b61408f766f2ba301/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.4449.00 ((SQL14_SP1_QFE-CU).160413-1153) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/79a658164e2e44e482bca7933ae40daf1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4449.00 ((SQL14_SP1_QFE-CU).160413-1153) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/9871f564b21d489591a9d62997125cfe1/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4449.00 ((SQL14_SP1_QFE-CU).160413-1153) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/b12da1e6770a4cb7819bae2c4d8ab0fb1/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.4449.00 ((SQL14_SP1_QFE-CU).160413-1153) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/326123b149634674bdb729d1f67111da2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4449.00 ((SQL14_SP1_QFE-CU).160413-1153) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/dc4d9c2424574034b47f8c3f62d96cee1/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4449.00 ((SQL14_SP1_QFE-CU).160413-1153) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/011a3a3c5ee64a52bbfbb132c3c067011/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4449.00 ((SQL14_SP1_QFE-CU).160413-1153) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/5867019c5089413eb07654da21ad9eb21/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4449.00 ((SQL14_SP1_QFE-CU).160413-1153) +``` + +# SQL Server 2014 SP1 CU5 - 12.0.4439.1 - x64 (KB3130926) +``` powershell +# SQL Server 2014 SP1 CU5 - 12.0.4439.1 - x64 (KB3130926) +$outputFolder = 'c:\sqlsyms\12.0.4439.1\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/8c05af1cd714431692715e7c894227922/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.4439.01 ((SQL14_SP1_QFE-CU).160215-1104) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/9d7930b2b40d4a76882ff6e932d114ea2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4439.01 ((SQL14_SP1_QFE-CU).160215-1104) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/3620205f1aa146fc8fb261528826e9252/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4439.01 ((SQL14_SP1_QFE-CU).160215-1104) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/a4841e65bbea49e8b8fb034d059b1f3a2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.4439.01 ((SQL14_SP1_QFE-CU).160215-1104) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/51bd4d350e134a0788e8e5082f7b5df22/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4439.01 ((SQL14_SP1_QFE-CU).160215-1104) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/040e2fe727c3407584cf8ec849b8ec752/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4439.01 ((SQL14_SP1_QFE-CU).160215-1104) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/ee405fe12c294db58642f2aaab531b541/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.4439.01 ((SQL14_SP1_QFE-CU).160215-1104) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/19c41b55d37f49c9a1ae06318c57e8d11/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.4439.01 ((SQL14_SP1_QFE-CU).160215-1104) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/b4b47d122cc049cbb8f6781a308dda711/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.4439.01 ((SQL14_SP1_QFE-CU).160215-1104) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/a1181e9122f6449b8283138dbe7117171/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4439.01 ((SQL14_SP1_QFE-CU).160215-1104) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/748dfbd824714b7784555b943be771552/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4439.01 ((SQL14_SP1_QFE-CU).160215-1104) +``` + +# SQL Server 2014 SP1 CU5 - 12.0.4439.1 - x86 (KB3130926) +``` powershell +# SQL Server 2014 SP1 CU5 - 12.0.4439.1 - x86 (KB3130926) +$outputFolder = 'c:\sqlsyms\12.0.4439.1\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/98b4120a06c3471f972576543f15ac971/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.4439.01 ((SQL14_SP1_QFE-CU).160215-1104) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/dd78d54baaeb4fcfa8ec3adac01727ee1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4439.01 ((SQL14_SP1_QFE-CU).160215-1104) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/0e9fc78f89ab4d5297fc3ade50fa39f51/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4439.01 ((SQL14_SP1_QFE-CU).160215-1104) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/71a0972911d64d6d89202a102f4e36331/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.4439.01 ((SQL14_SP1_QFE-CU).160215-1104) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/e8f53d675d904f2ab71e74b2619f6f612/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4439.01 ((SQL14_SP1_QFE-CU).160215-1104) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/0ccdcf5f1baa43bb8fe10be379928bc21/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4439.01 ((SQL14_SP1_QFE-CU).160215-1104) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/b4cea174690147acad1b103353feaad01/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4439.01 ((SQL14_SP1_QFE-CU).160215-1104) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/da27c83c09ec4ebfb0df22b5746adc711/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4439.01 ((SQL14_SP1_QFE-CU).160215-1104) +``` + +# SQL Server 2014 SP1 CU4 - 12.0.4436.0 - x64 (KB3106660) +``` powershell +# SQL Server 2014 SP1 CU4 - 12.0.4436.0 - x64 (KB3106660) +$outputFolder = 'c:\sqlsyms\12.0.4436.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/362a8410d21b4d39ac0e7a02cc9c2c372/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.4436.00 ((SQL14_SP1_QFE-CU).151202-1517) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/681476d84d7d40f186d3ea82a2661c672/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4436.00 ((SQL14_SP1_QFE-CU).151202-1517) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/a31f385046b54b9cbaf08c4df972c6782/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4436.00 ((SQL14_SP1_QFE-CU).151202-1517) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/8a3fe11c189b4435bcbe953f4841d99f2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.4436.00 ((SQL14_SP1_QFE-CU).151202-1517) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/8f68c8d3545c49e8b83079bc84c6e2842/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4436.00 ((SQL14_SP1_QFE-CU).151202-1517) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/f08834e6067d4b98acb3b60090b4ba292/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4436.00 ((SQL14_SP1_QFE-CU).151202-1517) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/1d1d583c3f204024a1c6247dfce1af251/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.4436.00 ((SQL14_SP1_QFE-CU).151202-1517) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/bf369e60da5943c5ac4ecd1c83e9c1491/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.4436.00 ((SQL14_SP1_QFE-CU).151202-1517) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/6fe2ce101a564db2a580f3f85176f0681/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.4436.00 ((SQL14_SP1_QFE-CU).151202-1517) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/e1afd1f24c8a44f1a734bd1c4a10eaf51/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4436.00 ((SQL14_SP1_QFE-CU).151202-1517) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/5aa7af725caf4fe38f52515b787d4c4d2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4436.00 ((SQL14_SP1_QFE-CU).151202-1517) +``` + +# SQL Server 2014 SP1 CU4 - 12.0.4436.0 - x86 (KB3106660) +``` powershell +# SQL Server 2014 SP1 CU4 - 12.0.4436.0 - x86 (KB3106660) +$outputFolder = 'c:\sqlsyms\12.0.4436.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/e3278cf94d974d73a099dd3541f1430b1/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.4436.00 ((SQL14_SP1_QFE-CU).151202-1517) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/65cc2740001e4389a652c81d662ff4a31/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4436.00 ((SQL14_SP1_QFE-CU).151202-1517) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/1215ee0470bf46c1bcd1ddfa35951f911/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4436.00 ((SQL14_SP1_QFE-CU).151202-1517) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/737570a73e254326826ad1c811c340671/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.4436.00 ((SQL14_SP1_QFE-CU).151202-1517) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/50cf83342da94fbeaee4f79bd16973ab2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4436.00 ((SQL14_SP1_QFE-CU).151202-1517) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/df2f947c30e4454b9e568b53ca4dd8c51/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4436.00 ((SQL14_SP1_QFE-CU).151202-1517) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/3e240bb821c44d9d8ab1e59638d2bf351/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4436.00 ((SQL14_SP1_QFE-CU).151202-1517) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/28a61563540846d5a4c6c1b9f58e6b9c1/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4436.00 ((SQL14_SP1_QFE-CU).151202-1517) +``` + +# SQL Server 2014 SP1 CU3 - 12.0.4427.24 - x64 (KB3094221) +``` powershell +# SQL Server 2014 SP1 CU3 - 12.0.4427.24 - x64 (KB3094221) +$outputFolder = 'c:\sqlsyms\12.0.4427.24\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/8b612bab70d84b87bc09f27e4886aeb32/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.4427.24 ((SQL14_SP1_QFE-CU).151010-1609) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/dd15f98e38c244fc99b4ea43e149751a2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4427.24 ((SQL14_SP1_QFE-CU).151010-1609) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/cfee366445fd45cb90c9a47537129e772/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4427.24 ((SQL14_SP1_QFE-CU).151010-1609) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/da33ddc66f9843f38802e386e21a23d92/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.4427.24 ((SQL14_SP1_QFE-CU).151010-1609) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/5d78955b0a444fa8a0829509864abdcf2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4427.24 ((SQL14_SP1_QFE-CU).151010-1609) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/d625926716ac4a4ab6d395e0717eee292/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4427.24 ((SQL14_SP1_QFE-CU).151010-1609) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/f7bfed5a7b9c4b0a89c2351606f6dabd1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.4427.24 ((SQL14_SP1_QFE-CU).151010-1609) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/2829cd5018b94524a05d17c0aba940a51/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.4427.24 ((SQL14_SP1_QFE-CU).151010-1609) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/28ce7b1a2fe64c1bae7180a1ab1d4b841/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.4427.24 ((SQL14_SP1_QFE-CU).151010-1609) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/2ab9eea24838455ebedc0b4bfca780651/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4427.24 ((SQL14_SP1_QFE-CU).151010-1609) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/d1da515568304cada52f5ca07d32c56f2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4427.24 ((SQL14_SP1_QFE-CU).151010-1609) +``` + +# SQL Server 2014 SP1 CU3 - 12.0.4427.24 - x86 (KB3094221) +``` powershell +# SQL Server 2014 SP1 CU3 - 12.0.4427.24 - x86 (KB3094221) +$outputFolder = 'c:\sqlsyms\12.0.4427.24\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/3ef0e0f2fe2b43ac93875b3b3925fc6e1/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.4427.24 ((SQL14_SP1_QFE-CU).151010-1609) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/e630387bc0da4378a384f2f0381a70361/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4427.24 ((SQL14_SP1_QFE-CU).151010-1609) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/195f5a4a374443d7aba2b2bee84e34891/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4427.24 ((SQL14_SP1_QFE-CU).151010-1609) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/f7d1027c3648472896a7f5d88da4c9d21/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.4427.24 ((SQL14_SP1_QFE-CU).151010-1609) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/9e81862bb11447788e4a5248fb8a067e2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4427.24 ((SQL14_SP1_QFE-CU).151010-1609) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/5a5b0039a4474b42bb55ccb3ca6127721/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4427.24 ((SQL14_SP1_QFE-CU).151010-1609) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/d656086d4f4b422580baf43047ee17da1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4427.24 ((SQL14_SP1_QFE-CU).151010-1609) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/ac149317d5054708a94ca8aa8cef2fb41/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4427.24 ((SQL14_SP1_QFE-CU).151010-1609) +``` + +# SQL Server 2014 SP1 CU2 - 12.0.4422.0 - x64 (KB3075950) +``` powershell +# SQL Server 2014 SP1 CU2 - 12.0.4422.0 - x64 (KB3075950) +$outputFolder = 'c:\sqlsyms\12.0.4422.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/cc4b19123a7e4b00bc327dc0d8c0535a2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.4422.00 ((SQL14_SP1_QFE-CU).150727-1536) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/685f3f3dd9bf40a384bc3b34b5e0ec382/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4422.00 ((SQL14_SP1_QFE-CU).150727-1536) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/132245b6e07d4ed0b8a037f372c07a1c2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4422.00 ((SQL14_SP1_QFE-CU).150727-1536) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/f2d5c201fa064580a88c8620fcf528942/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.4422.00 ((SQL14_SP1_QFE-CU).150727-1536) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/3c213b3e4cac475c986f38788ee7ae812/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4422.00 ((SQL14_SP1_QFE-CU).150727-1536) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/9833540f5dd84c07bfa7aa07e35878c82/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4422.00 ((SQL14_SP1_QFE-CU).150727-1536) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/703a0ff035d8421093c5873ca70254021/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.4422.00 ((SQL14_SP1_QFE-CU).150727-1536) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/a70c6bd99bbb44129002fe32794a1a491/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.4422.00 ((SQL14_SP1_QFE-CU).150727-1536) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/3b2cc6000a1e46aa8ad7be339858e1871/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.4422.00 ((SQL14_SP1_QFE-CU).150727-1536) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/6e69bdfbde834092882537afb0164ee41/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4422.00 ((SQL14_SP1_QFE-CU).150727-1536) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/d6bbc455ed6d43fca5b6c541fd9840a82/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4422.00 ((SQL14_SP1_QFE-CU).150727-1536) +``` + +# SQL Server 2014 SP1 CU2 - 12.0.4422.0 - x86 (KB3075950) +``` powershell +# SQL Server 2014 SP1 CU2 - 12.0.4422.0 - x86 (KB3075950) +$outputFolder = 'c:\sqlsyms\12.0.4422.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/3e6e97436d7947efba0199c077de575e1/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.4422.00 ((SQL14_SP1_QFE-CU).150727-1536) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/8f1c6ef392a94f7280e4551d787bde0e1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4422.00 ((SQL14_SP1_QFE-CU).150727-1536) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/802091eeae1040b9929300673cf1e6cc1/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4422.00 ((SQL14_SP1_QFE-CU).150727-1536) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/7cf486d748c648a993d8fee09d470ed01/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.4422.00 ((SQL14_SP1_QFE-CU).150727-1536) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/77421fe01c504798bd84ff1111394ed02/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4422.00 ((SQL14_SP1_QFE-CU).150727-1536) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/bce992e7e4704168967f6b792d2c92161/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4422.00 ((SQL14_SP1_QFE-CU).150727-1536) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/10d2fbe0372a465a984499f610117b671/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4422.00 ((SQL14_SP1_QFE-CU).150727-1536) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/8132ccd977ac49b9b82d21e453c9d7db1/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4422.00 ((SQL14_SP1_QFE-CU).150727-1536) +``` + +# SQL Server 2014 SP1 SP1 - 12.0.4100.1 - x64 (KB3058865) +``` powershell +# SQL Server 2014 SP1 SP1 - 12.0.4100.1 - x64 (KB3058865) +$outputFolder = 'c:\sqlsyms\12.0.4100.1\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/0b3969cc9d1c42209d848cdd6619deb22/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.4100.01 ((SQL14_PCU_main).150420-1653) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/cb126849ce004b6fb8128a91ca87d5de2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4100.01 ((SQL14_PCU_main).150420-1653) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/3b28768245824b4e9dbe603fd491e2852/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4100.01 ((SQL14_PCU_main).150420-1653) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/b7ffc8fe9e2f4b15b44e40b4afd2ea012/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.4100.01 ((SQL14_PCU_main).150420-1653) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/08ffbabfdc4a4926bc16c8522c9bbc322/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4100.01 ((SQL14_PCU_main).150420-1653) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/3b87272344ce49a79745b7c63a7e20182/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4100.01 ((SQL14_PCU_main).150420-1653) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/4fedbb6d132d4ed49a566bcd7212408d1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.4100.01 ((SQL14_PCU_main).150420-1653) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/c333820aef364ad2b93a5bcc5a1c66101/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.4100.01 ((SQL14_PCU_main).150420-1653) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/1a18e036793145c8a9d1ab124a2607e41/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.4100.01 ((SQL14_PCU_main).150420-1653) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/63dadaf018f1419f8a4dbbd6bc1dc14a1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4100.01 ((SQL14_PCU_main).150420-1653) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/ab6196f20a154ace825cff70fd87b6092/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4100.01 ((SQL14_PCU_main).150420-1653) +``` + +# SQL Server 2014 SP1 SP1 - 12.0.4100.1 - x86 (KB3058865) +``` powershell +# SQL Server 2014 SP1 SP1 - 12.0.4100.1 - x86 (KB3058865) +$outputFolder = 'c:\sqlsyms\12.0.4100.1\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/0865f069e71245ca8bfa3d606b60c1621/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.4100.01 ((SQL14_PCU_main).150420-1653) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/e489ada097d74198927ef538fd8927a41/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.4100.01 ((SQL14_PCU_main).150420-1653) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/5bea9870e6614f7e83671000e406de331/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.4100.01 ((SQL14_PCU_main).150420-1653) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/68a3418eaba04db5b35c3ab2cc4a67681/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.4100.01 ((SQL14_PCU_main).150420-1653) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/295830323d5343efad5c418d4e6dddb72/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.4100.01 ((SQL14_PCU_main).150420-1653) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/a3aeeef5442b49b4abf8d50de9edab181/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.4100.01 ((SQL14_PCU_main).150420-1653) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/1ea104008bc644218268d19341eecd741/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.4100.01 ((SQL14_PCU_main).150420-1653) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/e36eebbe2905446fbf814c89dee44df71/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.4100.01 ((SQL14_PCU_main).150420-1653) +``` + +# SQL Server 2014 RTM CU14 - 12.0.2569.0 - x64 (KB3158271) +``` powershell +# SQL Server 2014 RTM CU14 - 12.0.2569.0 - x64 (KB3158271) +$outputFolder = 'c:\sqlsyms\12.0.2569.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/539b0c025c174d6698c4969ee00d608a2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.2569.00 ((SQL14_RTM_QFE-CU).160527-1418) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/da89f627ad2346c38a7e801fed26a28d2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2569.00 ((SQL14_RTM_QFE-CU).160527-1418) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/50637ed0c6714c5c99da521077e3e5c32/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2569.00 ((SQL14_RTM_QFE-CU).160527-1418) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/01a3ff5e96cd40d5a8f1ab8f127009522/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.2569.00 ((SQL14_RTM_QFE-CU).160527-1418) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/05af9fc52b03405a9cb80cbd73c60a692/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2569.00 ((SQL14_RTM_QFE-CU).160527-1418) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/a803366e7b534798ab18db7ab2f059602/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2569.00 ((SQL14_RTM_QFE-CU).160527-1418) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/bee70081bce04d9e9a4d9145f820ec5f1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.2569.00 ((SQL14_RTM_QFE-CU).160527-1418) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/097922796c7443deaaebb689165db0c81/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.2569.00 ((SQL14_RTM_QFE-CU).160527-1418) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/fc8453414c104e1992d469013988d78d1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.2569.00 ((SQL14_RTM_QFE-CU).160527-1418) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/4cc60f940e164516ba060e2ec7a9085d1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2569.00 ((SQL14_RTM_QFE-CU).160527-1418) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/167b796ce1b84bd6aab8a050c0507d842/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2569.00 ((SQL14_RTM_QFE-CU).160527-1418) +``` + +# SQL Server 2014 RTM CU14 - 12.0.2569.0 - x86 (KB3158271) +``` powershell +# SQL Server 2014 RTM CU14 - 12.0.2569.0 - x86 (KB3158271) +$outputFolder = 'c:\sqlsyms\12.0.2569.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/759d2b26ff5346bd861ce3f29f45bec81/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.2569.00 ((SQL14_RTM_QFE-CU).160527-1418) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/78d8fd90a81d424b9a11cff7694359be1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2569.00 ((SQL14_RTM_QFE-CU).160527-1418) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/10adc5ffc4504f70bea9ace99b83d4811/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2569.00 ((SQL14_RTM_QFE-CU).160527-1418) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/d5d8a1b7129843e992a5cc7ac48d8cdc1/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.2569.00 ((SQL14_RTM_QFE-CU).160527-1418) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/88e10155378342d28c551097e352cddc2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2569.00 ((SQL14_RTM_QFE-CU).160527-1418) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/a51778462d5b483bb0f7c56f35e1b3881/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2569.00 ((SQL14_RTM_QFE-CU).160527-1418) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/63daa87222644774b370021497f13aae1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2569.00 ((SQL14_RTM_QFE-CU).160527-1418) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/2e5c327356dd422e8df429052b8e1de21/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2569.00 ((SQL14_RTM_QFE-CU).160527-1418) +``` + +# SQL Server 2014 RTM CU13 - 12.0.2568.0 - x64 (KB3144517) +``` powershell +# SQL Server 2014 RTM CU13 - 12.0.2568.0 - x64 (KB3144517) +$outputFolder = 'c:\sqlsyms\12.0.2568.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/de53ea6dfde743f18cadc0b0d43042492/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.2568.00 ((SQL14_RTM_QFE-CU).160330-1726) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/dd5ba486f24344ad8405ff37e26b4e1f2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2568.00 ((SQL14_RTM_QFE-CU).160330-1726) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/93d02eddd4a34a3dbbecfeb54abf9a1d2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2568.00 ((SQL14_RTM_QFE-CU).160330-1726) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/c9fd07c3fc294f1da6e434f006522b152/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.2568.00 ((SQL14_RTM_QFE-CU).160330-1726) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/a032aa8c1f9c4768a7f44c6e724c25542/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2568.00 ((SQL14_RTM_QFE-CU).160330-1726) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/c244f112481946d78890457e4e7ee5a72/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2568.00 ((SQL14_RTM_QFE-CU).160330-1726) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/64efea4a66a242fe84610bdea54e47fd1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.2568.00 ((SQL14_RTM_QFE-CU).160330-1726) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/d1faf0f81672488e975d5cbff4f5f4c51/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.2568.00 ((SQL14_RTM_QFE-CU).160330-1726) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/d6ba17eeb5534b6c8f09b7bd7a9d87ef1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.2568.00 ((SQL14_RTM_QFE-CU).160330-1726) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/7b633a8ab9664ffaa16dff394ebc5d331/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2568.00 ((SQL14_RTM_QFE-CU).160330-1726) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/5e921cfba868494fa153b17f0d1fda992/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2568.00 ((SQL14_RTM_QFE-CU).160330-1726) +``` + +# SQL Server 2014 RTM CU13 - 12.0.2568.0 - x86 (KB3144517) +``` powershell +# SQL Server 2014 RTM CU13 - 12.0.2568.0 - x86 (KB3144517) +$outputFolder = 'c:\sqlsyms\12.0.2568.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/f4ce9bbe9cd94155a053957fc6e89a171/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.2568.00 ((SQL14_RTM_QFE-CU).160330-1726) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/e3272664d7ac4280889108adaa8fa4081/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2568.00 ((SQL14_RTM_QFE-CU).160330-1726) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/b3d91828d7c04aef9f0a597390b6e3f01/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2568.00 ((SQL14_RTM_QFE-CU).160330-1726) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/7f73aff2ab6146b59f7cba467bfe64071/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.2568.00 ((SQL14_RTM_QFE-CU).160330-1726) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/5db522686f8c42f58a7a6cb449f772d32/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2568.00 ((SQL14_RTM_QFE-CU).160330-1726) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/d5748e2f6f7043058e5bbd55bacb3b4f1/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2568.00 ((SQL14_RTM_QFE-CU).160330-1726) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/5958ca20c2cd4e2e855fe49509dd0e7c1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2568.00 ((SQL14_RTM_QFE-CU).160330-1726) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/310e33c9d39046199259897860543ef81/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2568.00 ((SQL14_RTM_QFE-CU).160330-1726) +``` + +# SQL Server 2014 RTM CU12 - 12.0.2564.0 - x64 (KB3130923) +``` powershell +# SQL Server 2014 RTM CU12 - 12.0.2564.0 - x64 (KB3130923) +$outputFolder = 'c:\sqlsyms\12.0.2564.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/ac2576ff05574d0895c27ddeafbe5c8c2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.2564.00 ((SQL14_RTM_QFE-CU).160204-1937) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/24cf73afb18b44e98f4ba0ac01281e232/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2564.00 ((SQL14_RTM_QFE-CU).160204-1937) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/05ca53d70a0d46c78025be9f7379f3f02/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2564.00 ((SQL14_RTM_QFE-CU).160204-1937) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/e478a5c24cc047cdaa62614b9d6bd3052/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.2564.00 ((SQL14_RTM_QFE-CU).160204-1937) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/eb2d01edd0b143d3a8cf1c8a5ebea4972/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2564.00 ((SQL14_RTM_QFE-CU).160204-1937) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/16cdbd70f47b48cf908a13007767df1a2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2564.00 ((SQL14_RTM_QFE-CU).160204-1937) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/9f3ca7a2feee48a1998590fec323b2e91/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.2564.00 ((SQL14_RTM_QFE-CU).160204-1937) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/3ebf546ee388483abdb7dab6effd82d21/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.2564.00 ((SQL14_RTM_QFE-CU).160204-1937) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/a2f68300ade4407fb71d87f30a77fc111/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.2564.00 ((SQL14_RTM_QFE-CU).160204-1937) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/cc7dd6966b7e43d99c7c23447f95542f1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2564.00 ((SQL14_RTM_QFE-CU).160204-1937) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/f0308e1404e542b2a920139701283a252/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2564.00 ((SQL14_RTM_QFE-CU).160204-1937) +``` + +# SQL Server 2014 RTM CU12 - 12.0.2564.0 - x86 (KB3130923) +``` powershell +# SQL Server 2014 RTM CU12 - 12.0.2564.0 - x86 (KB3130923) +$outputFolder = 'c:\sqlsyms\12.0.2564.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/17b9f26230cd4187a439851dc2b15e5a1/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.2564.00 ((SQL14_RTM_QFE-CU).160204-1937) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/df46ff7b155e49048c088afde27092b21/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2564.00 ((SQL14_RTM_QFE-CU).160204-1937) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/1849c8c7f5774787a047b5c3105a4f861/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2564.00 ((SQL14_RTM_QFE-CU).160204-1937) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/1e704748340e45ad8c1e5bc9b08a77281/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.2564.00 ((SQL14_RTM_QFE-CU).160204-1937) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/c3e4dde16a9a427ea900174c72dfb9e82/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2564.00 ((SQL14_RTM_QFE-CU).160204-1937) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/6c5d715625174c2c94d325757fa8d1e81/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2564.00 ((SQL14_RTM_QFE-CU).160204-1937) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/fa23d7c84b444dcd8b619046b60b65421/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2564.00 ((SQL14_RTM_QFE-CU).160204-1937) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/29ba1ceeca2744fe84f8d852530d27f71/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2564.00 ((SQL14_RTM_QFE-CU).160204-1937) +``` + +# SQL Server 2014 RTM CU11 - 12.0.2560.0 - x64 (KB3106659) +``` powershell +# SQL Server 2014 RTM CU11 - 12.0.2560.0 - x64 (KB3106659) +$outputFolder = 'c:\sqlsyms\12.0.2560.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/71ccee0526474342a5891a30d552962b2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.2560.00 ((SQL14_RTM_QFE-CU).151130-1922) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/3919239c1e00493990334a7288fcb7962/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2560.00 ((SQL14_RTM_QFE-CU).151130-1922) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/756b21da38ee46d0984b1188544092342/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2560.00 ((SQL14_RTM_QFE-CU).151130-1922) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/d028137b7daa4438bc7be686320a64fe2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.2560.00 ((SQL14_RTM_QFE-CU).151130-1922) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/781c50f9c2c44642b355a47de65574b82/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2560.00 ((SQL14_RTM_QFE-CU).151130-1922) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/a0aff51dd9904d55a4fcce650e40a9762/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2560.00 ((SQL14_RTM_QFE-CU).151130-1922) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/9293a8099c4d4f49bc6b0543846b03791/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.2560.00 ((SQL14_RTM_QFE-CU).151130-1922) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/fa5b0015e66a4fb286899631f60591021/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.2560.00 ((SQL14_RTM_QFE-CU).151130-1922) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/56f5dd0eb56e420b92dcd5f59b05ef9c1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.2560.00 ((SQL14_RTM_QFE-CU).151130-1922) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/64b1f742fbcb4e2eb3f2e1dc05b70ea61/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2560.00 ((SQL14_RTM_QFE-CU).151130-1922) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/8ec5a23b411344a6b1fb5a9dfc8d1c752/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2560.00 ((SQL14_RTM_QFE-CU).151130-1922) +``` + +# SQL Server 2014 RTM CU11 - 12.0.2560.0 - x86 (KB3106659) +``` powershell +# SQL Server 2014 RTM CU11 - 12.0.2560.0 - x86 (KB3106659) +$outputFolder = 'c:\sqlsyms\12.0.2560.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/a90e6d303f4345efaedba859da66d0e21/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.2560.00 ((SQL14_RTM_QFE-CU).151130-1922) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/64473f2a9c0243d08ad2cebd7e62f0ac1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2560.00 ((SQL14_RTM_QFE-CU).151130-1922) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/eb1f9c11c81140199ee680f02d407a3c1/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2560.00 ((SQL14_RTM_QFE-CU).151130-1922) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/5b6c3b54f0234bb2be975c25092ba4851/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.2560.00 ((SQL14_RTM_QFE-CU).151130-1922) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/286b5c4590a94a3bb3da0360ecd0e9c72/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2560.00 ((SQL14_RTM_QFE-CU).151130-1922) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/ce4f67214c154f52ad60711ba933ad3d1/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2560.00 ((SQL14_RTM_QFE-CU).151130-1922) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/aec11813c97e4e44bdb233dd821866191/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2560.00 ((SQL14_RTM_QFE-CU).151130-1922) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/bd25689f8fa549398c347993c1fba4851/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2560.00 ((SQL14_RTM_QFE-CU).151130-1922) +``` + +# SQL Server 2014 RTM CU10 - 12.0.2556.4 - x64 (KB3094220) +``` powershell +# SQL Server 2014 RTM CU10 - 12.0.2556.4 - x64 (KB3094220) +$outputFolder = 'c:\sqlsyms\12.0.2556.4\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/a06b30032d9f4505a3c8f000010f8e4a2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.2556.04 ((SQL14_RTM_QFE-CU).150925-1720) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/e48e96adf3df44b481c69001d428659f2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2556.04 ((SQL14_RTM_QFE-CU).150925-1720) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/a1d6b6fd3e564262ae281bf794e96bd72/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2556.04 ((SQL14_RTM_QFE-CU).150925-1720) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/038d25c7c8644a3395f40f40f36382c62/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.2556.04 ((SQL14_RTM_QFE-CU).150925-1720) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/cfb6dad33e5f4582bb467ca8f85d4a162/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2556.04 ((SQL14_RTM_QFE-CU).150925-1720) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/98e46a54759c4bdfbab7383aa518630a2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2556.04 ((SQL14_RTM_QFE-CU).150925-1720) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/76f05d07a3e9414f80f50c6442eea7931/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.2556.04 ((SQL14_RTM_QFE-CU).150925-1720) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/1383af48c8034eebb40e2851e1a44a1c1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.2556.04 ((SQL14_RTM_QFE-CU).150925-1720) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/f3b781e181fe41d98402118e16e3f7601/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.2556.04 ((SQL14_RTM_QFE-CU).150925-1720) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/d0f7a6c9e839447fbf537b344c12efae1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2556.04 ((SQL14_RTM_QFE-CU).150925-1720) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/6f9cb7b79b0f4b7eb215793a66b2ef942/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2556.04 ((SQL14_RTM_QFE-CU).150925-1720) +``` + +# SQL Server 2014 RTM CU10 - 12.0.2556.4 - x86 (KB3094220) +``` powershell +# SQL Server 2014 RTM CU10 - 12.0.2556.4 - x86 (KB3094220) +$outputFolder = 'c:\sqlsyms\12.0.2556.4\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/9c806d9ee5a84c898f8421b5380b95e31/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.2556.04 ((SQL14_RTM_QFE-CU).150925-1720) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/b69a5dcf43574aa79661d3e85b9daf3b1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2556.04 ((SQL14_RTM_QFE-CU).150925-1720) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/97d553cffeff4762b0266da68f578fba1/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2556.04 ((SQL14_RTM_QFE-CU).150925-1720) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/d79a773caeba4ac59f6882c36b1f356c1/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.2556.04 ((SQL14_RTM_QFE-CU).150925-1720) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/f646c10572b24eaaadbae323b7abd2782/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2556.04 ((SQL14_RTM_QFE-CU).150925-1720) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/38dc9d399d6b41a69f084603941b4de21/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2556.04 ((SQL14_RTM_QFE-CU).150925-1720) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/3960118c1cbe4a29af87cc01706ce2641/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2556.04 ((SQL14_RTM_QFE-CU).150925-1720) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/7e7fd36e795447998d8a574e0de7c1871/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2556.04 ((SQL14_RTM_QFE-CU).150925-1720) +``` + +# SQL Server 2014 RTM CU9 - 12.0.2553.0 - x64 (KB3075949) +``` powershell +# SQL Server 2014 RTM CU9 - 12.0.2553.0 - x64 (KB3075949) +$outputFolder = 'c:\sqlsyms\12.0.2553.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/4d240a39c8904928a18106632f6553402/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.2553.00 ((SQL14_RTM_QFE-CU).150727-1511) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/a7035a6ff90d479b9919516f8a75c6f92/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2553.00 ((SQL14_RTM_QFE-CU).150727-1511) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/90c16352697346c4adc344d5bcbef4ec2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2553.00 ((SQL14_RTM_QFE-CU).150727-1511) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/c4b7ea36a9ed41e28a86daf39605b1332/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.2553.00 ((SQL14_RTM_QFE-CU).150727-1511) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/afdf18a69a2247a69f8775fb26ba35842/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2553.00 ((SQL14_RTM_QFE-CU).150727-1511) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/531f254bc1634a668690bfa78ac1c9642/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2553.00 ((SQL14_RTM_QFE-CU).150727-1511) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/a0a41504488d42e0889c7aec0d470a201/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.2553.00 ((SQL14_RTM_QFE-CU).150727-1511) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/8f66e9d5591841f585146e18e861ba1e1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.2553.00 ((SQL14_RTM_QFE-CU).150727-1511) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/7b7dadea82424ddb940d8bcb1ced7a461/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.2553.00 ((SQL14_RTM_QFE-CU).150727-1511) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/19ab0699fbdf4c26b2c48e3206ac53ca1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2553.00 ((SQL14_RTM_QFE-CU).150727-1511) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/eceabbbb5b7a43e49511f7e3b3064b472/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2553.00 ((SQL14_RTM_QFE-CU).150727-1511) +``` + +# SQL Server 2014 RTM CU9 - 12.0.2553.0 - x86 (KB3075949) +``` powershell +# SQL Server 2014 RTM CU9 - 12.0.2553.0 - x86 (KB3075949) +$outputFolder = 'c:\sqlsyms\12.0.2553.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/d56eacfc22cb4f8ebfb7ed4457b60f311/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.2553.00 ((SQL14_RTM_QFE-CU).150727-1511) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/2dd16123a37f485dae76965defe7f15e1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2553.00 ((SQL14_RTM_QFE-CU).150727-1511) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/569970ff8be84c0b9f067365e4a00c3b1/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2553.00 ((SQL14_RTM_QFE-CU).150727-1511) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/17dd6df3096b4d0199d1035815c1d8881/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.2553.00 ((SQL14_RTM_QFE-CU).150727-1511) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/594a78c1c2204ba1a183b4127c462a3e2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2553.00 ((SQL14_RTM_QFE-CU).150727-1511) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/6446039fddc749d3a1583d2472405cf21/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2553.00 ((SQL14_RTM_QFE-CU).150727-1511) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/6f805634dddd401994ea5e31420c30281/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2553.00 ((SQL14_RTM_QFE-CU).150727-1511) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/8d3747171962416d957f2f4a2a5dc8701/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2553.00 ((SQL14_RTM_QFE-CU).150727-1511) +``` + +# SQL Server 2014 RTM CU8 - 12.0.2546.0 - x64 (KB3067836) +``` powershell +# SQL Server 2014 RTM CU8 - 12.0.2546.0 - x64 (KB3067836) +$outputFolder = 'c:\sqlsyms\12.0.2546.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/1869491de3c641a18e49984e36c254472/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.2546.00 ((SQL14_RTM_QFE-CU).150606-0007) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/23feec68725245cba986d45a86d87c3f2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2546.00 ((SQL14_RTM_QFE-CU).150606-0007) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/21db9cb621534d9e9be8f5c03e7091c52/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2546.00 ((SQL14_RTM_QFE-CU).150606-0007) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/8575334bb55240b5a1f44608bf3eda9b2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.2546.00 ((SQL14_RTM_QFE-CU).150606-0007) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/aeb2b040245c4f408ba6cfba7376190a2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2546.00 ((SQL14_RTM_QFE-CU).150606-0007) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/bfffb5bc7a3044ebb54ab848cdfeb7632/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2546.00 ((SQL14_RTM_QFE-CU).150606-0007) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/6e2e2a0675164fe8a3ade4ecae7ac20c1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.2546.00 ((SQL14_RTM_QFE-CU).150606-0007) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/dde786dd2d5b4cdca67f2653dafdb4d91/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.2546.00 ((SQL14_RTM_QFE-CU).150606-0007) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/20f66d85e7d54ab797a4802c4e642b431/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.2546.00 ((SQL14_RTM_QFE-CU).150606-0007) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/281a067206bb4599bf54b71128337a161/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2546.00 ((SQL14_RTM_QFE-CU).150606-0007) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/a7596bb350534cfc874c588a8c31dccc2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2546.00 ((SQL14_RTM_QFE-CU).150606-0007) +``` + +# SQL Server 2014 RTM CU8 - 12.0.2546.0 - x86 (KB3067836) +``` powershell +# SQL Server 2014 RTM CU8 - 12.0.2546.0 - x86 (KB3067836) +$outputFolder = 'c:\sqlsyms\12.0.2546.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/a902edbf6d6e45a5bdb96d88b3d8b9eb1/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.2546.00 ((SQL14_RTM_QFE-CU).150606-0007) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/91f4ba068591426395fba9cf46b9fe3b1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2546.00 ((SQL14_RTM_QFE-CU).150606-0007) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/a3454c90a9ec423abaab7718704766c41/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2546.00 ((SQL14_RTM_QFE-CU).150606-0007) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/6648b0c58be2467c85d16b826474f8e71/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.2546.00 ((SQL14_RTM_QFE-CU).150606-0007) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/57dad04962d6454e8ee40edafdd2a7382/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2546.00 ((SQL14_RTM_QFE-CU).150606-0007) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/9b2bcdfb948342728b8154e042fa2aab1/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2546.00 ((SQL14_RTM_QFE-CU).150606-0007) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/9291ad53019f4d93b0a31996c43797fb1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2546.00 ((SQL14_RTM_QFE-CU).150606-0007) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/6aaa6f308fc649d8b2982b6ae4cb77c71/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2546.00 ((SQL14_RTM_QFE-CU).150606-0007) +``` + +# SQL Server 2014 RTM CU7 - 12.0.2495.0 - x64 (KB3046038) +``` powershell +# SQL Server 2014 RTM CU7 - 12.0.2495.0 - x64 (KB3046038) +$outputFolder = 'c:\sqlsyms\12.0.2495.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/892a317818044f39a181616fc087af5d2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.2495.00 ((SQL14_RTM_QFE-CU).150331-0856) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/3f9503803aac4aaf9068cf713da94fcc2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2495.00 ((SQL14_RTM_QFE-CU).150331-0856) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/7b4cb4924f874c2c9a01962d7bebb4322/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2495.00 ((SQL14_RTM_QFE-CU).150331-0856) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/f953a26136a349b4bc7123c9b57674cb2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.2495.00 ((SQL14_RTM_QFE-CU).150331-0856) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/5b04b86cb1df4377852dcdfbaa579d6a2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2495.00 ((SQL14_RTM_QFE-CU).150331-0856) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/68b76d2800ca4d67a20176b8080792622/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2495.00 ((SQL14_RTM_QFE-CU).150331-0856) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/8ed3b76470a54f71a22fe04ec4aa07971/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.2495.00 ((SQL14_RTM_QFE-CU).150331-0856) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/ac765b05370f4dd39bc3dab2c9c5b0881/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.2495.00 ((SQL14_RTM_QFE-CU).150331-0856) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/868f36d33dea4cdd80d7ac95d51becb61/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.2495.00 ((SQL14_RTM_QFE-CU).150331-0856) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/e750975049a44a5ca167527370ef01171/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2495.00 ((SQL14_RTM_QFE-CU).150331-0856) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/76a12fa76ee2455086cf3afd914b939b2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2495.00 ((SQL14_RTM_QFE-CU).150331-0856) +``` + +# SQL Server 2014 RTM CU7 - 12.0.2495.0 - x86 (KB3046038) +``` powershell +# SQL Server 2014 RTM CU7 - 12.0.2495.0 - x86 (KB3046038) +$outputFolder = 'c:\sqlsyms\12.0.2495.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/b723d38841c74cb09e79d2eeadffc2ab1/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.2495.00 ((SQL14_RTM_QFE-CU).150331-0856) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/0f90d520883c490f9d0815f7a6211e701/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2495.00 ((SQL14_RTM_QFE-CU).150331-0856) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/bc6b474d28164912bd70a0e0087e35261/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2495.00 ((SQL14_RTM_QFE-CU).150331-0856) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/c32b08605905479daa5521248a294c091/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.2495.00 ((SQL14_RTM_QFE-CU).150331-0856) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/96046540101444be821ef103aa4e0f982/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2495.00 ((SQL14_RTM_QFE-CU).150331-0856) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/710e00b267c04ae1bc850a013edee5231/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2495.00 ((SQL14_RTM_QFE-CU).150331-0856) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/982821e1f1a348c4845b7a31dd0a43ce1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2495.00 ((SQL14_RTM_QFE-CU).150331-0856) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/d8c2b98f2dd94438849861c279784cfb1/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2495.00 ((SQL14_RTM_QFE-CU).150331-0856) +``` + +# SQL Server 2014 RTM CU6 - 12.0.2480.0 - x64 (KB3031047) +``` powershell +# SQL Server 2014 RTM CU6 - 12.0.2480.0 - x64 (KB3031047) +$outputFolder = 'c:\sqlsyms\12.0.2480.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/dbacb5b0cfd24693ae42ddf04ab4b27c2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.2480.00 ((SQL14_RTM_QFE-CU).150128-1755) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/31d5b80990d64e0fb25cb5327135bf492/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2480.00 ((SQL14_RTM_QFE-CU).150128-1755) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/ff523ac683ae46a2b355c15b4ac022eb2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2480.00 ((SQL14_RTM_QFE-CU).150128-1755) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/edbd5ea4bbe04d47b93025254094b02d2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.2480.00 ((SQL14_RTM_QFE-CU).150128-1755) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/4929c9ecd1704cf8a7821dc901f6d92f2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2480.00 ((SQL14_RTM_QFE-CU).150128-1755) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/1c0f8135f2934a5ca84ebff15f88b6aa2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2480.00 ((SQL14_RTM_QFE-CU).150128-1755) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/3ab1423a6b7f48d1a942c5df2fd242b61/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.2480.00 ((SQL14_RTM_QFE-CU).150128-1755) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/c9aa7a554ed94d15b35740ffe04036c01/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.2480.00 ((SQL14_RTM_QFE-CU).150128-1755) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/95947070310e43e2accbc93c08f222241/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.2480.00 ((SQL14_RTM_QFE-CU).150128-1755) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/0d379c00cf81409587f1a4c9f95f77dd1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2480.00 ((SQL14_RTM_QFE-CU).150128-1755) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/ec96151a8358494bb84329e05aaf78e02/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2480.00 ((SQL14_RTM_QFE-CU).150128-1755) +``` + +# SQL Server 2014 RTM CU6 - 12.0.2480.0 - x86 (KB3031047) +``` powershell +# SQL Server 2014 RTM CU6 - 12.0.2480.0 - x86 (KB3031047) +$outputFolder = 'c:\sqlsyms\12.0.2480.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/9b22a94162d74004a82810c2c3710a3f1/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.2480.00 ((SQL14_RTM_QFE-CU).150128-1755) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/ececdbe975594116b9e388e6c9f8a80f1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2480.00 ((SQL14_RTM_QFE-CU).150128-1755) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/9f41e051cb014f8d9fec6e44e9b721131/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2480.00 ((SQL14_RTM_QFE-CU).150128-1755) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/2ffeb57130c84f8fa3d69df7de71eb681/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.2480.00 ((SQL14_RTM_QFE-CU).150128-1755) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/7d7d89e6640645beb6306cbf2444ee662/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2480.00 ((SQL14_RTM_QFE-CU).150128-1755) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/22336473e39548f99831e8d061b7831b1/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2480.00 ((SQL14_RTM_QFE-CU).150128-1755) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/b16a9fdb9f8546788b04a5d80b2bae261/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2480.00 ((SQL14_RTM_QFE-CU).150128-1755) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/2c1a8c9a1b8c44e283868f97d75481e01/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2480.00 ((SQL14_RTM_QFE-CU).150128-1755) +``` + +# SQL Server 2014 RTM CU5 - 12.0.2456.0 - x64 (KB3011055) +``` powershell +# SQL Server 2014 RTM CU5 - 12.0.2456.0 - x64 (KB3011055) +$outputFolder = 'c:\sqlsyms\12.0.2456.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/eb8a93e72a794e8b9f5e5319cfc523682/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.2456.00 ((SQL14_RTM_QFE-CU).141211-1636) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/53f31818f69145f48eee069d0d23fbd12/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2456.00 ((SQL14_RTM_QFE-CU).141211-1636) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/6e2939b1a6c747c79606f27572d2167d2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2456.00 ((SQL14_RTM_QFE-CU).141211-1636) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/133c13f037d542e68e5d1fb06ae6e8042/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.2456.00 ((SQL14_RTM_QFE-CU).141211-1636) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/1afa777fdd2643e8b7eaa7faa9b6b5fa2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2456.00 ((SQL14_RTM_QFE-CU).141211-1636) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/19634392d50f4dcab91217f04a415f482/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2456.00 ((SQL14_RTM_QFE-CU).141211-1636) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/8fbc290a832848ffb96d30114d63ed611/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.2456.00 ((SQL14_RTM_QFE-CU).141211-1636) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/291765ae21a741eda736cb1cbcea5de51/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.2456.00 ((SQL14_RTM_QFE-CU).141211-1636) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/7b53fe2f993e41209ea93c774deed22f1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.2456.00 ((SQL14_RTM_QFE-CU).141211-1636) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/214c250884534e1aa0185e6bef362a521/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2456.00 ((SQL14_RTM_QFE-CU).141211-1636) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/9b95a106672640318876b62eb49ce32b2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2456.00 ((SQL14_RTM_QFE-CU).141211-1636) +``` + +# SQL Server 2014 RTM CU5 - 12.0.2456.0 - x86 (KB3011055) +``` powershell +# SQL Server 2014 RTM CU5 - 12.0.2456.0 - x86 (KB3011055) +$outputFolder = 'c:\sqlsyms\12.0.2456.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/b845d2f2afb44859904e1c51ea2df77c1/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.2456.00 ((SQL14_RTM_QFE-CU).141211-1636) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/93ab40244d4b4108b3e1e5e507a841f81/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2456.00 ((SQL14_RTM_QFE-CU).141211-1636) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/3bd2da20bc3d42df9bda66521f4763141/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2456.00 ((SQL14_RTM_QFE-CU).141211-1636) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/301c79ece27a4a4ea90a4026b151273d1/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.2456.00 ((SQL14_RTM_QFE-CU).141211-1636) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/15d84d064320486d8f0aa9c175e73ff72/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2456.00 ((SQL14_RTM_QFE-CU).141211-1636) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/677fc25409af4e5cb079fc220a507a281/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2456.00 ((SQL14_RTM_QFE-CU).141211-1636) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/c99783448e224e5ead440e48808f3a371/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2456.00 ((SQL14_RTM_QFE-CU).141211-1636) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/3ee8df660b704120a5769fe486d912b91/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2456.00 ((SQL14_RTM_QFE-CU).141211-1636) +``` + +# SQL Server 2014 RTM CU4 - 12.0.2430.0 - x64 (KB2999197) +``` powershell +# SQL Server 2014 RTM CU4 - 12.0.2430.0 - x64 (KB2999197) +$outputFolder = 'c:\sqlsyms\12.0.2430.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/8ed2ab1b64c64cd6b53be5ba2940d1a42/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.2430.00 ((SQL14_RTM_QFE-CU).141015-1502) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/1d8587b3f0eb464f8da9733cc91606862/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2430.00 ((SQL14_RTM_QFE-CU).141015-1502) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/21f00ed9f1534ee39faf557af2efe0b22/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2430.00 ((SQL14_RTM_QFE-CU).141015-1502) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/0999d6303e144ea494c2befc049f4f052/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.2430.00 ((SQL14_RTM_QFE-CU).141015-1502) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/f21b42e831e3406796f8341329a2109c2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2430.00 ((SQL14_RTM_QFE-CU).141015-1502) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/6ea90b282987428e950c06ca61b48d022/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2430.00 ((SQL14_RTM_QFE-CU).141015-1502) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/72b8a33dcd5a4c199f48947510111e4f1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.2430.00 ((SQL14_RTM_QFE-CU).141015-1502) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/c3f38698f3db4272bbf911928e3a71c91/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.2430.00 ((SQL14_RTM_QFE-CU).141015-1502) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/c9e0caaa8d11431aadaff0f8fc85c2041/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.2430.00 ((SQL14_RTM_QFE-CU).141015-1502) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/f98a21da91c24cfdb165f8f2c1a4019d1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2430.00 ((SQL14_RTM_QFE-CU).141015-1502) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/3863b99a65d94c2f9aba257ddb80519c2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2430.00 ((SQL14_RTM_QFE-CU).141015-1502) +``` + +# SQL Server 2014 RTM CU4 - 12.0.2430.0 - x86 (KB2999197) +``` powershell +# SQL Server 2014 RTM CU4 - 12.0.2430.0 - x86 (KB2999197) +$outputFolder = 'c:\sqlsyms\12.0.2430.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/c842b82043f14b56bbdaf6f3daf8c9361/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.2430.00 ((SQL14_RTM_QFE-CU).141015-1502) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/bd6cc732c1a04a70949c746ad7c75bfc1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2430.00 ((SQL14_RTM_QFE-CU).141015-1502) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/5e255a6c840c4135afd13947b885a0bc1/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2430.00 ((SQL14_RTM_QFE-CU).141015-1502) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/bf46680cb561413d92bf308f29ed422d1/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.2430.00 ((SQL14_RTM_QFE-CU).141015-1502) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/c2a06041e7e2494889e753f9633f49ad2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2430.00 ((SQL14_RTM_QFE-CU).141015-1502) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/b6b6b351ea9b4ddc8d275499e307dc371/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2430.00 ((SQL14_RTM_QFE-CU).141015-1502) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/d44e146dd57b4e84bd689c2dc23f38a21/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2430.00 ((SQL14_RTM_QFE-CU).141015-1502) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/0bad01bb555b4a9a9fb58bba8dbdee961/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2430.00 ((SQL14_RTM_QFE-CU).141015-1502) +``` + +# SQL Server 2014 RTM CU3 - 12.0.2402.0 - x64 (KB2984923) +``` powershell +# SQL Server 2014 RTM CU3 - 12.0.2402.0 - x64 (KB2984923) +$outputFolder = 'c:\sqlsyms\12.0.2402.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/74853044551f42dc87b5388cb869e80e2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.2402.00 ((SQL14_RTM_QFE-CU).140813-1032) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/b95f32db724a460eb6eef6e130b837262/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2402.00 ((SQL14_RTM_QFE-CU).140813-1032) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/ea34d76c06f34b6cb7b0908f0746c0782/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2402.00 ((SQL14_RTM_QFE-CU).140813-1032) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/b0d9d6294e034a73afeeee938172760b2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.2402.00 ((SQL14_RTM_QFE-CU).140813-1032) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/bf41580581a9420fb851f76ec3afb75a2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2402.00 ((SQL14_RTM_QFE-CU).140813-1032) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/f96bf02390534634bdc1e8d623c2d33a2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2402.00 ((SQL14_RTM_QFE-CU).140813-1032) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/f822ab6d65fc431cb5ab54b0ee8e3d4e1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.2402.00 ((SQL14_RTM_QFE-CU).140813-1032) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/7b77a2193e4f4891b0f34f9cda87f7b11/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.2402.00 ((SQL14_RTM_QFE-CU).140813-1032) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/5ef94f8c3ac34e8494fe1807ea68107b1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.2402.00 ((SQL14_RTM_QFE-CU).140813-1032) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/70d73245215e4eb1968511982957b5a51/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2402.00 ((SQL14_RTM_QFE-CU).140813-1032) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/56ece3cd49754bf8b5aea9068ca1858a2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2402.00 ((SQL14_RTM_QFE-CU).140813-1032) +``` + +# SQL Server 2014 RTM CU3 - 12.0.2402.0 - x86 (KB2984923) +``` powershell +# SQL Server 2014 RTM CU3 - 12.0.2402.0 - x86 (KB2984923) +$outputFolder = 'c:\sqlsyms\12.0.2402.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/0232dbfdd56b459fb96c006f563d2f6c1/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.2402.00 ((SQL14_RTM_QFE-CU).140813-1032) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/0d331b541b294e44a065cae4384077da1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2402.00 ((SQL14_RTM_QFE-CU).140813-1032) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/1fdf9f2c4cd74c4c99eaf0b33fb615271/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2402.00 ((SQL14_RTM_QFE-CU).140813-1032) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/1f461bef6f764833badbfb63717c6ca21/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.2402.00 ((SQL14_RTM_QFE-CU).140813-1032) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/8dde3944f69a481aa12e39b50dc1387e2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2402.00 ((SQL14_RTM_QFE-CU).140813-1032) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/fc462491d53f4437bbf3b53c21a2d19b1/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2402.00 ((SQL14_RTM_QFE-CU).140813-1032) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/3abaa853cdfd43538b656cf6b8ed08f41/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2402.00 ((SQL14_RTM_QFE-CU).140813-1032) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/c1fcff98a6144ea89585dbf7506c49c31/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2402.00 ((SQL14_RTM_QFE-CU).140813-1032) +``` + +# SQL Server 2014 RTM CU2 - 12.0.2370.0 - x64 (KB2967546) +``` powershell +# SQL Server 2014 RTM CU2 - 12.0.2370.0 - x64 (KB2967546) +$outputFolder = 'c:\sqlsyms\12.0.2370.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/00fe9a5483574e96ba85d4e14743c8cf2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.2370.00 ((SQL14_RTM_QFE-CU).140621-1135) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/c0cd8d60c1ac4687a1f529cca07230152/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2370.00 ((SQL14_RTM_QFE-CU).140621-1135) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/a3e0e381d1dc4ba2abefa830fb5908072/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2370.00 ((SQL14_RTM_QFE-CU).140621-1135) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/abf0ec3c6c1f49efb5ad08dbf408ef8e2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.2370.00 ((SQL14_RTM_QFE-CU).140621-1135) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/2709a8f9d5804dc695ad1b95124e3c732/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2370.00 ((SQL14_RTM_QFE-CU).140621-1135) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/27958e94f9a14900b53db20d28600db82/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2370.00 ((SQL14_RTM_QFE-CU).140621-1135) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/af790770d88f4c40a2b39623e71a4dab1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.2370.00 ((SQL14_RTM_QFE-CU).140621-1135) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/d4ac25f2460744f992933ca2b332429e1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.2370.00 ((SQL14_RTM_QFE-CU).140621-1135) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/21a099f1ea704e979734421be237b3751/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.2370.00 ((SQL14_RTM_QFE-CU).140621-1135) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/28d76d0753dc4ed1b8a26d6a8820df5e1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2370.00 ((SQL14_RTM_QFE-CU).140621-1135) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/021ad6b05b234d8484546842381e7d652/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2370.00 ((SQL14_RTM_QFE-CU).140621-1135) +``` + +# SQL Server 2014 RTM CU2 - 12.0.2370.0 - x86 (KB2967546) +``` powershell +# SQL Server 2014 RTM CU2 - 12.0.2370.0 - x86 (KB2967546) +$outputFolder = 'c:\sqlsyms\12.0.2370.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/efa900c9c1eb4134a444a4adf16505551/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.2370.00 ((SQL14_RTM_QFE-CU).140621-1135) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/7e9bd6b6dc8f41448ceaad495e2da09a1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2370.00 ((SQL14_RTM_QFE-CU).140621-1135) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/1866d12aa39c485397ac98c9edfb88101/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2370.00 ((SQL14_RTM_QFE-CU).140621-1135) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/3cd6a9cb42774008ad553c1ff1b647d91/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.2370.00 ((SQL14_RTM_QFE-CU).140621-1135) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/9c6ed829937f4036b7fabcff7173cdab2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2370.00 ((SQL14_RTM_QFE-CU).140621-1135) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/6f14e9defc694da98c58fd58d3a358481/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2370.00 ((SQL14_RTM_QFE-CU).140621-1135) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/54dbf7bb6af447298c7637a9ada989ac1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2370.00 ((SQL14_RTM_QFE-CU).140621-1135) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/1e3ffb2e704744d6a73cfb79cb38619f1/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2370.00 ((SQL14_RTM_QFE-CU).140621-1135) +``` + +# SQL Server 2014 RTM CU1 - 12.0.2342.0 - x64 (KB2931693) +``` powershell +# SQL Server 2014 RTM CU1 - 12.0.2342.0 - x64 (KB2931693) +$outputFolder = 'c:\sqlsyms\12.0.2342.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/57c252c885d8450b93688037679d5db22/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2014.0120.2342.00 ((SQL14_RTM_QFE-CU).140404-1739) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/a35c73537ad64f2ab17ad8ef76ceeb4c2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2342.00 ((SQL14_RTM_QFE-CU).140404-1739) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/550f9e5b95f44c42a77d2f32154b77eb2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2342.00 ((SQL14_RTM_QFE-CU).140404-1739) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/b97e3ca52a8e4182992f891a812e911d2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2014.0120.2342.00 ((SQL14_RTM_QFE-CU).140404-1739) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/65b8869fb0b44abfaf9f3635bb4c694f2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2342.00 ((SQL14_RTM_QFE-CU).140404-1739) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/9e454a85cdba496dbb47c8aeb1d5c66b2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2342.00 ((SQL14_RTM_QFE-CU).140404-1739) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/ba6cba69141549d4b828b2e3a8e69b981/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2014.0120.2342.00 ((SQL14_RTM_QFE-CU).140404-1739) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/fe5ab059d8de48b6b74bd26c7c0015ca1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2014.0120.2342.00 ((SQL14_RTM_QFE-CU).140404-1739) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/318b9d34af1d4e1780ef5277e5a5a8741/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2014.0120.2342.00 ((SQL14_RTM_QFE-CU).140404-1739) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/8f42604977cd4be4a8c3d12f390048cf1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2342.00 ((SQL14_RTM_QFE-CU).140404-1739) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/5460fb87c3d54751906607c8a455f81a2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2342.00 ((SQL14_RTM_QFE-CU).140404-1739) +``` + +# SQL Server 2014 RTM CU1 - 12.0.2342.0 - x86 (KB2931693) +``` powershell +# SQL Server 2014 RTM CU1 - 12.0.2342.0 - x86 (KB2931693) +$outputFolder = 'c:\sqlsyms\12.0.2342.0\x86' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/74815ec15b4c4e5db8b41b9f77197a431/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2014.0120.2342.00 ((SQL14_RTM_QFE-CU).140404-1739) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/33e87393cabf44a381d3b0d5f7d36efe1/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2014.0120.2342.00 ((SQL14_RTM_QFE-CU).140404-1739) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/e84e6950792046a9ad837c8451c0bab41/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2014.0120.2342.00 ((SQL14_RTM_QFE-CU).140404-1739) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/2369cc5ed5334d2587d538a1075230d01/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2014.0120.2342.00 ((SQL14_RTM_QFE-CU).140404-1739) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/6982bb0a3859490eae0d8885cc0dd1322/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2014.0120.2342.00 ((SQL14_RTM_QFE-CU).140404-1739) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/5d24211092fb49aaa62c76ee12da579f1/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2014.0120.2342.00 ((SQL14_RTM_QFE-CU).140404-1739) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/c98e147056fd4ad9bc50de8c6705590a1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2014.0120.2342.00 ((SQL14_RTM_QFE-CU).140404-1739) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/76992783851b4654be2bd359dc53bc831/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2014.0120.2342.00 ((SQL14_RTM_QFE-CU).140404-1739) +``` + diff --git a/Errors/PDB/SQL-Server-2016.md b/Errors/PDB/SQL-Server-2016.md new file mode 100644 index 00000000..4acae0e8 --- /dev/null +++ b/Errors/PDB/SQL-Server-2016.md @@ -0,0 +1,699 @@ +# SQL Server 2016 SP2 CU13 - 13.0.5820.21 - x64 (KB4549825) +``` powershell +# SQL Server 2016 SP2 CU13 - 13.0.5820.21 - x64 (KB4549825) +$outputFolder = 'c:\sqlsyms\13.0.5820.21\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/e6a5231d69314339a622dec94dcdd7d32/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0131.5820.21 ((SQL16_SP2_QFE-CU).200522-0642) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/96c764d747bf420b9996befef7475c9a2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0131.5820.21 ((SQL16_SP2_QFE-CU).200522-0642) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/9ee1aa873d2d4b778e6a54459fd7914d2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0131.5820.21 ((SQL16_SP2_QFE-CU).200522-0642) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/e09ce83a1ee54955a5e6406176a389362/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0131.5820.21 ((SQL16_SP2_QFE-CU).200522-0642) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/62fe14b4c3604a3fb403bb7e22940c362/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0131.5820.21 ((SQL16_SP2_QFE-CU).200522-0642) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/7221bd8eef08483c81a4a857dd6587d82/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0131.5820.21 ((SQL16_SP2_QFE-CU).200522-0642) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/aa95581843cc476f8b86d487e4f708f51/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0131.5820.21 ((SQL16_SP2_QFE-CU).200522-0642) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/22bf33591a704ff09291525ac1d00d191/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0131.5820.21 ((SQL16_SP2_QFE-CU).200522-0642) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/8f4b1832517446938ef926263aab57cf1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0131.5820.21 ((SQL16_SP2_QFE-CU).200522-0642) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/f8668e661315449497cea566e51c83131/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0131.5820.21 ((SQL16_SP2_QFE-CU).200522-0642) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/2633f57463f64221a5ebeff75ed2100d2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0131.5820.21 ((SQL16_SP2_QFE-CU).200522-0642) +``` + +# SQL Server 2016 SP2 CU12 - 13.0.5698.0 - x64 (KB4536648) +``` powershell +# SQL Server 2016 SP2 CU12 - 13.0.5698.0 - x64 (KB4536648) +$outputFolder = 'c:\sqlsyms\13.0.5698.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/0271f8481dae4e9493e450b8dc796bc02/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0131.5698.00 ((SQL16_SP2_QFE-CU).200215-0125) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/641b2f06bbc146b38bc05e9b58e36d0f2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0131.5698.00 ((SQL16_SP2_QFE-CU).200215-0125) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/72307bde192a4c319454098c20cb912b2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0131.5698.00 ((SQL16_SP2_QFE-CU).200215-0125) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/bcd4e428d7c94039b4955ed076e7a3682/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0131.5698.00 ((SQL16_SP2_QFE-CU).200215-0125) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/92812c2e4617474db8111c7804eda4f92/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0131.5698.00 ((SQL16_SP2_QFE-CU).200215-0125) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/5a323ebb0fbc4248b605abd7c0654b2c2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0131.5698.00 ((SQL16_SP2_QFE-CU).200215-0125) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/d3cd4e59ac0046c1a6f61aafb00e2c4c1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0131.5698.00 ((SQL16_SP2_QFE-CU).200215-0125) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/20e8d53a37e1427cb93fa7cafe5f27aa1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0131.5698.00 ((SQL16_SP2_QFE-CU).200215-0125) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/d0bcad819dcc4842929e81a1e9ecb59e1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0131.5698.00 ((SQL16_SP2_QFE-CU).200215-0125) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/98ebdb42d04440ba9295070f88407f6a1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0131.5698.00 ((SQL16_SP2_QFE-CU).200215-0125) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/0148f923aea94af19053f99ba79996682/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0131.5698.00 ((SQL16_SP2_QFE-CU).200215-0125) +``` + +# SQL Server 2016 SP2 CU11 - 13.0.5598.27 - x64 (KB4527378) +``` powershell +# SQL Server 2016 SP2 CU11 - 13.0.5598.27 - x64 (KB4527378) +$outputFolder = 'c:\sqlsyms\13.0.5598.27\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/430ef93c7b564dc2a93647e6e1fafc8c2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0131.5598.27 ((SQL16_SP2_QFE-CU).191127-1657) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/79015e09729743128701ee4f66f24fe92/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0131.5598.27 ((SQL16_SP2_QFE-CU).191127-1657) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/c4b83e706a594c56b9f509cd06c33b762/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0131.5598.27 ((SQL16_SP2_QFE-CU).191127-1657) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/f137caf5bd854030935dcf93b62eeaeb2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0131.5598.27 ((SQL16_SP2_QFE-CU).191127-1657) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/832f21f9f07244ca8ae43ecb5f76fb9d2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0131.5598.27 ((SQL16_SP2_QFE-CU).191127-1657) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/1aefde25bf814c2197bd09f7f58513292/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0131.5598.27 ((SQL16_SP2_QFE-CU).191127-1657) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/380b9e486b1643008a409f775f7c8a411/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0131.5598.27 ((SQL16_SP2_QFE-CU).191127-1657) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/001fd9d68d3c4dae8e89c2402fa889021/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0131.5598.27 ((SQL16_SP2_QFE-CU).191127-1657) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/75ccea7cdb124f4a8ececf21620e312f1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0131.5598.27 ((SQL16_SP2_QFE-CU).191127-1657) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/8a1a47fa116541d3bf3428149ba6b3bb1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0131.5598.27 ((SQL16_SP2_QFE-CU).191127-1657) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/186252fbc0884d24b6fe231af0759a352/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0131.5598.27 ((SQL16_SP2_QFE-CU).191127-1657) +``` + +# SQL Server 2016 SP2 CU10 - 13.0.5492.2 - x64 (KB4524334) +``` powershell +# SQL Server 2016 SP2 CU10 - 13.0.5492.2 - x64 (KB4524334) +$outputFolder = 'c:\sqlsyms\13.0.5492.2\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/70ecf5dbd5ef45d58df538eeb5e739b42/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0131.5492.02 ((SQL16_SP2_QFE-CU).191004-1836) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/63e1be959b6b450b974b7736342adbfa2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0131.5492.02 ((SQL16_SP2_QFE-CU).191004-1836) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/bf2a1e4b8d03428aacfea5d795e2425b2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0131.5492.02 ((SQL16_SP2_QFE-CU).191004-1836) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/fd96f94072a141758a4cbea2812690a12/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0131.5492.02 ((SQL16_SP2_QFE-CU).191004-1836) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/4048059f80d943babfc3f6c28cbaea1f2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0131.5492.02 ((SQL16_SP2_QFE-CU).191004-1836) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/bb191544f6184394adf2c918affc041f2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0131.5492.02 ((SQL16_SP2_QFE-CU).191004-1836) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/d5895ca6c7dc4374b010a96739da4bc21/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0131.5492.02 ((SQL16_SP2_QFE-CU).191004-1836) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/801fb6f15a7f4965acaabfab3e987d9c1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0131.5492.02 ((SQL16_SP2_QFE-CU).191004-1836) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/c3151df89b1c457dabf76e34c04f1bb71/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0131.5492.02 ((SQL16_SP2_QFE-CU).191004-1836) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/6f298cba9ac5443cb1450d8082c0c3011/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0131.5492.02 ((SQL16_SP2_QFE-CU).191004-1836) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/006c2ae04bf045c0a9b5effd267136ad2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0131.5492.02 ((SQL16_SP2_QFE-CU).191004-1836) +``` + +# SQL Server 2016 SP2 CU8 - 13.0.5426.0 - x64 (KB4505830) +``` powershell +# SQL Server 2016 SP2 CU8 - 13.0.5426.0 - x64 (KB4505830) +$outputFolder = 'c:\sqlsyms\13.0.5426.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/18b397dfe9034092a48167ec1ec5ea0b2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0131.5426.00 ((SQL16_SP2_QFE-CU).190721-2038) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/132b5e0d712b4464be80ed12e1e5505e2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0131.5426.00 ((SQL16_SP2_QFE-CU).190721-2038) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/db48420d121b42899a92f0d23dc57ad22/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0131.5426.00 ((SQL16_SP2_QFE-CU).190721-2038) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/d5acd14328d4434abea6af32ef61536a2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0131.5426.00 ((SQL16_SP2_QFE-CU).190721-2038) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/32d9395ab3de4e75a7e11a1d23cb5e822/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0131.5426.00 ((SQL16_SP2_QFE-CU).190721-2038) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/c010f16083f14fab9a85dd2d21893a302/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0131.5426.00 ((SQL16_SP2_QFE-CU).190721-2038) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/9dfd9945902246ccb7d504ba4d348f461/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0131.5426.00 ((SQL16_SP2_QFE-CU).190721-2038) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/331c42cbf74a420e81faba8d2c85a3cf1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0131.5426.00 ((SQL16_SP2_QFE-CU).190721-2038) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/7acfbd3f08164c9aa7b501bf677cb43c1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0131.5426.00 ((SQL16_SP2_QFE-CU).190721-2038) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/d604a24250b64ca6a926842ec51546ad1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0131.5426.00 ((SQL16_SP2_QFE-CU).190721-2038) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/1e0e6f6d8afd403bbb31684416b9314e2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0131.5426.00 ((SQL16_SP2_QFE-CU).190721-2038) +``` + +# SQL Server 2016 SP2 Hotfix for SP2 CU7 - 13.0.5343.1 - x64 (4508636) +``` powershell +# SQL Server 2016 SP2 Hotfix for SP2 CU7 - 13.0.5343.1 - x64 (4508636) +$outputFolder = 'c:\sqlsyms\13.0.5343.1\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/e4884387ee894c14b9ba32a55b1e4ed72/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0131.5343.01 ((SQL16_SP2_QFE-OD).190614-1944) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/5504c31fbc484a04960c330f5520df7a2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0131.5343.01 ((SQL16_SP2_QFE-OD).190614-1944) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/b4414980247d436abdf4cf4c43f5023f2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0131.5343.01 ((SQL16_SP2_QFE-OD).190614-1944) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/47b47fc8b89d47d5a82297cf24630ca02/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0131.5343.01 ((SQL16_SP2_QFE-OD).190614-1944) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/72d0f73f142c4d1f9c2be9ce5c5f9a7b2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0131.5343.01 ((SQL16_SP2_QFE-OD).190614-1944) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/66bd5fc8cd934353b7fa1b2db5d1e5382/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0131.5343.01 ((SQL16_SP2_QFE-OD).190614-1944) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/5e06fd5a624848ff9a02a71ddf0c11481/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0131.5343.01 ((SQL16_SP2_QFE-OD).190614-1944) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/ca29126933fd43f7bcc35106076ac2471/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0131.5343.01 ((SQL16_SP2_QFE-OD).190614-1944) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/25e8c49501a8498a86d2a13ab329b3ea1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0131.5343.01 ((SQL16_SP2_QFE-OD).190614-1944) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/ccd4f61a1ae7416b9caecb49e46c96ca1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0131.5343.01 ((SQL16_SP2_QFE-OD).190614-1944) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/9dd288e031a2402dbad6f68c468a1f662/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0131.5343.01 ((SQL16_SP2_QFE-OD).190614-1944) +``` + +# SQL Server 2016 SP2 CU7 - 13.0.5337.0 - x64 (KB4495256) +``` powershell +# SQL Server 2016 SP2 CU7 - 13.0.5337.0 - x64 (KB4495256) +$outputFolder = 'c:\sqlsyms\13.0.5337.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/19f0728b189a437db61f6d0a59378c2f2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0131.5337.00 ((SQL16_SP2_QFE-CU).190516-0131) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/27a0893b43494606b4da007056d14b8f2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0131.5337.00 ((SQL16_SP2_QFE-CU).190516-0131) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/53f66882dcc948a5ab43ccf35f8c62172/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0131.5337.00 ((SQL16_SP2_QFE-CU).190516-0131) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/26528819a67f4c9793cdb2c6b6d25f022/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0131.5337.00 ((SQL16_SP2_QFE-CU).190516-0131) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/f6d28fb6f5ac469a828b160544679d362/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0131.5337.00 ((SQL16_SP2_QFE-CU).190516-0131) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/956090e1037945b2928f4f605b52ded32/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0131.5337.00 ((SQL16_SP2_QFE-CU).190516-0131) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/55ab1c4583324e4181dc2d13638a270c1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0131.5337.00 ((SQL16_SP2_QFE-CU).190516-0131) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/4a5ef712546c4ea593b3919fc8e9be3c1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0131.5337.00 ((SQL16_SP2_QFE-CU).190516-0131) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/b29f002c7c8546f399a8818e0f01340f1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0131.5337.00 ((SQL16_SP2_QFE-CU).190516-0131) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/decb2afdf5ad41c48644e8ee74024d501/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0131.5337.00 ((SQL16_SP2_QFE-CU).190516-0131) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/e272bf31dd404e02800badc8605d29702/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0131.5337.00 ((SQL16_SP2_QFE-CU).190516-0131) +``` + +# SQL Server 2016 SP2 CU6 - 13.0.5292.0 - x64 (KB4488536) +``` powershell +# SQL Server 2016 SP2 CU6 - 13.0.5292.0 - x64 (KB4488536) +$outputFolder = 'c:\sqlsyms\13.0.5292.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/950cfd27fb154e0fa81f5171d3a9e72c2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0131.5292.00 ((SQL16_SP2_QFE-CU).190311-2257) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/f4e8c4a23f0e4300b84aff830703780e2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0131.5292.00 ((SQL16_SP2_QFE-CU).190311-2257) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/98e48204764e43beb5a7512730a309542/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0131.5292.00 ((SQL16_SP2_QFE-CU).190311-2257) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/2c6f6ddf2326442bbf1d71142d177eb12/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0131.5292.00 ((SQL16_SP2_QFE-CU).190311-2257) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/e677182deae14a179afc8d4cd0de3e682/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0131.5292.00 ((SQL16_SP2_QFE-CU).190311-2257) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/705ca25058a944e6ab3c1ab89d77de3c2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0131.5292.00 ((SQL16_SP2_QFE-CU).190311-2257) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/6b45c84e9e8e4450ac26bdc614b491da1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0131.5292.00 ((SQL16_SP2_QFE-CU).190311-2257) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/1f44e38a066b4c9aad14b90ea547e5f11/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0131.5292.00 ((SQL16_SP2_QFE-CU).190311-2257) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/bcf044a5cfc64d03be7cdf8df023bd2d1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0131.5292.00 ((SQL16_SP2_QFE-CU).190311-2257) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/dad251dee8644e4dbf61bedbcf9a06bf1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0131.5292.00 ((SQL16_SP2_QFE-CU).190311-2257) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/d6c736e277fd4baf8e88d3b6d27cff362/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0131.5292.00 ((SQL16_SP2_QFE-CU).190311-2257) +``` + +# SQL Server 2016 SP2 CU5 - 13.0.5264.1 - x64 (KB4475776) +``` powershell +# SQL Server 2016 SP2 CU5 - 13.0.5264.1 - x64 (KB4475776) +$outputFolder = 'c:\sqlsyms\13.0.5264.1\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/0bae10a1491645f8a97b697fe565dd332/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0131.5264.01 ((SQL16_SP2_QFE-CU).190110-1506) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/85a6f0d21b0a4d8f96d6aa8049a1c8892/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0131.5264.01 ((SQL16_SP2_QFE-CU).190110-1506) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/f5b7a81e036a4be3bc7c1858909869802/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0131.5264.01 ((SQL16_SP2_QFE-CU).190110-1506) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/e8f4359ed540405ebf50b2593e54434b2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0131.5264.01 ((SQL16_SP2_QFE-CU).190110-1506) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/73d85290046448bdbcc3ede97dfc234b2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0131.5264.01 ((SQL16_SP2_QFE-CU).190110-1506) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/81dc5887677b47be879138df0c3009b12/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0131.5264.01 ((SQL16_SP2_QFE-CU).190110-1506) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/97818e2e150f41d4a1b3882e98aee44e1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0131.5264.01 ((SQL16_SP2_QFE-CU).190110-1506) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/fcb62686788c4edab5fbbb3586fa70641/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0131.5264.01 ((SQL16_SP2_QFE-CU).190110-1506) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/e3d3a5d84aa04e1c95a508d1a2a121ca1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0131.5264.01 ((SQL16_SP2_QFE-CU).190110-1506) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/8f3f2c17b925463ab3be306a8bfbf6191/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0131.5264.01 ((SQL16_SP2_QFE-CU).190110-1506) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/21046a92c3c344459925db3348bed5402/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0131.5264.01 ((SQL16_SP2_QFE-CU).190110-1506) +``` + +# SQL Server 2016 SP2 CU4 - 13.0.5233.0 - x64 (KB4464106) +``` powershell +# SQL Server 2016 SP2 CU4 - 13.0.5233.0 - x64 (KB4464106) +$outputFolder = 'c:\sqlsyms\13.0.5233.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/f1595ec49d654c548b60b5b8640881562/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0131.5233.00 ((SQL16_SP2_QFE-CU).181102-1539) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/8d1e052738ed4834ac1162b8970bf0532/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0131.5233.00 ((SQL16_SP2_QFE-CU).181102-1539) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/9b29b84d1daa4cb690c91697520de38a2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0131.5233.00 ((SQL16_SP2_QFE-CU).181102-1539) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/7975964f1eb7477988fd520d142465bf2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0131.5233.00 ((SQL16_SP2_QFE-CU).181102-1539) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/1be684f3c3984a379a6438f8c36fbb4a2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0131.5233.00 ((SQL16_SP2_QFE-CU).181102-1539) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/17bc4cfd173e428fb9eae9da392a49682/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0131.5233.00 ((SQL16_SP2_QFE-CU).181102-1539) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/87146b12ed3649fa9968b622bb55394e1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0131.5233.00 ((SQL16_SP2_QFE-CU).181102-1539) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/f428b375b3ac4ef38be75a3d7affd27b1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0131.5233.00 ((SQL16_SP2_QFE-CU).181102-1539) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/624caa45728c42819a84a8a89279d3471/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0131.5233.00 ((SQL16_SP2_QFE-CU).181102-1539) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/1f8acdfa201f4b3fb8fd8b64013b32be1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0131.5233.00 ((SQL16_SP2_QFE-CU).181102-1539) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/45097423fa97421fb2c60e85d141580c2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0131.5233.00 ((SQL16_SP2_QFE-CU).181102-1539) +``` + +# SQL Server 2016 SP2 CU3 - 13.0.5216.0 - x64 (KB4458871) +``` powershell +# SQL Server 2016 SP2 CU3 - 13.0.5216.0 - x64 (KB4458871) +$outputFolder = 'c:\sqlsyms\13.0.5216.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/f9c66f15cdc3472da5b316372a3cd0c62/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0131.5216.00 ((SQL16_SP2_QFE-CU).180913-2138) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/4eb925dc9f414f4293fb048931c1d1d12/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0131.5216.00 ((SQL16_SP2_QFE-CU).180913-2138) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/2aaea59f054945b1948f09a286af4aa22/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0131.5216.00 ((SQL16_SP2_QFE-CU).180913-2138) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/d9a41e1b050741a9915c9f2f68841b662/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0131.5216.00 ((SQL16_SP2_QFE-CU).180913-2138) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/127cbf6e83634f56858c143daccdf3472/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0131.5216.00 ((SQL16_SP2_QFE-CU).180913-2138) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/8cd3001646bb4bee9fa7b29c4e3c424d2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0131.5216.00 ((SQL16_SP2_QFE-CU).180913-2138) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/cef124fae1224970a283718094129ec41/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0131.5216.00 ((SQL16_SP2_QFE-CU).180913-2138) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/3428a25be3a1405bb9e935aa5e5a5f921/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0131.5216.00 ((SQL16_SP2_QFE-CU).180913-2138) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/86edaf9016ec43d49af82793f7361d011/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0131.5216.00 ((SQL16_SP2_QFE-CU).180913-2138) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/25fb6b2428844941bc633974f50616bc1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0131.5216.00 ((SQL16_SP2_QFE-CU).180913-2138) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/df83d51fbc304a579684e3c308750cba2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0131.5216.00 ((SQL16_SP2_QFE-CU).180913-2138) +``` + +# SQL Server 2016 SP2 CU2 + Security Update - 13.0.5201.2 - x64 (KB4458621) +``` powershell +# SQL Server 2016 SP2 CU2 + Security Update - 13.0.5201.2 - x64 (KB4458621) +$outputFolder = 'c:\sqlsyms\13.0.5201.2\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/048d5147a1fb4e80b787588ffc9fc1e62/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0131.5201.02 ((SQL16_SP2_QFE-CU).180818-0710) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/a75b883c7cf144338e088ca1afe44c472/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0131.5201.02 ((SQL16_SP2_QFE-CU).180818-0710) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/fadd356647c4454191fdf160228f57e72/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0131.5201.02 ((SQL16_SP2_QFE-CU).180818-0710) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/55d8b0e99a7446308229c50cefdd930e2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0131.5201.02 ((SQL16_SP2_QFE-CU).180818-0710) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/f7a6fc258016430597598d515e0a483f2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0131.5201.02 ((SQL16_SP2_QFE-CU).180818-0710) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/8f9e0659b5514f89b3cac5bdcfc7e3882/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0131.5201.02 ((SQL16_SP2_QFE-CU).180818-0710) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/ecb9fb39a89c4e59b3daad0b525fa9b71/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0131.5201.02 ((SQL16_SP2_QFE-CU).180818-0710) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/9ecba208484247eaa0a0e2d43c3bbb5d1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0131.5201.02 ((SQL16_SP2_QFE-CU).180818-0710) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/d05ba204ab6d4176bfa45358d8bc42121/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0131.5201.02 ((SQL16_SP2_QFE-CU).180818-0710) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/41df1265eeed4d5086844d85018088bf1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0131.5201.02 ((SQL16_SP2_QFE-CU).180818-0710) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/8360d2c4f315435cb1a449b1ebe4a68a2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0131.5201.02 ((SQL16_SP2_QFE-CU).180818-0710) +``` + +# SQL Server 2016 SP2 CU2 - 13.0.5153.0 - x64 (KB4340355) +``` powershell +# SQL Server 2016 SP2 CU2 - 13.0.5153.0 - x64 (KB4340355) +$outputFolder = 'c:\sqlsyms\13.0.5153.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/fddc412a5dcb40429eda4fb2f4fb09572/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0131.5153.00 ((SQL16_SP2_QFE-CU).180628-1652) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/dd1807b4810a4aee89a261e957c2d8f92/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0131.5153.00 ((SQL16_SP2_QFE-CU).180628-1652) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/0e02593224ce4b00a8ae88c15f7554822/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0131.5153.00 ((SQL16_SP2_QFE-CU).180628-1652) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/7f96e1cef4e24bd58ce1bfb0097d7bd62/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0131.5153.00 ((SQL16_SP2_QFE-CU).180628-1652) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/cbb698692191446e8e63cbb247cb4abe2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0131.5153.00 ((SQL16_SP2_QFE-CU).180628-1652) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/ce4e0c0acef54b2e889a6e92ce618f3b2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0131.5153.00 ((SQL16_SP2_QFE-CU).180628-1652) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/8b8a156300244f6d998e9518bf3655741/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0131.5153.00 ((SQL16_SP2_QFE-CU).180628-1652) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/f332d042c9ba422c8fb4dadb8ad6bd601/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0131.5153.00 ((SQL16_SP2_QFE-CU).180628-1652) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/f507bb1cdc6b4c46b06676fde5cdf8c71/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0131.5153.00 ((SQL16_SP2_QFE-CU).180628-1652) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/9689d6f86afc4da78d5cfb3bfbe5950b1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0131.5153.00 ((SQL16_SP2_QFE-CU).180628-1652) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/bb2788ca8bc24a8cac395d4371de62422/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0131.5153.00 ((SQL16_SP2_QFE-CU).180628-1652) +``` + +# SQL Server 2016 SP2 CU1 - 13.0.5149.0 - x64 (KB4135048) +``` powershell +# SQL Server 2016 SP2 CU1 - 13.0.5149.0 - x64 (KB4135048) +$outputFolder = 'c:\sqlsyms\13.0.5149.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/6d9698a353374e5c938b2acb7ee7ed362/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0131.5149.00 ((SQL16_SP2_QFE-CU).180519-0907) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/37faf9a6bc2b4d16a8d962d486092a302/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0131.5149.00 ((SQL16_SP2_QFE-CU).180519-0907) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/271e230238254765bcd979679d6b56982/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0131.5149.00 ((SQL16_SP2_QFE-CU).180519-0907) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/9f9dc614a58242c2a85acc563e431db62/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0131.5149.00 ((SQL16_SP2_QFE-CU).180519-0907) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/bf258f9a750546b6a8b936b4970b7eca2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0131.5149.00 ((SQL16_SP2_QFE-CU).180519-0907) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/b896f5579e09485e9d9eec87d67b676f2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0131.5149.00 ((SQL16_SP2_QFE-CU).180519-0907) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/3cd9ede70ebf4e4185992fe4fa65b2d61/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0131.5149.00 ((SQL16_SP2_QFE-CU).180519-0907) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/f31fd9f5e3ef4fe096cf59903c387f4b1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0131.5149.00 ((SQL16_SP2_QFE-CU).180519-0907) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/762df1defe62466280d87d81794865c61/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0131.5149.00 ((SQL16_SP2_QFE-CU).180519-0907) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/72d4af7f134e4cb49edcccf5f4cf383f1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0131.5149.00 ((SQL16_SP2_QFE-CU).180519-0907) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/c5ce87b693a14696b7df5cb69aee3d442/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0131.5149.00 ((SQL16_SP2_QFE-CU).180519-0907) +``` + +# SQL Server 2016 SP2 SP2 - 13.0.5026.0 - x64 (KB4052908) +``` powershell +# SQL Server 2016 SP2 SP2 - 13.0.5026.0 - x64 (KB4052908) +$outputFolder = 'c:\sqlsyms\13.0.5026.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/efc619ab5524425aa224c623beaf4a662/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0131.5026.00 ((SQL16_PCU_Main).180318-0835) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/104358b4c4b04eec8a75e36af274c29f2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0131.5026.00 ((SQL16_PCU_Main).180318-0835) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/cae1133e7ab54002a38c876e49559d222/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0131.5026.00 ((SQL16_PCU_Main).180318-0835) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/8f07285b69314e478c481af6c60aa28e2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0131.5026.00 ((SQL16_PCU_Main).180318-0835) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/c390e4f8204e4d87a76a44032594be0d2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0131.5026.00 ((SQL16_PCU_Main).180318-0835) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/4f2f9273fda643d4a2dfd31a67e93a0e2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0131.5026.00 ((SQL16_PCU_Main).180318-0835) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/7866454b831848c5b5de93b2b03fb8491/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0131.5026.00 ((SQL16_PCU_Main).180318-0835) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/445daee2af1a43f295208380348074031/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0131.5026.00 ((SQL16_PCU_Main).180318-0835) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/6c004a1c95204734b6cef4f8511617421/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0131.5026.00 ((SQL16_PCU_Main).180318-0835) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/a6047d2982024452905f1fff97fa11421/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0131.5026.00 ((SQL16_PCU_Main).180318-0835) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/ee2324e08c3e4f42acf1572a9cb62d9e2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0131.5026.00 ((SQL16_PCU_Main).180318-0835) +``` + +# SQL Server 2016 SP1 CU15 - 13.0.4574.0 - x64 (KB4495257) +``` powershell +# SQL Server 2016 SP1 CU15 - 13.0.4574.0 - x64 (KB4495257) +$outputFolder = 'c:\sqlsyms\13.0.4574.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/da14e7ceb24d4c2890b2bde9a03778e52/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0130.4574.00 ((SQL16_SP1_QFE-CU).190427-1658) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/d0dc0e05673549c39349963e9c6115eb2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0130.4574.00 ((SQL16_SP1_QFE-CU).190427-1658) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/003624ea1e0642a58b9040c5811ecc372/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0130.4574.00 ((SQL16_SP1_QFE-CU).190427-1658) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/c408c0723f014e5f90286bc7c822f7142/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0130.4574.00 ((SQL16_SP1_QFE-CU).190427-1658) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/205c4da00f5c4795a18730dd162b0e5c2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0130.4574.00 ((SQL16_SP1_QFE-CU).190427-1658) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/7d0210ad6c38483d82d5a673f656490b2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0130.4574.00 ((SQL16_SP1_QFE-CU).190427-1658) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/e5157d95993b4804b14b3ba28ac25a4e1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0130.4574.00 ((SQL16_SP1_QFE-CU).190427-1658) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/6c807a6e0bfe4a3d8ddbebb9c5df94b21/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0130.4574.00 ((SQL16_SP1_QFE-CU).190427-1658) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/04e55a9040ff4d5a901fb9edb3f714ba1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0130.4574.00 ((SQL16_SP1_QFE-CU).190427-1658) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/0d0627accf6849419318444c37eb8fb61/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0130.4574.00 ((SQL16_SP1_QFE-CU).190427-1658) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/16d8c4351bdc40ac9997dfc601968a8e2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0130.4574.00 ((SQL16_SP1_QFE-CU).190427-1658) +``` + +# SQL Server 2016 SP1 CU14 - 13.0.4560.0 - x64 (KB4488535) +``` powershell +# SQL Server 2016 SP1 CU14 - 13.0.4560.0 - x64 (KB4488535) +$outputFolder = 'c:\sqlsyms\13.0.4560.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/6a1934433512464b8b8ed905ad930ee62/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0130.4560.00 ((SQL16_SP1_QFE-CU).190312-0204) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/4d031e02b20c495c8581a9a757ae5fad2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0130.4560.00 ((SQL16_SP1_QFE-CU).190312-0204) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/fe7ef391534148c79622e391200336c42/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0130.4560.00 ((SQL16_SP1_QFE-CU).190312-0204) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/55eb1336f7f74ba48038b7c00dd46a0d2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0130.4560.00 ((SQL16_SP1_QFE-CU).190312-0204) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/cf41b9625c804b5c8cbc1a77ebc6330b2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0130.4560.00 ((SQL16_SP1_QFE-CU).190312-0204) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/9179e43956784d1ebdbffe52d6a40c5e2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0130.4560.00 ((SQL16_SP1_QFE-CU).190312-0204) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/c5be83b1f16440bc8f708236c273c2051/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0130.4560.00 ((SQL16_SP1_QFE-CU).190312-0204) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/15a13e10244142eb9d45aff1353423771/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0130.4560.00 ((SQL16_SP1_QFE-CU).190312-0204) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/a7b733870ad24fdfae1196da3201bee41/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0130.4560.00 ((SQL16_SP1_QFE-CU).190312-0204) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/33d27befeb5c4432830896ac70de90501/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0130.4560.00 ((SQL16_SP1_QFE-CU).190312-0204) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/9d0d577195464804b2e7e408f64f87d32/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0130.4560.00 ((SQL16_SP1_QFE-CU).190312-0204) +``` + +# SQL Server 2016 SP1 CU13 - 13.0.4550.1 - x64 (KB4475775) +``` powershell +# SQL Server 2016 SP1 CU13 - 13.0.4550.1 - x64 (KB4475775) +$outputFolder = 'c:\sqlsyms\13.0.4550.1\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/a9a4c14c343f48969f80364f590898602/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0130.4550.01 ((SQL16_SP1_QFE-CU).190110-1903) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/12140f43a3c84dc99114f1db9d63442b2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0130.4550.01 ((SQL16_SP1_QFE-CU).190110-1903) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/2485f60633124761be7e478491159c092/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0130.4550.01 ((SQL16_SP1_QFE-CU).190110-1903) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/4d617c540beb4fc59140e9f8547c57962/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0130.4550.01 ((SQL16_SP1_QFE-CU).190110-1903) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/c3061b6d621e4d1081838f523ef808d62/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0130.4550.01 ((SQL16_SP1_QFE-CU).190110-1903) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/22da8e8de40543f8aa01fb1b02a60e5c2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0130.4550.01 ((SQL16_SP1_QFE-CU).190110-1903) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/1a8accfb14c14072a4929654c400f8491/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0130.4550.01 ((SQL16_SP1_QFE-CU).190110-1903) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/c765c8f7785e4598b640f828d81fd9851/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0130.4550.01 ((SQL16_SP1_QFE-CU).190110-1903) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/30268bd8d01d40d0be47fb9ce30522021/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0130.4550.01 ((SQL16_SP1_QFE-CU).190110-1903) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/4c1f27348acd463dbe00df9477d840c51/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0130.4550.01 ((SQL16_SP1_QFE-CU).190110-1903) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/5c4f7f0fbb6a42689720fe6353a343e92/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0130.4550.01 ((SQL16_SP1_QFE-CU).190110-1903) +``` + +# SQL Server 2016 SP1 CU12 - 13.0.4541.0 - x64 (KB4464343) +``` powershell +# SQL Server 2016 SP1 CU12 - 13.0.4541.0 - x64 (KB4464343) +$outputFolder = 'c:\sqlsyms\13.0.4541.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/d3080f42570f4bf0a4a837a8895ca7902/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0130.4541.00 ((SQL16_SP1_QFE-CU).181026-1658) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/4dce2e3f19f74c31b5a6ac2af6a9d8262/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0130.4541.00 ((SQL16_SP1_QFE-CU).181026-1658) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/18954e55372343d5a4d6681895c263ea2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0130.4541.00 ((SQL16_SP1_QFE-CU).181026-1658) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/9aac7f2866b540b4ab2c1b9ac9e577a72/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0130.4541.00 ((SQL16_SP1_QFE-CU).181026-1658) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/8093743906d24ebbbaf34109d536867b2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0130.4541.00 ((SQL16_SP1_QFE-CU).181026-1658) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/c7333000708848b794283812c1bb4c1f2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0130.4541.00 ((SQL16_SP1_QFE-CU).181026-1658) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/c1238bf343b747f7b8b337f438942c711/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0130.4541.00 ((SQL16_SP1_QFE-CU).181026-1658) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/7f07d29b92d74e038aec8d7d0dd4b36b1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0130.4541.00 ((SQL16_SP1_QFE-CU).181026-1658) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/98c1ec14b1674f1c86ddd4ceb6ccf6fa1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0130.4541.00 ((SQL16_SP1_QFE-CU).181026-1658) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/06a0750893f44304ad32a17a180927f21/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0130.4541.00 ((SQL16_SP1_QFE-CU).181026-1658) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/7162e87a93b346bba5752ed81f9b57202/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0130.4541.00 ((SQL16_SP1_QFE-CU).181026-1658) +``` + +# SQL Server 2016 SP1 CU11 - 13.0.4528.0 - x64 (KB4459676) +``` powershell +# SQL Server 2016 SP1 CU11 - 13.0.4528.0 - x64 (KB4459676) +$outputFolder = 'c:\sqlsyms\13.0.4528.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/49f484665e944b7b955f47ac457f6f132/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0130.4528.00 ((SQL16_SP1_QFE-CU).180830-2114) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/db189aef1bba4446a2162ff54266b4ce2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0130.4528.00 ((SQL16_SP1_QFE-CU).180830-2114) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/e1bc1af368224105abe4120dbdb73f832/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0130.4528.00 ((SQL16_SP1_QFE-CU).180830-2114) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/33537b3dbc714ad39948f5a027e02e042/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0130.4528.00 ((SQL16_SP1_QFE-CU).180830-2114) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/d4a5c566de5f4e8cbc0724155e6897252/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0130.4528.00 ((SQL16_SP1_QFE-CU).180830-2114) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/6abb1e2ee2324531a59ef3e3532c7a012/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0130.4528.00 ((SQL16_SP1_QFE-CU).180830-2114) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/af8f4fe9f42b47208ffae42cd1cd846d1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0130.4528.00 ((SQL16_SP1_QFE-CU).180830-2114) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/2da374ada649478aa35648edc58188811/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0130.4528.00 ((SQL16_SP1_QFE-CU).180830-2114) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/f073ed383da5472da181faca36520b1e1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0130.4528.00 ((SQL16_SP1_QFE-CU).180830-2114) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/9f53ea00e8104275af6dbf64e1b6a3591/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0130.4528.00 ((SQL16_SP1_QFE-CU).180830-2114) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/2dc4533ebfec420a88bcb188833b50db2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0130.4528.00 ((SQL16_SP1_QFE-CU).180830-2114) +``` + +# SQL Server 2016 SP1 CU10 + Security Update - 13.0.4522.0 - x64 (KB4293808) +``` powershell +# SQL Server 2016 SP1 CU10 + Security Update - 13.0.4522.0 - x64 (KB4293808) +$outputFolder = 'c:\sqlsyms\13.0.4522.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/2c80618f9f82487ba2385a9cc3ddf88f2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0130.4522.00 ((SQL16_SP1_QFE-CU).180717-2208) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/0fae990bea634884b2bb03ef48ae0f9c2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0130.4522.00 ((SQL16_SP1_QFE-CU).180717-2208) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/744610eb2fed4fe28992cb1051af89f52/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0130.4522.00 ((SQL16_SP1_QFE-CU).180717-2208) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/231b6d23fea44f0e9978b2903e55f98c2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0130.4522.00 ((SQL16_SP1_QFE-CU).180717-2208) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/9ebc1faac19940a2913209dedfe0a8fb2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0130.4522.00 ((SQL16_SP1_QFE-CU).180717-2208) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/920fc8ef2b144b92b9e500f34c7a71292/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0130.4522.00 ((SQL16_SP1_QFE-CU).180717-2208) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/0f4ea0db1e374ab5aa9c527249a56a5b1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0130.4522.00 ((SQL16_SP1_QFE-CU).180717-2208) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/48c8d8e079b5402da40b9db2b50d98381/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0130.4522.00 ((SQL16_SP1_QFE-CU).180717-2208) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/332f649e9f7a4444b0e7f810cfe46daf1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0130.4522.00 ((SQL16_SP1_QFE-CU).180717-2208) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/306b24badfce478b88e7cc9bf4f158ba1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0130.4522.00 ((SQL16_SP1_QFE-CU).180717-2208) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/1900f69e405d454783d12534bc3e62232/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0130.4522.00 ((SQL16_SP1_QFE-CU).180717-2208) +``` + +# SQL Server 2016 SP1 CU10 - 13.0.4514.0 - x64 (KB4341569) +``` powershell +# SQL Server 2016 SP1 CU10 - 13.0.4514.0 - x64 (KB4341569) +$outputFolder = 'c:\sqlsyms\13.0.4514.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/eba3127f55a6490b925ac53a6af5ef262/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0130.4514.00 ((SQL16_SP1_QFE-CU).180622-1535) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/c36664a87ee44edc82989935ce8fa1ad2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0130.4514.00 ((SQL16_SP1_QFE-CU).180622-1535) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/7b867a51f536452a95636acf588d0cef2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0130.4514.00 ((SQL16_SP1_QFE-CU).180622-1535) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/4f050afd2b5b4cacb6ff7c302f5ce5c72/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0130.4514.00 ((SQL16_SP1_QFE-CU).180622-1535) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/e4ce24f005df4299b285c9da1050c01e2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0130.4514.00 ((SQL16_SP1_QFE-CU).180622-1535) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/ad7c0ab9750744a9985d59afa1474dda2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0130.4514.00 ((SQL16_SP1_QFE-CU).180622-1535) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/6a522b1480b54288a132ac67e8da49e51/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0130.4514.00 ((SQL16_SP1_QFE-CU).180622-1535) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/e63e19d43fb24d81b84c1208c96984ac1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0130.4514.00 ((SQL16_SP1_QFE-CU).180622-1535) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/7f5068607ec14c409d9d04c56ac9e1731/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0130.4514.00 ((SQL16_SP1_QFE-CU).180622-1535) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/0e87037690c64c06ac41a9db319a970f1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0130.4514.00 ((SQL16_SP1_QFE-CU).180622-1535) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/0840ef6023a7422f90acbfc2bfe60dfe2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0130.4514.00 ((SQL16_SP1_QFE-CU).180622-1535) +``` + +# SQL Server 2016 SP1 CU9 - 13.0.4502.0 - x64 (KB4100997) +``` powershell +# SQL Server 2016 SP1 CU9 - 13.0.4502.0 - x64 (KB4100997) +$outputFolder = 'c:\sqlsyms\13.0.4502.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/ee6e6cc4172f49ca87933514afe4929b2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0130.4502.00 ((SQL16_SP1_QFE-CU).180514-1334) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/2676f65ef4f14e1c9a6b62a9d1522fe82/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0130.4502.00 ((SQL16_SP1_QFE-CU).180514-1334) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/7dfceb96c58c453ba4e3d8a1ca78615d2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0130.4502.00 ((SQL16_SP1_QFE-CU).180514-1334) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/7f8a037059454eba99b698a776696daa2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0130.4502.00 ((SQL16_SP1_QFE-CU).180514-1334) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/334ffbfb732c4fc79e4e3513e5027a3d2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0130.4502.00 ((SQL16_SP1_QFE-CU).180514-1334) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/b561f4e3c38e4562b7972ea695cffc4c2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0130.4502.00 ((SQL16_SP1_QFE-CU).180514-1334) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/cf91d9718d41483bb4606f54896f9c3e1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0130.4502.00 ((SQL16_SP1_QFE-CU).180514-1334) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/fca548701ad64b9eb0f58be2ab0dccf11/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0130.4502.00 ((SQL16_SP1_QFE-CU).180514-1334) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/5cc13763d5064b6d97d9f1cc1ecaa20c1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0130.4502.00 ((SQL16_SP1_QFE-CU).180514-1334) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/beda030e12954da6a9eba8922683f73e1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0130.4502.00 ((SQL16_SP1_QFE-CU).180514-1334) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/2a17dec666134d14a64d767ef4aebe202/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0130.4502.00 ((SQL16_SP1_QFE-CU).180514-1334) +``` + +# SQL Server 2016 SP1 CU8 - 13.0.4474.0 - x64 (KB4077064) +``` powershell +# SQL Server 2016 SP1 CU8 - 13.0.4474.0 - x64 (KB4077064) +$outputFolder = 'c:\sqlsyms\13.0.4474.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/bad09995ed274e949232badd3f3d7aa82/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0130.4474.00 ((SQL16_SP1_QFE-CU).180224-1012) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/ddf784b88c44464fbbef4a3c309436392/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0130.4474.00 ((SQL16_SP1_QFE-CU).180224-1012) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/04aab3b7206c46a9b777313cc33d57402/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0130.4474.00 ((SQL16_SP1_QFE-CU).180224-1012) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/ef2f100c08554e4398658ca191205f162/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0130.4474.00 ((SQL16_SP1_QFE-CU).180224-1012) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/4b20376587754240a8157ec3f5c827102/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0130.4474.00 ((SQL16_SP1_QFE-CU).180224-1012) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/61506f0f9d5240c18416dae8f808755e2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0130.4474.00 ((SQL16_SP1_QFE-CU).180224-1012) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/7e93929a70af49a98c0d3a9d10d24d841/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0130.4474.00 ((SQL16_SP1_QFE-CU).180224-1012) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/e66b4e3643c94f26862bcdbcae4df7901/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0130.4474.00 ((SQL16_SP1_QFE-CU).180224-1012) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/48c28f25191a4ee0b7a4810e6c0f29f71/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0130.4474.00 ((SQL16_SP1_QFE-CU).180224-1012) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/ea990dbdb39247fbbd083d2de5f867d71/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0130.4474.00 ((SQL16_SP1_QFE-CU).180224-1012) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/0d79a37d6dda4c28aa9dea14724f12f52/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0130.4474.00 ((SQL16_SP1_QFE-CU).180224-1012) +``` + +# SQL Server 2016 SP1 CU7 - 13.0.4466.4 - x64 (KB4057119) +``` powershell +# SQL Server 2016 SP1 CU7 - 13.0.4466.4 - x64 (KB4057119) +$outputFolder = 'c:\sqlsyms\13.0.4466.4\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/4fb77886edcf4e9d89fac79ebf7d1fea2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0130.4466.04 ((SQL16_SP1_QFE-CU).171222-1041) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/04bc3e5a0e4f471e9b96d67c5e3f36df2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0130.4466.04 ((SQL16_SP1_QFE-CU).171222-1041) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/75cbabc14dbe4b78b399b0e5f88a97092/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0130.4466.04 ((SQL16_SP1_QFE-CU).171222-1041) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/c68cc2cb6c074e39881a844eec9778f82/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0130.4466.04 ((SQL16_SP1_QFE-CU).171222-1041) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/bf98529869b64e518f5afd9c0c5079c82/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0130.4466.04 ((SQL16_SP1_QFE-CU).171222-1041) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/9215ec6a12bf4d20a9e6798034e2036e2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0130.4466.04 ((SQL16_SP1_QFE-CU).171222-1041) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/33d2f4d2ce9c4e3ebb58b76dd1c289a81/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0130.4466.04 ((SQL16_SP1_QFE-CU).171222-1041) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/7aa9d469ad5e42b8b414338158cf15b41/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0130.4466.04 ((SQL16_SP1_QFE-CU).171222-1041) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/f86b9c579a474a3fac7812d34b52bf221/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0130.4466.04 ((SQL16_SP1_QFE-CU).171222-1041) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/893d1525c26945cf827a45f9b043e5eb1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0130.4466.04 ((SQL16_SP1_QFE-CU).171222-1041) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/c583e52b9d604d4da427ceb43ab482252/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0130.4466.04 ((SQL16_SP1_QFE-CU).171222-1041) +``` + +# SQL Server 2016 SP1 CU6 - 13.0.4457.0 - x64 (KB4037354) +``` powershell +# SQL Server 2016 SP1 CU6 - 13.0.4457.0 - x64 (KB4037354) +$outputFolder = 'c:\sqlsyms\13.0.4457.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/db2fe36302c64a1a86813d0549b22b012/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0130.4457.00 ((SQL16_SP1_QFE-CU).171108-1347) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/9cdf1937cd024f1e82060b74e9e60e512/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0130.4457.00 ((SQL16_SP1_QFE-CU).171108-1347) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/046a40a60ddc486086561319f5387e142/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0130.4457.00 ((SQL16_SP1_QFE-CU).171108-1347) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/2547dc27f1324d3fbb7daad4793c6cf12/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0130.4457.00 ((SQL16_SP1_QFE-CU).171108-1347) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/1a145eacaf05435abe69b319f8277b9c2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0130.4457.00 ((SQL16_SP1_QFE-CU).171108-1347) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/90a48bebb7f84ca9884ca115fa7ed9c32/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0130.4457.00 ((SQL16_SP1_QFE-CU).171108-1347) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/3daff9d0abe941b08003e61197ce4ede1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0130.4457.00 ((SQL16_SP1_QFE-CU).171108-1347) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/9bb39bd5bd404d9b8693d476a4976c381/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0130.4457.00 ((SQL16_SP1_QFE-CU).171108-1347) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/b76a518cfcad45f5bc36600f200d8df51/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0130.4457.00 ((SQL16_SP1_QFE-CU).171108-1347) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/5028c6a5a3bf40fb893b7034820c6ea81/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0130.4457.00 ((SQL16_SP1_QFE-CU).171108-1347) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/853cc6b85b6049bb8e28d35007644cf22/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0130.4457.00 ((SQL16_SP1_QFE-CU).171108-1347) +``` + +# SQL Server 2016 SP1 CU5 - 13.0.4451.0 - x64 (KB4040714) +``` powershell +# SQL Server 2016 SP1 CU5 - 13.0.4451.0 - x64 (KB4040714) +$outputFolder = 'c:\sqlsyms\13.0.4451.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/0adf0efaa0674d52b42ede2653b2bc792/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0130.4451.00 ((SQL16_SP1_QFE-CU).170905-1437) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/9c9bc2d7227d4a44826cc162dc9364782/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0130.4451.00 ((SQL16_SP1_QFE-CU).170905-1437) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/00a5c9de969c45918756df4cfd8c6f682/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0130.4451.00 ((SQL16_SP1_QFE-CU).170905-1437) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/01e048da3e0c4ca4bdf473066c7cf6c62/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0130.4451.00 ((SQL16_SP1_QFE-CU).170905-1437) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/bc8c89cf69be4fd3a3364dcb0a72dca52/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0130.4451.00 ((SQL16_SP1_QFE-CU).170905-1437) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/360009d4947e4ac08be932e3f16b2ccb2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0130.4451.00 ((SQL16_SP1_QFE-CU).170905-1437) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/8a5bedd54909459eb41b76521723683b1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0130.4451.00 ((SQL16_SP1_QFE-CU).170905-1437) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/57c8fa0d82c643d290ab9530b788e4d42/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0130.4451.00 ((SQL16_SP1_QFE-CU).170905-1437) +``` + +# SQL Server 2016 SP1 CU4 - 13.0.4446.0 - x64 (KB4024305) +``` powershell +# SQL Server 2016 SP1 CU4 - 13.0.4446.0 - x64 (KB4024305) +$outputFolder = 'c:\sqlsyms\13.0.4446.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/c880090278d9483faab63d7472a628ba2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0130.4446.00 ((SQL16_SP1_QFE-CU).170716-1734) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/ea6d107876b848c990276c5164f78e222/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0130.4446.00 ((SQL16_SP1_QFE-CU).170716-1734) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/d41f27d7505149d2a9d14483961593b92/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0130.4446.00 ((SQL16_SP1_QFE-CU).170716-1734) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/92e8bee376394dcb8a2a52800b39f5092/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0130.4446.00 ((SQL16_SP1_QFE-CU).170716-1734) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/149150e4cdbf4baf80620e32ef97fc012/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0130.4446.00 ((SQL16_SP1_QFE-CU).170716-1734) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/6cd22e703a544fac840bae7b3ab83c132/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0130.4446.00 ((SQL16_SP1_QFE-CU).170716-1734) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/76b434a7b537413da49b849be7bbd2b91/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0130.4446.00 ((SQL16_SP1_QFE-CU).170716-1734) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/eaaa9a9973f6411495bf3d00bb06f8f11/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0130.4446.00 ((SQL16_SP1_QFE-CU).170716-1734) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/b8813f5978cf4a3dba90881436bb77f71/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0130.4446.00 ((SQL16_SP1_QFE-CU).170716-1734) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/0a7f20ebf1024eaf8a1ffd2b239bfa4e1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0130.4446.00 ((SQL16_SP1_QFE-CU).170716-1734) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/eab3cf5200994d3eb10eaa1a884a3ef12/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0130.4446.00 ((SQL16_SP1_QFE-CU).170716-1734) +``` + +# SQL Server 2016 SP1 CU3 - 13.0.4435.0 - x64 (KB4019916) +``` powershell +# SQL Server 2016 SP1 CU3 - 13.0.4435.0 - x64 (KB4019916) +$outputFolder = 'c:\sqlsyms\13.0.4435.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/8fe09624812049058da82aa8f1dd66f22/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0130.4435.00 ((SQL16_SP1_QFE-CU).170427-1707) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/558322e65c7e4b328939747b49d560902/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0130.4435.00 ((SQL16_SP1_QFE-CU).170427-1707) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/470aff4a91ac4921b55a2172551f7bf12/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0130.4435.00 ((SQL16_SP1_QFE-CU).170427-1707) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/3149ea1cf3e144a595628fffafeb88fd2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0130.4435.00 ((SQL16_SP1_QFE-CU).170427-1707) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/0d9fe1a60fe342c1a1ce09de7ccdbd2a2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0130.4435.00 ((SQL16_SP1_QFE-CU).170427-1707) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/225b08e74e474943bc4e1122946cbf532/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0130.4435.00 ((SQL16_SP1_QFE-CU).170427-1707) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/de75b23f05c440f9a563565af615e1391/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0130.4435.00 ((SQL16_SP1_QFE-CU).170427-1707) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/08b0902123f545b6bbbcd419f6f8cb5b1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0130.4435.00 ((SQL16_SP1_QFE-CU).170427-1707) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/cc9c2fb0544943e48eb8e300255313191/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0130.4435.00 ((SQL16_SP1_QFE-CU).170427-1707) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/320d5955652048e78f2fc910d1eef2d51/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0130.4435.00 ((SQL16_SP1_QFE-CU).170427-1707) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/ded87b2c33dd49fd93d4daed66d9092f2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0130.4435.00 ((SQL16_SP1_QFE-CU).170427-1707) +``` + +# SQL Server 2016 SP1 CU2 - 13.0.4422.0 - x64 (KB4013106) +``` powershell +# SQL Server 2016 SP1 CU2 - 13.0.4422.0 - x64 (KB4013106) +$outputFolder = 'c:\sqlsyms\13.0.4422.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/cb638c12b4674d87ac7357f16e8ad0c32/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0130.4422.00 ((SQL16_SP1_QFE-CU).170306-1319) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/6cf52c50743545e3b6a49ff43d1379152/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0130.4422.00 ((SQL16_SP1_QFE-CU).170306-1319) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/bc808d257868486f8231cded7542228e2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0130.4422.00 ((SQL16_SP1_QFE-CU).170306-1319) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/be2f8736bbab4e6d9dddd5e2ee23c5ce2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0130.4422.00 ((SQL16_SP1_QFE-CU).170306-1319) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/7a42c58c49904f169a5aff489be7369b2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0130.4422.00 ((SQL16_SP1_QFE-CU).170306-1319) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/997d7a6a523843b08a2ae10c5d75534d2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0130.4422.00 ((SQL16_SP1_QFE-CU).170306-1319) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/c2b0f4c16c5a4e509441c8338aa5ec1c1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0130.4422.00 ((SQL16_SP1_QFE-CU).170306-1319) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/28f240977ff44072aa8e8b2a7d60ba641/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0130.4422.00 ((SQL16_SP1_QFE-CU).170306-1319) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/270d0aa365954e83ae7d1df1408d6d9a1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0130.4422.00 ((SQL16_SP1_QFE-CU).170306-1319) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/3b16a7b538974a81bf76596ef78cb3381/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0130.4422.00 ((SQL16_SP1_QFE-CU).170306-1319) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/65b28e59df5346238c2bb00123ee4d2b2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0130.4422.00 ((SQL16_SP1_QFE-CU).170306-1319) +``` + +# SQL Server 2016 SP1 CU1 - 13.0.4411.0 - x64 (KB3208177) +``` powershell +# SQL Server 2016 SP1 CU1 - 13.0.4411.0 - x64 (KB3208177) +$outputFolder = 'c:\sqlsyms\13.0.4411.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/268a89d9ed10413ba41fe54bf2d75b1e2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0130.4411.00 ((SQL16_SP1_QFE-CU).170106-1315) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/c9ead68f28c24061a124762b8351b6f82/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0130.4411.00 ((SQL16_SP1_QFE-CU).170106-1315) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/74b5f464baac4a9484c931946ae5b68f2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0130.4411.00 ((SQL16_SP1_QFE-CU).170106-1315) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/3c313be76f2444939a67caf043f53d7f2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0130.4411.00 ((SQL16_SP1_QFE-CU).170106-1315) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/84c8f12c82c44a1392d6f65ef1a318b52/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0130.4411.00 ((SQL16_SP1_QFE-CU).170106-1315) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/549f12f6d342442cb72a078cabc0b0362/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0130.4411.00 ((SQL16_SP1_QFE-CU).170106-1315) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/e2fa7e5dba454b9b88a2a1d96b467fd01/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0130.4411.00 ((SQL16_SP1_QFE-CU).170106-1315) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/751d83a8390f4faba2ebd6aafac7f1d51/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0130.4411.00 ((SQL16_SP1_QFE-CU).170106-1315) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/1b95571d967d4731b5e72ed855f469111/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0130.4411.00 ((SQL16_SP1_QFE-CU).170106-1315) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/2821e0a9f1074075bdda62de3e7008c61/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0130.4411.00 ((SQL16_SP1_QFE-CU).170106-1315) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/826a7546f2db4f3089d413578a2cdf882/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0130.4411.00 ((SQL16_SP1_QFE-CU).170106-1315) +``` + +# SQL Server 2016 SP1 SP1 - 13.0.4001.0 - x64 (KB3182545) +``` powershell +# SQL Server 2016 SP1 SP1 - 13.0.4001.0 - x64 (KB3182545) +$outputFolder = 'c:\sqlsyms\13.0.4001.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/1d3fa75eb35540e287b2e012d69785df2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0130.4001.00 ((SQL16_PCU_Main).161028-1734) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/d38058f49e7c4d62970677e4315f1f1c2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0130.4001.00 ((SQL16_PCU_Main).161028-1734) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/cb9e5b8e0483423cb122da4ad87534d52/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0130.4001.00 ((SQL16_PCU_Main).161028-1734) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/13cb00e6ed4d46789fadceb55abddfe92/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0130.4001.00 ((SQL16_PCU_Main).161028-1734) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/c6d08b108b154f8b8431f090dbaab1c92/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0130.4001.00 ((SQL16_PCU_Main).161028-1734) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/c1220065fb9e4e61919175ac9792a2bc2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0130.4001.00 ((SQL16_PCU_Main).161028-1734) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/f0fd3061c4be4486b3308828ea99276e1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0130.4001.00 ((SQL16_PCU_Main).161028-1734) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/f53682311a4e427ba43cc7908850cf9d1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0130.4001.00 ((SQL16_PCU_Main).161028-1734) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/f42433ff7c4b4c52b53875da10d4684e1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0130.4001.00 ((SQL16_PCU_Main).161028-1734) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/961e76a609b04a7c935cd8ad827f23381/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0130.4001.00 ((SQL16_PCU_Main).161028-1734) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/e6e24f9a081b42e3b9e22e1f6414b9b22/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0130.4001.00 ((SQL16_PCU_Main).161028-1734) +``` + +# SQL Server 2016 RTM CU9 - 13.0.2216.0 - x64 (KB4037357) +``` powershell +# SQL Server 2016 RTM CU9 - 13.0.2216.0 - x64 (KB4037357) +$outputFolder = 'c:\sqlsyms\13.0.2216.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/2c007938542145638d786ebdc67c1c9b2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0130.2216.00 ((SQL16_RTM_QFE-CU).171109-1343) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/b6c9ba6727b14530bf871a406d0724802/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0130.2216.00 ((SQL16_RTM_QFE-CU).171109-1343) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/477e9070b1e642a9b166ef3b07e1687b2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0130.2216.00 ((SQL16_RTM_QFE-CU).171109-1343) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/8946accd7bb14ec18499ee4c4e5e53812/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0130.2216.00 ((SQL16_RTM_QFE-CU).171109-1343) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/57cbeb8f33464fb69f691482ce8de8d42/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0130.2216.00 ((SQL16_RTM_QFE-CU).171109-1343) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/abd45d29f555480fadf1990a92e34b252/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0130.2216.00 ((SQL16_RTM_QFE-CU).171109-1343) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/ff1fa69bac4f4a6ea28eea880c69588e1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0130.2216.00 ((SQL16_RTM_QFE-CU).171109-1343) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/f56e5624d87b4a708ca9f6667aba68a71/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0130.2216.00 ((SQL16_RTM_QFE-CU).171109-1343) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/1ca1e6c22cb548b296414dc80c64f4ef1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0130.2216.00 ((SQL16_RTM_QFE-CU).171109-1343) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/0842b22e9ff84f00bfb066e5a557d3051/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0130.2216.00 ((SQL16_RTM_QFE-CU).171109-1343) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/e7ba978114ac4b5b9c032b8f1e1be2222/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0130.2216.00 ((SQL16_RTM_QFE-CU).171109-1343) +``` + +# SQL Server 2016 RTM CU8 - 13.0.2213.0 - x64 (KB4040713) +``` powershell +# SQL Server 2016 RTM CU8 - 13.0.2213.0 - x64 (KB4040713) +$outputFolder = 'c:\sqlsyms\13.0.2213.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/7a0af19f84774e599332cd0db1f1278a2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0130.2213.00 ((SQL16_RTM_QFE-CU).170905-1430) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/f70df0f1cf3d45b5988d87fa813fe74b2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0130.2213.00 ((SQL16_RTM_QFE-CU).170905-1430) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/f3809f64b9a8419ea5fa8f35a32197452/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0130.2213.00 ((SQL16_RTM_QFE-CU).170905-1430) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/7faa03153e474bcc9d8205a253de66df2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0130.2213.00 ((SQL16_RTM_QFE-CU).170905-1430) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/96aa656777b0457e9b21ebda6ec38f1e2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0130.2213.00 ((SQL16_RTM_QFE-CU).170905-1430) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/64c55c4c8b894ec191c9a512d64d05932/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0130.2213.00 ((SQL16_RTM_QFE-CU).170905-1430) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/2610adf0ecd04828af0815caf79e19351/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0130.2213.00 ((SQL16_RTM_QFE-CU).170905-1430) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/901b0c2906cb48e99fb09e1e8cbe9e751/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0130.2213.00 ((SQL16_RTM_QFE-CU).170905-1430) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/e47bab9e66704c33be9edb1c3468aee41/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0130.2213.00 ((SQL16_RTM_QFE-CU).170905-1430) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/07f0e5afd4634724b92cd6d5ac50fbcc1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0130.2213.00 ((SQL16_RTM_QFE-CU).170905-1430) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/e8186d9274b8415c90bea6dbee62765d2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0130.2213.00 ((SQL16_RTM_QFE-CU).170905-1430) +``` + +# SQL Server 2016 RTM CU6 - 13.0.2204.0 - x64 (KB4019914) +``` powershell +# SQL Server 2016 RTM CU6 - 13.0.2204.0 - x64 (KB4019914) +$outputFolder = 'c:\sqlsyms\13.0.2204.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/cfb9f1f67ed94f2ca6ce13a87b281a912/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0130.2204.00 ((SQL16_RTM_QFE-CU).170420-2326) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/e319d277318a43f7bdbfaf7c09e8ea0d2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0130.2204.00 ((SQL16_RTM_QFE-CU).170420-2326) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/f85c7c7fbcfe4fe2bfde5a9d3faaede92/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0130.2204.00 ((SQL16_RTM_QFE-CU).170420-2326) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/0bbbf57d7cc6413fbdade7dd8e806f682/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0130.2204.00 ((SQL16_RTM_QFE-CU).170420-2326) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/10777de046a746f1b118cfcc17d06c2b2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0130.2204.00 ((SQL16_RTM_QFE-CU).170420-2326) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/0152302a8c624ace9201fe5842e87e012/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0130.2204.00 ((SQL16_RTM_QFE-CU).170420-2326) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/3b988c8fe7f04e3f974a275a0eeeeb0b1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0130.2204.00 ((SQL16_RTM_QFE-CU).170420-2326) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/b7d84e7993fb4451b2cd97adae2171001/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0130.2204.00 ((SQL16_RTM_QFE-CU).170420-2326) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/c6b1fbc9d12d414b906f7be297838d8a1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0130.2204.00 ((SQL16_RTM_QFE-CU).170420-2326) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/788729ffd2354809b96f60469725732e1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0130.2204.00 ((SQL16_RTM_QFE-CU).170420-2326) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/0e8610c36c354d36986910b6ef9f99f12/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0130.2204.00 ((SQL16_RTM_QFE-CU).170420-2326) +``` + +# SQL Server 2016 RTM CU4 - 13.0.2193.0 - x64 (KB3205052) +``` powershell +# SQL Server 2016 RTM CU4 - 13.0.2193.0 - x64 (KB3205052) +$outputFolder = 'c:\sqlsyms\13.0.2193.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/29fff1570c614d079dd399bb465245ba2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0130.2193.00 ((SQL16_RTM_QFE-CU).170106-1104) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/51387eb8f90f4726aa9df7dd8a937c432/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0130.2193.00 ((SQL16_RTM_QFE-CU).170106-1104) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/bf13531c7d694d729c441c09b114ba5a2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0130.2193.00 ((SQL16_RTM_QFE-CU).170106-1104) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/37c497fe00574995b2275c82bd5448222/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0130.2193.00 ((SQL16_RTM_QFE-CU).170106-1104) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/db92e29b6d7a40a8b447c044382186f52/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0130.2193.00 ((SQL16_RTM_QFE-CU).170106-1104) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/c564d1d1af464ec4b23625bc349021e82/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0130.2193.00 ((SQL16_RTM_QFE-CU).170106-1104) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/d83d9a08a6304475973f8c1527e9a18b1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0130.2193.00 ((SQL16_RTM_QFE-CU).170106-1104) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/c9179764a88745b6b27d0340adfe00da1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0130.2193.00 ((SQL16_RTM_QFE-CU).170106-1104) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/0a6f9df489884c5aae89b04a707f77991/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0130.2193.00 ((SQL16_RTM_QFE-CU).170106-1104) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/db44013b2c72466ea3f22c14bdedc55f1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0130.2193.00 ((SQL16_RTM_QFE-CU).170106-1104) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/0e65448c6e524b05b5e23432481867792/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0130.2193.00 ((SQL16_RTM_QFE-CU).170106-1104) +``` + +# SQL Server 2016 RTM CU3 - 13.0.2186.6 - x64 (KB3205413) +``` powershell +# SQL Server 2016 RTM CU3 - 13.0.2186.6 - x64 (KB3205413) +$outputFolder = 'c:\sqlsyms\13.0.2186.6\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/2ff2ffcd1aec4430a320031a5b39932a2/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0130.2186.06 ((SQL16_RTM_QFE-CU).161031-1738) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/7a54654444b3498ea417d266f13be4852/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0130.2186.06 ((SQL16_RTM_QFE-CU).161031-1738) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/9554edfa9c98497691f273323bcb95cc2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0130.2186.06 ((SQL16_RTM_QFE-CU).161031-1738) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/c8625b8816e14ab5b1ff2831407f971f2/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0130.2186.06 ((SQL16_RTM_QFE-CU).161031-1738) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/3293fd4acafd48539b54f36145afa5a62/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0130.2186.06 ((SQL16_RTM_QFE-CU).161031-1738) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/2581ec9c9a2d477fb3e3b1d87b7a7db42/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0130.2186.06 ((SQL16_RTM_QFE-CU).161031-1738) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/dcb6d2efe1284ce697e4291b198fccce1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0130.2186.06 ((SQL16_RTM_QFE-CU).161031-1738) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/38d5d0c4e3e94a128f0e8e61535485481/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0130.2186.06 ((SQL16_RTM_QFE-CU).161031-1738) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/f198f8dfc2304e189df71ef4b47851fb1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0130.2186.06 ((SQL16_RTM_QFE-CU).161031-1738) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/9535038ce47847eca6d1a33db6a7497b1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0130.2186.06 ((SQL16_RTM_QFE-CU).161031-1738) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/f4a805d2b05c4cf0ac5538e5c9d3ef122/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0130.2186.06 ((SQL16_RTM_QFE-CU).161031-1738) +``` + +# SQL Server 2016 RTM CU2 - 13.0.2164.0 - x64 (KB3182270) +``` powershell +# SQL Server 2016 RTM CU2 - 13.0.2164.0 - x64 (KB3182270) +$outputFolder = 'c:\sqlsyms\13.0.2164.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/940eac419c934059b710be37641e39112/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0130.2164.00 ((SQL16_RTM_QFE-CU).160909-1949) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/61e79d07815549199699608cf3ebd8a22/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0130.2164.00 ((SQL16_RTM_QFE-CU).160909-1949) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/0b0fe3a447d74fec8396a46cbcf4ade42/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0130.2164.00 ((SQL16_RTM_QFE-CU).160909-1949) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/7aee76c9772241c4abab13ba1d825bc02/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0130.2164.00 ((SQL16_RTM_QFE-CU).160909-1949) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/fc8265399db44d05bb66cf0c53d3a9132/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0130.2164.00 ((SQL16_RTM_QFE-CU).160909-1949) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/43431b47b3c242f2a76e2d5ca301d0372/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0130.2164.00 ((SQL16_RTM_QFE-CU).160909-1949) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/956fcfce5bc348a9abe7db682dc7a85e1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0130.2164.00 ((SQL16_RTM_QFE-CU).160909-1949) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/6dc828b4ac564e199c26106da4394a591/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0130.2164.00 ((SQL16_RTM_QFE-CU).160909-1949) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/6e06587843f44870abfb873c263bdd581/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0130.2164.00 ((SQL16_RTM_QFE-CU).160909-1949) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/3717f27071594c5e976040c9e18032df1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0130.2164.00 ((SQL16_RTM_QFE-CU).160909-1949) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/8c33d4ecd80a4de683073c4e36fe87242/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0130.2164.00 ((SQL16_RTM_QFE-CU).160909-1949) +``` + +# SQL Server 2016 RTM CU1 - 13.0.2149.0 - x64 (KB3164674) +``` powershell +# SQL Server 2016 RTM CU1 - 13.0.2149.0 - x64 (KB3164674) +$outputFolder = 'c:\sqlsyms\13.0.2149.0\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\sqldk.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqldk.pdb/175d1d9f3e3f4aa5b25e8defb354e9282/sqldk.pdb' -OutFile "$outputFolder\sqldk.pdb" } # File version 2015.0130.2149.00 ((SQL16_RTM_QFE-CU).160711-2134) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/c887519f85984f93a45d804fbd9efa7c2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2015.0130.2149.00 ((SQL16_RTM_QFE-CU).160711-2134) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/52a90f506b934a63bee7f9acb3ecbd592/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2015.0130.2149.00 ((SQL16_RTM_QFE-CU).160711-2134) +if (-not (Test-Path "$outputFolder\sqltses.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqltses.pdb/9285360a585b4659a9178b94d54195e52/sqltses.pdb' -OutFile "$outputFolder\sqltses.pdb" } # File version 2015.0130.2149.00 ((SQL16_RTM_QFE-CU).160711-2134) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/431d7cd65d56492084619a4f2be7de342/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2015.0130.2149.00 ((SQL16_RTM_QFE-CU).160711-2134) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/a4c480d343034344a88ac1b39f672b152/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2015.0130.2149.00 ((SQL16_RTM_QFE-CU).160711-2134) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/501ffaaba03a405c942a3636f744d86f1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2015.0130.2149.00 ((SQL16_RTM_QFE-CU).160711-2134) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/df614cefd0a64503b3f9a8b8e28d62ab1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2015.0130.2149.00 ((SQL16_RTM_QFE-CU).160711-2134) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/7f75cde05cd84c74b27b97fde6200cf21/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2015.0130.2149.00 ((SQL16_RTM_QFE-CU).160711-2134) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/986ce3d6b4334bacb5c924134d2883971/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2015.0130.2149.00 ((SQL16_RTM_QFE-CU).160711-2134) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/d67b0283c81c4a93b4d4ede2af0cec522/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2015.0130.2149.00 ((SQL16_RTM_QFE-CU).160711-2134) +``` + diff --git a/Errors/PDB/SQL-Server-2017.md b/Errors/PDB/SQL-Server-2017.md new file mode 100644 index 00000000..2eac5632 --- /dev/null +++ b/Errors/PDB/SQL-Server-2017.md @@ -0,0 +1,522 @@ +# SQL Server 2017 RTM CU21 - 14.0.3335.7 - x64 (KB4557397) +``` powershell +# SQL Server 2017 RTM CU21 - 14.0.3335.7 - x64 (KB4557397) +$outputFolder = 'c:\sqlsyms\14.0.3335.7\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/eb5a565f1039423ab57f1b0c07f2cf062/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3335.07 ((SQL17_RTM_QFE-CU).200613-0316) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/a95c4feb63e24e859cc3ea84c66738362/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3335.07 ((SQL17_RTM_QFE-CU).200613-0316) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/15abf4bc294f43439f8d26bcc081b7852/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3335.07 ((SQL17_RTM_QFE-CU).200613-0316) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/0b714c2255d248be8e2772ed2614c3252/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3335.07 ((SQL17_RTM_QFE-CU).200613-0316) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/cfa406dc3e6f44fbaecf3bb7bfef85403/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3335.07 ((SQL17_RTM_QFE-CU).200613-0316) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/74e2955f444d4a999afc17aebfc101b62/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3335.07 ((SQL17_RTM_QFE-CU).200613-0316) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/e2a53588492542619e2df6eb2f15fbd81/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3335.07 ((SQL17_RTM_QFE-CU).200613-0316) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/0611eac031eb43e1ba9b7df173a4baaf1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3335.07 ((SQL17_RTM_QFE-CU).200613-0316) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/bee1e0c4ebf047f58848229e8e8080301/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3335.07 ((SQL17_RTM_QFE-CU).200613-0316) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/0f83d02887a64bb38055cec85d9816351/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3335.07 ((SQL17_RTM_QFE-CU).200613-0316) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/ebf1bd99202241e49994b70abd89b06c2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3335.07 ((SQL17_RTM_QFE-CU).200613-0316) +``` + +# SQL Server 2017 RTM CU20 - 14.0.3294.2 - x64 (KB4541283) +``` powershell +# SQL Server 2017 RTM CU20 - 14.0.3294.2 - x64 (KB4541283) +$outputFolder = 'c:\sqlsyms\14.0.3294.2\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/bee1fad8fac344258a08781c73e86ed52/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3294.02 ((SQL17_RTM_QFE-CU).200313-2113) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/2a5c5b4ca34b4406b4458d69ac3e4cae2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3294.02 ((SQL17_RTM_QFE-CU).200313-2113) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/3875b7d16696416f9301c11cef45b20d2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3294.02 ((SQL17_RTM_QFE-CU).200313-2113) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/b50d619829294819a0b07403e79e9ded2/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3294.02 ((SQL17_RTM_QFE-CU).200313-2113) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/32ca1afe76d247de8ddeb0b8bed119763/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3294.02 ((SQL17_RTM_QFE-CU).200313-2113) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/b33c89a9f1bf48dab0da20e1e1f14b372/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3294.02 ((SQL17_RTM_QFE-CU).200313-2113) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/13f6629965894b1a898d22a6075e9d321/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3294.02 ((SQL17_RTM_QFE-CU).200313-2113) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/c56991f0bbb44efd9550bdb640b930921/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3294.02 ((SQL17_RTM_QFE-CU).200313-2113) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/c57fd569df0c4b71827c8a73da6ff82f1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3294.02 ((SQL17_RTM_QFE-CU).200313-2113) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/120c44132c254546a280305c87974fd41/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3294.02 ((SQL17_RTM_QFE-CU).200313-2113) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/2187f716c3254ca882a146416b6231d92/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3294.02 ((SQL17_RTM_QFE-CU).200313-2113) +``` + +# SQL Server 2017 RTM CU19 - 14.0.3281.6 - x64 (KB4535007) +``` powershell +# SQL Server 2017 RTM CU19 - 14.0.3281.6 - x64 (KB4535007) +$outputFolder = 'c:\sqlsyms\14.0.3281.6\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/77d53ce9ab0d4543b6625be66af453422/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3281.06 ((SQL17_RTM_QFE-CU).200124-0352) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/e19ffa5d57f24259a2a98fdd90289e152/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3281.06 ((SQL17_RTM_QFE-CU).200124-0352) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/f421b91603c34ba99b30746fd8059d772/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3281.06 ((SQL17_RTM_QFE-CU).200124-0352) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/672558a3b8504bb0b1dd7bcd11f9c84a2/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3281.06 ((SQL17_RTM_QFE-CU).200124-0352) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/1e174cf6018a4087be3d9fb563fe1b633/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3281.06 ((SQL17_RTM_QFE-CU).200124-0352) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/971fc73e739647b8998f3a158cdeee4f2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3281.06 ((SQL17_RTM_QFE-CU).200124-0352) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/84c15d654b424537b1947ac49c2bffef1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3281.06 ((SQL17_RTM_QFE-CU).200124-0352) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/b69205eb69a8423dbec803e670916fe51/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3281.06 ((SQL17_RTM_QFE-CU).200124-0352) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/7eec0edeb9f9430c9958d3a06448b6c21/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3281.06 ((SQL17_RTM_QFE-CU).200124-0352) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/2a200d24c4da4a678c4ebe925100e6e41/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3281.06 ((SQL17_RTM_QFE-CU).200124-0352) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/e13e064b30614472be3ba2d950f0a78b2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3281.06 ((SQL17_RTM_QFE-CU).200124-0352) +``` + +# SQL Server 2017 RTM CU18 - 14.0.3257.3 - x64 (KB4527377) +``` powershell +# SQL Server 2017 RTM CU18 - 14.0.3257.3 - x64 (KB4527377) +$outputFolder = 'c:\sqlsyms\14.0.3257.3\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/0cf29846f3c24e78ad6c68ffc23c958b2/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3257.03 ((SQL17_RTM_QFE-CU).191116-0848) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/edc4c7b44f9842f5ba869f71b5d409d72/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3257.03 ((SQL17_RTM_QFE-CU).191116-0848) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/e9b9a716dd8a4c80a1cde404d18ca8142/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3257.03 ((SQL17_RTM_QFE-CU).191116-0848) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/ee0cc71e1a194e49bbb83839ce3b7f342/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3257.03 ((SQL17_RTM_QFE-CU).191116-0848) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/18f1fdf24e1c4a2b8a647f005476ea353/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3257.03 ((SQL17_RTM_QFE-CU).191116-0848) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/92014d8cf1724ba281afe5be39449fce2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3257.03 ((SQL17_RTM_QFE-CU).191116-0848) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/88d125cb6c734230bda07306dc5a44971/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3257.03 ((SQL17_RTM_QFE-CU).191116-0848) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/4f77a328940e448e97c9bb6e817b34c71/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3257.03 ((SQL17_RTM_QFE-CU).191116-0848) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/2572674dae244c15af96c8fb8dbc76891/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3257.03 ((SQL17_RTM_QFE-CU).191116-0848) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/ae6fdf41e3a34796a31096c15ffe09b71/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3257.03 ((SQL17_RTM_QFE-CU).191116-0848) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/46d8ae1b2f884ce8bd9bbf46c2a5a54e2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3257.03 ((SQL17_RTM_QFE-CU).191116-0848) +``` + +# SQL Server 2017 RTM CU17 - 14.0.3238.1 - x64 (KB4515579) +``` powershell +# SQL Server 2017 RTM CU17 - 14.0.3238.1 - x64 (KB4515579) +$outputFolder = 'c:\sqlsyms\14.0.3238.1\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/5e50e02ad0cf43da8949c7caa26c49f92/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3238.01 ((SQLServer2017-CU14).190913-2228) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/fdb5ae5d994745f5b29bd9e5a44cfbac2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3238.01 ((SQLServer2017-CU14).190913-2228) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/c4ff40dd1b834161b04985c7e21556dc2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3238.01 ((SQLServer2017-CU14).190913-2228) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/4bef8588459043f89f045f2cb9956e342/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3238.01 ((SQLServer2017-CU14).190913-2228) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/4bf28ededa384502a61929dae625e0833/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3238.01 ((SQLServer2017-CU14).190913-2228) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/ac756fec0f804ed4b6bc3fecccb7ed152/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3238.01 ((SQLServer2017-CU14).190913-2228) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/2d58e76525314e67b7158d5b971973471/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3238.01 ((SQLServer2017-CU14).190913-2228) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/41ff67e8d1d94d7782771b2ceb7d91461/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3238.01 ((SQLServer2017-CU14).190913-2228) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/3567f1e7bd304700a1315891a9bffcf21/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3238.01 ((SQLServer2017-CU14).190913-2228) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/74418625e16d46dea9c4dabf1f3c97711/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3238.01 ((SQLServer2017-CU14).190913-2228) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/c3a61d285faa4b848c2ad7e7b02c54742/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3238.01 ((SQLServer2017-CU14).190913-2228) +``` + +# SQL Server 2017 RTM CU16 - 14.0.3223.3 - x64 (KB4508218) +``` powershell +# SQL Server 2017 RTM CU16 - 14.0.3223.3 - x64 (KB4508218) +$outputFolder = 'c:\sqlsyms\14.0.3223.3\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/cc2cb01a74b84342bad196721c4b229a2/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3223.03 ((SQLServer2017-CU14).190712-2335) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/b6830a8a29e746f7a9e334bbc16f73cd2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3223.03 ((SQLServer2017-CU14).190712-2335) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/d4be23dadfa94b4eaedf98e747a35f7a2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3223.03 ((SQLServer2017-CU14).190712-2335) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/60134c9480e24546b6dfcfa95981db792/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3223.03 ((SQLServer2017-CU14).190712-2335) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/942175c9b9254c3a8143db7613f4720e3/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3223.03 ((SQLServer2017-CU14).190712-2335) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/3d22f9effe75470b9cb73b22e30ee0042/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3223.03 ((SQLServer2017-CU14).190712-2335) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/d172da872f4f42faa859e1e262d8f1fe1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3223.03 ((SQLServer2017-CU14).190712-2335) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/2945c675b7f4457892e17485e328b6e11/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3223.03 ((SQLServer2017-CU14).190712-2335) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/05671d5db5a04a3e87f616b6a172e64e1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3223.03 ((SQLServer2017-CU14).190712-2335) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/3ba3e96155514539bf263e91196a59591/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3223.03 ((SQLServer2017-CU14).190712-2335) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/238777599d2342ada234a90d46ae10cd2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3223.03 ((SQLServer2017-CU14).190712-2335) +``` + +# SQL Server 2017 RTM CU15+GDR - 14.0.3192.2 - x64 (KB4505225) +``` powershell +# SQL Server 2017 RTM CU15+GDR - 14.0.3192.2 - x64 (KB4505225) +$outputFolder = 'c:\sqlsyms\14.0.3192.2\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/122fc135abf24465ba9e6be0a6274eb32/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3192.02 ((SQLServer2017-CU14).190615-0703) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/207221dfd01a4ecda2e45a5be4afa8342/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3192.02 ((SQLServer2017-CU14).190615-0703) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/7f9c184f5b2944cc8c1bdba07670f8412/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3192.02 ((SQLServer2017-CU14).190615-0703) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/9559bc0f3b5e4cef8a84ce08601fe3df2/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3192.02 ((SQLServer2017-CU14).190615-0703) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/24b12b3f43be4a27a4139c39849ef5e33/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3192.02 ((SQLServer2017-CU14).190615-0703) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/efd30261c88042a2a49e19b21f90ef002/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3192.02 ((SQLServer2017-CU14).190615-0703) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/cb6a1cd50b654d0a8474f4ed74255e6c1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3192.02 ((SQLServer2017-CU14).190615-0703) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/139c16954bd04111a21c3d8e834e5ea41/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3192.02 ((SQLServer2017-CU14).190615-0703) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/e0243d6070c94969a2aabfc1c32fb0a61/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3192.02 ((SQLServer2017-CU14).190615-0703) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/439bff18122840658f0e9240ffda29301/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3192.02 ((SQLServer2017-CU14).190615-0703) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/107813d2dfe94332aec5cba570dfa4082/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3192.02 ((SQLServer2017-CU14).190615-0703) +``` + +# SQL Server 2017 RTM Hotfix for CU15 - 14.0.3164.1 - x64 (4506633) +``` powershell +# SQL Server 2017 RTM Hotfix for CU15 - 14.0.3164.1 - x64 (4506633) +$outputFolder = 'c:\sqlsyms\14.0.3164.1\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/5f0e68f3162641ad8d035c501c0b697c2/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3164.01 ((SQLServer2017-CU15-OD).190529-2332) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/f90eacadd1904231a7dc6326c4ab53af2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3164.01 ((SQLServer2017-CU15-OD).190529-2332) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/7ef8fc8b0ed04a9f9dc7872b2ddb5bdb2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3164.01 ((SQLServer2017-CU15-OD).190529-2332) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/05f95c5ac74d4eb599b922c69dbc39c12/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3164.01 ((SQLServer2017-CU15-OD).190529-2332) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/6775b239a8fe440ba6bdae93bfcb524c3/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3164.01 ((SQLServer2017-CU15-OD).190529-2332) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/2be30f46dc9c414aa6ec8855811226fa2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3164.01 ((SQLServer2017-CU15-OD).190529-2332) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/6c08af17cbcc4ae6b47b9b000ba2df9f1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3164.01 ((SQLServer2017-CU15-OD).190529-2332) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/1f39d18ce9124de3a8af1fb9bf3b16b21/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3164.01 ((SQLServer2017-CU15-OD).190529-2332) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/beef7d8475d8486bb1acf9603c370d9b1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3164.01 ((SQLServer2017-CU15-OD).190529-2332) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/3c4f56edb20a4d7f903ea7985ee392551/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3164.01 ((SQLServer2017-CU15-OD).190529-2332) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/e5610121ea0b430ba050cfd7de9a55a72/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3164.01 ((SQLServer2017-CU15-OD).190529-2332) +``` + +# SQL Server 2017 RTM CU15 - 14.0.3162.1 - x64 (KB4498951) +``` powershell +# SQL Server 2017 RTM CU15 - 14.0.3162.1 - x64 (KB4498951) +$outputFolder = 'c:\sqlsyms\14.0.3162.1\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/1dfc724617524d0b81e6c9bfe5a3fa922/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3162.01 ((SQLServer2017-CU14).190516-0147) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/5b6770d3a2954ad38fcf61d69b2406f62/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3162.01 ((SQLServer2017-CU14).190516-0147) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/d912ea3687524101b23bc88c89be16062/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3162.01 ((SQLServer2017-CU14).190516-0147) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/7e76c3114d2445fb957c7e2f8d395b722/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3162.01 ((SQLServer2017-CU14).190516-0147) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/f5a9dd15f9e0443cbabb7b93f9d76b233/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3162.01 ((SQLServer2017-CU14).190516-0147) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/e5f4295c75c6451a885b0d60309760772/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3162.01 ((SQLServer2017-CU14).190516-0147) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/ba6e8c729b7f41a7b6863e2c11cd13561/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3162.01 ((SQLServer2017-CU14).190516-0147) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/1b3d232725c54f5dbd6e80715545efad1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3162.01 ((SQLServer2017-CU14).190516-0147) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/67e2b8702fa745f88d74d149c65524b81/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3162.01 ((SQLServer2017-CU14).190516-0147) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/1b81dfc91133481ab49da77d8e57f3c61/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3162.01 ((SQLServer2017-CU14).190516-0147) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/d7da732da1224c3dbbf571c85cdf65532/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3162.01 ((SQLServer2017-CU14).190516-0147) +``` + +# SQL Server 2017 RTM CU14+GDR - 14.0.3103.1 - x64 (KB4494352) +``` powershell +# SQL Server 2017 RTM CU14+GDR - 14.0.3103.1 - x64 (KB4494352) +$outputFolder = 'c:\sqlsyms\14.0.3103.1\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/3d4403b9c1644b51ae4e8518d6ce10852/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3103.01 ((SQLServer2017-CU14).190323-0508) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/dd1cd60ea219405ba26b3549a087d7cd2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3103.01 ((SQLServer2017-CU14).190323-0508) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/d8204dcd590548d0886483894461e2712/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3103.01 ((SQLServer2017-CU14).190323-0508) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/b5b369edbeb54c34929c63aaeef0c56a2/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3103.01 ((SQLServer2017-CU14).190323-0508) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/6e83a97d29fa45dcad8a1531728528103/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3103.01 ((SQLServer2017-CU14).190323-0508) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/201a31638edb45cea8fc7e3089c1b8bb2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3103.01 ((SQLServer2017-CU14).190323-0508) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/ccbb2144f26d47ecb0117313489d42d71/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3103.01 ((SQLServer2017-CU14).190323-0508) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/8e895540bc1b48b1ac1056481e757a001/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3103.01 ((SQLServer2017-CU14).190323-0508) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/02e0af9b69b241f4a9f63962d2f7b3e51/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3103.01 ((SQLServer2017-CU14).190323-0508) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/55a7586e0a684168944bc84d8b3f3a7b1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3103.01 ((SQLServer2017-CU14).190323-0508) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/13efe2857d1f407d8c3eafab072d28812/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3103.01 ((SQLServer2017-CU14).190323-0508) +``` + +# SQL Server 2017 RTM CU14 - 14.0.3076.1 - x64 (KB4484710) +``` powershell +# SQL Server 2017 RTM CU14 - 14.0.3076.1 - x64 (KB4484710) +$outputFolder = 'c:\sqlsyms\14.0.3076.1\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/9dc4b5b9129b4d90aca76c656a8a7cdb2/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3076.01 ((SQLServer2017-CU14).190313-0159) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/12a634d42b0a466fa8892f030ec414cf2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3076.01 ((SQLServer2017-CU14).190313-0159) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/5a0ee5562cf744fe87b6f8f0e66342a62/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3076.01 ((SQLServer2017-CU14).190313-0159) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/a9e9815a726f4f658305f67cbcb7ba432/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3076.01 ((SQLServer2017-CU14).190313-0159) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/7b7b6d8bbf4e4baba8437e4623514f163/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3076.01 ((SQLServer2017-CU14).190313-0159) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/74bda280c8e8462b879a8d1c6684d8b32/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3076.01 ((SQLServer2017-CU14).190313-0159) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/d9b0c3d63a0d48ce80d7ae4e6bd2faae1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3076.01 ((SQLServer2017-CU14).190313-0159) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/fb39d136087c4150905913a5a901dd081/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3076.01 ((SQLServer2017-CU14).190313-0159) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/4a46951e68434ecd93a667401da5c63c1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3076.01 ((SQLServer2017-CU14).190313-0159) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/ed48cfbb0bcb463b8ca48ab657da16221/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3076.01 ((SQLServer2017-CU14).190313-0159) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/8505782dfd8c4d589bb569f27dda72282/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3076.01 ((SQLServer2017-CU14).190313-0159) +``` + +# SQL Server 2017 RTM CU13 - 14.0.3048.4 - x64 (KB4466404) +``` powershell +# SQL Server 2017 RTM CU13 - 14.0.3048.4 - x64 (KB4466404) +$outputFolder = 'c:\sqlsyms\14.0.3048.4\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/db7d37e644684c76aca6244566f04ddb2/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3048.04 ((SQLServer2017-CU13).181130-2004) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/deb451448a184a019d15fbecb4b3dbd42/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3048.04 ((SQLServer2017-CU13).181130-2004) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/154b616962204fc98ab8ba2ac0944fd62/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3048.04 ((SQLServer2017-CU13).181130-2004) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/a8ea1f9fa4a8417b901a2e9c1108cd532/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3048.04 ((SQLServer2017-CU13).181130-2004) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/162006a3c04048a5b3c3bd6db4d37d5c3/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3048.04 ((SQLServer2017-CU13).181130-2004) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/254e81f1cf6d407188805d66c3fc8a002/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3048.04 ((SQLServer2017-CU13).181130-2004) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/6ad53123fe984297bf11178b0f6833b61/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3048.04 ((SQLServer2017-CU13).181130-2004) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/64e83552a4324544b14f7ad910d6dbd31/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3048.04 ((SQLServer2017-CU13).181130-2004) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/2750700543774a219883ff4fd8f9b1c71/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3048.04 ((SQLServer2017-CU13).181130-2004) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/045b89b9000c427aa2d7eb19476ead711/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3048.04 ((SQLServer2017-CU13).181130-2004) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/bb0704a30a134cc8a0436285de13449b2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3048.04 ((SQLServer2017-CU13).181130-2004) +``` + +# SQL Server 2017 RTM CU12 - 14.0.3045.24 - x64 (KB4464082) +``` powershell +# SQL Server 2017 RTM CU12 - 14.0.3045.24 - x64 (KB4464082) +$outputFolder = 'c:\sqlsyms\14.0.3045.24\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/e1a278df9008417880471554645ffe0e2/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3045.24 ((SQLServer2017-CU12).181019-0539) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/0f960e0b699d427db586034ed7b0fdef2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3045.24 ((SQLServer2017-CU12).181019-0539) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/3901620f11594833aa71280f8375f0be2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3045.24 ((SQLServer2017-CU12).181019-0539) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/9cfe911d498646b8ae4f2f50a9d067a42/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3045.24 ((SQLServer2017-CU12).181019-0539) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/27ed7bd2e8a7400e886335247c98a3073/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3045.24 ((SQLServer2017-CU12).181019-0539) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/9ab679cc975b4b1ba1d15706afd6450a2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3045.24 ((SQLServer2017-CU12).181019-0539) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/d2812bf323f14d81a9b099908c9ffff61/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3045.24 ((SQLServer2017-CU12).181019-0539) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/6615c4c7be0c407697ca045825239c131/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3045.24 ((SQLServer2017-CU12).181019-0539) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/196df91bf910437c9fd9acfa2117826f1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3045.24 ((SQLServer2017-CU12).181019-0539) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/6cc447fe65eb4c59aa455ccbf9b251a91/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3045.24 ((SQLServer2017-CU12).181019-0539) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/5cc64f878ee841aab5448338015a5c952/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3045.24 ((SQLServer2017-CU12).181019-0539) +``` + +# SQL Server 2017 RTM CU11 - 14.0.3038.14 - x64 (KB4462262) +``` powershell +# SQL Server 2017 RTM CU11 - 14.0.3038.14 - x64 (KB4462262) +$outputFolder = 'c:\sqlsyms\14.0.3038.14\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/33fb5fb0d73a441090eb718412270dbd2/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3038.14 ((SQLServer2017-CU11).180914-1944) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/c9ed01ded3264172a6a840a1510a9e082/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3038.14 ((SQLServer2017-CU11).180914-1944) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/58093a59f19b4a3398ce13fe13ed92ab2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3038.14 ((SQLServer2017-CU11).180914-1944) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/93188b40fdeb4d9b84f1b0825df6e5402/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3038.14 ((SQLServer2017-CU11).180914-1944) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/652be97b165947e18523339f10380c3e3/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3038.14 ((SQLServer2017-CU11).180914-1944) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/056712b91a6b43a98b8ddb86e19d07832/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3038.14 ((SQLServer2017-CU11).180914-1944) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/767d4249b3b342ccb953f3ff28a3477b1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3038.14 ((SQLServer2017-CU11).180914-1944) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/eec4e581cc1e4e9289b0ff1027f761c21/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3038.14 ((SQLServer2017-CU11).180914-1944) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/95f766b77d5340cf91e4237c1b5cb1d11/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3038.14 ((SQLServer2017-CU11).180914-1944) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/3da659532f314c3d971b21293e4fbf911/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3038.14 ((SQLServer2017-CU11).180914-1944) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/4ecd8c32a3744a72b86f59e40106e58f2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3038.14 ((SQLServer2017-CU11).180914-1944) +``` + +# SQL Server 2017 RTM CU10 - 14.0.3037.1 - x64 (KB4342123) +``` powershell +# SQL Server 2017 RTM CU10 - 14.0.3037.1 - x64 (KB4342123) +$outputFolder = 'c:\sqlsyms\14.0.3037.1\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/bd9f49c63360495684146dfce60449ca2/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3037.01 ((SQLServer2017-CU10).180727-1609) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/a7ac68d2a55042d4b014d983ca4dc5652/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3037.01 ((SQLServer2017-CU10).180727-1609) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/89f5a5f6f6cb46308ee263616e47a1e52/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3037.01 ((SQLServer2017-CU10).180727-1609) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/73b2fdabd985459abcf4b906d49acabe2/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3037.01 ((SQLServer2017-CU10).180727-1609) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/1914abc38f5c4d259a75f0d60f99fb503/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3037.01 ((SQLServer2017-CU10).180727-1609) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/c440983f340f41279499f51c06f0796a2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3037.01 ((SQLServer2017-CU10).180727-1609) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/e67f311e495e452cba574599785f478f1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3037.01 ((SQLServer2017-CU10).180727-1609) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/007f32ffc751482cab8cce28fae4eaae1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3037.01 ((SQLServer2017-CU10).180727-1609) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/d1e4131926fb4197a56f62d1aec4b0891/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3037.01 ((SQLServer2017-CU10).180727-1609) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/04067943d1b14ed58777d6bc6307223c1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3037.01 ((SQLServer2017-CU10).180727-1609) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/7726181ee6a44f1bb557e413279dd4ab2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3037.01 ((SQLServer2017-CU10).180727-1609) +``` + +# SQL Server 2017 RTM CU9 + GDR - 14.0.3035.2 - x64 (KB4293805) +``` powershell +# SQL Server 2017 RTM CU9 + GDR - 14.0.3035.2 - x64 (KB4293805) +$outputFolder = 'c:\sqlsyms\14.0.3035.2\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/2cd60104c58545f8930beb63ebc961542/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3035.02 ((SQLServer2017-CU9-GDR).180707-0051) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/0960eef2f5f74555a6bc0201f30b2dd32/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3035.02 ((SQLServer2017-CU9-GDR).180707-0051) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/c48a041fc73742acb92a2483901e3e232/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3035.02 ((SQLServer2017-CU9-GDR).180707-0051) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/97b1e169ef954a2fa0624d2da36be4712/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3035.02 ((SQLServer2017-CU9-GDR).180707-0051) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/04a742d9881d40f69a5b7d65befc114c3/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3035.02 ((SQLServer2017-CU9-GDR).180707-0051) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/a91a2cb72c0b4147ac810d5c0fb0b1822/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3035.02 ((SQLServer2017-CU9-GDR).180707-0051) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/17e84ac011b740de94a0e096713ed7061/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3035.02 ((SQLServer2017-CU9-GDR).180707-0051) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/89f68be128904de1aa86fcb9815538161/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3035.02 ((SQLServer2017-CU9-GDR).180707-0051) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/f2c0eb19ab6b47609637f59efac0a5c71/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3035.02 ((SQLServer2017-CU9-GDR).180707-0051) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/0f67bd671bda40e7b9498d504d67d9c71/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3035.02 ((SQLServer2017-CU9-GDR).180707-0051) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/2fed6d1f4fc74711a8088b94f98d10062/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3035.02 ((SQLServer2017-CU9-GDR).180707-0051) +``` + +# SQL Server 2017 RTM CU9 - 14.0.3030.27 - x64 (KB4341265) +``` powershell +# SQL Server 2017 RTM CU9 - 14.0.3030.27 - x64 (KB4341265) +$outputFolder = 'c:\sqlsyms\14.0.3030.27\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/66034bb7692f47b68d91508392748a702/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3030.27 ((SQLServer2017-CU9).180630-0026) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/cd0f72d319dd45b48226d59a0a4d1b942/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3030.27 ((SQLServer2017-CU9).180630-0026) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/d62f64ac53a647e4a5be66a50a609f542/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3030.27 ((SQLServer2017-CU9).180630-0026) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/cd65ee0c97594540ac37cf1346fd46072/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3030.27 ((SQLServer2017-CU9).180630-0026) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/20879ea42b6046c6ac042fd5917732433/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3030.27 ((SQLServer2017-CU9).180630-0026) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/ffcd6d3fd4724d65b7f0c3c1dcd3bbbc2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3030.27 ((SQLServer2017-CU9).180630-0026) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/9af640605b0941d9b7934ab9eea3acdd1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3030.27 ((SQLServer2017-CU9).180630-0026) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/31ea27e79fc14bb991e62f4060d7c3a81/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3030.27 ((SQLServer2017-CU9).180630-0026) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/7805edcb819f4e70ab4d14520165787f1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3030.27 ((SQLServer2017-CU9).180630-0026) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/097b87a6547a4e8d87b2f63f8b514e0b1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3030.27 ((SQLServer2017-CU9).180630-0026) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/764a2e690ea84ab3943f336482774e932/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3030.27 ((SQLServer2017-CU9).180630-0026) +``` + +# SQL Server 2017 RTM CU8 - 14.0.3029.16 - x64 (KB4338363) +``` powershell +# SQL Server 2017 RTM CU8 - 14.0.3029.16 - x64 (KB4338363) +$outputFolder = 'c:\sqlsyms\14.0.3029.16\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/5525b238911a499ca15f316ab6c962822/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3029.16 ((SQLServer2017-CU8).180613-1911) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/1399d2afb4264c55b70e45f70f798bf22/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3029.16 ((SQLServer2017-CU8).180613-1911) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/c50bc63f8aee470a99e4662f43e0d0522/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3029.16 ((SQLServer2017-CU8).180613-1911) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/35d0d8eb3c1c437ba654cb78cd4fa1e62/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3029.16 ((SQLServer2017-CU8).180613-1911) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/e2ba4bb806624faa8bbacdae707e61163/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3029.16 ((SQLServer2017-CU8).180613-1911) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/404b3fcd8cc841ccbe0003b3dfb189f02/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3029.16 ((SQLServer2017-CU8).180613-1911) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/281f91e3d7d14f3faaa9992d00ba32991/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3029.16 ((SQLServer2017-CU8).180613-1911) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/28abba31fdde432389c3beb6641c86b61/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3029.16 ((SQLServer2017-CU8).180613-1911) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/10393de02ddd42ae80046a075942ed4b1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3029.16 ((SQLServer2017-CU8).180613-1911) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/3ed5a913bd7f49e4b00d13e1e0d96bd01/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3029.16 ((SQLServer2017-CU8).180613-1911) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/78fd9b633d9d4f15b3fa6cef32db99d72/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3029.16 ((SQLServer2017-CU8).180613-1911) +``` + +# SQL Server 2017 RTM CU7 - 14.0.3026.27 - x64 (KB4229789) +``` powershell +# SQL Server 2017 RTM CU7 - 14.0.3026.27 - x64 (KB4229789) +$outputFolder = 'c:\sqlsyms\14.0.3026.27\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/10da85787e1149a58e60e6c0b2c7a1552/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3026.27 ((SQLServer2017-CU7).180510-1901) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/65dcd0640108491a9e0de5ed8058f1fb2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3026.27 ((SQLServer2017-CU7).180510-1901) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/293ecb04af0f483b898462dba64e945a2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3026.27 ((SQLServer2017-CU7).180510-1901) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/3799cfd261564e5ba73053afe3e0b60c2/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3026.27 ((SQLServer2017-CU7).180510-1901) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/c236c6b5eced44c3a22b1b7779f989d33/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3026.27 ((SQLServer2017-CU7).180510-1901) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/8d9a1bacfae04c508cd2852cfc3d4e912/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3026.27 ((SQLServer2017-CU7).180510-1901) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/6fc5beab5b2b42d9b0575f3e384038f51/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3026.27 ((SQLServer2017-CU7).180510-1901) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/946a419bcbcc44d08c05275adfb3dbc01/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3026.27 ((SQLServer2017-CU7).180510-1901) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/ed1e63b89e7743619a7f541d831943f01/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3026.27 ((SQLServer2017-CU7).180510-1901) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/2747080059f64f4ba2a97a69287d05e51/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3026.27 ((SQLServer2017-CU7).180510-1901) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/37b0126ce3264429b7a3070d9c7ca29d2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3026.27 ((SQLServer2017-CU7).180510-1901) +``` + +# SQL Server 2017 RTM CU6 - 14.0.3025.34 - x64 (KB4101464) +``` powershell +# SQL Server 2017 RTM CU6 - 14.0.3025.34 - x64 (KB4101464) +$outputFolder = 'c:\sqlsyms\14.0.3025.34\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/a98a782c58784e29bbaa2c211b0f5c682/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3025.34 ((SQLServer2017-CU6).180410-0033) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/f24aacbfad9e414285f7046d1d48d2be2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3025.34 ((SQLServer2017-CU6).180410-0033) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/42522ba8c70843a89dd2cbe8af1bb4b32/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3025.34 ((SQLServer2017-CU6).180410-0033) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/b4e8225ee505470da1c3ae7cd8b872e12/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3025.34 ((SQLServer2017-CU6).180410-0033) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/02573056bbd745149600abc3fda59b873/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3025.34 ((SQLServer2017-CU6).180410-0033) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/75e13c8cab1140ff95e0a8be1561e5f52/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3025.34 ((SQLServer2017-CU6).180410-0033) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/e9265ab70bc24f7892140a0c56c8fff71/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3025.34 ((SQLServer2017-CU6).180410-0033) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/0b7a9ff5214245c7935cedb57471d2b71/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3025.34 ((SQLServer2017-CU6).180410-0033) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/99e106f3dc9d4485910ca051be7c7ead1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3025.34 ((SQLServer2017-CU6).180410-0033) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/ebfd29864c4549c48179f4a037ac91271/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3025.34 ((SQLServer2017-CU6).180410-0033) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/ae60023494ff4dd7a992cde1dbedd2d52/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3025.34 ((SQLServer2017-CU6).180410-0033) +``` + +# SQL Server 2017 RTM CU5 - 14.0.3023.8 - x64 (KB4092643) +``` powershell +# SQL Server 2017 RTM CU5 - 14.0.3023.8 - x64 (KB4092643) +$outputFolder = 'c:\sqlsyms\14.0.3023.8\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/109e36e55c01403497cc5d50c579d8532/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3023.08 ((SQLServer2017-CU5).180302-2330) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/bddaac25fb1f426da61e50a94d7fc9ab2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3023.08 ((SQLServer2017-CU5).180302-2330) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/b1507220d6954a02a8b70fc6a55ef15a2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3023.08 ((SQLServer2017-CU5).180302-2330) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/3741e4701fc3405b96394985517ff8a02/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3023.08 ((SQLServer2017-CU5).180302-2330) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/ac8d8709958847f8a0acfc7d842689343/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3023.08 ((SQLServer2017-CU5).180302-2330) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/b32f21bc37674e1b935d03ad80b368f42/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3023.08 ((SQLServer2017-CU5).180302-2330) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/457d193fc3f44383aceee37f22beb4ee1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3023.08 ((SQLServer2017-CU5).180302-2330) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/6051c5232f1b45d7add16da0ffbd40561/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3023.08 ((SQLServer2017-CU5).180302-2330) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/ae5d32ddd37e4201b4deb372cd8eeace1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3023.08 ((SQLServer2017-CU5).180302-2330) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/ab8e5af83878473e9872fa70607103c91/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3023.08 ((SQLServer2017-CU5).180302-2330) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/691d47cd1fe84e27beecb625888885242/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3023.08 ((SQLServer2017-CU5).180302-2330) +``` + +# SQL Server 2017 RTM CU4 - 14.0.3022.28 - x64 (KB4056498) +``` powershell +# SQL Server 2017 RTM CU4 - 14.0.3022.28 - x64 (KB4056498) +$outputFolder = 'c:\sqlsyms\14.0.3022.28\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/57d7c3c8a5d0448e80136b24d0fff1c32/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3022.28 ((SQLServer2017-CU1).180209-2025) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/d579a66e0be244f4933f70d895ea0ca72/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3022.28 ((SQLServer2017-CU1).180209-2025) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/3b96d064c2a7446b8bf27f889a05c5f82/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3022.28 ((SQLServer2017-CU1).180209-2025) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/c0a46b4eda834af696bc62f1f25d2ed12/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3022.28 ((SQLServer2017-CU1).180209-2025) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/98358edb8975452a950cf30afd43dacb3/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3022.28 ((SQLServer2017-CU1).180209-2025) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/d2356ed3f2a54cd39d5b0d6c67c270b02/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3022.28 ((SQLServer2017-CU1).180209-2025) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/374a04e072bc477297ac9c32d1cec4761/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3022.28 ((SQLServer2017-CU1).180209-2025) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/ae215b6a707a4db08bc6442bd43ac11c1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3022.28 ((SQLServer2017-CU1).180209-2025) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/076f3b18167d41edbd98e8898113cad41/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3022.28 ((SQLServer2017-CU1).180209-2025) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/69e152bad2594a2cb66eaeeaa412f1611/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3022.28 ((SQLServer2017-CU1).180209-2025) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/6061b66f34624106bafd4ee77d938d8f2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3022.28 ((SQLServer2017-CU1).180209-2025) +``` + +# SQL Server 2017 RTM CU3 - 14.0.3015.40 - x64 (KB4052987) +``` powershell +# SQL Server 2017 RTM CU3 - 14.0.3015.40 - x64 (KB4052987) +$outputFolder = 'c:\sqlsyms\14.0.3015.40\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/fd63f54995484f9cada261048b448e362/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3015.40 ((SQLServer2017-CU1).171222-2334) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/8e5e48eb780a41c496ec3aff3e0470dd2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3015.40 ((SQLServer2017-CU1).171222-2334) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/b882d062f0ae4f3a826bdae177e2f6ae2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3015.40 ((SQLServer2017-CU1).171222-2334) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/a56fa639b1be44b791f33e70221a74d42/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3015.40 ((SQLServer2017-CU1).171222-2334) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/35e6d755c08b44dea0288b8f4c8be7e33/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3015.40 ((SQLServer2017-CU1).171222-2334) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/a90c29baa7a945e79a5f316c1c016de92/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3015.40 ((SQLServer2017-CU1).171222-2334) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/a1723bbc5db04c588a7c8090f24732931/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3015.40 ((SQLServer2017-CU1).171222-2334) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/84fb90a5783b4d3da9f829e36dd5e4f11/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3015.40 ((SQLServer2017-CU1).171222-2334) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/72cc987076974daead0760fbfc9e06dc1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3015.40 ((SQLServer2017-CU1).171222-2334) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/8041f1f6e7894ae08d6acdd1ed3988d91/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3015.40 ((SQLServer2017-CU1).171222-2334) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/422ffe74342b4124ac700e11127116952/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3015.40 ((SQLServer2017-CU1).171222-2334) +``` + +# SQL Server 2017 RTM CU2 - 14.0.3008.27 - x64 (KB4052574) +``` powershell +# SQL Server 2017 RTM CU2 - 14.0.3008.27 - x64 (KB4052574) +$outputFolder = 'c:\sqlsyms\14.0.3008.27\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/3138403f1ce44cc1969afc40973749f12/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3008.27 ((SQLServer2017-CU1).171116-1722) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/f1a833a2d2c34202b7302121de112bd32/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3008.27 ((SQLServer2017-CU1).171116-1722) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/40d5a1efad844abfa5a689f2e49153e12/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3008.27 ((SQLServer2017-CU1).171116-1722) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/a1dfaae5bf0f4d5691487e1d7ca137fe2/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3008.27 ((SQLServer2017-CU1).171116-1722) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/abc003696f9c4269b13c4e246bd6d10e2/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3008.27 ((SQLServer2017-CU1).171116-1722) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/8d19325e37f34ec5b6f4ebe1ea29978e2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3008.27 ((SQLServer2017-CU1).171116-1722) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/9496aab8e37448c5ad97fde8635a3d201/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3008.27 ((SQLServer2017-CU1).171116-1722) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/d984365873cb4a10a728e6f95b206aef1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3008.27 ((SQLServer2017-CU1).171116-1722) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/5c90a79531e94e37ba58d8993b04e1201/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3008.27 ((SQLServer2017-CU1).171116-1722) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/edcf09de5c5a482991e58e26301562341/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3008.27 ((SQLServer2017-CU1).171116-1722) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/11a2d383108e4e49bac7214a5c4e7c2e2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3008.27 ((SQLServer2017-CU1).171116-1722) +``` + +# SQL Server 2017 RTM CU1 - 14.0.3006.16 - x64 (KB4038634) +``` powershell +# SQL Server 2017 RTM CU1 - 14.0.3006.16 - x64 (KB4038634) +$outputFolder = 'c:\sqlsyms\14.0.3006.16\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/87eba05ec89242d9927509fa7cd4df222/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.3006.16 ((SQLServer2017-CU1).171019-0548) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/e801003d9d0e480aaf2a9961f14722be2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.3006.16 ((SQLServer2017-CU1).171019-0548) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/5eb2d9b1ed7647099675595f5c1af9542/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.3006.16 ((SQLServer2017-CU1).171019-0548) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/dfeb0841aebc48fc92d2ebce8243d6b02/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.3006.16 ((SQLServer2017-CU1).171019-0548) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/133d9c8bada14ea89a11c0c505f8c2412/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.3006.16 ((SQLServer2017-CU1).171019-0548) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/c7ef60b6dc0c4068a48974e6dcf589e42/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.3006.16 ((SQLServer2017-CU1).171019-0548) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/e1feb096228e45b4ad3fd948d10b06f21/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.3006.16 ((SQLServer2017-CU1).171019-0548) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/fc74cd37bd3c40f1a63232f24b9861621/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.3006.16 ((SQLServer2017-CU1).171019-0548) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/88d42585c0844b0493b3383459c778cb1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.3006.16 ((SQLServer2017-CU1).171019-0548) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/85149cd8bce34a5d80e738205084b92a1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.3006.16 ((SQLServer2017-CU1).171019-0548) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/641d7dfd397d4232a6cf7ccc61db3ec32/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.3006.16 ((SQLServer2017-CU1).171019-0548) +``` + +# SQL Server 2017 RTM GDR - 14.0.2014.14 - x64 (KB4494351) +``` powershell +# SQL Server 2017 RTM GDR - 14.0.2014.14 - x64 (KB4494351) +$outputFolder = 'c:\sqlsyms\14.0.2014.14\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/3b83b1a537f04ab3a16e88432d682bcb2/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.2014.14 ((SQL17_RTM_GDR).190405-1545) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/d72fae04d4364d2f9fddc737646f1baa2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.2014.14 ((SQL17_RTM_GDR).190405-1545) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/51b6292d90284698b26fd5785f1470cd2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.2014.14 ((SQL17_RTM_GDR).190405-1545) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/74cac1ac260d4f90b5c2e3d16bd2e1fa2/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.2014.14 ((SQL17_RTM_GDR).190405-1545) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/bf2dc2594f0045b287cf32f04ea6dc033/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.2014.14 ((SQL17_RTM_GDR).190405-1545) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/1f4bea33f4a44fcbbb2ed8b1b636dc442/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.2014.14 ((SQL17_RTM_GDR).190405-1545) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/962db9f1c6a34d7bb306a6b5a9eb43821/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.2014.14 ((SQL17_RTM_GDR).190405-1545) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/20bb3d988bee43fa8b73251c97892d9b1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.2014.14 ((SQL17_RTM_GDR).190405-1545) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/1cab94f0f12f4c0dafd50eaf20df7ae51/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.2014.14 ((SQL17_RTM_GDR).190405-1545) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/a54634c716264671ad9b42292c6d6c751/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.2014.14 ((SQL17_RTM_GDR).190405-1545) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/408c96c6da754a7f9ea16fd4e961910c2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.2014.14 ((SQL17_RTM_GDR).190405-1545) +``` + +# SQL Server 2017 RTM GDR - 14.0.2002.14 - x64 (KB4293803) +``` powershell +# SQL Server 2017 RTM GDR - 14.0.2002.14 - x64 (KB4293803) +$outputFolder = 'c:\sqlsyms\14.0.2002.14\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/eede151a1fe14c888e12bd2cd18499342/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.2002.14 ((SQL17_RTM_GDR).180721-1410) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/1365eb638bb547fb8dda02460ccb1db32/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.2002.14 ((SQL17_RTM_GDR).180721-1410) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/3d765ec46087444a99857a8850ed91612/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.2002.14 ((SQL17_RTM_GDR).180721-1410) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/59c28b768a1a468d9a1d7c9e3e86c8792/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.2002.14 ((SQL17_RTM_GDR).180721-1410) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/c51ed42364994190bde46cadad32bfcc3/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.2002.14 ((SQL17_RTM_GDR).180721-1410) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/67fa8e005f9e4dd5aa0f1eecd911e9fd2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.2002.14 ((SQL17_RTM_GDR).180721-1410) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/0f1a7721cd8e47319fec23bdc5ec7b911/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.2002.14 ((SQL17_RTM_GDR).180721-1410) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/3ae9ebe14179453fa16c7790e4468c0a1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.2002.14 ((SQL17_RTM_GDR).180721-1410) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/1986c63f87fd4b93aecba08c176afb911/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.2002.14 ((SQL17_RTM_GDR).180721-1410) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/5b3e2b01fca64473b86112687e9633b51/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.2002.14 ((SQL17_RTM_GDR).180721-1410) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/c11351f7ec7643bfa04d930c29d6d4872/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.2002.14 ((SQL17_RTM_GDR).180721-1410) +``` + +# SQL Server 2017 RTM GDR - 14.0.2000.63 - x64 (KB4057122) +``` powershell +# SQL Server 2017 RTM GDR - 14.0.2000.63 - x64 (KB4057122) +$outputFolder = 'c:\sqlsyms\14.0.2000.63\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/48cf4690e5f34376afb5a53a8f8ab45d2/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.2000.63 ((SQL17_RTM_GDR).171222-2325) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/efc35e061a2a4daf97ee2bac1f6a96302/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.2000.63 ((SQL17_RTM_GDR).171222-2325) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/59f051256d4743af8f758d0645475b962/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.2000.63 ((SQL17_RTM_GDR).171222-2325) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/5e35faefffe6499b9489c56f061d804e2/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.2000.63 ((SQL17_RTM_GDR).171222-2325) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/989ba51ed4984d1e8df0b1653ecaf3fc3/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.2000.63 ((SQL17_RTM_GDR).171222-2325) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/20e66bce4c7f42f5837a7e65b84e7a742/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.2000.63 ((SQL17_RTM_GDR).171222-2325) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/db011824808740f7b2bdc935fde6ea301/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.2000.63 ((SQL17_RTM_GDR).171222-2325) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/77a3acda141547c1a6c80fdd4417d3651/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.2000.63 ((SQL17_RTM_GDR).171222-2325) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/177b8b95f7254a86a9eb266863bccfb01/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.2000.63 ((SQL17_RTM_GDR).171222-2325) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/77e3bb72b6cb4714aafd8f36cfceccfe1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.2000.63 ((SQL17_RTM_GDR).171222-2325) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/4b38c81bae244806938fe19e14dfbf2e2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.2000.63 ((SQL17_RTM_GDR).171222-2325) +``` + +# SQL Server 2017 RTM RTM - 14.0.1000.169 - x64 (NA) +``` powershell +# SQL Server 2017 RTM RTM - 14.0.1000.169 - x64 (NA) +$outputFolder = 'c:\sqlsyms\14.0.1000.169\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/3cbcf6039e774ef7b3216ad46ed66e162/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2017.0140.1000.169 ((SQLServer).170822-2340) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/f188529c1026441ea07ad838452c34832/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2017.0140.1000.169 ((SQLServer).170822-2340) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/a93a74f3276b4f14a8a57d6b42bf8ae22/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2017.0140.1000.169 ((SQLServer).170822-2340) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/e0a351d14abe45afbaef64d1f88cc9fa2/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2017.0140.1000.169 ((SQLServer).170822-2340) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/7db97580232143a99f64077925f11a9d3/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2017.0140.1000.169 ((SQLServer).170822-2340) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/7be72e22126e41a0ba4a1589d22db4ef2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2017.0140.1000.169 ((SQLServer).170822-2340) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/a042792795f74ae093210433b2ef4f5c1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2017.0140.1000.169 ((SQLServer).170822-2340) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/79032174ef0b4f9eac01826df8f5334f1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2017.0140.1000.169 ((SQLServer).170822-2340) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/2cf7210d69f34a5484c0aa7010921c501/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2017.0140.1000.169 ((SQLServer).170822-2340) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/e1b7563a29b445e6aec1dc8739824fa61/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2017.0140.1000.169 ((SQLServer).170822-2340) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/2270ab48523147ce8c3aa44993fb31bb2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2017.0140.1000.169 ((SQLServer).170822-2340) +``` + diff --git a/Errors/PDB/SQL-Server-2019.md b/Errors/PDB/SQL-Server-2019.md new file mode 100644 index 00000000..697afc15 --- /dev/null +++ b/Errors/PDB/SQL-Server-2019.md @@ -0,0 +1,306 @@ +# SQL Server 2019 RTM CU5 - 15.0.4043.16 - x64 (KB4552255) +``` powershell +# SQL Server 2019 RTM CU5 - 15.0.4043.16 - x64 (KB4552255) +$outputFolder = 'c:\sqlsyms\15.0.4043.16\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/26dc3c5c64d84fbe9858e9751952614b2/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2019.0150.4043.16 ((SQLServer2019-CU5).200611-0058) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/b7ecc728f4d145db8216e57082798f7f2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2019.0150.4043.16 ((SQLServer2019-CU5).200611-0058) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/e0e08efa82cf49839524d699fcbfcdd32/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2019.0150.4043.16 ((SQLServer2019-CU5).200611-0058) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/fb3bc1d1ea3b445e8b2d8f82af2c83082/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2019.0150.4043.16 ((SQLServer2019-CU5).200611-0058) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/2250bc823b6d45d78bbb1526118d5bcd1/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2019.0150.4043.16 ((SQLServer2019-CU5).200611-0058) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/f15f1bb425e345fbbbf9052dfff3009f2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2019.0150.4043.16 ((SQLServer2019-CU5).200611-0058) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/7119961e9948486980ac4126d67f28671/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2019.0150.4043.16 ((SQLServer2019-CU5).200611-0058) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/a5e2854d1d5e4c1b9c354018f78c6ca91/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2019.0150.4043.16 ((SQLServer2019-CU5).200611-0058) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/822326dc5739477b9d02545c442b49911/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2019.0150.4043.16 ((SQLServer2019-CU5).200611-0058) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/5303b7b87c2c4e2789a75900f67989fe1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2019.0150.4043.16 ((SQLServer2019-CU5).200611-0058) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/17641aefa414415686ca0f4ad81a06a12/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2019.0150.4043.16 ((SQLServer2019-CU5).200611-0058) +``` + +# SQL Server 2019 RTM CU4 - 15.0.4033.1 - x64 (KB4548597) +``` powershell +# SQL Server 2019 RTM CU4 - 15.0.4033.1 - x64 (KB4548597) +$outputFolder = 'c:\sqlsyms\15.0.4033.1\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/a17ffc040bf74b9da5f1c2f8bee3b0ae2/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2019.0150.4033.01 ((SQLServer2019-CU4).200314-2237) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/007d639428594ba6b418a4031001af3c2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2019.0150.4033.01 ((SQLServer2019-CU4).200314-2237) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/a0e96c634bcf469ba8d5739a3763b31c2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2019.0150.4033.01 ((SQLServer2019-CU4).200314-2237) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/72be5cf0b1754f7990ac550066c59cf22/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2019.0150.4033.01 ((SQLServer2019-CU4).200314-2237) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/8cf1b3945a3342828669727df4b89a561/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2019.0150.4033.01 ((SQLServer2019-CU4).200314-2237) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/996fcbd6df90470fbf483f5bbc076f022/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2019.0150.4033.01 ((SQLServer2019-CU4).200314-2237) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/5e53ca24d90540b48d0c183348897c011/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2019.0150.4033.01 ((SQLServer2019-CU4).200314-2237) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/caaa30913c3f443fa2971996571662721/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2019.0150.4033.01 ((SQLServer2019-CU4).200314-2237) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/0727c20ffb694b7b966a311ba8a839ed1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2019.0150.4033.01 ((SQLServer2019-CU4).200314-2237) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/46e02f96623c4a3b980d6b915c81586c1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2019.0150.4033.01 ((SQLServer2019-CU4).200314-2237) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/f326b1ebadce4ed7b63721256723d9d12/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2019.0150.4033.01 ((SQLServer2019-CU4).200314-2237) +``` + +# SQL Server 2019 RTM CU3 - 15.0.4023.6 - x64 (KB4538853) +``` powershell +# SQL Server 2019 RTM CU3 - 15.0.4023.6 - x64 (KB4538853) +$outputFolder = 'c:\sqlsyms\15.0.4023.6\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/1f99f28740354638ab808a14641af26a2/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2019.0150.4023.06 ((SQLServer2019-CU3).200304-0805) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/7ec066594c274590ad0e4284ecbb7e7b2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2019.0150.4023.06 ((SQLServer2019-CU3).200304-0805) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/6f5ca7b595704b1a83302a33ae4bc0232/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2019.0150.4023.06 ((SQLServer2019-CU3).200304-0805) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/c5447784964c488cb3ec1370a45ce8a32/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2019.0150.4023.06 ((SQLServer2019-CU3).200304-0805) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/ac8c33e259e74a37be1fba98de2d5dea1/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2019.0150.4023.06 ((SQLServer2019-CU3).200304-0805) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/b82843359f73486ebb55be54a8258a512/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2019.0150.4023.06 ((SQLServer2019-CU3).200304-0805) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/eabcb2cbd8734147826fc8e5fed91d051/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2019.0150.4023.06 ((SQLServer2019-CU3).200304-0805) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/67e76e9883cc408ab61bef65da8566ca1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2019.0150.4023.06 ((SQLServer2019-CU3).200304-0805) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/4aa18ea029164914a8ebca601fb086f31/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2019.0150.4023.06 ((SQLServer2019-CU3).200304-0805) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/24f1b7e3408e46df88b53a0417eff0ec1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2019.0150.4023.06 ((SQLServer2019-CU3).200304-0805) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/e46cc8dbdfc540dda33b7bd994f636782/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2019.0150.4023.06 ((SQLServer2019-CU3).200304-0805) +``` + +# SQL Server 2019 RTM CU2 - 15.0.4013.40 - x64 (KB4536075) +``` powershell +# SQL Server 2019 RTM CU2 - 15.0.4013.40 - x64 (KB4536075) +$outputFolder = 'c:\sqlsyms\15.0.4013.40\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/db2c3b3cd98041eebe71f258bb783cf52/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2019.0150.4013.40 ((SQLServer2019-CU2).200204-0018) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/79cc12f37c694a4cb246d9ff1006f48a2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2019.0150.4013.40 ((SQLServer2019-CU2).200204-0018) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/135a7055bda8408a958cfd365c4a04342/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2019.0150.4013.40 ((SQLServer2019-CU2).200204-0018) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/8d85294d07c14151baa2c1fdcedb3d702/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2019.0150.4013.40 ((SQLServer2019-CU2).200204-0018) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/dc09a9a5bc5d41798cfd16759101bc0f1/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2019.0150.4013.40 ((SQLServer2019-CU2).200204-0018) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/f6fa22f7a94744a3836e2e336677209a2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2019.0150.4013.40 ((SQLServer2019-CU2).200204-0018) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/05c36542b2c44ac2b7e2b6718e4ee9dd1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2019.0150.4013.40 ((SQLServer2019-CU2).200204-0018) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/b2a184d9e3704c63a988ad8a142af4e81/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2019.0150.4013.40 ((SQLServer2019-CU2).200204-0018) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/2d4753074ba64ba193ab702286a752b71/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2019.0150.4013.40 ((SQLServer2019-CU2).200204-0018) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/19e519afd6a34b2ba91458cbf5378e801/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2019.0150.4013.40 ((SQLServer2019-CU2).200204-0018) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/70258a046ea44af38bf97bb73a90df412/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2019.0150.4013.40 ((SQLServer2019-CU2).200204-0018) +``` + +# SQL Server 2019 RTM CU1 - 15.0.4003.23 - x64 (KB4527376) +``` powershell +# SQL Server 2019 RTM CU1 - 15.0.4003.23 - x64 (KB4527376) +$outputFolder = 'c:\sqlsyms\15.0.4003.23\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/1c28d53f4ce34500a0824edf754bb3182/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2019.0150.4003.23 ((SQL19_RTM_QFE-OD).191206-2237) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/725357d7267b4fcb8bed1520f7638ae52/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2019.0150.4003.23 ((SQL19_RTM_QFE-OD).191206-2237) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/872bec978b414b4894b0007d495aff9c2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2019.0150.4003.23 ((SQL19_RTM_QFE-OD).191206-2237) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/c2f014bfeb4148e79fa69e3bdf81fc232/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2019.0150.4003.23 ((SQL19_RTM_QFE-OD).191206-2237) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/9186d8f25f3344849c0afbd8086431c71/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2019.0150.4003.23 ((SQL19_RTM_QFE-OD).191206-2237) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/86c0928cbca241508082e6ae13a7b2ad2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2019.0150.4003.23 ((SQL19_RTM_QFE-OD).191206-2237) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/ddc9bae1e79e4be38aba05b28f20ba481/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2019.0150.4003.23 ((SQL19_RTM_QFE-OD).191206-2237) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/9c7a349dca4a4f8bb2a405e2a36d7b091/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2019.0150.4003.23 ((SQL19_RTM_QFE-OD).191206-2237) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/f19350dff8c54443aee52644b816d1371/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2019.0150.4003.23 ((SQL19_RTM_QFE-OD).191206-2237) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/6c2376ab69404cf89eea336bc33242371/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2019.0150.4003.23 ((SQL19_RTM_QFE-OD).191206-2237) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/db06d320fc1a4f1492e857d7804288672/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2019.0150.4003.23 ((SQL19_RTM_QFE-OD).191206-2237) +``` + +# SQL Server 2019 RTM Servicing Update (GDR1) - 15.0.2070.41 - x64 (KB4517790) +``` powershell +# SQL Server 2019 RTM Servicing Update (GDR1) - 15.0.2070.41 - x64 (KB4517790) +$outputFolder = 'c:\sqlsyms\15.0.2070.41\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/35fa14a3b9874a72a017fadba93e24b12/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2019.0150.2070.41 ((SQLServer).191029-0237) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/1535e7976f0a431baf2704de5f2e5fdc2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2019.0150.2070.41 ((SQLServer).191029-0237) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/9cb9edfe939f4b03b50222c9b39f196c2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2019.0150.2070.41 ((SQLServer).191029-0237) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/bdd5d0345b64423394986dc1a4a37e3d2/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2019.0150.2070.41 ((SQLServer).191029-0237) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/01955e0a0c344aa9ba96522fb1ce96671/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2019.0150.2070.41 ((SQLServer).191029-0237) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/34e92930c4454a74acadc5f504d350f92/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2019.0150.2070.41 ((SQLServer).191029-0237) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/39717e154f0746668714cce86cebc6ba1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2019.0150.2070.41 ((SQLServer).191029-0237) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/e1295a820f7d4cb08ca66421bc0e872c1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2019.0150.2070.41 ((SQLServer).191029-0237) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/30c5297c5e244754a8e799717f9dd69b1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2019.0150.2070.41 ((SQLServer).191029-0237) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/69bd28349a494ebca2c0c0be7230183c1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2019.0150.2070.41 ((SQLServer).191029-0237) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/c0ead5152bae41f69d8dbcb210237a062/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2019.0150.2070.41 ((SQLServer).191029-0237) +``` + +# SQL Server 2019 RTM RTM - 15.0.2000.5 - x64 (Nov 2019) +``` powershell +# SQL Server 2019 RTM RTM - 15.0.2000.5 - x64 (Nov 2019) +$outputFolder = 'c:\sqlsyms\15.0.2000.5\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/a32ecbddb336439994cc1bf8ca5612052/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2019.0150.2000.05 ((SQLServer).190924-2033) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/c451d01cb0d142afb1e497def47bd4b32/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2019.0150.2000.05 ((SQLServer).190924-2033) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/b69375ae56964976a91c384bda088abc2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2019.0150.2000.05 ((SQLServer).190924-2033) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/c111d07e3fe9461cb21655d20b2f13e82/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2019.0150.2000.05 ((SQLServer).190924-2033) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/d3cc4bb1711f45e5bdcbfdc6ce90400e1/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2019.0150.2000.05 ((SQLServer).190924-2033) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/ee3b2b5f10024545bc623c768f8e98c82/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2019.0150.2000.05 ((SQLServer).190924-2033) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/b996f74062ef41f88e762d7cde413ca81/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2019.0150.2000.05 ((SQLServer).190924-2033) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/a5b534efcad44ea4b8951a28847907031/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2019.0150.2000.05 ((SQLServer).190924-2033) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/139725cae1124fd19c7065ca5dd091c01/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2019.0150.2000.05 ((SQLServer).190924-2033) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/6e3e07ad09d6475aae40a87c8483f31e1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2019.0150.2000.05 ((SQLServer).190924-2033) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/55586008647b45f49f51934563c320cb2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2019.0150.2000.05 ((SQLServer).190924-2033) +``` + +# SQL Server 2019 RC RC1 - 15.0.1900.25 - x64 (Aug 2019) +``` powershell +# SQL Server 2019 RC RC1 - 15.0.1900.25 - x64 (Aug 2019) +$outputFolder = 'c:\sqlsyms\15.0.1900.25\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/807730dc54d8486cbb301034d5c8e8d42/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2019.0150.1900.25 ((SQLServer).190816-2101) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/df94c4b01e8b47a7aab9cc2c24b425bb2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2019.0150.1900.25 ((SQLServer).190816-2101) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/176f91f058de40ca94e15eda8da9cc382/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2019.0150.1900.25 ((SQLServer).190816-2101) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/a3397ad3fbbd424eb40829ec9875fc832/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2019.0150.1900.25 ((SQLServer).190816-2101) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/7c43dc13a0244c34a87633c0b3bdf9851/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2019.0150.1900.25 ((SQLServer).190816-2101) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/e2f9e096f96e4860b8ba44cf4cc5a0a72/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2019.0150.1900.25 ((SQLServer).190816-2101) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/ca9b35071e0143df9136f86359a5ac471/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2019.0150.1900.25 ((SQLServer).190816-2101) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/a11cc82202ff404a9241a178f6c5c5eb1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2019.0150.1900.25 ((SQLServer).190816-2101) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/bdfab5fc03914efc839596e3476487e51/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2019.0150.1900.25 ((SQLServer).190816-2101) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/ebd4a16987eb4c8198107eca6471f4af1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2019.0150.1900.25 ((SQLServer).190816-2101) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/8f08dd3bcf934ea8933e21473ded4a042/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2019.0150.1900.25 ((SQLServer).190816-2101) +``` + +# SQL Server 2019 CTP CTP 3.2 - 15.0.1800.32 - x64 (Jul 2019) +``` powershell +# SQL Server 2019 CTP CTP 3.2 - 15.0.1800.32 - x64 (Jul 2019) +$outputFolder = 'c:\sqlsyms\15.0.1800.32\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/9c623f4336c24e489fd8dd3998f34cc02/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2019.0150.1800.32 ((SQLServer).190718-0401) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/e705bad3292c47e4b4d6963b8e559a1d2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2019.0150.1800.32 ((SQLServer).190718-0401) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/7a2bc2e75f4f4bc4ae68bbb4952c30642/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2019.0150.1800.32 ((SQLServer).190718-0401) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/9f16df7c1680418d83a375eb42883a312/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2019.0150.1800.32 ((SQLServer).190718-0401) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/85d769fd63df4a07b0bd03e683b3ac8e1/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2019.0150.1800.32 ((SQLServer).190718-0401) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/fa2ccd5225de4ff3a33d2f28ddb69ec22/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2019.0150.1800.32 ((SQLServer).190718-0401) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/1c3a00d0fa0a41d89e8f0b5ba2713f5d1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2019.0150.1800.32 ((SQLServer).190718-0401) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/886259b54c1246ff9884f355af67f1201/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2019.0150.1800.32 ((SQLServer).190718-0401) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/87b8448051c848149b5beb098d4880841/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2019.0150.1800.32 ((SQLServer).190718-0401) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/434635bff10945e8bb07c9f25339e75e1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2019.0150.1800.32 ((SQLServer).190718-0401) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/22541fc9a9034693b17da8546301e3bb2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2019.0150.1800.32 ((SQLServer).190718-0401) +``` + +# SQL Server 2019 CTP CTP3.1 - 15.0.1700.37 - x64 (Jun 2019) +``` powershell +# SQL Server 2019 CTP CTP3.1 - 15.0.1700.37 - x64 (Jun 2019) +$outputFolder = 'c:\sqlsyms\15.0.1700.37\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/9e557f85f9224d708abf2f557c7456e62/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2019.0150.1700.37 ((SQLServer).190619-1757) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/9af9b26e3fea49f1bd5b5367174bd9242/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2019.0150.1700.37 ((SQLServer).190619-1757) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/a6090023473742aa8f5c2fe198274cfe2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2019.0150.1700.37 ((SQLServer).190619-1757) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/e7708ef60f1d406f8bf6b05117dd8d962/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2019.0150.1700.37 ((SQLServer).190619-1757) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/12aa7d212fb14305bb582a9d0156079c1/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2019.0150.1700.37 ((SQLServer).190619-1757) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/60706aa038aa4e84901a0eb75c660d452/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2019.0150.1700.37 ((SQLServer).190619-1757) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/6b687fb2adab4f49b13169f0f6a6b1261/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2019.0150.1700.37 ((SQLServer).190619-1757) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/b96e03193f454e32a634e57ec66cb2dc1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2019.0150.1700.37 ((SQLServer).190619-1757) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/6b65fc282cf944fa9f3facf18303fa2e1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2019.0150.1700.37 ((SQLServer).190619-1757) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/0eed3325fb7f4ee085f479e484f5bfa81/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2019.0150.1700.37 ((SQLServer).190619-1757) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/51dbb121d73f4dbaa4640507a7558ecc2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2019.0150.1700.37 ((SQLServer).190619-1757) +``` + +# SQL Server 2019 CTP CTP3.0 - 15.0.1600.8 - x64 (May 2019) +``` powershell +# SQL Server 2019 CTP CTP3.0 - 15.0.1600.8 - x64 (May 2019) +$outputFolder = 'c:\sqlsyms\15.0.1600.8\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/8be214152c184afcaa324365f9c1a3b52/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2019.0150.1600.08 ((SQLServer).190517-0718) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/6bf39a278a27415e9aabfdb240d9ca612/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2019.0150.1600.08 ((SQLServer).190517-0718) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/c3e953f7f5704ce69b8ca62fbc62656b2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2019.0150.1600.08 ((SQLServer).190517-0718) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/8e72849826824e919215135180d284d92/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2019.0150.1600.08 ((SQLServer).190517-0718) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/d0e0e82ed4be4852962c4ac90303107c1/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2019.0150.1600.08 ((SQLServer).190517-0718) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/3986538b627e42b982a5c663fa9751862/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2019.0150.1600.08 ((SQLServer).190517-0718) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/866191ebab104dd38be0a902d87762581/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2019.0150.1600.08 ((SQLServer).190517-0718) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/38304f5776fc4982a96cf4628dcc51941/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2019.0150.1600.08 ((SQLServer).190517-0718) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/3bfcef2ebbba4702af4be06c10c06f861/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2019.0150.1600.08 ((SQLServer).190517-0718) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/25b7cfed794846d8acfed97c702ba2cd1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2019.0150.1600.08 ((SQLServer).190517-0718) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/a0d82d62e01542b9962d6093d402ebf62/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2019.0150.1600.08 ((SQLServer).190517-0718) +``` + +# SQL Server 2019 CTP CTP2.5 - 15.0.1500.28 - x64 (April 2019) +``` powershell +# SQL Server 2019 CTP CTP2.5 - 15.0.1500.28 - x64 (April 2019) +$outputFolder = 'c:\sqlsyms\15.0.1500.28\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/de490193e66048d4b8f93980b36f5cec2/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2019.0150.1500.28 ((SQLServer).190415-2131) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/222c7b12b2d34c709a092e59249e541a2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2019.0150.1500.28 ((SQLServer).190415-2131) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/ae39c1a85f294c068a7510b8c93814432/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2019.0150.1500.28 ((SQLServer).190415-2131) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/6916c4073925451ba18162d2b39980dc2/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2019.0150.1500.28 ((SQLServer).190415-2131) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/1c80ecdf24d44affa414ab37a3a78f6f1/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2019.0150.1500.28 ((SQLServer).190415-2131) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/af19898435d34f4e9f1dcda16e34b98a2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2019.0150.1500.28 ((SQLServer).190415-2131) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/f0f4f38d477a491db3fa7360b91551531/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2019.0150.1500.28 ((SQLServer).190415-2131) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/3f3eafd827f14c60ba3709af3fa2af791/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2019.0150.1500.28 ((SQLServer).190415-2131) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/09127f33dee145fcb2b1828163d986a11/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2019.0150.1500.28 ((SQLServer).190415-2131) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/dc460c45ed50496f9eff9c3fc107f46f1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2019.0150.1500.28 ((SQLServer).190415-2131) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/2fe2f4d6593444dca6294d8694cc01442/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2019.0150.1500.28 ((SQLServer).190415-2131) +``` + +# SQL Server 2019 CTP CTP2.4 - 15.0.1400.75 - x64 (March 2019) +``` powershell +# SQL Server 2019 CTP CTP2.4 - 15.0.1400.75 - x64 (March 2019) +$outputFolder = 'c:\sqlsyms\15.0.1400.75\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/19d870c6afaa43c9b925ace5a6c841d92/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2019.0150.1400.75 ((SQLServer).190316-1802) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/a3a47799b1b64d928b721a14d2caa7252/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2019.0150.1400.75 ((SQLServer).190316-1802) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/14270b62941a4b98bd6c0f4e640ce7182/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2019.0150.1400.75 ((SQLServer).190316-1802) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/7348cf1b0b4a4fe6bd0a8091df4b602a2/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2019.0150.1400.75 ((SQLServer).190316-1802) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/ad38a740f1a54a93b5ad507dcdd9d4d01/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2019.0150.1400.75 ((SQLServer).190316-1802) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/32664240697e4a6a99c56bbaa4b286a32/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2019.0150.1400.75 ((SQLServer).190316-1802) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/a6fad09bf4054c9697c38eb84eae5a801/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2019.0150.1400.75 ((SQLServer).190316-1802) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/70da4b6f6a574d47bba5cc811ec1046a1/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2019.0150.1400.75 ((SQLServer).190316-1802) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/dbd7a18fab2946f8a58c35c6bcdfa13d1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2019.0150.1400.75 ((SQLServer).190316-1802) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/1b74c0360a0e4338a7d92cd8c00cd9d31/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2019.0150.1400.75 ((SQLServer).190316-1802) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/dde99a1492e84ef0926504cfe6afebec2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2019.0150.1400.75 ((SQLServer).190316-1802) +``` + +# SQL Server 2019 CTP CTP2.3 - 15.0.1300.359 - x64 (Feb 2019) +``` powershell +# SQL Server 2019 CTP CTP2.3 - 15.0.1300.359 - x64 (Feb 2019) +$outputFolder = 'c:\sqlsyms\15.0.1300.359\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/8d76a19c14344ec387a897611b8b8b882/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2019.0150.1300.359 ((SQLServer).190216-0730) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/a3f62ef419b64a8c973a24150ba095b22/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2019.0150.1300.359 ((SQLServer).190216-0730) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/66abfc4397dd480f8873349e5edbfd142/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2019.0150.1300.359 ((SQLServer).190216-0730) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/c7ce4847496848b2ae3f24a282f479b12/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2019.0150.1300.359 ((SQLServer).190216-0730) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/a0f649ac82df495ba6a2a8fd818fb1dd1/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2019.0150.1300.359 ((SQLServer).190216-0730) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/33dbea5fbe0143d58286fe47f21605702/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2019.0150.1300.359 ((SQLServer).190216-0730) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/b1b0c9de60a14ec5a04f8f1cd80a75301/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2019.0150.1300.359 ((SQLServer).190216-0730) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/4293b10217714217a630622cb51ca0861/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2019.0150.1300.359 ((SQLServer).190216-0730) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/68bda83b7e99449987e9bdaa25a3abd31/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2019.0150.1300.359 ((SQLServer).190216-0730) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/aff6d1fc049e46028094cb26ee5fb9101/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2019.0150.1300.359 ((SQLServer).190216-0730) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/377253089c3e42168bbd7d13bedb1da52/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2019.0150.1300.359 ((SQLServer).190216-0730) +``` + +# SQL Server 2019 CTP CTP2.2 - 15.0.1200.24 - x64 (Dec 2018) +``` powershell +# SQL Server 2019 CTP CTP2.2 - 15.0.1200.24 - x64 (Dec 2018) +$outputFolder = 'c:\sqlsyms\15.0.1200.24\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/2c606b4367a4429c992d5ca42512c7282/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2018.0150.1200.24 ((SQLServer).181205-2233) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/a67be7179bab4e30bc9e9b2bf0a0259a2/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2018.0150.1200.24 ((SQLServer).181205-2233) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/9a0e2aabffc94c52a0c130ba253fe9712/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2018.0150.1200.24 ((SQLServer).181205-2233) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/d58e802ce7984e098a7cec464a001bee2/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2018.0150.1200.24 ((SQLServer).181205-2233) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/15d57320c04b444bb34709c58a93d1691/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2018.0150.1200.24 ((SQLServer).181205-2233) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/8eb24ab8cb084224b18cdb3aaa075be02/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2018.0150.1200.24 ((SQLServer).181205-2233) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/40669c7f8e7f4d33949b7c590b78ae581/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2018.0150.1200.24 ((SQLServer).181205-2233) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/48d913073c2c404cac8f449c33020ba31/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2018.0150.1200.24 ((SQLServer).181205-2233) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/71c0383ff3d64837baa474cb8fd46d341/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2018.0150.1200.24 ((SQLServer).181205-2233) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/25ac40a4dfb04d8d9e943259156c6eff1/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2018.0150.1200.24 ((SQLServer).181205-2233) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/eef4684b29ec49ada134bf2e5d266c7b2/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2018.0150.1200.24 ((SQLServer).181205-2233) +``` + +# SQL Server 2019 CTP CTP2.1 - 15.0.1100.94 - x64 (Nov 2018) +``` powershell +# SQL Server 2019 CTP CTP2.1 - 15.0.1100.94 - x64 (Nov 2018) +$outputFolder = 'c:\sqlsyms\15.0.1100.94\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/2396a09ad02847069a2932edada5013f2/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2018.0150.1100.94 ((SQLServer).181101-2034) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/2a859b14f55a49b18757dae8a9d431b02/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2018.0150.1100.94 ((SQLServer).181101-2034) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/84f83087a0914973a9378f1bd7391f0a2/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2018.0150.1100.94 ((SQLServer).181101-2034) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/4a0764a16a9f4862a294c68fa70d9e362/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2018.0150.1100.94 ((SQLServer).181101-2034) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/15a322a3311b4663b97cd77c55312efc3/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2018.0150.1100.94 ((SQLServer).181101-2034) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/2c7c552e20814e7cafd031b4a5f55ff82/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2018.0150.1100.94 ((SQLServer).181101-2034) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/1861f31229a24d098ba62005e71ec1ed1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2018.0150.1100.94 ((SQLServer).181101-2034) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/0eefeca4685943f0b57d87091fda67e41/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2018.0150.1100.94 ((SQLServer).181101-2034) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/c9379eab5bab492cbbff0cec75549d6f1/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2018.0150.1100.94 ((SQLServer).181101-2034) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/c8e790ff4bdf41bc976393b733fae5521/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2018.0150.1100.94 ((SQLServer).181101-2034) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/28856cd400a64ae8bdd78eee5d1969a12/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2018.0150.1100.94 ((SQLServer).181101-2034) +``` + +# SQL Server 2019 CTP CTP2.0 - 15.0.1000.34 - x64 (Oct 2018) +``` powershell +# SQL Server 2019 CTP CTP2.0 - 15.0.1000.34 - x64 (Oct 2018) +$outputFolder = 'c:\sqlsyms\15.0.1000.34\x64' # <>' +mkdir -f $outputFolder +if (-not (Test-Path "$outputFolder\SqlDK.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlDK.pdb/1fb52db46791403f80a736a3a2892d872/SqlDK.pdb' -OutFile "$outputFolder\SqlDK.pdb" } # File version 2018.0150.1000.34 ((SQLServer).180918-0824) +if (-not (Test-Path "$outputFolder\sqlmin.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlmin.pdb/dbb1be06cf8f47fab0354ab426dc85b82/sqlmin.pdb' -OutFile "$outputFolder\sqlmin.pdb" } # File version 2018.0150.1000.34 ((SQLServer).180918-0824) +if (-not (Test-Path "$outputFolder\sqllang.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqllang.pdb/e0c87c8653a14fce8988a727a0c113742/sqllang.pdb' -OutFile "$outputFolder\sqllang.pdb" } # File version 2018.0150.1000.34 ((SQLServer).180918-0824) +if (-not (Test-Path "$outputFolder\SqlTsEs.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SqlTsEs.pdb/95328c1d4b7e4c0991b1e3b23d7599132/SqlTsEs.pdb' -OutFile "$outputFolder\SqlTsEs.pdb" } # File version 2018.0150.1000.34 ((SQLServer).180918-0824) +if (-not (Test-Path "$outputFolder\sqlaccess.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlaccess.pdb/d51850bf713a4cd0bd080a52bdbda48d3/sqlaccess.pdb' -OutFile "$outputFolder\sqlaccess.pdb" } # File version 2018.0150.1000.34 ((SQLServer).180918-0824) +if (-not (Test-Path "$outputFolder\qds.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/qds.pdb/b7b40f4370474643b66a0b4f458bfa1e2/qds.pdb' -OutFile "$outputFolder\qds.pdb" } # File version 2018.0150.1000.34 ((SQLServer).180918-0824) +if (-not (Test-Path "$outputFolder\hkruntime.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkruntime.pdb/6b48ecaa4c254d3fb8415b7b48b1addf1/hkruntime.pdb' -OutFile "$outputFolder\hkruntime.pdb" } # File version 2018.0150.1000.34 ((SQLServer).180918-0824) +if (-not (Test-Path "$outputFolder\hkengine.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkengine.pdb/98e6ce276a384a459c3902090bb411e01/hkengine.pdb' -OutFile "$outputFolder\hkengine.pdb" } # File version 2018.0150.1000.34 ((SQLServer).180918-0824) +if (-not (Test-Path "$outputFolder\hkcompile.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/hkcompile.pdb/b3123f07e8a24ff99677f0c0a39ab3461/hkcompile.pdb' -OutFile "$outputFolder\hkcompile.pdb" } # File version 2018.0150.1000.34 ((SQLServer).180918-0824) +if (-not (Test-Path "$outputFolder\SQLOS.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/SQLOS.pdb/1c74d1e91078452f9facb3317fdf7b851/SQLOS.pdb' -OutFile "$outputFolder\SQLOS.pdb" } # File version 2018.0150.1000.34 ((SQLServer).180918-0824) +if (-not (Test-Path "$outputFolder\sqlservr.pdb")) { Invoke-WebRequest -uri 'https://msdl.microsoft.com/download/symbols/sqlservr.pdb/b3c1eb7ab1d2455aac81b7eb7fb43a162/sqlservr.pdb' -OutFile "$outputFolder\sqlservr.pdb" } # File version 2018.0150.1000.34 ((SQLServer).180918-0824) +``` + diff --git a/Errors/README.md b/Errors/README.md index 721fd0c6..8c01d4f0 100644 --- a/Errors/README.md +++ b/Errors/README.md @@ -2,14 +2,15 @@ ## Useful links - - [System Error Messages](https://technet.microsoft.com/en-us/library/cc645603%28v=sql.105%29.aspx) - - [Database Engine Error Severities](https://docs.microsoft.com/en-us/sql/relational-databases/errors-events/database-engine-error-severities) - - [Integration Services Error and Message Reference](https://docs.microsoft.com/en-us/sql/integration-services/integration-services-error-and-message-reference) - - [View and Read SQL Server Setup Log Files](https://docs.microsoft.com/en-us/sql/database-engine/install-windows/view-and-read-sql-server-setup-log-files) - - [Troubleshoot the SQL Server Utility](https://msdn.microsoft.com/en-us/library/ee210592.aspx) - - [Common Issues: Licensing Errors](http://blogs.sqlsentry.com/georgeboakye/common-issues-licensing-errors/) - - [SQL Server 2016 Distributed Replay Errors](https://www.sqlskills.com/blogs/jonathan/sql-server-2016-distributed-replay-errors/) - - [The Instance ID MSSQLSERVER Is Already In Use](http://www.sqlservercentral.com/articles/MSSQLSERVER/161398/) +- [System Error Messages](https://technet.microsoft.com/en-us/library/cc645603%28v=sql.105%29.aspx) +- [Database Engine Error Severities](https://docs.microsoft.com/en-us/sql/relational-databases/errors-events/database-engine-error-severities) +- [Integration Services Error and Message Reference](https://docs.microsoft.com/en-us/sql/integration-services/integration-services-error-and-message-reference) +- [View and Read SQL Server Setup Log Files](https://docs.microsoft.com/en-us/sql/database-engine/install-windows/view-and-read-sql-server-setup-log-files) +- [Troubleshoot the SQL Server Utility](https://docs.microsoft.com/en-us/sql/database-engine/troubleshoot-the-sql-server-utility) +- [Common Issues: Licensing Errors](https://www.sentryone.com/blog/georgeboakye/common-issues-licensing-errors) +- [SQL Server 2016 Distributed Replay Errors](https://www.sqlskills.com/blogs/jonathan/sql-server-2016-distributed-replay-errors/) +- [The Instance ID MSSQLSERVER Is Already In Use](http://www.sqlservercentral.com/articles/MSSQLSERVER/161398/) +- [SQL Server: Detach/Attach Gotchas!](https://sqljana.wordpress.com/2018/04/08/sql-server-detach-attach-gotchas/) ## SQL Server All Errors List @@ -17,9 +18,47 @@ ```sql SELECT message_id, severity, text FROM sys.messages - WHERE language_id = 1033; -- assuming US English + WHERE language_id = 1033; /* assuming US English */ ``` +Your `language_id` you can find in [`sys.syslanguages`](https://docs.microsoft.com/en-us/sql/relational-databases/system-compatibility-views/sys-syslanguages-transact-sql) system view, column `msglangid`: + +| langid | dateformat | datefirst | upgrade | name | alias | months | shortmonths | days | lcid | msglangid | +|--------|------------|-----------|---------|--------------------|---------------------|----------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------|------|-----------| +| 0 | mdy | 7 | 0 | us_english | English | January,February,March,April,May,June,July,August,September,October,November,December | Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec | Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday | 1033 | 1033 | +| 1 | dmy | 1 | 0 | Deutsch | German | Januar,Februar,März,April,Mai,Juni,Juli,August,September,Oktober,November,Dezember | Jan,Feb,Mär,Apr,Mai,Jun,Jul,Aug,Sep,Okt,Nov,Dez | Montag,Dienstag,Mittwoch,Donnerstag,Freitag,Samstag,Sonntag | 1031 | 1031 | +| 2 | dmy | 1 | 0 | Français | French | janvier,février,mars,avril,mai,juin,juillet,août,septembre,octobre,novembre,décembre | janv,févr,mars,avr,mai,juin,juil,août,sept,oct,nov,déc | lundi,mardi,mercredi,jeudi,vendredi,samedi,dimanche | 1036 | 1036 | +| 3 | ymd | 7 | 0 | 日本語 | Japanese | 01,02,03,04,05,06,07,08,09,10,11,12 | 01,02,03,04,05,06,07,08,09,10,11,12 | 月曜日,火曜日,水曜日,木曜日,金曜日,土曜日,日曜日 | 1041 | 1041 | +| 4 | dmy | 1 | 0 | Dansk | Danish | januar,februar,marts,april,maj,juni,juli,august,september,oktober,november,december | jan,feb,mar,apr,maj,jun,jul,aug,sep,okt,nov,dec | mandag,tirsdag,onsdag,torsdag,fredag,lørdag,søndag | 1030 | 1030 | +| 5 | dmy | 1 | 0 | Español | Spanish | Enero,Febrero,Marzo,Abril,Mayo,Junio,Julio,Agosto,Septiembre,Octubre,Noviembre,Diciembre | Ene,Feb,Mar,Abr,May,Jun,Jul,Ago,Sep,Oct,Nov,Dic | Lunes,Martes,Miércoles,Jueves,Viernes,Sábado,Domingo | 3082 | 3082 | +| 6 | dmy | 1 | 0 | Italiano | Italian | gennaio,febbraio,marzo,aprile,maggio,giugno,luglio,agosto,settembre,ottobre,novembre,dicembre | gen,feb,mar,apr,mag,giu,lug,ago,set,ott,nov,dic | lunedì,martedì,mercoledì,giovedì,venerdì,sabato,domenica | 1040 | 1040 | +| 7 | dmy | 1 | 0 | Nederlands | Dutch | januari,februari,maart,april,mei,juni,juli,augustus,september,oktober,november,december | jan,feb,mrt,apr,mei,jun,jul,aug,sep,okt,nov,dec | maandag,dinsdag,woensdag,donderdag,vrijdag,zaterdag,zondag | 1043 | 1043 | +| 8 | dmy | 1 | 0 | Norsk | Norwegian | januar,februar,mars,april,mai,juni,juli,august,september,oktober,november,desember | jan,feb,mar,apr,mai,jun,jul,aug,sep,okt,nov,des | mandag,tirsdag,onsdag,torsdag,fredag,lørdag,søndag | 2068 | 2068 | +| 9 | dmy | 7 | 0 | Português | Portuguese | janeiro,fevereiro,março,abril,maio,junho,julho,agosto,setembro,outubro,novembro,dezembro | jan,fev,mar,abr,mai,jun,jul,ago,set,out,nov,dez | segunda-feira,terça-feira,quarta-feira,quinta-feira,sexta-feira,sábado,domingo | 2070 | 2070 | +| 10 | dmy | 1 | 0 | Suomi | Finnish | tammikuuta,helmikuuta,maaliskuuta,huhtikuuta,toukokuuta,kesäkuuta,heinäkuuta,elokuuta,syyskuuta,lokakuuta,marraskuuta,joulukuuta | tammi,helmi,maalis,huhti,touko,kesä,heinä,elo,syys,loka,marras,joulu | maanantai,tiistai,keskiviikko,torstai,perjantai,lauantai,sunnuntai | 1035 | 1035 | +| 11 | ymd | 1 | 0 | Svenska | Swedish | januari,februari,mars,april,maj,juni,juli,augusti,september,oktober,november,december | jan,feb,mar,apr,maj,jun,jul,aug,sep,okt,nov,dec | måndag,tisdag,onsdag,torsdag,fredag,lördag,söndag | 1053 | 1053 | +| 12 | dmy | 1 | 0 | čeština | Czech | leden,únor,březen,duben,květen,červen,červenec,srpen,září,říjen,listopad,prosinec | I,II,III,IV,V,VI,VII,VIII,IX,X,XI,XII | pondělí,úterý,středa,čtvrtek,pátek,sobota,neděle | 1029 | 1029 | +| 13 | ymd | 1 | 0 | magyar | Hungarian | január,február,március,április,május,június,július,augusztus,szeptember,október,november,december | jan,febr,márc,ápr,máj,jún,júl,aug,szept,okt,nov,dec | hétfő,kedd,szerda,csütörtök,péntek,szombat,vasárnap | 1038 | 1038 | +| 14 | dmy | 1 | 0 | polski | Polish | styczeń,luty,marzec,kwiecień,maj,czerwiec,lipiec,sierpień,wrzesień,październik,listopad,grudzień | I,II,III,IV,V,VI,VII,VIII,IX,X,XI,XII | poniedziałek,wtorek,środa,czwartek,piątek,sobota,niedziela | 1045 | 1045 | +| 15 | dmy | 1 | 0 | română | Romanian | ianuarie,februarie,martie,aprilie,mai,iunie,iulie,august,septembrie,octombrie,noiembrie,decembrie | Ian,Feb,Mar,Apr,Mai,Iun,Iul,Aug,Sep,Oct,Nov,Dec | luni,marţi,miercuri,joi,vineri,sîmbătă,duminică | 1048 | 1048 | +| 16 | ymd | 1 | 0 | hrvatski | Croatian | siječanj,veljača,ožujak,travanj,svibanj,lipanj,srpanj,kolovoz,rujan,listopad,studeni,prosinac | sij,vel,ožu,tra,svi,lip,srp,kol,ruj,lis,stu,pro | ponedjeljak,utorak,srijeda,četvrtak,petak,subota,nedjelja | 1050 | 1050 | +| 17 | dmy | 1 | 0 | slovenčina | Slovak | január,február,marec,apríl,máj,jún,júl,august,september,október,november,december | I,II,III,IV,V,VI,VII,VIII,IX,X,XI,XII | pondelok,utorok,streda,štvrtok,piatok,sobota,nedeľa | 1051 | 1051 | +| 18 | dmy | 1 | 0 | slovenski | Slovenian | januar,februar,marec,april,maj,junij,julij,avgust,september,oktober,november,december | jan,feb,mar,apr,maj,jun,jul,avg,sept,okt,nov,dec | ponedeljek,torek,sreda,četrtek,petek,sobota,nedelja | 1060 | 1060 | +| 19 | dmy | 1 | 0 | ελληνικά | Greek | Ιανουαρίου,Φεβρουαρίου,Μαρτίου,Απριλίου,Μα_ου,Ιουνίου,Ιουλίου,Αυγούστου,Σεπτεμβρίου,Οκτωβρίου,Νοεμβρίου,Δεκεμβρίου | Ιαν,Φεβ,Μαρ,Απρ,Μαϊ,Ιουν,Ιουλ,Αυγ,Σεπ,Οκτ,Νοε,Δεκ | Δευτέρα,Τρίτη,Τετάρτη,Πέμπτη,Παρασκευή,Σάββατο,Κυριακή | 1032 | 1032 | +| 20 | dmy | 1 | 0 | български | Bulgarian | януари,февруари,март,април,май,юни,юли,август,септември,октомври,ноември,декември | януари,февруари,март,април,май,юни,юли,август,септември,октомври,ноември,декември | понеделник,вторник,сряда,четвъртък,петък,събота,неделя | 1026 | 1026 | +| 21 | dmy | 1 | 0 | русский | Russian | Январь,Февраль,Март,Апрель,Май,Июнь,Июль,Август,Сентябрь,Октябрь,Ноябрь,Декабрь | янв,фев,мар,апр,май,июн,июл,авг,сен,окт,ноя,дек | понедельник,вторник,среда,четверг,пятница,суббота,воскресенье | 1049 | 1049 | +| 22 | dmy | 1 | 0 | Türkçe | Turkish | Ocak,Şubat,Mart,Nisan,Mayıs,Haziran,Temmuz,Ağustos,Eylül,Ekim,Kasım,Aralık | Oca,Şub,Mar,Nis,May,Haz,Tem,Ağu,Eyl,Eki,Kas,Ara | Pazartesi,Salı,Çarşamba,Perşembe,Cuma,Cumartesi,Pazar | 1055 | 1055 | +| 23 | dmy | 1 | 0 | British | British English | January,February,March,April,May,June,July,August,September,October,November,December | Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec | Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday | 2057 | 1033 | +| 24 | dmy | 1 | 0 | eesti | Estonian | jaanuar,veebruar,märts,aprill,mai,juuni,juuli,august,september,oktoober,november,detsember | jaan,veebr,märts,apr,mai,juuni,juuli,aug,sept,okt,nov,dets | esmaspäev,teisipäev,kolmapäev,neljapäev,reede,laupäev,pühapäev | 1061 | 1061 | +| 25 | ymd | 1 | 0 | latviešu | Latvian | janvāris,februāris,marts,aprīlis,maijs,jūnijs,jūlijs,augusts,septembris,oktobris,novembris,decembris | jan,feb,mar,apr,mai,jūn,jūl,aug,sep,okt,nov,dec | pirmdiena,otrdiena,trešdiena,ceturtdiena,piektdiena,sestdiena,svētdiena | 1062 | 1062 | +| 26 | ymd | 1 | 0 | lietuvių | Lithuanian | sausis,vasaris,kovas,balandis,gegužė,birželis,liepa,rugpjūtis,rugsėjis,spalis,lapkritis,gruodis | sau,vas,kov,bal,geg,bir,lie,rgp,rgs,spl,lap,grd | pirmadienis,antradienis,trečiadienis,ketvirtadienis,penktadienis,šeštadienis,sekmadienis | 1063 | 1063 | +| 27 | dmy | 7 | 0 | Português (Brasil) | Brazilian | Janeiro,Fevereiro,Março,Abril,Maio,Junho,Julho,Agosto,Setembro,Outubro,Novembro,Dezembro | Jan,Fev,Mar,Abr,Mai,Jun,Jul,Ago,Set,Out,Nov,Dez | Segunda-Feira,Terça-Feira,Quarta-Feira,Quinta-Feira,Sexta-Feira,Sábado,Domingo | 1046 | 1046 | +| 28 | ymd | 7 | 0 | 繁體中文 | Traditional Chinese | 一月,二月,三月,四月,五月,六月,七月,八月,九月,十月,十一月,十二月 | 01,02,03,04,05,06,07,08,09,10,11,12 | 星期一,星期二,星期三,星期四,星期五,星期六,星期日 | 1028 | 1028 | +| 29 | ymd | 7 | 0 | 한국어 | Korean | 01,02,03,04,05,06,07,08,09,10,11,12 | 01,02,03,04,05,06,07,08,09,10,11,12 | 월요일,화요일,수요일,목요일,금요일,토요일,일요일 | 1042 | 1042 | +| 30 | ymd | 7 | 0 | 简体中文 | Simplified Chinese | 01,02,03,04,05,06,07,08,09,10,11,12 | 01,02,03,04,05,06,07,08,09,10,11,12 | 星期一,星期二,星期三,星期四,星期五,星期六,星期日 | 2052 | 2052 | +| 31 | dmy | 1 | 0 | Arabic | Arabic | Muharram,Safar,Rabie I,Rabie II,Jumada I,Jumada II,Rajab,Shaaban,Ramadan,Shawwal,Thou Alqadah,Thou Alhajja | Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec | Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday | 1025 | 1025 | +| 32 | dmy | 7 | 0 | ไทย | Thai | มกราคม,กุมภาพันธ์,มีนาคม,เมษายน,พฤษภาคม,มิถุนายน,กรกฎาคม,สิงหาคม,กันยายน,ตุลาคม,พฤศจิกายน,ธันวาคม | ม.ค.,ก.พ.,มี.ค.,เม.ย.,พ.ค.,มิ.ย.,ก.ค.,ส.ค.,ก.ย.,ต.ค.,พ.ย.,ธ.ค. | จันทร์,อังคาร,พุธ,พฤหัสบดี,ศุกร์,เสาร์,อาทิตย์ | 1054 | 1054 | +| 33 | dmy | 1 | 0 | norsk (bokmål) | Bokmål | januar,februar,mars,april,mai,juni,juli,august,september,oktober,november,desember | jan,feb,mar,apr,mai,jun,jul,aug,sep,okt,nov,des | mandag,tirsdag,onsdag,torsdag,fredag,lørdag,søndag | 1044 | 1044 | ## Levels of Severity @@ -46,103 +85,308 @@ SELECT message_id, severity, text | 24 | Indicates a media failure. The system administrator may have to restore the database. You may also have to call your hardware vendor. | -## SQL Server Common Errors -Error code equal `message_id` from `sys.messages` +## SQL Server Errors + +| message_id | Description | Article | +|-----------:|----------------------------------------------------------------------------------------------------------|-----------------------------------------------------| +| 0 | You may see “out of user memory quota” message in errorlog when you use In-Memory OLTP feature … | [Out of user memory quota][7] | +| 0 | Logon Failure: The User has not Been Granted. The operating system returned the error ????? while … | [Compressed backup errors][8] | +| 0 | A transport-level error has occurred when receiving results from the server. | [link1][31] | +| 0 | The MSSQLSERVER service was unable to log on as SQLAuthority\SQLFarmService with the currently c … | [The User has not Been Granted][9] | +| 0 | A server error occurred on current command. The results, if any, should be discarded. | [Who owns your availability groups?] | +| 0 | A network-related issue or instance-specific error occured while establishing a connection to SQL Server | [Cannot Connect to SQL Server] | +| 0 | Connecting to Azure SQL Database: Requested tenant identifier '00000000-0000-0000-0000-000000000000' is… | [Requested tenant identifier] | +| 102 | Incorrect syntax near '%.*ls'. | [102_link1],[102_link2][39] | +| 120 | The select list for the INSERT statement contains fewer items than the insert list. The number of … | [120_link1][35] | +| 121 | The select list for the INSERT statement contains more items than the insert list. The number of … | [121_link1][35] | +| 131 | The size (%d) given to the %S_MSG '%.*ls' exceeds the maximum allowed for any data type (%d). | [131_link1][47] | +| 145 | ORDER BY items must appear in the select list if SELECT DISTINCT is specified. | [145_link1][27] | +| 156 | Incorrect syntax near the keyword 'ORDER'. | [156_link1][23] | +| 207 | Invalid column name '%.*ls'. | [207_link1] | +| 213 | Column name or number of supplied values does not match table definition. | [213_link1][3],[213_link2][35] | +| 229 | The %ls permission was denied on the object '%.*ls', database '%.*ls', schema '%.*ls'. | [229_link1][12] | +| 241 | Conversion failed when converting date and/or time from character string. | [241_link1] | +| 257 | Implicit conversion from data type %ls to %ls is not allowed. Use the CONVERT function to run this query | [257_link1] | +| 264 | The column name '%.*ls' is specified more than once in the SET clause or column list of an INSERT … | [264_link1][25] | +| 297 | The user does not have permission to perform this action. | [297_link1][12] | +| 352 | The table-valued parameter "%.*ls" must be declared with the READONLY option. | [352_link1][22] | +| 459 | Collation '%.*ls' is supported on Unicode data types only and cannot be applied to char, varchar or … | [459_link1] | +| 535 | The datediff function resulted in an overflow. The number of dateparts separating two date/time | [535_link1] | +| 596 | Cannot continue execution because the session is in the kill state. | [596_link1],[596_link2][31],[596_link3][32] | +| 650 | You can only specify the READPAST lock in the READ COMMITTED or REPEATABLE READ isolation levels. | [650_link1] | +| 657 | Could not disable support for increased partitions in database … | [657_link1] | +| 665 | The operating system returned error 665(The requested operation could not be completed due to a file … | [665_link1],[665_link2][52] | +| 666 | The maximum system-generated unique value for a duplicate group was exceeded for index with … | [666_link1] | +| 701 | There is insufficient system memory in resource pool '%ls' to run this query. … | [701_link1],[701_link2][11] | +| 824 | SQL Server detected a logical consistency-based I/O error … | [824_link1],[824_link2],[KB2152734],[824_link3][42] | +| 825 | The operating system returned error %ls to SQL Server. It failed creating event for a %S_MSG at … | [825_link1] | +| 913 | Could Not Find Database %d. Database May Not be Activated Yet or May be in Transition … | [913_link1] | +| 922 | Database '%.*ls' is being recovered. Waiting until recovery is finished. | [922_link1] | +| 926 | Database '%.*ls' cannot be opened. It has been marked SUSPECT by recovery. See the SQL Server errorlog … | [926_link1] | +| 1052 | Conflicting %ls options "%ls" and "%ls". | [1052_link1][33] | +| 1065 | The NOLOCK and READUNCOMMITTED lock hints are not allowed for target tables of INSERT, UPDATE, DELETE …| [1065_link1] | +| 1105 | Could not allocate space for object '%.*ls'%.*ls in database '%.*ls' because the '%.*ls' filegroup is …| [1105_link1] | +| 1204 | The instance of the SQL Server Database Engine cannot obtain a LOCK resource at this time. Rerun your … | [1204_link1][46] | +| 1205 | Transaction (Process ID %d) was deadlocked on %.*ls resources with another process and has been chosen … | [1205_link1][46] | +| 1222 | Lock request time out period exceeded. | [1222_link1][46] | +| 1219 | Your session has been disconnected because of a high priority DDL operation. | [1219_link1][32] | +| 1450 | The operating system returned error 1450 (Insufficient system resources exist to complete the … | [52] | +| 1480 | The %S_MSG database "%.*ls" is changing roles from "%ls" to "%ls" because the mirroring session or … | [1480_link1][48] | +| 1701 | Creating or altering table %ls failed because the minimum row size would be 8061, including 10 b … | [1701_link1] | +| 1807 | Could not obtain exclusive lock on database ‘model’. Retry the operation later. … | [1807_link1] | +| 1904 | The statistics on table has 65 columns in the key list … | [1904_link1] | +| 1908 | Column '%.*ls' is partitioning column of the index '%.*ls'. Partition columns for a unique index … | [1908_link1][18] | +| 2533 | Table error: page %S_PGID allocated to object ID %d, index ID %d, partition ID %I64d, alloc unit ID … | [2533_link1][50] | +| 2534 | Table error: page %S_PGID, whose header indicates that it is allocated to object ID %d, index ID %d, … | [2534_link1][50] | +| 2812 | Could not find stored procedure '%.*ls'. | [2812_link1][38] | +| 3101 | Exclusive access could not be obtained because the database is in use. … | [3101_link1] | +| 3154 | The backup set holds a backup of a database other than the existing … | [3154_link1] | +| 3241 | The media family on device '%ls' is incorrectly formed. SQL Server cannot process this media fam … | [3241_link1] | +| 3314 | During undoing of a logged operation in database '%.*ls', an error occurred at log record ID %S … | [3314_link1] | +| 3634 | The operating system returned the error '%ls' while attempting '%ls' on '%ls'. … | [3634_link1] | +| 3637 | A parallel operation cannot be started from a DAC connection. | [3637_link1] | +| 3743 | The database '%.*ls' is enabled for database mirroring. Database mirroring must be removed befor … | [3743_link1] | +| 3906 | Failed to update database "%.*ls" because the database is read-only. | [3906_link1] | +| 3930 | The current transaction cannot be committed and cannot support operations that write to the log … | [3930_link1] | +| 3956 | Snapshot isolation transaction failed to start in database '%.*ls' because the ALTER DATABASE command … | [3956_link1][49] | +| 3960 | Snapshot isolation transaction aborted due to update conflict. You cannot use snapshot isolation to … | [3960_link1][49] | +| 4064 | Cannot open user default database. Login failed.Login failed. … | [4064_link1] | +| 4189 | Cannot convert to text/ntext or collate to '%.*ls' because these legacy LOB types do not support UTF-8 … | [4189_link1][21] | +| 4353 | Conflicting file relocations have been specified for file '%.*ls'. Only a single WITH MOVE clause … | [4353_link1] | +| 4629 | Permissions on server scoped catalog views or system stored procedures or extended stored … | [4629_link1][12] | +| 4901 | ALTER TABLE only allows columns to be added that can contain nulls, or have a DEFAULT definition … | [4901_link1][33] | +| 4922 | ALTER TABLE ALTER COLUMN Address failed because one or more objects access this column. … | [4922_link1] | +| 4934 | Computed column '%.*ls' in table '%.*ls' cannot be persisted because the column does user or … | [4934_link1] | +| 4947 | ALTER TABLE SWITCH statement failed. There is no identical index in source table '%.*ls' for the … | [4947_link1][18] | +| 5004 | To use ALTER DATABASE, the database must be in a writable state in which a checkpoint can be executed. | [5004_link1] | +| 5011 | User does not have permission to alter database '%.*ls', the database does not exist, or the database … | [5011_link1][49] | +| 5061 | ALTER DATABASE failed because a lock could not be placed on database '%.*ls'. Try again later. | [5061_link1] | +| 5084 | Setting database option %ls to %ls for database '%.*ls'. | [5084_link1][43] | +| 5120 | Unable to open the physical file ... Operating system error 5: "5(Access is denied.)" … | [SQL SERVER - FIX Error 5120] | +| 5123 | CREATE FILE encountered operating system error "%ls"(The system cannot find the path specified.) … | [5123_link1], [5123_link2] | +| 5171 | %.*ls is not a primary database file. | [5171_link1][29] | +| 5172 | The header for file '%ls' is not a valid database file header. The %ls property is incorrect. | [5172_link1][29] | +| 5235 | %lsDBCC %ls (%ls%ls%ls)%ls executed by %ls terminated abnormally due to error state %d. Elapsed time: … | [5235_link1][50] | +| 5846 | Common language runtime (CLR) execution is not supported under lightweight pooling. Disable one of two … | [5846_link1] | +| 6335 | XML datatype instance has too many levels of nested nodes. Maximum allowed depth is 128 levels. | [6335_link1] | +| 6348 | Specified collection '%.*ls' cannot be created because it already exists or you do not have permission. | [6348_link1][36] | +| 6401 | Cannot roll back %.*ls. No transaction or savepoint of that name was found. | [6401_link1][4] | +| 7341 | Cannot get the current row value of column "%ls.%ls" from OLE DB provider "%ls" for linked server "%ls … | [7341_link1][37] | +| 7344 | The OLE DB provider "%ls" for linked server "%ls" could not %ls table "%ls" because of column … | [7344_link1][3] | +| 7356 | The OLE DB provider "%ls" for linked server "%ls" supplied inconsistent metadata for a column. … | [7356_link1][37] | +| 7357 | Cannot process the object "%ls". The OLE DB provider "%ls" for linked server "%ls" indicates that … | [7357_link1][2], [7357_link2][2] | +| 7391 | The operation could not be performed because OLE DB provider "%ls" for linked server "%ls" ... … | [7391_link2][2] | +| 7719 | CREATE/ALTER partition function failed as only maximum of 1000 partitions can be created. … | [657_link1] | +| 7926 | Check statement aborted. The database could not be checked as a database snapshot could not be created … | [7926_link1][50] | +| 8101 | An explicit value for the identity column in table '%.*ls' can only be specified when a column list is … | [8101_link1][40] | +| 8107 | IDENTITY_INSERT is already ON for table '%.*ls.%.*ls.%.*ls'. Cannot perform SET operation for table '% … | [8107_link1][40] | +| 8115 | Arithmetic overflow error converting %ls to data type %ls. | [8115_link1][24] | +| 8116 | Argument data type %ls is invalid for argument %d of %ls function. | [8116_link1][44] | +| 8117 | Operand data type %ls is invalid for %ls operator. | [8117_link1][44] | +| 8180 | Statement(s) could not be prepared. | [8180_link1][28] | +| 8127 | Column "%.*ls.%.*ls" is invalid in the ORDER BY clause because it is not contained in either an … | [8127_link1][27] | +| 8152 | String or binary data would be truncated. | [8152_link1][47] | +| 8624 | Internal Query Processor Error: The query processor could not produce a query plan. | [8624_link1] | +| 8645 | A timeout occurred while waiting for memory resources to execute the query in resource pool '%ls' (%ld … | [8645_link1] | +| 8651 | Could not perform the operation because the requested memory grant was not available in resource … | [8651_link1] | +| 8672 | The MERGE statement attempted to UPDATE or DELETE the same row more than once... … | [8672_link1] | +| 8909 | Table error: Object ID %d, index ID %d, partition ID %I64d, alloc unit ID %I64d (type %.*ls), pa … | [8909_link1] | +| 8921 | Check terminated. A failure was detected while collecting facts. Possibly tempdb out of space or … | [8921_link1] | +| 8928 | Object ID %d, index ID %d, partition ID %I64d, alloc unit ID %I64d (type %.*ls): Page %S_PGID could not… | [8928_link1][42] | +| 8939 | Table error: Object ID %d, index ID %d, partition ID %I64d, alloc unit ID %I64d (type %.*ls), page … | [8939_link1][42] | +| 8948 | Database error: Page %S_PGID is marked with the wrong type in PFS page %S_PGID. PFS status 0x%x … | [8948_link1][20] | +| 9001 | The log for database '%.*ls' is not available. Check the operating system error log for related … | [9001_link1][16] | +| 9002 | The transaction log for database '%ls' is full due to '%ls'. … | [9002_link1][17],[9002_link2][19],[9002_link3] | +| 9105 | The provided statistics stream is corrupt. | [9105_link1][33] | +| 9642 | An error occurred in a Service Broker/Database Mirroring transport connection endpoint, Error: %i, … | [9105_link1][45] | +| 10314 | An error occurred in the Microsoft .NET Framework while trying to load assembly id %d. The server may … | [10314_link1],[10314_link2] | +| 10637 | Cannot perform this operation on '%.*ls' with ID %I64d as one or more indexes are currently in … | [10637_link1][32] | +| 10794 | The %S_MSG '%ls' is not supported with %S_MSG. | [10794_link1][39],[10794_link2] | +| 11442 | Columnstore index creation is not supported in tempdb when memory-optimized metadata mode is enabled. … | [11442_link1][51] | +| 11535 | EXECUTE statement failed because its WITH RESULT SETS clause specified %d result set(s), and the … | [11535_link1][38] | +| 12349 | Operation not supported for memory optimized tables having columnstore index. | [12349_link1][41] | +| 13609 | JSON text is not properly formatted. Unexpected character '%lc' is found at position %d. | [13609_link1] | +| 13515 | Setting SYSTEM_VERSIONING to ON failed because history table '%.*ls' has custom unique keys defined. … | [13515_link1][33] | +| 13518 | Setting SYSTEM_VERSIONING to ON failed because history table '%.*ls' has IDENTITY column specification … | [13518_link1][33] | +| 13523 | Setting SYSTEM_VERSIONING to ON failed because table '%.*ls' has %d columns and table '%.*ls' has %d … | [13523_link1][33] | +| 13543 | Setting SYSTEM_VERSIONING to ON failed because history table '%.*ls' contains invalid records with end … | [13543_link1][33] | +| 13570 | The use of replication is not supported with system-versioned temporal table '%s' | [13570_link1] | +| 13573 | Setting SYSTEM_VERSIONING to ON failed because history table '%.*ls' contains overlapping records. | [13573_link1][33] | +| 13575 | ADD PERIOD FOR SYSTEM_TIME failed because table '%.*ls' contains records where end of period is not … | [13575_link1][33] | +| 13901 | Identifier '%.*ls' in a MATCH clause is not a node table or an alias for a node table. | [13901_link1][30] | +| 13902 | Identifier '%.*ls' in a MATCH clause is not an edge table or an alias for an edge table. | [13902_link1][30] | +| 15002 | The procedure 'sys.sp_dbcmptlevel' cannot be executed within a transaction. … | [15002_link1] | +| 15021 | Invalid value given for parameter %s. Specify a valid parameter value. | [15021_link1] | +| 15136 | The database principal is set as the execution context of one or more procedures, functions, … | [15136_link1] | +| 15190 | There are still remote logins or linked logins for the server '%s'. | [15190_link1] | +| 15199 | The current security context cannot be reverted. Please switch to the original database where … | [15199_link1][1] | +| 15274 | Access to the remote server is denied because the current security context is not trusted. | [15274_link1] | +| 15404 | Could not obtain information about Windows NT group/user '%ls', error code %#lx. | [15404_link1] | +| 15406 | Cannot execute as the server principal because the principal "%.*ls" does not exist, this type of … | [15406_link1][1] | +| 15457 | Configuration option '%ls' changed from %ld to %ld. Run the RECONFIGURE statement to install. | [5457_link1][43] | +| 17051 | SQL Server evaluation edition has expired. | [17051_link1] | +| 17182 | TDSSNIClient initialization failed with error 0x%lx, status code 0x%lx. Reason: %S_MSG %.*ls | [17182_link1][15] | +| 17190 | Initializing the FallBack certificate failed with error code: %d, state: %d, error number: %d. … | [17190_link1] | +| 17300 | SQL Server was unable to run a new system task, either because there is insufficient memory or the … | [17300_link1] | +| 17836 | Length specified in network packet payload did not match number of bytes read; the connection has been … | [17836_link1][45] | +| 18054 | Error %d, severity %d, state %d was raised, but no message with that error number was found in … | [18054_link1] | +| 18272 | During restore restart, an I/O error occurred on checkpoint file '%s' (operating system error %s … | [18272_link1] | +| 18357 | Reason: An attempt to login using SQL authentication failed. Server is configured for Integrated … | [18357_link1][5] | +| 18401 | Login failed for user '%.*ls'. Reason: Server is in script upgrade mode. Only administrator can connect… | [18401_link1] | +| 18452 | Login failed. The login is from an untrusted domain and cannot be used with Windows authenticati … | [18452_link1] | +| 18456 | Login failed for user '%.*ls'.%.*ls%.*ls | [18456_link1] | +| 20598 | The row was not found at the Subscriber when applying the replicated %S_MSG command for Table '%s' with… | [20598_link1] | +| 22911 | The capture job cannot be used by Change Data Capture to extract changes from the log when … | [22911_link1] | +| 25713 | The value specified for %S_MSG, "%.*ls", %S_MSG, "%.*ls", is invalid. | [25713_link1],[25713_link2] | +| 26023 | Server TCP provider failed to listen on [ %s <%s> %d]. Tcp port is already in use. | [26023_link1][13] | +| 33111 | Cannot find server %S_MSG with thumbprint '%.*ls'. | [33111_link1] | +| 33206 | SQL Server Audit failed to create the audit file '%s'. Make sure that the disk is not full and … | [33206_link1][10] | +| 35217 | The thread pool for Always On Availability Groups was unable to start a new worker thread because … | [35217_link1] | +| 35250 | The connection to the primary replica is not active. The command cannot be processed. | [35250_link1] | +| 35264 | Always On Availability Groups data movement for database '%.*ls' has been suspended for the following … | [35264_link1][48] | +| 35320 | Column store indexes are not allowed on tables for which the durability option SCHEMA_ONLY is specified. | [35320_link1][41] | +| 35337 | UPDATE STATISTICS failed because statistics cannot be updated on a columnstore index. … | [35337_link1][33] | +| 35343 | The statement failed. Column '%.*ls' has a data type that cannot participate in a columnstore index. | [35343_link1][36] | +| 39004 | A '%s' script error occurred during execution of 'sp_execute_external_script' with HRESULT 0x%x. | [39004_link1][14] | +| 41121 | The local availability replica of availability group '%.*ls' cannot accept signal '%s' in its current …| [41121_link1] | +| 41317 | A user transaction that accesses memory optimized tables or natively compiled modules cannot access more…| [41317_link1][51] | +| 41922 | The backup operation for a database with service-managed transaprent data encryption is not supported on…| [41922_link1] | -| Error Code | Description | Article | -|-----------:|---------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------| -| ? | You may see “out of user memory quota” message in errorlog when you use In-Memory OLTP feature | [Out of user memory quota] | -| ? | The operating system returned the error ????? while attempting SetEndOfFile' on '\\SQLBackups\database.bak'. BACKUP DATABASE is terminating abnormally. | [Compressed backup errors and TF 3042] | -| - | The MSSQLSERVER service was unable to log on as SQLAuthority\SQLFarmService with the currently configured password due to the following error: ... | [Logon Failure: The User has not Been Granted] | -| 0 | A server error occurred on current command. The results, if any, should be discarded. | [Who owns your availability groups?] | -| 102 | Incorrect syntax near '%.*ls'. | [102_link1] | -| 207 | Invalid column name '%.*ls'. | [207_link1] | -| 535 | The datediff function resulted in an overflow. The number of dateparts separating two date/time instances is too large... | [Nuance of datetime data type in SQL Server] | -| 596 | Cannot continue execution because the session is in the kill state. | [596_link1] | -| 657 | Could not disable support for increased partitions in database ... | [SQL SERVER – Disabling 15000 Partitions (15k)] | -| 703 | There is insufficient system memory in resource pool 'default' to run this query. | [703_link1] | -| 824 | SQL Server detected a logical consistency-based I/O error | [Resolve Microsoft SQL Server Error Code 824], [KB2152734] | -| 825 | The operating system returned error %ls to SQL Server. It failed creating event for a %S_MSG at offset %#016I64x in file '%ls'. | [825_link1] | -| 913 | Could Not Find Database %d. Database May Not be Activated Yet or May be in Transition | [FIX: Error: 913, Severity: 16 – Could Not Find Database ID] | -| 1701 | Creating or altering table %ls failed because the minimum row size would be 8061, including 10 bytes of internal overhead... | [1701_link1] | -| 1807 | Could not obtain exclusive lock on database ‘model’. Retry the operation later. | [CREATE DATABASE – I’ve not seen that before.] | -| 1904 | The statistics on table has 65 columns in the key list | [SQL SERVER - Fix: Error: Msg 1904] | -| 3013 | RESTORE DATABASE is terminating abnormally | [KB290787] | -| 3041 | BACKUP failed to complete the command %.*ls. Check the backup application log for detailed messages. | [3041_link1] | -| 3101 | Exclusive access could not be obtained because the database is in use. | [3101_link1] | -| 3154 | The backup set holds a backup of a database other than the existing | [Database Restore Fails with Msg 3154] | -| 3241 | The media family on device '%ls' is incorrectly formed. SQL Server cannot process this media family. | [Unable to restore a backup – Msg 3241] | -| 3314 | During undoing of a logged operation in database '%.*ls', an error occurred at log record ID %S_LSN. Typically, the specific failure is logged ... | [3314_link1] | -| 3634 | The operating system returned the error '%ls' while attempting '%ls' on '%ls'. | [3634_link1] | -| 3743 | The database '%.*ls' is enabled for database mirroring. Database mirroring must be removed before you drop the database. | [3743_link1] | -| 3930 | The current transaction cannot be committed and cannot support operations that write to the log file. Roll back the transaction. | [3930_link1] | -| 4064 | Cannot open user default database. Login failed.Login failed. | [4064_link1] | -| 4922 | ALTER TABLE ALTER COLUMN Address failed because one or more objects access this column. | [SQL Server 2016 Online ALTER COLUMN Operation] | -| 5120 | Unable to open the physical file ... Operating system error 5: "5(Access is denied.)" | [SQL SERVER - FIX Error 5120] | -| 5123 | CREATE FILE encountered operating system error "%ls"(The system cannot find the path specified.) | [5123_link1], [5123_link1] | -| 6335 | XML datatype instance has too many levels of nested nodes. Maximum allowed depth is 128 levels. | [6335_link1] | -| 7357 | Cannot process the object "%ls". The OLE DB provider "%ls" for linked server "%ls" ... | [Discuss Execute(SQL) At LinkedServer] | -| 7391 | The operation could not be performed because OLE DB provider "%ls" for linked server "%ls" ... | [Discuss Execute(SQL) At LinkedServer] | -| 7719 | CREATE/ALTER partition function failed as only maximum of 1000 partitions can be created. | [SQL SERVER – Disabling 15000 Partitions (15k)] | -| 8624 | Internal Query Processor Error: The query processor could not produce a query plan. | [Internal Query Processor Error with ColumnStore Indexes] | -| 8651 |Could not perform the operation because the requested memory grant was not available in resource pool '%ls' (%ld). | [8651_link1] | -| 8672 | The MERGE statement attempted to UPDATE or DELETE the same row more than once... | [8672_link1] | -| 8909 | Table error: Object ID %d, index ID %d, partition ID %I64d, alloc unit ID %I64d (type %.*ls), page ID %S_PGID contains an incorrect page ID in its ... | [8909_link1] | -| 8921 | Check terminated. A failure was detected while collecting facts. Possibly tempdb out of space or a system table is inconsistent. Check previous errors. | [8921_link1] | -| 9002 | The transaction log for database '%ls' is full due to '%ls'. | [9002_link1] | -| 15002 | The procedure 'sys.sp_dbcmptlevel' cannot be executed within a transaction. | [15002_link1] | -| 15136 | The database principal is set as the execution context of one or more procedures, functions, ... | [Unable to drop a user in a database] | -| 17182 | Tcp port is already in use | [TCP Port Is Already In Use] | -| 17190 | Initializing the FallBack certificate failed with error code: %d, state: %d, error number: %d. | [17190_link1] | -| 18272 | During restore restart, an I/O error occurred on checkpoint file '%s' (operating system error %s). The statement is proceeding but cannot be restarted. | [18272_link1] | -| 18452 | Login failed. The login is from an untrusted domain and cannot be used with Windows authentication | [Login from an Untrusted Domain] | -| 18456 | Login failed for user '%.*ls'.%.*ls%.*ls | [Why won’t my SQL Logins work?] | -| 35250 | The connection to the primary replica is not active. The command cannot be processed. | [35250_link1] | +[1]:https://sqlstudies.com/2018/05/16/the-trials-and-tribulations-of-reverting-from-impersonation/ +[2]:https://sqlpowershell.wordpress.com/2016/11/09/sql-server-discuss-executesql-at-linkedserver/ +[3]:https://sqlstudies.com/2018/06/14/the-identity-column-the-insert-and-the-linked-server/ +[4]:http://www.sqlservercentral.com/blogs/sql-server-overview/2018/05/07/know-about-sql-server-error-6401/ +[5]:https://sqlstudies.com/2018/06/18/misleading-errors-server-is-configured-for-windows-authentication-only-but-its-not/ +[6]:https://sqlstudies.com/2018/05/10/each-session-should-be-able-to-have-its-own-temp-table-but-there-can-be-problems/ +[7]:https://blogs.msdn.microsoft.com/psssql/2017/06/07/you-may-see-out-of-user-memory-quota-message-in-errorlog-when-you-use-in-memory-oltp-feature/ +[8]:https://sqlstudies.com/2017/03/16/compressed-backup-errors-and-tf-3042/ +[9]:https://blog.sqlauthority.com/2017/04/14/sql-server-logon-failure-user-not-granted-requested-logon-type-computer/ +[10]:http://nebraskasql.blogspot.com/2018/03/error-33206-sql-server-audit-failed-to.html +[11]:http://nebraskasql.blogspot.com/2014/03/error-701-insufficient-system-memory.html +[12]:http://www.nielsberglund.com/2018/06/24/sp-execute-external-script-and-permissions/ +[13]:https://blogs.msdn.microsoft.com/psssql/2018/07/26/july-10-2018-windows-updates-cause-sql-startup-issues-due-to-tcp-port-is-already-in-use-errors/ +[14]:https://36chambers.wordpress.com/2017/04/27/error-0x80004005-in-sql-server-r-services/ +[15]:https://blogs.msdn.microsoft.com/sql_pfe_blog/2016/10/05/tcp-port-is-already-in-use/ +[16]:http://nedotter.com/archive/2018/07/dangerous-moves-setting-max-size-for-in-memory-oltp-containers/ +[17]:https://docs.microsoft.com/en-us/sql/relational-databases/logs/troubleshoot-a-full-transaction-log-sql-server-error-9002 +[18]:https://dbafromthecold.com/2018/02/21/indexing-and-partitioning/ +[19]:http://nebraskasql.blogspot.com/2018/08/the-mystery-of-exploding-t-log.html +[20]:https://www.sqlskills.com/blogs/paul/pfs-corruption-after-upgrading-from-sql-server-2014/ +[21]:https://sqlquantumleap.com/2018/09/28/native-utf-8-support-in-sql-server-2019-savior-false-prophet-or-both/ +[22]:https://sqlstudies.com/2018/09/13/using-table-valued-parameters-with-sp_executesql/ +[23]:http://sqlstudies.com/2018/09/19/you-cant-delete-top-x-with-an-order-by/ +[24]:https://www.brentozar.com/archive/2018/10/sum-avg-and-arithmetic-overflow/ +[25]:https://www.sqltheater.com/blog/using-the-same-column-twice-in-an-update-statement/ +[26]:http://jasonbrimhall.info/2018/12/14/synonyms-in-sql-server-good-and-bad/ +[27]:https://www.brentozar.com/archive/2018/08/a-common-query-error/ +[28]:https://blog.sqlauthority.com/2019/01/14/sql-server-fix-msg-8180-statements-could-not-be-prepared-deferred-prepare-could-not-be-completed/ +[29]:https://blog.sqlauthority.com/2018/08/29/sql-server-unable-to-attach-database-files-the-pageaudit-property-is-incorrect-ransomware-attack/ +[30]:http://www.nikoport.com/2018/12/01/sql-graph-part-iii-derived-tables-views/ +[31]:https://www.mssqltips.com/sqlservertip/5971/accelerated-database-recovery-in-sql-server-2019/ +[32]:https://www.brentozar.com/archive/2019/03/what-happens-when-you-cancel-or-kill-a-resumable-index-creation/ +[33]:https://curiousaboutdata.com/2019/04/15/temporal-tables-list-of-errors-with-reasons/ +[34]:https://www.sqlserverscience.com/maintenance/update-statistics-failed-statistics-cannot-be-updated-columnstore-index/ +[35]:https://www.sqlshack.com/methods-to-insert-data-into-sql-server/ +[36]:https://www.kevinrchant.com/2019/05/20/interesting-sql-server-2019-findings-testing-sp_estimate_data_compression_savings/ +[37]:https://blog.pythian.com/fix-sql-server-to-postgresql-linked-server-error-requested-conversion-is-not-supported/ +[38]:https://www.sqlshack.com/exec-sql-overview-and-examples/ +[39]:http://www.nikoport.com/2015/09/02/columnstore-indexes-part-64-t-sql-improvements-in-sql-server-2016/ +[40]:https://bertwagner.com/2019/06/25/multiple-identity-inserts/ +[41]:https://www.sqlshack.com/how-to-create-a-clustered-columnstore-index-on-a-memory-optimized-table/ +[42]:https://www.sqlserverscience.com/internals/invalid-protection-option/ +[43]:https://www.red-gate.com/hub/product-learning/sql-monitor/spotting-unauthorized-configuration-settings-sql-server +[44]:https://www.red-gate.com/hub/product-learning/sql-prompt/problems-caused-by-use-of-the-sql_variant-datatype +[45]:http://www.seangallardy.com/error-8474-state-11-17836-state-20-9642-state-3-and-your-companys-need-to-incessantly-scan-for-vulnerable-ports/ +[46]:https://www.mssqltips.com/sqlservertip/6279/prevent-sql-server-blocking-using-locktimeout/ +[47]:https://www.sqlshack.com/sql-varchar-data-type-deep-dive/ +[48]:https://blog.waynesheffield.com/wayne/archive/2020/08/availability-group-issues-fixed-with-alerts/ +[49]:https://www.red-gate.com/simple-talk/sql/t-sql-programming/row-versioning-concurrency-in-sql-server/ +[50]:https://sqlblog.org/2020/11/05/navigating-dbcc-checkdb-for-vldb +[51]:https://www.mssqltips.com/sqlservertip/6230/memoryoptimized-tempdb-metadata-in-sql-server-2019/ +[52]:https://learn.microsoft.com/troubleshoot/sql/database-engine/database-file-operations/1450-and-665-errors-running-dbcc-checkdb -[Out of user memory quota]:https://blogs.msdn.microsoft.com/psssql/2017/06/07/you-may-see-out-of-user-memory-quota-message-in-errorlog-when-you-use-in-memory-oltp-feature/ -[Compressed backup errors and TF 3042]:https://sqlstudies.com/2017/03/16/compressed-backup-errors-and-tf-3042/ -[Logon Failure: The User has not Been Granted]:https://blog.sqlauthority.com/2017/04/14/sql-server-logon-failure-user-not-granted-requested-logon-type-computer/ [Who owns your availability groups?]:http://www.cjsommer.com/2016-10-20-who-owns-your-availability-groups/ +[Cannot Connect to SQL Server]:https://dallasdbas.com/irl-cannot-connect-to-sql-server/ +[Requested tenant identifier]:https://sqlstudies.com/2020/05/20/connecting-to-azure-sql-database-requested-tenant-identifier-00000000-0000-0000-0000-000000000000-is-not-valid/ [102_link1]:http://jasonbrimhall.info/2017/11/17/incorrect-syntax-what/ [207_link1]:http://www.sqlservercentral.com/questions/IDENT_CURRENT/165581/ -[SQL SERVER – Disabling 15000 Partitions (15k)]:https://blog.sqlauthority.com/2016/05/20/sql-server-disabling-15000-15k-partitions/ -[Nuance of datetime data type in SQL Server]:http://www.sqlservercentral.com/articles/T-SQL/153921/ +[241_link1]:https://www.essentialsql.com/datatype-conversion-in-sql-using-cast-and-convert/ +[257_link1]:https://sqlstudies.com/2020/04/16/what-is-the-datatype-sql_varient/ +[459_link1]:https://sqlquantumleap.com/2019/03/13/differences-between-the-various-binary-collations-cultures-versions-and-bin-vs-bin2/ +[535_link1]:http://www.sqlservercentral.com/articles/T-SQL/153921/ [596_link1]:http://sql-sasquatch.blogspot.ru/2017/09/sqlserver-just-how-minimal-can-that.html -[703_link1]:https://blogs.msdn.microsoft.com/psssql/2017/02/22/be-aware-of-701-error-if-you-use-memory-optimized-table-variable-in-a-loop/ -[Resolve Microsoft SQL Server Error Code 824]:http://www.sqlservercentral.com/blogs/sql-server-citation-sql-blog-by-hemantgiri-s-goswami-sql-mvp/2016/08/23/resolve-microsoft-sql-server-error-code-824/ +[650_link1]:https://sqlundercover.com/2019/02/07/alter-table-fails-on-replicated-tables-with-isolation-level-serializable-or-read-uncommitted-on-sql2012-and-earlier/ +[657_link1]:https://blog.sqlauthority.com/2016/05/20/sql-server-disabling-15000-15k-partitions/ +[665_link1]:https://dba.stackexchange.com/a/334820 +[666_link1]:https://blogs.msdn.microsoft.com/psssql/2018/02/16/uniqueifier-considerations-and-error-666/ +[701_link1]:https://blogs.msdn.microsoft.com/psssql/2017/02/22/be-aware-of-701-error-if-you-use-memory-optimized-table-variable-in-a-loop/ +[824_link1]:http://www.sqlservercentral.com/blogs/sql-server-citation-sql-blog-by-hemantgiri-s-goswami-sql-mvp/2016/08/23/resolve-microsoft-sql-server-error-code-824/ +[824_link2]:https://stevestedman.com/2018/08/checkdb-error-msg-824-level-24/ [825_link1]:https://www.sqlskills.com/blogs/paul/a-little-known-sign-of-impending-doom-error-825/ -[FIX: Error: 913, Severity: 16 – Could Not Find Database ID]:https://blog.sqlauthority.com/2017/04/10/sql-server-fix-error-913-severity-16-not-find-database-id-3-database-may-not-activated-yet-may-transition-sql-service/ -[KB2152734]:https://support.microsoft.com/en-us/kb/2152734 +[913_link1]:https://blog.sqlauthority.com/2017/04/10/sql-server-fix-error-913-severity-16-not-find-database-id-3-database-may-not-activated-yet-may-transition-sql-service/ +[922_link1]:https://blog.sqlauthority.com/2018/08/27/sql-server-how-to-drop-or-delete-suspect-database/ +[926_link1]:https://blog.sqlauthority.com/2018/11/06/sql-server-script-level-upgrade-for-database-master-failed-because-upgrade-step-msdb110_upgrade-sql-encountered-error-926-state-1-severity-25/ +[KB2152734]:https://support.microsoft.com/help/2152734 +[1065_link1]:https://www.mssqltips.com/sqlservertip/2470/understanding-the-sql-server-nolock-hint/ +[1105_link1]:https://www.joshthecoder.com/2019/07/17/can-you-fail-to-spill-to-tempdb.html [1701_link1]:http://www.sqlservercentral.com/questions/163450/ -[CREATE DATABASE – I’ve not seen that before.]:http://www.sqlservercentral.com/blogs/martin_catherall/2017/01/22/create-database-ive-not-seen-that-before/ -[SQL SERVER - Fix: Error: Msg 1904]:http://blog.sqlauthority.com/2016/10/27/sql-server-fix-error-msg-1904-statistics-table-65-columns-key-list/ -[KB290787]:https://support.microsoft.com/en-us/kb/290787 +[1807_link1]:http://www.sqlservercentral.com/blogs/martin_catherall/2017/01/22/create-database-ive-not-seen-that-before/ +[1904_link1]:http://blog.sqlauthority.com/2016/10/27/sql-server-fix-error-msg-1904-statistics-table-65-columns-key-list/ +[KB290787]:https://support.microsoft.com/help/290787 +[2709_link1]:https://www.brentozar.com/archive/2018/04/an-odd-case-of-blocking/ [3041_link1]:https://www.sqlservercentral.com/Forums/Topic1179720-1550-1.aspx [3101_link1]:https://sqlstudies.com/2017/11/27/closing-all-of-the-connections-to-a-database/ +[3154_link1]:http://www.patrickkeisler.com/2016/05/database-restore-fails-with-msg-3154.html +[3241_link1]:https://blogs.msdn.microsoft.com/psssql/2017/04/12/unable-to-restore-a-backup-msg-3241/ [3314_link1]:https://www.sqlskills.com/blogs/paul/20122014-bug-that-can-cause-database-or-server-to-go-offline/ [3634_link1]:https://sqlundercover.com/2017/08/29/restores-using-invalid-backup-default-locations/ +[3637_link1]:https://blog.sqlauthority.com/2019/02/25/sql-server-fix-3637-a-parallel-operation-cannot-be-started-from-a-dac-connection/ [3743_link1]:https://blog.sqlauthority.com/2017/12/05/sql-server-msg-3743-database-enabled-database-mirroring-database-mirroring-must-removed-drop-database/ +[3906_link1]:https://thelonedba.wordpress.com/2019/03/03/failed-update-read-only-database-backup/ [3930_link1]:http://michaeljswart.com/2017/01/case-study-troubleshooting-doomed-transactions/ [4064_link1]:https://blog.sqlauthority.com/2008/11/04/sql-server-fix-error-4064-cannot-open-user-default-database-login-failed-login-failed-for-user/ -[SQL Server 2016 Online ALTER COLUMN Operation]:https://www.mssqltips.com/sqlservertip/4749/sql-server-2016-online-alter-column-operation/ -[Database Restore Fails with Msg 3154]:http://www.patrickkeisler.com/2016/05/database-restore-fails-with-msg-3154.html -[Unable to restore a backup – Msg 3241]:https://blogs.msdn.microsoft.com/psssql/2017/04/12/unable-to-restore-a-backup-msg-3241/ +[4353_link1]:https://blog.sqlauthority.com/2019/05/24/sql-server-fix-msg-4353-conflicting-file-relocations-have-been-specified-for-file-only-a-single-with-move-clause-should-be-specified-for-any-logical-file-name/ +[4922_link1]:https://www.mssqltips.com/sqlservertip/4749/sql-server-2016-online-alter-column-operation/ +[4934_link1]:https://www.brentozar.com/archive/2018/04/an-odd-case-of-blocking/ [SQL SERVER - FIX Error 5120]:http://blog.sqlauthority.com/2016/10/26/sql-server-fix-error-5120-database-read-mode-attaching-files/ +[5004_link1]:https://www.scarydba.com/2019/02/11/query-store-and-a-read_only-database/ +[5061_link1]:https://sqlstudies.com/2020/06/11/end-an-alter-database-immediately-if-anyone-is-in-the-database/ [5123_link1]:https://blogs.msdn.microsoft.com/sql_pfe_blog/2016/11/10/tempdb-misconfiguration-when-sql-server-fails-to-create-a-secondary-data-file/ [5123_link2]:https://blog.sqlauthority.com/2017/09/21/sql-server-fix-msg-5123-level-16-create-file-encountered-operating-system-error-5/ +[5846_link1]:https://bornsql.ca/blog/proposed-sql-server-defaults-disable-lightweight-pooling/ [6335_link1]:https://www.brentozar.com/archive/2017/06/biggest-query-plans-dont-show-dmvs/ -[Discuss Execute(SQL) At LinkedServer]:http://www.sqlservercentral.com/blogs/powersql-by-prashanth-jayaram/2016/11/09/sql-server-discuss-executesql-at-linkedserver/ +[8624_link1]:http://www.sqlservercentral.com/articles/Indexing/149879/ +[8645_link1]:https://orderbyselectnull.com/2019/04/16/sql-server-2017-cu14-change-to-cci-insert-memory-time-out-behavior/ [8651_link1]:https://blobeater.blog/2017/05/18/setting-sql-server-max-memory-dangerously-low/ [8672_link1]:https://blog.sqlauthority.com/2017/03/13/sql-server-fix-error-msg-8672-merge-statement-attempted-update-delete-row/ [8909_link1]:https://www.sqlskills.com/blogs/paul/disaster-recovery-101-object-id-0-index-id-1-partition-id-0/ [8921_link1]:https://www.sqlskills.com/blogs/paul/disaster-recovery-101-fixing-a-broken-system-table-page/ -[9002_link1]:https://docs.microsoft.com/en-us/sql/relational-databases/logs/troubleshoot-a-full-transaction-log-sql-server-error-9002 +[9002_link3]:https://www.sqlserverscience.com/internals/adding-new-transaction-log-file-when-existing-log-full/ +[10314_link1]:https://www.sqlskills.com/blogs/paul/the-curious-case-of-the-clr-assembly-failure-after-an-ag-failover/ +[10314_link2]:https://www.sqlservercentral.com/articles/do-not-set-trustwority-on-for-the-ssisdb-catalog +[10794_link2]:https://www.brentozar.com/archive/2020/07/remember-nothing-stops-a-hekaton-transaction-yeah-about-that/ +[13609_link1]:https://itsalljustelectrons.blogspot.com/2019/05/Splitting-Strings-With-OPENJSON.html +[13570_link1]:https://www.mssqltips.com/sqlservertip/5281/sql-server-replication-for-temporal-tables/ [15002_link1]:https://blogs.msdn.microsoft.com/luti/2017/05/17/sql-server-offline-after-applying-service-pack/ -[Internal Query Processor Error with ColumnStore Indexes]:http://www.sqlservercentral.com/articles/Indexing/149879/ -[Unable to drop a user in a database]:https://blogs.msdn.microsoft.com/psssql/2016/11/15/unable-to-drop-a-user-in-a-database/ -[TCP Port Is Already In Use]:https://blogs.msdn.microsoft.com/sql_pfe_blog/2016/10/05/tcp-port-is-already-in-use/ +[15021_link1]:https://nebraskasql.blogspot.com/2018/10/invalid-value-given-for-parameter.html +[15136_link1]:https://blogs.msdn.microsoft.com/psssql/2016/11/15/unable-to-drop-a-user-in-a-database/ +[15190_link1]:https://blog.sqlauthority.com/2018/12/15/sql-server-fix-msg-15190-there-are-still-remote-logins-or-linked-logins-for-the-server/ +[15274_link1]:https://blog.sqlauthority.com/2019/06/03/sql-server-fix-msg-15274-access-to-the-remote-server-is-denied-because-the-current-security-context-is-not-trusted/ +[15404_link1]:https://sqlstudies.com/2020/05/06/could-not-obtain-information-about-windows-nt-group-user/ +[17051_link1]:https://www.brentozar.com/archive/2020/06/how-to-upgrade-sql-server-evaluation-edition-to-developer-edition/ [17190_link1]:https://www.sqlskills.com/blogs/jonathan/using-group-managed-service-accounts-for-sql-server/ +[17300_link1]:https://blog.sqlauthority.com/2018/08/16/sql-server-error-17300-the-error-is-printed-in-terse-mode-because-there-was-error-during-formatting/ +[18054_link1]:https://sqlstudies.com/2019/07/24/custom-error-messages/ [18272_link1]:https://sqlundercover.com/2017/08/29/restores-using-invalid-backup-default-locations/ -[Login from an Untrusted Domain]:http://jasonbrimhall.info/2016/11/08/login-from-an-untrusted-domain-back-to-basics/ -[Why won’t my SQL Logins work?]:https://sqlstudies.com/2017/01/12/why-wont-my-sql-logins-work/ +[18401_link1]:https://blog.sqlauthority.com/2019/05/20/sql-server-fix-error-login-failed-for-user-reason-server-is-in-script-upgrade-mode-only-administrator-can-connect-at-this-time-microsoft-sql-server-error-18401/ +[18452_link1]:http://jasonbrimhall.info/2016/11/08/login-from-an-untrusted-domain-back-to-basics/ +[18456_link1]:https://sqlstudies.com/2017/01/12/why-wont-my-sql-logins-work/ +[20598_link1]:https://support.microsoft.com/help/3066750 +[22911_link1]:https://www.sqlshack.com/sql-server-filestream-with-change-data-capture/ +[25713_link1]:https://sqlquantumleap.com/2018/01/22/server-audit-mystery-filtering-class_type-gets-error-msg-25713/ +[25713_link2]:https://sqlquantumleap.com/2018/01/30/server-audit-mystery-filtering-action_id-gets-error-msg-25713/ +[33111_link1]:https://sqlundercover.com/2018/04/04/encrypting-sql-server-database-backups/ [35250_link1]:https://blog.sqlauthority.com/2017/05/18/sql-server-fix-msg-35250-level-16-state-7-connection-primary-replica-not-active-command-cannot-processed/ +[35217_link1]:https://www.seangallardy.com/error-35217-and-availability-groups-smh/ +[41121_link1]:https://joshthecoder.com/2020/06/22/a-bug-with-ag-health-checks.html +[41922_link1]:http://timradney.com/2020/05/23/updated-default-settings-for-azure-sql-managed-instance-databases/ diff --git a/Extended_Events/ADS_Standard_Azure.sql b/Extended_Events/ADS_Standard_Azure.sql new file mode 100644 index 00000000..a882b8b1 --- /dev/null +++ b/Extended_Events/ADS_Standard_Azure.sql @@ -0,0 +1,31 @@ +/* +Original link: https://sqlperformance.com/2020/04/sql-performance/bandwidth-friendly-query-profiling-azure-sql-database +Author: Greg Gonzalez +*/ + +ALTER EVENT SESSION [ADS_Standard_Azure] ON DATABASE +DROP EVENT sqlserver.attention, +DROP EVENT sqlserver.existing_connection, +DROP EVENT sqlserver.login, +DROP EVENT sqlserver.logout, +DROP EVENT sqlserver.rpc_completed, +DROP EVENT sqlserver.sql_batch_completed, +DROP EVENT sqlserver.sql_batch_starting +GO + +ALTER EVENT SESSION [ADS_Standard_Azure] ON DATABASE +ADD EVENT sqlserver.rpc_completed( +ACTION(package0.event_sequence,sqlserver.client_app_name,sqlserver.client_pid,sqlserver.database_id,sqlserver.query_hash,sqlserver.session_id,sqlserver.username) + WHERE (([package0].[equal_boolean]([sqlserver].[is_system],(0))) AND ([duration] >= (1000000)))), +ADD EVENT sqlserver.sql_batch_completed( +ACTION(package0.event_sequence,sqlserver.client_app_name,sqlserver.client_pid,sqlserver.database_id,sqlserver.query_hash,sqlserver.session_id,sqlserver.username) + WHERE (([package0].[equal_boolean]([sqlserver].[is_system],(0))) AND ([duration] >= (1000000)))) +GO + +ALTER EVENT SESSION [ADS_Standard_Azure] ON DATABASE +DROP TARGET package0.ring_buffer +GO + +ALTER EVENT SESSION [ADS_Standard_Azure] ON DATABASE +ADD TARGET package0.ring_buffer(SET max_events_limit=(10),max_memory=(51200)) +GO diff --git a/Extended_Events/AppExecutionTimeout.sql b/Extended_Events/AppExecutionTimeout.sql new file mode 100644 index 00000000..2117eb4d --- /dev/null +++ b/Extended_Events/AppExecutionTimeout.sql @@ -0,0 +1,34 @@ +/* +Original link: http://blog.sqlgrease.com/how-to-detect-query-timeout-errors-with-extended-events/ +Author: Franklin Yamamoto + +SELECT + object_name + , convert(xml, event_data) AS event_data + , file_name + , file_offset +FROM sys.fn_xe_file_target_read_file(N'AppExecutionTimeout*.xel',NULL,NULL,NULL); +GO +*/ + +/* Stop trace if started */ +IF EXISTS (SELECT * FROM sys.dm_xe_sessions WHERE name = 'AppExecutionTimeout') + ALTER EVENT SESSION AppExecutionTimeout ON SERVER STATE = STOP; + +/* Delete trace if exists */ +IF EXISTS (SELECT * FROM sys.server_event_sessions WHERE name = 'AppExecutionTimeout') + DROP EVENT SESSION AppExecutionTimeout ON SERVER; + +/* Create trace */ +CREATE EVENT SESSION AppExecutionTimeout ON SERVER +ADD EVENT sqlserver.attention +(ACTION (sqlserver.session_id, sqlserver.database_id, sqlserver.database_name, +sqlserver.username, sqlserver.sql_text, sqlserver.client_hostname, +sqlserver.client_app_name) +WHERE ([package0].[equal_boolean]([sqlserver].[is_system],(0)))) +ADD TARGET package0.event_file(SET filename=N'AppExecutionTimeout.xel', +max_file_size=(5),max_rollover_files=(2)); +GO + +ALTER EVENT SESSION AppExecutionTimeout ON SERVER STATE = START; +GO diff --git a/Extended_Events/AuditFileSize.sql b/Extended_Events/AuditFileSize.sql new file mode 100644 index 00000000..f0cb9888 --- /dev/null +++ b/Extended_Events/AuditFileSize.sql @@ -0,0 +1,56 @@ +/* +Original link: https://jasonbrimhall.info/2019/06/25/database-file-changes/ +Source link: https://github.com/ktaranov/sqlserver-kit/blob/master/Extended_Events/AuditFileSize.sql +Author: Phil Factor + +*/ + +USE master; +GO +-- Create the Event Session +IF EXISTS ( SELECT * + FROM sys.server_event_sessions + WHERE name = 'AuditFileSize' ) + DROP EVENT SESSION AuditFileSize + ON SERVER; +GO + +CREATE EVENT SESSION AuditFileSize ON SERVER +ADD EVENT sqlserver.database_file_size_change ( --good + ACTION ( sqlserver.database_id, sqlserver.session_id, + sqlserver.database_name, sqlserver.client_hostname, sqlserver.sql_text, + sqlserver.nt_username, sqlserver.username, sqlserver.session_nt_username, + sqlserver.client_app_name, sqlserver.context_info, + sqlserver.client_connection_id ) + ), +ADD EVENT sqlserver.databases_shrink_data_movement ( --good + ACTION ( sqlserver.database_id, sqlserver.session_id, + sqlserver.database_name, sqlserver.client_hostname, sqlserver.sql_text, + sqlserver.nt_username, sqlserver.username, sqlserver.session_nt_username, + sqlserver.client_app_name, sqlserver.context_info, + sqlserver.client_connection_id ) + ), +ADD EVENT sqlserver.databases_log_file_used_size_changed ( --good --this is a very chatty event and may be left off + ACTION ( sqlserver.database_id, sqlserver.session_id, + sqlserver.database_name, sqlserver.client_hostname, sqlserver.sql_text, + sqlserver.nt_username, sqlserver.username, sqlserver.session_nt_username, + sqlserver.client_app_name, sqlserver.context_info, + sqlserver.client_connection_id ) + ), +ADD EVENT sqlserver.databases_log_shrink ( --good + ACTION ( sqlserver.database_id, sqlserver.session_id, + sqlserver.database_name, sqlserver.client_hostname, sqlserver.sql_text, + sqlserver.nt_username, sqlserver.username, sqlserver.session_nt_username, + sqlserver.client_app_name, sqlserver.context_info, + sqlserver.client_connection_id ) + ) +ADD TARGET package0.event_file ( + SET filename = 'c:\XE\AuditFileSize.xel' + , max_file_size = 5 + , max_rollover_files = 4 ) +WITH ( MAX_MEMORY = 4 MB + , EVENT_RETENTION_MODE = ALLOW_SINGLE_EVENT_LOSS + , TRACK_CAUSALITY = ON + , MAX_DISPATCH_LATENCY = 1 SECONDS + , STARTUP_STATE = ON ); +GO diff --git a/Extended_Events/AutoTuneMonitor.sql b/Extended_Events/AutoTuneMonitor.sql new file mode 100644 index 00000000..2d62826f --- /dev/null +++ b/Extended_Events/AutoTuneMonitor.sql @@ -0,0 +1,84 @@ +/* +https://jasonbrimhall.info/2019/01/04/automatic-tuning-monitoring-and-diagnostics/ +Author: Jason Brimhall +*/ + +USE master; +GO +-- Create the Event Session +IF EXISTS +( + SELECT * + FROM sys.server_event_sessions + WHERE name = 'AutoTuneMonitor' +) + DROP EVENT SESSION AutoTuneMonitor ON SERVER; +GO + +CREATE EVENT SESSION [AutoTuneMonitor] +ON SERVER + ADD EVENT qds.automatic_tuning_config_change + (ACTION + ( + sqlserver.database_id, + sqlserver.nt_username, + sqlserver.sql_text, + sqlserver.username, + sqlserver.session_nt_username, + sqlserver.client_app_name, + sqlserver.session_id, + sqlserver.client_hostname + ) + ), + ADD EVENT qds.automatic_tuning_diagnostics + (ACTION + ( + sqlserver.database_id, + sqlserver.nt_username, + sqlserver.sql_text, + sqlserver.username, + sqlserver.session_nt_username, + sqlserver.client_app_name, + sqlserver.session_id, + sqlserver.client_hostname + ) + ), + ADD EVENT qds.automatic_tuning_state_change + (ACTION + ( + sqlserver.database_id, + sqlserver.nt_username, + sqlserver.sql_text, + sqlserver.username, + sqlserver.session_nt_username, + sqlserver.client_app_name, + sqlserver.session_id, + sqlserver.client_hostname + ) + ), + ADD EVENT qds.automatic_tuning_error + (ACTION + ( + sqlserver.database_id, + sqlserver.nt_username, + sqlserver.sql_text, + sqlserver.username, + sqlserver.session_nt_username, + sqlserver.client_app_name, + sqlserver.session_id, + sqlserver.client_hostname + ) + ) + ADD TARGET package0.event_file + (SET filename = N'C:\XE\AutoTuneMonitor.xel'), + ADD TARGET package0.ring_buffer +WITH +( + MAX_DISPATCH_LATENCY = 5 SECONDS, + TRACK_CAUSALITY = ON, + STARTUP_STATE = OFF +); +GO + +ALTER EVENT SESSION [AutoTuneMonitor] ON SERVER STATE = START; +GO \ No newline at end of file diff --git a/Extended_Events/CheckpointTracking.sql b/Extended_Events/CheckpointTracking.sql new file mode 100644 index 00000000..b697cc53 --- /dev/null +++ b/Extended_Events/CheckpointTracking.sql @@ -0,0 +1,59 @@ +/* +Original link: https://www.sqlserverscience.com/extended-events/checkpoint-tracking-via-extended-events/ +Author: Max Vernon +*/ + +IF NOT EXISTS ( /* only create this session if one doesn't already exist + to prevent inadvertant loss of events. + */ + SELECT 1 + FROM sys.server_event_sessions ss + WHERE ss.name = N'CheckpointTracking' + ) +BEGIN + CREATE EVENT SESSION CheckpointTracking + ON SERVER + ADD EVENT sqlserver.checkpoint_begin + ( + ACTION + ( + package0.callstack + , package0.collect_system_time + , package0.event_sequence + , sqlserver.client_app_name + , sqlserver.client_hostname + , sqlserver.database_id + , sqlserver.database_name + , sqlserver.is_system + , sqlserver.session_id + , sqlserver.session_nt_username + , sqlserver.sql_text + ) + ) + , ADD EVENT sqlserver.checkpoint_end + ( + ACTION + ( + package0.callstack + , package0.collect_system_time + , package0.event_sequence + , sqlserver.client_app_name + , sqlserver.client_hostname + , sqlserver.database_id + , sqlserver.database_name + , sqlserver.is_system + , sqlserver.session_id + , sqlserver.session_nt_username + , sqlserver.sql_text + ) + ) + ADD TARGET package0.ring_buffer + ( + SET max_memory = 10240 + ) + WITH (STARTUP_STATE=OFF); +END +GO +ALTER EVENT SESSION CheckpointTracking +ON SERVER +STATE = START; diff --git a/Extended_Events/ConfigurationItemsChanged.sql b/Extended_Events/ConfigurationItemsChanged.sql new file mode 100644 index 00000000..50c2f1d5 --- /dev/null +++ b/Extended_Events/ConfigurationItemsChanged.sql @@ -0,0 +1,85 @@ +/* +Original link: https://www.red-gate.com/hub/product-learning/sql-monitor/spotting-unauthorized-configuration-settings-sql-server +Source link: https://github.com/ktaranov/sqlserver-kit/blob/master/Extended_Events/ConfigurationItemsChanged.sql +Author: Phil Factor + + +SELECT + CONVERT(datetime2, + SwitchOffset(CONVERT(datetimeoffset,xed.event_data.value('(@timestamp)[1]', 'datetime2')), + DateName(TzOffset, SYSDATETIMEOFFSET()))) AS datetime_local, + xed.event_data.value('(data[@name="error_number"]/value)[1]', 'int') AS [Error_Number], + xed.event_data.value('(data[@name="severity"]/value)[1]', 'int') AS Severity, + xed.event_data.value('(data[@name="message"]/value)[1]', 'varchar(255)') AS [Message], + xed.event_data.value('(action[@name="username"]/value)[1]', 'varchar(255)') AS UserName, + xed.event_data.value('(action[@name="nt_username"]/value)[1]', 'varchar(255)') AS NT_Username, + xed.event_data.value('(action[@name="sql_text"]/value)[1]', 'nvarchar(max)') AS SQL_Text, + xed.event_data.value('(action[@name="database_name"]/value)[1]', 'varchar(255)') AS [Database_Name], + xed.event_data.value('(action[@name="client_connection_id"]/value)[1]', 'varchar(255)') AS client_conn, + xed.event_data.value('(action[@name="client_app_name"]/value)[1]', 'varchar(255)') AS client_app_name +FROM @Target_Data.nodes('//RingBufferTarget/event') AS xed (event_data); + +EXEC sp_configure 'show advanced options',1; +RECONFIGURE; +GO +EXEC sp_configure 'CLR Enabled',1; +EXEC sp_configure 'Ad Hoc Distributed Queries',1; +EXEC sp_configure 'Cross DB Ownership Chaining',1; +EXEC sp_configure 'Database Mail XPs',1; +EXEC sp_configure 'Ole Automation Procedures',1; +EXEC sp_configure 'Remote ACCESS',1; +EXEC sp_configure 'Remote Admin Connections',1; +EXEC sp_configure 'Scan for Startup Procs',1; +RECONFIGURE -- To update the currently configured value for advanced options. +GO + +/* this code turns OFF some of the configuration items with security issues */ +EXEC sp_configure 'show advanced options',1; +RECONFIGURE; +GO +EXEC sp_configure 'Ad Hoc Distributed Queries',0; +EXEC sp_configure 'CLR ENABLED',0; +EXEC sp_configure 'Cross DB Ownership Chaining',0; +EXEC sp_configure 'Database Mail XPs',0; +EXEC sp_configure 'Ole Automation Procedures',0; +EXEC sp_configure 'Remote ACCESS',0; +EXEC sp_configure 'Remote Admin Connections',0; +EXEC sp_configure 'Scan for Startup Procs',0; +EXEC sp_configure 'show advanced options',0; +RECONFIGURE; -- To update the currently configured value for advanced options. +GO +*/ + +USE master; +GO + +IF EXISTS --if the session already exists, then delete it. We are assuming you've changed something + ( + SELECT * FROM sys.server_event_sessions + WHERE server_event_sessions.name = 'ConfigurationItemsChanged' + ) + DROP EVENT SESSION ConfigurationItemsChanged ON SERVER; +GO +CREATE EVENT SESSION ConfigurationItemsChanged -- the name of the session +ON SERVER + ADD EVENT sqlserver.error_reported --just the one event + (ACTION + ( + sqlserver.client_app_name, sqlserver.client_connection_id, + sqlserver.database_name, sqlserver.nt_username, sqlserver.sql_text, + sqlserver.username --all these are useful for tracking an error + ) + WHERE (([error_number]=(15457)) OR ([error_number]=(5084))) + ) + ADD TARGET package0.ring_buffer /* we will write it to a ring buffer target only */ + (SET max_memory = (4096)) +WITH + ( + MAX_MEMORY = 4096KB, EVENT_RETENTION_MODE = ALLOW_SINGLE_EVENT_LOSS, + MAX_DISPATCH_LATENCY = 30 SECONDS, MAX_EVENT_SIZE = 0KB, + MEMORY_PARTITION_MODE = NONE, TRACK_CAUSALITY = OFF, STARTUP_STATE = ON + ); +GO + +ALTER EVENT SESSION ConfigurationItemsChanged ON SERVER STATE = START; +GO diff --git a/Extended_Events/DBRecoveryProgress.sql b/Extended_Events/DBRecoveryProgress.sql new file mode 100644 index 00000000..a18d256c --- /dev/null +++ b/Extended_Events/DBRecoveryProgress.sql @@ -0,0 +1,116 @@ +/* +Original link: https://www.sqlservercentral.com/blogs/database-recovery-monitoring-with-xe +Source link: https://github.com/ktaranov/sqlserver-kit/blob/master/Extended_Events/DBRecoveryProgress.sql +Author: Jason Brimhall +*/ + +USE master; +GO +-- Create the Event Session +IF EXISTS +( + SELECT + * + FROM sys.server_event_sessions + WHERE name = 'DBRecoveryProgress' +) + DROP EVENT SESSION DBRecoveryProgress ON SERVER; +GO + +CREATE EVENT SESSION DBRecoveryProgress + ON SERVER + ADD EVENT sqlserver.database_recovery_progress_report + (ACTION + ( + /* yes this may be overkill on the actions - it is for discovery*/ + sqlserver.database_id + , sqlserver.session_id + , sqlserver.database_name + , sqlserver.tsql_stack + , package0.event_sequence + , sqlserver.sql_text + , sqlserver.nt_username + , sqlserver.username + , sqlserver.session_nt_username + , sqlserver.client_app_name + , sqlserver.context_info + , sqlserver.client_connection_id + , sqlserver.query_hash + , sqlserver.query_plan_hash + , package0.callstack + ) + ) + , ADD EVENT sqlserver.database_recovery_trace + (ACTION + ( + sqlserver.database_id + , sqlserver.session_id + , sqlserver.database_name + , sqlserver.tsql_stack + , package0.event_sequence + , sqlserver.sql_text + , sqlserver.nt_username + , sqlserver.username + , sqlserver.session_nt_username + , sqlserver.client_app_name + , sqlserver.context_info + , sqlserver.client_connection_id + , sqlserver.query_hash + , sqlserver.query_plan_hash + , package0.callstack + ) + ) + , ADD EVENT sqlserver.database_recovery_times + (ACTION + ( + sqlserver.database_id + , sqlserver.session_id + , sqlserver.database_name + , sqlserver.tsql_stack + , package0.event_sequence + , sqlserver.sql_text + , sqlserver.nt_username + , sqlserver.username + , sqlserver.session_nt_username + , sqlserver.client_app_name + , sqlserver.context_info + , sqlserver.client_connection_id + , sqlserver.query_hash + , sqlserver.query_plan_hash + , package0.callstack + ) + ) + , ADD EVENT sqlserver.database_recovery_lsn_report + (ACTION + ( + sqlserver.database_id + , sqlserver.session_id + , sqlserver.database_name + , sqlserver.tsql_stack + , package0.event_sequence + , sqlserver.sql_text + , sqlserver.nt_username + , sqlserver.username + , sqlserver.session_nt_username + , sqlserver.client_app_name + , sqlserver.context_info + , sqlserver.client_connection_id + , sqlserver.query_hash + , sqlserver.query_plan_hash + , package0.callstack + ) + ) + ADD TARGET package0.event_file + (SET filename = 'c:\Windows\Temp\DatabaseXEDBRecoveryProgress.xel', max_file_size = 5, max_rollover_files = 4) + WITH + ( + MAX_MEMORY = 4MB + , EVENT_RETENTION_MODE = ALLOW_SINGLE_EVENT_LOSS + , TRACK_CAUSALITY = ON + , MAX_DISPATCH_LATENCY = 5 SECONDS + , STARTUP_STATE = ON + ); +GO + +ALTER EVENT SESSION DBRecoveryProgress ON SERVER STATE = START; +GO diff --git a/Extended_Events/FileSizeChanges.sql b/Extended_Events/FileSizeChanges.sql new file mode 100644 index 00000000..9adcef3f --- /dev/null +++ b/Extended_Events/FileSizeChanges.sql @@ -0,0 +1,106 @@ +/* +Original link: https://sqlperformance.com/2020/04/extended-events/removing-default-trace-2 +Author: Aaron Bertrand + +WITH FileInfo(XEPath) AS + ( + SELECT LEFT(BasePath,COALESCE(NULLIF(CHARINDEX(SessName,BasePath)-1,-1),0)) + SessName + N'*.xel' + FROM + ( + SELECT xmlsrc.data.value(N'(@name)[1]', N'nvarchar(max)'), SessName + FROM + ( + SELECT CONVERT(xml,target_data), s.[name] + FROM sys.dm_xe_session_targets AS t + INNER JOIN sys.dm_xe_sessions AS s + ON s.[address] = t.event_session_address + WHERE s.[name] = N'FileSizeChanges' + ) AS xefile (TargetData, SessName) + CROSS APPLY TargetData.nodes(N'//EventFileTarget/File') AS xmlsrc(data) + ) AS InnerData(BasePath, SessName) + ), + SessionData([EventData]) AS + ( + SELECT CONVERT(xml, TargetData.event_data) FROM FileInfo CROSS APPLY + sys.fn_xe_file_target_read_file(FileInfo.XEPath, NULL, NULL, NULL) AS TargetData + ), + src AS + ( + SELECT + EndTimeUTC = x.d.value(N'(@timestamp)[1]', N'datetime2'), + DatabaseID = x.d.value(N'(data [@name="database_id"]/value)[1]', N'int'), + [FileName] = x.d.value(N'(data [@name="file_name"]/value)[1]', N'sysname'), + Duration = x.d.value(N'(data [@name="duration"]/value)[1]', N'int'), + FileType = x.d.value(N'(data [@name="file_type"]/text)[1]', N'varchar(4)'), + Culprit = x.d.value(N'(action[@name="sql_text"]/value)[1]', N'nvarchar(max)'), + IsAutomatic = x.d.value(N'(data [@name="is_automatic"]/value)[1]', N'varchar(5)'), + ChangeKB = x.d.value(N'(data [@name="size_change_kb"]/value)[1]', N'bigint'), + Principal = x.d.value(N'(action[@name="server_principal_name"]/value)[1]', N'sysname'), + username = x.d.value(N'(action[@name="username"]/value)[1]', N'sysname'), + AppName = x.d.value(N'(action[@name="client_app_name"]/value)[1]', N'sysname'), + HostName = x.d.value(N'(action[@name="client_hostname"]/value)[1]', N'sysname') + --, [EventData] -- raw XML to troubleshoot specific events + FROM SessionData CROSS APPLY EventData.nodes('/event') AS x(d) + ) + SELECT + DatabaseName = DB_NAME(DatabaseID), + [FileName], + DurationSeconds = CONVERT(decimal(18,3),Duration/1000000.0), + StartTimeUTC = CONVERT(datetime2(3), DATEADD(MICROSECOND, -Duration, EndTimeUTC)), + EndTimeUTC = CONVERT(datetime2(3), EndTimeUTC), + FileType, + Culprit = CASE WHEN Culprit IS NULL AND AppName LIKE N'Repl%' + THEN AppName ELSE Culprit END, + IsAutomatic, + ChangeMB = CONVERT(decimal(18,3), ChangeKB / 1024.0), + Principal = COALESCE([Principal], COALESCE(NULLIF(username,N''),N'?')), + HostName, + App = CASE WHEN AppName LIKE N'%Management Studio%Query%' + THEN N'SSMS - Query Window' + WHEN AppName LIKE N'%Management Studio%' + THEN N'SSMS - GUI!' + ELSE AppName END--, [EventData] -- raw XML to troubleshoot specific events + FROM src; +*/ + +/* Create trace */ +DECLARE @path nvarchar(max) = (SELECT REVERSE(SUBSTRING(p, CHARINDEX(N'\', p), 4000)) + FROM (SELECT REVERSE((CONVERT(nvarchar(max), SERVERPROPERTY(N'ErrorLogFileName'))))) AS s(p)); + +IF EXISTS (SELECT 1 FROM sys.dm_xe_sessions WHERE name = N'FileSizeChanges') +BEGIN + EXEC sys.sp_executesql N'DROP EVENT SESSION FileSizeChanges ON SERVER;'; +END + +DECLARE @sql nvarchar(max) = N' CREATE EVENT SESSION FileSizeChanges ON SERVER +ADD EVENT sqlserver.database_file_size_change +( + ACTION + ( + sqlserver.sql_text, + sqlserver.client_app_name, + sqlserver.client_hostname, + sqlserver.username, + sqlserver.server_principal_name + ) +) +ADD TARGET package0.event_file +( + SET filename = ''' + @path + N'FileSizeChanges.xel'', + MAX_FILE_SIZE = 100, -- MB + MAX_ROLLOVER_FILES = 100 -- 100 MB x 100 = max 10 GB +) +WITH +( + MAX_MEMORY = 8192 KB, + EVENT_RETENTION_MODE = ALLOW_SINGLE_EVENT_LOSS, + MAX_DISPATCH_LATENCY = 30 SECONDS, + MAX_EVENT_SIZE = 0 KB, + TRACK_CAUSALITY = OFF, + STARTUP_STATE = ON +); + +ALTER EVENT SESSION FileSizeChanges ON SERVER STATE = START;'; + +EXEC sys.sp_executesql @sql; +GO diff --git a/Extended_Events/ImplicitConversionOnly.sql b/Extended_Events/ImplicitConversionOnly.sql new file mode 100644 index 00000000..863483e5 --- /dev/null +++ b/Extended_Events/ImplicitConversionOnly.sql @@ -0,0 +1,21 @@ +/* +Original link: https://www.scarydba.com/2018/10/15/using-extended-events-to-capture-implicit-conversions/ +Author: Grant Fritchey +*/ +-- If the Event Session exists DROP it +IF EXISTS (SELECT 1 +FROM sys.server_event_sessions +WHERE name = N'ImplicitConversionOnly') + DROP EVENT SESSION ImplicitConversionOnly ON SERVER; + +CREATE EVENT SESSION ImplicitConversionOnly +ON SERVER +ADD EVENT sqlserver.plan_affecting_convert +(ACTION (sqlserver.sql_text) +-- WHERE (sqlserver.equal_i_sql_unicode_string(sqlserver.database_name, N'AdventureWorks2017')) +) +ADD TARGET package0.event_file +(SET filename = N'ImplicitConversionOnly'); + +ALTER EVENT SESSION ImplicitConversionOnly ON SERVER STATE = START; +GO diff --git a/Extended_Events/InvestigateWaitsMaxDop.sql b/Extended_Events/InvestigateWaitsMaxDop.sql new file mode 100644 index 00000000..ebe0dc89 --- /dev/null +++ b/Extended_Events/InvestigateWaitsMaxDop.sql @@ -0,0 +1,53 @@ +/* +Original link: https://www.sqlskills.com/blogs/paul/who-is-overriding-maxdop-1-on-the-instance/ +Author: Paul Randal + +-- Get parallel plan with trace flag https://github.com/ktaranov/sqlserver-kit/blob/master/SQL%20Server%20Trace%20Flag.md#8649 +SELECT * FROM AdventureWorks2012.Sales.SalesOrderDetail WHERE OrderQty > 1000 OPTION (MAXDOP 8, QUERYTRACEON 8649); +GO + +SELECT + [data1].[value] ('(./@timestamp)[1]', 'datetime') AS [Time], + [data1].[value] ('(./data[@name="dop"]/value)[1]', 'INT') AS [DOP], + [data1].[value] ('(./action[@name="client_hostname"]/value)[1]', 'VARCHAR(MAX)') AS [Host], + [data1].[value] ('(./action[@name="nt_username"]/value)[1]', 'VARCHAR(MAX)') AS [User], + [data1].[value] ('(./action[@name="sql_text"]/value)[1]','VARCHAR(MAX)') AS [Statement] +FROM ( + SELECT CONVERT (XML, [target_data]) AS data + FROM sys.dm_xe_session_targets [xst] + INNER JOIN sys.dm_xe_sessions [xs] + ON [xst].[event_session_address] = [xs].[address] + WHERE [xs].[name] = N'InvestigateWaitsMaxDop') AS t +CROSS APPLY data.nodes('//event') n (data1); +GO +*/ + +/* Stop trace if started */ +IF EXISTS (SELECT * FROM sys.dm_xe_sessions WHERE name = 'InvestigateWaitsMaxDop') + ALTER EVENT SESSION InvestigateWaitsMaxDop ON SERVER STATE = STOP; + +/* Delete trace if exists */ +IF EXISTS (SELECT * FROM sys.server_event_sessions WHERE name = 'InvestigateWaitsMaxDop') + DROP EVENT SESSION InvestigateWaitsMaxDop ON SERVER; + +/* Create trace */ +CREATE EVENT SESSION InvestigateWaitsMaxDop ON SERVER +ADD EVENT sqlserver.degree_of_parallelism +( + ACTION ( + sqlserver.client_hostname, + sqlserver.nt_username, + sqlserver.sql_text) + WHERE dop > 1 /* parallel plans */ +) +ADD TARGET package0.ring_buffer +WITH ( + MAX_MEMORY = 50 MB, + MAX_DISPATCH_LATENCY = 5 SECONDS +); +GO + +/* Start trace +ALTER EVENT SESSION InvestigateWaitsMaxDop ON SERVER STATE = START; +GO +*/ diff --git a/Extended_Events/LinkedServerMonitor.sql b/Extended_Events/LinkedServerMonitor.sql new file mode 100644 index 00000000..2096622b --- /dev/null +++ b/Extended_Events/LinkedServerMonitor.sql @@ -0,0 +1,135 @@ +/* +https://jasonbrimhall.info/2021/01/02/powerful-monitoring-for-your-linked-servers-with-xevents/ +by Jason Brimhall 2021-01-02 +*/ + +/* Create the Event Session */ +IF EXISTS +( + SELECT * + FROM sys.server_event_sessions + WHERE name = 'LinkedServerMonitor' +) + DROP EVENT SESSION LinkedServerMonitor ON SERVER; +GO + + +CREATE EVENT SESSION [LinkedServerMonitor] +ON SERVER + ADD EVENT sqlserver.oledb_data_read + (ACTION + ( + package0.callstack + , sqlserver.client_app_name + , sqlserver.database_name + , sqlserver.nt_username + , sqlserver.query_hash + , sqlserver.query_plan_hash + , sqlserver.session_id + , sqlserver.sql_text + , sqlserver.client_hostname + , sqlserver.tsql_stack + , package0.event_sequence + , sqlserver.context_info + , sqlserver.client_connection_id + , sqlserver.username + , sqlserver.database_id + ) + ) + , ADD EVENT sqlserver.oledb_query_interface + (ACTION + ( + package0.callstack + , sqlserver.client_app_name + , sqlserver.database_name + , sqlserver.nt_username + , sqlserver.query_hash + , sqlserver.query_plan_hash + , sqlserver.session_id + , sqlserver.sql_text + , sqlserver.client_hostname + , sqlserver.tsql_stack + , package0.event_sequence + , sqlserver.context_info + , sqlserver.client_connection_id + , sqlserver.username + , sqlserver.database_id + ) + ) + , ADD EVENT sqlserver.oledb_error + (ACTION + ( + package0.callstack + , sqlserver.client_app_name + , sqlserver.database_name + , sqlserver.nt_username + , sqlserver.query_hash + , sqlserver.query_plan_hash + , sqlserver.session_id + , sqlserver.sql_text + , sqlserver.client_hostname + , sqlserver.tsql_stack + , package0.event_sequence + , sqlserver.context_info + , sqlserver.client_connection_id + , sqlserver.username + , sqlserver.database_id + ) + ) + , ADD EVENT sqlserver.oledb_provider_information + (ACTION + ( + package0.callstack + , sqlserver.client_app_name + , sqlserver.database_name + , sqlserver.nt_username + , sqlserver.query_hash + , sqlserver.query_plan_hash + , sqlserver.session_id + , sqlserver.sql_text + , sqlserver.client_hostname + , sqlserver.tsql_stack + , package0.event_sequence + , sqlserver.context_info + , sqlserver.client_connection_id + , sqlserver.username + , sqlserver.database_id + ) + ) + , ADD EVENT sqlserver.oledb_provider_initialized + (ACTION + ( + package0.callstack + , sqlserver.client_app_name + , sqlserver.database_name + , sqlserver.nt_username + , sqlserver.query_hash + , sqlserver.query_plan_hash + , sqlserver.session_id + , sqlserver.sql_text + , sqlserver.client_hostname + , sqlserver.tsql_stack + , package0.event_sequence + , sqlserver.context_info + , sqlserver.client_connection_id + , sqlserver.username + , sqlserver.database_id + ) + ) + ADD TARGET package0.event_file + (SET filename = N'C:\XE\LinkedServerMonitor', max_file_size = (256), max_rollover_files = (2)) + , ADD TARGET package0.histogram + (SET filtering_event_name = N'sqlserver.oledb_data_read' + , slots = (10000) --modify depending on your needs + , source = N'sqlserver.tsql_stack') +WITH +( + MAX_DISPATCH_LATENCY = 5 SECONDS + , TRACK_CAUSALITY = ON + , STARTUP_STATE = ON +); +GO + + +ALTER EVENT SESSION LinkedServerMonitor ON SERVER STATE = START; +GO diff --git a/Extended_Events/LockEscalation.sql b/Extended_Events/LockEscalation.sql new file mode 100644 index 00000000..eaca905f --- /dev/null +++ b/Extended_Events/LockEscalation.sql @@ -0,0 +1,14 @@ +/* +https://littlekendra.com/2017/04/03/which-locks-count-toward-lock-escalation/ +by Kendra Little Melton 2017-04-03 +*/ + +DROP EVENT SESSION LockEscalation ON SERVER; +GO + +CREATE EVENT SESSION LockEscalation ON SERVER +ADD EVENT sqlserver.lock_escalation(SET collect_database_name=(1),collect_statement=(1) + ACTION(sqlserver.session_id)) +ADD TARGET package0.event_file(SET filename=N'C:\XE\Lock_Escalation.xel') +WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=NO_EVENT_LOSS,MAX_DISPATCH_LATENCY=5 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=OFF) +GO diff --git a/Extended_Events/ProcedureWaits.sql b/Extended_Events/ProcedureWaits.sql new file mode 100644 index 00000000..78a6225b --- /dev/null +++ b/Extended_Events/ProcedureWaits.sql @@ -0,0 +1,18 @@ +/* +Original link: https://www.scarydba.com/2018/02/05/wait-statistics-query/ +Author: Grant Fritchey +*/ + +CREATE EVENT SESSION ProcedureWaits +ON SERVER + ADD EVENT sqlos.wait_completed + (SET collect_wait_resource = (1) + WHERE (sqlserver.equal_i_sql_unicode_string(sqlserver.database_name, N'AdventureWorks2017'))), + ADD EVENT sqlserver.module_end + (WHERE ( sqlserver.database_name = N'AdventureWorks2017' + AND object_name = N'ProductTransactionHistoryByReference')), + ADD EVENT sqlserver.rpc_completed + (WHERE (sqlserver.database_name = N'AdventureWorks2017')), + ADD EVENT sqlserver.rpc_starting + (WHERE (sqlserver.database_name = N'AdventureWorks2017')) +WITH (TRACK_CAUSALITY = ON); diff --git a/Extended_Events/QueryExecutionDetails.sql b/Extended_Events/QueryExecutionDetails.sql new file mode 100644 index 00000000..62cbad80 --- /dev/null +++ b/Extended_Events/QueryExecutionDetails.sql @@ -0,0 +1,40 @@ +/* +Original link: https://www.scarydba.com/2019/06/03/which-query-used-the-most-cpu-implementing-extended-events/ +Source link: https://github.com/ktaranov/sqlserver-kit/blob/master/Extended_Events/DBRecoveryProgress.sql +Author: Grant Fritchey +*/ + +USE master; +GO + +IF EXISTS +( + SELECT + * + FROM sys.server_event_sessions + WHERE name = 'QueryExecutionDetails' +) + DROP EVENT SESSION QueryExecutionDetails ON SERVER; +GO + +CREATE EVENT SESSION QueryExecutionDetails +ON SERVER +ADD EVENT sqlserver.rpc_completed +(WHERE (sqlserver.database_name = N'AdventureWorks')), +ADD EVENT sqlserver.rpc_starting +(WHERE (sqlserver.database_name = N'AdventureWorks')), +ADD EVENT sqlserver.sp_statement_completed +(WHERE (sqlserver.database_name = N'AdventureWorks')), +ADD EVENT sqlserver.sql_batch_completed +(WHERE (sqlserver.database_name = N'AdventureWorks')), +ADD EVENT sqlserver.sql_batch_starting +(WHERE (sqlserver.database_name = N'AdventureWorks')), +ADD EVENT sqlserver.sql_statement_completed +(SET collect_statement = (1) +WHERE (sqlserver.database_name = N'AdventureWorks')) +ADD TARGET package0.event_file +(SET filename = N'C:\ExEvents\QueryExecutionDetails.xel') +WITH (TRACK_CAUSALITY = ON); + +ALTER EVENT SESSION QueryExecutionDetails ON SERVER STATE = START; +GO diff --git a/Extended_Events/README.md b/Extended_Events/README.md index 0a23fbaa..795afd55 100644 --- a/Extended_Events/README.md +++ b/Extended_Events/README.md @@ -1,10 +1,10 @@ # SQL Server Extended Events SQL Server Extended Events has a highly scalable and highly configurable architecture that allows users to collect as much or as little information as is necessary to troubleshoot or identify a performance problem. - - Useful links: - [Extended Events Microsoft Docs](https://docs.microsoft.com/en-us/sql/relational-databases/extended-events/extended-events) + - [Creating a SQL Server audit using SQL Server Extended Events and Triggers](https://www.sqlshack.com/creating-a-sql-server-audit-using-sql-server-extended-events-and-triggers/) (by Ahmad Yaseen) + - [How to automate SQL Server deadlock collection process using Extended Events and SQL Server Agent](https://www.sqlshack.com/automate-sql-server-deadlock-collection-process-using-extended-events-sql-server-agent/) (by Jefferson Elias) - [Find Your Dark Queries](http://michaeljswart.com/2017/04/finding-your-dark-queries/) - [Finding Blocked Processes and Deadlocks using SQL Server Extended Events](https://www.brentozar.com/archive/2014/03/extended-events-doesnt-hard/) - [What event information can I get by default from SQL Server?](http://dba.stackexchange.com/questions/48052/what-event-information-can-i-get-by-default-from-sql-server) @@ -17,8 +17,10 @@ Useful links: - [Erin Stellato articles about extended events](https://www.sqlskills.com/blogs/erin/category/extended-events/) - [Stairway to SQL Server Extended Events](http://www.sqlservercentral.com/stairway/134867/) (by Erin Stellato) - [Measuring “Observer Overhead” of SQL Trace vs. Extended Events](https://sqlperformance.com/2012/10/sql-trace/observer-overhead-trace-extended-events) (by Jonathan Kehayias) + - [An Identity Crisis: Is it Profiler or is it Extended Events?](http://jasonbrimhall.info/2017/12/22/an-identity-crisis-is-it-profiler-or-is-it-extended-events/) (by Jason Brimhall) Courses: + - [Learning Extended Events in 60 Days](http://jasonbrimhall.info/2015/09/08/learning-extended-events-in-60-days/) (by Jason Brimhall) - [SQL Server: Introduction to Extended Events](https://www.pluralsight.com/courses/sqlserver-basicxevents) (by Jonathan Kehayias) - [SQL Server: Advanced Extended Events](https://www.pluralsight.com/courses/sqlserver-advanced-xevents) (by Jonathan Kehayias) - [SQL Server: Replacing Profiler with Extended Events](https://www.pluralsight.com/courses/sqlserver-replacing-profiler-extended-events) (by Erin Stellato) diff --git a/Extended_Events/SchemaQueryByUser.sql b/Extended_Events/SchemaQueryByUser.sql new file mode 100644 index 00000000..648f3283 --- /dev/null +++ b/Extended_Events/SchemaQueryByUser.sql @@ -0,0 +1,30 @@ +/* +Original link: https://gist.github.com/SQLDBAWithABeard/3a617e04de5db729e941a0fd6ebed7cc +Author: Rob Sewell +*/ + +/* Stop trace if started */ +IF EXISTS (SELECT * FROM sys.dm_xe_sessions WHERE name = 'SchemaQueryByUser') + ALTER EVENT SESSION SchemaQueryByUser ON SERVER STATE = STOP; + +/* Delete trace if exists */ +IF EXISTS (SELECT * FROM sys.server_event_sessions WHERE name = 'SchemaQueryByUser') + DROP EVENT SESSION SchemaQueryByUser ON SERVER; + +/* Create trace */ +CREATE EVENT SESSION SchemaQueryByUser ON SERVER +ADD EVENT sqlserver.sql_batch_completed(SET collect_batch_text=(1) + ACTION(sqlserver.database_name, sqlserver.session_server_principal_name) + WHERE ((((((((NOT ([sqlserver].[like_i_sql_unicode_string]([sqlserver].[session_server_principal_name],N'EZCORP\Y%'))) + AND (([sqlserver].[like_i_sql_unicode_string]([batch_text],N'%%')) + OR ([sqlserver].[equal_i_sql_unicode_string]([sqlserver].[database_name],N'')))) + AND (NOT ([sqlserver].[like_i_sql_unicode_string]([batch_text],N'%SELECT CASE WHEN has_dbaccess%END%')))) + AND (NOT ([sqlserver].[like_i_sql_unicode_string]([batch_text],N'%SELECT case when @edition = N''SQL Azure''%')))) + AND (NOT ([sqlserver].[like_i_sql_unicode_string]([batch_text],N'%SERVERPROPERTY(%')))) + AND (NOT ([sqlserver].[like_i_sql_unicode_string]([batch_text],N'%HasMemoryOptimizedObjects from master.sys.master_files mf join master.sys.databases db on mf.database_id%')))) + AND (NOT ([sqlserver].[like_i_sql_unicode_string]([batch_text],N'%database_query_store_options%')))) + AND (NOT ([sqlserver].[like_i_sql_unicode_string]([batch_text],N'%SET SHOWPLAN%'))))) +GO + +ALTER EVENT SESSION SchemaQueryByUser ON SERVER STATE = START; +GO diff --git a/Extended_Events/System_Health_Addition.sql b/Extended_Events/System_Health_Addition.sql new file mode 100644 index 00000000..2913af7b --- /dev/null +++ b/Extended_Events/System_Health_Addition.sql @@ -0,0 +1,50 @@ +/* +Original link: https://karaszi.com/looking-for-strange +Author: Tibor Karaszi's +*/ + +--Stop trace if started +IF EXISTS (SELECT * FROM sys.dm_xe_sessions WHERE name = 'SystemHealthAddition') + ALTER EVENT SESSION SystemHealthAddition ON SERVER STATE = STOP; + +--Delete trace if exists +IF EXISTS (SELECT * FROM sys.server_event_sessions WHERE name = 'SystemHealthAddition') + DROP EVENT SESSION SystemHealthAddition ON SERVER; + +--Create trace +CREATE EVENT SESSION [SystemHealthAddition] ON SERVER +ADD EVENT sqlserver.attention( + WHERE (package0.greater_than_uint64(database_id,(4)) + AND package0.equal_boolean(sqlserver.is_system,(0)))) , +ADD EVENT sqlserver.auto_stats( + WHERE (package0.greater_than_uint64(database_id,(4)) + AND package0.equal_boolean(sqlserver.is_system,(0)) + AND package0.greater_than_equal_int64(object_id,(1000000)) + AND package0.greater_than_uint64(duration,(10)))), +ADD EVENT sqlserver.database_file_size_change, +ADD EVENT sqlserver.database_started, +ADD EVENT sqlserver.lock_deadlock, +ADD EVENT sqlserver.lock_escalation, +ADD EVENT sqlserver.lock_timeout_greater_than_0, +ADD EVENT sqlserver.long_io_detected, + +--Begin performance section +ADD EVENT qds.query_store_plan_forcing_failed, +ADD EVENT sqlserver.exchange_spill, +ADD EVENT sqlserver.execution_warning, +ADD EVENT sqlserver.hash_spill_details, +ADD EVENT sqlserver.hash_warning, +ADD EVENT sqlserver.optimizer_timeout, +ADD EVENT sqlserver.query_memory_grant_blocking, +ADD EVENT sqlserver.query_memory_grants, +ADD EVENT sqlserver.sort_warning, +ADD EVENT sqlserver.window_spool_ondisk_warning +--End performance section + +ADD TARGET package0.event_counter; +GO + +/* +--Start trace +ALTER EVENT SESSION SystemHealthAddition ON SERVER STATE = START; +*/ diff --git a/Extended_Events/TrackApiCursor.sql b/Extended_Events/TrackApiCursor.sql new file mode 100644 index 00000000..b91beb3f --- /dev/null +++ b/Extended_Events/TrackApiCursor.sql @@ -0,0 +1,97 @@ +/* +https://blog.pythian.com/extended-events-fetching-api-cursors/ +by Shawn Melton January 3, 2017 +*/ + +DROP EVENT SESSION TrackApiCursor ON SERVER; +GO + +CREATE EVENT SESSION TrackApiCursor ON SERVER +ADD EVENT sqlserver.cursor_close( + ACTION( + sqlserver.client_app_name, + sqlserver.database_name, + sqlserver.is_system, + sqlserver.session_id, + sqlserver.sql_text) + WHERE ( + [sqlserver].[is_system]<>(0) + -- AND [sqlserver].[client_app_name]=N'Steely-Eyed-Missle-Man' + ) +), +ADD EVENT sqlserver.cursor_open( + ACTION( + sqlserver.client_app_name, + sqlserver.database_name, + sqlserver.is_system, + sqlserver.query_hash, + sqlserver.session_id, + sqlserver.sql_text) + WHERE ( + [sqlserver].[is_system]<>(0) + -- AND [sqlserver].[client_app_name]=N'Steely-Eyed-Missle-Man' + ) +), +ADD EVENT sqlserver.rpc_completed( + ACTION( + sqlserver.client_app_name, + sqlserver.database_name, + sqlserver.is_system, + sqlserver.query_hash, + sqlserver.session_id, + sqlserver.sql_text) + WHERE ( + [sqlserver].[is_system]<>(0) + -- AND [sqlserver].[client_app_name]=N'Steely-Eyed-Missle-Man' + ) +) +ADD TARGET package0.event_file(SET filename=N'Track_api_cursor.xel') +WITH ( + MAX_DISPATCH_LATENCY=12 SECONDS, + TRACK_CAUSALITY=ON +); +GO + +ALTER EVENT SESSION TrackApiCursor ON SERVER STATE = START; +GO + +/* Read the data */ +IF OBJECT_ID('tempdb..#XEResults') IS NOT NULL + DROP TABLE #XEResults ; +GO +IF OBJECT_ID('tempdb..#XEResultsParsed') IS NOT NULL + DROP TABLE #XEResultsParsed ; +GO + +-- Create results table to load data from XE files +CREATE TABLE #XEResults +( + [RowID] INT IDENTITY + PRIMARY KEY, + [event_data] XML +); + +-- Load the event data from the file target +INSERT INTO #XEResults + ([event_data]) +SELECT CAST([event_data] AS XML) AS event_data +FROM [sys].[fn_xe_file_target_read_file](N'Track_api_cursor*xel',NULL,NULL,NULL) ; + +--SELECT * FROM #XEResults + +-- Query the Event data from the Target. +SELECT [event].[value]('(@name)[1]', 'varchar(50)') AS event_name +-- , DATEADD(hh, DATEDIFF(hh, GETUTCDATE(), CURRENT_TIMESTAMP), [event].[value]('(@timestamp)[1]', 'datetime2')) AS [timestamp] + ,[event].[value]('(action[@name="session_id"]/value)[1]', 'int') AS [session_id] + ,[event].[value]('(action[@name="database_name"]/value)[1]','varchar(128)') AS [database_name] + ,[event].[value]('(action[@name="client_app_name"]/value)[1]','varchar(500)') AS [client_app_name] + ,[event].[value]('(data[@name="object_name"]/value)[1]', 'varchar(50)') AS [object_name] + ,[event].[value]('(action[@name="sql_text"]/value)[1]','varchar(max)') AS [sql_text] + ,[event].[value]('(data[@name="statement"]/value)[1]', 'varchar(1000)') AS [statement] + ,[event].[value]('(action[@name="attach_activity_id_xfer"]/value)[1]', 'varchar(200)') AS [attach_activity_id_xfer] + ,[event].[value]('(action[@name="attach_activity_id"]/value)[1]', 'varchar(200)') AS [attach_activity_id] +FROM #XEResults +CROSS APPLY [event_data].[nodes]('event') AS [q] ([event]) +ORDER BY DATEADD(hh, DATEDIFF(hh, GETUTCDATE(), CURRENT_TIMESTAMP),[event].[value]('(@timestamp)[1]', 'datetime2')) + ,[event].[value]('(action[@name="attach_activity_id"]/value)[1]', 'varchar(200)'); + diff --git a/Extended_Events/TrackDBFileChange.sql b/Extended_Events/TrackDBFileChange.sql new file mode 100644 index 00000000..66b1b41a --- /dev/null +++ b/Extended_Events/TrackDBFileChange.sql @@ -0,0 +1,55 @@ +/* +Original link: https://jasonbrimhall.info/2018/11/27/auditing-when-database-files-change/ +Source link: https://github.com/ktaranov/sqlserver-kit/blob/master/Extended_Events/TrackDBFileChange.sql +Author: Jason Brimhall + +SELECT + event_data.value('(event/@name)[1]', 'varchar(50)') AS event_name + ,event_data.value('(event/@timestamp)[1]','varchar(max)') as timestamp + ,event_data.value('(event/data[@name="count"]/value)[1]', 'bigint') AS DbSizeChangeTo_KB + ,event_data.value('(event/action[@name="sql_text"]/value)[1]', 'varchar(max)') AS sql_text + ,db_name(event_data.value('(event/action[@name="database_id"]/value)[1]', 'int')) AS DBQueryExecutedFrom + ,db_name(event_data.value('(event/data[@name="database_id"]/value)[1]','int')) as AffectedDB + ,event_data.value('(event/action[@name="client_hostname"]/value)[1]', 'varchar(max)') AS ClientHost + ,event_data.value('(event/action[@name="session_id"]/value)[1]', 'varchar(max)') AS session_id +FROM( + SELECT CAST(event_data AS xml) AS TargetData + FROM sys.fn_xe_file_target_read_file('C:\XE\DBFileSizeChange*.xel','C:\XE\DBFileSizeChange*.xem',NULL, NULL) + + ) AS evts(event_data) +WHERE event_data.value('(event/@name)[1]', 'varchar(50)') = 'databases_log_file_size_changed' + or event_data.value('(event/@name)[1]', 'varchar(50)') = 'databases_data_file_size_changed' + --or event_data.value('(event/@name)[1]', 'varchar(50)') = 'databases_log_growth' +ORDER BY timestamp; +*/ + +USE master; +GO + +IF EXISTS(SELECT 1 FROM sys.server_event_sessions WHERE name = N'TrackDBFileChange') + DROP EVENT SESSION TrackDBFileChange ON SERVER; +GO + +CREATE EVENT SESSION TrackDBFileChange ON SERVER +ADD EVENT sqlserver.databases_data_file_size_changed( + ACTION(sqlserver.session_id,sqlserver.database_id,sqlserver.client_hostname, + sqlserver.sql_text) + ) +,ADD EVENT sqlserver.databases_log_file_size_changed( + ACTION(sqlserver.session_id,sqlserver.database_id,sqlserver.client_hostname, + sqlserver.sql_text) + ) +ADD TARGET package0.asynchronous_file_target( + SET filename='C:\XE\TrackDBFileChange.xel' + , max_file_size = 5 + , max_rollover_files = 4 + , metadatafile='C:\XE\TrackDBFileChange.xem' + ) --if the path does not exist, a nasty error will be thrown +, +ADD TARGET package0.ring_buffer -- Store events in the ring buffer target + (SET max_memory = 4096) +WITH (MAX_MEMORY = 4MB, EVENT_RETENTION_MODE = ALLOW_SINGLE_EVENT_LOSS, TRACK_CAUSALITY = ON, MAX_DISPATCH_LATENCY = 1 SECONDS,startup_state = ON); +GO + +ALTER EVENT SESSION TrackDBFileChange ON SERVER STATE = START; +GO diff --git a/Extended_Events/TrackTFChange.sql b/Extended_Events/TrackTFChange.sql new file mode 100644 index 00000000..23709bfb --- /dev/null +++ b/Extended_Events/TrackTFChange.sql @@ -0,0 +1,49 @@ +/* +Original link: http://jasonbrimhall.info/2018/12/06/capture-the-flag-the-trace-flag/ +Author: Jason Brimhall +*/ +-- If the Event Session exists DROP it +IF EXISTS (SELECT 1 FROM sys.server_event_sessions WHERE name = N'TrackTFChange') + DROP EVENT SESSION TrackTFChange ON SERVER; + +CREATE EVENT SESSION TrackTFChange ON SERVER +ADD EVENT sqlserver.trace_flag_changed( + ACTION (sqlserver.database_name,sqlserver.client_hostname,sqlserver.client_app_name, + sqlserver.sql_text, + sqlserver.session_id) + -- WHERE sqlserver.client_app_name <> 'Microsoft SQL Server Management Studio - Transact-SQL IntelliSense' + ) +ADD TARGET package0.ring_buffer +WITH (MAX_DISPATCH_LATENCY=5SECONDS, TRACK_CAUSALITY=ON); +GO + +ALTER EVENT SESSION TrackTFChange ON SERVER STATE = START; +GO + + +SELECT event_data.value('(event/@name)[1]', 'varchar(50)') AS event_name + , event_data.value('(event/@timestamp)[1]','varchar(max)') as timestamp + , event_data.value('(event/data[@name="flag"]/value)[1]', 'bigint') AS TraceFlag + , event_data.value('(event/data[@name="type"]/text)[1]', 'varchar(max)') AS FlagType + , CASE event_data.value('(event/data[@name="new_value"]/value)[1]','int') + WHEN 0 then 'Enabled' + WHEN 1 then 'Disabled' + END as NewValue + , event_data.value('(event/action[@name="sql_text"]/value)[1]', 'varchar(max)') AS sql_text + , event_data.value('(event/action[@name="database_name"]/value)[1]', 'varchar(max)') AS DBQueryExecutedFrom + , event_data.value('(event/action[@name="client_hostname"]/value)[1]', 'varchar(max)') AS ClientHost + , event_data.value('(event/action[@name="client_app_name"]/value)[1]', 'varchar(max)') AS appname + , event_data.value('(event/action[@name="session_id"]/value)[1]', 'varchar(max)') AS session_id +FROM(SELECT evnt.query('.') AS event_data + FROM + ( SELECT CAST(target_data AS xml) AS TargetData + FROM sys.dm_xe_sessions AS s + INNER JOIN sys.dm_xe_session_targets AS t + ON s.address = t.event_session_address + WHERE s.name = 'TrackTFChange' + AND t.target_name = 'ring_buffer' + ) AS tab + CROSS APPLY TargetData.nodes ('RingBufferTarget/event') AS split(evnt) + ) AS evts(event_data) +WHERE event_data.value('(event/@name)[1]', 'varchar(50)') = 'trace_flag_changed' +ORDER BY timestamp ASC; diff --git a/Extended_Events/XE_Truncate.sql b/Extended_Events/XE_Truncate.sql new file mode 100644 index 00000000..5289f428 --- /dev/null +++ b/Extended_Events/XE_Truncate.sql @@ -0,0 +1,23 @@ +/* +https://www.sqlservercentral.com/forums/topic/extended-events-capture-truncate-using-object_altered-event +by Evgeny Garaev 2018-06-28 +*/ + +/* Stop trace if started */ +IF EXISTS (SELECT * FROM sys.dm_xe_sessions WHERE name = N'XE_Truncate') + ALTER EVENT SESSION XE_Truncate ON SERVER STATE = STOP; + +/* Delete trace if exists */ +IF EXISTS (SELECT * FROM sys.server_event_sessions WHERE name = N'XE_Truncate') + DROP EVENT SESSION XE_Truncate ON SERVER; + + +CREATE EVENT SESSION XE_Truncate ON SERVER +ADD EVENT sqlserver.sp_statement_starting(SET collect_statement=(1) +WHERE ([sqlserver].[like_i_sql_unicode_string]([statement], N'truncate table%'))), +ADD EVENT sqlserver.sql_statement_starting(SET collect_statement=(1) +WHERE ([sqlserver].[like_i_sql_unicode_string]([statement],N'truncate table%'))); +GO + +ALTER EVENT SESSION XE_Truncate ON SERVER STATE = START; +GO diff --git a/Extended_Events/system_health_azure.sql b/Extended_Events/system_health_azure.sql new file mode 100644 index 00000000..dbeb3c20 --- /dev/null +++ b/Extended_Events/system_health_azure.sql @@ -0,0 +1,109 @@ +/* +Original link: https://www.scarydba.com/2019/03/04/system_health-extended-events-in-azure-sql-database/ +Author: Grant Fritchey +*/ + +IF EXISTS (SELECT * FROM sys.dm_xe_database_sessions AS dxds WHERE dxds.name = 'system_health_azure') +DROP EVENT SESSION system_health_azure ON SERVER; +GO + +CREATE EVENT SESSION system_health_azure +ON DATABASE +ADD EVENT sqlserver.error_reported +(ACTION (sqlserver.session_id, +sqlserver.database_id, +sqlserver.sql_text, +sqlserver.tsql_stack) +-- Get callstack, SPID, and query for all high severity errors ( above sev 20 ) +WHERE severity >= 20 +-- Get callstack, SPID, and query for OOM errors ( 17803 , 701 , 802 , 8645 , 8651 , 8657 , 8902 ), Hekaton checkpoint/merge errors (41354, 41355, 41367, 41384), Hekaton compilation related errors (41336, 41309, 41312, 41313) +OR ( ERROR_NUMBER = 17803 +OR ERROR_NUMBER = 701 +OR ERROR_NUMBER = 802 +OR ERROR_NUMBER = 8645 +OR ERROR_NUMBER = 8651 +OR ERROR_NUMBER = 8657 +OR ERROR_NUMBER = 8902 +OR ERROR_NUMBER = 41354 +OR ERROR_NUMBER = 41355 +OR ERROR_NUMBER = 41367 +OR ERROR_NUMBER = 41384 +OR ERROR_NUMBER = 41336 +OR ERROR_NUMBER = 41309 +OR ERROR_NUMBER = 41312 +OR ERROR_NUMBER = 41313)), +-- ADD EVENT sqlserver.xml_deadlock_report, +ADD EVENT sqlos.wait_info +(ACTION (sqlserver.session_id, +sqlserver.sql_text) +WHERE ( duration > 15000 +AND ( ( wait_type >= N'LATCH_NL' -- Waits for latches and important wait resources (not locks ) that have exceeded 15 seconds. +AND ( ( wait_type >= N'PAGELATCH_NL' +AND wait_type <= N'PAGELATCH_DT') --PAGELATCH_NL;PAGELATCH_KP;PAGELATCH_SH;PAGELATCH_UP;PAGELATCH_EX;PAGELATCH_DT +OR (wait_type <= N'LATCH_DT') --LATCH_NL;LATCH_KP;LATCH_SH;LATCH_UP;LATCH_EX;LATCH_DT +OR ( wait_type >= N'PAGEIOLATCH_NL' +AND wait_type <= N'PAGEIOLATCH_DT') --PAGEIOLATCH_NL;PAGEIOLATCH_KP;PAGEIOLATCH_SH;PAGEIOLATCH_UP;PAGEIOLATCH_EX;PAGEIOLATCH_DT +OR ( wait_type >= N'IO_COMPLETION' +AND wait_type <= N'NETWORK_IO') --IO_COMPLETION;ASYNC_IO_COMPLETION;NETWORK_IO +OR (wait_type = N'RESOURCE_SEMAPHORE') +OR (wait_type = N'SOS_WORKER') +OR ( wait_type >= N'FCB_REPLICA_WRITE' +AND wait_type <= N'WRITELOG') --FCB_REPLICA_WRITE;FCB_REPLICA_READ;WRITELOG +OR (wait_type = N'CMEMTHREAD') +OR (wait_type = N'TRACEWRITE') +OR (wait_type = N'RESOURCE_SEMAPHORE_MUTEX'))) +OR ( duration > 30000 -- Waits for locks that have exceeded 30 secs. +AND wait_type <= N'LCK_M_RX_X' -- all lock waits +)))), +ADD EVENT sqlos.wait_info_external +(ACTION (sqlserver.session_id, +sqlserver.sql_text) +WHERE ( duration > 5000 +AND ( ( -- Login related preemptive waits that have exceeded 5 seconds. +( wait_type >= N'PREEMPTIVE_OS_GENERICOPS' +AND wait_type <= N'PREEMPTIVE_OS_ENCRYPTMESSAGE') --PREEMPTIVE_OS_GENERICOPS;PREEMPTIVE_OS_AUTHENTICATIONOPS;PREEMPTIVE_OS_ACCEPTSECURITYCONTEXT;PREEMPTIVE_OS_ACQUIRECREDENTIALSHANDLE;PREEMPTIVE_OS_COMPLETEAUTHTOKEN;PREEMPTIVE_OS_DECRYPTMESSAGE;PREEMPTIVE_OS_DELETESECURITYCONTEXT;PREEMPTIVE_OS_ENCRYPTMESSAGE +OR ( wait_type >= N'PREEMPTIVE_OS_INITIALIZESECURITYCONTEXT' +AND wait_type <= N'PREEMPTIVE_OS_QUERYSECURITYCONTEXTTOKEN') --PREEMPTIVE_OS_INITIALIZESECURITYCONTEXT;PREEMPTIVE_OS_LOGONUSER;PREEMPTIVE_OS_QUERYSECURITYCONTEXTTOKEN +OR ( wait_type >= N'PREEMPTIVE_OS_AUTHZGETINFORMATIONFROMCONTEXT' +AND wait_type <= N'PREEMPTIVE_OS_REVERTTOSELF') --PREEMPTIVE_OS_AUTHZGETINFORMATIONFROMCONTEXT;PREEMPTIVE_OS_AUTHZINITIALIZECONTEXTFROMSID;PREEMPTIVE_OS_AUTHZINITIALIZERESOURCEMANAGER;PREEMPTIVE_OS_LOOKUPACCOUNTSID;PREEMPTIVE_OS_REVERTTOSELF +OR ( wait_type >= N'PREEMPTIVE_OS_CRYPTACQUIRECONTEXT' +AND wait_type <= N'PREEMPTIVE_OS_DEVICEOPS') --PREEMPTIVE_OS_CRYPTACQUIRECONTEXT;PREEMPTIVE_OS_CRYPTIMPORTKEY;PREEMPTIVE_OS_DEVICEOPS +OR ( wait_type >= N'PREEMPTIVE_OS_NETGROUPGETUSERS' +AND wait_type <= N'PREEMPTIVE_OS_NETUSERMODALSGET') --PREEMPTIVE_OS_NETGROUPGETUSERS;PREEMPTIVE_OS_NETLOCALGROUPGETMEMBERS;PREEMPTIVE_OS_NETUSERGETGROUPS;PREEMPTIVE_OS_NETUSERGETLOCALGROUPS;PREEMPTIVE_OS_NETUSERMODALSGET +OR ( wait_type >= N'PREEMPTIVE_OS_NETVALIDATEPASSWORDPOLICYFREE' +AND wait_type <= N'PREEMPTIVE_OS_DOMAINSERVICESOPS') --PREEMPTIVE_OS_NETVALIDATEPASSWORDPOLICYFREE;PREEMPTIVE_OS_DOMAINSERVICESOPS +OR (wait_type = N'PREEMPTIVE_OS_VERIFYSIGNATURE')) +OR ( duration > 45000 -- Preemptive OS waits that have exceeded 45 seconds. +AND ( ( wait_type >= N'PREEMPTIVE_OS_SETNAMEDSECURITYINFO' +AND wait_type <= N'PREEMPTIVE_CLUSAPI_CLUSTERRESOURCECONTROL') --PREEMPTIVE_OS_SETNAMEDSECURITYINFO;PREEMPTIVE_OS_CLUSTEROPS;PREEMPTIVE_CLUSAPI_CLUSTERRESOURCECONTROL +OR ( wait_type >= N'PREEMPTIVE_OS_RSFXDEVICEOPS' +AND wait_type <= N'PREEMPTIVE_OS_DSGETDCNAME') --PREEMPTIVE_OS_RSFXDEVICEOPS;PREEMPTIVE_OS_DIRSVC_NETWORKOPS;PREEMPTIVE_OS_DSGETDCNAME +OR ( wait_type >= N'PREEMPTIVE_OS_DTCOPS' +AND wait_type <= N'PREEMPTIVE_DTC_ABORT') --PREEMPTIVE_OS_DTCOPS;PREEMPTIVE_DTC_ABORT +OR ( wait_type >= N'PREEMPTIVE_OS_CLOSEHANDLE' +AND wait_type <= N'PREEMPTIVE_OS_FINDFILE') --PREEMPTIVE_OS_CLOSEHANDLE;PREEMPTIVE_OS_COPYFILE;PREEMPTIVE_OS_CREATEDIRECTORY;PREEMPTIVE_OS_CREATEFILE;PREEMPTIVE_OS_DELETEFILE;PREEMPTIVE_OS_DEVICEIOCONTROL;PREEMPTIVE_OS_FINDFILE +OR ( wait_type >= N'PREEMPTIVE_OS_GETCOMPRESSEDFILESIZE' +AND wait_type <= N'PREEMPTIVE_ODBCOPS') --PREEMPTIVE_OS_GETCOMPRESSEDFILESIZE;PREEMPTIVE_OS_GETDISKFREESPACE;PREEMPTIVE_OS_GETFILEATTRIBUTES;PREEMPTIVE_OS_GETFILESIZE;PREEMPTIVE_OS_GETLONGPATHNAME;PREEMPTIVE_OS_GETVOLUMEPATHNAME;PREEMPTIVE_OS_GETVOLUMENAMEFORVOLUMEMOUNTPOINT;PREEMPTIVE_OS_MOVEFILE;PREEMPTIVE_OS_OPENDIRECTORY;PREEMPTIVE_OS_REMOVEDIRECTORY;PREEMPTIVE_OS_SETENDOFFILE;PREEMPTIVE_OS_SETFILEPOINTER;PREEMPTIVE_OS_SETFILEVALIDDATA;PREEMPTIVE_OS_WRITEFILE;PREEMPTIVE_OS_WRITEFILEGATHER;PREEMPTIVE_OS_LIBRARYOPS;PREEMPTIVE_OS_FREELIBRARY;PREEMPTIVE_OS_GETPROCADDRESS;PREEMPTIVE_OS_LOADLIBRARY;PREEMPTIVE_OS_MESSAGEQUEUEOPS;PREEMPTIVE_ODBCOPS +OR ( wait_type >= N'PREEMPTIVE_OS_DISCONNECTNAMEDPIPE' +AND wait_type <= N'PREEMPTIVE_CLOSEBACKUPMEDIA') --PREEMPTIVE_OS_DISCONNECTNAMEDPIPE;PREEMPTIVE_OS_PROCESSOPS;PREEMPTIVE_OS_SECURITYOPS;PREEMPTIVE_OS_SERVICEOPS;PREEMPTIVE_OS_SQLCLROPS;PREEMPTIVE_OS_WINSOCKOPS;PREEMPTIVE_OS_GETADDRINFO;PREEMPTIVE_OS_WSASETLASTERROR;PREEMPTIVE_OS_FORMATMESSAGE;PREEMPTIVE_OS_REPORTEVENT;PREEMPTIVE_OS_BACKUPREAD;PREEMPTIVE_OS_WAITFORSINGLEOBJECT;PREEMPTIVE_OS_QUERYREGISTRY;PREEMPTIVE_CLOSEBACKUPMEDIA +OR wait_type = N'PREEMPTIVE_OS_AUTHENTICATIONOPS' +OR wait_type = N'PREEMPTIVE_OS_FREECREDENTIALSHANDLE' +OR wait_type = N'PREEMPTIVE_OS_AUTHORIZATIONOPS' +OR wait_type = N'PREEMPTIVE_COM_COCREATEINSTANCE' +OR wait_type = N'PREEMPTIVE_OS_NETVALIDATEPASSWORDPOLICY' +OR wait_type = N'PREEMPTIVE_VSS_CREATESNAPSHOT'))))) +/* add target package0.event_file -- Store events on disk (in the LOG folder of the instance) +( +set filename = N'system_health_azure.xel', +max_file_size = 5, /* MB */ +max_rollover_files = 4 +),*/ +ADD TARGET package0.ring_buffer -- Store events in the ring buffer target +(SET MAX_MEMORY = 4096, max_events_limit = 5000) +WITH (MAX_DISPATCH_LATENCY = 120 SECONDS, +STARTUP_STATE = ON); +GO + +IF NOT EXISTS (SELECT * FROM sys.dm_xe_database_sessions AS dxds WHERE dxds.name = 'system_health_azure') +ALTER EVENT SESSION system_health_azure ON DATABASE STATE = START; +GO diff --git a/Help/README.md b/Help/README.md new file mode 100644 index 00000000..2dae4b4c --- /dev/null +++ b/Help/README.md @@ -0,0 +1,19 @@ +# SQL Help + +Need free help? Just follow this simple step: +1. [Join GitHub](https://github.com/join) +2. Add star to this repo +3. Open new issue with a detailed explanation of your problem + +## How to ask right? + +1. [Create issue](https://github.com/ktaranov/sqlserver-kit/issues/new) in this repo or question on stackoverflow.com +2. Include: + 1. Operation system with detailed version (Windows, Ubuntu, Macos etc.). Example: `Microsoft Windows [Version 10.0.16299.248]` + 2. Relation database type (SQL Server preferred, Orcale, MySQL, PostgreSQL, SQLite etc.) with detailed version. Example: `Microsoft SQL Server 2017 (RTM-CU1) (KB4038634) - 14.0.3006.16 (X64) ... on Windows 10 Pro 10.0` + 3. Demo script (if necessary) to reproduce your problem. +3. Distribute your question using this channels: + 1. [Twitter #sqlhelp](https://twitter.com/search?q=%23sqlhelp&src=tyah) with `#sqlhelp` hash tag + 2. [Slack #sqlhelp](https://sqlcommunity.slack.com/messages/sqlhelp/) (more than 700 People) + 3. [SQLServerCentral Forum](https://www.sqlservercentral.com/Forums/) + 4. Telegram chat (Russian preferred): https://t.me/sqlcom diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..89f65430 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2015-2021 Konstantin Taranov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index 34b7d44f..00000000 --- a/LICENSE.md +++ /dev/null @@ -1,9 +0,0 @@ -# The MIT License (MIT) - -Copyright (c) 2015-2017 Konstantin Taranov - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/PowerShell/Clone-SQLLogin.ps1 b/PowerShell/Clone-SQLLogin.ps1 index 6bf0af3f..26ea2ea0 100644 --- a/PowerShell/Clone-SQLLogin.ps1 +++ b/PowerShell/Clone-SQLLogin.ps1 @@ -1,42 +1,45 @@ <# .Synopsis - Clone a SQL Server Login based on another exsiting login. + Clone a SQL Server Login based on another exsiting login. + .DESCRIPTION - Clone a SQL Server Login based on another exsiting login on one or multiple servers and the process can generate a script for auditing purpose. + Clone a SQL Server Login based on another exsiting login on one or multiple servers and the process can generate a script for auditing purpose. + .EXAMPLE - The following command scripts out the permissions of login account [John] and generates the script at "c:\temp\clone.sql" - Notice, parameters [OldLogin] and [NewLogin] uses the same value of "John" - Clone-SQLLogin -Server Server1, Server2 -OldLogin John -NewLogin John -FilePath "c:\temp\clone.sql" + The following command scripts out the permissions of login account [John] and generates the script at "c:\temp\clone.sql" + Notice, parameters [OldLogin] and [NewLogin] uses the same value of "John" + Clone-SQLLogin -Server Server1, Server2 -OldLogin John -NewLogin John -FilePath "c:\temp\clone.sql" .EXAMPLE The following command exports a script that can be used to clone login account [John] for new login account [David], and the script is created at "c:\temp\clone.sql" also the -Execute parameter means the new account "David" will be created Clone-SQLLogin -Server Server1, Server2 -OldLogin John -NewLogin David -NewPassword 'P@$$W0rd' -FilePath "c:\temp\clone.sql" -Execute; - + .Parameter ServerInstance - ServerInstance is of string array datat ype, and can accept a string of sql instance names, spearated by comma. (mandatory) - + ServerInstance is of string array datat ype, and can accept a string of sql instance names, spearated by comma. (mandatory) + .Parameter OldLogin - The login account is the source where all the permissions will be scripted out and to be used for the NewLogin account (mandatory) - + The login account is the source where all the permissions will be scripted out and to be used for the NewLogin account (mandatory) + .Parameter NewLogin - The login account is the target account that we want to clone (mandatory) - + The login account is the target account that we want to clone (mandatory) + .Parameter NewPassword The password for the new login account if we want to create the login, default to empty string "" (optional) - + .Parameter FilePath - The full path name for the generated sql script (optional) + The full path name for the generated sql script (optional) .Parameter Execute - This is a swich parameter, if present, it means we need to create the NewLogin account. - + This is a swich parameter, if present, it means we need to create the NewLogin account. + .OUTPUTS - none + none + .NOTES - A few service broker related permissions are not covered in this version 1. - Original link: https://www.mssqltips.com/sqlservertip/4572/cloning-a-sql-server-login-with-all-permissions-using-powershell/ - Author: Jeffrey Yao + A few service broker related permissions are not covered in this version 1. + Original link: https://www.mssqltips.com/sqlservertip/4572/cloning-a-sql-server-login-with-all-permissions-using-powershell/ + Author: Jeffrey Yao #> #requires -version 3.0 add-type -assembly "Microsoft.SqlServer.Smo, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"; #if Version-11.xx means sql server 2012 diff --git a/PowerShell/Collect_Windows_Counters.ps1 b/PowerShell/Collect_Windows_Counters.ps1 new file mode 100644 index 00000000..7ad22ea4 --- /dev/null +++ b/PowerShell/Collect_Windows_Counters.ps1 @@ -0,0 +1,61 @@ +# http://www.bradleyschacht.com/collecting-server-performance-metrics-powershell/ + +$outputDirectory = "C:\Temp"; #Directory where the restult file will be stored. + +$computerName = ""; #Set the Computer from which to collect counters. Leave blank for local computer. +$sampleInterval = 15; #Collection interval in seconds. +$maxSamples = 240; #How many samples should be collected at the interval specified. Set to 0 for continuous collection. + +# Check to see if the output directory exists. If not, create it. +if (-not(Test-Path $outputDirectory)) + { + Write-Host "Output directory does not exist. Directory will be created." + $null = New-Item -Path $outputDirectory -ItemType "Directory" + Write-Host "Output directory created."; + } + +# Strip the \ off the end of the directory if necessary. +if ($outputDirectory.EndsWith("\")) {$outputDirectory = $outputDirectory.Substring(0, $outputDirectory.Length - 1)}; + +#Create the name of the output file in the format of "computer date time.csv". +$outputFile = "$outputDirectory\$(if($computerName -eq ''){$env:COMPUTERNAME} else {$computerName}) $(Get-Date -Format "yyyy_MM_dd HH_mm_ss").csv"; + +# Write the parameters to the screen. +Write-Host " + +Collecting counters... +Press Ctrl+C to exit."; + +# Specify the list of performance counters to collect. +$counters = + @(` + "\Processor(_Total)\% Processor Time" ` + ,"\Memory\Available MBytes" ` + ,"\Paging File(_Total)\% Usage" ` + ,"\LogicalDisk(*)\Avg. Disk Bytes/Read" ` + ,"\LogicalDisk(*)\Avg. Disk Bytes/Write" ` + ,"\LogicalDisk(*)\Avg. Disk sec/Read" ` + ,"\LogicalDisk(*)\Avg. Disk sec/Write" ` + ,"\LogicalDisk(*)\Disk Read Bytes/sec" ` + ,"\LogicalDisk(*)\Disk Write Bytes/sec" ` + ,"\LogicalDisk(*)\Disk Reads/sec" ` + ,"\LogicalDisk(*)\Disk Writes/sec" + ); + +#Set the variables for the Get-Counter cmdlet. +$variables = @{ + SampleInterval = $sampleInterval; + Counter = $counters; +} + +#Add the computer name if it was not blank. +if ($computerName -ne "") {$variables.Add("ComputerName","$computerName")}; + +#Either set the sample interval or specify to collect continuous. +if ($maxSamples -eq 0) {$variables.Add("Continuous",1)} +else {$variables.Add("MaxSamples","$maxSamples")}; + +# Show the variables then execute the command while storing the results in a file. +$variables; +Get-Counter @Variables | Export-Counter -FileFormat csv -Path $outputFile; + \ No newline at end of file diff --git a/PowerShell/Convert-LSN.ps1 b/PowerShell/Convert-LSN.ps1 new file mode 100644 index 00000000..a138aa25 --- /dev/null +++ b/PowerShell/Convert-LSN.ps1 @@ -0,0 +1,55 @@ +function Convert-LSN { + <# + .SYNOPSIS + Converts Lsns between Hex and/or numeric formats + + .DESCRIPTION + Function takes an LSN in either split Hexadecimal format () or numeric + + It then returns both formats in an object + + https://stuart-moore.com/converting-sql-server-lsns-with-powershell/ + + .PARAMETER LSN + The LSN value to be converted + + .EXAMPLE + PS C:\ $output = Convert-LSN -LSN 0000047c:00000108:0001 + + Will return object $Output with the following value + $Output.HexLSN = 0000014:000000f3:0001 + $Output.NumericLSN = 20000000024300001 + #> + [CmdletBinding()] + param( + [string]$LSN + ) + + if ($LSN -match '^[a-fA-F0-9]{8}:[a-fA-F0-9]{8}:[a-fA-F0-9]{4}$') { + Write-Verbose -Message 'Hexadecimal LSN passed in, converting to numeric' + $sections = $LSN.Split(':') + $sect1 = [System.Convert]::ToInt64($sections[0], 16).ToString() + $sect2 = [System.Convert]::ToInt64($sections[1], 16).ToString().PadLeft(10, '0') + $sect3 = [System.Convert]::ToInt64($sections[2], 16).ToString().PadLeft(5, '0') + $Hexadecimal = $LSN + $Numeric = $sect1 + $sect2 + $sect3 + + } elseif ($LSN -match '^[0-9]{15}[0-9]+$') { + Write-Verbose -Message 'Numeric LSN passed in, converting to Hexadecimal' + $sect1 = '{0:x}' -f [System.Convert]::ToString($LSN.Substring(0, $LSN.length-15), 16).PadLeft(8,'0') + $sect2 = '{0:x}' -f [System.Convert]::ToString($LSN.Substring($lsn.length-14, 9), 16).PadLeft(8, '0') + $sect3 = '{0:x}' -f [System.Convert]::ToString($LSN.Substring($lsn.length-5, 5), 16).PadLeft(4, '0') + $Numeric = $LSN + $Hexadecimal = $sect1 + ':' + $sect2 + ':' + $sect3 + } else { + Write-Warning -Message 'LSN passed in is neither Numeric nor in the correct hexadecimal format' + return + } + + [PSCustomObject]@{ + Hexadecimal = $Hexadecimal + Numeric = $Numeric + } +} + +$output = Convert-LSN -LSN 0000014:000000f3:0001 \ No newline at end of file diff --git a/PowerShell/Convert_trc_to_2008r2.ps1 b/PowerShell/Convert_trc_to_2008r2.ps1 new file mode 100644 index 00000000..b60c20a3 --- /dev/null +++ b/PowerShell/Convert_trc_to_2008r2.ps1 @@ -0,0 +1,33 @@ +#requires -version 2.0 + +<# +.SYNOPSIS + Changes the version information in the header of a SQL Server trace + +.DESCRIPTION + Author: Gianluca Sartori - @spaghettidba + Create date: 2012-11-07 + https://spaghettidba.com/2012/11/08/more-on-converting-trace-files/ + +.PARAMETER fileName + Trace file name +#> + +## ============================================= +## Author: Gianluca Sartori - @spaghettidba +## Create date: 2012-11-07 +## Description: Changes the version information +## in the header of a SQL Server trace +## ============================================= +$fileName = "somefile.trc" + +# The version information we want to write: 0x0A = 10 = SQLServer 2008 +[Byte[]] $versionData = 0x0A +# The offset of the version information in the file +$offset = 390 + +[System.IO.FileMode] $open = [System.IO.FileMode]::OpenOrCreate +$stream = New-Object System.IO.FileStream -ArgumentList $fileName, $open +$stream.Seek($offset, [System.IO.SeekOrigin]::Begin); +$stream.Write($versionData, 0, $versionData.Length); +$stream.Close() diff --git a/PowerShell/Disable_CEIP.ps1 b/PowerShell/Disable_CEIP.ps1 new file mode 100644 index 00000000..c275bbd7 --- /dev/null +++ b/PowerShell/Disable_CEIP.ps1 @@ -0,0 +1,36 @@ +#requires -version 2.0 + +<# +.SYNOPSIS + Disable SQL Server CEIP services + +.DESCRIPTION + Author: Eric Cobb + Create date: 2020-02-18 + http://www.sqlnuggets.com/blog/disable-telemetry-on-multiple-sql-servers-with-powershell/ + +.PARAMETER server + Server list where disable SEIP services +#> + +$server = 'Server01' ,'Server02','Server03','Server04'; + +# Stop all CEIP services +invoke-command -computername $server {Get-Service |? name -Like "*TELEMETRY*" | ? status -eq "running" | Stop-Service}; + +# Disable all CEIP services +invoke-command -computername $server {Get-Service |? name -Like "*TELEMETRY*" | Set-Service -StartMode Disabled}; + +# Check service status (should see "stopped" and "disabled" +invoke-command -computername $server {Get-Service |? name -Like "*TELEMETRY*" | select -property name,starttype,status}; + +# Disable "Error Reporting" and "Customer Feedback" Registry Values +invoke-command -computername $server {Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server' -Recurse | Where-Object -Property Property -eq 'EnableErrorReporting'| Set-ItemProperty -Name EnableErrorReporting -Value 0}; +invoke-command -computername $server {Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server' -Recurse | Where-Object -Property Property -eq 'EnableErrorReporting'| Set-ItemProperty -Name CustomerFeedback -Value 0}; +invoke-command -computername $server {Get-ChildItem 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server' -Recurse | Where-Object -Property Property -eq 'EnableErrorReporting'| Set-ItemProperty -Name EnableErrorReporting -Value 0}; +invoke-command -computername $server {Get-ChildItem 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server' -Recurse | Where-Object -Property Property -eq 'EnableErrorReporting'| Set-ItemProperty -Name CustomerFeedback -Value 0}; + +# Check registry values (should see 0 for "EnableErrorReporting" and "CustomerFeedback") +invoke-command -computername $server {Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server' -Recurse | Where-Object -Property Property -eq 'EnableErrorReporting'}; +invoke-command -computername $server {Get-ChildItem 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server' -Recurse | Where-Object -Property Property -eq 'EnableErrorReporting'}; + \ No newline at end of file diff --git a/PowerShell/Disable_Enable_All_Triggers_In_Database.ps1 b/PowerShell/Disable_Enable_All_Triggers_In_Database.ps1 new file mode 100644 index 00000000..51ac8a30 --- /dev/null +++ b/PowerShell/Disable_Enable_All_Triggers_In_Database.ps1 @@ -0,0 +1,25 @@ +#requires -version 5.0 +#requires -modules dbatools + +<# +.SYNOPSIS + Disable and enable again all triggers in database + +.DESCRIPTION + Disable and enable again all triggers in database + https://jesspomfret.com/disable-all-triggers/ + +.PARAMETER database + Database name +#> + +$database = "AdventureWorks2017"; +$svr = Connect-DbaInstance -SqlInstance server1; +$foreach ($tbl in $svr.databases[$database].Tables) +{ + foreach ($tr in $($tbl.Triggers | Where-Object Isenabled)) { + $triggers += $tr | Select-Object @{l='SchemaName';e={$tbl.Schema}}, @{l='TableName';e={$tbl.name}}, @{l='TriggerName';e={$_.name}}; + $tr.isenabled = $FALSE; + $tr.alter(); + } +} diff --git a/PowerShell/Export-SQLTableToCSV.ps1 b/PowerShell/Export-SQLTableToCSV.ps1 new file mode 100644 index 00000000..eb24e65a --- /dev/null +++ b/PowerShell/Export-SQLTableToCSV.ps1 @@ -0,0 +1,488 @@ +#requires -version 4 +#requires -modules PSLogging +<# +.SYNOPSIS + Export in parallel sql server tables into csv files using bcp utility +.DESCRIPTION + Export in parallel sql server tables into csv files using bcp utility + bcp docs: https://docs.microsoft.com/en-us/sql/tools/bcp-utility +.PARAMETER CSVPath + Specifies path to out csv file(s) and log file +.PARAMETER ServerName + Specifies a SQL Server name +.PARAMETER DatabaseName + Specifies a database name +.PARAMETER CodePage + Specifies code page +.PARAMETER SchemaName + Specifies shema name. Use this parameter with parameter TableName +.PARAMETER TableName + Specifies table name. +.PARAMETER ExcludeColumns + Specifies which columns will be excluded. +.PARAMETER OrderByColumns + Sets order by specific columns. +.PARAMETER MinRowCount + Specifies a minimum row count for table(s) which will be unloaded +.PARAMETER MaxRowCount + Specifies a maximum row count for table(s) which will be unloaded +.PARAMETER FormatFile + Specify format file +.PARAMETER FieldTerminator + Specify field terminator +.PARAMETER RowTerminator + Specify row terminator +.PARAMETER FileExtension + Determines the file extension +.PARAMETER Collation + Specifies collation. Using collation parameter not allowed without format file parameter ('xml' or 'fmt') +.PARAMETER OutputColumnHeaders + Specifies presence of headers - true - export with headers; false - export without headers +.PARAMETER SavePhysicalOrder + Specifies column order. False - Alphabet column order type; true - physical column order type +.PARAMETER OrderByColumns_term + Sets order by specific columns +.OUTPUTS Log File + The script log file stored in C:\Windows\Temp\.log +.NOTES + Version: + Author: Konstantin Taranov k@taranov.pro + Author Modified: Alexander Titenko aleks.titenko@gmail.com + Creation Date: 2017-09-26 + Last modified: 2017-09-29 + Purpose/Change: Add PSLogging module +.EXAMPLE + Export-SQLTableToCSV -CSVPath D:\12\ -ServerName NL-04 -DatabaseName NIIGAZ -MinRowCount 1 -MaxRowCount 3; +#> + +#---------------------------------------------------------[Initialisations]-------------------------------------------------------- + +#Set Error Action to Silently Continue +$ErrorActionPreference = 'SilentlyContinue' + +#Import Modules & Snap-ins +Import-Module PSLogging + +#----------------------------------------------------------[Declarations]---------------------------------------------------------- + +#Script Version +$sScriptVersion = '1.1' + +#Log File Info +$sLogPath = 'D:\1\' +$sLogName = 'Export-SQLTableToCSV.log' +$sLogFile = Join-Path -Path $sLogPath -ChildPath $sLogName + +#-----------------------------------------------------------[Functions]------------------------------------------------------------ + +Function Export-SQLTableToCSV +{ + Param( + # Specifies path to out csv file(s) and log file + [Parameter(Mandatory=$true)] + [string]$CSVPath, + # Specifies a SQL Server name + [Parameter(Mandatory=$true)] + [string]$ServerName, + # Specifies a database name + [Parameter(Mandatory=$true)] + [string]$DatabaseName, + [Parameter(Mandatory=$false)] + [string]$CodePage = '-C65001', + [Parameter(Mandatory=$false)] + [string]$ExcludeColumns, + [Parameter(Mandatory=$false)] + [string]$SchemaName, + [Parameter(Mandatory=$false)] + [string]$TableName, + [Parameter(Mandatory=$false)] + [string]$OrderByColumns, + [Parameter(Mandatory=$false)] + [string]$MinRowCount, + [Parameter(Mandatory=$false)] + [string]$MaxRowCount, + [Parameter(Mandatory=$false)] + [string]$FormatFile, + [Parameter(Mandatory=$false)] + [string]$FieldTerminator, + [Parameter(Mandatory=$false)] + [string]$RowTerminator, + [Parameter(Mandatory=$false)] + [string]$FileExtension, + [Parameter(Mandatory=$false)] + [string]$Collation, + [Parameter(Mandatory=$false)] + [switch]$OutputColumnHeaders, + [Parameter(Mandatory=$false)] + [switch]$SavePhysicalOrder, + [Parameter(Mandatory=$false)] + [string]$OrderByColumns_term = ',' + + ) + Begin + { + Write-LogInfo -LogPath $sLogFile -Message "Srart export SQL Tables from $DatabaseName in $CSVPath with bcp utility" + $sw = [Diagnostics.Stopwatch]::StartNew() + Write-Host "[*] Start script at $(Get-Date -Format 'HH:mm:ss')" -foreground:yellow; + } + Process + { + Try + { + if (-not(Test-Path $CSVPath)) + { + $message = "Path $CSVPath doesn't exist!" + Write-Host $message -ForegroundColor Red + Write-LogInfo -LogPath $sLogFile -Message $message + break + } + + $alllowableFormatFileTypes = @('','xml','fmt') + + if ($alllowableFormatFileTypes -notcontains $FormatFile) + { + $message = "Allowed values for parameter FormatFile is xml, fmt or blank value" + Write-Host $message -ForegroundColor Red + Write-LogInfo -LogPath $sLogFile -Message $message + break + } + + if (-not($FormatFile) -and $Collation) + { + $message = "Using collation parameter not allowed without format file parameter ('xml' or 'fmt')" + Write-Host $message -ForegroundColor Red + Write-LogInfo -LogPath $sLogFile -Message + break + } + + if ($ExcludeColumns[0] -notcontains '[' -and $ExcludeColumns -notcontains '') + { + $message = "Parameter orderByColumns must be in square brackets and separated by comma" + Write-Host $message -ForegroundColor Red + Write-LogInfo -LogPath $sLogFile -Message + break + } + + if ($ExcludeColumns[0] -contains '[' -and $FormatFile -notcontains '') + { + $message = "Parameter ExcludeColumns must be blank, since parameter FormatFile is present" + Write-Host $message -ForegroundColor Red + Write-LogInfo -LogPath $sLogFile -Message + break + } + + if ($ExcludeColumns -and ($SchemaName -or $TableName)) + { + $message = "Parameter ExcludeColumns must be blank, since parameters SchemaName or TableName are present" + Write-Host $message -ForegroundColor Red + Write-LogInfo -LogPath $sLogFile -Message + break + } + + if ($OrderByColumns -and ($SchemaName -or $TableName)) + { + $message = "Parameter OrderByColumns must be blank, since parameters SchemaName or TableName are present" + Write-Host $message -ForegroundColor Red + Write-LogInfo -LogPath $sLogFile -Message + break + } + + if (-not($OutputColumnHeaders)) + { + $message = "Headers won't output. If you want headers run with switch parameter: -OutputColumnHeaders" + Write-Host $message -ForegroundColor Yellow + Write-LogInfo -LogPath $sLogFile -Message $message + } + + if (-not($SavePhysicalOrder)) + { + $message = "Alphabet column order type use. If you want column physical order run with switch parameter: -SavePhysicalOrder" + Write-Host $message -ForegroundColor Yellow + Write-LogInfo -LogPath $sLogFile -Message $message + } + else + { + $message = "Physical column order is used" + Write-Host $message -ForegroundColor Yellow + Write-LogInfo -LogPath $sLogFile -Message "Use physical column order" + } + + if ($Collation) + { + $invokeCollation = Invoke-Sqlcmd -ServerInstance $ServerName -Database $DatabaseName -Verbose -Query " + select COUNT(*) from sys.fn_helpcollations() WHERE name = '$Collation';"; + + if ($invokeCollation.Column1 -eq 0) + { + $message = "Defined collation not found in server collations list" + Write-Host $message -ForegroundColor Yellow + Write-LogInfo -LogPath $sLogFile -Message $message + $Collation = '' + } + } + + if ($FieldTerminator) + { + $FieldTerminatorToHeaders = $FieldTerminator + $FieldTerminator = '-t"' + $FieldTerminator + '"'; + } + + if ($RowTerminator) + { + $RowTerminator = '-r"' + $RowTerminator + '"' + } + + if ($CodePage) + { + $CodePage = '-c ' + $CodePage + '' + } + + if ($FormatFile -and $FormatFile -eq 'xml') + { + $FormatFileForBcp = 'xml" -x' + } + else + { + $FormatFileForBcp = 'fmt"' + } + + if ($ShemaName) + { + $tableDependencySchemaName = "and t.schema_id = (SELECT SCHEMA_ID('$ShemaName'))" + } + else + { + $tableDependencySchemaName = '' + } + + if ($TableName) + { + $tableDependencyTableName = "and t.name = '$TableName'" + } + else + { + $tableDependencyTableName = '' + } + + $tableDependecy = Invoke-Sqlcmd -ServerInstance $ServerName -Database $DatabaseName -Verbose -Query " + SELECT QUOTENAME(SCHEMA_NAME(t.schema_id)) AS SchemaName + , QUOTENAME(t.name) AS TableName + , SUM(ps.row_count) AS TableRowCount + FROM sys.tables t + INNER JOIN sys.dm_db_partition_stats ps + ON ps.object_id = t.object_id + WHERE index_id < 2 + GROUP BY t.name + , t.schema_id + HAVING SUM(ps.row_count) >= $MinRowCount AND SUM(ps.row_count) <= $MaxRowCount $tableDependencySchemaName $tableDependencyTableName + ORDER BY SUM(ps.row_count) ASC + OPTION (RECOMPILE); + "; + + $tableDependecy + + Foreach ($t in $tableDependecy) + { + $tableFullName = $t[0] + '.' + $t[1] + $ShemaName = $t[0].Split('[').Split(']') + $TableName = $t[1].Split('[').Split(']') + $ShemaName = ([string]$ShemaName).Trim() + $TableName = ([string]$TableName).Trim() + $tableFullNameAndFileExt = $TableFullName + '.' + $FileExtension + $filePath = $CSVPath + $TableFullName + '.' + $FileExtension + $filePathWithHeaders = $CSVPath + $TableFullName + '_headers.' + $FileExtension + $FormatFilePath = $CSVPath + $TableFullName + '.' + $FormatFile + $FormatFileDelPath = $CSVPath + $TableFullName + 'del.' + $FormatFile + + Write-Debug "tableFullName:$tableFullName` + ShemaName:$ShemaName` + trimmedShemaName:$trimmedShemaName` + TableName:$TableName` + trimmedTableName:$trimmedTableName` + tableFullNameAndFileExt:$tableFullNameAndFileExt` + filePath:$filePath` + filePathWithHeaders:$filePathWithHeaders` + FormatFilePath:$FormatFilePath` + FormatFileDelPath:$FormatFileDelPath" + + if ($OrderByColumns) + { + $CountOrderByColumns = $OrderByColumns.split($OrderByColumns_term).Count + $invokeCountOrderByColumns = Invoke-Sqlcmd -ServerInstance $ServerName -Database $DatabaseName -Verbose -Query " + SELECT COUNT(*) + FROM sys.columns sac + WHERE sac.object_id = (SELECT OBJECT_ID('$tableFullName')) AND Name IN ('$OrderByColumns'); + "; + Write-Debug "OrderByColumns: $OrderByColumns` + CountOrderByColumns: $CountOrderByColumns" + + if ($invokeCountOrderByColumns.Column1 -notin $CountOrderByColumns) + { + write-Host "Some columns in OrderByColumns not exists in table" -ForegroundColor Red + break + } + Write-Debug "invokeCountOrderByColumns.Column1: $invokeCountOrderByColumns.Column1" + } + + if ($SavePhysicalOrder) + { + $columnsOrder = 'ORDER BY sac.column_id' + } + else + { + $columnsOrder = 'ORDER BY Name' + } + Write-Debug "SavePhysicalOrder: $SavePhysicalOrder` + columnsOrder: $columnsOrder" + + $invokeOrderByColumns = Invoke-Sqlcmd -ServerInstance $ServerName -Database $DatabaseName -Verbose -Query " + SELECT Name + FROM sys.columns sac + WHERE sac.object_id = (SELECT OBJECT_ID('$tableFullName')) AND Name NOT IN ('$ExcludeColumns') $columnsOrder; + "; + Write-Debug "ExcludeColumns: $ExcludeColumns" + + $Columns = '' + $ColumnsToHeaders = '' + + foreach ($i in $invokeOrderByColumns.Name) + { + $Columns += '[' + $i + '],' + $ColumnsToHeaders += $i + $FieldTerminatorToHeaders + } + $Columns = $Columns -replace ".$" + $ColumnsToHeaders = "'" + ($ColumnsToHeaders -replace ".$") + "'" + + Write-Debug "Columns: $Columns` + ColumnsToHeaders: $ColumnsToHeaders" + + $bcpStatement = 'bcp "SELECT '+ $Columns +' FROM ['+ $ServerName +'].['+ $DatabaseName +'].['+ $ShemaName +'].['+ $TableName +']' + ` + $OrdrByColumns + '" queryout "' + $CSVPath + '['+ $ShemaName +'].['+ $TableName +'].' + ` + $FileExtension + '" -T -S ' + $ServerName + ' ' + $CodePage + ' ' + $FieldTerminator + ' ' + $RowTerminator + ''; + + Write-Debug "bcpStatement: $bcpStatement" + + Invoke-Expression $bcpStatement + + if ($OutputColumnHeaders) + { + $bcpStatement = 'bcp "SELECT ' + $ColumnsToHeaders + '" queryout "' + $CSVPath + '['+ $ShemaName +'].['+ $TableName +']_headers.' + ` + $FileExtension + '" -T -S ' + $ServerName + ' ' + $CodePage + ' ' + $FieldTerminator + ' ' + $RowTerminator + ''; + + Write-Debug "bcpStatement: $bcpStatement" + + Invoke-Expression $bcpStatement + } + + cmd /C "copy /b $filePathWithHeaders + $filePath $filePathWithHeaders" + cmd /C "del $filePath" + cmd /C "ren $filePathWithHeaders `"$tableFullNameAndFileExt`"" + + if ($FormatFile -eq ('xml' -or 'fmt') -and $SavePhysicalOrder) + { + $bcpStatement = 'bcp ['+ $DatabaseName +'].'+ $tableFullName +' format nul -c -f "' + $CSVPath + ` + '['+ $ShemaName +'].['+ $TableName +'].' + $FormatFileForBcp + ' ' + $FieldTerminator + ' -T '; + + Write-Debug "bcpStatement: $bcpStatement" + + Invoke-Expression $bcpStatement + + } + + if ($FormatFile) + { + $tmpSchemaAndTableName = '['+ $ShemaName +'].[tmp' + $TableName + ']' + + if ($SavePhysicalOrder) + { + $bcpStatement = 'bcp ['+ $DatabaseName +'].'+ $tableFullName +' format nul -c -f "' + $CSVPath + ` + '['+ $ShemaName +'].['+ $TableName +']del.' + $FormatFileForBcp + ' ' + $FieldTerminator + ' -T '; + + Write-Debug "bcpStatement: $bcpStatement" + + Invoke-Expression $bcpStatement + } + else + { + $invokeStatement = 'IF OBJECT_ID(''['+ $DatabaseName +'].'+ $tmpSchemaAndTableName +''') IS NOT NULL DROP TABLE ' +$tmpSchemaAndTableName +'; + SELECT ' + $Columns + ' INTO ' +$tmpSchemaAndTableName +' FROM ['+ $DatabaseName +'].'+ $tableFullName +' WHERE 1=2;' + + Write-Debug "invokeStatement: $invokeStatement" + + Invoke-Sqlcmd -ServerInstance $ServerName -Database $DatabaseName -Verbose -Query $invokeStatement + } + + } + + if ($FormatFile) + { + $invokeCollation = Invoke-Sqlcmd -ServerInstance $ServerName -Database $DatabaseName -Verbose -Query " + SELECT CONVERT(VARCHAR(128), DATABASEPROPERTYEX('$DatabaseName', 'collation')); + ;"; + + $CurrentCollation = $invokeCollation.Column1 + Write-Debug "CurrentCollation: $CurrentCollation" + + if ($FormatFile -eq 'xml') + { + $lob = 'SINGLE_NCLOB' + } + if ($FormatFile -eq 'fmt') + { + $lob = 'SINGLE_CLOB' + } + + if ($Collation -eq '' -and $FormatFile -eq 'fmt') + { + $Collation = '""""' + } + + if ($Collation -eq '' -and $FormatFile -eq 'xml') + { + $Collation = '' + } + + $bcpStatement = 'bcp "SELECT REPLACE(BulkColumn, '''+ $CurrentCollation +''', '''+ $Collation +''') AS BulkColumn + FROM OPENROWSET(BULK '''+ $FormatFileDelPath +''', '+ $lob +') as x" queryout "'+ $FormatFilePath +'" -c -T' + + Write-Debug "bcpStatement - $bcpStatement" + + Invoke-Expression $bcpStatement + + cmd /C "del $FormatFileDelPath" + } + } + } + Catch + { + Write-LogError -LogPath $sLogFile -Message $_.Exception -ExitGracefully + Break + } + } + End + { + If (-not $Error) + { + Write-Host 'Completed Successfully.' -ForegroundColor Green + Write-Host "[*] Stop script at $(Get-Date -Format 'HH:mm:ss')" -foreground:yellow; + $sw.Stop(); + $sw.Elapsed | Format-Table -Property Minutes, Seconds, Milliseconds -AutoSize; + Write-LogInfo -LogPath $sLogFile -Message 'Completed Successfully.' + Write-LogInfo -LogPath $sLogFile -Message ' ' + } + else + { + Write-Error -ErrorRecord + Write-LogInfo -LogPath $sLogFile -Message $Error + } + } +} + +#-----------------------------------------------------------[Execution]------------------------------------------------------------ + +Start-Log -LogPath $sLogPath -LogName $sLogName -ScriptVersion $sScriptVersion + +Export-SQLTableToCSV -CSVPath D:\1\ -ServerName NL-04 -DatabaseName NIIGAZ -MinRowCount 1 -MaxRowCount 2 -CodePage '-C65001' -FileExtension txt -FieldTerminator '|' -RowTerminator '\n' -OutputColumnHeaders -SavePhysicalOrder -Debug -FormatFile xml + + +Stop-Log -LogPath $sLogFile diff --git a/PowerShell/Export_Query_To_Csv.ps1 b/PowerShell/Export_Query_To_Csv.ps1 new file mode 100644 index 00000000..d31f9082 --- /dev/null +++ b/PowerShell/Export_Query_To_Csv.ps1 @@ -0,0 +1,40 @@ +#requires -version 5.0 +#requires -modules sqlserver + +<# +.SYNOPSIS + Export SQL server table to csv file with quotes (if needed) and header + +.DESCRIPTION + Piping Invoke-Sqlcmd into csv file with quotes only if needed. + Also replace False and True on 0 and 1 for bit types columns. + +.NOTES + Original link: http://www.sqlmovers.com/removing-quotes-from-csv-created-by-powershell/ + Author: Russ Loski + Version: 1.3 + Modified: 2020-01-09 by Konstantin Taranov + Source link: https://github.com/ktaranov/sqlserver-kit/blob/master/Powershell/Export_Query_To_Csv.ps1 +#> + +$databaseName = "master"; +$fileName = $tableName = "sys.objects"; +$delimiter = ","; # possible values "`t", ",", ";", "|" +if ($delimiter -eq "|") { + $delimiterReg = $delimiterBit = "\|"; + } else { + $delimiterReg = $delimiterBit = $delimiter; + }; +$regReplace = '\G(?^|' + $delimiterReg + '+)(("(?[^' + $delimiterReg + '"]*?)"(?=' + $delimiterReg + '|$))|(?".*?(? +function Format-SQLCode { + [OutputType([String])] + [cmdletbinding()] + param( + #Style for format script t-sql + [ValidateSet('Collapsed', 'Commas before', 'Default', 'Indented', 'Right aligned')] + [string]$Style, + #Path to file + [Parameter(Mandatory, ParameterSetName = 'File', ValueFromPipelineByPropertyName = $true)] + [Alias('FilePath', 'FullNamePath')] + [string]$FullName, + #Script + [Parameter(Mandatory, ParameterSetName = 'Script')] + [string]$Script + ) + begin { + $ErrorActionPreference = 'Continue'; + $FnName = '[Format-RedGateScriptSQL]'; + if ((Invoke-WebRequest -UseBasicParsing 'https://promptformatapi.red-gate.com/').StatusCode -ne 200) { + Write-Warning "$FnName Check your connection with the Internet"; + return; + } + } + process { + $Uri = "https://promptformatapi.red-gate.com/api/format/$Style"; + try { + if ($FullName) { + # preparing body for request + Write-Verbose "$FnName Get content from file: $FullName"; + $FileContent = Get-Content $FullName -Encoding UTF8 -Raw; + $Body = "`"$FileContent`""; + Write-Verbose "$Body"; + } + elseif ($Script) { + Write-Verbose "$Body"; + $Body = "`"$Script`""; + } + + Write-Verbose "$FnName $paramInvokeWebRequest"; + + Write-Verbose "$FnName Invoke-WebRequest"; + $Response = Invoke-WebRequest ` + -Uri $Uri ` + -Method "POST" ` + -Headers @{"path" = "/api/format/Collapsed"; "origin" = "https://www.red-gate.com"; "accept-encoding" = "gzip, deflate, br"; "accept-language" = "pl-PL,pl;q=0.9,en-US;q=0.8,en;q=0.7"; "user-agent" = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"; "accept" = "*/*"; "referer" = "https://www.red-gate.com/products/sql-development/sql-prompt/?utm_source=format-sql&utm_medium=redirect&utm_campaign=sqlprompt"; "authority" = "promptformatapi.red-gate.com"; "scheme" = "https"; "dnt" = "1"; "method" = "POST"} ` + -ContentType "application/json" ` + -Body $Body ` + + if ($Response.StatusCode -eq 200) { + [string]$FormattedScript = ($Response.Content).replace('\r\n', '`r`n'); + return Invoke-Expression -Command $FormattedScript; + } + } + catch [Microsoft.PowerShell.Commands.HttpResponseException] { + Write-Warning "$(($_.ErrorDetails.Message | ConvertFrom-Json).Details) - $FullName"; + } + catch { + Write-Warning "$($_.ErrorDetails.Message) - $FullName"; + } + } + end { }; +} diff --git a/PowerShell/Get-QueryPlan.ps1 b/PowerShell/Get-QueryPlan.ps1 new file mode 100644 index 00000000..28b312a0 --- /dev/null +++ b/PowerShell/Get-QueryPlan.ps1 @@ -0,0 +1,153 @@ +<# +.Synopsis + Formatting your T-SQL code +.DESCRIPTION + Formatting T-SQL code through RedGate Format Api (https://www.red-gate.com/products/sql-development/sql-prompt/) + + Works on PowerShell Core (aka PowerShell 6+) +.EXAMPLE + $Script = '--(Query 16)_(AlwaysOn AG Cluster) + SELECT cluster_name, quorum_type_desc, quorum_state_desc + FROM sys.dm_hadr_cluster WITH (NOLOCK) OPTION (RECOMPILE); + ------' + + Format-SQLCode -Script $Script -Style Default +.EXAMPLE + Formatting one file + + Format-SQLCode ` + -FullName 'C:\SQL Server 2014 Diagnostic Information Queries\(Query 11)_(SQL Server Agent Alerts).sql' ` + -Style Default +.EXAMPLE + Formatting all file on a directory + + Get-ChildItem 'C:\SQL Server 2014 Diagnostic Information Queries' -File | Format-SQLCode -Style Default + +.EXAMPLE + Formatting all file on a directory and save the result to file. + + $ListFiles = Get-ChildItem 'C:\Temp\SQL Server 2014 Diagnostic Information Queries\' -File + Foreach($File in $ListFiles) { + $File | Format-SQLCode -Style Indented | Set-Content -PassThru -Path $File.FullName + } + +.LINK + Author: Mateusz Nadobnik + Link: http://mnadobnik.pl/format-sqlcode +  + Date: 01.02.2019 + Version: 1.0.0.0 + Keywords: Formatting, T-SQL, RedGate, SQL Prompt + Notes: + Changelog: +#> +###################################################################################### +# +# File Name: Get-QueryPlan.ps1 +# +# Applies to: SQL Server 2008 +# SQL Server 2008 R2 +# SQL Server 2012 +# +# Purpose: Used to retrieve an XML query plan from cache. +# +# Prerequisite: Powershell must be installed. +# SQL Server components must be installed. +# +# Parameters: [string]$SqlInstance - SQL Server name (Ex: SERVER\INSTANCE) +# [string]$PlanHandle - Binary query handle +# +# Author: Patrick Keisler +# +# Version: 1.0.0 +# +# Date: 08/30/2013 +# +# Help: http://www.patrickkeisler.com/2013/09/the-case-of-null-queryplan.html +# +###################################################################################### + +#Define input parameters +param ( + [Parameter(Mandatory=$true)] + [ValidateNotNullOrEmpty()] + [string] + $SqlInstance + + ,[Parameter(Mandatory=$true)] + [ValidateNotNullOrEmpty()] + [string] + $PlanHandle + ) + +Write-Host "Script starting." + +#Grab the path where the Powershell script was executed from. +$path = Split-Path $MyInvocation.MyCommand.Path + +#Build the SQL Server connection objects +$conn = New-Object System.Data.SqlClient.SqlConnection +$builder = New-Object System.Data.SqlClient.SqlConnectionStringBuilder +$cmd = New-Object System.Data.SqlClient.SqlCommand + +#Build the TSQL statement & connection string +$SqlCommand = "SELECT query_plan FROM sys.dm_exec_text_query_plan(" + $PlanHandle + ",DEFAULT,DEFAULT);" +$builder.psBase.DataSource = $SqlInstance +$builder.psBase.InitialCatalog = "master" +$builder.psBase.IntegratedSecurity = $true +$builder.psBase.ApplicationName = "Get-QueryPlan" +$builder.psBase.Pooling = $true +$builder.psBase.ConnectTimeout = 15 +$conn.ConnectionString = $builder.ConnectionString +$cmd.Connection = $conn +$cmd.CommandText = $SqlCommand + +try +{ + if ($conn.State -eq "Closed") + { + #Open a connection to SQL Server + $conn.Open() + } + + #Execute the TSQL statement + [string]$QueryPlanText = $cmd.ExecuteScalar() + + #Write the output to a file + $FileName = $path + "\output.sqlplan" + $stream = New-Object System.IO.StreamWriter($FileName) + $stream.WriteLine($QueryPlanText) + + if ($stream.BaseStream -ne $null) + { + #Close the stream object + $stream.close() + } + + if ($conn.State -eq "Open") + { + #Close the SQL Server connection + $conn.Close() + } + + Write-Host "Script completed successfully." +} +catch +{ + #Capture errors if needed + if ($_.Exception.InnerException) + { + $Host.UI.WriteErrorLine("ERROR: " + $_.Exception.InnerException.Message) + if ($_.Exception.InnerException.InnerException) + { + $Host.UI.WriteErrorLine("ERROR: " + $_.Exception.InnerException.InnerException.Message) + } + } + else + { + $Host.UI.WriteErrorLine("ERROR: " + $_.Exception.Message) + } + + Write-Host . + Write-Host "ERROR: Script failed." +} diff --git a/PowerShell/OnlineFilegroupMigration.ps1 b/PowerShell/OnlineFilegroupMigration.ps1 new file mode 100644 index 00000000..e82d6827 --- /dev/null +++ b/PowerShell/OnlineFilegroupMigration.ps1 @@ -0,0 +1,338 @@ +# SQL Server Online Filegroup Migration for Powershell +# Author: Bob Pusateri, http://www.bobpusateri.com +# Date: March 2013 +# +# This script is provided "as is" without warranty of any kind, +# either expressed or implied. It is the user's reponsibility +# to read and understand this code before executing on any +# system. Always test in a development environment!! + + +# REQUIRED FIELDS +$serverName = "ServerName"; # name of the instance +$dbName = "DBName"; # name of the database +$sourceFG = "SourceFG"; # filegroup you're moving objects out of +$destFG = "DestFG"; # filegroup you're moving objects into +$logPath = "C:\path\to\fg_move_logs"; # all queries are logged to this folder so you have record of what was run + +# FILTERS - if these are non-null only the objects that match will be migrated +$schemaFilter = $null; # can be $null, a literal "tablename" or a LIKE "%foo%" +$nameFilter = $null; # can be $null, a literal "tablename" or a LIKE "%foo%" +$minSizeFilter = $null; # can be $null or size in MB +$maxSizeFilter = $null; # can be $null or size in MB + +# If an individual query exceeds this timeout value it will be cancelled +$queryTimeoutSeconds = 21600; # 6 hours + +$runQueries = "n"; # "y" will execute the queries. + #"n" will print to screen & log but not execute + +$ErrorActionPreference = 'Stop'; +$dtStart = Get-Date; + +[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null; + +# this just helps for printing errors to console +Function PrintUpdate($str, $printToScreen) { + $s = (Get-Date -format HH:mm:ss) + " $str"; + if($printToScreen) { + if($host.Name -eq "ConsoleHost") { + Write-Host $s; + } else { # no host is present in SQL Agent + Write-Output $s; + } + } + $s | out-file -filepath $logFile -append; +} + +# gets the columns that make up an index. +Function GetIndexColumns($idx, $includedColumns) { + $colStr = ""; + foreach($ic in $idx.IndexedColumns) { + if($ic.IsIncluded -eq $includedColumns) { + $colStr += "[" + $ic.Name + "]"; + if($ic.Descending -eq $true) { + $colStr += " DESC" + } + $colStr += ", "; + } #if + } # foreach + if ($colStr.length -gt 0) { + return $colStr.Substring(0, $colStr.length-2); + } else { + return $colStr; + } +} # GetIndexColumns + +Function RunSQLQuery($queryStr) { + try { + PrintUpdate $queryStr $false; + if($runQueries -eq "y") { + $a = Invoke-Sqlcmd -ServerInstance $serverName -database $dbName -query $queryStr -OutputSQLErrors $true -QueryTimeout $queryTimeoutSeconds; + return $a; + } + } catch { + PrintUpdate $_ $true; + } +} # RunSQLQuery + +$server = New-Object Microsoft.SqlServer.Management.Smo.Server($serverName); + +if (!(Test-Path $logPath)) { + New-Item $logPath -Type Directory +} + +$logFile = "$logPath\" + (Get-Date -UFormat %Y%m%d_%H%M%S) + ".log"; + +if ($server.Edition -eq $null) { + throw "Cannot connect to server $serverName."; +} + +if(!$server.Edition.ToLower().Contains("enterprise") -and !$server.Edition.ToLower().Contains("developer")) { + throw "You need enterprise or developer edition to do online index operations"; +} + +$db = $server.Databases[$dbName]; + +if ($db -eq $null) { + throw "Database [$dbName] does not exist."; +} + +if ($db.FileGroups[$sourceFG] -eq $null) { + throw "Source filegroup [$sourceFG] does not exist."; +} + +if ($db.FileGroups[$destFG] -eq $null) { + throw "Source filegroup [$destFG] does not exist."; +} + +# get all indexes in source FG satisfying schema & name filters +$qry = "SELECT s.name AS SchemaName, + o.name AS ObjName, + o.object_id AS ObjID, + p.index_id AS IndexID, + i.name AS IdxName, + i.is_unique AS IsUnique, + ROUND(CAST(au.data_pages AS FLOAT)/128,2) AS Size_MB, + f.name AS DataFilegroup, + f2.name AS LOBFilegroup +FROM sys.allocation_units au WITH (NOLOCK) + JOIN sys.partitions p WITH (NOLOCK) ON au.container_id = p.partition_id + JOIN sys.objects o WITH (NOLOCK) ON p.object_id = o.object_id + JOIN sys.indexes i WITH (NOLOCK) ON p.index_id = i.index_id AND i.object_id = p.object_id + JOIN sys.schemas s WITH (NOLOCK) ON o.schema_id = s.schema_id + LEFT JOIN sys.tables t WITH (NOLOCK) ON o.object_id = t.object_id + LEFT JOIN sys.filegroups f WITH (NOLOCK) ON au.data_space_id = f.data_space_id + LEFT JOIN sys.filegroups f2 WITH (NOLOCK) ON t.lob_data_space_id = f2.data_space_id +WHERE au.[type] = 1 + AND i.[type] <= 2 -- heap, clustered, nonclustered + AND (f.[name] = '$sourceFG' OR f2.[name] = '$sourceFG')"; + +if ($schemaFilter -ne $null) { + $qry += "`n`tAND s.name LIKE '$schemaFilter'"; +} + +if ($nameFilter -ne $null) { + $qry += "`n`tAND o.name LIKE '$nameFilter'"; +} + +if ($minSizeFilter -ne $null) { + $qry += "`n`tAND au.data_pages > " + ($minSizeFilter * 128); +} + +if ($maxSizeFilter -ne $null) { + $qry += "`n`tAND au.data_pages <= " + ($maxSizeFilter * 128); +} + +$qry += "`nORDER BY SchemaName, ObjName, p.index_id;"; + +$idxList = Invoke-Sqlcmd -ServerInstance $serverName -database $dbName -query $qry + +$totalSize = 0; +$migratedSize = 0; +$foreachIndex = 0; +$foreachSize = $idxList.Length; + +#iterate through each index +foreach ($i in $idxList | sort Size_MB,SchemaName,ObjName) { + $sn = $i.SchemaName; + $on = $i.ObjName; + $iid = $i.IndexID; + $in = $i.IdxName; + $sz = $i.Size_MB; + $oid = $i.ObjID; + $online = "ON"; + + $foreachIndex += 1; + $totalSize += $sz; + + PrintUpdate "[$foreachIndex / $foreachSize] Moving $sn.$on ($iid) [$sz MB]" $true; + # does index contain datatypes that prohibit online operations? + #if($online = "ON") { + if($iid -le 1) { + # if indexID = 0 then look in sys.columns + $qry = "SELECT COUNT(c.OBJECT_ID) AS n + FROM sys.columns c + INNER JOIN sys.objects o ON c.object_id = o.object_id + INNER JOIN sys.schemas s ON o.schema_id = s.schema_id + INNER JOIN sys.types t ON c.user_type_id = t.user_type_id + WHERE s.name = '$sn' + AND o.name = '$on' + AND ( + t.name IN ('text','ntext','image','xml') + OR ( + t.name IN ('varchar','nvarchar','varbinary') + AND + t.max_length = -1 + ) + );"; + } else { + # else look in sys.index_columns + $qry = "SELECT COUNT(ic.object_id) AS n + FROM sys.index_columns ic + INNER JOIN sys.objects o ON ic.object_id = o.object_id + INNER JOIN sys.schemas s ON o.schema_id = s.schema_id + INNER JOIN sys.columns c ON ic.object_id = c.object_id AND ic.column_id = c.column_id + INNER JOIN sys.types t ON c.user_type_id = t.user_type_id + WHERE s.name = '$sn' + AND o.name = '$on' + AND ic.index_id = $iid + AND ( + t.name IN ('text','ntext','image','xml') + OR ( + t.name IN ('varchar','nvarchar','varbinary') + AND + t.max_length = -1 + ) + );"; + } + + try { + $rs = Invoke-Sqlcmd -ServerInstance $serverName -database $dbName -query $qry; + if($rs[0] -gt 0) { + $online = "OFF"; + } + } catch { + $online = "OFF"; + } + #} + + # if lob filegroup needs to change re-create and swap + if(![System.DBNULL]::Value.Equals($i.LOBFilegroup) -and $i.LOBFilegroup -ne $destFG -and $iid -le 1) { + # skipping because we're not doing offline operations + PrintUpdate " Skipping - LOB filegroup prevents online operations" $true; + continue; + } # + + # if index = 0 then create CL, move, delete CL + if($iid -eq 0) { + if($online -eq "OFF") { + # skipping because it can't be done online + PrintUpdate " Skipping - column(s) prevents online operations" $true; + continue; + } + + # disable all NC indexes + $tbl = $db.Tables.Item($on, $sn); + PrintUpdate " Disabling nonclustered indexes" $true; + foreach($ix in $tbl.Indexes | where {$_.ID -gt 1}) { + $j = $ix.ID; + PrintUpdate " Disabling index $j" $true; + if($runQueries -eq "y") { + $ix.Disable(); + $ix.Refresh(); + } + } # foreach + + # create clustered index on first column, rebuild CL on new filegroup, drop CL and return to heap + $qry = "SELECT QUOTENAME([name]) AS n FROM sys.columns WHERE object_id = $oid AND column_id = 1"; + $firstCol = Invoke-Sqlcmd -ServerInstance $serverName -database $dbName -query $qry; + + $qry = "CREATE CLUSTERED INDEX CL_Blah ON [$sn].[$on] (" + $firstCol.n + ") `nWITH(ONLINE=$online) ON [$destFG];"; + $qry += "`nDROP INDEX CL_Blah ON [$sn].[$on];"; + #Write-Host $qry; + PrintUpdate " Moving heap" $true; + RunSQLQuery($qry); + $migratedSize += $sz; + + # rebuild all NC indexes on new filegroup + PrintUpdate " Re-enabling nonclustered indexes" $true; + foreach($ix in $tbl.Indexes | where {$_.ID -gt 1}) { + $j = $ix.ID; + PrintUpdate " Rebuilding index $j" $true; + $ix.FileGroup = $destFG; + if($runQueries -eq "y") { + $ix.Recreate(); + $ix.Refresh(); + } + $migratedSize += ($ix.SpaceUsed/1MB); + } # foreach + + } elseif($iid -ge 1) { #clustered index + if(![System.DBNULL]::Value.Equals($i.LOBFilegroup) -and $i.LOBFilegroup -ne $destFG) { + # if the LOB filegroup needs to change, it can't be done here + # the table needs to be dropped and everything recreated + PrintUpdate " Skipping - LOB filegroup prevents online operations" $true; + continue; + } + + if($online -eq "OFF") { + # skipping because it can't be done online + PrintUpdate " Skipping - column(s) prevents online operations" $true; + continue; + } + + $tbl = $db.Tables.Item($on, $sn); + + # if index is on a heap, skip because all NC indexes on heaps will be rebuilt when the heap is moved + if(!$tbl.HasClusteredIndex) { + PrintUpdate " Skipping because index is on a heap" $true; + continue; + } + + $idx = $tbl.Indexes[$in]; + + $scr = "CREATE "; + if($idx.IsUnique -eq $true) {$scr += "UNIQUE ";} + if($idx.IsClustered -eq $true) {$scr += "CLUSTERED ";} + $scr += "INDEX [$in] ON [$sn].[$on]("; + $scr += GetIndexColumns $idx $false; + $scr += ") "; + if((GetIndexColumns $idx $true) -ne "") { + $scr += "`nINCLUDE ("; + $scr += GetIndexColumns $idx $true; + $scr += ") "; + } + if($idx.FilterDefinition -ne "") { + $scr += "`nWHERE "; + $scr += $idx.FilterDefinition; + $scr += " "; + } + $scr += "`nWITH (DROP_EXISTING=ON, ONLINE=$online, SORT_IN_TEMPDB="; + if($sz -lt 25000) { + $scr += "ON, " + } else { + $scr += "OFF, " + } + #add partition compression support later + $scr += "DATA_COMPRESSION="; + $scr += $idx.PhysicalPartitions[0].DataCompression; + $scr += ") `nON [$destFG];"; + + RunSQLQuery($scr); + $migratedSize += $sz; + + } + +} #foreach + +Write-Host "Made it to end"; +Write-Host "Total Size: $totalSize MB"; +Write-Host "Migrated Size: $migratedSize MB"; + +$runDuration = New-TimeSpan $dtStart (Get-Date); +$hrs = $runDuration.Hours; +$mins = $runDuration.Minutes; +$secs = $runDuration.Seconds; +write-host "Completed in $hrs hours $mins minutes $secs seconds"; + diff --git a/PowerShell/ParameterCaseCheck.ps1 b/PowerShell/ParameterCaseCheck.ps1 new file mode 100644 index 00000000..66cb0b71 --- /dev/null +++ b/PowerShell/ParameterCaseCheck.ps1 @@ -0,0 +1,38 @@ +<# +.Synopsis + Search for any parameter that does not match the column name. + +.OUTPUTS + Any parameter that does not match the column name + +.NOTES + Original link: https://nocolumnname.blog/2018/05/25/finding-parameters-that-do-not-match-column-names/ + Author: Shane O'Neill +#> + +$PatternMatch = '(?\w+)\s*=\s*@(?\w+)' + +$FindStoredProcedureParameters = @{ + SqlInstance = 'localhost' + Database = 'master' + Pattern = $PatternMatch + IncludeSystemDatabases = $true +} + +Find-DbaStoredProcedure @FindStoredProcedureParameters | + ForEach-Object -Process { + $ParentRow = $_ + + $_ | ForEach-Object StoredProcedureTextFound | Select-String -Pattern $PatternMatch -AllMatches | ForEach-Object Matches | ForEach-Object -Process { + [PSCustomObject]@{ + ServerName = $ParentRow.SqlInstance + DatabaseName = $ParentRow.Database + SchemaName = $ParentRow.Schema + ProcedureName = $ParentRow.Name + TextFound = ($_.Groups | Where-Object Name -eq '0').Value + ColumnName = ($_.Groups | Where-Object Name -eq 'ColumnName').Value + ParameterName = ($_.Groups | Where-Object Name -eq 'ParameterName').Value + } + } +} | Where-Object { ($_.ColumnName -ne $_.ParameterName) } | + Select-Object -Property * -Unique diff --git a/PowerShell/Parse-TSQL.ps1 b/PowerShell/Parse-TSQL.ps1 new file mode 100644 index 00000000..89725a4c --- /dev/null +++ b/PowerShell/Parse-TSQL.ps1 @@ -0,0 +1,39 @@ +#requires -version 5.0 +#requires -modules dbatools,pester + +<# +.Synopsis + Ensure that some SQL Scripts in a directory would parse so there was some guarantee that they were valid T-SQL. + +.OUTPUTS + Any invalid TSQL + +.NOTES + Original link: https://sqldbawithabeard.com/2018/07/25/a-powershell-pester-check-for-parsing-sql-scripts/ + Author: Rob Sewell +#> + +Describe "Testing SQL" { + Context "Running Parser" { + ## Load assembly + $dbatoolsPath = 'C:\Program Files\WindowsPowerShell\Modules\dbatools'; + + $Parserdll = (Get-ChildItem $dbatoolsPath -Include Microsoft.SqlServer.Management.SqlParser.dll -Recurse)[0].FullName; + [System.Reflection.Assembly]::LoadFile($Parserdll) | Out-Null; + + $TraceDll = (Get-ChildItem $dbatoolsPath -Include Microsoft.SqlServer.Diagnostics.Strace.dll -Recurse)[0].FullName; + [System.Reflection.Assembly]::LoadFile($TraceDll) | Out-Null; + + $ParseOptions = New-Object Microsoft.SqlServer.Management.SqlParser.Parser.ParseOptions; + $ParseOptions.BatchSeparator = 'GO'; + $files = Get-ChildItem -Path $Env:Directory -Include *.sql -Recurse; ## This variable is set as a Build Process Variable or put your path here + $files.ForEach{ + It "$($Psitem.FullName) Should Parse SQL correctly" { + $filename = $Psitem.FullName; + $sql = Get-Content -LiteralPath "$fileName"; + $Script = [Microsoft.SqlServer.Management.SqlParser.Parser.Parser]::Parse($SQL, $ParseOptions); + $Script.Errors | Should -BeNullOrEmpty; + } + } + } +} diff --git a/PowerShell/Read-XEL-File.ps1 b/PowerShell/Read-XEL-File.ps1 new file mode 100644 index 00000000..9dc3f10f --- /dev/null +++ b/PowerShell/Read-XEL-File.ps1 @@ -0,0 +1,40 @@ +#requires -version 3.0 + +<# +.Synopsis + Read Extended Event .xel file. + +.OUTPUTS + First 50 rows of .xel file delimeted columns by ; and rows by \r\n + +.NOTES + Original link: https://sqlserverpowershell.com/2017/04/06/read-an-extended-events-file-via-powershell/ + Author: Scott Newman +#> + +$xelFilePath = 'c:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\Log\system_health_0_131916022434590000.xel'; +$xelDDLPath = 'C:\Program Files\Microsoft SQL Server\140\Shared\'; + +Add-Type -Path ($xelDDLPath+'Microsoft.SqlServer.XE.Core.dll'); +Add-Type -Path ($xelDDLPath+'Microsoft.SqlServer.XEvent.Linq.dll'); + +$events = New-Object Microsoft.SqlServer.XEvent.Linq.QueryableXEventData($xelFilePath) +$sb = New-Object System.Text.StringBuilder + +$events | select -First 50 | %{ + $event = $_ + [void]$sb.Append("$($event.Timestamp);;"); + + for($i=0;$i-lt($event.Fields.Count-1);$i++){ + [void]$sb.Append("$($event.Fields[$i].Value.ToString().Replace("`r`n", ''));;"); + } + + $event.Actions | %{ + $action = $_ + [void]$sb.Append("$($action.value.ToString().Replace("`r`n", ''));;"); + } + [void]$sb.Append("ServerName;;"); + + [void]$sb.AppendLine(); +} +$sb.ToString(); diff --git a/PowerShell/Read_XEL_file.ps1 b/PowerShell/Read_XEL_file.ps1 new file mode 100644 index 00000000..4815b499 --- /dev/null +++ b/PowerShell/Read_XEL_file.ps1 @@ -0,0 +1,28 @@ +$path = 'd:\system_health_0_131914905113690000.xel' + +#Add-Type -Path 'C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\Extensions\Application\Microsoft.SqlServer.XE.Core.dll' +#Add-Type -Path 'C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\Extensions\Application\Microsoft.SqlServer.XEvent.Linq.dll' + +Add-Type -Path 'C:\Program Files\Microsoft SQL Server\120\Shared\Microsoft.SqlServer.XE.Core.dll' +Add-Type -Path 'C:\Program Files\Microsoft SQL Server\120\Shared\Microsoft.SqlServer.XEvent.Linq.dll' + +$events = New-Object Microsoft.SqlServer.XEvent.Linq.QueryableXEventData($path) +$sb = New-Object System.Text.StringBuilder + +$events | select -First 50 | %{ + $event = $_ + [void]$sb.Append("$($event.Timestamp);;"); + + for($i=0;$i-lt($event.Fields.Count-1);$i++){ + [void]$sb.Append("$($event.Fields[$i].Value.ToString().Replace("`r`n", ''));;"); + } + + $event.Actions | %{ + $action = $_ + [void]$sb.Append("$($action.value.ToString().Replace("`r`n", ''));;"); + } + [void]$sb.Append("ServerName;;"); + + [void]$sb.AppendLine(); +} +$sb.ToString(); diff --git a/PowerShell/SQL_Server_Discovery_Report.ps1 b/PowerShell/SQL_Server_Discovery_Report.ps1 new file mode 100644 index 00000000..e82d9532 --- /dev/null +++ b/PowerShell/SQL_Server_Discovery_Report.ps1 @@ -0,0 +1,156 @@ + <# + .SYNOPSIS + SQL Server discovery report. + + .DESCRIPTION + Runs the SQL Server discovery report (opens in default browser). Run as Administrator!!! + + .INPUTS + None + + .OUTPUTS + None + + .NOTES + Version: 1.1 + + Author: Dave Mason + https://twitter.com/BeginTry + https://itsalljustelectrons.blogspot.com/ + + Creation Date: 2018/04/18 + + Assumptions: + 1. The sub-folder "Microsoft SQL Server" exists in %PROGRAMFILES%, + even if SQL was installed to a non-default path. This has been + verified on SQL 2008R2 and SQL 2012. Further verification may be needed. + 2. The numbered sub-folders in "%PROGRAMFILES%\Microsoft SQL Server" correlate to + installed versions of SQL Server. The numbers sync with database compatibility + levels. For example: + 140 "%PROGRAMFILES%\Microsoft SQL Server\140" SQL Server 2017 + 130 "%PROGRAMFILES%\Microsoft SQL Server\130" SQL Server 2016 + 120 "%PROGRAMFILES%\Microsoft SQL Server\120" SQL Server 2014 + 110 "%PROGRAMFILES%\Microsoft SQL Server\110" SQL Server 2012 + 100 "%PROGRAMFILES%\Microsoft SQL Server\100" SQL Server 2008 R2 + If this version/folder/naming convention remains intact for future versions, + this script should continue to work with no enhancements. + 3. The discovery report displays installed components for the version of SQL + Server associated with setup.exe, along with installed components of all + lesser versions of SQL Server that are installed. + + History: + 2018/04/23 DMason + Output a message if no installed SQL Server features are found. + Enhancements for older versions of SQL Server (2008, 2005). + Thanks to Wayne Sheffield for verifying the Setup.exe Bootstrap path for + SQL Server 2008 R2 and for providing paths for SQL Server 2008 and 2005. + https://twitter.com/DBAWayne + https://blog.waynesheffield.com/wayne/ + +#> + +#Locate the "%PROGRAMFILES%\Microsoft SQL Server" folder. +$MSSQLpath = [System.IO.Path]::Combine($env:ProgramFiles, "Microsoft SQL Server") +$lstCompatLevelDirs = New-Object "System.Collections.Generic.List[Int32]" + +<# + Iterate through the "Microsoft SQL Server" sub-folders. + Sub-folder names that are numeric are added to List of type Int32. +#> +Get-ChildItem -Directory $MSSQLpath | + ForEach-Object { + [Int32]$DirNum = 0 + + if ([Int32]::TryParse($_.Name, [ref]$DirNum)) + { + $lstCompatLevelDirs.Add($DirNum) + } + } + +#Sort() the List, then Reverse() it so there is DESCENDING order. +$lstCompatLevelDirs.Sort() +$lstCompatLevelDirs.Reverse() + +[bool] $setupExeFound = $false + +<# + Find the Setup Bootstrap Setup.exe file in the "highest" sub-folder. + Here are a few examples: + "%PROGRAMFILES%\Microsoft SQL Server\140\Setup Bootstrap\SQL2017\setup.exe" + "%PROGRAMFILES%\Microsoft SQL Server\130\Setup Bootstrap\SQLServer2016\setup.exe" + "%PROGRAMFILES%\Microsoft SQL Server\120\Setup Bootstrap\SQLServer2014\setup.exe" + "%PROGRAMFILES%\Microsoft SQL Server\110\Setup Bootstrap\SQLServer2012\setup.exe" + "%PROGRAMFILES%\Microsoft SQL Server\100\Setup Bootstrap\SQLServer2008R2\Setup.exe" +#> +ForEach($int in $lstCompatLevelDirs) +{ + #The "Setup Bootstrap" path. For example: "%PROGRAMFILES%\Microsoft SQL Server\140\Setup Bootstrap + [string]$SetupBootstrap = [System.IO.Path]::Combine( + [System.IO.Path]::Combine($MSSQLpath, $int.ToString()), + "Setup Bootstrap") + + if ([System.IO.Directory]::Exists($SetupBootstrap)) + { + <# + Iterate through the list of sub-folders with names that match the pattern "SQL*" + #> + ForEach($sqlSubDir in [System.IO.Directory]::GetDirectories($SetupBootstrap, "SQL*")) + { + <# + Search for "setup.exe". + If found: + Run the exe with the appropriate parameters to run the discovery report. + Break out of the loops. + #> + [string]$setupExe = [System.IO.Path]::Combine($sqlSubDir, "setup.exe") + + if ([System.IO.File]::Exists($setupExe)) + { + $setupExeFound = $true + Start-Process -FilePath $setupExe -ArgumentList "/Action=RunDiscovery" + break + } + } + } + + if($setupExeFound) + { + break + } +} + +<# + If the Setup.exe is still not found, search for it in hard-coded paths that correspond + to older versions that didn't use the current version/folder/naming convention. + + 2008: "%PROGRAMFILES%\Microsoft SQL Server\100\Setup Bootstrap\Release\Setup.exe" + 2005: "%PROGRAMFILES%\Microsoft SQL Server\90\Setup Bootstrap\Setup.exe" +#> +if(-Not $setupExeFound) +{ + $lstOldSqlVersionSetupExePaths = New-Object "System.Collections.Generic.List[string]" + + #SQL 2008 + $lstOldSqlVersionSetupExePaths.Add([System.IO.Path]::Combine($MSSQLpath, "100\Setup Bootstrap\Release\Setup.exe")) + + #SQL 2005 + $lstOldSqlVersionSetupExePaths.Add([System.IO.Path]::Combine($MSSQLpath, "90\Setup Bootstrap\Setup.exe")) + + #TODO: add strings to the array for even older versions of SQL (gulp). + + + ForEach($setupExe in $lstOldSqlVersionSetupExePaths) + { + if ([System.IO.File]::Exists($setupExe)) + { + $setupExeFound = $true + Start-Process -FilePath $setupExe -ArgumentList "/Action=RunDiscovery" + break + } + } +} + +if(-Not $setupExeFound) +{ + Write-Host "No installed SQL Server features found." -ForegroundColor Yellow +} diff --git a/PowerShell/Scripting_Out_SQL_Server_Data_As_Insert_Statements.ps1 b/PowerShell/Scripting_Out_SQL_Server_Data_As_Insert_Statements.ps1 new file mode 100644 index 00000000..a0edb49c --- /dev/null +++ b/PowerShell/Scripting_Out_SQL_Server_Data_As_Insert_Statements.ps1 @@ -0,0 +1,161 @@ +#requires -version 5.0 +#requires -modules sqlserver + +<# +.SYNOPSIS + Script for writing out data from one or more databases either in insert statements + +.DESCRIPTION + Script for writing out data from one or more databases either in insert statements + (useful for scripting small tables of static data) or in native BCP files + + Other types of BCP output are easy to do by altering the BCP parameters in the + script slightly. + You can specify which tables you want to script out via a regex. You can use wildcards + to specify the databases + +.PARAMETER Filepath + Local directory to save build-scripts to. + +.PARAMETER DataSource + Server name and instance. + +.PARAMETER Databases + Databases to copy from. wildcard comparison *, ? [a-d](range) and [and](set of chars). + +.PARAMETER SQLUserName + Leave blank if Windows auth. + +.PARAMETER TablesRegex + Regex match to specify tables. + +.PARAMETER UseBCP + Use native BCP files if true and generate INSERT statments if false. Default false. + +.NOTES + Original link: https://www.red-gate.com/simple-talk/blogs/scripting-out-sql-server-data-as-insert-statements-via-powershell/ + Author: Phil Factor + Version: 1.1 + Modified: 2019-08-26 by Konstantin Taranov + Source link: https://github.com/ktaranov/sqlserver-kit/blob/master/Powershell/Scripting_Out_SQL_Server_Data_As_Insert_Statements.ps1 +#> + + +$Filepath = 'C:\Temp'; # local directory to save build-scripts to +$DataSource = 'localhost'; # server name and instance +$Databases = @('maste*', 'model'); <# the databases to copy from. wildcard comparison *, ? + [a-d](range) and [and](set of chars) #> +$SQLUserName = ''; #leave blank if Windows auth +$TablesRegex = '.*'; # Regex match to specify tables +$UseBCP =$false; + +# set "Option Explicit" to catch subtle errors +set-psdebug -strict +$ErrorActionPreference = "stop" # you can opt to stagger on, bleeding, if an error occurs +#load the sqlserver module +$popVerbosity = $VerbosePreference +$VerbosePreference = "Silentlycontinue" +# the import process is very noisy if you are in verbose mode +Import-Module sqlserver -DisableNameChecking #load the SQLPS functionality +$VerbosePreference = $popVerbosity +# get credentials if necessary +if ($SQLUserName -ne '') #then it is using SQL Server Credentials +{ + $SqlEncryptedPasswordFile = ` + "$env:USERPROFILE\$($SqlUserName)-$($SQLInstance).txt" + # test to see if we know about the password in a secure string stored in the user area + if (Test-Path -path $SqlEncryptedPasswordFile -PathType leaf) + { + #has already got this set for this login so fetch it + $Sqlencrypted = Get-Content $SqlEncryptedPasswordFile | ConvertTo-SecureString + $SqlCredentials = ` + New-Object System.Management.Automation.PsCredential($SqlUserName, $Sqlencrypted) + } + else #then we have to ask the user for it + { + #hasn't got this set for this login + $SqlCredentials = get-credential -Credential $SqlUserName + $SqlCredentials.Password | ConvertFrom-SecureString | + Set-Content $SqlEncryptedPasswordFile + } +} + +$ms = 'Microsoft.SqlServer' +$My = "$ms.Management.Smo" # +if ($SQLUserName -eq '') #dead simple if using windows security +{ $s = new-object ("$My.Server") $DataSource } +else # if using sql server security we do it via a connection object +{ + $ServerConnection = new-object "$ms.Management.Common.ServerConnection" ( + $DataSource, $SQLUsername, $SqlCredentials.Password) + $s = new-object ("$My.Server") $ServerConnection +} +if ($s.Version -eq $null) { Throw "Can't find the instance $Datasource" } +$CreationScriptOptions = new-object ("$My.ScriptingOptions") +<# this is only needed if we are doing insert statements #> +$MyPreferences = @{ + 'ScriptBatchTerminator' = $true; # this only goes to the file + 'ToFileOnly' = $true; #no need of string output as well + 'ScriptData' = $true; + 'scriptSchema' = $false; + 'Encoding' = [System.Text.Encoding]::UTF8; +} +$MyPreferences.GetEnumerator() | + Foreach{ $Name = $_.name; $CreationScriptOptions.$name = $_.Value } + +$possibilities = $s.Databases | select name +$DatabaseList = @() +$DatabaseList += $databases | +where { $_ -Notlike '*[*?]*' } | +where { $possibilities.Name -contains $_ } +$DatabaseList += $databases | + where { $_ -like '*[*?]*' } | + foreach{ $wildcard = $_; $possibilities.Name | where { $_ -like $wildcard } } +$DatabaseList | Sort-Object -Unique | + foreach { + write-verbose "now doing $($_)" + $TheDatabase = $s.Databases[$_] + + $TheDatabase.Tables | where { $_.IsSystemObject -eq $false -and $_.name -match $tablesRegex } | + foreach{ + <# calculate where it should be saved #> + $directory = "$($FilePath)\$($s.Name)\$($TheDatabase.Name)\Data" + <# check that the directory exists #> + if (-not (Test-Path -PathType Container $directory)) + { + <# we create the directory if it doesn't already exist #> + $null = New-Item -ItemType Directory -Force -Path $directory; + } + if ($UseBCP -eq $true) <# then we are doing a Native BCP#> + { + if ($SQLUserName -eq '')<# OK. Easy, a trusted connection #> + { + #native format -n, Trusted connection -T + BCP "$($_.Schema).$($_.Name)" out "$($directory)\$($_.Schema)_$($_.Name).bcp" ` + -n -T "-d$($TheDatabase.Name)" "-S$($s.Name)" + } + else <# if not a trusted connection we need to provide a userid and password #> + { + $progress=''; + $Progress=BCP "$($_.Schema).$($_.Name)" out "$($directory)\$($_.Schema)_$($_.Name).bcp" ` + -n "-d$($TheDatabase.Name)" "-S$($s.Name)" ` + "-U$($s.ConnectionContext.Login)" "-P$($s.ConnectionContext.Password)" + } + Write-verbose "Writing out to $($_.Schema).$($_.Name) $($directory)\$($_.Schema)_$($_.Name).bcp + $progress" + if (-not ($?)) # if there was an error + { + throw ("Error with data export of $($directory)\$($_.Schema)_$($_.Name).bcp "); + } + + } + else <# we are doing insert statements #> + { + $CreationScriptOptions.Filename = ` + "$($FilePath)\$($s.Name)\$($TheDatabase.Name)\Data\$($_.Schema)_$($_.Name)_Data.sql"; + $scripter = new-object ("$My.Scripter") ($s); + $scripter.Options = $CreationScriptOptions; + $scripter.EnumScript($_.Urn); + } + } +} diff --git a/PowerShell/Send-SqlDataToExcel.ps1 b/PowerShell/Send-SqlDataToExcel.ps1 new file mode 100644 index 00000000..603de6a5 --- /dev/null +++ b/PowerShell/Send-SqlDataToExcel.ps1 @@ -0,0 +1,297 @@ +Function Send-SQLDataToExcel { + <# + .SYNOPSIS + Inserts a DataTable - returned by SQL query into an ExcelSheet, more efficiently than sending it via Export-Excel + .DESCRIPTION + This command can accept a data table object or take a SQL statement and run it against a database connection. + If running a SQL statement, the accepts either + * an object representing a session with a SQL server or ODBC database, or + * a connection String to make a session. + The command takes most of the parameters of Export-Excel, and after inserting the table into the worksheet it + calls Export-Excel to carry out other tasks on the sheet. It is more efficient to do this than to get data-rows + and pipe them into Export-Excel, stripped off the database 'housekeeping' properties. + .PARAMETER DataTable + A System.Data.DataTable object containing the data to be inserted into the spreadsheet without running a query. + .PARAMETER Session + An active ODBC Connection or SQL connection object representing a session with a database which will be queried to get the data . + .PARAMETER Connection + A database connection string to be used to create a database session; either + * A Data source name written in the form DSN=ODBC_Data_Source_Name, or + * A full odbc or SQL Connection string, or + * The name of a SQL server. + .PARAMETER MSSQLServer + Specifies the connection string is for SQL server, not ODBC. + .PARAMETER SQL + The SQL query to run against the session which was passed in -Session or set up from -Connection. + .PARAMETER Database + Switches to a specific database on a SQL server. + .PARAMETER QueryTimeout + Override the default query time of 30 seconds. + .PARAMETER Path + Path to a new or existing .XLSX file. + .PARAMETER WorkSheetName + The name of a sheet within the workbook - "Sheet1" by default. + .PARAMETER KillExcel + Closes Excel - prevents errors writing to the file because Excel has it open. + .PARAMETER Title + Text of a title to be placed in the top left cell. + .PARAMETER TitleBold + Sets the title in boldface type. + .PARAMETER TitleSize + Sets the point size for the title. + .PARAMETER TitleBackgroundColor + Sets the cell background color for the title cell. + .PARAMETER TitleFillPattern + Sets the fill pattern for the title cell. + .PARAMETER Password + Sets password protection on the workbook. + .PARAMETER IncludePivotTable + Adds a Pivot table using the data in the worksheet. + .PARAMETER PivotTableName + If a Pivot table is created from command line parameters, specificies the name of the new sheet holding the pivot. If Omitted this will be "WorksheetName-PivotTable" + .PARAMETER PivotRows + Name(s) columns from the spreadhseet which will provide the Row name(s) in a pivot table created from command line parameters. + .PARAMETER PivotColumns + Name(s) columns from the spreadhseet which will provide the Column name(s) in a pivot table created from command line parameters. + .PARAMETER PivotFilter + Name(s) columns from the spreadhseet which will provide the Filter name(s) in a pivot table created from command line parameters. + .PARAMETER PivotData + In a pivot table created from command line parameters, the fields to use in the table body is given as a Hash table in the form ColumnName = Average|Count|CountNums|Max|Min|Product|None|StdDev|StdDevP|Sum|Var|VarP . + .PARAMETER PivotDataToColumn + If there are multiple datasets in a PivotTable, by default they are shown seperatate rows under the given row heading; this switch makes them seperate columns. + .PARAMETER NoTotalsInPivot + In a pivot table created from command line parameters, prevents the addition of totals to rows and columns. + .PARAMETER IncludePivotChart + Include a chart with the Pivot table - implies -IncludePivotTable. + .PARAMETER ChartType + The type for Pivot chart (one of Excel's defined chart types) + .PARAMETER NoLegend + Exclude the legend from the pivot chart. + .PARAMETER ShowCategory + Add category labels to the pivot chart. + .PARAMETER ShowPercent + Add Percentage labels to the pivot chart. + .PARAMETER PivotTableDefinition + Instead of describing a single pivot table with mutliple commandline paramters; you can use a HashTable in the form PivotTableName = Definition; + Definition is itself a hashtable with Sheet PivotTows, PivotColumns, PivotData, IncludePivotChart and ChartType values. + .PARAMETER ConditionalFormat + One or more conditional formatting rules defined with New-ConditionalFormattingIconSet. + .PARAMETER ConditionalText + Applies a 'Conditional formatting rule' in Excel on all the cells. When specific conditions are met a rule is triggered. + .PARAMETER BoldTopRow + Makes the top Row boldface. + .PARAMETER NoHeader + Does not put field names at the top of columns. + .PARAMETER RangeName + Makes the data in the worksheet a named range. + .PARAMETER AutoNameRange + Makes each column a named range. + .PARAMETER TableName + Makes the data in the worksheet a table with a name applies a style to it. Name must not contain spaces. + .PARAMETER TableStyle + Selects the style for the named table - defaults to 'Medium6'. + .PARAMETER BarChart + Creates a "quick" bar chart using the first text column as labels and the first numeric column as values + .PARAMETER ColumnChart + Creates a "quick" column chart using the first text column as labels and the first numeric column as values + .PARAMETER LineChart + Creates a "quick" line chart using the first text column as labels and the first numeric column as values + .PARAMETER PieChart + Creates a "quick" pie chart using the first text column as labels and the first numeric column as values + .PARAMETER ExcelChartDefinition + A hash table containing ChartType, Title, NoLegend, ShowCategory, ShowPercent, Yrange, Xrange and SeriesHeader for one or more [non-pivot] charts. + .PARAMETER StartRow + Row to start adding data. 1 by default. Row 1 will contain the title if any. Then headers will appear (Unless -No header is specified) then the data appears. + .PARAMETER StartColumn + Column to start adding data - 1 by default. + .PARAMETER FreezeTopRow + Freezes headers etc. in the top row. + .PARAMETER FreezeFirstColumn + Freezes titles etc. in the left column. + .PARAMETER FreezeTopRowFirstColumn + Freezes top row and left column (equivalent to Freeze pane 2,2 ). + .PARAMETER FreezePane + Freezes panes at specified coordinates (in the form RowNumber , ColumnNumber). + .PARAMETER AutoFilter + Enables the 'Filter' in Excel on the complete header row. So users can easily sort, filter and/or search the data in the select column from within Excel. + .PARAMETER AutoSize + Sizes the width of the Excel column to the maximum width needed to display all the containing data in that cell. + .PARAMETER Show + Opens the Excel file immediately after creation. Convenient for viewing the results instantly without having to search for the file first. + .PARAMETER CellStyleSB + A script block which is run at the end of the process to apply styles to cells (although it can be used for other purposes). + The script block is given three paramaters; an object containing the current worksheet, the Total number of Rows and the number of the last column. + .PARAMETER ReturnRange + If specified, Export-Excel returns the range of added cells in the format "A1:Z100" + .PARAMETER PassThru + If specified, Export-Excel returns an object representing the Excel package without saving the package first. To save it you need to call the save or Saveas method or send it back to Export-Excel. + + .EXAMPLE + C:\> Send-SQLDataToExcel -MsSQLserver -Connection localhost -SQL "select name,type,type_desc from [master].[sys].[all_objects]" -Path .\temp.xlsx -WorkSheetname master -AutoSize -FreezeTopRow -AutoFilter -BoldTopRow + + Connects to the local SQL server and selects 3 columns from [Sys].[all_objects] and exports then to a sheet named master with some basic header management + .EXAMPLE + C:\> $SQL="SELECT top 25 Name,Length From TestData ORDER BY Length DESC" + C:\> $Connection = ' Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=C:\Users\James\Documents\Database1.accdb;' + + C:\> Send-SQLDataToExcel -Connection $connection -SQL $sql -path .\demo1.xlsx -WorkSheetname "Sizes" -AutoSize + + This declares a SQL statement and creates an ODBC connection string to read from an Access file and extracts data from it and sends it to a new worksheet + + .EXAMPLE + C:\> $SQL="SELECT top 25 DriverName, Count(RaceDate) as Races, Count(Win) as Wins, Count(Pole) as Poles, Count(FastestLap) as Fastlaps FROM Results GROUP BY DriverName ORDER BY (count(win)) DESC" + C:\> $Connection = 'Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};Dbq=C:\users\James\Documents\f1Results.xlsx;' + + C:\> Send-SQLDataToExcel -Connection $connection -SQL $sql -path .\demo1.xlsx -WorkSheetname "Winners" -AutoSize -AutoNameRange -ConditionalFormat @{DataBarColor="Blue"; Range="Wins"} + + This declares a SQL statement and creates an ODBC connection string to read from an Excel file, it then runs the statement and outputs the resulting data to a new spreadsheet. + The spreadsheet is formatted and a data bar added to show make the drivers' wins clearer. + (the F1 results database is available from https://1drv.ms/x/s!AhfYu7-CJv4ehNdZWxJE9LMAX_N5sg ) + .EXAMPLE + C:\> $SQL = "SELECT top 25 DriverName, Count(RaceDate) as Races, Count(Win) as Wins, Count(Pole) as Poles, Count(FastestLap) as Fastlaps FROM Results GROUP BY DriverName ORDER BY (count(win)) DESC" + C:\> Get-SQL -Session F1 -excel -Connection "C:\Users\mcp\OneDrive\public\f1\f1Results.xlsx" -sql $sql -OutputVariable Table | out-null + + C:\> Send-SQLDataToExcel -DataTable $Table -Path ".\demo3.xlsx" -WorkSheetname Gpwinners -autosize -TableName winners -TableStyle Light6 -show + + This uses Get-SQL (at least V1.1 - download from the gallery with Install-Module -Name GetSQL - note the function is Get-SQL the module is GetSQL without the "-" ) + to simplify making database connections and building /submitting SQL statements. + Here it uses the same SQL statement as before; -OutputVariable leaves a System.Data.DataTable object in $table + and Send-SQLDataToExcel puts $table into the worksheet and sets it as an Excel table. + (the F1 results database is available from https://1drv.ms/x/s!AhfYu7-CJv4ehNdZWxJE9LMAX_N5sg ) + .EXAMPLE + C:\> $SQL = "SELECT top 25 DriverName, Count(Win) as Wins FROM Results GROUP BY DriverName ORDER BY (count(win)) DESC" + C:\> Send-SQLDataToExcel -Session $DbSessions["f1"] -SQL $sql -Path ".\demo3.xlsx" -WorkSheetname Gpwinners -autosize -ColumnChart + + Like the previous example, this uses Get-SQL (download from the gallery with Install-Module -Name GetSQL). It uses the connection which Get-SQL made rather than an ODFBC connection string + Here the data is presented as a quick chart. + .EXAMPLE + C:\> Send-SQLDataToExcel -path .\demo3.xlsx -WorkSheetname "LR" -Connection "DSN=LR" -sql "SELECT name AS CollectionName FROM AgLibraryCollection Collection ORDER BY CollectionName" + + This example uses an Existing ODBC datasource name "LR" which maps to an adobe lightroom database and gets a list of collection names into a worksheet + #> + [CmdletBinding()] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingPlainTextForPassword","")] + param ( + [Parameter(ParameterSetName="SQLConnection", Mandatory=$true)] + [Parameter(ParameterSetName="ODBCConnection",Mandatory=$true)] + $Connection, + [Parameter(ParameterSetName="ExistingSession",Mandatory=$true)] + [System.Data.Common.DbConnection]$Session, + [Parameter(ParameterSetName="SQLConnection",Mandatory=$true)] + [switch]$MsSQLserver, + [Parameter(ParameterSetName="SQLConnection")] + [String]$DataBase, + [Parameter(ParameterSetName="SQLConnection", Mandatory=$true)] + [Parameter(ParameterSetName="ODBCConnection",Mandatory=$true)] + [Parameter(ParameterSetName="ExistingSession",Mandatory=$true)] + [string]$SQL, + [int]$QueryTimeout, + [Parameter(ParameterSetName="Pre-FetchedData",Mandatory=$true)] + [System.Data.DataTable]$DataTable, + $Path, + [String]$WorkSheetname = 'Sheet1', + [Switch]$KillExcel, + [Switch]$Show, + [String]$Title, + [OfficeOpenXml.Style.ExcelFillStyle]$TitleFillPattern = 'None', + [Switch]$TitleBold, + [Int]$TitleSize = 22, + $TitleBackgroundColor, + [String]$Password, + [Hashtable]$PivotTableDefinition, + [Switch]$IncludePivotTable, + [String[]]$PivotRows, + [String[]]$PivotColumns, + $PivotData, + [String[]]$PivotFilter, + [Switch]$PivotDataToColumn, + [Switch]$NoTotalsInPivot, + [Switch]$IncludePivotChart, + [OfficeOpenXml.Drawing.Chart.eChartType]$ChartType = 'Pie', + [Switch]$NoLegend, + [Switch]$ShowCategory, + [Switch]$ShowPercent, + [Switch]$AutoSize, + [Switch]$FreezeTopRow, + [Switch]$FreezeFirstColumn, + [Switch]$FreezeTopRowFirstColumn, + [Int[]]$FreezePane, + [Switch]$AutoFilter, + [Switch]$BoldTopRow, + [Switch]$NoHeader, + [String]$RangeName, + [String]$TableName, + [OfficeOpenXml.Table.TableStyles]$TableStyle = 'Medium6', + [Switch]$Barchart, + [Switch]$PieChart, + [Switch]$LineChart , + [Switch]$ColumnChart , + [Object[]]$ExcelChartDefinition, + [Switch]$AutoNameRange, + [Object[]]$ConditionalFormat, + [Object[]]$ConditionalText, + [ScriptBlock]$CellStyleSB, + [Int]$StartRow = 1, + [Int]$StartColumn = 1, + [Switch]$ReturnRange, + [Switch]$Passthru + ) + + if ($KillExcel) { + Get-Process excel -ErrorAction Ignore | Stop-Process + while (Get-Process excel -ErrorAction Ignore) {Start-Sleep -Milliseconds 250} + } + + #We were either given a session object or a connection string (with, optionally a MSSQLServer parameter) + # If we got -MSSQLServer, create a SQL connection, if we didn't but we got -Connection create an ODBC connection + if ($MsSQLserver -and $Connection) { + if ($Connection -notmatch "=") {$Connection = "server=$Connection;trusted_connection=true;timeout=60"} + $Session = New-Object -TypeName System.Data.SqlClient.SqlConnection -ArgumentList $Connection + if ($Session.State -ne 'Open') {$Session.Open()} + if ($DataBase) {$Session.ChangeDatabase($DataBase) } + } + elseif ($Connection) { + $Session = New-Object -TypeName System.Data.Odbc.OdbcConnection -ArgumentList $Connection ; $Session.ConnectionTimeout = 30 + } + + If ($session) { + #A session was either passed in or just created. If it's a SQL one make a SQL DataAdapter, otherwise make an ODBC one + if ($Session.GetType().name -match "SqlConnection") { + $dataAdapter = New-Object -TypeName System.Data.SqlClient.SqlDataAdapter -ArgumentList ( + New-Object -TypeName System.Data.SqlClient.SqlCommand -ArgumentList $SQL, $Session) + } + else { + $dataAdapter = New-Object -TypeName System.Data.Odbc.OdbcDataAdapter -ArgumentList ( + New-Object -TypeName System.Data.Odbc.OdbcCommand -ArgumentList $SQL, $Session ) + } + if ($QueryTimeout) {$dataAdapter.SelectCommand.CommandTimeout = $ServerTimeout} + + #Both adapter types output the same kind of table, create one and fill it from the adapter + $DataTable = New-Object -TypeName System.Data.DataTable + $rowCount = $dataAdapter.fill($dataTable) + Write-Verbose -Message "Query returned $rowCount row(s)" + } + if ($DataTable.Rows.Count) { + #ExportExcel user a -NoHeader parameter so that's what we use here, but needs to be the other way around. + $printHeaders = -not $NoHeader + if ($Title) {$r = $StartRow +1 } + else {$r = $StartRow} + #Get our Excel sheet and fill it with the data + $excelPackage = Export-Excel -Path $Path -WorkSheetname $WorkSheetname -PassThru + $excelPackage.Workbook.Worksheets[$WorkSheetname].Cells[$r,$StartColumn].LoadFromDataTable($dataTable, $printHeaders ) | Out-Null + + #Apply date format + for ($c=0 ; $c -lt $DataTable.Columns.Count ; $c++) { + if ($DataTable.Columns[$c].DataType -eq [datetime]) { + Set-ExcelColumn -Worksheet $excelPackage.Workbook.Worksheets[$WorkSheetname] -Column ($c +1) -NumberFormat 'Date-Time' + } + } + + #Call export-excel with any parameters which don't relate to the SQL query + "Connection", "Database" , "Session", "MsSQLserver", "Destination" , "SQL" , "DataTable", "Path" | ForEach-Object {$null = $PSBoundParameters.Remove($_) } + Export-Excel -ExcelPackage $excelPackage @PSBoundParameters + } + else {Write-Warning -Message "No Data to insert."} + #If we were passed a connection and opened a session, close that session. + if ($Connection) {$Session.close() } +} diff --git a/PowerShell/Simulate_Databse_Load.ps1 b/PowerShell/Simulate_Databse_Load.ps1 new file mode 100644 index 00000000..d1a641fd --- /dev/null +++ b/PowerShell/Simulate_Databse_Load.ps1 @@ -0,0 +1,77 @@ +# https://www.scarydba.com/2019/01/07/powershell-to-simulate-load/ +# GRANT FRITCHEY +# 2019-01-07 + + +# connect to the database +$SqlConnection = New-Object System.Data.SqlClient.SqlConnection +$SqlConnection.ConnectionString = 'Server=WIN-8A2LQANSO51;Database=AdventureWorks2017;trusted_connection=true' + +# gather values +$RefCmd = New-Object System.Data.SqlClient.SqlCommand +$RefCmd.CommandText = "SELECT th.ReferenceOrderID, +COUNT(th.ReferenceOrderID) AS RefCount +FROM Production.TransactionHistory AS th +GROUP BY th.ReferenceOrderID;" +$RefCmd.Connection = $SqlConnection +$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter +$SqlAdapter.SelectCommand = $RefCmd +$RefData = New-Object System.Data.DataSet +$SqlAdapter.Fill($RefData) + +# Execute a stored procedure +$Sniffcmd = New-Object System.Data.SqlClient.SqlCommand +$Sniffcmd.CommandType = [System.Data.CommandType]'StoredProcedure' +$Sniffcmd.CommandText = "dbo.ProductTransactionHistoryByReference" +$Sniffcmd.Parameters.Add("@ReferenceOrderID",[System.Data.SqlDbType]"Int") +$Sniffcmd.Connection = $SqlConnection + +# Optionally, clear the cache +$Freecmd = New-Object System.Data.SqlClient.SqlCommand +$Freecmd.CommandText = "DECLARE @plan_handle VARBINARY(64); +SELECT @plan_handle = deps.plan_handle +FROM sys.dm_exec_procedure_stats AS deps +WHERE deps.object_id = OBJECT_ID('dbo.ProductTransactionHistoryByReference'); +DBCC FREEPROCCACHE(@plan_handle);" +$Freecmd.Connection = $SqlConnection + +# Count the executions +$x = 0 + +# Run forever +while(1 -ne 0) +{ + foreach($row in $RefData.Tables[0]) + { + # Establish an occasional wait + $check = get-random -Minimum 7 -Maximum 20 + $wait = $x % $check + if ($wait -eq 0) + { + #set a random sleep period in seconds + $waittime = get-random -minimum 3 -maximum 13 + start-sleep -s $waittime + $x = 0} + # Up the count + $x += 1 + # Execute the procedure + $RefID = $row[0] + $SqlConnection.Open() + $Sniffcmd.Parameters["@ReferenceOrderID"].Value = $RefID + $Sniffcmd.ExecuteNonQuery() | Out-Null + $SqlConnection.Close() + # clear the cache on each execution + #$SqlConnection.Open() + #$Freecmd.ExecuteNonQuery() | Out-Null + #$SqlConnection.Close() + # clear the cache based on random + $check = get-random -Minimum 7 -Maximum 20 + $clear = $x % $check + if($clear -eq 4) + { + $SqlConnection.Open() + $Freecmd.ExecuteNonQuery() | Out-Null + $SqlConnection.Close() + } + } +} \ No newline at end of file diff --git a/PowerShell/Test-SQLScripts.ps1 b/PowerShell/Test-SQLScripts.ps1 new file mode 100644 index 00000000..e18fdcd1 --- /dev/null +++ b/PowerShell/Test-SQLScripts.ps1 @@ -0,0 +1,265 @@ +<# +.SYNOPSIS +Scans a (list of) T-SQL script files(s) and returns information about the operations being performed by them. + +.DESCRIPTION +This function utilizes the SQL Server ScriptDom Parser object to parse and return information about each batch and statements within each batch +of T-SQL commands they contain. It will return an object that contains high-level information, as well as a batches object which in turn contains +statement objects. + +.PARAMETER Files +The [System.IO.FileInfo] object containing the files you want to scan. This type of object is usually returned from a Get-ChildItem cmdlet, so you can pipe the +results of it to this function. Required. + +.PARAMETER PathToScriptDomLibrary +This function requires the use of the Microsoft.SqlServer.TransactSql.ScriptDom object, which is NOT part of the standard SQL Server client libraries. Instead, +it is installed as part of a SQL Server installation. Which means to use this function, you either have to run it on a host that has SQL Server installed, or you +need a copy of the library locally. If you're using the latter, you need to manually provide the path to the Microsoft.SqlServer.TransactSql.ScriptDom.DLL file. +This path will be used as part of Add-Type to load the library which contains all the required namespaces and object code. Defaults to empty. + +.PARAMETER UseQuotedIdentifier +Whether or not the quoted identifier option is turned on for the parser. Defaults to true and is passed to the object instantiation. + +.NOTES +Out-of-the-box this function will search for: + - DML statements (INSERT, UPDATE, DELETE) + - Certain DDL Statements: + - ALTER TABLE + - DROP INDEX + - CREATE INDEX + - CREATE PROCEDURE + - DROP PROCEDURE + +You can extend the tests by adding a new [ParserKey] object to the $ParserKeys array. For now, these defined tests live in the code +but I expect them to be an external json file at some point. + +Author: Drew Furgiuele (@pittfurg, port1433.com) +Tags: T-SQL, Parser + +.LINK + +.EXAMPLE +$Results = Get-ChildItem -Path C:\Scripts | ./Test-SQLScripts.ps1 + +Execute the parser against a list of files returned from the Get-ChildItem cmdlet and store the returned object in the $Results variable + +.EXAMPLE +$Results = Get-ChildItem -Path C:\Scripts | ./Test-SQLScripts.ps1 -PathToScriptDomLibrary "C:\Program Files (x86)\Microsoft SQL Server\130\SDK\Assemblies\Microsoft.SqlServer.TransactSql.ScriptDom.dll" + +Same as above example, but manually point to where the parser library is stored (useful for hosts that don't have SQL Server installed and you manually +copied the library to it). + + +#> +[cmdletbinding()] +param( + [Parameter( + Mandatory = $true, + Position = 0, + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true) + ] [System.IO.FileInfo] $Files, + [Parameter(Mandatory=$false)] [string] $PathToScriptDomLibrary = $null, + [Parameter(Mandatory=$false)] [string] $UseQuotedIdentifier = $true +) + + +begin { + $ParserKeys = @() + + Class ParserKey { + [string] $ObjectType + [string] $SchemaSpecification + ParserKey ([string] $ObjectType, [string] $SchemaSpecification) { + $this.ObjectType = $ObjectType + $this.SchemaSpecification = $SchemaSpecification + } + } + + $ParserKeys += New-Object Parserkey ("SelectStatement","Queryexpression.Fromclause.Tablereferences.Schemaobject") + $ParserKeys += New-Object Parserkey ("InsertStatement","InsertSpecification.Target.SchemaObject") + $ParserKeys += New-Object Parserkey ("UpdateStatement","UpdateSpecification.Target.SchemaObject") + $ParserKeys += New-Object Parserkey ("DeleteStatement","DeleteSpecification.Target.SchemaObject") + $ParserKeys += New-Object Parserkey ("AlterTableAddTableElementStatement","SchemaObjectName") + $ParserKeys += New-Object Parserkey ("AlterTableDropTableElementStatement","SchemaObjectName") + $ParserKeys += New-Object Parserkey ("DropIndexStatement","DropIndexClauses.Object") + $ParserKeys += New-Object Parserkey ("CreateIndexStatement","OnName") + $ParserKeys += New-Object Parserkey ("CreateProcedureStatement","ProcedureReference.Name") + $ParserKeys += New-Object Parserkey ("CreateTableStatement","SchemaObjectName") + $ParserKeys += New-Object Parserkey ("DropProcedureStatement","Objects") + $ParserKeys += New-Object Parserkey ("DropTableStatement","Objects") + + + function Get-UpdatedTableFromReferences($TableReference) { + Write-Verbose "Looks like a joined DML statement, need to get into the references..." + if ($TableReference.FirstTableReference) { + Get-UpdatedTableFromReferences $TableReference.FirstTableReference + } else { + Write-Verbose "closing recursion..." + Return $TableReference.SchemaObject + } + } + + function Get-Statement ($Statement, $Keys) { + $StatementObject = [PSCustomObject] @{ + PSTypeName = "Parser.DOM.Statement" + ScriptName = $f.Name + BatchNumber= $TotalBatches + StatementNumber = $TotalStatements + StatementType = $null + Action = $null + IsQualified = $false + OnObjectSchema = $null + OnObjectName = $null + } + + Add-Member -InputObject $StatementObject -Type ScriptMethod -Name ToString -Value { $this.psobject.typenames[0] } -Force + + $StatementObject.Action = ($Statement.ScriptTokenStream | Where-Object {$_.Line -eq $Statement.StartLine -and $_.Column -eq $Statement.StartColumn}).Text.ToUpper() + + if ($statementObject.Action -eq "If") { + Write-Verbose "Found an an 'IF' statement, looking at the 'THEN' part of the statement..." + if ($Statement.ThenStatement.StatementList.Statements.Count -ge 1) { + $SubStatements = $Statement.ThenStatement.StatementList.Statements + ForEach ($su in $subStatements) { + $StatementObject = Get-Statement $su $keys + } + } else { + $StatementObject = Get-Statement $Statement.ThenStatement $keys + } + $StatementObject.IsQualified = $true + } else { + $Property = $Statement + $ObjectType = ($Keys | Where-Object {$_.ObjectType -eq $Statement.gettype().name}).ObjectType + Write-Verbose "Object type: $ObjectType" + if ($ObjectType -eq "UpdateStatement" -and $statement.UpdateSpecification.WhereClause -ne $null -and $statement.UpdateSpecification.SetClauses -ne $null) { + $SchemaObject = Get-UpdatedTableFromReferences $Statement.UpdateSpecification.FromClause.TableReferences.FirstTableReference + $StatementObject.OnObjectSchema = $SchemaObject.SchemaIdentifier.Value + $StatementObject.OnObjectName = $SchemaObject.BaseIdentifier.Value + } elseif ($ObjectType -eq "SelectStatement" -and $statement.Queryexpression.fromclause.tablereferences.FirstTableReference -ne $null) { + $SchemaObject = Get-UpdatedTableFromReferences $statement.Queryexpression.fromclause.tablereferences.FirstTableReference + $StatementObject.OnObjectSchema = $SchemaObject.SchemaIdentifier.Value + $StatementObject.OnObjectName = $SchemaObject.BaseIdentifier.Value + } else { + try { + $StatementObject.StatementType = $Statement.GetType().Name.ToString() + $SplitDefinition = (($Keys | Where-Object {$_.ObjectType -eq $Statement.gettype().name}).SchemaSpecification).Split(".") + ForEach ($def in $SplitDefinition) { + $Property = $Property | Select-Object -ExpandProperty $def + } + $StatementObject.OnObjectSchema = $Property.SchemaIdentifier.Value + $StatementObject.OnObjectName = $Property.BaseIdentifier.Value + } catch { + Write-Warning "Parsed statement has no descernible statement type. Maybe define one as a parser key?" + } + } + } + return $StatementObject + + } + + $LibraryLoaded = $false + $ObjectCreated = $false + $LibraryVersions = @(13,12,11) + + if ($PathToScriptDomLibrary -ne "") { + try { + Add-Type -Path $PathToScriptDomLibrary -ErrorAction SilentlyContinue + Write-Verbose "Loaded library from path $PathToScriptDomLibrary" + } catch { + throw "Couldn't load the required ScriptDom library from the path specified!" + } + } else { + ForEach ($v in $LibraryVersions) + { + if (!$LibraryLoaded) { + try { + Add-Type -AssemblyName "Microsoft.SqlServer.TransactSql.ScriptDom,Version=$v.0.0.0,Culture=neutral,PublicKeyToken=89845dcd8080cc91" -ErrorAction SilentlyContinue + Write-Verbose "Loaded version $v.0.0.0 of the ScriptDom library." + $LibraryLoaded = $true + } catch { + Write-Verbose "Couldn't load version $v.0.0.0 of the ScriptDom library." + } + } + } + } + + ForEach ($v in $LibraryVersions) + { + if (!$ObjectCreated) { + try { + $ParserNameSpace = "Microsoft.SqlServer.TransactSql.ScriptDom.TSql" + $v + "0Parser" + $Parser = New-Object $ParserNameSpace($UseQuotedIdentifier) + $ObjectCreated = $true + Write-Verbose "Created parser object for version $v..." + } catch { + Write-Verbose "Couldn't load version $v.0.0.0 of the ScriptDom library." + } + } + } + + if (!$ObjectCreated) { + throw "Unable to create ScriptDom library; did you load the right version of the library?" + } + +} + + +process { + ForEach ($f in $Files) { + $CurrentFileName = $f.FullName + Write-Verbose "Parsing $CurrentFileName..." + $Reader = New-Object System.IO.StreamReader($f.FullName) + $Errors= $null + $Fragment = $Parser.Parse($Reader, [ref] $Errors) + + [bool] $HasErrors = $false + if ($Errors -ne $null) { + [bool] $HasErrors = $true + } + + $ScriptObject = [PSCustomObject] @{ + PSTypeName = "Parser.DOM.Script" + ScriptName = $f.Name + ScriptFilePath = $f.FullName + NumberOfBatches = $Fragment.Batches.Count + HasParseErrors = $HasErrors + Errors = $Errors + Batches = @() + } + + Add-Member -InputObject $ScriptObject -Type ScriptMethod -Name ToString -Value { $this.psobject.typenames[0] } -Force + + + $TotalBatches = 0 + ForEach ($b in $Fragment.Batches) { + $TotalBatches++; + + $BatchObject = [pscustomobject] @{ + PSTypeName = "Parser.DOM.Batch" + ScriptName = $f.Name + BatchNumber = $TotalBatches + Statements = @() + } + + Add-Member -InputObject $BatchObject -Type ScriptMethod -Name ToString -Value { $this.psobject.typenames[0] } -Force + + $TotalStatements = 0 + ForEach ($s in $b.Statements) { + $TotalStatements++ + $StatementObject = Get-Statement $s $ParserKeys + + $BatchObject.Statements += $StatementObject + } + $ScriptObject.Batches += $BatchObject + } + + $Reader.Close() + + $ScriptObject + } +} + +end { + $Reader.Dispose() +} diff --git a/README.md b/README.md index 263cf36f..49364d6f 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,17 @@ # SQL Server KIT - - - - - - - - - - - -[![licence badge]][licence] +[![license badge]][license] [![stars badge]][stars] [![forks badge]][forks] [![issues badge]][issues] [![contributors_badge]][contributors] -[licence badge]:https://img.shields.io/badge/license-MIT-blue.svg +[license badge]:https://img.shields.io/badge/license-MIT-blue.svg [stars badge]:https://img.shields.io/github/stars/ktaranov/sqlserver-kit.svg [forks badge]:https://img.shields.io/github/forks/ktaranov/sqlserver-kit.svg [issues badge]:https://img.shields.io/github/issues/ktaranov/sqlserver-kit.svg [contributors_badge]:https://img.shields.io/github/contributors/ktaranov/sqlserver-kit.svg -[licence]:https://github.com/ktaranov/sqlserver-kit/blob/master/LICENSE.md +[license]:https://github.com/ktaranov/sqlserver-kit/blob/master/LICENSE [stars]:https://github.com/ktaranov/sqlserver-kit/stargazers [forks]:https://github.com/ktaranov/sqlserver-kit/network [issues]:https://github.com/ktaranov/sqlserver-kit/issues @@ -30,15 +19,25 @@ Useful links, scripts, tools and best practice for Microsoft SQL Server Database -Headers: + + +## Table of Contents - [Repo Folders and Files](#repo-folders-and-files) - [SQL Server Web Resources](#sql-server-web-resources) + - [SQL Server Blogs](#blogs) + - [Security Resources](#security) + - [SQL Server Free Videos](#free-videos) + - [Free Database Podcasts](#podcasts) + - [SQL Courses](#courses) + - [SQL Server Backwards Compatibility](#backwards-compatibility) + - [Social, Forum and Messenger SQL Server Groups](#social) + - [SQL Server Open Source Projects](#open-source) - [BIML Resources and Bloggers](#biml-resources-and-bloggers) - - [SQL Server Sample Databases and Datasets](#sql-server-sample-databases-and-datasets) - [PowerShell and SQL Server](#powershell-and-sql-server) - [TSQL Format Code](#tsql-format-code) - [SQL Server Test Data Generation](#sql-server-test-data-generation) - - [Free SQL Server, R ebooks](#free-ebooks) + - [Free SQL Server and R ebooks](#free-ebooks) + - [Paid SQL Server ebooks](#paid-ebooks) - [License](#license) @@ -46,48 +45,49 @@ Headers: - [SQL Server Data Types](/SQL%20Server%20Data%20Types.md) - [SQL Server Drivers](/SQL%20Server%20Drivers.md) - [SQL Server Edition](/SQL%20Server%20Edition.md) - - [SQL Server Hints](/SQL%20Server%Hints.md) + - [SQL Server Hints](/SQL%20Server%20Hints.md) - [SQL Server Name Convention and T-SQL Programming Style](/SQL%20Server%20Name%20Convention%20and%20T-SQL%20Programming%20Style.md) - [SQL Server Licensing](/SQL%20Server%20Licensing.md) - [SQL Server People](/SQL%20Server%20People.md 'Most Valuable SQL Server professionals') - - [SQL Server Trace Flag](/SQL%20Server%20Trace%20Flag.md 'Complete list - 533 Trace Flags') (**Complete list - 533 trace flags**) - - [SQL Server Version](/SQL%20Server%20Version.md 'List of all Microsoft SQL Sever versions') (**Complete list - from SQL Server 1.0 to SQL Server 2017**) + - [SQL Server Trace Flag](/SQL%20Server%20Trace%20Flag.md 'Complete list - 613 Trace Flags') (**Complete list - 620 trace flags**) + - [SQL Server Version](/SQL%20Server%20Version.md 'List of all Microsoft SQL Sever versions') (**Complete list - from SQL Server 1.0 to SQL Server 2019**) - [Articles](/Articles) - [CLR procedures](/CLR) - [SplitterB_CLR](/CLR/SplitterB_CLR.sql) - [Extended Events](/Extended_Events) - [Known Errors](/Errors) - - [Solution](/Solution) - - [dbWarden](/Solution/dbWarden) a free SQL Server Monitoring Package (by Stevie Rounds and Michael Rounds) - - [Base line Collector script](/Solution/BaselineCollector) (by Robert Virag) - - [Ola Maintenance Solution](/Solution/Ola_Maintenance_Solution) (by Ola Hallengren) - - [SQLQueryStress](/Solution/SQLQueryStress) (by Adam Machanic) - - [SysJobHistory](/Solution/SysJobHistory) (by David Wentzel) - - [SSMS](/SSMS) - - [SSMS addins](/SSMS/SSMS_Addins.md) (**34 useful free and paid SSMS Addins**) - - [SSMS Snippets](/SSMS/SSMS_Snippets) - - [SSMS Shortcuts](/SSMS/SSMS_Shortcuts.md) (**More than 300 Shortcuts**) - - [SSMS Tips](/SSMS/SSMS_Tips.md) (**Complete guide about hidden gems of SSMS**) + - [SQL Server Sample Databases and Datasets](/Sample_Databases) - [Scripts](/Scripts) - **Awesome SQL Server Diagnostic Information Queries** (by Glenn Alan Berry) + - [SQL Managed Instance Diagnostic Information Queries](/Scripts/SQL%20Managed%20Instance%20Diagnostic%20Information%20Queries.sql) + - [Azure SQL Database Diagnostic Information Queries](/Scripts/Azure%20SQL%20Database%20Diagnostic%20Information%20Queries.sql) + - [SQL Server 2019 Diagnostic Information Queries](/Scripts/SQL%20Server%202019%20Diagnostic%20Information%20Queries.sql) - [SQL Server 2017 Diagnostic Information Queries](/Scripts/SQL%20Server%202017%20Diagnostic%20Information%20Queries.sql) - [SQL Server 2016 Diagnostic Information Queries](/Scripts/SQL%20Server%202016%20Diagnostic%20Information%20Queries.sql) - [SQL Server 2014 Diagnostic Information Queries](Scripts/SQL%20Server%202014%20Diagnostic%20Information%20Queries.sql) - [SQL Server 2012 Diagnostic Information Queries](/Scripts/SQL%20Server%202012%20Diagnostic%20Information%20Queries.sql) - [SQL Server 2008 R2 Diagnostic Information Queries](/Scripts/SQL%20Server%202008%20R2%20Diagnostic%20Information%20Queries.sql) - [SQL Server 2008 Diagnostic Information Queries](/Scripts/SQL%20Server%202008%20Diagnostic%20Information%20Queries.sql) + - [SQL Server 2005 Diagnostic Information Queries](/Scripts/SQL%20Server%202005%20Diagnostic%20Information%20Queries.sql) - [Table count alternative](/Scripts/Table%20Count%20alternative.sql) (by Jes Schultz Borland) - [Foreign Key batch rename](/Scripts/Foreign%20Key%20batch%20rename.sql) (by Wes Henriksen) - [Count character matches](/Scripts/Count%20character%20matches.sql) - and many others... + - [Solution](/Solution) + - [dbWarden](/Solution/dbWarden) a free SQL Server Monitoring Package (by Stevie Rounds and Michael Rounds) + - [Base line Collector script](/Solution/BaselineCollector) (by Robert Virag) + - [SysJobHistory](/Solution/SysJobHistory) (by David Wentzel) + - [SSMS](/SSMS) + - [SSMS addins](/SSMS/SSMS_Addins.md) (**37 useful free and paid SSMS Addins**) + - [SSMS Snippets](/SSMS/SSMS_Snippets) + - [SSMS Shortcuts](/SSMS/SSMS_Shortcuts.md) (**More than 300 Shortcuts**) + - [SSMS Tips](/SSMS/SSMS_Tips.md) (**Complete guide about hidden gems of SSMS**) - [Stored Procedure](/Stored_Procedure) - - [sp_DBPermissions](/Stored_Procedure/sp_DBPermissions.sql) (by Kenneth Fisher) - - [sp_SrvPermissions](/Stored_Procedure/sp_SrvPermissions.sql) (by Kenneth Fisher) - - [sp_RestoreGene](/Stored_Procedure/sp_RestoreGene.sql) (by Paul Brewer) - - [usp_who5](/Stored_Procedure/usp_who5.sql) (by Sean Smith) - - [usp_String_Search](/Stored_Procedure/usp_String_Search.sql) (by Sean Smith) - - [usp_BulkUpload](/Stored_Procedure/usp_BulkUpload.sql) - - [usp_TableUnpivot](/Stored_Procedure/usp_TableUnpivot.sql) + - [sp_RestoreGene](/Stored_Procedure/dbo.sp_RestoreGene.sql) (by Paul Brewer) + - [usp_who5](/Stored_Procedure/dbo.usp_who5.sql) (by Sean Smith) + - [usp_String_Search](/Stored_Procedure/dbo.usp_String_Search.sql) (by Sean Smith) + - [usp_BulkUpload](/Stored_Procedure/dbo.usp_BulkUpload.sql) + - [usp_TableUnpivot](/Stored_Procedure/dbo.usp_TableUnpivot.sql) - and many others... - [User Defined Function](/User_Defined_Function) - [udf_parseJSON](/User_Defined_Function/udf_parseJSON.sql) @@ -96,13 +96,14 @@ Headers: - [udf_SplitStringByDelimiter](/User_Defined_Function/udf_SplitStringByDelimiter.sql) - [udf_Tally](/User_Defined_Function/udf_Tally.sql) - and many others... - - [Utilities](/Utilities) (**Complete list of 260 SQL Server paid and free Utilities and Tools**) + - [Utilities](/Utilities) (**Complete list of 395 SQL Server paid and free Utilities and Tools**) -[*Back to top*](#header01) +**[⬆ back to top](#table-of-contents)** ## SQL Server Web Resources - - Blogs + - Blogs + - [Brent Ozar feedly reading list](https://github.com/BrentOzar/sqlblogs) - [SQL Central Blog Scripts](http://www.sqlservercentral.com/Scripts/) - [SQL Central Blog Articles](http://www.sqlservercentral.com/Articles/) - [SQL Central Blog Stairways](http://www.sqlservercentral.com/stairway/) @@ -110,15 +111,13 @@ Headers: - [MSSQLTips](https://www.mssqltips.com/get-free-sql-server-tips/) - [BRENT OZAR](https://www.brentozar.com/) scripts, videos and articles - [Simple-talk Articles](https://www.simple-talk.com/) - - [SQLSentry Blog](http://blogs.sqlsentry.com) + - [SentryOne Blog](https://www.sentryone.com/blog) - [Glenn Berry's SQL Server Performance](http://sqlserverperformance.wordpress.com/) - [Kenneth Fisher SQLStudies Blog](http://sqlstudies.com/) - [Best SQL Server Perfomance Blog](http://sqlperformance.com/) - [Weblogs SQLTeam Blogs](http://weblogs.sqlteam.com/) - - [SQLMag](http://sqlmag.com/) - - [SQLShack](http://www.sqlshack.com/) - - [LessThanDot SQL Server Blog](http://blogs.lessthandot.com/index.php/category/datamgmt/dbprogramming/mssqlserver/) - - [SQLBlog](http://sqlblog.com) + - [SQLShack](https://www.sqlshack.com/) + - [SQL Kiwi by Paul White](https://www.sql.kiwi/) - [DatabseJournal SQL Server Blog](http://www.databasejournal.com/features/mssql/) - [SQLPass](http://www.sqlpass.org/Home.aspx) - [Vertabelo Blog](http://www.vertabelo.com/blog) @@ -138,102 +137,137 @@ Headers: - [SQL.ru SQL Server](http://www.sql.ru/blogs/t-sql) (Russian) - [C# Corner SQL Server Articles](http://www.c-sharpcorner.com/technologies/sql-server) - [TechTarget Blog](http://searchsqlserver.techtarget.com/) - - [Toad SQL Server Blog](http://www.toadworld.com/platforms/sql-server/b/weblog) + - [Toad SQL Server Blog](https://blog.toadworld.com/tag/sql-server) - [SQL-Articles](http://sql-articles.com/articles/) - [DallasDBAs Blog](http://dallasdbas.com/blog/) - [UpSearch Blog](https://upsearch.com/blog/) + - [SQL tutorial](https://www.scaler.com/topics/sql) - [ProData Blog](http://blogs.prodata.ie/) - - [Red9 SQL Server Performance Blog](https://red9.com/blog/) - [DallasDBAs.com Blog](http://dallasdbas.com/blog/) - [SQLBI Blog](http://www.sqlbi.com) - [RDX Blog](http://blog.rdx.com) - [Codingsight](http://codingsight.com/) - [Solomon Rutzky's SQL Quantum Leap Blog](https://SqlQuantumLeap.com/) - - Security (great thanks to [Troy Hunt](https://www.troyhunt.com/troys-ultimate-list-of-security-links/)) + - [Niels Berglund Blog](https://nielsberglund.com) + - [BornSQL Blog](https://bornsql.ca/blog/) + - [Kevin Chant Blog](https://www.kevinrchant.com/) + - [SQLBlog.org](https://sqlblog.org) + - [Idera SQL Server Blog](https://community.idera.com/tags/SQL%2bServer) + - [SQL Server Science Blog](https://www.sqlserverscience.com/) (by Max Vernon) + - [Kohera SQL Server Blog](https://kohera.be/blog/category/sql-server/) + - [SQL Queries Cheat Sheet](https://helpercodes.com/sql-query-cheatsheet-tutorial/) + - Security (great thanks to [Troy Hunt](https://www.troyhunt.com/troys-ultimate-list-of-security-links/)) - SQL injection - - [sqlmap](http://sqlmap.org/) – The tool for mounting SQL injection attacks tests against a running site - - [Drupal 7 SQL injection flaw of 2014](https://www.drupal.org/PSA-2014-003) – great example of how impactful it still is (patch it within 7 hours or you’re owned) - - [Ethical Hacking: SQL Injection](http://www.pluralsight.com/courses/ethical-hacking-sql-injection) – If you really want to go deep, here’s five and a half hours worth of Pluralsight content + - [sqlmap - The tool for mounting SQL injection attacks tests against a running site](http://sqlmap.org/) + - [Drupal 7 SQL injection flaw of 2014](https://www.drupal.org/PSA-2014-003) – great example of how impactful it still is (patch it within 7 hours or you are owned) + - [Ethical Hacking: SQL Injection](http://www.pluralsight.com/courses/ethical-hacking-sql-injection) – If you really want to go deep, here is five and a half hours worth of Pluralsight content - Exploit databases and breach coverage - [seclists.org](http://seclists.org) – Heaps of exploits consolidated from various bug tracking lists - [Exploit Database](https://www.exploit-db.com/) – Very comprehensive list of vulnerabilities - - [PunkSPIDER](https://www.punkspider.org/) – Lots of vulnerabilities of all kinds all over the web (about 90M sites scanned with over 3M vulns at present) - [Data Loss DB](http://datalossdb.org/) – Good list of breaches including stats on number of records compromised - - [Information is Beautiful: World’s Biggest Data Breaches](http://www.informationisbeautiful.net/visualizations/worlds-biggest-data-breaches-hacks/) – Fantastic visualisation of incidents that give a great indication of scale + - [Information is Beautiful: World’s Biggest Data Breaches](http://www.informationisbeautiful.net/visualizations/worlds-biggest-data-breaches-hacks/) - [Biggest data breaches in history](https://www.comparitech.com/blog/information-security/biggest-data-breaches-in-history/) (by Dave Albaugh) - - [SQL Server Database Engine Permission Posters](http://social.technet.microsoft.com/wiki/contents/articles/11842.sql-server-database-engine-permission-posters.aspx) + - [Microsoft SQL Server Permissions Posters](https://github.com/Microsoft/sql-server-samples/tree/master/samples/features/security/permissions-posters) - [Module Signing Info](https://modulesigning.info/) - Info and resources related to module signing (i.e. Certificates, Asymmetric Keys, `ADD SIGNATURE`, etc) in T-SQL and SQLCLR - - Free Videos + - [SQL Server security best practices](https://learn.microsoft.com/en-us/sql/relational-databases/security/sql-server-security-best-practices) (by Microsoft) + - Free Videos - [Youtube Brent Ozar](https://www.youtube.com/user/BrentOzar/videos) + - [Youtube Free SQL Server Statisctics Class](https://www.youtube.com/playlist?list=PLDYqU5RH_aX05ajDAH-6sYXr4i1Mjh9lT) + - [SQLPASSTV videos](https://www.youtube.com/user/SQLPASSTV/videos) - [IDERA Resource Center](https://www.idera.com/resourcecentral) - [MSSQLTips SQL Server Webcasts and Videos](https://www.mssqltips.com/sql-server-webcasts/) - [SQL Server Videos](http://www.sqlservervideos.com/) - [TECHNET How do I Videos](https://technet.microsoft.com/en-us/library/dd353197.aspx) - [Veeam Learn Microsoft SQL Server](http://go.veeam.com/learn-microsoft-sql-server-free-video-tutorial-course.html) - - [MidnightDBA ITBookWorm Video](http://midnightdba.itbookworm.com/) + - [MidnightDBA ITBookWorm Video](http://midnightdba.itbookworm.com/Minion/Reindex) - [SQL Server Hangouts](https://www.youtube.com/playlist?list=PLvcGRPk71pmRi2UZHKfyruJKu_zHZ0ROc) (by Boris Hristov, Cathrine Wilhelmsen) - [Youtube russianVC](https://www.youtube.com/channel/UC0UA5gKnOq9TM1RNvMIArwg) (Russian) + - [Youtube SSMSBoost tutorials](https://www.youtube.com/channel/UCkm2ETlBDjs5V-kKb6j86zQ) - [Youtube Redgate Videos](https://www.youtube.com/redgate) - - [Dell DBA days the Brent Ozar Unlimited 2015](https://software.dell.com/event/webcast-series-dell-dba-days-the-brent-ozar-unlimited-show890450) - - [Dell DBA days the Brent Ozar Unlimited 2016](https://software.dell.com/event/live-webcast-series-dell-dba-days-the-brent-ozar-unlimited-show-the-se8112821) - [User Group.tv](http://usergroup.tv/) (by Shawn Weisfeld) - [SQLPass Virtual Chapters](http://www.sqlpass.org/passchapters/virtualchapters.aspx) - [Youtube SQLpassion](https://www.youtube.com/channel/UCkrUQVPrv36Musorn0K4KoA) - - [SQLBits Video](http://sqlbits.com/) - - [Business Intelligence Videos](http://www.bidn.com/Videos/Videos) + - [SQLBits Video](https://sqlbits.com/content/) - [Pragmatic Works Free Training Webinars](http://pragmaticworks.com/Training/FreeTrainingWebinars) - [Youtube Pragmatic Works Video](https://www.youtube.com/user/PragmaticWorks) (by Devin Knight and Manuel Quintana) - - [MVP: Data Platform](https://channel9.msdn.com/Blogs/MVP-Data-Platform) - - Free Database Podcasts + - [TechEd SQL Server Videos](https://channel9.msdn.com/Search?term=sql%20server&lang-en=true) + - [Build 2018 conference](http://sqlservercode.blogspot.ru/2018/05/azure-sql-data-warehouse-azure-sql.html) + - [New Stars of Data SQL Server Video](https://www.youtube.com/playlist?list=PLLq_tkpMFDU5ibrnqn6I8CZxZ2-zYWG9m) + - [Youtube Community 1nn0va](https://www.youtube.com/c/Community1nn0va/videos) (by Community 1nn0va) + - Free Database Podcasts - [SQL Server Radio](http://www.sqlserverradio.com/) (by Guy Glantser and Matan Yungman) - [SQL Data Partners](http://sqldatapartners.com/podcast/) (by Carlos L Chacon, César Oviedo and Adrian Miranda) - [Away from the Keyboard](http://awayfromthekeyboard.com/) (by Cecil Phillip and Richie Rump) - [RunAs Radio](http://runasradio.com/) (by Richard Campbell and Greg Hughes) - [People Talking Tech](http://peopletalkingtech.com/) (by Denny Cherry) - [NET Rocks!](http://www.dotnetrocks.com/) (by Richard Campbell and Carl Franklin) - - [SQL Down Under Podcast](http://www.sqldownunder.com/Podcasts) (by Greg Low) + - [SQL Down Under Podcast](https://sqldownunder.com/pages/sql-down-under-podcast) (by Greg Low) - [Free sql server video tutorials for beginners](http://csharp-video-tutorials.blogspot.ru/p/free-sql-server-video-tutorials-for.html) (by PRAGIM Technologies) - - [Midnight DBA Podcast](http://midnightdba.itbookworm.com/Show) (by Sean and Jen McCown) - [Dear SQL DBA](https://www.littlekendra.com/dearsqldba/) (by Kendra Little) - [GroupBy.org - Group By is a free online event for the community, by the community](https://groupby.org/) (by Brent Ozar team) - [DevopsCafe](http://devopscafe.org/) (by John Willis and Damon Edwards) - [SQLPlayer](http://sqlplayer.net/) (by Kamil Nowinski and Damian Widera) - [Data Driven](http://datadriven.tv/) (by Frank La Vigne and Andy Leonard) - - [SQL Down Under Podcast](https://www.sqldownunder.com) (by Greg Low) - - Courses + - [SQL Undercover Podcast](https://sqlundercover.com/category/podcast/) (by David Fowler and Adrian Buckman) + - [Dallas DBAs](https://dallasdbas.com/) (by Kevin Hill) + - [SQL Server Pain Relief: Office Hours](https://www.stitcher.com/podcast/sql-server-pain-relief-office-hours-with-brent-ozar-unlimitedr) (by Brent Ozar) + - [Azure DevOps Podcast](http://azuredevopspodcast.clear-measure.com/) (by Microsoft) + - [Mixed Extents](https://youtu.be/hBgMadT9fuU) (by EightKB) + - Courses - Free - - [Learn SQL Server by solving problems](https://sqlworkbooks.com/courses-overview/) (by Little Kendra) + - [SQLBolt - Learn SQL with simple, interactive exercises](https://sqlbolt.com/) + - [Learning Extended Events in 60 Days](https://jasonbrimhall.info/2015/09/08/learning-extended-events-in-60-days/) and new [link](http://sqlxevents.com/) (by Jason Brimhall) + - [Learn SQL Server by solving problems](https://littlekendra.com/courses-overview/) (by Little Kendra) - [Codecademy Learn SQL](https://www.codecademy.com/learn/learn-sql) - [Codecademy SQL: Table Transformation](https://www.codecademy.com/learn/sql-table-transformation) - [Codecademy SQL: Analyzing Business Metrics](https://www.codecademy.com/learn/sql-analyzing-business-metrics) - [MVA SQL Server Courses](https://mva.microsoft.com/product-training/sql-server) - - [How to Think Like the SQL Server Engine](https://learnfrom.brentozar.com/courses/how-to-think-like-the-engine-an-introduction-to-sql-server-internals/) - - [Number and Date Tables](https://www.brentozar.com/archive/2016/01/video-free-training-of-the-week-number-and-date-tables/) + - [How to Think Like the SQL Server Engine](https://www.brentozar.com/training/think-like-sql-server-engine/) - [Free SQL Tutorials](http://www.guru99.com/sql.html) - [OpenedX Microsoft Courses](https://openedx.microsoft.com/) - [SQLBolt - Learn SQL with simple, interactive exercises](https://sqlbolt.com/) - [SQL Tutorial](https://sqlzoo.net) - [HackerRank.com - SQL interactive exercises and many others languages](https://www.hackerrank.com/domains/sql) - [SQL-EX.ru - Practical skills of SQL language](http://www.sql-ex.ru) (Russian, English) + - [Free Azure certification training courses](https://rlevchenko.com/2019/01/11/free-azure-certification-training-courses/) + - [SQL Server Tutorial](https://www.tutorialgateway.org/sql/) (by Tutorial Gateway) + - [Intro to SQL: Querying and managing data](https://www.khanacademy.org/computing/computer-programming/sql) + - [T-SQL Tutorial](https://www.tutorialspoint.com/t_sql/index.htm) (by TutorialSpoint) + - [T-SQL Tutorial and examples](https://www.tsql.info/sql-tutorial.php) (by tsql.info) + - [Red Gate Data Platform courses](https://www.red-gate.com/hub/university/courses/data-platform) (by Red Gate) + - [SQLZoo tutorial](https://sqlzoo.net/) + - [edX SQL Courses](https://www.edx.org/learn/sql) (by edX) + - [SQL Murder Mystery](https://github.com/NUKnightLab/sql-mysteries) (by NUKnightLab) + - [SQL Murder Mystery with answers](https://github.com/erika-e/sql-mysteries) (by Erika Pullum) + - [SQL Problems and solutions](http://www.sql-tutorial.ru/en) (by S. I. Moiseenko) + - [Advanced T-SQL Puzzles](https://github.com/smpetersgithub/AdvancedSQLPuzzles) (by Scott Peters) + - [Leetcode SQL Problems](https://leetcode.com/problemset/database/) - Paid - [Lynda Courses](http://www.lynda.com/SQL-Server-training-tutorials/456-0.html) - [Veeam Free Courses](https://go.veeam.com/microsoft-sql-series-webinars.html) - [SQLSkills Trainings](https://www.sqlskills.com/sql-server-training/online-training/) - - [Brent Ozar Team Trainings](https://learnfrom.brentozar.com/) + - [Brent Ozar Team Trainings](https://www.brentozar.com/training/) - [Pluralsight Courses](https://www.pluralsight.com/search?q=sql+server&categories=all) - [SolidQ Classes](https://training.solidq.com/classes/) - [JOOQ SQL Masterclass](http://www.jooq.org/training/) - [Learn SQL Server High Availability & Disaster Recovery](https://learnsqlserverhadr.com/) (by Edwin M Sarmiento) - [Madeira Data Solutions Academy](http://madeira-data-solutions.teachable.com/) - [SQLpassion Online Academy](http://www.sqlpassion.at/online-training/index.html) (by Klaus Aschenbrenner) - - SQL Server Backwards Compatibility - - [2017 Backwards Compatibility](https://docs.microsoft.com/en-us/sql/database-engine/sql-server-database-engine-backward-compatibility) - - [2016 Backwards Compatibility](https://docs.microsoft.com/en-us/sql/database-engine/sql-server-database-engine-backward-compatibility) - - [2014 Backwards Compatibility](https://msdn.microsoft.com/en-us/library/cc280407(v=sql.120).aspx) - - [2012 Backwards Compatibility](https://msdn.microsoft.com/en-us/library/cc707787(v=sql.110).aspx) - - [2008 R2 Backwards Compatibility](https://msdn.microsoft.com/en-us/library/cc707787(v=sql.105).aspx) - - [2008 Backwards Compatibility](https://msdn.microsoft.com/en-us/library/cc707787(v=sql.100).aspx) - - [2005 Backwards Compatibility](http://technet.microsoft.com/en-us/library/ms143532(v=sql.90).aspx) + - [Vertabelo Academy](https://academy.vertabelo.com/) + - [Darling Data - The Best SQL Server Training On The Internet?](https://learn.erikdarlingdata.com/) (by Erik Darling) + - [W3Resource SQL Exercises, Practice, Solution](https://www.w3resource.com/sql-exercises/) (by w3resource) + - [LinkedIn SQL Server cources](https://www.linkedin.com/learning/search?entityType=COURSE&keywords=sql%20server) (by LinkedIn) + - SQL Server Deprecated database engine features and Backwards Compatibility + - [Deprecated Features in SQL Server Replication](https://learn.microsoft.com/en-us/sql/relational-databases/replication/deprecated-features-in-sql-server-replication?view=sql-server-ver16) + - [Deprecated database engine features in SQL Server 2022](https://learn.microsoft.com/sql/database-engine/discontinued-database-engine-functionality-in-sql-server?view=sql-server-ver16) + - [Deprecated database engine features in SQL Server 2019](https://learn.microsoft.com/sql/database-engine/deprecated-database-engine-features-in-sql-server-2019?view=sql-server-ver16) + - [Deprecated database engine features in SQL Server 2017](https://learn.microsoft.com/sql/database-engine/deprecated-database-engine-features-in-sql-server-2017?view=sql-server-ver16) + - [Deprecated database engine features in SQL Server 2016](https://learn.microsoft.com/sql/database-engine/deprecated-database-engine-features-in-sql-server-2016?view=sql-server-ver16) + - [2014 Backwards Compatibility](https://docs.microsoft.com/en-us/sql/getting-started/backward-compatibility?view=sql-server-2014) + - [2012 Backwards Compatibility](https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2012/ms143532(v=sql.110)) + - [2008 R2 Backwards Compatibility](https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2008-r2/cc707787(v=sql.105)) + - [2008 Backwards Compatibility](https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2008/cc707787(v=sql.100)) + - [2005 Backwards Compatibility](https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2005/ms143532(v=sql.90)) - SQL Server System Views Map - [SQL Server 2008 System Views Map](https://www.microsoft.com/en-us/download/details.aspx?id=9301) - [SQL Server 2012 System Views Map](https://www.microsoft.com/en-us/download/details.aspx?id=39083) @@ -242,26 +276,73 @@ Headers: - [Troubleshooting connectivity issues with Microsoft Azure SQL Database](https://support.microsoft.com/en-in/help/10085/troubleshooting-connectivity-issues-with-microsoft-azure-sql-database) - [Troubleshooting Always On Issues](https://support.microsoft.com/en-us/help/10179/troubleshooting-alwayson-issues) - [Guide for enhancing privacy and addressing GDPR requirements with the Microsoft SQL platform](https://aka.ms/gdprsqlwhitepaper) - - Social, Forum and Messenger SQL Server Groups + - SQL Server feedbacks + - [SQL Server help and feedback](https://docs.microsoft.com/en-us/sql/sql-server/sql-server-get-help) + - [Azure Data Studio feedback](https://github.com/Microsoft/azuredatastudio/issues) + - [Azure SQL DB feedback](https://feedback.azure.com/forums/217321-sql-database) + - [Azure SQL DB Managed Instances feedback](https://feedback.azure.com/forums/915676-sql-managed-instance) + - [Power BI feedback](https://ideas.powerbi.com/forums/265200-power-bi-ideas) + - [SSMS feedback](https://social.msdn.microsoft.com/Forums/en-US/home?forum=sqltools) + - [SQL Server Data Tools feedback](https://social.msdn.microsoft.com/Forums/en-US/home?forum=ssdt&filter=alltypes&sort=lastpostdesc) + - Social, Forum and Messenger SQL Server Groups - [SQLServerCentral Forum](http://www.sqlservercentral.com/Forums/) (more than 10^6 People) - - [Slack #sqlhelp](https://sqlcommunity.slack.com/messages/sqlhelp/) (more than 700 People) - - [Slack #firstresponderkit](https://sqlcommunity.slack.com/messages/firstresponderkit/) (more then 70 People) - - [Twitter #sqlhelp](https://twitter.com/hashtag/sqlhelp) (more than 500 People) + - [Slack #sqlhelp](https://sqlcommunity.slack.com/messages/sqlhelp/) (more than 900 People) + - [Slack #firstresponderkit](https://sqlcommunity.slack.com/messages/firstresponderkit/) (more then 90 People) + - [Twitter #SQLServer](https://twitter.com/hashtag/SQLServer), [Twitter #SQLFamily](https://twitter.com/hashtag/SQLFamily), [Twitter #sqlhelp](https://twitter.com/hashtag/sqlhelp) (more than 500 People) + - Reddit – [`/r/sqlserver`](https://www.reddit.com/r/SQLServer/), [`/r/sql`](https://www.reddit.com/r/SQL/), and [`/r/database`](https://www.reddit.com/r/Database/) - [SQL.ru SQL Server Forum](http://www.sql.ru/forum/microsoft-sql-server) (more than 10^5 People, Russian) - [VK.com #sqlcom](https://vk.com/sqlcom) (more than 3600 People, Russian) - [SQL Server User Group Meetings](https://www.mssqltips.com/sql-server-user-groups/) - - [Russian SQL Server User Group](https://www.facebook.com/groups/144858492215825/) (434 People, Russian) - - [SQLcom.ru telegram channel](https://t.me/sqlcom) (284 People, Russian) + - [Russian SQL Server User Group](https://www.facebook.com/groups/144858492215825/) (900 People, Russian) + - [SQLcom.ru telegram chat](https://t.me/sqlcom) (1900 People, Russian) + - [PowerBI telegram chat](https://t.me/PBI_Rus) (295 People, Russian) + - [PostgesSQL telegram chat](https://t.me/pgsql) (2823 People, Russian) + - [DBA telegram chat](https://t.me/dba_ru) (1389 People, Russian) + - [SQLTeam SQL Server Forum](https://forums.sqlteam.com/) + - [Red Gate SQL Server Forum](https://forum.red-gate.com/) + - [Microsoft SQL Server on Q&A](https://docs.microsoft.com/en-us/answers/products/sql-server) + - SQL Server Conferences + - [SQL Saturdays](https://sqlsaturday.com/) + - [Pass Sumit - Red Gate](https://passdatacommunitysummit.com) + - [SQLBits](https://sqlbits.com/) + - [Microsoft Ignite](https://myignite.microsoft.com/home) + - [Microsoft Build](https://mybuild.microsoft.com/home) + - [Devintersection](https://devintersection.com/) + - [SentryOne SQL Server Virtual Conference](https://info.sentryone.com/accelerate-2020) + - [Red Gate SQL Server Online Events](https://www.red-gate.com/hub/events/online-events/) + - [EigthKB Sql Server Internals Conference](https://eightkb.online/) + - [DataWeekender](https://www.dataweekender.com/schedule) + - [Dativerse](https://sessionize.com/dativerse) + - [Future Data Driven](https://datadrivencommunity.com/) + - [DataMinds Connect](https://datamindsconnect.be/) + - [New Stars of Data ](https://www.newstarsofdata.com/) + - [Data Weekender](https://www.dataweekender.com/) + - [Data Toboggan](http://www.datatoboggan.co.uk/) + - [The SQL Server & Azure SQL Conference](https://www.mssqlconf.com/#!/) + - [Microsoft Build](https://mybuild.microsoft.com/home) + - [Microsoft Ignite](https://myignite.microsoft.com/home) + - [Microsoft Inspire](https://myinspire.microsoft.com/home) + - [DataMinutes](https://datagrillen.com/dataminutes/) + - [Data & AI Summit](https://databricks.com/dataaisummit) - Open Source Projects + - [SQLFluff - A SQL linter and auto-formatter for Humans](https://github.com/sqlfluff/sqlfluff) + - [sp_whoisactive](http://whoisactive.com/) (documentation) and github repo for it [sp_WhoIsActive](https://github.com/amachanic/sp_whoisactive) (by Adam Machanic) - [Brent Ozar SQL Server First Responder Kit](https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit) (Github) - - [SQL Server Maintenance Solution](https://github.com/olahallengren/sql-server-maintenance-solution) (by Ola Hallengren) (Github) + - [SQL Server Ola Hallengren's Maintenance Solution](https://github.com/olahallengren/sql-server-maintenance-solution) (by Ola Hallengren) (Github) + - [Standby restore script output for Ola Hallengren's Maintenance Solution](https://github.com/jzagelbaum/OlaHallengrenRestoreScript) (by jzagelbaum) (Github) + - [SqlQueryStress - SQL query stress simulator for SQL Server](https://github.com/ErikEJ/SqlQueryStress) (by Adam Machanic and Erik Ejlskov Jensen) + - [WorkloadTools - collection of tools to collect, analyze and replay SQL Server workloads, on premises and in the cloud](https://github.com/spaghettidba/WorkloadTools) (by Gianluca Sartori) - [Statistic Parser](https://github.com/Jorriss/StatisticsParser) (by Richie Rump) (Github) - [SQL Generator](https://github.com/Jorriss/sqlgenerator) (by Richie Rump) (Github) - [Columnstore Indexes Scripts Library](https://github.com/NikoNeugebauer/CISL) (by Niko Neugebauer) (Github) - [MOSL - Memory Optimized Script Library](https://github.com/NikoNeugebauer/MOSL) (by Niko Neugebauer) (Github) + - [sp_SrvPermissions - stored procedure for list Server permissions](https://github.com/sqlstudent144/SQL-Server-Scripts/blob/master/sp_SrvPermissions.sql) (by Kenneth Fisher) + - [sp_DBPermissions - stored procedure for list database permissions](https://github.com/sqlstudent144/SQL-Server-Scripts/blob/master/sp_DBPermissions.sql) (by Kenneth Fisher) + - [stpChecklist_Seguranca - stored procedure with more than 70 security items to validate your SQL Server database](https://github.com/dirceuresende/checklist_seguranca) (by Dirceu Resende) - [mssql-docker - Official Microsoft repository for SQL Server in Docker resources](https://github.com/ktaranov/mssql-docker) (by Microsoft) (Github) - [SQLCover - TSQL code coverage tool for SQL Server 2008+](https://github.com/GoEddie/SQLCover) (by Ed Elliott) (Github) - - [tSQLt testing framework for Microsoft SQL Server](https://github.com/tSQLt-org/tSQLt) (Github) + - [tSQLt - testing framework for Microsoft SQL Server](https://github.com/tSQLt-org/tSQLt) (Github) + - [SQLCop - tSQLt tests to highlight potential problems in your database](https://github.com/red-gate/SQLCop) (Red Gate) - [T-SQL SimMetrics string matching algorithms](https://github.com/GuerrillaAnalytics/similarity) (Github) - [Azure Blob Storage Backup](https://github.com/bornsql/azureblobstoragesync) (by Randolph West) (Github) - [StackExchange.DataExplorer - free tool for executing SQL queries against Stack Exchange databases](https://github.com/StackExchange/StackExchange.DataExplorer) (Github) @@ -289,8 +370,68 @@ Headers: - [Automatically fix high VLF counts in SQL Server 2012+](https://github.com/tboggiano/autofix-vlfs) (by Tracy Boggiano) - [splittinglargefiles - Process for splitting large files in a filegroup that has grown out of control.](https://github.com/tboggiano/splittinglargefiles) (by Tracy Boggiano) - [olamaintconfigtables - This are tables and jobs that can use to run Ola's scripts as T-SQL Jobs and run on Linux](https://github.com/tboggiano/olamaintconfigtables) (by Tracy Boggiano) + - [SQL Undercover Toolbox - A collection of cool and useful tools, procedures and scripts for the discerning DBA](https://github.com/SQLUndercover/UndercoverToolbox) (by SQL Undercover) + - [dba-database - Database containing DBA helper code and open source software](https://github.com/amtwo/dba-database) (by Andy Mallon) + - [SQLServerSpaceAnalysis PowerBI](https://github.com/SQLJana/SQLServerSpaceAnalysis) (by Jana Sattainathan) + - [SQL Server Telegram Bot](https://github.com/ionflux/mssql-telegram-bot/) + - [ZabbixMSSQL - Zabbix Template and tools for Microsoft SQL Server](https://github.com/dreik/ZabbixMSSQL) (by Sergey Kolesnik) + - [AGLatency - analyze AG log block movement latency between replicas and create report accordingly](https://github.com/suyouquan/AGLatency) (by Simon Su) + - [SQLSetupTools - FixMissingMSI, Product Browser, SQL Registry Viewer](https://github.com/suyouquan/SQLSetupTools) (by Simon Su) + - [tsql-parser - Library Written in C# For Parsing SQL Server T-SQL Scripts in .Net](https://github.com/bruce-dunwiddie/tsql-parser) (by Bruce Dunwiddie) + - [tsqllint - Configurable linting for TSQL](https://github.com/tsqllint/tsqllint) (by tsqllint) + - [Rezoom.SQL - F# ORM for SQL databases](https://github.com/rspeele/Rezoom.SQL) (by Robert Peele) + - [SQLtoExcel - Exports the output of one or more TSQL script queries to Excel](https://github.com/BeginTry/SQLtoExcel) (by Dave Mason) + - [Analysis Services - Analysis Services samples and community projects](https://github.com/Microsoft/Analysis-Services) (by Microsoft) + - [ms-sql-express-replication - replication library written for MS SQL Sever Express edition](https://github.com/janhalama/ms-sql-express-replication) (by Jan Halama) + - [SQL query builder, written in C#](https://github.com/sqlkata/querybuilder) + - [php-crud-api - Single file PHP script that adds a REST API to a SQL database](https://github.com/mevdschee/php-crud-api) (by Maurits van der Schee) + - [sql2xls - SQL to Excel Export Tool](https://github.com/bornsql/sql2xls) (by Randolph West) + - [azureblobstoragesync - Backup any version of your on-premises SQL Server database to a network share or Azure Blob Storage and restore it too](https://github.com/bornsql/azureblobstoragesync) (by Randolph West) + - [sql_profiler - Microsoft SQL-Server Profiler (command-line) for Linux/Mac/Windows](https://github.com/ststeiger/sql_profiler) (by Stefan Steiger) + - [dbops - Powershell module that provides continuous database deployments on any scale](https://github.com/sqlcollaborative/dbops) (by Kirill Kravtsov) + - [TabularTranslator - allow create translations for a translation file generated by SSDT for tabular models with the compatibility level 1200 and up](https://github.com/Kjonge/TabularTranslator) (by Kjonge) + - [TSqlStrong - T-Sql type checker that detects improper joins, possibly null value operations, enumeration check constraint violations, incorrect use of temporary table at call site, and more](https://github.com/JSuder-xx/TSqlStrong) (by John Suder) + - [SQL Power Doc - is a collection of Windows PowerShell scripts and modules that discover, document, and diagnose SQL Server instances and their underlying Windows OS & machine configuration](https://github.com/kendalvandyke/sqlpowerdoc) (by Kendal Van Dyke) + - [rsqlserver - Sql Server driver database interface (DBI) driver for R](https://github.com/agstudy/rsqlserver) + - [DBA MultiTool - T-SQL scripts for the long haul: optimizing storage, on-the-fly documentation, and general administrative needs.](https://github.com/LowlyDBA/dba-multitool) (by John McCall) + - [language-extensions-sqlserver - SQL Server Language Extensions project](https://github.com/microsoft/sql-server-language-extensions) (by Microsoft) + - [AzureRMR - R package for interacting with Azure Resource Manager](https://github.com/Azure/AzureRMR) (by Microsoft) + - [EntityFramework.Utilities - Provides extensions for EntityFramework that doesn't exist out of the box like delete and update by query and bulk inserts](https://github.com/MikaelEliasson/EntityFramework.Utilities) (by Mikael Eliasson) + - [EFCore.BulkExtensions - Entity Framework Core Bulk Batch Extensions for Insert Update Delete and Read (CRUD) operations on SQL Server and SQLite](https://github.com/borisdj/EFCore.BulkExtensions) (by Boris Djurdjevic) + - [Performance Analysis of Logs (PAL) Tool](https://github.com/clinthuffman/PAL) (by Clint Huffman) + - [SQL-Server-Permissions-Manager - a set of scripts for managing logins and permissions on SQL Server databases](https://github.com/ericcobb/SQL-Server-Permissions-Manager) (by Eric Cobb) + - [AwesomeSQLServer - collection of SQL Server Queries and documentations to fix your SQL Server's bottle neck](https://github.com/SQLadmin/AwesomeSQLServer) (by SqlAdmin) + - [databases_scripts - SQL Server useful scripts](https://github.com/dgavrikov/databases_scripts/tree/master/SQL%20Server) (by Dmitriy Gavrikov) + - [sp_PressureDetector - stored procedure for quickly detecting CPU and Memory pressure on a SQL Server](https://github.com/erikdarlingdata/DarlingData/tree/main/sp_PressureDetector) (by Erik Darling) + - [sp_HumanEvents - make Extended Events easier and more approachable for the average admin to troubleshoot common scenarios](https://www.erikdarlingdata.com/sp_humanevents/) (by Erik Darling) + - [Export Prometheus metrics from SQL queries](https://github.com/albertodonato/query-exporter) (by Alberto Donato) + - [homebrew-mssql-release - brew formulae for Microsoft ODBC Driver for SQL Server and SQL Server Command Line Utilities](https://github.com/microsoft/homebrew-mssql-release) (by Microsoft) + - [ASSP - Analysis Services Stored Procedure Project](https://asstoredprocedures.github.io/ASStoredProcedures/) (by Darren Gosbell) + - [Data-Blogger-Resource-Kit - Includes resources for use by bloggers, microbloggers, vloggers, and origami enthusiasts who focus on SQL Server](https://github.com/amtwo/Data-Blogger-Resource-Kit) (by Andy Andy Mallon) + - [SQL-Server-Multi-Thread - a framework to do multi-threading in T-SQL using SQL Server Agent jobs.](https://github.com/jobbish-sql/SQL-Server-Multi-Thread) (by ) + - [SQL Server and Azure SQL Labs and Workshops](https://microsoft.github.io/sqlworkshops/) (by Microsoft) + - [MsSqlDependencyBrowser - Simple tool to browse between dependent objects on MS SQL Server](https://github.com/usharik/MsSqlDependencyBrowser) (by Aleksej Usharovskij) + - [`Projects-MS-SQL-Server-DBA` - Utilities and Scripts for SQL Server dba](https://github.com/jobgemws/Projects-MS-SQL-Server-DBA) (by Evgeniy Gribkov) + - [`sp_alter_column` stored procedure is able to alter a column with dependencies](https://github.com/segovoni/sp_alter_column) (by Sergio Govoni) + - [Toolbox repository for Madeira's consultant team](https://github.com/MadeiraData/MadeiraToolbox) (by Madeira) + - [`mssql-jobs-hadr` - maintain scheduled jobs on SQL Servers with either Availability Groups or Database Mirroring](https://github.com/MadeiraData/mssql-jobs-hadr) (by Eitan Blumin) + - [Fluent Migrator is a migration framework for .NET much like Ruby on Rails Migrations](https://github.com/fluentmigrator/fluentmigrator) (by Eivind Gussiås Løksetheloekset, Mark Junker, Tom Marien) + - [SQL Server in Docker](https://github.com/microsoft/mssql-docker) (by Microsoft) + - [ActiveRecord SQL Server Adapter - SQL Server Adapter For Rails](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter) (by rails-sqlserver) + - [EFCorePowerTools - Reverse engineering, model visualization and migrations UI for EF Core](https://github.com/ErikEJ/EFCorePowerTools) (by Erik Ejlskov Jensen) + - [SqlTableDependency - a high-level C# component used to audit, monitor and receive notifications on SQL Server's record table changes](https://github.com/christiandelbianco/monitor-table-change-with-sqltabledependency) (by Christian Del Bianco) + - [EFSecondLevelCache.Core - Entity Framework Core Second Level Caching Library (Redis)](https://github.com/VahidN/EFSecondLevelCache.Core) (by Vahid Nasiri) + - [Dotmim.Sync - a brand new database synchronization, multi platform, multi databases, developed on top of .Net Standard 2.0](https://github.com/Mimetis/Dotmim.Sync) + - [Hekaton-based shock absorber pattern for SQL Server](https://github.com/sqlsunday/shock-absorber) (by Daniel Hutmacher) + - [HammerDBBenchmark - Swarchy T101 Wilson HammerDb Benchmark Setup Scripts for SQL Server](https://github.com/swarchy/HammerDBBenchmark) (by Swarchy T101 Wilson) + - [sqlblockedprocesses - SQL Server Blocked Process Report Viewer](https://github.com/mjswart/sqlblockedprocesses) (by Michael J. Swart) + - [sp_CRUDGen - stored procedure that generates stored procedures for you based on your tables and metadata like foreign keys and data types](https://github.com/kevinmartintech/sp_CRUDGen) (by Kevin Martin) + - [sp_Develop - can be used by database developers, software developers and for performing database code (smell) reviews.s](https://github.com/EmergentSoftware/SQL-Server-Development-Assessment) (by Kevin Martin) + - [DBA Dash - Performance monitoring tool for SQL Server](https://github.com/trimble-oss/dba-dash) (by Trimble) + - [lowlydba.sqlserver - A cross-platform Ansible collection using PowerShell to configure and maintain SQL Server](https://github.com/lowlydba/lowlydba.sqlserver) - (by John McCall) + - [SQLWatch - SQLWATCH is an Open Source and completely free SQL Server Monitoring project](https://sqlwatch.io/) (by Marcin Gminski) + - [Azure_Synapse_Toolbox - Repository of tools/queries for managing and monitoring Azure Synapse](https://github.com/microsoft/Azure_Synapse_Toolbox) (by Microsoft) - Other - - [sp_whoisactive](http://whoisactive.com/) (by Adam Machanic) - [SQL# SQLCLR functions](https://sqlsharp.com/) (by Sql Quantum Lift) - [SQL Server Latch Classes Library](https://www.sqlskills.com/help/latches/) (by Paul S. Randal) - [SQL Server Wait Types Library](https://www.sqlskills.com/help/waits/) (by Paul S. Randal) @@ -302,16 +443,16 @@ Headers: - [DBA Stackexchange SQL Server](http://dba.stackexchange.com/questions/tagged/sql-server) - [Server Fault - is a question and answer site for system and network administrators](https://serverfault.com/) - [SQL Server Connection Strings](https://www.connectionstrings.com/sql-server/) + - [SQL Connection String Generator for .NET](https://aireforge.com/Tools/ConnectionStringGenerator) - [SQL Injection Cheat Sheet](https://www.netsparker.com/blog/web-security/sql-injection-cheat-sheet/) (by Ferruh Mavituna) - - [RSS Most Recent SQL Server KBs](https://support.microsoft.com/en-us/rss?rssid=1044) - [Stackoverflow SQL Anti Patterns](http://stackoverflow.com/questions/346659/what-are-the-most-common-sql-anti-patterns) - [Azure Speed](http://www.azurespeed.com/) (by Blair Chen) - - [SQLFiddle](http://sqlfiddle.com) + - [DBFiddle - test your queries online](https://dbfiddle.uk/?rdbms=sqlserver_2019) + - [SQLize Online - is a free online SQL environment for quickly running, experimenting with and sharing SQL code](https://sqlize.online/sql/mssql2019/) - [Experts-Exchange.com MS SQL Server Topics](https://www.experts-exchange.com/topics/ms-sql-server/) - [Paste The Plan - share query plans quickly and easily](https://www.brentozar.com/pastetheplan/) (by Brent Ozar Team) - [StackExchange DataExplorer Query On line](http://data.stackexchange.com/stackoverflow/query/new) - [Dell Databases Wiki](http://en.community.dell.com/techcenter/storage/w/wiki/5018.sc-series-technical-documents) (by Doug Bernhardt) - - [SDUTools - Free Tools for DBAs and Developers on pure TSQL](http://sqldownunder.azurewebsites.net/Resources/SDUTools) (by SQL Down Under) - [SqlServerSearcher - open source C# tool for searching SQL Server objects](https://github.com/CoderAllan/SqlServerSearcher) (by Allan Simonsen) - [DbUp is a .NET library that helps you to deploy changes to SQL Server databases](https://github.com/DbUp/DbUp) - [SQL Server monitor - manages sql server performance](https://github.com/unruledboy/SQLMonitor) (by Wilson Chen) @@ -322,8 +463,38 @@ Headers: - [OrcaMDF - C# parser for MDF files](https://github.com/improvedk/OrcaMDF) (by Mark S. Rasmussen) - [Microsoft SQL Server Zabbix templates](https://share.zabbix.com/databases/microsoft-sql-server) - [Telegraf SQL Server Plugin](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/sqlserver) (by influxdata) - -[*Back to top*](#header02) + - [SDU Tools - pure TSQL functions Toolkit](https://sqldownunder.com/pages/sdu-tools) (by SQLDownUnder) + - [Microsoft SQL Server Publications](https://www.microsoft.com/en-us/research/search/?q=sql+server&content-type=publications) + - [SQL Server Feedback](https://feedback.azure.com/forums/908035-sql-server) + - [Docs Overview SQL Tools](https://docs.microsoft.com/en-us/sql/tools/overview-sql-tools) + - [SQL ConstantCare®: clear, personal advice for your SQL Server](https://www.brentozar.com/sql-constantcare/) (by Brent Ozar) + - [The SQL Server Execution Plan Reference](https://sqlserverfast.com/epr/) (by Hugo Kornelis) + - [EC2 Instance Calculator](https://ec2instances.info/) + - [AWS Calculator](https://calculator.aws/#/) + - [Azure Instance Calculator](http://www.azureinstances.info/) + - [PowerBI Premium Calculator](https://powerbi.microsoft.com/en-us/calculator/) + - [Nuodb Oracle and SQL Server Calculator ](https://www.nuodb.com/product/license-cost-calculator) + - [Github SQL Trending](https://github.com/trending/sql) + - [SQLCallStackResolver - Utility to resolve SQL Server callstacks to their correct symbolic form](https://github.com/arvindshmicrosoft/SQLCallStackResolver) (by Arvind Shyamsundar) + - [Azure updates](https://azure.microsoft.com/en-us/updates/?status=all) + - [Guides for Microsoft SQL Server Express](https://expressdb.io/) (by John McCall) + - [SQL Server Diagrams](http://www.e-squillace.com/tech/techdiagrams/#SQL_Server) + - [SQL Cheat Sheet for MySQL](https://websitesetup.org/sql-cheat-sheet/) (by Luke Harrison) + - [Azure Database Migration Guide](https://datamigration.microsoft.com/) (by Microsoft) + - [Hermitage: Testing transaction isolation levels in relation databases](https://github.com/ept/hermitage) (by Martin Kleppmann) + - [csv to INSERT online converter - translates your tab-delimited data into a T-SQL INSERT statement](https://table.strd.co/) (by Structured Concepts AB) + - [SQL Server Diagrams](http://www.e-squillace.com/techdiagrams-sqlserver/) (by George Squillace) + - [New Stars of Data 2020 Presentations](https://github.com/SQLGrillen/NSOD-1) (by SQLGrillen) + - [Get Your ColumnScore](https://columnscore.com) (by ColumnScore) + - [SQL Assessment API rules in .csv format](https://github.com/microsoft/sql-server-samples/blob/master/samples/manage/sql-assessment-api/DefaultRuleset.csv) (by Microsoft) + - [SQL cheat sheet for PostgreSQL and Oracle](https://www.pcwdld.com/sql-cheat-sheet) (by Marc Wilson) + - [Bllitz Excel UI](https://1pro.bi/blitz-excel-ui/) (by Alex) + - [Industry-specific Data Models - cover Subject Areas and are used to create Enterprise Data Models](https://web.archive.org/web/20220330034214/http://databaseanswers.org/data_models/) + - [Library of Database Schemas](https://dbschemalibrary.com/) + - [SQLFacts - A powerful suite of FREE TSQL tools for SQL Server database professionals](https://www.sqlfacts.com) + - [sql-log-shipping-service - provides a solution for automatically restoring SQL Server transaction log backups](https://github.com/trimble-oss/sql-log-shipping-service) (by Trimble Online Source Store) + +**[⬆ back to top](#table-of-contents)** ## BIML Resources and Bloggers @@ -337,7 +508,7 @@ BIML Resources - [Stairway to Biml](http://www.sqlservercentral.com/stairway/100550/) - [Biml User Group at LinkedIn](https://www.linkedin.com/groups/4640985) - [Building Blocks of Biml (Pluralsight course by Stacia Misner Varga)](https://app.pluralsight.com/library/courses/building-blocks-biml/table-of-contents) -- [Biml-tagged posts on this blog](http://sqlblog.com/blogs/andy_leonard/archive/tags/BIML/default.aspx) +- [SQL Reserved Words](https://modern-sql.com/reserved-words-empirical-list) (by Markus Winand) BIML Bloggers - [Ben Weissman](https://www.solisyon.de/biml-blog-de/) @@ -346,15 +517,12 @@ BIML Bloggers - [Brian Bønk](http://www.bonk.dk/biml/) - [Cathrine Wilhelmsen](http://www.cathrinewilhelmsen.net/biml/) - [Datachix: Julie Smith and Audrey Hammonds](http://datachix.com/) -- [David Stein](http://www.made2mentor.com/category/biml/) -- [Davide Mauri](http://sqlblog.com/blogs/davide_mauri/archive/tags/BIML/default.aspx) +- [Davide Mauri](http://blog.davidemauri.it/) - [Erik Hudzik](http://www.anexinet.com/blog/author/ehudzik/) - [Hennie de Nooijer](http://bifuture.blogspot.com/search/label/BIML) - [John Welch](http://agilebi.com/jwelch/tag/biml/) - [Joost van Rossum](http://microsoft-ssis.blogspot.com/search/label/BIML) -- [Koen Verbeeck](http://blogs.lessthandot.com/index.php/tag/biml/) - [Marco Schreuder](http://blog.in2bi.eu/biml/) -- [Martin Andersson](http://www.frysdisken.net/) - [Meagan Longoria](https://datasavvy.wordpress.com/category/biml/) - [Nicholas Sorrell](http://sorrell.github.io/) - [Paul Te Braak](https://paultebraak.wordpress.com/tag/biml/) @@ -362,39 +530,10 @@ BIML Bloggers - [Reeves Smith](https://reevessmith.wordpress.com/category/biml/) - [Roelant Vos](http://roelantvos.com/blog/?tag=biml) - [Rui Custódio](http://www.bi4all.pt/taxonomy/term/75) -- [Samuel Vanga](http://samuelvanga.com/category/biml/) -- [Stephen Leach](http://www.imgroup.com/author/stephen-leach/) - [Tim Mitchell](https://www.timmitchell.net/post/tag/biml/) - [Warwick Rudd](http://www.sqlmastersconsulting.com.au/SQL-Server-Blog/PID/1675/mcat/1682/evl/0/nsw/t/EDNSearch/Biml) -[*Back to top*](#header020) - - -## SQL Server Sample Databases and Datasets -Alternative download link for some sample databases: http://bit.ly/ya-ssk - - - [AdventureWorks Sample Databases and Scripts for SQL Server 2017, 2016, 2014 , 2012](https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks) - - [Microsoft SQL Server 2008 R2 SR1 Sample Databases](https://sqlserversamples.codeplex.com/releases/view/72278) - - [Thinking Big (Adventure)](http://sqlblog.com/blogs/adam_machanic/archive/2011/10/17/thinking-big-adventure.aspx) (by Adam Machanic) - - [WideWorldImporters Sample Database](https://github.com/Microsoft/sql-server-samples/releases/tag/wide-world-importers-v1.0) (Github Microsoft) - - [IoT Smart Grid sample - demonstrates how SQL Server 2016 memory optimized databases could be used to ingest a very high input data rate](https://github.com/Microsoft/sql-server-samples/releases/tag/iot-smart-grid-v1.0) (Github Microsoft) - - [In-Memory OLTP (WWI Sales Orders)](https://github.com/Microsoft/sql-server-samples/releases/tag/wwi-sales-orders-v0.5) (Github Microsoft) - - [Bigger Fact Table for Wide World Importers](http://www.sqlservercentral.com/blogs/koen-verbeeck/2016/08/12/bigger-fact-table-for-wide-world-importers/) (by Koen Verbeeck) - - [Contoso Retail Data Warehose](https://github.com/Microsoft/sql-server-samples/tree/master/samples/databases/contoso-data-warehouse) (Github) - - [How to Download the Stack Overflow Database via BitTorrent 2016-03](https://www.brentozar.com/archive/2015/10/how-to-download-the-stack-overflow-database-via-bittorrent/) (by Brent Ozar) - - [Updating the Stack Overflow Demo Database version 2016-12-15](https://www.brentozar.com/archive/2017/01/updating-stack-overflow-demo-database/) - - [Stackexchange Source files - xml files](https://archive.org/download/stackexchange) - - [Amazon product data](http://jmcauley.ucsd.edu/data/amazon/) (This dataset contains product reviews and metadata from Amazon, including 142.8 million reviews spanning May 1996 - July 2014) - - [Git repo for SQL Server Reporting Services samples and community projects](https://github.com/Microsoft/Reporting-Services) - - [SQLSkills sample databases](https://www.sqlskills.com/sql-server-resources/sql-server-demos/) (also include SAMPLE CORRUPT DATABASES) - - [SQLIndexWorkbook Sample Database](http://www.littlekendra.com/downloads/get-the-sqlindexworkbook-database/) (by Little Kendra) - - [Data.gov](https://www.data.gov/) - - [Itzik Ben-Gan Sample Databases](http://tsql.solidq.com/books/source_code/) (by Itzik Ben-Gan) - - [Orders: Open Source Sample Database](https://www.brentozar.com/orders-open-source-sample-database/) (by Brent Ozar) - - [BabbyNames Database](https://github.com/LitKnd/BabbyNames) (by Kendra Little) - - [SQL Server Sakila DB](https://www.jooq.org/sakila) (by jOQO) - -[*Back to top*](#header03) +**[⬆ back to top](#table-of-contents)** ## PowerShell and SQL Server @@ -412,7 +551,6 @@ Alternative download link for some sample databases: http://bit.ly/ya-ssk - [PowerShell Blog NetNerds](https://blog.netnerds.net/) - [QS Config](http://www.sqlhammer.com/qs-config/) (by Derik Hammer) - [Idera 89 Free SQL Server PowerShell Scripts](https://www.idera.com/productssolutions/freetools/sqlpowershellscripts) - - [Performance Analysis of Logs (PAL) Tool](https://github.com/clinthuffman/PAL) (by Clint Huffman) - [Powershell SQL Server Library (PSSQLLib)](https://github.com/sanderstad/PSSQLLib) (by Sander Stad) (Github) - [Trello Board: Powershell and SQL Client Tools](https://trello.com/b/NEerYXUU/powershell-sql-client-tools-sqlps-ssms) - [PowerUpSQL: A PowerShell Toolkit for Attacking SQL Server](https://github.com/NetSPI/PowerUpSQL) (Github) @@ -421,72 +559,73 @@ Alternative download link for some sample databases: http://bit.ly/ya-ssk - [ReportingServicesTools - Reporting Services Powershell Tools](https://github.com/Microsoft/ReportingServicesTools) (by Microsoft) - [Powershell xSQLServer module contains DSC resources for deployment and configuration of SQL Server](https://github.com/PowerShell/xSQLServer) (Github by Microsoft) - [Export-DMVInformation - Export the resuts from Glenn Berry's DMV queries directly to Excel](https://github.com/sanderstad/Export-DMVInformation/) (Github) (by Sander Stad) + - [Export-QueryToSQLTable - Export one or more query results run against one or more instances/databases to table](https://github.com/SQLJana/Export-QueryToSQLTable) (by Jana Sattainathan) (Github) + - [PowerBIETL - a developer tool to quickly load a SQL Database using PowerBIDesktop queries](https://www.powershellgallery.com/packages/PowerBIETL/) (by DevScope) -[*Back to top*](#header05) +**[⬆ back to top](#table-of-contents)** ## TSQL Format Code - - http://sqlinform.com/ - - http://www.dpriver.com/pp/sqlformat.htm - - http://stackoverflow.com/questions/401928/sql-formatter-for-sql-management-studio - - http://www.apexsql.com/sql_tools_refactor.aspx + - [SQLinform Online Web](https://sqlinform.azurewebsites.net) + - [SQLinform Online Utility](https://www.sqlinform.com) + - [Instant SQL Formatter](http://www.dpriver.com/pp/sqlformat.htm) - http://poorsql.com/ - http://www.architectshack.com/PoorMansTSqlFormatter.ashx - http://www.ssmstoolspack.com/ - http://www.devart.com/dbforge/sql/sqlcomplete/ - - http://www.sql-format.com/ + - http://www.apexsql.com/sql_tools_refactor.aspx + - http://stackoverflow.com/questions/401928/sql-formatter-for-sql-management-studio -[*Back to top*](#header06) +**[⬆ back to top](#table-of-contents)** ## SQL Server Test Data Generation - https://www.simple-talk.com/sql/t-sql-programming/generating-test-data-in-tsql/ - - http://www.yandataellan.com/ + - http://www.convertcsv.com/generate-test-data.htm - https://github.com/benkeen/generatedata - https://sourceforge.net/projects/dbmonster/ - https://sourceforge.net/projects/spawner/ - - http://databene.org/databene-benerator - - http://stackoverflow.com/questions/591892/tools-for-generating-mock-data + - [Tools for Generating Mock Data](https://stackoverflow.com/q/591892) + - https://mockaroo.com + - https://anonymize.strd.co/ -[*Back to top*](#header07) +**[⬆ back to top](#table-of-contents)** -## Free SQL Server, R ebooks - +## Free SQL Server and R ebooks SQL Server: - - [Awesome Red Gate ebooks](http://www.red-gate.com/community/books/) + - [Awesome Red Gate ebooks](https://www.red-gate.com/hub/books/) - SQL Developers - - [Defensive Database Programming](http://assets.red-gate.com/community/books/defensive-database-programming.pdf) (by Alex Kuznetsov) - - [Inside the SQL Server Query Optimizer](http://assets.red-gate.com/community/books/inside-the-sql-server-query-optimizer.pdf) (by Benjamin Nevarez) - - [SQL Server Execution Plans, 2nd Edition](http://assets.red-gate.com/community/books/sql-server-execution-plans-book.zip) (by Grant Fritchey) - - [SQL Server Source Control Basics](http://www.red-gate.com/products/sql-development/sql-source-control/entrypage/sql-server-source-control-basics) (by Robert Sheldon, Rob Richardson & Tony Davis) - - [The Art of XSD](http://assets.red-gate.com/community/books/the-art-of-xsd.pdf) (by Jacob Sebastian) - - [The Redgate Guide to SQL Server Team-based Development](http://assets.red-gate.com/products/sql-development/sql-source-control/entrypage/assets/RG_Guide_to_SQL_Server_Dev.pdf) (by Phil Factor, Grant Fritchey, Alex Kuznetsov, and Mladen Prajdić) + - [Defensive Database Programming](https://assets.red-gate.com/community/books/defensive-database-programming.pdf) (by Alex Kuznetsov) + - [Inside the SQL Server Query Optimizer](https://assets.red-gate.com/community/books/inside-the-sql-server-query-optimizer.pdf) (by Benjamin Nevarez) + - [SQL Server Execution Plans, 3rd Edition](https://www.red-gate.com/products/dba/sql-monitor/entrypage/execution-plans) (by Grant Fritchey) + - [SQL Server Source Control Basics](https://www.red-gate.com/products/sql-development/sql-source-control/entrypage/sql-server-source-control-basics) (by Robert Sheldon, Rob Richardson & Tony Davis) + - [The Art of XSD](https://assets.red-gate.com/community/books/the-art-of-xsd.pdf) (by Jacob Sebastian) + - [The Redgate Guide to SQL Server Team-based Development](https://assets.red-gate.com/products/sql-development/sql-source-control/entrypage/assets/RG_Guide_to_SQL_Server_Dev.pdf) (by Phil Factor, Grant Fritchey, Alex Kuznetsov, and Mladen Prajdić) - [XML Stairway](https://assets.red-gate.com/simple-talk/stairway-to-xml.pdf) - - [119 SQL Code Smells](http://assets.red-gate.com/community/books/sql-code-smells.pdf) + - [119 SQL Code Smells](https://assets.red-gate.com/community/books/sql-code-smells.pdf) + - [High Performance Techniques for SQL Server](https://www.sentryone.com/sql-server-books) (by SentryOne) - SQL DBA - - [SQL Server Internals: In-Memory OLTP](http://www.red-gate.com/library/sql-server-internals-in-memory-oltp) (by Kalen Delaney) - - [Fundamentals Of SQL Server 2012 Replication](http://assets.red-gate.com/community/books/fundamentals-of-sql-server-2012-replication.pdf) (by Sebastian Meine) - - [Tribal SQL](http://www.red-gate.com/library/tribal-sql) - - [SQL Server Transaction Log Management](http://assets.red-gate.com/offerings/transaction-log-management.pdf) (by Tony Davis and Gail Shaw) - - [The Art of SQL Server FILESTREAM](http://assets.red-gate.com/community/books/art-of-ss-filestream.pdf) (by Jacob Sebastian and Sven Aelterman) - - [SQL Server Concurrency: Locking, Blocking and Row Versioning](http://www.red-gate.com/library/sql-server-concurrency-locking-blocking-and-row-versioning) (by Kalen Delaney) - - [SQL Server Backup and Restore](http://assets.red-gate.com/community/books/sql-server-backup-and-restore.pdf) (by Shawn McGehee) - - [Troubleshooting SQL Server: A Guide for the Accidental DBA](http://assets.red-gate.com/products/dba/assets/Accidental_DBA_EBook.zip) (by Jonathan Kehayias and Ted Krueger ) + - [SQL Server Internals: In-Memory OLTP](https://www.red-gate.com/library/sql-server-internals-in-memory-oltp) (by Kalen Delaney) + - [Fundamentals Of SQL Server 2012 Replication](https://assets.red-gate.com/community/books/fundamentals-of-sql-server-2012-replication.pdf) (by Sebastian Meine) + - [Tribal SQL](https://www.red-gate.com/library/tribal-sql) + - [SQL Server Transaction Log Management](https://www.red-gate.com/library/sql-server-transaction-log-management) (by Tony Davis and Gail Shaw) + - [The Art of SQL Server FILESTREAM](https://assets.red-gate.com/community/books/art-of-ss-filestream.pdf) (by Jacob Sebastian and Sven Aelterman) + - [SQL Server Concurrency: Locking, Blocking and Row Versioning](https://www.red-gate.com/library/sql-server-concurrency-locking-blocking-and-row-versioning) (by Kalen Delaney) + - [SQL Server Backup and Restore](https://assets.red-gate.com/community/books/sql-server-backup-and-restore.pdf) (by Shawn McGehee) + - [Troubleshooting SQL Server: A Guide for the Accidental DBA](https://www.red-gate.com/library/troubleshooting-sql-server-a-guide-for-accidental-dbas) (by Jonathan Kehayias and Ted Krueger ) - [SQL Server Hardware](http://assets.red-gate.com/community/books/sql-server-hardware-ebook.pdf) (by Glen Berry) - [Microsoft huge collection](https://blogs.msdn.microsoft.com/mssmallbiz/2013/06/18/huge-collection-of-free-microsoft-ebooks-for-you-including-office-office-365-sharepoint-sql-server-system-center-visual-studio-web-development-windows-windows-azure-and-windows-server/) - [Microsoft large collection](https://blogs.msdn.microsoft.com/mssmallbiz/2012/07/27/large-collection-of-free-microsoft-ebooks-for-you-including-sharepoint-visual-studio-windows-phone-windows-8-office-365-office-2010-sql-server-2012-azure-and-more/) - [Largest FREE Microsoft eBook Giveaway!](https://blogs.msdn.microsoft.com/mssmallbiz/2017/07/11/largest-free-microsoft-ebook-giveaway-im-giving-away-millions-of-free-microsoft-ebooks-again-including-windows-10-office-365-office-2016-power-bi-azure-windows-8-1-office-2013-sharepo/) - - [Microsoft MVA Free ebooks](https://mva.microsoft.com/ebooks) - [OnlineVideoLectures ebooks](http://onlinevideolecture.com/ebooks/?subject=SQL-Server) - - [Brent Ozar ebooks](http://www.brentozar.com/first-aid/free-database-books-pdfs-download/) + - [Brent Ozar ebooks](https://www.brentozar.com/first-aid/) - [E-books SQL Server Directory](http://www.e-booksdirectory.com/listing.php?category=569) - - [TOAD SQL Server ebooks](https://www.toadworld.com/platforms/sql-server/b/weblog/archive/2013/06/21/huge-collection-of-free-microsoft-sql-server-ebooks) - [Syncfusion Techportal](http://syncfusion.com/resources/techportal) - [Modern Storage Strategies for SQL Server](http://www.actualtech.io/gg-modern-storage/) - [Migrating SQL Server Databases to Azure](https://blogs.msdn.microsoft.com/microsoft_press/2016/05/11/free-ebook-microsoft-azure-essentials-migrating-sql-server-databases-to-azure/) - - [SQL Sentry Free eBooks](https://www.sqlsentry.com/sql-server-books) + - [SentryOne Free eBooks](https://www.sentryone.com/resources#filter=.ebook) - [Microsoft Cloud Security for Enterprise Architects (PDF)](http://download.microsoft.com/download/6/d/f/6dfd7614-bbcf-4572-a871-e446b8cf5d79/msft_cloud_architecture_security.pdf) - [Brent Ozar SQL Server Setup Checklist eBook](http://u.brentozar.com/eBook_SQL_Server_Setup_Checklist.pdf) - [Introducing Microsoft SQL Server 2016](https://info.microsoft.com/Introducing-SQL-Server-2016-eBook.html) @@ -495,7 +634,16 @@ SQL Server: - [Power BI from Rookie to Rock Star book](http://radacad.com/download-free-power-bi-book-pdf-format) (by Reza Rad) - [Online Book: Analytics with Power BI and R](http://radacad.com/online-book-analytics-with-power-bi-and-r) (by Leila Etaati) - [Architecture of a Database System](http://db.cs.berkeley.edu/papers/fntdb07-architecture.pdf) (by Joseph M. Hellerstein, Michael Stonebraker and James Hamilton) - + - [Query Optimization with SentryOne Plan Explorer](https://info.sentryone.com/ebook-query-optimization-plan-explorer) + - [Troubleshooting SQL Server Performance](https://info.sentryone.com/ebook-troubleshooting-sql-server-performance) (by Kevin Kline) + - [Azure Machine Learning Studio: An Unleashed Guide](http://radacad.com/book-azure-machine-learning-studio-an-unleashed-guide) (by Leila Etaati) + - [Nutanix Best Practices for SQL Server 2016](https://www.nutanix.com/viewer.html?type=pdf&lpurl=virtualize-microsoft-sql-server-hyperconverged-infrastructure.php&fromCampaign=true) (by Nutanix, Inc.) + - [Cloud Analytics with Microsoft Azure](https://azure.microsoft.com/en-us/resources/cloud-analytics-with-microsoft-azure/) (by Has Altaiar, Jack Lee, Michael Peña) + - [Snowflake for SQL Server Users Part 1 – Core Concepts](https://sqldownunder.blob.core.windows.net/public/SnowflakeForSQLServerUsers_Part_1_CoreConcepts%20-%20for%20SDU%20Insiders.pdf) (by Dr Greg Low) + - [The Fundamental Guide To Sql Query Optimization](https://www.quest.com/whitepapert/the-fundamental-guide-to-sql-query-optimization8143740/) (by Janis Griffin) + - [An Expert Guide To Sql Server Performance Tuning](https://www.quest.com/whitepaper/an-expert-guide-to-sql-server-performance-tuning8143874/) (by Brent Ozar, Pinal Dave, Janis Griffin) + - [Microsoft® SQL Server® Notes for Professionals book](https://books.goalkicker.com/MicrosoftSQLServerBook/) (by GoalKicker Books) + R: - [BookDown - Write HTML, PDF, ePub, and Kindle books with R Markdown](https://bookdown.org) - [FreeComputerBooks R EBooks](http://freecomputerbooks.com/langRBooks.html) @@ -506,13 +654,29 @@ R: - [Text Mining with R](http://tidytextmining.com/) (by Julia Silge and David Robinson) - [An Introduction to Statistical Learning with Applications in R](http://www-bcf.usc.edu/~gareth/ISL/) (by Gareth James, Daniela Witten, Trevor Hastie and Robert Tibshirani) -[*Back to top*](#header08) +**[⬆ back to top](#table-of-contents)** + + + +## SQL Server Paid Books +- [T-SQL Fundamentals](https://amzn.to/39CLxSN) 361 pages (by Itzik Ben-Gan) +- [T-SQL Querying (Developer Reference)](https://amzn.to/3bGxVIa) 803 pages (by Itzik Ben-Gan) +- [Great Post, Erik](https://amzn.to/3bMtgUY) 342 pages (by Erik Darling) +- [Learn T-SQL Querying](https://amzn.to/39Ia7BX) 450 pages (by Pedro Lopes, Pam Lahoud) +- [SQL Server 2017 Query Performance Tuning](https://amzn.to/2UW3s2E) 823 pages (by Grant Fritchey) +- [Query Store for SQL Server 2019](https://amzn.to/2OZAzPp) 236 pages (by Tracy Boggiano, Grant Fritchey) +- [SQL Server 2019 Revealed](https://amzn.to/2OZSiWS) 444 pages (by Bob Ward) +- [Pro SQL Server Internals](https://www.amazon.co.uk/dp/1484219635/) 840 pages (by Dmitri Korotkevitch) +- [Pro SQL Server Always On Availability Groups](https://www.amazon.co.uk/dp/B01M3U6WRM/) 332 pages (by Uttam Parui, Vivek Sanil) +- [Refactoring Legacy T-SQL for Improved Performance: Modern Practices for SQL Server](https://www.amazon.co.uk/dp/1484255801/) 260 pages (by Lisa Bohm) +- [Hands-On SQL Server 2019 Analysis Services](https://www.packtpub.com/product/hands-on-sql-server-2019-analysis-services/9781800204768) (by Steve Hughes) + + +**[⬆ back to top](#table-of-contents)** ## License -[MIT](/LICENSE.md) +[MIT](/LICENSE) -If some procedures or scripts are restricted due to **ELUA** (or we can not find original author), please email or add issue - we remove/update it immediately. +If some procedures or scripts are restricted due to **ELUA** (or we can not find original author), please email us or add issue - we remove/update it immediately. Thanks for understanding and patience. - - diff --git a/SQL Server DBCC List.md b/SQL Server DBCC List.md index c3933df7..b94d2541 100644 --- a/SQL Server DBCC List.md +++ b/SQL Server DBCC List.md @@ -227,7 +227,7 @@ DBCC setioweight (weight) DBCC show_statistics ('table_name', 'target_name') -DBCC showcontig (table_id | table_name [, index_id | index_name] [WITH FAST, ALL_INDEXES, TABLERESULTS [,ALL_LEVELS]]) +DBCC showcontig (table_id | table_name [, index_id | index_name] [WITH FAST, ALL_INDEXES, TABLERESULTS [,ALL_LEVELS]]) -- https://www.sqlskills.com/blogs/paul/the-curious-case-of-extent-scan-fragmentation/ DBCC showdbaffinity diff --git a/SQL Server Data Types.md b/SQL Server Data Types.md index a7a98baf..b2b3a3ed 100644 --- a/SQL Server Data Types.md +++ b/SQL Server Data Types.md @@ -1,31 +1,15 @@ # Microsoft SQL Server Data Types -Complete list of all Microsoft SQL Server Data Types - -Headers: - - [Source link](#source-link) - - [Data Type Precedence (Transact-SQL)](#data-type-precedence) - - [Data Type Synonyms (Transact-SQL)](#data-type-synonyms) - - [Precision, Scale, and Length (Transact-SQL)](#precision-scale-and-length) - - [SQL Server, SSIS and Biml Data Types](#sql-server-ssis-and-biml-data-types) - - [SQL Server Data Types Length](#sql-server-data-types-length) - - [SQL Server to MySQL, Oracle, PostgreSQL and SQLite Data Type Mapping](#sql-server-to-mysql-oracle-postgresql-sqlite) - - -## Source link - - - [MSDN Data Types](https://msdn.microsoft.com/en-us/library/ms187752.aspx) - - [MSDN Data Type Precedence](https://msdn.microsoft.com/en-us/library/ms190309.aspx) - - [MSDN Data Type Synonyms](https://msdn.microsoft.com/en-us/library/ms177566.aspx) - - [MSDN Precision, Scale, and Length](https://msdn.microsoft.com/en-us/library/ms190476.aspx) - - [Integration Services Data Types](https://msdn.microsoft.com/en-us/library/ms141036.aspx) - - [DbType Enumeration](https://msdn.microsoft.com/en-us/library/System.Data.DbType.aspx) - - [SQL Server, SSIS and Biml Data Types](http://www.cathrinewilhelmsen.net/2014/05/27/sql-server-ssis-and-biml-data-types/) - - [SQL Server Integration Services, Data Type Mapping](http://milambda.blogspot.ru/2014/02/sql-server-integration-services-data.html) - - [SQL Server Data Type Conversion](https://msdn.microsoft.com/en-us/library/ms191530.aspx) - - [SQL Server to MySQL Data Type Conversion](https://convertdb.com/mysql_mssql_mapping) - - [SQL Server to Oracle Data Type Conversion](https://docs.oracle.com/cd/B19306_01/gateways.102/b14270/apa.htm) - - [SQL Server to PostgreSQL Data Type Conversion](http://www.sqlines.com/sql-server-to-postgresql) - - [SQL Server to SQLite Data Type Conversion](http://ericsink.com/mssql_mobile/data_types.html) +Detailed information about Microsoft SQL Server Data Types and its mapping to another databases and program languages analog. + +## Table of Contents: +- [Data Type Precedence (Transact-SQL)](#data-type-precedence) +- [Data Type Synonyms (Transact-SQL)](#data-type-synonyms) +- [Precision, Scale, and Length (Transact-SQL)](#precision-scale-and-length) +- [SQL Server, SSIS and Biml Data Types](#sql-server-ssis-and-biml-data-types) +- [SQL Server Data Types Length](#sql-server-data-types-length) +- [SQL Server to MySQL, Oracle, PostgreSQL and SQLite Data Type Mapping](#sql-server-to-mysql-oracle-postgresql-sqlite) +- [SQL Server Data Types Mapping to Program Languages](#sql-server-data-types-mapping-to-program-languages) +- [Source links](#source-links) ## Data Type Precedence (Transact-SQL) @@ -35,35 +19,37 @@ If the conversion is not a supported implicit conversion, an error is returned. When both operand expressions have the same data type, the result of the operation has that data type. SQL Server uses the following precedence order for data types: - 1. sql_variant - 2. xml - 3. datetimeoffset - 4. datetime2 - 5. datetime - 6. smalldatetime - 7. date - 8. time - 9. float - 10. real - 11. decimal - 12. money - 13. smallmoney - 14. bigint - 15. int - 16. smallint - 17. tinyint - 18. bit - 19. ntext - 20. text - 21. image - 22. timestamp - 23. uniqueidentifier - 24. nvarchar (including nvarchar(max) ) - 25. nchar - 26. varchar (including varchar(max) ) - 27. char - 28. varbinary (including varbinary(max) ) - 29. binary (lowest) +1. [sql_variant] (**highest**) +2. [xml] +3. [datetimeoffset] +4. [datetime2] +5. [datetime] +6. [smalldatetime] +7. [date] +8. [time] +9. [float][4] +10. [real][4] +11. [decimal][2] +12. [money][3] +13. [smallmoney][3] +14. [bigint][1] +15. [int][1] +16. [smallint][1] +17. [tinyint][1] +18. [bit] +19. [ntext][7] +20. [text][7] +21. [image][7] +22. [timestamp] +23. [uniqueidentifier] +24. [nvarchar][5] (including [nvarchar(max)][5]) +25. [nchar][5] +26. [varchar][5] (including [varchar(max)][5]) +27. [char][5] +28. [varbinary][8] (including [varbinary(max)][8]) +29. [binary][8] (**lowest**) + +**[⬆ back to top](#table-of-contents)** ## Data Type Synonyms (Transact-SQL) @@ -71,31 +57,33 @@ SQL Server uses the following precedence order for data types: Data type synonyms are included in SQL Server for ISO compatibility. The following table lists the synonyms and the SQL Server system data types that they map to. -| Synonym | SQL Server system data type | -|-------------------------------|-----------------------------| -| Binary varying | varbinary | -| char varying | varchar | -| character | char | -| character | char(1) | -| character(n) | char(n) | -| character varying(n) | varchar(n) | -| Dec | decimal | -| Double precision | float | -| float[(n)] for n = 1-7 | real | -| float[(n)] for n = 8-15 | float | -| integer | int | -| national character(n) | nchar(n) | -| national char(n) | nchar(n) | -| national character varying(n) | nvarchar(n) | -| national char varying(n) | nvarchar(n) | -| national text | ntext | -| timestamp | rowversion | +| Synonym | System data type | +|-------------------------------|------------------| +| Binary varying | varbinary | +| char varying | varchar | +| character | char | +| character | char(1) | +| character(n) | char(n) | +| character varying(n) | varchar(n) | +| Dec | decimal | +| Double precision | float | +| float[(n)] for n = 1-7 | real | +| float[(n)] for n = 8-15 | float | +| integer | int | +| national character(n) | nchar(n) | +| national char(n) | nchar(n) | +| national character varying(n) | nvarchar(n) | +| national char varying(n) | nvarchar(n) | +| national text | ntext | +| timestamp | rowversion | Data type synonyms can be used instead of the corresponding base data type name in data definition language (DDL) statements, such as CREATE TABLE, CREATE PROCEDURE, or DECLARE @variable. However, after the object is created, the synonyms have no visibility. When the object is created, the object is assigned the base data type that is associated with the synonym. There is no record that the synonym was specified in the statement that created the object. +**[⬆ back to top](#table-of-contents)** + ## Precision, Scale, and Length (Transact-SQL) @@ -130,6 +118,8 @@ The operand expressions are denoted as expression e1, with precision p1 and scal \* The result precision and scale have an absolute maximum of 38. When a result precision is greater than 38, the corresponding scale is reduced to prevent the integral part of a result from being truncated. +**[⬆ back to top](#table-of-contents)** + ## SQL Server, SSIS and Biml Data Types @@ -138,171 +128,296 @@ The table does not include all possible mappings or all data types, but is meant | SQL Server | SSIS Variables | SSIS Pipeline Buffer | OLE DB | ADO.NET | Biml | |--------------------|----------------|----------------------|-------------------|-------------------|-----------------------| -| [bigint] | Int64 | DT_I8 | LARGE_INTEGER | Int64 | Int64 | -| [binary] | Object | DT_BYTES | - | Binary | Binary | +| [bigint][1] | Int64 | DT_I8 | LARGE_INTEGER | Int64 | Int64 | +| [binary][8] | Object | DT_BYTES | - | Binary | Binary | | [bit] | Boolean | DT_BOOL | VARIANT_BOOL | Boolean | Boolean | -| [char] | String | DT_STR | VARCHAR | StringFixedLength | AnsiStringFixedLength | +| [char][5] | String | DT_STR | VARCHAR | StringFixedLength | AnsiStringFixedLength | | [date] | Object | DT_DBDATE | DBDATE | Date | Date | | [datetime] | DateTime | DT_DBTIMESTAMP | DATE | DateTime | DateTime | | [datetime2] | Object | DT_DBTIMESTAMP2 | DBTIME2 | DateTime2 | DateTime2 | | [datetimeoffset] | Object | DT_DBTIMESTAMPOFFSET | DBTIMESTAMPOFFSET | DateTimeOffset | DateTimeOffset | -| [decimal] | Decimal | DT_NUMERIC | NUMERIC | Decimal | Decimal | -| [float] | Double | DT_R8 | FLOAT | Double | Double | +| [decimal][2] | Decimal | DT_NUMERIC | NUMERIC | Decimal | Decimal | +| [float][4] | Double | DT_R8 | FLOAT | Double | Double | | [geography] | - | DT_IMAGE | - | Object | Object | | [geometry] | - | DT_IMAGE | - | Object | Object | | [hierarchyid] | - | DT_BYTES | - | Object | Object | -| [image] (*) | Object | DT_IMAGE | - | Binary | Binary | -| [int] | Int32 | DT_I4 | LONG | Int32 | Int32 | -| [money] | Object | DT_CY, DT_NUMERIC | CURRENCY | Currency | Currency | -| [nchar] | String | DT_WSTR | NVARCHAR | StringFixedLength | StringFixedLength | -| [ntext] (*) | String | DT_NTEXT | - | String | String | -| [numeric] | Decimal | DT_NUMERIC | NUMERIC | Decimal | Decimal | -| [nvarchar] | String | DT_WSTR | NVARCHAR | String | String | -| [nvarchar](max) | Object | DT_NTEXT | - | - | String | -| [real] | Single | DT_R4 | FLOAT, DOUBLE | Single | Single | +| [image][7] (*) | Object | DT_IMAGE | - | Binary | Binary | +| [int][1] | Int32 | DT_I4 | LONG | Int32 | Int32 | +| [money][3] | Object | DT_CY, DT_NUMERIC | CURRENCY | Currency | Currency | +| [nchar][5] | String | DT_WSTR | NVARCHAR | StringFixedLength | StringFixedLength | +| [ntext][7] (*) | String | DT_NTEXT | - | String | String | +| [numeric][2] | Decimal | DT_NUMERIC | NUMERIC | Decimal | Decimal | +| [nvarchar][5] | String | DT_WSTR | NVARCHAR | String | String | +| [nvarchar(max)][5] | Object | DT_NTEXT | - | - | String | +| [real][4] | Single | DT_R4 | FLOAT, DOUBLE | Single | Single | | [rowversion] | Object | DT_BYTES | - | Binary | Binary | | [smalldatetime] | DateTime | DT_DBTIMESTAMP | DATE | DateTime | DateTime | -| [smallint] | Int16 | DT_I2 | SHORT | Int16 | Int16 | -| [smallmoney] | Object | DT_CY, DT_NUMERIC | CURRENCY | Currency | Currency | +| [smallint][1] | Int16 | DT_I2 | SHORT | Int16 | Int16 | +| [smallmoney][3] | Object | DT_CY, DT_NUMERIC | CURRENCY | Currency | Currency | | [sql_variant] | Object | DT_WSTR, DT_NTEXT | - | Object | Object | | [table] | Object | - | - | - | - | -| [text] (*) | Object | DT_TEXT | - | - | AnsiString | +| [text][7] (*) | Object | DT_TEXT | - | - | AnsiString | | [time] | Object | DT_DBTIME2 | DBTIME2 | Time | Time | | [timestamp] (*) | Object | DT_BYTES | - | Binary | Binary | -| [tinyint] | Byte | DT_UI1 | BYTE | Byte | Byte | +| [tinyint][1] | Byte | DT_UI1 | BYTE | Byte | Byte | | [uniqueidentifier] | String, Object | DT_GUID | GUID | Guid | Guid | -| [varbinary] | Object | DT_BYTES | - | Binary | Binary | -| [varbinary](max) | Object | DT_IMAGE | - | Binary | Binary | -| [varchar] | String | DT_STR | VARCHAR | String | AnsiString | -| [varchar](max) | Object | DT_TEXT | - | - | AnsiString | +| [varbinary][8] | Object | DT_BYTES | - | Binary | Binary | +| [varbinary(max)][8]| Object | DT_IMAGE | - | Binary | Binary | +| [varchar][5] | String | DT_STR | VARCHAR | String | AnsiString | +| [varchar(max)][5] | Object | DT_TEXT | - | - | AnsiString | | [xml] | Object | DT_NTEXT | - | - | Xml | (\* *These data types will be removed in a future version of SQL Server. Avoid using these data types in new projects, and try to change them in current projects*) +**[⬆ back to top](#table-of-contents)** + ## SQL Server Data Types Length -| General Type | Type | N value | Precision | Storage size, bytes | Range (in SQL Server) | -|----------------------|--------------------|----------------|-----------------------------------|----------------------:|------------------------------------------------------------------------------------------------------------------------------------------------| -| Exact Numerics | [bit] | | | 1 | 1, 0 | -| Exact Numerics | [tinyint] | | | 1 | 0 to 255 | -| Exact Numerics | [smallint] | | | 2 | -2^15(-32768) to 2^15(32767) | -| Exact Numerics | [int] | | | 4 | -2^31(-2 147 483 648) to (2^31(2 147 483 647) | -| Exact Numerics | [bigint] | | | 8 | -2^63(-9 233 372 036 854 775 808) to 2^63(9 233 372 036 854 775 807) | -| Exact Numerics | [decimal] | | 1-9
10-19
20-28
29-38 | 5
9
13
17 | from -10^38 +1 through 10^38 -1 | -| Exact Numerics | [smallmoney] | | | 4 | -214 748.3648 to 214 748.3647 | -| Exact Numerics | [money] | | | 8 | -922 337 203 685 477.5808 to 922 337 203 685 477.5807 | -| Approximate Numerics | [float] | 1-24
25-53 | 7
15 | 4
8 | -3.40E+38 to -1.18E-38, 0 and 1.18E-38 to 3.40E+38
-1.79E+308 to -2.23E-308, 0 and 2.23E-308 to 1.79E+308 | -| Date and Time | [date] | | | 3 | 0001-01-01 through 9999-12-31
January 1, 1 CE through December 31, 9999 CE | -| Date and Time | [smalldatetime] | | | 4 | 1900-01-01 through 2079-06-06
January 1, 1900 through June 6, 2079
00:00:00 through 23:59:59 | -| Date and Time | [time] | | 8-11
12-13
14-16 | 3
4
5 | 00:00:00.0000000 through 23:59:59.9999999 | -| Date and Time | [datetime2] | | 1-2
3-4
5-7 | 6
7
8 | 0001-01-01 through 9999-12-31
January 1, 1 CE through December 31, 9999 CE
00:00:00 through 23:59:59.9999999 | -| Date and Time | [datetime] | | | 8 | anuary 1, 1753 through December 31, 9999
00:00:00 through 23:59:59.997 | -| Date and time | [datetimeoffset] | | 26-29
30-34 | 8
10 | 0001-01-01 through 9999-12-31
January 1, 1 CE through December 31, 9999 CE
00:00:00 through 23:59:59.9999999
-14:00 throuth +14:00 | -| Caracter Strings | [char] | 1-8000 | | n | | -| Caracter Strings | [varchar] | 1-8000 | | n + 2 | | -| Caracter Strings | [varchar](max) | 1-(2^31 - 1) | | 2^31 - 1 + 2 | | -| Caracter Strings | [nchar] | 1-4000 | | | | -| Caracter Strings | [nvarchar] | 1-4000 | | | | -| Caracter Strings | [nvarchar](max) | 1-(2^31 - 1) | | | | -| Caracter Strings | [ntext](*) | 1-(2^30 - 1) | | n + n | | -| Caracter Strings | [text](*) | 1-(2^31 - 1) | | | | -| Binary Strings | [image](*) | 1-(2^31 - 1) | | n | | -| Binary Strings | [binary] | 1-8000 | | n | | -| Binary Strings | [varbinary] | 1-8000 | | n | | -| Binary Strings | [varbinary](max) | 1-(2^31 - 1) | | n + 2 | | -| Other Data Types | [cursor] | | | | | -| Other Data Types | [sql_variant] | | | max 8016 | | -| Other Data Types | [hierarchyid] | | | max 892 | | -| Other Data Types | [rowversion] | | | 8 | | -| Other Data Types | [timestamp](*) | | | | | -| Other Data Types | [uniqueidentifier] | | | 16 | | -| Other Data Types | [xml] | | | max 2Gb | | -| Other Data Types | [table] | | | | | -| Spatial Data Types | [geometry] | | | | | -| Spatial Data Types | [geography] | | | | | +| General Type | Type | N value | Precision | Storage size, bytes | Range (in SQL Server) | +|-----------------------|--------------------|----------------|-----------------------------------|----------------------:|------------------------------------------------------------------------------------------------------------------------------------------------| +| Exact Numerics | [bit] | | | 1 | 1, 0 | +| Exact Numerics | [tinyint][1] | | | 1 | 0 to 255 | +| Exact Numerics | [smallint][1] | | | 2 | -2^15(-32768) to 2^15(32767) | +| Exact Numerics | [int][1] | | | 4 | -2^31(-2 147 483 648) to 2^31(2 147 483 647) | +| Exact Numerics | [bigint][1] | | | 8 | -2^63(-9 233 372 036 854 775 808) to 2^63(9 233 372 036 854 775 807) | +| Exact Numerics | [decimal][2] | | 1-9
10-19
20-28
29-38 | 5
9
13
17 | from -10^38 +1 through 10^38 -1 | +| Exact Numerics | [smallmoney][3] | | | 4 | -214 748.3648 to 214 748.3647 | +| Exact Numerics | [money][3] | | | 8 | -922 337 203 685 477.5808 to 922 337 203 685 477.5807 | +| Approximate Numerics | [float][4] | 1-24
25-53 | 7
15 | 4
8 | -3.40E+38 to -1.18E-38, 0 and 1.18E-38 to 3.40E+38
-1.79E+308 to -2.23E-308, 0 and 2.23E-308 to 1.79E+308 | +| Date and Time | [date] | | | 3 | 0001-01-01 through 9999-12-31
January 1, 1 CE through December 31, 9999 CE | +| Date and Time | [smalldatetime] | | | 4 | 1900-01-01 through 2079-06-06
January 1, 1900 through June 6, 2079
00:00:00 through 23:59:59 | +| Date and Time | [time] | | 8-11
12-13
14-16 | 3
4
5 | 00:00:00.0000000 through 23:59:59.9999999 | +| Date and Time | [datetime2] | | 1-2
3-4
5-7 | 6
7
8 | 0001-01-01 through 9999-12-31
January 1, 1 CE through December 31, 9999 CE
00:00:00 through 23:59:59.9999999 | +| Date and Time | [datetime] | | | 8 | anuary 1, 1753 through December 31, 9999
00:00:00 through 23:59:59.997 | +| Date and time | [datetimeoffset] | | 26-29
30-34 | 8
10 | 0001-01-01 through 9999-12-31
January 1, 1 CE through December 31, 9999 CE
00:00:00 through 23:59:59.9999999
-14:00 throuth +14:00 | +| Character Strings | [char][5] | 1-8000 | | n | | +| Character Strings | [varchar][5] | 1-8000 | | n + 2 | | +| Character Strings | [varchar(max)][5] | 1-(2^31 - 1) | | 2^31 - 1 + 2 | | +| Character Strings | [nchar][5] | 1-4000 | | | | +| Character Strings | [nvarchar][5] | 1-4000 | | | | +| Character Strings | [nvarchar(max)][5] | 1-(2^31 - 1) | | | | +| Character Strings | [ntext][7] (*) | 1-(2^30 - 1) | | n + n | | +| Character Strings | [text][7] (*) | 1-(2^31 - 1) | | | | +| Binary Strings | [image][7] (*) | 1-(2^31 - 1) | | n | | +| Binary Strings | [binary][8] | 1-8000 | | n | | +| Binary Strings | [varbinary][8] | 1-8000 | | n | | +| Binary Strings | [varbinary(max)][8]| 1-(2^31 - 1) | | n + 2 | | +| Other Data Types | [cursor] | | | | | +| Other Data Types | [sql_variant] | | | max 8016 | | +| Other Data Types | [hierarchyid] | | | max 892 | | +| Other Data Types | [rowversion] | | | 8 | | +| Other Data Types | [timestamp] (*) | | | | | +| Other Data Types | [uniqueidentifier] | | | 16 | | +| Other Data Types | [xml] | | | max 2Gb | | +| Other Data Types | [table] | | | | | +| Spatial Data Types | [geometry] | | | | | +| Spatial Data Types | [geography] | | | | | +(\* *These data types will be removed in a future version of SQL Server. Avoid using these data types in new projects, and try to change them in current projects*) + +**[⬆ back to top](#table-of-contents)** ## SQL Server to MySQL, Oracle, PostgreSQL, SQLite Data Type Mapping -| General Type | Type | MySQL | Oracle | PostgreSQL | SQLite | -|----------------------|--------------------|----------------------------------------------------------------|---------------|-----------------------------|--------:| -| Exact Numerics | [bit] | TINYINT(1) | NUMBER(3) | BOOLEAN | INTEGER | -| Exact Numerics | [tinyint] | TINYINT(signed) | NUMBER(3) | SMALLINT | INTEGER | -| Exact Numerics | [smallint] | SMALLINT | NUMBER(5) | SMALLINT | INTEGER | -| Exact Numerics | [int] | MEDIUMINT, INT | NUMBER(10) | INT | INTEGER | -| Exact Numerics | [bigint] | BIGINT | NUMBER(19) | BIGINT | INTEGER | -| Exact Numerics | [decimal] | DECIMAL | NUMBER(p[,s]) | DECIMAL(p,s) | REAL | -| Exact Numerics | [smallmoney] | DOUBLE | NUMBER(10,4) | MONEY | REAL | -| Exact Numerics | [money] | DOUBLE | NUMBER(19,4) | MONEY | REAL | -| Approximate Numerics | [float] | FLOAT
DOUBLE; REAL | FLOAT(49) | DOUBLE PRECISION | REAL | -| Date and Time | [date] | DATE | | DATE | TEXT | -| Date and Time | [smalldatetime] | TIMESTAMP | DATE | TIMESTAMP(0) | TEXT | -| Date and Time | [time] | TIME | | TIME | TEXT | -| Date and Time | [datetime2] | DDATETIME | | TIMESTAMP | TEXT | -| Date and Time | [datetime] | | DATE | TIMESTAMP(3) | TEXT | -| Date and time | [datetimeoffset] | | | TIMESTAMP
with time zone| TEXT | -| Caracter Strings | [char] | CHAR | CHAR | CHAR | TEXT | -| Caracter Strings | [varchar] | VARCHAR | VARCHAR2 | VARCHAR | TEXT | -| Caracter Strings | [varchar](max) | | VARCHAR2 | TEXT | TEXT | -| Caracter Strings | [nchar] | NCHAR | | NCHAR | TEXT | -| Caracter Strings | [nvarchar] | | NCHAR | VARCHAR | TEXT | -| Caracter Strings | [nvarchar](max) | VARCHAR
TINYTEXT
TEXT(M)
MEDIUMTEXT
LONGTEXT | NCHAR | TEXT | TEXT | -| Caracter Strings | [ntext](*) | | LONG | TEXT | TEXT | -| Caracter Strings | [text](*) | | LONG | TEXT | TEXT | -| Binary Strings | [image](*) | LONGBLOB | LONG RAW | BYTEA | BLOB | -| Binary Strings | [binary] | BINARY | RAW | BYTEA | BLOB | -| Binary Strings | [varbinary] | | RAW | BYTEA | BLOB | -| Binary Strings | [varbinary](max) | VARBINARY(M)
TINYBLOB
BLOB
MEDIUMBLOB
LONGBLOB | RAW | BYTEA | BLOB | -| Other Data Types | [cursor] | | | | TEXT | -| Other Data Types | [sql_variant] | BLOB | | | TEXT | -| Other Data Types | [hierarchyid] | | | | TEXT | -| Other Data Types | [rowversion] | | | BYTEA | TEXT | -| Other Data Types | [timestamp](*) | | RAW | BYTEA | TEXT | -| Other Data Types | [uniqueidentifier] | CHAR | CHAR(36) | CHAR(16) | TEXT | -| Other Data Types | [xml] | | | XML | TEXT | -| Other Data Types | [table] | | | | - | -| Spatial Data Types | [geometry] | | | VARCHAR | TEXT | -| Spatial Data Types | [geography] | | | VARCHAR | TEXT | +- [SQL Server 2019 data types](https://docs.microsoft.com/en-us/sql/t-sql/data-types/data-types-transact-sql?view=sql-server-ver15) +- [MySQL 8.0 data types](https://dev.mysql.com/doc/refman/8.0/en/data-types.html) +- [Oracle 19C data types](https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlqr/Data-Types.html#GUID-DCCC6F18-15A0-4ECC-BA48-16F73F844844) +- [PostgreSQL 12 data types](https://www.postgresql.org/docs/12/datatype.html) +- [SQLite 3 data types][28] +- [SQL Server to MySQL Data Type Conversion](https://convertdb.com/mysql_mssql_mapping) +- [SQL Server to Oracle Data Type Conversion](https://docs.oracle.com/cd/B19306_01/gateways.102/b14270/apa.htm) +- [SQL Server to PostgreSQL Data Type Conversion](http://www.sqlines.com/sql-server-to-postgresql) +- [SQL Server to SQLite Data Type Conversion](http://ericsink.com/mssql_mobile/data_types.html) + + +Common data-type conversions between SQL Server, Oracle, Sybase ASE, and DB2. +More details [here](https://www.sqlserverscience.com/documentation/common-data-type-conversions-between-sql-server-oracle-sybase-ase-and-db2/) + +| Source | Destination | +|-------------|-------------| +| MSSQLSERVER | DB2 | +| MSSQLSERVER | ORACLE | +| MSSQLSERVER | SYBASE | +| ORACLE | MSSQLSERVER | + +```tsql +DECLARE @source_dbms SYSNAME = N'%' + , @source_version SYSNAME = N'%' + , @source_type SYSNAME = N'%' + , @destination_dbms SYSNAME = N'%' + , @destination_version SYSNAME = N'%' + , @destination_type SYSNAME = N'%' + , @defaults_only BIT = 0; + +SELECT * +FROM sys.fn_helpdatatypemap ( + @source_dbms + , @source_version + , @source_type + , @destination_dbms + , @destination_version + , @destination_type + , @defaults_only + ); +``` + +| General Type | Type | ANSI | MySQL | Oracle | PostgreSQL | SQLite | +|-----------------------|--------------------|------|:--------------------------|:--------------|:----------------------------|:--------------| +| Exact Numerics | [bit] | No | [TINYINT(1)][20] | NUMBER(1) | BOOLEAN | [INTEGER][28] | +| Exact Numerics | [tinyint][1] | No | [TINYINT(3) UNSIGNED][20] | NUMBER(3) | SMALLINT | [INTEGER][28] | +| Exact Numerics | [smallint][1] | Yes | [SMALLINT][20] | NUMBER(5) | SMALLINT | [INTEGER][28] | +| Exact Numerics | [int][1] | Yes | [INT][20] | NUMBER(10) | INT | [INTEGER][28] | +| Exact Numerics | [bigint][1] | No | [BIGINT][20] | NUMBER(19) | BIGINT | [INTEGER][28] | +| Exact Numerics | [decimal][2] | Yes | [DECIMAL][21] | NUMBER(p[,s]) | DECIMAL(p,s) | [REAL][28] | +| Exact Numerics | [smallmoney][3] | No | [DECIMAL(10,4)][21] | NUMBER(10,4) | MONEY | [REAL][28] | +| Exact Numerics | [money][3] | No | [DECIMAL(19,4)][21] | NUMBER(19,4) | MONEY | [REAL][28] | +| Approximate Numerics | [real][4] | Yes | [FLOAT][22] | FLOAT(24) | DOUBLE PRECISION | [REAL][28] | +| Approximate Numerics | [float][4](1-24) | Yes | [FLOAT][22] | FLOAT(24) | DOUBLE PRECISION | [REAL][28] | +| Approximate Numerics | [float][4](25-53) | Yes | [FLOAT][22] | FLOAT(49) | DOUBLE PRECISION | [REAL][28] | +| Date and Time | [date] | Yes | [DATE][22] | DATE | DATE | [TEXT][28] | +| Date and Time | [smalldatetime] | No | [TIMESTAMP][23] | DATE | TIMESTAMP(0) | [TEXT][28] | +| Date and Time | [time] | Yes | [TIME][24] | - | TIME | [TEXT][28] | +| Date and Time | [datetime2] | Yes | [DATETIME][23] | - | TIMESTAMP | [TEXT][28] | +| Date and Time | [datetime] | Yes | [DATETIME][23] | DATE | TIMESTAMP(3) | [TEXT][28] | +| Date and time | [datetimeoffset] | No | - | - | TIMESTAMP
with time zone| [TEXT][28] | +| Character Strings | [char][5] | Yes | [CHAR][26] | CHAR | CHAR | [TEXT][28] | +| Character Strings | [varchar][5] | Yes | [VARCHAR][26] | VARCHAR2 | VARCHAR | [TEXT][28] | +| Character Strings | [varchar(max)][5] | Yes | [LONGTEXT][25] | VARCHAR2 | TEXT | [TEXT][28] | +| Character Strings | [nchar][5] | Yes | [CHAR][26] with utf8 | NCHAR | CHAR | [TEXT][28] | +| Character Strings | [nvarchar][5] | Yes | [VARCHAR][26] with utf8 | NVARCHAR | VARCHAR | [TEXT][28] | +| Character Strings | [nvarchar(max)][5] | Yes | [LONGTEXT][25] | NCHAR | TEXT | [TEXT][28] | +| Character Strings | [ntext][7] (*) | No | [LONGTEXT][25] | CLOB | TEXT | [TEXT][28] | +| Character Strings | [text][7] (*) | No | [LONGTEXT][25] | LONG | TEXT | [TEXT][28] | +| Binary Strings | [image][7] (*) | No | [LONGBLOB][25] | LONG RAW | BYTEA | [BLOB][28] | +| Binary Strings | [binary][8] | Yes | [BINARY][27] | BLOB | BYTEA | [BLOB][28] | +| Binary Strings | [varbinary][8] | Yes | [VARBINARY][27] | RAW | BYTEA | [BLOB][28] | +| Binary Strings | [varbinary(max)][8]| Yes | [LONGTEXT][25] | RAW | BYTEA | [BLOB][28] | +| Other Data Types | [cursor] | No | - | - | - | - | +| Other Data Types | [sql_variant] | No | [TEXT][25] | CLOB | TEXT | [TEXT][28] | +| Other Data Types | [hierarchyid] | No | [TEXT][25] | BLOB | VARCHAR | [TEXT][28] | +| Other Data Types | [rowversion] | No | [TEXT][25] | RAW | BYTEA | [TEXT][28] | +| Other Data Types | [timestamp] (*) | No | [TEXT][25] | RAW | BYTEA | [TEXT][28] | +| Other Data Types | [uniqueidentifier] | No | [CHAR(16)][26] | CHAR(16) | CHAR(16) | [TEXT][28] | +| Other Data Types | [xml] | Yes | [LONGTEXT][25] | [XMLTYPE] | XML | [TEXT][28] | +| Other Data Types | [table] | No | - | - | - | - | +| Spatial Data Types | [geometry] | No | [TEXT][25] | BLOB | VARCHAR | [TEXT][28] | +| Spatial Data Types | [geography] | No | [TEXT][25] | BLOB | VARCHAR | [TEXT][28] | (\* *These data types will be removed in a future version of SQL Server. Avoid using these data types in new projects, and try to change them in current projects*) -[bit]:https://msdn.microsoft.com/en-us/library/ms177603.aspx -[tinyint]:https://msdn.microsoft.com/en-us/library/ms187745.aspx -[smallint]:https://msdn.microsoft.com/en-us/library/ms187745.aspx -[int]:https://msdn.microsoft.com/en-us/library/ms187745.aspx -[bigint]:https://msdn.microsoft.com/en-us/library/ms187745.aspx -[decimal]:https://msdn.microsoft.com/en-us/library/ms187746.aspx -[numeric]:https://msdn.microsoft.com/en-us/library/ms187746.aspx -[smallmoney]:https://msdn.microsoft.com/en-us/library/ms179882.aspx -[money]:https://msdn.microsoft.com/en-us/library/ms179882.aspx -[float]:https://msdn.microsoft.com/en-us/library/ms173773.aspx -[real]:https://msdn.microsoft.com/en-us/library/ms173773.aspx -[date]:https://msdn.microsoft.com/en-us/library/bb630352.aspx -[smalldatetime]:https://msdn.microsoft.com/en-us/library/ms182418.aspx -[time]:https://msdn.microsoft.com/en-us/library/bb677243.aspx -[datetime2]:https://msdn.microsoft.com/en-us/library/bb677335.aspx -[datetime]:https://msdn.microsoft.com/en-us/library/ms187819.aspx -[datetimeoffset]:https://msdn.microsoft.com/en-us/library/bb630289.aspx -[char]:https://msdn.microsoft.com/en-us/library/ms176089.aspx -[varchar]:https://msdn.microsoft.com/en-us/library/ms176089.aspx -[nchar]:https://msdn.microsoft.com/en-us/library/ms186939.aspx -[nvarchar]:https://msdn.microsoft.com/en-us/library/ms186939.aspx -[ntext]:https://msdn.microsoft.com/en-us/library/ms187993.aspx -[text]:https://msdn.microsoft.com/en-us/library/ms187993.aspx -[image]:https://msdn.microsoft.com/en-us/library/ms187993.aspx -[binary]:https://msdn.microsoft.com/en-us/library/ms188362.aspx -[varbinary]:https://msdn.microsoft.com/en-us/library/ms188362.aspx -[cursor]:https://msdn.microsoft.com/en-us/library/ms190498.aspx -[sql_variant]:https://msdn.microsoft.com/en-us/library/ms173829.aspx -[hierarchyid]:https://msdn.microsoft.com/en-us/library/bb677290.aspx -[rowversion]:https://msdn.microsoft.com/en-us/library/ms182776.aspx -[timestamp]:https://msdn.microsoft.com/en-us/library/ms182776.aspx -[uniqueidentifier]:https://msdn.microsoft.com/en-us/library/ms187942.aspx -[xml]:https://msdn.microsoft.com/en-us/library/ms187339.aspx -[table]:https://msdn.microsoft.com/en-us/library/ms175010.aspx -[geometry]:https://msdn.microsoft.com/en-us/library/cc280487.aspx -[geography]:https://msdn.microsoft.com/en-us/library/cc280766.aspx +**[⬆ back to top](#table-of-contents)** + + +## SQL Server Data Types Mapping to Program Languages + + +- [Java and SQL Server supported data types](https://docs.microsoft.com/en-us/sql/language-extensions/how-to/java-to-sql-data-types) +- [Data type mappings between Python and SQL Server](https://docs.microsoft.com/en-us/sql/machine-learning/python/python-libraries-and-data-types) +- [Data type mappings between R and SQL Server](https://docs.microsoft.com/en-us/sql/machine-learning/r/r-libraries-and-data-types) + +| General Type | Type | ANSI | Java | Python | R | +|:----------------------|:-------------------|:-----|:---------------------|:--------|:----------| +| Exact Numerics | [bit] | No | boolean | bool | logical | +| Exact Numerics | [tinyint][1] | No | short | uint8 | integer | +| Exact Numerics | [smallint][1] | Yes | short | int16 | integer | +| Exact Numerics | [int][1] | Yes | int | int32 | integer | +| Exact Numerics | [bigint][1] | No | long | numeric | numeric | +| Exact Numerics | [decimal][2] | Yes | java.math.BigDecimal | ? | numeric | +| Exact Numerics | [smallmoney][3] | No | java.math.BigDecimal | ? | numeric | +| Exact Numerics | [money][3] | No | java.math.BigDecimal | ? | numeric | +| Approximate Numerics | [real][4] | Yes | float | float32 | numeric | +| Approximate Numerics | [float][4](1-24) | Yes | float | float32 | numeric | +| Approximate Numerics | [float][4](25-53) | Yes | double | float64 | numeric | +| Date and Time | [date] | Yes | java.sql.date | ? | POSIXct | +| Date and Time | [smalldatetime] | No | java.sql.timestamp | ? | POSIXct | +| Date and Time | [time] | Yes | ? | ? | POSIXct | +| Date and Time | [datetime2] | Yes | java.sql.timestamp | ? | POSIXct | +| Date and Time | [datetime] | Yes | java.sql.timestamp | ? | POSIXct | +| Date and time | [datetimeoffset] | No | ? | ? | ? | +| Character Strings | [char][5] | Yes | String (**) | str | character | +| Character Strings | [varchar][5] | Yes | String (**) | str | character | +| Character Strings | [varchar(max)][5] | Yes | String (**) | str | character | +| Character Strings | [nchar][5] | Yes | String | str | character | +| Character Strings | [nvarchar][5] | Yes | String | str | character | +| Character Strings | [nvarchar(max)][5] | Yes | String | str | character | +| Character Strings | [ntext][7] (*) | No | String | str | character | +| Character Strings | [text][7] (*) | No | String (**) | str | character | +| Binary Strings | [image][7] (*) | No | byte[] | str | - | +| Binary Strings | [binary][8] | Yes | byte[] | raw | raw | +| Binary Strings | [varbinary][8] | Yes | byte[] | bytes | raw | +| Binary Strings | [varbinary(max)][8]| Yes | byte[] | bytes | raw | +| Other Data Types | [cursor] | No | - | - | - | +| Other Data Types | [sql_variant] | No | String | str | - | +| Other Data Types | [hierarchyid] | No | String | str | - | +| Other Data Types | [rowversion] | No | ? | ? | - | +| Other Data Types | [timestamp] (*) | No | ? | ? | - | +| Other Data Types | [uniqueidentifier] | No | String | str | - | +| Other Data Types | [xml] | Yes | ? | ? | - | +| Other Data Types | [table] | No | - | - | - | +| Spatial Data Types | [geometry] | No | ? | ? | - | +| Spatial Data Types | [geography] | No | ? | ? | - | + +(\* *These data types will be removed in a future version of SQL Server. Avoid using these data types in new projects, and try to change them in current projects*) +(\*\* *Only UTF8 Strings supported*) + +**[⬆ back to top](#table-of-contents)** + + +## Source links + +- [Data Types (Transact-SQL)](https://docs.microsoft.com/en-us/sql/t-sql/data-types/data-types-transact-sql) +- [Data Type Precedence (Transact-SQL)](https://docs.microsoft.com/en-us/sql/t-sql/data-types/data-type-precedence-transact-sql) +- [Data Type Synonyms (Transact-SQL)](https://docs.microsoft.com/en-us/sql/t-sql/data-types/data-type-synonyms-transact-sql) +- [Precision, Scale, and Length](https://docs.microsoft.com/en-us/sql/t-sql/data-types/precision-scale-and-length-transact-sql) +- [Integration Services Data Types](https://docs.microsoft.com/en-us/sql/integration-services/data-flow/integration-services-data-types) +- [DbType Enumeration](https://docs.microsoft.com/en-us/dotnet/api/system.data.dbtype) +- [SQL Server, SSIS and Biml Data Types](http://www.cathrinewilhelmsen.net/2014/05/27/sql-server-ssis-and-biml-data-types/) +- [SQL Server Integration Services, Data Type Mapping](http://milambda.blogspot.ru/2014/02/sql-server-integration-services-data.html) +- [Data type conversion (Database Engine)](https://docs.microsoft.com/en-us/sql/t-sql/data-types/data-type-conversion-database-engine) + +**[⬆ back to top](#table-of-contents)** + + +[1]:https://docs.microsoft.com/sql/t-sql/data-types/int-bigint-smallint-and-tinyint-transact-sql +[2]:https://docs.microsoft.com/sql/t-sql/data-types/decimal-and-numeric-transact-sql +[3]:https://docs.microsoft.com/sql/t-sql/data-types/money-and-smallmoney-transact-sql +[4]:https://docs.microsoft.com/sql/t-sql/data-types/float-and-real-transact-sql +[5]:https://docs.microsoft.com/sql/t-sql/data-types/char-and-varchar-transact-sql +[6]:https://docs.microsoft.com/sql/t-sql/data-types/nchar-and-nvarchar-transact-sql +[7]:https://docs.microsoft.com/sql/t-sql/data-types/ntext-text-and-image-transact-sql +[8]:https://docs.microsoft.com/sql/t-sql/data-types/binary-and-varbinary-transact-sql + +[bit]:https://docs.microsoft.com/sql/t-sql/data-types/bit-transact-sql +[date]:https://docs.microsoft.com/sql/t-sql/data-types/date-transact-sql +[smalldatetime]:https://docs.microsoft.com/sql/t-sql/data-types/smalldatetime-transact-sql +[time]:https://docs.microsoft.com/sql/t-sql/data-types/time-transact-sql +[datetime2]:https://docs.microsoft.com/sql/t-sql/data-types/datetime2-transact-sql +[datetime]:https://docs.microsoft.com/sql/t-sql/data-types/datetime-transact-sql +[datetimeoffset]:https://docs.microsoft.com/sql/t-sql/data-types/datetimeoffset-transact-sql +[cursor]:https://docs.microsoft.com/sql/t-sql/data-types/cursor-transact-sql +[sql_variant]:https://docs.microsoft.com/sql/t-sql/data-types/sql-variant-transact-sql +[hierarchyid]:https://docs.microsoft.com/sql/t-sql/data-types/hierarchyid-data-type-method-reference +[rowversion]:https://docs.microsoft.com/sql/t-sql/data-types/rowversion-transact-sql +[timestamp]:https://docs.microsoft.com/sql/t-sql/data-types/rowversion-transact-sql#remarks +[uniqueidentifier]:https://docs.microsoft.com/sql/t-sql/data-types/uniqueidentifier-transact-sql +[xml]:https://docs.microsoft.com/sql/t-sql/xml/xml-transact-sql +[table]:https://docs.microsoft.com/sql/t-sql/data-types/table-transact-sql +[geometry]:https://docs.microsoft.com/sql/t-sql/spatial-geometry/spatial-types-geometry-transact-sql +[geography]:https://docs.microsoft.com/sql/t-sql/spatial-geography/spatial-types-geography + +[20]:https://dev.mysql.com/doc/refman/8.0/en/integer-types.html +[21]:https://dev.mysql.com/doc/refman/8.0/en/fixed-point-types.html +[22]:https://dev.mysql.com/doc/refman/8.0/en/floating-point-types.html +[23]:https://dev.mysql.com/doc/refman/8.0/en/datetime.html +[24]:https://dev.mysql.com/doc/refman/8.0/en/time.html +[25]:https://dev.mysql.com/doc/refman/8.0/en/blob.html +[26]:https://dev.mysql.com/doc/refman/8.0/en/char.html +[27]:https://dev.mysql.com/doc/refman/8.0/en/binary-varbinary.html + +[28]:https://www.sqlite.org/datatype3.html + +[XMLTYPE]:https://docs.oracle.com/en/database/oracle/oracle-database/12.2/arpls/XMLTYPE.html diff --git a/SQL Server Drivers.md b/SQL Server Drivers.md index f2bbccae..43dec2e7 100644 --- a/SQL Server Drivers.md +++ b/SQL Server Drivers.md @@ -5,6 +5,17 @@ Please see below for a summary of the different drivers, both current and legacy [SQL Server Drivers](https://docs.microsoft.com/en-us/sql/connect/sql-server-drivers) +# Driver feature support matrix for Microsoft SQL Server +[Driver feature support matrix for Microsoft SQL Server](https://docs.microsoft.com/en-us/sql/connect/driver-feature-matrix) +If you're planning to use a feature in Microsoft SQL Server, it might not be available in all drivers. Some reasons a feature might not be in a particular driver include: + +- The feature doesn't apply to the driver technology. +- The feature is new and hasn't been implemented across all drivers yet. +- The feature isn't in demand in a particular driver. +- Other features are being implemented first. +We wish all drivers supported every feature and spend effort to ensure feature parity across drivers. However that isn't always possible. To help you choose the appropriate driver for your needs, here's a list of popular features and the drivers that implement them. + + ## Current SQL Drivers The following SQL Drivers are actively developed. Each driver has a support statement that can be found by following the links. @@ -15,10 +26,16 @@ This driver is developed, tested, and supported by Microsoft. [Microsoft ADO.NET for SQL Server](https://docs.microsoft.com/en-us/sql/connect/ado-net/microsoft-ado-net-for-sql-server) | [Download .Net Driver](http://www.microsoft.com/net/download/) +### Ballerina +The Ballerina MSSQL Connector provides seamless integration with Microsoft SQL Server, allowing developers to work with databases efficiently in cloud-native and REST-based applications. This connector is an open-source project which is actively developed, tested, and supported by the Ballerina team. + +[ballerinax/mssql connector for SQL Server](https://central.ballerina.io/ballerinax/mssql/latest) | [GitHub](https://github.com/ballerina-platform/module-ballerinax-mssql) + + ### JDBC The JDBC SQL driver is a Java implementation of the TDS protocol, which is supported by all modern versions of SQL Server. This driver is developed, tested, and supported by Microsoft. -[Microsoft JDBC Driver for SQL Server](https://docs.microsoft.com/en-us/sql/connect/jdbc/microsoft-jdbc-driver-for-sql-server) | [Download JDBC Driver](https://go.microsoft.com/fwlink/?linkid=852460) +[Microsoft JDBC Driver for SQL Server](https://docs.microsoft.com/en-us/sql/connect/jdbc/microsoft-jdbc-driver-for-sql-server) | [Download JDBC Driver](https://docs.microsoft.com/en-us/sql/connect/jdbc/download-microsoft-jdbc-driver-for-sql-server?view=sql-server-2017) ### ODBC @@ -30,13 +47,13 @@ The ODBC SQL driver is a C++ implementation of the TDS protocol, which is suppor ### PHP The PHP SQL driver relies on the Microsoft SQL Server ODBC Driver to handle the low-level communication with SQL Server. This driver is developed, tested, and supported by Microsoft. -[Microsoft PHP Driver for SQL Driver](https://docs.microsoft.com/en-us/sql/connect/php/microsoft-php-driver-for-sql-server) | [Download PHP Driver](https://www.microsoft.com/en-us/download/details.aspx?id=20098) | [Github](https://github.com/Microsoft/msphpsql) +[Microsoft PHP Driver for SQL Driver](https://docs.microsoft.com/en-us/sql/connect/php/microsoft-php-driver-for-sql-server) | [Download PHP Driver](https://github.com/microsoft/msphpsql/releases/latest) | [Github](https://github.com/Microsoft/msphpsql) ### Node.js The tedious module is a javascript implementation of the TDS protocol, which is supported by all modern versions of SQL Server. The driver is an open source project, available on Github. -[Node.js Driver for SQL Server](https://docs.microsoft.com/en-us/sql/connect/node-js/node-js-driver-for-sql-server) | [Install Node.js Driver](http://msdn.microsoft.com/library/mt652094.aspx) +[Node.js Driver for SQL Server](https://docs.microsoft.com/en-us/sql/connect/node-js/node-js-driver-for-sql-server) | [Install Node.js Driver](https://docs.microsoft.com/en-us/sql/connect/node-js/step-1-configure-development-environment-for-node-js-development) ### Python @@ -52,7 +69,13 @@ There are several python SQL Drivers available. Choose which one you want to use ### Ruby The TinyTDS gem is a Ruby implementation of the TDS protocol, which is supported by all modern versions of SQL Server. -[Ruby Driver for SQL Server](https://docs.microsoft.com/en-us/sql/connect/ruby/ruby-driver-for-sql-server) | [Install Ruby Driver](http://msdn.microsoft.com/library/mt711041.aspx) +[Ruby Driver for SQL Server](https://docs.microsoft.com/en-us/sql/connect/ruby/ruby-driver-for-sql-server) | [Install Ruby Driver](https://docs.microsoft.com/en-us/sql/connect/ruby/ruby-driver-for-sql-server) + + +### Rails +The SQL Server adapter for ActiveRecord v5.1 using SQL Server 2012 or higher. + +[SQL Server Adapter For Rails](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter) ## Legacy SQL Drivers @@ -63,7 +86,7 @@ Each driver has a support statement that can be found by following the links. ## OLEDB The OLE DB provider will not be included after SQL Server 2012. -[Microsoft OLE DB](https://msdn.microsoft.com/library/ms722784.aspx) +[Microsoft OLE DB](https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms722784(v=vs.85)) ### ADO diff --git a/SQL Server Edition.md b/SQL Server Edition.md index e08cf8c1..2f72035a 100644 --- a/SQL Server Edition.md +++ b/SQL Server Edition.md @@ -1,13 +1,15 @@ # Microsoft SQL Server Edition Source links: - - [Official Microsoft Page](http://www.microsoft.com/en-us/server-cloud/products/sql-server-editions/) - - [Features Supported by the Editions of SQL Server 2016](https://msdn.microsoft.com/en-us/library/cc645993.aspx) + - [Editions and supported features of SQL Server 2017](https://docs.microsoft.com/en-us/sql/sql-server/editions-and-components-of-sql-server-2017?view=sql-server-2017) + - [Features Supported by the Editions of SQL Server 2017](https://docs.microsoft.com/en-us/sql/sql-server/editions-and-components-of-sql-server-2017) + - [Features Supported by the Editions of SQL Server 2016](https://docs.microsoft.com/en-us/sql/sql-server/editions-and-components-of-sql-server-2016) - [Features Supported by the Editions of SQL Server 2014](https://msdn.microsoft.com/en-us/library/cc645993%28v=SQL.120%29.aspx) - [Features Supported by the Editions of SQL Server 2012](https://msdn.microsoft.com/en-us/library/cc645993%28v=SQL.110%29.aspx) - [Features Supported by the Editions of SQL Server 2008](https://msdn.microsoft.com/en-us/library/cc645993%28v=SQL.100%29.aspx) - [Features Supported by the Editions of SQL Server 2005](https://technet.microsoft.com/en-us/library/ms143761%28v=sql.90%29.aspx) - - [SQL Server Pricing](https://www.microsoft.com/en-us/server-cloud/products/sql-server/purchasing.aspx) + - [SQL Server 2017 Pricing](https://www.microsoft.com/en-Us/sql-server/sql-server-2017-pricing) + - [Azure SQL Database pricing](https://azure.microsoft.com/en-us/pricing/details/sql-database/managed/?cdn=disable) - [An Overview of SQL Server 2016 Licensing](http://sqlmag.com/scaling-success-sql-server-2016/overview-sql-server-2016-licensing) diff --git a/SQL Server Name Convention and T-SQL Programming Style.md b/SQL Server Name Convention and T-SQL Programming Style.md index 6580458b..5f01ff49 100644 --- a/SQL Server Name Convention and T-SQL Programming Style.md +++ b/SQL Server Name Convention and T-SQL Programming Style.md @@ -1,168 +1,632 @@ # SQL Server Name Convention and T-SQL Programming Style -Official Reference and useful links - - [Transact-SQL Formatting Standards](https://www.simple-talk.com/sql/t-sql-programming/transact-sql-formatting-standards-%28coding-styles%29/) (by Robert Sheldon) - - [Subjectivity: Naming Standards](http://blogs.sqlsentry.com/aaronbertrand/subjectivity-naming-standards/) (by Aaron Bertrand) - - [General Database Conventions](http://kejser.org/database-naming-conventions/general-database-conventions/) (by Thomas Kejser) - - [Writing Readable SQL](http://www.codeproject.com/Articles/126380/Writing-Readable-SQL) (by Red Gate_) - - [SQL Style Guide](http://www.sqlstyle.guide/) (by Simon Holywell) - - [SQL Code Layout and Beautification](https://www.simple-talk.com/sql/t-sql-programming/sql-code-layout-and-beautification/) (by William Brewer) - - [TSQL Coding Style](http://www.databasejournal.com/features/mssql/tsql-coding-style.html) (by Gregory Larsen) - - [Database object Limitations](http://technet.microsoft.com/en-us/library/ms172451%28v=sql.110%29.aspx) - - [User-Defined Functions MSDN](http://msdn.microsoft.com/en-us/library/ms191007.aspx) - - [Synonim TECHNET](http://technet.microsoft.com/en-us/library/ms187552(v=sql.110).aspx) - - [Primary and Foreign Key Constraints MSDN](http://msdn.microsoft.com/en-us/library/ms179610.aspx) - - [sys.objects MSDN](http://msdn.microsoft.com/en-us/library/ms190324.aspx) - - [Constraints TECHNET](http://technet.microsoft.com/en-us/library/ms189862%28v=sql.105%29.aspx) - - [CHECK Constraint TECHNET](http://technet.microsoft.com/en-us/library/ms188258%28v=sql.105%29.aspx) - - [SQL Server CLR Integration MSDN](http://msdn.microsoft.com/en-us/library/ms254498%28v=vs.110%29.aspx) - - [CLR Databse Objects MSDN](http://msdn.microsoft.com/en-us/library/ms345099%28SQL.100%29.aspx) - - [CLR Stored Procedures](http://msdn.microsoft.com/en-us/library/ms131094%28v=sql.100%29.aspx) - - [User-defined Functions](http://msdn.microsoft.com/en-us/library/ms191320.aspx) - - [MSDN SET NOCOUNT ON](https://docs.microsoft.com/en-us/sql/t-sql/statements/set-nocount-transact-sql) - - [T-SQL Coding Guidelines Presentation](http://www.slideshare.net/chris1adkin/t-sql-coding-guidelines) (by Chris Adkin) - - [Sql Coding Style](http://c2.com/cgi/wiki?SqlCodingStyle) - - [SQL Server Code Review Checklist for Developers](https://www.sqlshack.com/sql-server-code-review-checklist-for-developers/) (by Samir Behara) - - [SQL Formatting standards – Capitalization, Indentation, Comments, Parenthesis](https://solutioncenter.apexsql.com/sql-formatting-standards-capitalization-indentation-comments-parenthesis/) (by ApexSQL) - - [In The Cloud: The Importance of Being Organized]:http://sqlblog.com/blogs/john_paul_cook/archive/2017/05/16/in-the-cloud-the-importance-of-being-organized.aspx - - [Naming Conventions in Azure](http://www.sqlchick.com/entries/2017/6/24/naming-conventions-in-azure) - - [The Basics of Good T-SQL Coding Style – Part 3: Querying and Manipulating Data](https://www.simple-talk.com/sql/t-sql-programming/basics-good-t-sql-coding-style-part-3-querying-manipulating-data/) +> There are only two hard things in Computer Science: cache invalidation and naming things +> -- [Phil Karlton](https://www.karlton.org/2017/12/naming-things-hard/) + +[Naming convention](https://en.wikipedia.org/wiki/Naming_convention_(programming)) is a set of rules for choosing the character sequence to be used for identifiers which denote variables, types, functions, and other entities in source code and documentation. + +Reasons for using a naming convention (as opposed to allowing programmers to choose any character sequence) include the following: +- To reduce the effort needed to read and understand source code. +- To enable code reviews to focus on more important issues than arguing over syntax and naming standards. +- To enable code quality review tools to focus their reporting mainly on significant issues other than syntax and style preferences. + +## Table of Contents + +- [SQL Server Object Name Convention](#sql-server-object-name-convention) +- [SQL Server Data Types Recommendation](#data-types-recommendation) +- [SQL Server Function Recommendations](#function-recommendation) +- [T-SQL Programming T-SQL Style](#t-sql-programming-style) + - [General T-SQL programming style](#general-t-sql-programming-style) + - [Stored procedures and functions programming style](#programming-style) + - [Dynamic T-SQL Recommendation](#dynamic-t-sql-recommendation) +- [Reference and useful links](#reference) + + + ## SQL Server Object Name Convention -| Object | Code | Notation | Length | Plural | Prefix | Suffix | Abbreviation | Char Mask | Example | -|----------------------------------|------| ---------- |-------:|--------|--------|--------|--------------|--------------|------------------------------------| -| Database | | UPPERCASE | 30 | No | No | No | Yes | [A-z] | MYDATABASE | -| Database Trigger | | PascalCase | 50 | No | DTR_ | No | Yes | [A-z] | DTR_CheckLogin | -| Schema | | lowercase | 30 | No | No | No | Yes | [A-z][0-9] | myschema | -| File Table | | PascalCase | 128 | No | FT_ | No | Yes | [A-z][0-9] | FT_MyTable | -| Global Temporary Table | | PascalCase | 118 | No | No | No | Yes | ##[A-z][0-9] | ##MyTable | -| Local Temporary Table | | PascalCase | 118 | No | No | No | Yes | #[A-z][0-9] | #MyTable | -| Table | U | PascalCase | 30 | No | No | No | Yes | [A-z][0-9] | MyTable | -| Table Column | | PascalCase | 30 | No | No | No | Yes | [A-z][0-9] | MyColumn | -| Table Default Values | D | PascalCase | 128 | No | DF_ | No | Yes | [A-z][0-9] | DF_MyTable_MyColumn | -| Table Check Column Constraint | C | PascalCase | 128 | No | CK_ | No | Yes | [A-z][0-9] | CK_MyTable_MyColumn | -| Table Check Table Constraint | C | PascalCase | 128 | No | CTK_ | No | Yes | [A-z][0-9] | CTK_MyTable_MyColumn_AnotherColumn | -| Table Primary Key | PK | PascalCase | 128 | No | PK_ | No | Yes | [A-z][0-9] | PK_MyTableID | -| Table Alternative Key | UQ | PascalCase | 128 | No | AK_ | No | Yes | [A-z][0-9] | AK_MyTable_MyColumn_AnotherColumn | -| Table Foreign Key | F | PascalCase | 128 | No | FK_ | No | Yes | [A-z][0-9] | FK_MyTable_ForeignTableID | -| Table Clustered Index | | PascalCase | 128 | No | IXC_ | No | Yes | [A-z][0-9] | IXC_MyTable_MyColumn_AnotherColumn | -| Table Non Clustered Index | | PascalCase | 128 | No | IX_ | No | Yes | [A-z][0-9] | IX_MyTable_MyColumn_AnotherColumn | -| Table Trigger | TR | PascalCase | 128 | No | TR_ | No | Yes | [A-z][0-9] | TR_MyTable_LogicalName | -| View | V | PascalCase | 128 | No | VI_ | No | No | [A-z][0-9] | VI_LogicalName | -| Stored Procedure | P | PascalCase | 128 | No | usp_ | No | No | [A-z][0-9] | usp_LogicalName | -| Scalar User-Defined Function | FN | PascalCase | 50 | No | udf_ | No | No | [A-z][0-9] | udf_FunctionLogicalName | -| Table-Valued Function | FN | PascalCase | 50 | No | tvf_ | No | No | [A-z][0-9] | tvf_FunctionLogicalName | -| Synonym | SN | camelCase | 128 | No | sy_ | No | No | [A-z][0-9] | sy_logicalName | -| Sequence | SO | PascalCase | 128 | No | sq_ | No | No | [A-z][0-9] | sq_TableName | -| CLR Assembly | | PascalCase | 128 | No | CA | No | Yes | [A-z][0-9] | CALogicalName | -| CLR Stored Procedures | PC | PascalCase | 128 | No | pc_ | No | Yes | [A-z][0-9] | pc_CAName_LogicalName | -| CLR Scalar User-Defined Function | | PascalCase | 50 | No | cudf_ | No | No | [A-z][0-9] | cudf_CAName_LogicalName | -| CLR Table-Valued Function | | PascalCase | 50 | No | ctvf_ | No | No | [A-z][0-9] | ctvf_CAName_LogicalName | -| CLR User-Defined Aggregates | | PascalCase | 50 | No | ca_ | No | No | [A-z][0-9] | ca_CAName_LogicalName | -| CLR User-Defined Types | | PascalCase | 50 | No | ct_ | No | No | [A-z][0-9] | ct_CAName_LogicalName | -| CLR Triggers | | PascalCase | 50 | No | ctr_ | No | No | [A-z][0-9] | ctr_CAName_LogicalName | +| Object | Code | Notation | Length | Plural | Prefix | Suffix | Abbreviation | Char Mask | Example | +|------------------------------------------|------| ---------- |-------:|--------|---------|--------|--------------|--------------|--------------------------------------| +| [Database] | | UPPERCASE | 30 | No | No | No | Yes | [A-z] | `MYDATABASE` | +| [Schema] | | lowercase | 30 | No | No | No | Yes | [a-z][0-9] | `myschema` | +| [Global Temporary Table] | | PascalCase | 117 | No | No | No | Yes | ##[A-z][0-9] | `##MyTable` | +| [Local Temporary Table] | | PascalCase | 116 | No | No | No | Yes | #[A-z][0-9] | `#MyTable` | +| [File Table] | | PascalCase | 128 | No | `FT_` | No | Yes | [A-z][0-9] | `FT_MyTable` | +| [Memory-optimized SCHEMA_AND_DATA Table] | | PascalCase | 128 | No | `MT_` | `_SD` | Yes | [A-z][0-9] | `MT_MyTable_SD` | +| [Memory-optimized SCHEMA_ONLY Table] | | PascalCase | 128 | No | `MT_` | `_SO` | Yes | [A-z][0-9] | `MT_MyTable_SO` | +| [Temporal Table] | | PascalCase | 128 | No | No | `_TT` | Yes | [A-z][0-9] | `MyTable_TT` | +| [Disk-Based Table] | U | PascalCase | 128 | No | No | No | Yes | [A-z][0-9] | `MyTable` | +| [Disk-Based Wide Table - SPARSE Column] | U | PascalCase | 128 | No | No | `_SPR` | Yes | [A-z][0-9] | `MyTable_SPR` | +| [Table Column] | | PascalCase | 128 | No | No | No | Yes | [A-z][0-9] | `MyColumn` | +| [Table Column SPARSE] | | PascalCase | 128 | No | No | `_SPR` | Yes | [A-z][0-9] | `MyColumn_SPR` | +| [Columns Check Constraint] | C | PascalCase | 128 | No | `CTK_` | No | Yes | [A-z][0-9] | `CTK_MyTable_MyColumn_AnotherColumn` | +| [Column Check Constraint] | C | PascalCase | 128 | No | `CK_` | No | Yes | [A-z][0-9] | `CK_MyTable_MyColumn` | +| [Column Default Values] | D | PascalCase | 128 | No | `DF_` | No | Yes | [A-z][0-9] | `DF_MyTable_MyColumn` | +| [Table Primary Key] | PK | PascalCase | 128 | No | `PK_` | No | Yes | [A-z][0-9] | `PK_MyTableID` | +| [Table Unique (Alternative) Key] | UQ | PascalCase | 128 | No | `AK_` | No | Yes | [A-z][0-9] | `AK_MyTable_MyColumn_AnotherColumn` | +| [Table Foreign Key] | F | PascalCase | 128 | No | `FK_` | No | Yes | [A-z][0-9] | `FK_MyTable_ForeignTableID` | +| [Table Clustered Index] | | PascalCase | 128 | No | `IXC_` | No | Yes | [A-z][0-9] | `IXC_MyTable_MyColumn_AnotherColumn` | +| [Table Non Clustered Index] | | PascalCase | 128 | No | `IX_` | No | Yes | [A-z][0-9] | `IX_MyTable_MyColumn_AnotherColumn` | +| [DDL Trigger] | TR | PascalCase | 128 | No | `TR_` | `_DDL` | Yes | [A-z][0-9] | `TR_LogicalName_DDL` | +| [DML Trigger] | TR | PascalCase | 128 | No | `TR_` | `_DML` | Yes | [A-z][0-9] | `TR_MyTable_LogicalName_DML` | +| [Logon Trigger] | TR | PascalCase | 128 | No | `TR_` | `_LOG` | Yes | [A-z][0-9] | `TR_LogicalName_LOG` | +| [View] | V | PascalCase | 128 | No | `VI_` | No | No | [A-z][0-9] | `VI_LogicalName` | +| [Indexed View] | V | PascalCase | 128 | No | `VIX_` | No | No | [A-z][0-9] | `VIX_LogicalName` | +| [Statistic] | | PascalCase | 128 | No | `ST_` | No | No | [A-z][0-9] | `ST_MyTable_MyColumn_AnotherColumn` | +| [Stored Procedure] | P | PascalCase | 128 | No | `usp_` | No | No | [A-z][0-9] | `usp_LogicalName` | +| [Scalar User-Defined Function] | FN | PascalCase | 128 | No | `udf_` | No | No | [A-z][0-9] | `udf_FunctionLogicalName` | +| [Table-Valued Function] | FN | PascalCase | 128 | No | `tvf_` | No | No | [A-z][0-9] | `tvf_FunctionLogicalName` | +| [Synonym] | SN | camelCase | 128 | No | `sy_` | No | No | [A-z][0-9] | `sy_logicalName` | +| [Sequence] | SO | PascalCase | 128 | No | `sq_` | No | No | [A-z][0-9] | `sq_TableName` | +| [CLR Assembly] | | PascalCase | 128 | No | `CA ` | No | Yes | [A-z][0-9] | `CALogicalName` | +| [CLR Stored Procedures] | PC | PascalCase | 128 | No | `pc_` | No | Yes | [A-z][0-9] | `pc_CAName_LogicalName` | +| [CLR Scalar User-Defined Function] | | PascalCase | 128 | No | `cudf_` | No | No | [A-z][0-9] | `cudf_CAName_LogicalName` | +| [CLR Table-Valued Function] | | PascalCase | 128 | No | `ctvf_` | No | No | [A-z][0-9] | `ctvf_CAName_LogicalName` | +| [CLR User-Defined Aggregates] | | PascalCase | 128 | No | `ca_` | No | No | [A-z][0-9] | `ca_CAName_LogicalName` | +| [CLR User-Defined Types] | | PascalCase | 128 | No | `ct_` | No | No | [A-z][0-9] | `ct_CAName_LogicalName` | +| [CLR Triggers] | | PascalCase | 128 | No | `ctr_` | No | No | [A-z][0-9] | `ctr_CAName_LogicalName` | +| [Linked Server] | | PascalCase | 128 | No | `ls_` | No | No | [A-z][0-9] | `ls_LogicalName` | + +[Database]:https://docs.microsoft.com/en-us/sql/t-sql/statements/create-database-transact-sql +[Schema]:https://docs.microsoft.com/en-us/sql/relational-databases/security/authentication-access/create-a-database-schema +[Global Temporary Table]:https://docs.microsoft.com/en-us/sql/relational-databases/tables/tables +[Local Temporary Table]:https://docs.microsoft.com/en-us/sql/relational-databases/tables/tables +[File Table]:https://docs.microsoft.com/en-us/sql/relational-databases/blob/filetables-sql-server +[Memory-optimized SCHEMA_AND_DATA Table]:https://docs.microsoft.com/en-us/sql/relational-databases/in-memory-oltp/introduction-to-memory-optimized-tables +[Memory-optimized SCHEMA_ONLY Table]:https://docs.microsoft.com/en-us/sql/relational-databases/in-memory-oltp/defining-durability-for-memory-optimized-objects +[Temporal Table]:https://docs.microsoft.com/en-us/sql/relational-databases/tables/temporal-tables +[Disk-Based Table]:https://docs.microsoft.com/en-us/sql/relational-databases/in-memory-oltp/comparing-disk-based-table-storage-to-memory-optimized-table-storage +[Disk-Based Wide Table - SPARSE Column]:https://docs.microsoft.com/en-us/sql/relational-databases/tables/tables#wide-tables +[Table Column]:https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-table-transact-sql +[Table Column SPARSE]:https://docs.microsoft.com/en-us/sql/relational-databases/tables/use-sparse-columns +[Columns Check Constraint]:https://docs.microsoft.com/en-us/sql/relational-databases/tables/create-check-constraints +[Column Check Constraint]:https://docs.microsoft.com/en-us/sql/relational-databases/tables/create-check-constraints +[Column Default Values]:https://docs.microsoft.com/en-us/sql/relational-databases/tables/specify-default-values-for-columns +[Table Primary Key]:https://docs.microsoft.com/en-us/sql/relational-databases/tables/create-primary-keys +[Table Unique (Alternative) Key]:https://docs.microsoft.com/en-us/sql/relational-databases/tables/create-unique-constraints +[Table Foreign Key]:https://docs.microsoft.com/en-us/sql/relational-databases/tables/create-foreign-key-relationships +[Table Clustered Index]:https://docs.microsoft.com/en-us/sql/relational-databases/indexes/clustered-and-nonclustered-indexes-described +[Table Non Clustered Index]:https://docs.microsoft.com/en-us/sql/relational-databases/indexes/clustered-and-nonclustered-indexes-described +[DDL Trigger]:https://docs.microsoft.com/en-us/sql/t-sql/statements/create-trigger-transact-sql +[DML Trigger]:https://docs.microsoft.com/en-us/sql/relational-databases/triggers/dml-triggers +[Logon Trigger]:https://docs.microsoft.com/en-us/sql/t-sql/statements/create-trigger-transact-sql +[View]:https://docs.microsoft.com/en-us/sql/relational-databases/views/views +[Indexed View]:https://docs.microsoft.com/en-us/sql/relational-databases/views/create-indexed-views +[Statistic]:https://docs.microsoft.com/en-us/sql/t-sql/statements/create-statistics-transact-sql +[Stored Procedure]:https://docs.microsoft.com/en-us/sql/t-sql/statements/create-procedure-transact-sql +[Scalar User-Defined Function]:https://docs.microsoft.com/en-us/sql/relational-databases/user-defined-functions/create-user-defined-functions-database-engine#Scalar +[Table-Valued Function]:https://docs.microsoft.com/en-us/sql/relational-databases/user-defined-functions/create-user-defined-functions-database-engine#TVF +[Synonym]:https://docs.microsoft.com/en-us/sql/relational-databases/synonyms/synonyms-database-engine +[Sequence]:https://docs.microsoft.com/en-us/sql/relational-databases/sequence-numbers/sequence-numbers +[CLR Assembly]:https://docs.microsoft.com/en-us/sql/relational-databases/clr-integration/assemblies/creating-an-assembly +[CLR Stored Procedures]:https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql/clr-stored-procedures +[CLR Scalar User-Defined Function]:https://docs.microsoft.com/en-us/sql/relational-databases/clr-integration-database-objects-user-defined-functions/clr-user-defined-functions +[CLR Table-Valued Function]:https://docs.microsoft.com/en-us/sql/relational-databases/clr-integration-database-objects-user-defined-functions/clr-table-valued-functions +[CLR User-Defined Aggregates]:https://docs.microsoft.com/en-us/sql/relational-databases/clr-integration-database-objects-user-defined-functions/clr-user-defined-aggregates +[CLR User-Defined Types]:https://docs.microsoft.com/en-us/sql/relational-databases/clr-integration-database-objects-user-defined-types/clr-user-defined-types +[CLR Triggers]:https://docs.microsoft.com/en-us/sql/relational-databases/triggers/create-clr-triggers +[Linked Server]:https://docs.microsoft.com/en-us/sql/relational-databases/linked-servers/linked-servers-database-engine + +**[⬆ back to top](#table-of-contents)** + + + +## SQL Server Data Types Recommendation + +More details about SQL Server data types and mapping it with another databases and program languages you can find [here](https://github.com/ktaranov/sqlserver-kit/blob/master/SQL%20Server%20Data%20Types.md) + +| General Type | Type | ANSI | Recommended | What use instead | Why use or not | +|----------------------|---------------------|------|----------------|--------------------|------------------------------------------------------------------------------------| +| Exact Numerics | [bit] | No | *Maybe* | [tinyint][1] | `bit` convert any number (except 0) to 1, 0 converted to 0 | +| Exact Numerics | [tinyint][1] | No | *Maybe* | [int][1] | for saving 3 bytes compare to `int` data type or for replacing `bit` data type | +| Exact Numerics | [smallint][1] | Yes | *Maybe* | [int][1] | for saving 2 bytes compare to `int` data type | +| Exact Numerics | [int][1] | Yes | Yes | - | | +| Exact Numerics | [bigint][1] | No | Yes | [int][1] | if you work more than 2^31 numbers. | +| Exact Numerics | [decimal][2] | Yes | Yes | - | | +| Exact Numerics | [smallmoney][3] | No | *Maybe* | [decimal][2] | [possibility to loss precision due to rounding errors][9] | +| Exact Numerics | [money][3] | No | *Maybe* | [decimal][2] | [possibility to loss precision due to rounding errors][9] | +| Approximate Numerics | [real][4] | Yes | Yes | - | | +| Approximate Numerics | [float][4](1-24) | Yes | No | [real][4] | SQL Server automatically converts `float(1-24)` to `real` data type | +| Approximate Numerics | [float][4](24-53) | Yes | Yes | - | | +| Date and Time | [date] | Yes | Yes | - | | +| Date and Time | [smalldatetime] | No | *Maybe* | [date] | | +| Date and Time | [time] | Yes | Yes | - | | +| Date and Time | [datetime2] | No | Yes | - | | +| Date and Time | [datetime] | Yes | *Maybe* | [datetime2] | [On the Advantages of DateTime2(n) over DateTime] | +| Date and time | [datetimeoffset] | No | Yes | - | | +| Character Strings | [char][5] | Yes | *Maybe* | [varchar][5] | Save 1 byte from `varchar`, but be ready for trailing spaces | +| Character Strings | [varchar][5] | Yes | Yes | - | | +| Character Strings | [varchar(max)][5] | Yes | Yes | - | | +| Character Strings | [nchar][6] | Yes | *Maybe* | [nvarchar][6] | | +| Character Strings | [nvarchar][6] | Yes | Yes | - | | +| Character Strings | [nvarchar(max)][6] | Yes | Yes | - | | +| Character Strings | [ntext][7] | No | **Deprecated** | [nvarchar(max)][6] | [NVARCHAR(MAX) VS NTEXT in SQL Server] | +| Character Strings | [text][7] | No | **Deprecated** | [varchar(max)][6] | [Differences Between Sql Server TEXT and VARCHAR(MAX) Data Type] | +| Binary Strings | [image][7] | No | **Deprecated** | [varbinary(max)][8]| [VARBINARY(MAX) Tames the BLOB] | +| Binary Strings | [binary][8] | Yes | **Deprecated** | [varbinary][8] | [Conversions between any data type and the binary data types are not guaranteed][8]| +| Binary Strings | [varbinary][8] | Yes | Yes | - | | +| Binary Strings | [varbinary(max)][8] | Yes | Yes | - | | +| Other Data Types | [cursor] | No | Yes | - | | +| Other Data Types | [sql_variant] | No | Yes | - | | +| Other Data Types | [hierarchyid] | No | Yes | - | | +| Other Data Types | [rowversion] | No | *Maybe* | - | | +| Other Data Types | [timestamp] | No | **Deprecated** | [rowversion] | it is just synonym to [rowversion] data type and must be [removed][] | +| Other Data Types | [uniqueidentifier] | No | Yes | - | | +| Other Data Types | [xml] | Yes | Yes | - | | +| Other Data Types | [table] | No | *Maybe* | - | | +| Spatial Data Types | [geometry] | No | Yes | - | | +| Spatial Data Types | [geography] | No | Yes | - | | + +[1]:https://docs.microsoft.com/sql/t-sql/data-types/int-bigint-smallint-and-tinyint-transact-sql +[2]:https://docs.microsoft.com/sql/t-sql/data-types/decimal-and-numeric-transact-sql +[3]:https://docs.microsoft.com/sql/t-sql/data-types/money-and-smallmoney-transact-sql +[4]:https://docs.microsoft.com/sql/t-sql/data-types/float-and-real-transact-sql +[5]:https://docs.microsoft.com/sql/t-sql/data-types/char-and-varchar-transact-sql +[6]:https://docs.microsoft.com/sql/t-sql/data-types/nchar-and-nvarchar-transact-sql +[7]:https://docs.microsoft.com/sql/t-sql/data-types/ntext-text-and-image-transact-sql +[8]:https://docs.microsoft.com/sql/t-sql/data-types/binary-and-varbinary-transact-sql +[9]:https://www.red-gate.com/hub/product-learning/sql-prompt/avoid-use-money-smallmoney-datatypes + +[bit]:https://docs.microsoft.com/sql/t-sql/data-types/bit-transact-sql +[date]:https://docs.microsoft.com/sql/t-sql/data-types/date-transact-sql +[smalldatetime]:https://docs.microsoft.com/sql/t-sql/data-types/smalldatetime-transact-sql +[time]:https://docs.microsoft.com/sql/t-sql/data-types/time-transact-sql +[datetime2]:https://docs.microsoft.com/sql/t-sql/data-types/datetime2-transact-sql +[datetime]:https://docs.microsoft.com/sql/t-sql/data-types/datetime-transact-sql +[datetimeoffset]:https://docs.microsoft.com/sql/t-sql/data-types/datetimeoffset-transact-sql +[cursor]:https://docs.microsoft.com/sql/t-sql/data-types/cursor-transact-sql +[sql_variant]:https://docs.microsoft.com/sql/t-sql/data-types/sql-variant-transact-sql +[hierarchyid]:https://docs.microsoft.com/sql/t-sql/data-types/hierarchyid-data-type-method-reference +[rowversion]:https://docs.microsoft.com/sql/t-sql/data-types/rowversion-transact-sql +[timestamp]:https://docs.microsoft.com/sql/t-sql/data-types/rowversion-transact-sql#remarks +[uniqueidentifier]:https://docs.microsoft.com/sql/t-sql/data-types/uniqueidentifier-transact-sql +[xml]:https://docs.microsoft.com/sql/t-sql/xml/xml-transact-sql +[table]:https://docs.microsoft.com/sql/t-sql/data-types/table-transact-sql +[geometry]:https://docs.microsoft.com/sql/t-sql/spatial-geometry/spatial-types-geometry-transact-sql +[geography]:https://docs.microsoft.com/sql/t-sql/spatial-geography/spatial-types-geography +[On the Advantages of DateTime2(n) over DateTime]:http://www.sqltact.com/2012/12/on-advantages-of-datetime2n-over.html +[Differences Between Sql Server TEXT and VARCHAR(MAX) Data Type]:https://sqlhints.com/2016/05/11/differences-between-sql-server-text-and-varcharmax-data-type/ +[NVARCHAR(MAX) VS NTEXT in SQL Server]:https://www.sqlservercurry.com/2010/07/nvarcharmax-vs-ntext-in-sql-server.html +[VARBINARY(MAX) Tames the BLOB]:https://www.itprotoday.com/microsoft-visual-studio/varbinarymax-tames-blob +[removed]:https://feedback.azure.com/forums/908035-sql-server/suggestions/32889865-deprecate-timestamp-the-keyword-not-rowversion-i + +**[⬆ back to top](#table-of-contents)** + + +## SQL Server Function Recommendations +This is only recommendations! But it is consistent for choosing only 1 function from possibles alterntives and use only it. + +| Not Recommended | Recommended | When and Why | More details | +|-----------------------|------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------| +| [`!=`][12] | [`<>`][12] | `<>` is [`ANSI`], `!=` not `ANSI`, [`<>` and `!=` are identical][13] | [13] | +| [`CONVERT`][10] | [`CAST`][10] | `CAST` is [`ANSI`] | [14],[15] | +| [`ISNULL`] | [`COALECSE`] | `COALECSE` is [`ANSI`] and supports more than two arguments, `ISNULL` has dangerous behaviour with possibility to implicit triming string | [16],[17] | +| [`DATEDIFF`] | [`DATEADD`] | The predicate `MyDateTime < DATEADD(SECOND, -1, GETUTCDATE())` syntax is [`SARGable`] | [18],[19] | +| [`SELECT`] | [`SET`] | Using `SET` (is [`ANSI`]) instead of `SELECT` when assigning variables due to properly work with `Msg 501 Subquery returned more than 1 value` | [20],[21],[22] | +| [`STR`] | [`CAST`][10] | `STR` is not [`ANSI`], extremly slow, don't use more than 15 digits, and has rounding problem - use `CAST` plus concatenate instead `STR` | [23] | +| [`ISNUMERIC`] | [`TRY_CONVERT`] | `ISNUMERIC` can often lead to data type conversion errors, when importing data. For SQL Server below 2012 use `WHERE` with `LIKE`. | [24] | +| [`GETDATE`] | [`SYSUTCDATETIME`] | Daylight Saving Time and other factors can play havoc with our dates and times, rounding to the nearest 3 milliseconds. | [25] | +| [`GETUTCDATE`] | [`SYSUTCDATETIME`] | Daylight Saving Time and other factors can play havoc with our dates and times, rounding to the nearest 3 milliseconds. | [25] | +| [`SYSDATETIME`] | [`SYSUTCDATETIME`] | Daylight Saving Time and other factors can play havoc with our dates and times, rounding to the nearest 3 milliseconds. | [25] | +| [`CURRENT_TIMESTAMP`] | [`SYSUTCDATETIME`] | It's too similar to the poorly-named TIMESTAMP data type, which has nothing to do with dates and times and should be called `ROWVERSION`. | [26] | +| [`DATETIMEFROMPARTS`] | [`DATETIME2FROMPARTS`] | The `datetime` data type returns a value to the nearest three milliseconds, as long as it ends with 0, 3, and 7. This is data corruption by definition. | [26] | +| [`ISDATE`] | [`TRY_CONVERT`] | `ISNUMERIC` can often lead to data type conversion errors, when importing data. For SQL Server below 2012 use `WHERE` with `LIKE`. | [26] | +| [`BETWEEN`] | [`>=`] and [`<=`] | Always use an open-ended range to prevent erroneously including or excluding rows. It's much less complex to find the beginning of the next period than the end of the current period. | [27] | + +[12]:https://docs.microsoft.com/sql/t-sql/language-elements/comparison-operators-transact-sql +[13]:https://dba.stackexchange.com/a/155670/107045 +[14]:https://www.sentryone.com/blog/aaronbertrand/backtobasics-cast-vs-convert +[15]:https://nakulvachhrajani.com/2011/07/18/cast-vs-convert-is-there-a-difference-as-far-as-sql-server-is-concerned-which-is-better/ +[`COALECSE`]:https://docs.microsoft.com/sql/t-sql/language-elements/coalesce-transact-sql +[`ISNULL`]:https://docs.microsoft.com/sql/t-sql/functions/isnull-transact-sql +[16]:https://www.mssqltips.com/sqlservertip/2689/deciding-between-coalesce-and-isnull-in-sql-server/ +[17]:https://nocolumnname.blog/2017/10/09/a-subtle-difference-between-coalesce-and-isnull/ +[`DATEADD`]:https://docs.microsoft.com/en-us/sql/t-sql/functions/dateadd-transact-sql +[`DATEDIFF`]:https://docs.microsoft.com/en-us/sql/t-sql/functions/datediff-transact-sql +[`SARGable`]:https://www.sqlshack.com/how-to-use-sargable-expressions-in-t-sql-queries-performance-advantages-and-examples/ +[18]:https://michaeljswart.com/2017/12/when-measuring-timespans-try-dateadd-instead-of-datediff/ +[19]:https://dba.stackexchange.com/q/132437/107045 +[`SET`]:https://docs.microsoft.com/en-gb/sql/t-sql/language-elements/set-local-variable-transact-sql +[`SELECT`]:https://docs.microsoft.com/en-gb/sql/t-sql/language-elements/select-local-variable-transact-sql +[20]:https://assets.red-gate.com/community/books/defensive-database-programming.pdf +[21]:https://www.mssqltips.com/sqlservertip/1888/when-to-use-set-vs-select-when-assigning-values-to-variables-in-sql-server/ +[22]:http://vyaskn.tripod.com/differences_between_set_and_select.htm +[`STR`]:https://docs.microsoft.com/en-us/sql/t-sql/functions/str-transact-sql +[23]:https://www.sqlservercentral.com/articles/hidden-formatting-troubles-with-str-sql-spackle +[`ISNUMERIC`]:https://docs.microsoft.com/en-us/sql/t-sql/functions/isnumeric-transact-sql +[`TRY_CONVERT`]:https://docs.microsoft.com/en-us/sql/t-sql/functions/try-convert-transact-sql +[24]:https://www.red-gate.com/hub/product-learning/sql-prompt/sql-prompt-code-analysis-avoid-using-isnumeric-function-e1029 +[25]:https://bornsql.ca/blog/dates-times-sql-server-t-sql-functions-get-current-date-time/ +[`GETDATE`]:https://docs.microsoft.com/sql/t-sql/functions/getdate-transact-sql +[`SYSUTCDATETIME`]:https://docs.microsoft.com/en-gb/sql/t-sql/functions/sysutcdatetime-transact-sql +[`GETUTCDATE`]:https://docs.microsoft.com/sql/t-sql/functions/getutcdate-transact-sql +[`SYSDATETIME`]:https://docs.microsoft.com/sql/t-sql/functions/sysdatetime-transact-sql +[`CURRENT_TIMESTAMP`]:https://docs.microsoft.com/sql/t-sql/functions/current-timestamp-transact-sql +[26]:https://bornsql.ca/blog/dates-and-times-in-sql-server-more-functions-you-should-never-use/ +[`DATETFROMPARTS`]:https://docs.microsoft.com/sql/t-sql/functions/datefromparts-transact-sql +[`DATETIMEFROMPARTS`]:https://docs.microsoft.com/sql/t-sql/functions/datetimefromparts-transact-sql +[`DATETIME2FROMPARTS`]:https://docs.microsoft.com/sql/t-sql/functions/datetime2fromparts-transact-sql +[`ISDATE`]:https://docs.microsoft.com/sql/t-sql/functions/isdate-transact-sql +[`BETWEEN`]:https://docs.microsoft.com/sql/t-sql/language-elements/between-transact-sql +[`>=`]:https://docs.microsoft.com/en-us/sql/t-sql/language-elements/greater-than-or-equal-to-transact-sql +[`<=`]:https://docs.microsoft.com/en-us/sql/t-sql/language-elements/less-than-or-equal-to-transact-sql +[27]:https://www.mssqltips.com/sqlservertip/5206/sql-server-datetime-best-practices/ + +**[⬆ back to top](#table-of-contents)** + + + ## T-SQL Programming Style -SQL Server TSQL Coding Conventions, Best Practices, and Programming Guidelines - -### General programming style - - Delimiters: spaces (not tabs) - - No square brackets [] and reserved words in object names and alias, use only Latin symbols **[A-z]** and numeric **[0-9]** - - Prefer [ANSI syntax](http://standards.iso.org/ittf/PubliclyAvailableStandards/c053681_ISO_IEC_9075-1_2011.zip) and functions - - All finished expressions should have `;` at the end (this is ANSI standard and Microsoft announced with the SQL Server 2008 release that semicolon statement terminators will become mandatory in a future version so statement terminators other than semicolons (whitespace) are currently deprecated. This deprecation announcement means that you should always use semicolon terminators in new development.) - More details [here](http://www.dbdelta.com/always-use-semicolon-statement-terminators/) - - All script files should end with `GO` and line break - - The first argument in SELECT expression should be on the same line with it: `SELECT LastName` - - Arguments are divided by line breaks, commas should be placed before an argument: +SQL Server T-SQL Coding Conventions, Best Practices, and Programming Guidelines. + + + +### General programming T-SQL style + + - For database objects names in code use only schema plus object name, do not hardcode server and database names in your code: + ```tsql + /* good */ + CREATE TABLE dbo.MyTable (MyColumn int); + + /* bad*/ + CREATE TABLE PRODSERVER.PRODDB.dbo.MyTable (MyColumn int); + CREATE TABLE MyTable (MyColumn int); + ``` + More details [here](https://www.red-gate.com/simple-talk/opinion/editorials/why-you-shouldnt-hardcode-the-current-database-name-in-your-views-functions-and-stored-procedures/), + [here](https://www.sqlserverscience.com/basics/on-default-schemas-and-search-paths/), + [here](https://www.red-gate.com/hub/product-learning/sql-prompt/finding-code-smells-using-sql-prompt-procedures-lack-schema-qualification), + [here](https://sqlstudies.com/2020/06/22/i-created-a-table-and-sql-created-a-schema-and-a-user/), + [here](https://sqlperformance.com/2014/11/t-sql-queries/multiple-plans-identical-query), + [here](https://sqlblog.org/2019/09/12/bad-habits-to-kick-avoiding-the-schema-prefix). + - Delimiters: **spaces** (not tabs). + - Always use multi-line comment `/* */` instead in-line comment `--` in production code due to potential formating problems in different tools and programs. + More details [here](https://www.brentozar.com/archive/2021/04/never-ever-ever-start-t-sql-comments-with-two-dashes/), [here](https://sqlkover.com/ssis-and-the-ora-00907-missing-right-parenthesis-error/), and [here](https://docs.microsoft.com/troubleshoot/sql/admin/crashes-run-oracle-linked-server-query). + - Never use asterisk (`*`) in select statements `SELECT *` and `INSERT` statements, use explicit column names. + Main problems are: traffic issues, Memory Grants issues, Index usage issues. + **Only one exception, see it below.** + More details [here](https://www.red-gate.com/hub/product-learning/sql-prompt/finding-code-smells-using-sql-prompt-asterisk-select-list), + [here](https://sqlblog.org/2009/10/10/bad-habits-to-kick-using-select-omitting-the-column-list), + [here](https://dba.stackexchange.com/q/253873/107045), + [here](https://www.erikdarlingdata.com/sql-server/all-the-problems-with-select/). + - Use asterisk (`*`) **ONLY** in an archiving situation, where rows are being moved to another table that must have the same structure. + ```sql + INSERT INTO SalesOrderArchive /* Note no column list */ + SELECT * + FROM SalesOrder + WHERE OrderDate < @OneYearAgo; + + DELETE FROM SalesOrder + WHERE OrderDate < @OneYearAgo; + ``` + If a new column is added to `SalesOrder` table in the future, but not to `SalesOrderArchive`, the `INSERT` will fail. + Which sounds bad, but it's actually a really good thing! Because the alternative is much worse. + If all the columns were listed on the `INSERT` and the `SELECT`, then the `INSERT` would succeed, and so would the following `DELETE` (which is effectively `DELETE *`). + Production code that succeeds doesn't get any attention, and it may be a long time before someone notices that the new column is not being archived, but being silently deleted altogether. + More details [here](https://dba.stackexchange.com/a/253917/107045). + - No square brackets `[]` and [reserved words](https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Check_Reserved_Words_For_Object_Names.sql) in object names and alias, use only Latin symbols **`[A-z]`** and numeric **`[0-9]`**. + - Prefer [`ANSI`](http://standards.iso.org/ittf/PubliclyAvailableStandards/c053681_ISO_IEC_9075-1_2011.zip) syntax and functions ([`CAST`][10] instead [`CONVERT`][10], [`COALESE`](https://docs.microsoft.com/en-us/sql/t-sql/language-elements/coalesce-transact-sql) instead [`ISNULL`](https://docs.microsoft.com/en-us/sql/t-sql/functions/isnull-transact-sql), etc.). + - All finished expressions should have semicolon `;` at the end. + This is [`ANSI`] standard and Microsoft announced with the SQL Server 2008 release that semicolon statement terminators will become mandatory in a future version so statement terminators other than semicolons (whitespace) are currently deprecated. + This deprecation announcement means that you should always use semicolon terminators in new development. + From [Transact-SQL Syntax Conventions (Transact-SQL)](https://docs.microsoft.com/en-us/sql/t-sql/language-elements/transact-sql-syntax-conventions-transact-sql): + > Although the semicolon isn't required for most statements in this version of SQL Server, it will be required in a future version. + + More details [here](http://www.dbdelta.com/always-use-semicolon-statement-terminators/), [here](https://www.brentozar.com/archive/2015/12/give-your-t-sql-a-semicolonoscopy/), and [here](https://sqlblog.org/2009/09/03/ladies-and-gentlemen-start-your-semi-colons). + Semicolon is mandority for: + 1. [Common table expression `WITH CTE `](https://docs.microsoft.com/sql/t-sql/queries/with-common-table-expression-transact-sql): + > When a CTE is used in a statement that is part of a batch, the statement before it must be followed by a semicolon. + 2. [`Merge`](https://docs.microsoft.com/sql/t-sql/statements/merge-transact-sql) statements: + > The MERGE statement requires a semicolon (;) as a statement terminator. Error 10713 is raised when a MERGE statement is run without the terminator. + 3. [`TROW`](https://docs.microsoft.com/sql/t-sql/language-elements/throw-transact-sql) exceptions: + > The statement before the THROW statement must be followed by the semicolon (;) statement terminator. + 4. All [Service Broker statements](https://docs.microsoft.com/sql/t-sql/statements/send-transact-sql): + > If the SEND statement isn't the first statement in a batch or stored procedure, the preceding statement must be terminated with a semicolon (;). + - All script files should end with `GO` and line break. This is neccesary for batching scripts run throw `sqlcmd` or another tools. + - Keywords should be in **UPPERCASE**: `SELECT`, `FROM`, `GROUP BY` etc. This increases the readability of the code. + - Data types declaration should be in **lowercase**: `varchar(30)`, `int`, `real`, `nvarchar(max)` etc. + More details [here](https://www.sentryone.com/blog/aaronbertrand/backtobasics-lower-case-data-types). + - All system database and tables must be in **lowercase** for properly working for Case Sensitive instance: `master, sys.tables …`. + - Do not use [nested transactions](https://docs.microsoft.com/en-us/sql/ado/guide/data/transaction-processing#nested-transactions). + The commit of a nested transaction has absolutely no effect – as the only transaction that really exists as far as SQL Server is concerned is the outer one. + More details [here](https://www.sqlskills.com/blogs/paul/a-sql-server-dba-myth-a-day-2630-nested-transactions-are-real/). + - Whenever you have data modification on non-temporary tables, is to use [explicit transactions] over [autocommit]. + 1. If you have a stored procedure which is simply running a `SELECT` statement, use [autocommit]. + 2. If you have a stored procedure which performs data modification on non-temporary tables, use an [explicit transactions] only over the area which modifies data. + 3. If you are working with non-global temporary tables beforehand, don’t include any modification of those inside the explicit transaction. + 4. In a [loop](https://docs.microsoft.com/en-us/sql/t-sql/language-elements/while-transact-sql), choose whether you want to put the [explicit transactions] around the loop or inside it. In most cases, prefer to put the transaction inside the loop to minimize the amount of time that blocking other users. + 5. Outside of a stored procedure use [explicit transactions] if you’re doing something potentially risky. + 6. Watch out for nested transactions. In SQL Server, there’s very little utility in them and their behavior is weird. [Paul Randal explains in great detail just how broken they are](https://www.sqlskills.com/blogs/paul/a-sql-server-dba-myth-a-day-2630-nested-transactions-are-real/). + More details [here](https://36chambers.wordpress.com/2020/08/10/transaction-modes-in-sql-server/). + - Avoid using [Cross-Database Queries](https://docs.microsoft.com/en-us/sql/relational-databases/in-memory-oltp/cross-database-queries) because it increase backup/restore complexity (you restore one database, then realise you don’t have log backups to bring the other database to the same point in time). + Also Azure SQL Database does not support cross-database queries and you can not migrate into in future. + - Use `temp` tables to reduce network trafic, decrease query complexity and also to get better estimates for modification queries. More details [here](https://www.brentozar.com/archive/2020/04/how-to-get-better-estimates-for-modification-queries/). + - When more than one logical operator is used always use parentheses, even when they are not required. + This can improve the readability of queries, and reduce the chance of making a subtle mistake because of operator precedence. + There is no significant performance penalty in using parentheses. More details [here](https://docs.microsoft.com/en-us/sql/relational-databases/query-processing-architecture-guide#logical-operator-precedence). ```sql - SELECT FirstName - , LastName + SELECT + ProductID + FROM Production.Product + WHERE (ProductModelID = 20 OR ProductModelID = 21) + AND Color = 'Red'; + + ``` + - Always use aliases for table names. More details [here](https://sqlinthewild.co.za/index.php/2019/04/23/no-this-is-not-a-bug-in-t-sql/). + - Whenever you’re working with multiple tables in a join (explicit or, like this one, implicit), always specify which table each column comes from. Even if your code works just fine today, just adding an unfortunately named column many years later can break your code. More details [here](https://sqlsunday.com/2020/12/21/the-uncorrelated-correlated-subquery/). + - Avoid non-standard column and table aliases, use, if required, double-quotes for special characters and always `AS` keyword before alias: + ```sql + SELECT + p.LastName AS "Last Name" + FROM dbo.Person AS p; ``` - - Keywords and data types declaration should be in **UPPERCASE** - - `FROM, WHERE, INTO, JOIN, GROUP BY, ORDER BY` expressions should be aligned so, that all their arguments are placed under each other - - All objects must used with schema names but without database and server name: `FROM dbo.Table` - - All system database and tables must be in lower case for properly working in Case Sensitive instance - - For demo queries use TOP(100) or lower value because SQL Server SQL Server uses one sorting method for TOP 1-100 rows, and a different one for 101+ rows - More details [here](https://www.brentozar.com/archive/2017/09/much-can-one-row-change-query-plan-part-2/) + More details [here](https://www.red-gate.com/hub/product-learning/sql-prompt/sql-prompt-code-analysis-avoid-non-standard-column-aliases). + All possible ways using aliases in SQL Server: + + ```tsql + /* Recommended due to ANSI */ + SELECT SCHEMA_NAME(schema_id) + '.' + "name" AS "Tables" FROM sys.tables; -Example: + /* Not recommended but possible */ + SELECT SCHEMA_NAME(schema_id) + '.' + [name] AS "Tables" FROM sys.tables; + SELECT Tables = SCHEMA_NAME(schema_id) + '.' + [name] FROM sys.tables; + SELECT "Tables" = SCHEMA_NAME(schema_id) + '.' + [name] FROM sys.tables; + SELECT [Tables] = SCHEMA_NAME(schema_id) + '.' + [name] FROM sys.tables; + SELECT 'Tables' = SCHEMA_NAME(schema_id) + '.' + [name] FROM sys.tables; + SELECT SCHEMA_NAME(schema_id) + '.' + [name] [Tables] FROM sys.tables; + SELECT SCHEMA_NAME(schema_id) + '.' + [name] 'Tables' FROM sys.tables; + SELECT SCHEMA_NAME(schema_id) + '.' + [name] "Tables" FROM sys.tables; + SELECT SCHEMA_NAME(schema_id) + '.' + [name] Tables FROM sys.tables; + SELECT SCHEMA_NAME(schema_id) + '.' + [name] AS [Tables] FROM sys.tables; + SELECT SCHEMA_NAME(schema_id) + '.' + [name] AS 'Tables' FROM sys.tables; + SELECT SCHEMA_NAME(schema_id) + '.' + [name] AS Tables FROM sys.tables; + ``` + - Always consider using an explicit range condition when comparing dates for properly make use of an index. More details [here](https://use-the-index-luke.com/sql/where-clause/obfuscation/dates). + ```tsql + /* bad */ + SELECT sale_date + FROM sales + WHERE YEAR(sale_date) >= 1970 + AND YEAR(sale_date) < 1971; + + /* good */ + SELECT sale_date + FROM sales + WHERE sale_date >= CAST('1970-01-01' AS date) + AND sale_date < CAST('1971-01-01', AS date); + ``` + + - The first argument in `SELECT` expression should be on the next line: + ```sql + SELECT + FirstName + ``` + - Arguments are divided by line breaks, commas should be placed before an argument: + ```sql + SELECT + FirstName + , LastName + ``` + - For SQL Server >= 2012 use [`FETCH-OFFSET`] instead [`TOP`]. + More details [here](https://docs.microsoft.com/en-us/sql/t-sql/queries/select-order-by-clause-transact-sql#using-offset-and-fetch-to-limit-the-rows-returned). + But if you use [`TOP`] avoid use [`TOP`] in a `SELECT` statement without an `ORDER BY`. + More details [here](https://www.red-gate.com/hub/product-learning/sql-prompt/finding-code-smells-using-sql-prompt-top-without-order-select-statement). + - If you using [`TOP`] (instead recommended [`FETCH-OFFSET`]) function with round brackets because [`TOP`] has supports use of an expression, such as `(@Rows*2)`, or a sub query: `SELECT TOP(100) LastName …`. + More details [here](https://www.red-gate.com/hub/product-learning/sql-prompt/sql-prompt-code-analysis-avoiding-old-style-top-clause). + Also [`TOP`] without brackets does not work with `UPDATE` and `DELETE` statements. + ```tsql + /* Not working without brackets () */ + DECLARE @n int = 1; + SELECT TOP@n name FROM sys.objects; + ``` + - For demo queries use `TOP(100)` or lower value because SQL Server uses one sorting method for `TOP` 1-100 rows, and a different one for 101+ rows. + More details [here](https://www.brentozar.com/archive/2017/09/much-can-one-row-change-query-plan-part-2/) and [here](https://sqlsunday.com/2020/12/08/the-curious-case-of-the-top-n-sort/). +- Avoid specifying integers in the `ORDER BY` clause as positional representations of the columns in the select list. + The statement with integers is not as easily understood by others compared with specifying the actual column name. + In addition, changes to the select list, such as changing the column order or adding new columns, requires modifying the `ORDER BY` clause in order to avoid unexpected results. + More details [here](https://docs.microsoft.com/en-us/sql/t-sql/queries/select-order-by-clause-transact-sql#best-practices). + ```sql + /* bad */ + SELECT ProductID, Name FROM production.Production ORDER BY 2; -```sql + /* good */ + SELECT ProductID, Name FROM production.Production ORDER BY Name; + ``` + + - Avoid wrapping functions around columns specified in the `WHERE` and `JOIN` clauses. + Doing so makes the columns non-deterministic and prevents the query processor from using indexes. + - Use `NULL` or `NOT NULL` for each column in a temporary table. The [`ANSI_NULL_DFLT_ON`](https://docs.microsoft.com/en-us/sql/t-sql/statements/set-ansi-null-dflt-on-transact-sql) option control the way the Database Engine assigns the `NULL` or `NOT NULL` attributes to columns when these attributes are not specified in a `CREATE TABLE` or `ALTER TABLE` statement. + If a connection executes a procedure with different settings for these options than the connection that created the procedure, the columns of the table created for the second connection can have different nullability and exhibit different behavior. If `NULL` or `NOT NULL` is explicitly stated for each column, the temporary tables are created by using the same nullability for all connections that execute the procedure. + - Use modification statements that convert nulls and include logic that eliminates rows with null values from queries. Be aware that in Transact-SQL, `NULL` is not an empty or "nothing" value. It is a placeholder for an unknown value and can cause unexpected behavior, especially when querying for result sets or using AGGREGATE functions. + - Use the `UNION ALL` operator instead of the `UNION` or `OR` operators, unless there is a specific need for distinct values. + The `UNION ALL` operator requires less processing overhead because duplicates are not filtered out of the result set. + - Avoid using `INSERT INTO` a permanent table with `ORDER BY`. + More details [here](https://www.red-gate.com/hub/product-learning/sql-prompt/sql-prompt-code-analysis-insert-permanent-table-order-pe020). + - Avoid using shorthand (`wk, yyyy, d` etc.) with date/time operations, use full names: `month, day, year`. + More details [here](https://sqlblog.org/2011/09/20/bad-habits-to-kick-using-shorthand-with-date-time-operations) and [here][27]. + - Avoid ambiguous formats for date-only literals, use `CAST('yyyymmdd' AS DATE)` format. + - Avoid treating dates like strings and avoid calculations on the left-hand side of the `WHERE` clause. + More details [here](https://sqlblog.org/2009/10/16/bad-habits-to-kick-mis-handling-date-range-queries). + - Avoid using [hints](https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql) except `RECOMPILE` if needed and `NOEXPAND` (see next tip). + More details [here](https://www.red-gate.com/hub/product-learning/sql-prompt/sql-prompt-code-analysis-a-hint-is-used-pe004-7). + - Use [`NOEXPAND`](https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-table#using-noexpand) hint for [indexed views](https://docs.microsoft.com/sql/relational-databases/views/create-indexed-views) on non enterprise editions and Prior to SQL Server 2016 (13.x) SP1 to let the query optimizer know that we have indexes. + More details [here](https://bornsql.ca/blog/using-indexed-views-dont-forget-this-important-tip/). + - Use [`LOOP JOIN`](https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-query#arguments) and [`FAST 1`](https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-query#arguments) query hints for deleting huge number of rows with `ON DELETE CASCADE` foreign keys specification. + More details [here](https://dba.stackexchange.com/a/262116). + - If you use [hints] always use it with `WITH` keyword because omitting the `WITH` keyword is a deprecated feature and will be removed from future Microsoft SQL Server versions. + One benefit of using the `WITH` keyword is that you can specify multiple table hints using the WITH keyword against the same table. + More details [here](https://www.sqlshack.com/understanding-impact-clr-strict-security-configuration-setting-sql-server-2017/). + - Avoid use of `SELECT…INTO` for production code, use instead `CREATE TABLE` + `INSERT INTO …` approach. More details [here](https://www.red-gate.com/hub/product-learning/sql-prompt/use-selectinto-statement). + - Use only ISO standard JOINS syntaxes. The *old style* Microsoft/Sybase `JOIN` style for SQL, which uses the `=*` and `*=` syntax, has been deprecated and is no longer used. + Queries that use this syntax will fail when the database engine level is 10 (SQL Server 2008) or later (compatibility level 100). The ANSI-89 table citation list (`FROM tableA, tableB`) is still ISO standard for `INNER JOINs` only. Neither of these styles are worth using. + It is always better to specify the type of join you require` INNER`, `LEFT OUTER`, `RIGHT OUTER`, `FULL OUTER` and `CROSS`, which has been standard since ANSI SQL-92 was published. While you can choose any supported `JOIN `style, without affecting the query plan used by SQL Server, using the ANSI-standard syntax will make your code easier to understand, more consistent, and portable to other relational database systems. + More details [here](https://www.red-gate.com/hub/product-learning/sql-prompt/finding-code-smells-using-sql-prompt-old-style-join-syntax-st001). + - Do not use a scalar user-defined function (UDF) in a `JOIN` condition, `WHERE` search condition, or in a `SELECT` list, unless the function is [schema-bound](https://docs.microsoft.com/en-us/sql/t-sql/statements/create-function-transact-sql#best-practices). + More details [here](https://www.red-gate.com/hub/product-learning/sql-prompt/misuse-scalar-user-defined-function-constant-pe017). + - For scalar function use [`WITH SCHEMABINDING`](https://docs.microsoft.com/en-us/sql/t-sql/statements/create-function-transact-sql#best-practices) option to get a performance boost. More details [here](https://bertwagner.com/2018/12/04/two-words-for-faster-scalar-functions/) + - Do not use [`INFORMATION_SCHEMA`] views to determine the schema of an object. [`INFORMATION_SCHEMA`] views only represent a **subset of the metadata** of an object. + The only reliable way to find the schema of a object is to query the [`sys.objects`](https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-objects-transact-sql) catalog view. [`INFORMATION_SCHEMA`] does not represent every possible state of the objects in SQL. For example, [`filtered indexes`](https://docs.microsoft.com/en-us/sql/relational-databases/indexes/create-filtered-indexes). The [`INFORMATION_SCHEMA`] are incomplete. + More details [here](https://github.com/MicrosoftDocs/sql-docs/issues/4188). + - Do not use explicit transactions for DML and DDL especially for reorganize index because the locking behavior of this statemnets becomes more restrictive. + More details [here](https://github.com/MicrosoftDocs/sql-docs/pull/4011). + - In [sqlcmd](https://docs.microsoft.com/en-us/sql/tools/sqlcmd-utility) move the `-U`and `-P` parameters after the `-Q` parameter so that the password is at the end of the command. + More details [here](https://bornsql.ca/blog/the-curious-case-of-the-sqlcmd-password/) + ``` + sqlcmd -S MSSQLSERVER$EXPRESS -Q "dbcc checkdb ('master') with DATA_PURITY, NO_INFOMSGS;" -U maintenanceUser -P ""weirdPassword + ``` + - Only update rows that changed? Try using `EXISTS` and `EXCEPT` for perfomance reasons and code readanlity.More details [here](https://chadbaldwin.net/2020/12/30/only-update-rows-that-changed). + - Use `EXISTS` or `NOT EXISTS` if referencing a subquery, and `IN` or `NOT IN` when have a list of literal values. + More details [here](https://www.brentozar.com/archive/2018/08/a-common-query-error/). + - For concatenate unicode strings: + - always using the upper-case `N`; + - always store into a variable of type `nvarchar(max)`; + - avoid truncation of string literals, simply ensure that one piece is converted to `nvarchar(max)`. + Example: + ```tsql + /* good */ + DECLARE @nvcmaxVariable nvarchar(max); + SET @nvcmaxVariable = CAST(N'ಠ russian anomaly ЯЁЪ ಠ ' AS nvarchar(max)) + N'something else' + N'another'; + SELECT @nvcmaxVariable; + ``` + More details [here](https://themondaymorningdba.wordpress.com/2018/09/13/them-concatenatin-blues/). + - Always specify a length to any text-based data type such as `varchar`, `nvarchar`, `char`, `nchar`: + ```tsql + /* bad */ + DECLARE @myBadVarcharVariable varchar; + DECLARE @myBadNVarcharVariable nvarchar; + DECLARE @myBadCharVariable char; + DECLARE @myBadNCharVariable nchar; + + /* good */ + DECLARE @myGoodVarchareVariable varchar(50); + DECLARE @myGoodNVarchareVariable nvarchar(90); + DECLARE @myGoodCharVariable char(7); + DECLARE @myGoodNCharVariable nchar(10); + ``` + More details [here](https://www.red-gate.com/hub/product-learning/sql-prompt/using-a-variable-length-datatype-without-explicit-length-the-whys-and-wherefores) and [here](https://sqlblog.org/2009/10/09/bad-habits-to-kick-declaring-varchar-without-length). + - Use only [`ORIGINAL_LOGIN()`](https://docs.microsoft.com/en-us/sql/t-sql/functions/original-login-transact-sql) function because is the only function that consistently returns the actual login name that we started with regardless of impersonation. + More details [here](https://sqlstudies.com/2015/06/24/which-user-function-do-i-use/). + - Always use `IF` statement with `BEGIN-END` block to prevent errors with multi line statements: + ```tsql + DECLARE @x int = 0; + DECLARE @y int = 1; + + /* bad */ + IF @y > @x + SET @x = @x + 1; + SET @y = @y - 1; + ELSE + PRINT(1); + /* Msg 156, Level 15, State 1, Line 8 + Incorrect syntax near the keyword 'ELSE'. */ + + /* good */ + IF @y > @x + BEGIN + SET @x = @x + 1; + SET @y = @y - 1; + END; + ELSE + BEGIN + PRINT(1); + END; + ``` + - `FROM, WHERE, INTO, JOIN, GROUP BY, ORDER BY` expressions should be aligned so, that all their arguments are placed under each other (see Example below) + +TSQL Example with formating: + +```tsql WITH CTE_MyCTE AS ( - SELECT t1.Value1 AS Val1 - , t1.Value2 AS Val2 - , t2.Value3 AS Val3 - INNER JOIN dbo.Table3 AS t2 - ON t1.Value1 = t2.Value1 - WHERE t1.Value1 > 1 - AND t2.Value2 >= 101 + SELECT + t1.Value1 AS Val1 + , t1.Value2 AS Val2 + , t2.Value3 AS Val3 + INNER JOIN dbo.Table3 AS t2 + ON t1.Value1 = t2.Value1 + WHERE t1.Value1 > 1 + AND t2.Value2 >= 101 ) -SELECT t1.Value1 AS Val1 - , t1.Value2 AS Val2 - , t2.Value3 AS Val3 - INTO #Table3 - FROM CTE_MyCTE AS t1 - ORDER BY t2.Value2; +SELECT + t1.Value1 AS Val1 + , t1.Value2 AS Val2 + , t2.Value3 AS Val3 +INTO #Table3 +FROM CTE_MyCTE AS t1 +ORDER BY t2.Value2; ``` +**[⬆ back to top](#table-of-contents)** + + + ### Stored procedures and functions programming style - - All stored procedures and functions should use ALTER statement and start with the object presence check - - ALTER statement should be preceded by 2 line breaks +Recommendations from Microsoft: [Stored procedure Best practice][11] + + - All stored procedures and functions should use `ALTER` statement and start with the object presence check (see example below) for saving `GRANTs` on your object. + Also if you use Query Store and plan forcing and `DROP` and then `CREATE` new object you loosing plan forcing, more details [here](https://www.scarydba.com/2020/03/02/query-store-plan-forcing-and-drop-create/). + For SQL Server 2016 and higher you can use new `CREATE OR ALTER` statement. + - `ALTER` statement should be preceded by 2 line breaks - Parameters name should be in **camelCase** - Parameters should be placed under procedure name divided by line breaks - - After the ALTER statement and before AS keyword should be placed a comment with execution example - - The procedure or function should begin with parameter check + - After the `ALTER` statement and before `AS` keyword should be placed a comment with execution example + - The procedure or function should begin with parameters checks (see example below) - Create `sp_` procedures only in `master` database - SQL Server will always scan through the system catalog first - - Always use `BEGIN TRY` and `BEGIN CATCH` - - Always use `/* */` instead inline comment `--` - - Use `SET NOCOUNT ON` for stops the message that shows the count of the number of rows affected by a Transact-SQL statement - - Use TOP expression with `()`: -```tsql --- Not working without () -DECLARE @n int = 1; -SELECT TOP@n name FROM sys.objects; -``` + - Always use `BEGIN TRY` and `BEGIN CATCH` for error handling + - Use `SET NOCOUNT ON;` for stops the message that shows the count of the number of rows affected by a Transact-SQL statement and decreasing network traffic. + More details [here](https://www.red-gate.com/hub/product-learning/sql-prompt/finding-code-smells-using-sql-prompt-set-nocount-problem-pe008-pe009) and [here][11]. + - Do not use `SET NOCOUNT OFF;` because it is default behavior + - Use `RAISERROR` instead `PRINT` if you want to give feedback about the state of the currently executing SQL batch without lags. + More details [here](http://sqlity.net/en/984/print-vs-raiserror/) and [here](http://sqlservercode.blogspot.com/2019/01/print-disruptor-of-batch-deletes-in-sql.html). + - Call natively-compiled stored procedures without named parameters. + More details [here](https://sqlperformance.com/2015/06/t-sql-queries/how-not-to-call-hekaton-procedures). - All code should be self documenting - - TSQL code, triggers, stored procedures, functions, should have a standard comment banner: -```tsql -summary: > - This procedure returns an object build script as a single-row, single column - result. -Revisions: - - Author: Bill Gates - Version: 1.1 - Modification: dealt properly with heaps - date: 2017-07-15 - - version: 1.2 - modification: Removed several bugs and got column-level constraints working - date: 2017-06-30 -example: - - code: udf_MyFunction 'testValsue'; -returns: > - single row, single column result Build_Script. + - T-SQL code, triggers, stored procedures, functions, scripts, should have a standard comment-documentation banner: ``` + + Get all databases meta data using dynamic T-SQL + 1 data set: temp table #DatabaseInfo. + No + Konstantin Taranov + 2018-03-01 + 2019-11-14 by Konstantin Taranov + 1.2 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Databases_Report.sql + +``` + +**[⬆ back to top](#table-of-contents)** -Stored Procedure Example: + Stored Procedure Example: -```sql +```tsql IF OBJECT_ID('dbo.usp_StoredProcedure', 'P') IS NULL EXECUTE('CREATE PROCEDURE dbo.usp_StoredProcedure as SELECT 1'); GO -ALTER PROCEDURE dbo.usp_StoredProcedure ( - @parameterValue1 SMALLINT - , @parameterValue2 NVARCHAR(300) - , @debug BIT = 0 +ALTER PROCEDURE dbo.usp_StoredProcedure( + @parameterValue1 smallint + , @parameterValue2 nvarchar(300) + , @debug bit = 0 ) /* -EXECUTE dbo.usp_StoredProcedure - @parameterValue1 = 0 - , @parameterValue2 = N'BULK' + + Simple example of tsql procedure + nothing + No + Konstantin Taranov + 2019-01-01 + 2019-11-25 by Konstantin Taranov + 1.2 + - + EXECUTE dbo.usp_StoredProcedure + @parameterValue1 = 0 + , @parameterValue2 = N'BULK' + */ AS SET NOCOUNT ON; @@ -170,21 +634,178 @@ SET NOCOUNT ON; BEGIN TRY IF (@parameterValue1 < 0 OR @parameterValue2 NOT IN ('SIMPLE', 'BULK', 'FULL')) RAISERROR('Not valid data parameter!', 16, 1); - PRINT @parameterValue2; + IF (@debug) PRINT @parameterValue2; END TRY BEGIN CATCH - -- Print error information. - PRINT 'Error: ' + CONVERT(varchar(50), ERROR_NUMBER()) + - ', Severity: ' + CONVERT(varchar(5), ERROR_SEVERITY()) + - ', State: ' + CONVERT(varchar(5), ERROR_STATE()) + - ', Procedure: ' + ISNULL(ERROR_PROCEDURE(), '-') + - ', Line: ' + CONVERT(varchar(5), ERROR_LINE()) + - ', User name: ' + CONVERT(sysname, CURRENT_USER); + /* Print error information. */ + PRINT 'Error: ' + CAST(ERROR_NUMBER()) AS varchar(50)) + + ', Severity: ' + CAST(ERROR_SEVERITY(), varchar(5)) + + ', State: ' + CAST(ERROR_STATE(), varchar(5) ) + + ', Procedure: ' + COALESCE(ERROR_PROCEDURE(), '-') + + ', Line: ' + CAST(ERROR_LINE(), varchar(5)) + + ', User name: ' + CAST(ORIGINAL_LOGIN(), sysname); PRINT ERROR_MESSAGE(); END CATCH; - -SET NOCOUNT OFF; GO ``` + +**[⬆ back to top](#table-of-contents)** + + + +### Dynamic T-SQL Recommendation + +**Highly recommended to read awesome detailed article about dynamic T-SQL by Erland Sommarskog: [The Curse and Blessings of Dynamic SQL](http://sommarskog.se/dynamic_sql.html)** + +Dynamic SQL is a programming technique that allows you to construct SQL statements dynamically at runtime. +It allows you to create more general purpose and flexible SQL statement because the full text of the SQL statements may be unknown at compilation. +For example, you can use the dynamic SQL to create a stored procedure that queries data against a table whose name is not known until runtime. + +More details [here](http://www.sqlservertutorial.net/sql-server-stored-procedures/sql-server-dynamic-sql/). + +- Do not use [nvarchar(max)][6] for your object’s name parameter, use [sysname](https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2008-r2/ms191240(v=sql.105)?redirectedfrom=MSDN) instead (synonym for nvarchar(128) except that, by default, sysname is NOT NULL). + ```tsql + /* Bad */ + DECLARE @tableName nvarchar(max) = N'MyTableName'; + + /* Good */ + DECLARE @tableName sysname = N'MyTableName'; + ``` +- Do quote the names of your objects properly. + ```tsql + /* Bad */ + DECLARE @tsql nvarchar(max); + DECLARE @tableName sysname = N'My badly named table!'; + SET @tsql = N'SELECT object_id FROM ' + @tableName; + + /* Good */ + DECLARE @tsql nvarchar(max); + DECLARE @tableName sysname = N'My badly named table 111!'; + SET @tsql = N'SELECT object_id FROM ' + QUOTENAME(@tableName); + ``` +- Always use [`sp_executesql`] instead [`EXEC`] to prevent sql injection. + Also [`sp_executesql`] can parameterizing your dynamic statement that means plans can be reused as well (when the value of the dynamic object is the same). + Also [`sp_executesql`] can even be used to output values as well (see example below). + ```tsql + /* Bad EXEC example with sql injection*/ + DECLARE @tsql nvarchar(max); + DECLARE @tableName sysname = N'master.sys.tables; SELECT * FROM master.sys.server_principals;'; + SET @tsql = N'SELECT "name" FROM ' + @tableName + N';'; + EXEC (@tsql); + + /* Good sp_executesql example*/ + DECLARE @tsql nvarchar(max); + DECLARE @tableName sysname = N'master.sys.tables'; + DECLARE @id int = 2107154552; + SET @tsql = N'SELECT name FROM ' + @tableName + + N' WHERE object_id = ' + CONVERT(nvarchar(max), @id); + EXEC sp_executesql @tsql, N'@ID int', @ID = @id; + + /* Good sp_executesql example with OUTPUT */ + DECLARE @tsql nvarchar(max); + DECLARE @tableName sysname = N'master.sys.tables'; + DECLARE @count bigint; + SET @tsql = N'SELECT @countOUT = COUNT(*) FROM ' + @tableName + N';'; + EXEC sp_executesql @tsql, N'@countOUT bigint OUTPUT', @countOUT = @count OUTPUT; + PRINT('@count = ' + CASE WHEN @count IS NULL THEN 'NULL' ELSE CAST(@count AS varchar(30)) END); + ``` +- Do not use dynamic T-SQL if your statement is not dynamic. + ```tsql + /* Bad */ + DECLARE @tsql nvarchar(max); + DECLARE @id int = 2107154552; + SET @tsql = N'SELECT object_id, "name" FROM master.sys.tables WHERE object_id = ' + CAST(@id AS nvarchar(max)); + EXEC sp_executesql @tsql; + + /* Good */ + DECLARE @id int = 2107154552; + SELECT object_id, "name" FROM master.sys.tables WHERE object_id = @id; + ``` +- Do not debug the code that creates the dynamic T-SQL first, debug the generated T-SQL statement instead. + Use `@debug` variable to print (or a `SELECT` statement if your dynamic T-SQL is over 4000 characters) dynamic statement instead executing it. + See example below. +- Do take the time to format your dynamic T-SQL. + ```tsql + /* Bad @tsql formating */ + DECLARE @tsql nvarchar(max); + DECLARE @sep nvarchar(30) = ' UNION ALL '; + DECLARE @debug bit = 1; + + SELECT @tsql = COALESCE(@tsql, N'') + + N'SELECT N' + QUOTENAME(name,'''') + + N' AS DBName, (SELECT COUNT(*) FROM ' + + QUOTENAME(name) + N'.sys.tables) AS TableCount' + + @sep + FROM sys.databases + ORDER BY name; + + SET @tsql = LEFT(@tsql, LEN(@tsql) - LEN(@sep)); + IF @debug = 1 SELECT @tsql AS "tsql" ELSE EXEC sp_executesql @tsql; + + /* Good @tsql formating */ + DECLARE @tsql nvarchar(max); + DECLARE @sep nvarchar(30) = ' UNION ALL '; + DECLARE @debug bit = 1; + DECLARE @crlf nvarchar(10) = NCHAR(13) + NCHAR(10); + + SELECT @tsql = COALESCE(@tsql, N'') + @crlf + + N'SELECT N' + QUOTENAME(name,'''') + N' AS DBName' + @crlf + + N' , (SELECT COUNT(*) FROM ' + QUOTENAME(name) + N'.sys.tables) AS TableCount' + @crlf + + @sep + FROM sys.databases + ORDER BY name; + + SET @tsql = LEFT(@tsql, LEN(@tsql) - LEN(@sep)) + N';'; + IF @debug = 1 SELECT @tsql AS "tsql" ELSE EXEC sp_executesql @tsql; + ``` + +**[⬆ back to top](#table-of-contents)** + + + +## Official Reference and useful links + + - [Transact-SQL Formatting Standards](https://www.simple-talk.com/sql/t-sql-programming/transact-sql-formatting-standards-%28coding-styles%29/) (by Robert Sheldon) + - [Subjectivity: Naming Standards](http://blogs.sqlsentry.com/aaronbertrand/subjectivity-naming-standards/) (by Aaron Bertrand) + - [General Database Conventions](http://kejser.org/database-naming-conventions/general-database-conventions/) (by Thomas Kejser) + - [Writing Readable SQL](http://www.codeproject.com/Articles/126380/Writing-Readable-SQL) (by Red Gate) + - [SQL Style Guide](http://www.sqlstyle.guide/) (by Simon Holywell) + - [SQL Code Layout and Beautification](https://www.simple-talk.com/sql/t-sql-programming/sql-code-layout-and-beautification/) (by William Brewer) + - [TSQL Coding Style](http://www.databasejournal.com/features/mssql/tsql-coding-style.html) (by Gregory Larsen) + - [User-Defined Functions](https://docs.microsoft.com/en-us/sql/relational-databases/user-defined-functions/user-defined-functions) + - [Synonyms (Database Engine)](https://docs.microsoft.com/en-us/sql/relational-databases/synonyms/synonyms-database-engine) + - [Primary and Foreign Key Constraints](https://docs.microsoft.com/en-us/sql/relational-databases/tables/primary-and-foreign-key-constraints) + - [sys.objects](https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-objects-transact-sql) + - [SQL Server Constraints](https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-table-table-constraint-transact-sql) + - [CHECK Constraint TECHNET](http://technet.microsoft.com/en-us/library/ms188258%28v=sql.105%29.aspx) + - [SQL Server CLR Integration](https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql/introduction-to-sql-server-clr-integration) + - [Deploying CLR Database Objects](https://docs.microsoft.com/en-us/sql/relational-databases/clr-integration/deploying-clr-database-objects) + - [CLR Stored Procedures](https://docs.microsoft.com/en-us/sql/database-engine/dev-guide/clr-stored-procedures) + - [User-defined Functions](https://docs.microsoft.com/en-us/sql/relational-databases/user-defined-functions/create-user-defined-functions-database-engine) + - [SET NOCOUNT ON (Transact-SQL)](https://docs.microsoft.com/en-us/sql/t-sql/statements/set-nocount-transact-sql) + - [T-SQL Coding Guidelines Presentation](http://www.slideshare.net/chris1adkin/t-sql-coding-guidelines) (by Chris Adkin) + - [Sql Coding Style](http://c2.com/cgi/wiki?SqlCodingStyle) + - [SQL Server Code Review Checklist for Developers](https://www.sqlshack.com/sql-server-code-review-checklist-for-developers/) (by Samir Behara) + - [SQL Formatting standards – Capitalization, Indentation, Comments, Parenthesis](https://solutioncenter.apexsql.com/sql-formatting-standards-capitalization-indentation-comments-parenthesis/) (by ApexSQL) + - [In The Cloud: The Importance of Being Organized](http://sqlblog.com/blogs/john_paul_cook/archive/2017/05/16/in-the-cloud-the-importance-of-being-organized.aspx) + - [Naming Conventions in Azure](http://www.sqlchick.com/entries/2017/6/24/naming-conventions-in-azure) + - [The Basics of Good T-SQL Coding Style – Part 3: Querying and Manipulating Data](https://www.simple-talk.com/sql/t-sql-programming/basics-good-t-sql-coding-style-part-3-querying-manipulating-data/) + - [SQL naming conventions](https://www.red-gate.com/simple-talk/blogs/sql-naming-conventions/) (by Phi Factor) + - [SQL Server Compact Object Limitations](http://technet.microsoft.com/en-us/library/ms172451%28v=sql.110%29.aspx) + - [Dos and Don'ts of Dynamic SQL](https://www.sqlservercentral.com/articles/dos-and-donts-of-dynamic-sql) (by Thom Andrews) + +**[⬆ back to top](#table-of-contents)** + +[`TOP`]:https://docs.microsoft.com/it-it/sql/t-sql/queries/top-transact-sql +[`FETCH-OFFSET`]:https://docs.microsoft.com/en-us/sql/t-sql/queries/select-order-by-clause-transact-sql +[`sp_executesql`]:https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-executesql-transact-sql +[`EXEC`]:https://docs.microsoft.com/en-us/sql/t-sql/language-elements/execute-transact-sql +[10]:https://docs.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql +[`INFORMATION_SCHEMA`]:https://docs.microsoft.com/en-us/sql/relational-databases/system-information-schema-views/system-information-schema-views-transact-sql +[11]:https://docs.microsoft.com/en-us/sql/t-sql/statements/create-procedure-transact-sql#best-practices +[explicit transactions]:https://docs.microsoft.com/en-us/sql/t-sql/language-elements/transactions-transact-sql +[autocommit]:https://docs.microsoft.com/en-us/sql/t-sql/statements/set-implicit-transactions-transact-sql +[`ANSI`]:http://standards.iso.org/ittf/PubliclyAvailableStandards/c053681_ISO_IEC_9075-1_2011.zip +[hints]:https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql diff --git a/SQL Server People.md b/SQL Server People.md index 53c13d45..0c9cdfa2 100644 --- a/SQL Server People.md +++ b/SQL Server People.md @@ -17,9 +17,9 @@ Most valuable professionals in Microsoft SQL Server Database world | Cody Konior | [Cody Konior Blog] | AUS | Perth | [@codykonior] | NULL | 0 | - | | Stephen Wynkoop | [Stephen Wynkoop Site] | USA | Tucson | [@swynk] | NULL | 0 | - | | Brent Ozar | [Brent Ozar Blog] | USA | Chicago | [@BrentO] | help@brentozar.com | 7 | [Ozar MVP] | -| Adam Machanic | [SQLBlog] | USA | Boston | [@AdamMachanic] | NULL | 12 | [Machanic MVP] | +| Adam Machanic | [SQLBlog] | USA | Boston | [@AdamMachanic] | NULL | 13 | [Machanic MVP] | | Ola Hallengren | [Ola Maintenance Solution] | SWE | NULL | [@olahallengren] | ola@hallengren.com | 3 | [Hallengren MVP] | -| Erland Sommarskog | [Sommarskog Blog] | SWE | Stockholm | NULL | esquel@sommarskog.se | 13 | [Sommarskog MVP] | +| Erland Sommarskog | [Sommarskog Blog] | SWE | Stockholm | NULL | esquel@sommarskog.se | 14 | [Sommarskog MVP] | | Phil Factor | [Phil Simple-Talk] | | NULL | [@phil_factor] | NULL | 0 | - | | Robert Sheldon | [Robert Simple-Talk] | | NULL | NULL | NULL | 0 | - | | Glenn Alan Berry | [Glenn Blog] | USA | Denwer | [@GlennAlanBerry] | glenn@SQLskills.com | 10 | [Berry MVP] | @@ -30,7 +30,7 @@ Most valuable professionals in Microsoft SQL Server Database world | Jason Strate | [Jason Blog] | | NULL | [@StrateSQL] | NULL | 7 | [Strate MVP] | | Jeremiah Peschka | [Jeremiah Blog] | | NULL | [@peschkaj] | jeremiah.peschka@gmail.com | 5 | [Peschka MVP] | | Gail Shaw | [Gail Blog] | ZAF | Johannesburg | [@SQLintheWild] | NULL | 8 | [Shaw MVP] | -| Aaron Bertrand | [Aaron Articles] | | NULL | [@AaronBertrand] | NULL | 19 | [Bertrand MVP] | +| Aaron Bertrand | [Aaron Articles] | | NULL | [@AaronBertrand] | NULL | 20 | [Bertrand MVP] | | Kevin Kline | [Kevin Blog] | | NULL | [@kekline] | kevin_e_kline@yahoo.com | 13 | [Kline MVP] | | John Sansom | [John Blog] | | NULL | [@SqlBrit] | NULL | 0 | - | | Jes Borland | [Jes Articles] | | NULL | [@grrl_geek] | NULL | 4 | [Borland MVP] | @@ -43,7 +43,7 @@ Most valuable professionals in Microsoft SQL Server Database world | Kendal Van Dyke | [KendaL Blog] | | NULL | [@SQLDBA] | NULL | 0 | - | | Tim Ford | [Tim Blog] | | NULL | [@sqlagentman] | NULL | 7 | [Ford MVP] | | Steve Jones | [Steve Jones Blog] | | NULL | [@way0utwest] | NULL | 9 | [Jones MVP] | -| Thomas Larock | [Thomas Larock Blog] | | NULL | [@sqlrockstar] | NULL | 7 | [LaRock MVP] | +| Thomas Larock | [Thomas Larock Blog] | | NULL | [@sqlrockstar] | NULL | 9 | [LaRock MVP] | | Derik Hammer | [Derik Hammer Blog] | USA | Oklahoma | [@drayhammer] | NULL | 1 | [Derik MVP] | | Chrissy LeMaire | [Chrissy LeMaire Blog] | | NULL | [@cl] | NULL | 1 | [LeMaire MVP] | | Tim Mitchell | [Tim Mitchell Blog] | | NULL | [@Tim_Mitchell] | NULL | 7 | [Mitchell MVP] | @@ -57,11 +57,11 @@ Most valuable professionals in Microsoft SQL Server Database world | Matan Yungman | - | ISR | Tel Aviv | [@MatanYungman] | NULL | 0 | [Yungman MVP] | | Julie Koesmarno | [July Blog] | USA | Redmond | [@MsSQLGirl] | NULL | 0 | - | | Michael J Swart | [Michael Blog] | CAN | Waterloo | [@MJSwart] | NULL | 5 | [Swart MVP] | -| Dmitry Pilugin | [Dmitry Blog] | RUS | Moscow | [@SomewereSomehow] | pilugin@inbox.ru | 3 | [Pilugin MVP] | +| Dmitry Pilugin | [Dmitry Blog] | RUS | Moscow | [@SomewereSomehow] | pilugin@inbox.ru | 4 | [Pilugin MVP] | | Buck Woody | [Buck Blog] | | NULL | [@buckwoodymsft] | NULL | 0 | - | | Steve Stedman | [Steve Stedman Blog] | USA | Austin | [@stedman] | NULL | 0 | - | -| Daniel Hutmacher | [Daniel Hutmacher Blog] | USA | Austin | [@dhmacher] | NULL | 0 | - | -| Niko Neugebauer | [Niko Blog] | PRT | NULL | [@NikoNeugebauer] | niko@nikoport.com | 0 | - | +| Daniel Hutmacher | [Daniel Hutmacher Blog] | SWE | Stockholm | [@dhmacher] | NULL | 0 | - | +| Niko Neugebauer | [Niko Blog] | PRT | NULL | [@NikoNeugebauer] | niko@nikoport.com | 6 | [Neugebauer MVP] | | Mike Fal | [Mike Fal Blog] | USA | Denver | [@Mike_Fal] | NULL | 0 | - | | Robert L Davis | [Robert Blog] | USA | New York | [@SQLSoldier] | NULL | 3 | [Davis MVP] | | Chris Shaw | [Chris Shaw Blog] | USA | Colorado | [@SQLShaw] | NULL | 8 | [Shaw MVP] | @@ -74,7 +74,6 @@ Most valuable professionals in Microsoft SQL Server Database world | Raul Gonzalez | [Raul Gonzalez Blog] | | NULL | [@SQLDoubleG] | NULL | 0 | - | | Rob Sewell | [Rob Sewell Blog] | GBR | Somerset | [@sqldbawithbeard] | NULL | 1 | [Swell MVP] | | Jonathan Kehayias | [Jonathan Kehayias Articles] | USA | Tampa | [@SQLPoolBoy] | NULL | 9 | [Kehayias MVP] | -| Niko Neugebauer | [Niko Blog] | PRT | NULL | [@NikoNeugebauer] | NULL | 6 | [Neugebauer MVP] | | Thomas Kejser | [Thomas Kejser Blog] | DNK | NULL | NULL | thomas@kejser.org | 0 | - | | Patrick Keisler | [Patrick Keisler Blog] | USA | New York | [@patrickkeisler] | NULL | 0 | - | | Markus Winand | [Markus Winand Blog] | AUT | Vienna | [@MarkusWinand] | NULL | 0 | - | @@ -88,6 +87,11 @@ Most valuable professionals in Microsoft SQL Server Database world | Solomon Rutzky | [Sql Quantum Leap] | USA | Raleigh | [@SqlQuantumLeap] | [Contact Solomon Rutzky][1] | 0 | | | Ned Otter | [Ned Otter Blog] | USA | New York | [@NedOtter] | [Contact Ned Otter][2] | 0 | | | Joe Obbish | [Joe Obbish Blog] | | NULL | NULL | NULL | 0 | | +| Stephen Bennett | [Stephen Bennett Blog] | ENG | London | NULL | NULL | 0 | | +| Brian Davis | [Brian Davis Articles] | USA | NULL | [@brian78] | NULL | 0 | | +| Raul Gonzalez | [Raul Gonzalez Blog] | | NULL | [@SQLDoubleG] | NULL | 0 | | +| Hugo Kornelis | [Hugo Kornelis Blog] | | NULL | [@Hugo_Kornelis] | NULL | 12 | [Kornelis MVP] | +| Drew Furgiuele | [Drew Furgiuele Blog] | USA | Dublin | [@pittfurg] | NULL | 1 | [Furgiuele MVP] | [Stephen Wynkoop Site]:https://www.sswug.org/ [Cody Konior Blog]:https://www.codykonior.com/categories/#sql @@ -101,7 +105,7 @@ Most valuable professionals in Microsoft SQL Server Database world [Andrea Allred Blog]:https://royalsql.com/ [Randolph West Blog]:https://rabryst.ca/ [Dave Ballantyne]:clearskysql.co.uk/ -[Lori Edwards Blog]:https://blogs.sentryone.com/author/LoriEdwards/ +[Lori Edwards Blog]:https://www.sentryone.com/blog/author/lori-edwards [Brent Ozar Blog]:http://www.brentozar.com/ [SQLBlog]:http://sqlblog.com/ [Ola Maintenance Solution]:https://ola.hallengren.com/ @@ -147,7 +151,6 @@ Most valuable professionals in Microsoft SQL Server Database world [Steve Stedman Blog]:http://stevestedman.com [Daniel Hutmacher Blog]:https://sqlsunday.com [Niko Blog]:http://www.nikoport.com -[Mike Fal Blog]:http://www.mikefal.net/ [Robert Blog]:http://www.sqlsoldier.com/wp/ [Chris Shaw Blog]:https://chrisshaw.wordpress.com [Andy Mallon Blog]:http://www.am2.co/ @@ -175,6 +178,11 @@ Most valuable professionals in Microsoft SQL Server Database world [Ned Otter Blog]:http://nedotter.com/ [2]:http://nedotter.com/contact/ [Joe Obbish Blog]:https://orderbyselectnull.com/ +[Stephen Bennett Blog]:https://sqlnotesfromtheunderground.wordpress.com/ +[Brian Davis Articles]:https://www.sentryone.com/blog/author/brian-davis +[Raul Gonzalez Blog]:http://www.sqldoubleg.com/ +[Hugo Kornelis Blog]:https://sqlserverfast.com/ +[Drew Furgiuele Blog]:https://port1433.com/ [@swynk]:https://twitter.com/swynk [@codykonior]:https://twitter.com/codykonior @@ -232,7 +240,6 @@ Most valuable professionals in Microsoft SQL Server Database world [@stedman]:https://twitter.com/stedman [@dhmacher]:https://twitter.com/dhmacher [@NikoNeugebauer]:https://twitter.com/NikoNeugebauer -[@Mike_Fal]:https://twitter.com/Mike_Fal [@SQLSoldier]:https://twitter.com/SQLSoldier [@SQLShaw]:https://twitter.com/SQLShaw [@AMtwo]:https://twitter.com/AMtwo @@ -253,6 +260,10 @@ Most valuable professionals in Microsoft SQL Server Database world [@bertwagner]:https://twitter.com/bertwagner [@SqlQuantumLeap]:https://twitter.com/SqlQuantumLeap [@NedOtter]:https://twitter.com/NedOtter +[@brian78]:https://twitter.com/brian78 +[@SQLDoubleG]:https://twitter.com/SQLDoubleG +[@Hugo_Kornelis]:https://twitter.com/Hugo_Kornelis +[@pittfurg]:https://twitter.com/pittfurg [Swell MVP]:https://mvp.microsoft.com/en-us/PublicProfile/5002693?fullName=Rob%20%20Sewell [Walsh MVP]:https://mvp.microsoft.com/en-us/PublicProfile/4032569?fullName=Mike%20%20Walsh @@ -295,3 +306,5 @@ Most valuable professionals in Microsoft SQL Server Database world [Feasel MVP]:https://mvp.microsoft.com/en-us/PublicProfile/5001922?fullName=Kevin%20%20Feasel [Sheffield MVP]:https://mvp.microsoft.com/en-us/PublicProfile/5002585?fullName=Wayne%20%20Sheffield [Korotkevitch MVP]:https://mvp.microsoft.com/en-us/PublicProfile/4039717?fullName=Dmitri%20%20Korotkevitch +[Kornelis MVP]:https://mvp.microsoft.com/en-us/PublicProfile/33298?fullName=Hugo%20Kornelis +[Furgiuele MVP]:https://mvp.microsoft.com/en-us/PublicProfile/5003244?fullName=Drew%20Furgiuele diff --git a/SQL Server Trace Flag.md b/SQL Server Trace Flag.md index 03f924bb..9f741171 100644 --- a/SQL Server Trace Flag.md +++ b/SQL Server Trace Flag.md @@ -1,97 +1,137 @@ # Microsoft SQL Server Trace Flags -Complete list of Microsoft SQL Server trace flags (533 trace flags) +Detailed list of all discovered (documented and undocumented) Microsoft SQL Server trace flags (**622** trace flags). -**REMEMBER: Be extremely careful with trace flags, test in your test environment first. And consult professionals first if you are the slightest uncertain about the effects of your changes.** -**Trace flag behavior may not be supported in future releases of SQL Server.** +⚠ **REMEMBER: Be extremely careful with trace flags, test in your development environment first. +And consult professionals first if you are the slightest uncertain about the effects of your changes.** + +⚠ **Some trace flags were introduced in specific SQL Server versions. +For more information on the applicable version, see the Microsoft Support article associated with a specific trace flag.** + +⚠ **Trace flag behavior may not be supported in future releases of SQL Server.** + +⚠ **[Azure SQL Database Managed Instance](https://docs.microsoft.com/en-us/azure/sql-database/sql-database-managed-instance) supports the following global Trace Flags: [460](#460), [2301](#2301), [2389](#2389), [2390](#2390), [2453](#2453), [2467](#2467), [7471](#7471), [8207](#8207), [9389](#9389), [10316](#10316) and [11024](#11024). +Session trace-flags are not yet supported in Managed Instance.** + +⚠ **[When specifying a trace flag with the `-T` option](https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/database-engine-service-startup-options#list-of-startup-options), use an uppercase "**T**" to pass the trace flag number. +A lowercase "**t**" is accepted by SQL Server, but this sets other internal trace flags that are required only by SQL Server support engineers. +(Parameters specified in the Control Panel startup window are not read.)** Headers: - [What are Microsoft SQL Server Trace Flags?](#what-are-microsoft-sql-server-trace-flags) - [How do I turn Trace Flags on and off?](#how-do-i-turn-trace-flags-on-and-off) - [How do I know what Trace Flags are turned on at the moment?](#how-do-i-know-what-trace-flags-are-turned-on-at-the-moment) - [What Are the Optimizer Rules?](#what-are-the-optimizer-rules) + - [Remarks](#remarks) + - [Unknown trace flags](#unknown-trace-flags) - [Recommended Trace Flags](#recommended-trace-flags) - [Trace flags list](#trace-flags-list) Source links: - - [A Topical Collection of SQL Server Flags](https://sqlcrossjoin.wordpress.com/2013/10/28/a-topical-collection-of-sql-server-flags/) (by Aaron Morelli) - - [Steinar Andersen great post](http://www.sqlservice.se/updated-microsoft-sql-server-trace-flag-list/) - - [Yusuf Anis trace flag table](http://www.sqlservercentral.com/articles/trace+flags/70131/) - - [Docs Trace Flags] - - [Albert van der Sel TF list](http://antapex.org/traceflags_sqlserver.txt) - - [TECHNET List Of SQL Server Trace Flags] - - [Amit Banerjee TF list](http://troubleshootingsql.com/2012/07/01/sql-server-2008-trace-flags/) - - [Paul Randal discussing TF Pro’s and Con’s](http://www.sqlskills.com/blogs/paul/the-pros-and-cons-of-trace-flags/) - - **When specifying a trace flag with the -T option, use an uppercase "T" to pass the trace flag number. -A lowercase "t" is accepted by SQL Server, but this sets other internal trace flags that are required only by SQL Server support engineers. -(Parameters specified in the Control Panel startup window are not read.)**: https://technet.microsoft.com/en-us/en-en/library/ms190737%28v=sql.120%29.aspx - - [Enabling SQL Server Trace Flag for a Poor Performing Query Using QUERYTRACEON](https://www.mssqltips.com/sqlservertip/3320/enabling-sql-server-trace-flag-for-a-poor-performing-query-using-querytraceon/) - - [Disabling SQL Server Optimizer Rules with QUERYRULEOFF](https://www.mssqltips.com/sqlservertip/4175/disabling-sql-server-optimizer-rules-with-queryruleoff/) - - [SQLskills SQL101: Trace Flags](https://www.sqlskills.com/blogs/erin/sqlskills-101-trace-flags/) - - [Derik Hammer Trace Flag Recommendation](http://www.sqlhammer.com/deriks-favorite-trace-flags/) +- [Docs Trace Flags] +- [A Topical Collection of SQL Server Flags](https://sqlcrossjoin.wordpress.com/2013/10/28/a-topical-collection-of-sql-server-flags/) (by Aaron Morelli) +- [Steinar Andersen great post](http://www.sqlservice.se/updated-microsoft-sql-server-trace-flag-list/) +- [Yusuf Anis trace flag table](http://www.sqlservercentral.com/articles/trace+flags/70131/) +- [Albert van der Sel TF list](http://antapex.org/traceflags_sqlserver.txt) +- [TECHNET List Of SQL Server Trace Flags] +- [Amit Banerjee TF list](http://troubleshootingsql.com/2012/07/01/sql-server-2008-trace-flags/) +- [Paul Randal discussing TF Pro’s and Con’s](http://www.sqlskills.com/blogs/paul/the-pros-and-cons-of-trace-flags/) +- [Enabling SQL Server Trace Flag for a Poor Performing Query Using QUERYTRACEON](https://www.mssqltips.com/sqlservertip/3320/enabling-sql-server-trace-flag-for-a-poor-performing-query-using-querytraceon/) +- [Disabling SQL Server Optimizer Rules with QUERYRULEOFF](https://www.mssqltips.com/sqlservertip/4175/disabling-sql-server-optimizer-rules-with-queryruleoff/) +- [SQLskills SQL101: Trace Flags](https://www.sqlskills.com/blogs/erin/sqlskills-101-trace-flags/) +- [Derik Hammer - Trace Flag Recommendation](http://www.sqlhammer.com/deriks-favorite-trace-flags/) +- [Brent Ozar - Bad Idea Jeans: Finding Undocumented Trace Flags](https://rebrand.ly/brent-finding-undocumented-trace-flags) +- [Joe Obbish - A Method to Find Trace Flags](https://rebrand.ly/joe-finding-undocumented-trace-flags) **Great thanks to:** - - Aaron Morelli ([b](https://sqlcrossjoin.wordpress.com) | [@sqlcrossjoin](https://twitter.com/sqlcrossjoin)) - - Steinar Andersen ([b](http://www.sqlservice.se/) | [@SQLSteinar](https://twitter.com/SQLSteinar)) - - Brent Ozar ([b](https://www.brentozar.com/) | [@BrentO](https://twitter.com/BrentO)) - - Yusuf Anis - - Lars Utterström - - Martin Höglund - - Håkan Winther - - Toine Rozemeijer - - Robert L Davis ([b](http://www.sqlsoldier.com/wp/) | [@SQLSoldier](https://twitter.com/SQLSoldier)) - - Lonny Niederstadt ([b](http://sql-sasquatch.blogspot.ru/) | [@sql_handle](https://twitter.com/@sql_handle)) - - Andrzej Kukuła - - Alexander Titenko ([gtihub](https://github.com/AlexTitenko)) - - Albert van der Sel - - Amit Banerjee - - Erin Stellato ([b](http://www.sqlskills.com/blogs/erin/) | [@erinstellato](https://twitter.com/erinstellato)) - - Darik Hammer ([b](http://www.sqlhammer.com/) | [@drayhammer](https://twitter.com/drayhammer)) - - Erik Darling ([b](https://www.brentozar.com/archive/author/erik-darling/)) - - Joe Obbish ([b](https://orderbyselectnull.com/)) - - Glenn Berry ([b](https://sqlserverperformance.wordpress.com/) | [t](https://twitter.com/GlennAlanBerry)) - - Pedro Lopes ([b](https://social.msdn.microsoft.com/profile/Pedro+Lopes+%28PL%29) | [t](https://twitter.com/sqlpto)) - - Paul White ([b](http://sqlblog.com/blogs/paul_white/) | [t](https://twitter.com/SQL_Kiwi)) +- Aaron Morelli ([b](https://sqlcrossjoin.wordpress.com) | [@sqlcrossjoin](https://twitter.com/sqlcrossjoin)) +- Steinar Andersen ([b](http://www.sqlservice.se/) | [@SQLSteinar](https://twitter.com/SQLSteinar)) +- Brent Ozar ([b](https://www.brentozar.com/)) +- Yusuf Anis +- Lars Utterström +- Martin Höglund +- Håkan Winther +- Toine Rozemeijer +- Robert L Davis ([b](http://www.sqlsoldier.com/wp/) | [@SQLSoldier](https://twitter.com/SQLSoldier)) +- Lonny Niederstadt ([b](http://sql-sasquatch.blogspot.ru/) | [@sql_handle](https://twitter.com/@sql_handle)) +- Andrzej Kukuła +- Alexander Titenko ([gtihub](https://github.com/AlexTitenko)) +- Albert van der Sel +- Amit Banerjee +- Erin Stellato ([b](http://www.sqlskills.com/blogs/erin/) | [@erinstellato](https://twitter.com/erinstellato)) +- Darik Hammer ([b](http://www.sqlhammer.com/) | [@drayhammer](https://twitter.com/drayhammer)) +- Erik Darling ([b](https://www.brentozar.com/archive/author/erik-darling/)) +- Joe Obbish ([b](https://orderbyselectnull.com/)) +- Glenn Berry ([b](https://sqlserverperformance.wordpress.com/) | [t](https://twitter.com/GlennAlanBerry)) +- Pedro Lopes ([b](https://social.msdn.microsoft.com/profile/Pedro+Lopes+%28PL%29) | [t](https://twitter.com/sqlpto)) +- Paul White ([b](https://www.sql.kiwi/) | [t](https://twitter.com/SQL_Kiwi)) +- Alexey Nagorskiy ([github](https://github.com/fenixfx)) +- Niko Neugebauer ([b](http://www.nikoport.com/) | [t](https://twitter.com/@NikoNeugebauer)) +- Solomon Rutzky ([b](https://SqlQuantumLeap.com/) | [t](https://twitter.com/@SqlQuantumLeap)) +- Jason Brimhall ([b](http://jasonbrimhall.info/) | [t](https://twitter.com/sqlrnnr)) +- Victor Isakov ([b](https://victorisakov.wordpress.com/)) +- Scott Caldwell ([b](https://blog.rdx.com/) | [t](https://twitter.com/sqldroid)) +- Mike Fal ([b](http://www.mikefal.net) | [t](https://twitter.com/Mike_Fal)) +- Prince Kumar Rastogi ([b](https://www.sqlservergeeks.com/author/princerastogi/) | [t](https://twitter.com/princerastogi2)) +- Kendra Little ([b](http://www.littlekendra.com/) | [t](https://twitter.com/Kendra_Little)) +- Slava Oks ([t](https://twitter.com/slava_oks/)) +- John Sterrett ([b](https://www.procuresql.com/)) +- Pavel Málek ([t](https://twitter.com/malekpav)) +- Andrew Pruski ([b](https://dbafromthecold.com/) | [t](https://twitter.com/dbafromthecold)) +- Josh Darnell ([b](https://joshthecoder.com/) | [t](https://twitter.com/josh_the_coder)) +- Andrzej Kukula +- Aaron Bertrand ([b](https://sqlperformance.com/author/abertrand) | [t](https://twitter.com/AaronBertrand)) +- Wilfred van Dijk +- Tracy Boggiano ([b](http://databasesuperhero.com) | [t](https://twitter.com/TracyBoggiano)) +- Danilo Zocco (https://github.com/CrazySwimmer) +- Michael Abair (https://github.com/abair34) +- Mikulas Mraz (https://github.com/Prohiller) ## What are Microsoft SQL Server Trace Flags? Trace Flags are settings that in some way or another alters the behavior of various SQL Server functions: [Docs Trace Flags] +Trace flags are used to set specific server characteristics or to alter a particular behavior. For example, trace flag [3226](#3226) is a commonly used startup trace flag which suppresses successful backup messages in the error log. +Trace flags are frequently used to diagnose performance issues or to debug stored procedures or complex computer systems, but they may also be recommended by Microsoft Support to address behavior that is negatively impacting a specific workload. +All documented trace flags and those recommended by Microsoft Support are fully supported in a production environment when used as directed. +Note that trace flags in this list may have additional considerations regarding their particular usage, so it is advisable to carefully review all the recommendations given here and/or by your support engineer. +Also, as with any configuration change in SQL Server, it is always best to thoroughly test the flag in a non-production environment before deploying. + ## How do I turn Trace Flags on and off? - - You can use the [DBCC TRACEON](https://msdn.microsoft.com/en-us/library/ms187329.aspx "Official MSDN DBCC TRACEON Article") and [DBCC TRACEOFF](https://msdn.microsoft.com/en-us/library/ms174401.aspx "Official MSDN DBCC TRACEOFF Article") commands - - You can use the [-T option](https://technet.microsoft.com/en-us/library/ms190737%28v=sql.120%29.aspx "Official TECHNET Database Engine Service Startup Options Article") in the startup configuration for the SQL Server Service. - **When specifying a trace flag with the -T option, use an uppercase "T" to pass the trace flag number. A lowercase "t" is accepted by SQL Server, but this sets other internal trace flags that are required only by SQL Server support engineers. (Parameters specified in the Control Panel startup window are not read.)** - - You can also use the hint [QUERYTRACEON](https://support.microsoft.com/en-us/kb/2801413 "Official QUERYTRACEON KB Article") in your queries: **<querytraceon_hint ::= {QUERYTRACEON trace_flag_number}>** + - You can use the [DBCC TRACEON] and [DBCC TRACEOFF] commands + - You can use the [-T option](https://docs.microsoft.com/sql/database-engine/configure-windows/database-engine-service-startup-options "Official Microsoft Docs Database Engine Service Startup Options Article") in the startup configuration for the SQL Server Service. + **When specifying a trace flag with the `-T` option, use an uppercase `"T"` to pass the trace flag number. A lowercase `"t"` is accepted by SQL Server, but this sets other internal trace flags that are required only by SQL Server support engineers. (Parameters specified in the Control Panel startup window are not read.)** + - You can also use the hint [QUERYTRACEON](https://support.microsoft.com/kb/2801413 "Official QUERYTRACEON KB Article") in your queries: **<querytraceon_hint ::= {QUERYTRACEON trace_flag_number}>** ## How do I know what Trace Flags are turned on at the moment? -From SSMS 16 every sql plan content information about trace flags in section `Trace flags` +From SSMS 16 every sql plan content information about trace flags in section `Trace flags`. -You can use the [DBCC TRACESTATUS](https://docs.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-tracestatus-transact-sql "Microsoft Docs DBCC TRACESTATUS") command +You can use the [DBCC TRACESTATUS] command. The following example displays the status of all trace flags that are currently enabled globally: -```sql +```tsql DBCC TRACESTATUS(-1); GO ``` The following example displays the status of trace flags 2528 and 3205: -```sql +```tsql DBCC TRACESTATUS (2528, 3205); GO ``` The following example displays whether trace flag 3205 is enabled globally: -```sql +```tsql DBCC TRACESTATUS (3205, -1); GO ``` The following example lists all the trace flags that are enabled for the current session: -```sql +```tsql DBCC TRACESTATUS (); GO ``` @@ -107,7 +147,7 @@ When we write a simple select statement with an inner join, the query optimizer To obtain the list of rules of your version of SQL Server we must use the undocumented DBCC commands SHOWONRULES and SHOWOFFRULES. Those commands display the enabled and disabled rules for the whole instance respectively. As you may guess, the number of rules varies amongst versions. -```sql +```tsql USE master; GO @@ -131,23 +171,86 @@ GO | LASJNtoSM | Left Anti Semi Join to Sort Merge | + +## Remarks +There are three scopes at which trace flags can work: query, session, and global. +- Query trace flags are active for the context of a specific query +- Session trace flags are active for a connection and are visible only to that connection +- Global trace flags are set at the server level and are visible to every connection on the server. + +Some flags can only be enabled as global, and some can be enabled at either global or session scope. + +⚠ **Some `USE HINT` hints may conflict with trace flags enabled at the global or session level, or database scoped configuration settings. In this case, the query level hint (`USE HINT`) always takes precedence. If a `USE HINT` conflicts with another query hint, or a trace flag enabled at the query level (such as by [QUERYTRACEON]), SQL Server will generate an error when trying to execute the query.** + +The following rules apply: +- A global trace flag must be enabled globally. Otherwise, the trace flag has no effect. We recommend that you enable global trace flags at startup, by using the `-T` command line option. This ensures the trace flag remains active after a server restart. Restart SQL Server for the trace flag to take effect. +- If a trace flag has either global, session or query scope, it can be enabled with the appropriate scope. A trace flag that is enabled at the session level never affects another session, and the effect of the trace flag is lost when the SPID that opened the session logs out. + +Trace flags are set `ON` or `OFF` by using either of the following methods: +- Using the [DBCC TRACEON] and [DBCC TRACEOFF] commands. +For example, to enable the 2528 trace flag globally, use `DBCC TRACEON` with the `-1` argument: `DBCC TRACEON (2528, -1)`. The effect of enabling a global trace flag with `DBCC TRACEON` is lost on server restart. To turn off a global trace flag, use `DBCC TRACEOFF` with the `-1` argument. +- Using the `-T` startup option to specify that the trace flag be set on during startup. +The `-T` startup option enables a trace flag globally. You cannot enable a session-level trace flag by using a startup option. This ensures the trace flag remains active after a server restart. For more information about startup options, see [Database Engine Service Startup Options](https://github.com/MicrosoftDocs/sql-docs/blob/live/docs/database-engine/configure-windows/database-engine-service-startup-options.md). +- At the query level, by using the [QUERYTRACEON][KB2801413] query hint. The [QUERYTRACEON][KB2801413] option is only supported for Query Optimizer trace flags documented in the [Docs Trace Flags]. However, this option will not return any error or warning if an unsupported trace flag number is used. If the specified trace flag is not one that affects a query execution plan, the option will be silently ignored. +More than one trace flag can be specified in the OPTION clause if `QUERYTRACEON` `trace_flag_number` is duplicated with different trace flag numbers. +Executing a query with the [QUERYTRACEON][KB2801413] option requires membership in the sysadmin fixed server role. +The [QUERYTRACEON][KB2801413] option can be used in [Plan Guides](https://docs.microsoft.com/en-us/sql/relational-databases/performance/plan-guides). + +Use the [DBCC TRACESTATUS] command to determine which trace flags are currently active. + + + +## Unknown trace flags +List of Unknown trace flags enabled on default Azure SQL Server instances, see more details here: [Azure SQL DB Managed Instances: Trace Flags, Ahoy!](https://www.brentozar.com/archive/2018/03/azure-sql-db-managed-instances-trace-flags-ahoy/) +If you know behavior some of them please open an issue or contact me (taranov.pro). + + - [ ] 2591 + - [ ] 3447 (but 3448 is there, which is supposed to help fix an issue with hung Mirrored databases) + - [ ] 3978 + - [ ] 4141 + - [ ] 5521 + - [ ] 7838 + - [ ] 8037 + - [ ] 8054 + - [ ] 8057 + - [ ] 8063 + - [ ] 8065 + - [ ] 9041 + - [ ] 9537 + - [ ] 9570 + - [ ] 9883 + - [ ] 9905 + - [ ] 9934 + - [ ] 9940 + - [ ] 9941 + + ## Recommended Trace Flags - [Trace Flag 272](#272) (for SQL Server 2012) + - [Trace Flag 460](#460) (2017 for >= CU14, 2016 for >= SP2 CU6) - [Trace Flag 1118](#1118) (for versions < SQL Server 2016) - [Trace Flag 3023](#3023) (for versions < SQL Server 2014) - [Trace Flag 3226](#3226) (for all versions) - - [Trace Flag 7412](#7412) (for versions >= SQL Server 2016) - - [Trace Flag 7745](#7745) (for versions >= SQL Server 2016) - - [Trace Flag 7752](#7752) (for versions >= SQL Server 2016) - -**Trace Flag 272** prevents identity gap after restarting SQL Server 2012 instance, critical for columns with identity and tinyint and smallint data types. + - [Trace Flag 3427](#3427) (for SQL Server 2016) + - [Trace Flag 3449](#3449) (for versions SQL Server 2012 SP3 CU3 or later or SQL Server 2014 SP1 CU7 or later) + - [Trace Flag 6534](#6534) (for versions SQL Server 2012, 2014, 2016) (if use [spatial data types](https://docs.microsoft.com/sql/relational-databases/spatial/spatial-data-sql-server)) + - [Trace Flag 7412](#7412) (for versions >= SQL Server 2016 and < SQL Server 2019) + - [Trace Flag 7745](#7745) (for versions >= SQL Server 2016 and Query Store enabled) + - [Trace Flag 7752](#7752) (for versions >= SQL Server 2016 and < 2019 and Query Store enabled) + - [Trace Flag 7806](#7806) (for SQL Server Express Edition) + - [Trace Flag 8099](#8099) (for versions 2019 CU2 and 2019 CU3 only) + +**Trace Flag 272** prevents identity gap after restarting SQL Server 2012 instance, critical for columns with identity and `tinyint` and `smallint` data types. (Demo for repeating this issue [here](https://github.com/ktaranov/sqlserver-kit/Errors/Identity_gap_sql_server_2012.sql)) +**Trace Flag 460** Replace error message [8152] with [2628] (`String or binary data would be truncated. The statement has been terminated.`). +Description for [2628] message has useful information - which column had the truncation and which row.
+ **Trace flag 1118** addresses contention that can exist on a particular type of page in a database, the SGAM page. This trace flag typically provides benefit for customers that make heavy use of the tempdb system database. -In SQL Server 2016, you change this behavior using the MIXED_PAGE_ALLOCATION database option, and there is no need for TF 1118. +In SQL Server 2016, you change this behavior using the `MIXED_PAGE_ALLOCATION` database option, and there is no need for TF 1118. **Trace flag 3023** is used to enable the CHECKSUM option, by default, for all backups taken on an instance. With this option enabled, page checksums are validated during a backup, and a checksum for the entire backup is generated. @@ -158,7 +261,18 @@ Information about successful backups is still written to `msdb` and can be queri For servers with multiple databases and regular transaction log backups, enabling this option means the ERRORLOG is no longer bloated with BACKUP DATABASE and Database backed up messages. As a DBA, this is a good thing because when I look in my ERRORLOG, I really only want to see errors, I don’t want to scroll through hundreds or thousands of entries about successful backups. -**Trace flag 7412** Enables the lightweight query execution statistics profiling infrastructure. +**Trace flag 3427** Another change in SQL Server 2016 behavior that could impact tempdb-heavy workloads has to do with Common Criteria Compliance (CCC), also known as C2 auditing. +We introduced functionality to allow for transaction-level auditing in CCC which can cause some additional overhead, particularly in workloads that do heavy inserts and updates in temp tables. +Unfortunately, this overhead is incurred whether you have CCC enabled or not. In SQL Server 2016 you can enable trace flag 3427 to bypass this overhead starting with SP1 CU2. Starting in SQL Server 2017 CU4, we automatically bypass this code if CCC is disabled. + +**Trace flag 3449** (and you are on SQL Server 2012 SP3 CU3 or later or SQL Server 2014 SP1 CU7 or later), +will get much better performance by avoiding a FlushCache call in a number of different common scenarios, such as backup database, +backup transaction log, create database, add a file to a database, restore a transaction log, recover a database, shrink a database file, and a SQL Server “graceful” shutdown. + +**Trace flag 6534** enables performance improvement of query operations with spatial data types in SQL Server 2012, SQL Server 2014 and SQL Server 2016. +The performance gain will vary, depending on the configuration, the types of queries, and the objects. + +**Trace flag 7412** enables the lightweight query execution statistics profiling infrastructure. Unless your server is already CPU bound, like you’re running all the time with 95% CPU, unless you are at that point, turn on this trace flag at any server you have. This would be my advice here because this enables that lightweight profiling infrastructure there and then you’ll see in a few minutes what it unleashes here. So one thing that happens when I enable the lightweight profiling is that the sys.dm_exec_query_profiles DMV, which is something that actually populates the live query stats ability or feature of SSMS, now also is also populated with this lightweight profiling, which means that for all essence, we are now able to run a live query stats on all fashions at any given point in time, and this is extremely useful for let’s say a production DBA that someone calls and says, “Hey, you have a problem. @@ -169,41 +283,48 @@ Using this trace may cause Query Store data not previously flushed to disk to be For a SQL Server shutdown, the command SHUTDOWN WITH NOWAIT can be used instead of this trace flag to force an immediate shutdown. **Trace Flag: 7752** enables asynchronous load of Query Store. -Use this trace flag if SQL Server is experiencing high number of QDS_LOADDB waits related to Query Store synchronous load (default behavior). +Use this trace flag if SQL Server is experiencing high number of [QDS_LOADDB](https://www.sqlskills.com/help/waits/qds_loaddb/) waits related to Query Store synchronous load (default behavior). + +**Trace Flag: 7806** enables a dedicated administrator connection ([DAC]) on SQL Server Express. + +**Trace Flag: 8099** enables a spinlock contention fix for high-end systems running SQL Server 2019 (15.x) serving many concurrent users. Starting with SQL 2019 CU 4 this fix is enabled by default. ## Trace Flags List -Summary: **533 trace flags** +Summary: **622 trace flags** #### Trace Flag: -1 Function: Sets trace flags for all client connections, rather than for a single client connection. -Because trace flags set using the -T command-line option automatically apply to all connections, this trace flag is used only when setting trace flags using DBCC TRACEON and DBCC TRACEOFF.
+Because trace flags set using the -T command-line option automatically apply to all connections, this trace flag is used only when setting trace flags using [DBCC TRACEON] and [DBCC TRACEOFF].
Link: http://www.sql-server-performance.com/2002/traceflags/ #### Trace Flag: 101 -Function: Verbose Merge Replication logging output for troubleshooting -Merger repl performance
-Link: https://support.microsoft.com/en-us/help/2892633
-Scope: global only +Function: Increases the verboseness of the merge replication agent logging.
+**IMPORTANT**: Trace flag 101 can only be enabled for the [Replication Merge Agent] using the `-T` option when executing `replmerg.exe` from the command prompt.
+**WARNING**: Trace flag 101 is not meant to be enabled continuously in a production environment, but only for time-limited troubleshooting purposes.
+Link: https://support.microsoft.com/kb/2892633
+Scope: Replication Merge Agent only #### Trace Flag: 102 -Function: Verbose Merge Replication logging to msmerge\_history table for troubleshooting Merger repl performance
-Link: https://support.microsoft.com/en-us/help/2892633
-Scope: global only +Function: Increases the verboseness of the merge replication agent logging and directs it to the `..msmerge_history` table.
+**IMPORTANT**: Trace flag 102 can only be enabled for the pReplication Merge Agent[ using the `-T` option when executing `replmerg.exe` from the command prompt. +**WARNING**: Trace flag 102 is not meant to be enabled continuously in a production environment, but only for time-limited troubleshooting purposes. +Link: https://support.microsoft.com/kb/2892633
+Scope: Replication Merge Agent only -**Undocumented trace flag**
#### Trace Flag: 105 +**Undocumented trace flag**
Function: Join more than 16 tables in SQL server 6.5
-Link: http://www.databasejournal.com/features/mssql/article.php/1443351/SQL-Server-65-Some-Useful-Trace-Flags.htm +Link: [SQL Server 6.5: Some Useful Trace Flag] @@ -244,7 +365,7 @@ Function: Forces correct conversion semantics in the scope of DBCC check command **Note: This trace flag applies to SQL Server 2016 RTM CU3, SQL Server 2016 SP1 and higher builds.**
**WARNING: Trace flag 139 is not meant to be enabled continuously in a production environment, and should be used for the sole purpose of performing database validation checks described in this Microsoft Support article. It should be immediately disabled after validation checks are completed.**
-Link: http://support.microsoft.com/help/4010261
+Link: https://support.microsoft.com/kb/4010261
Link: [Docs Trace Flags]
Scope: global only @@ -264,41 +385,53 @@ Function: Consider using when replaying against SQL 8.0, to avoid an attempt to Link: None + +#### Trace Flag: 166 +**Undocumented trace flag**
+Function: Unclear. Observable effect was to change the identifier for act1008 to act1009 in a query plan.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + #### Trace Flag: 168 Function: Bugfix in ORDER BY. This hotfix introduces trace flag 168. After you apply this hotfix, you must enable trace flag 168. Trace flag 168 must be set before the database is migrated to SQL Server 2005. If trace flag 168 is set after the database is migrated, the query result will remain unsorted.
-Link: https://support.microsoft.com/en-us/help/926292 +Link: https://support.microsoft.com/kb/926292 #### Trace Flag: 174 Function: Increases the SQL Server Database Engine plan cache bucket count from 40,009 to 160,001 on 64-bit systems.
-**Note: Please ensure that you thoroughly test this option, before rolling it into a production environment.** -Link: https://support.microsoft.com/en-us/help/3026083/fix-sos-cachestore-spinlock-contention-on-ad-hoc-sql-server-plan-cache
+**Note: Please ensure that you thoroughly test this option, before rolling it into a production environment.**
+Link: https://support.microsoft.com/kb/3026083/
Link: [Docs Trace Flags]
+Link: [SQL Server Plan Cache Limits]
+Link: [KB2964518]
Scope: global only #### Trace Flag: 176 Function: Enables a fix to address errors when rebuilding partitions online for tables that contain a computed partitioning column.
-Link: https://support.microsoft.com/en-us/help/3213683/fix-unable-to-rebuild-the-partition-online-for-a-table-that-contains-a
+Link: https://support.microsoft.com/kb/3213683/
+Link: https://support.microsoft.com/kb/4541096/
Link: [Docs Trace Flags]
Scope: global or session #### Trace Flag: 204 -Function: SQL 6.5 – Backward compatibility switch that enables non-ansi standard behavior. E.g. previously SQL server ignored trailing blanks in the like statement and allowed queries that contained aggregated functions to have items in the group by clause that were not in the select list.
-Link: https://support.microsoft.com/en-us/help/153096/fix-sql-server-6.5-service-pack-1-fixlist +Function: SQL 6.5 – Backward compatibility switch that enables non-ansi standard behavior. +E.g. previously SQL server ignored trailing blanks in the like statement and allowed queries that contained aggregated functions to have items in the group by clause that were not in the select list.
+Link: [KB153096] #### Trace Flag: 205 Function: Reports to the error log when a statistics-dependent stored procedure is being recompiled as a result of auto-update statistics.
-Link: https://support.microsoft.com/en-us/kb/195565
+Link: https://support.microsoft.com/kb/195565
Link: [Docs Trace Flags]
Scope: global only @@ -320,7 +453,7 @@ Link: None #### Trace Flag: 210 Function: SQL 9 – Error when you run a query against a view: "An error occurred while executing batch"
-Link: https://support.microsoft.com/en-us/kb/945892 +Link: https://support.microsoft.com/kb/945892 @@ -402,8 +535,9 @@ Link: None #### Trace Flag: 260 -Function: Prints versioning information about extended stored procedure dynamic-link libraries (DLLs). For more information about GetXpVersion(), see [Creating Extended Stored Procedures](https://msdn.microsoft.com/en-us/library/ms164627.aspx).
-Link: http://msdn.microsoft.com/en-us/library/ms164627.aspx
+Function: Prints versioning information about extended stored procedure dynamic-link libraries (DLLs). +When SQL Server is started with the trace flag `-T260` or if a user with system administrator privileges runs `DBCC TRACEON (260)`, and if the extended stored procedure DLL does not support `__GetXpVersion()`, a warning message (`Error 8131: Extended stored procedure DLL '%' does not export __GetXpVersion().`) is printed to the error log. (Note that `__GetXpVersion()` begins with **two underscores**.)
+Link: https://docs.microsoft.com/en-us/sql/relational-databases/extended-stored-procedures-programming/creating-extended-stored-procedures
Link: [Docs Trace Flags]
Scope: global or session @@ -418,12 +552,14 @@ Link: None #### Trace Flag: 272 -**Note: Critical only for SQL Server 2012** +**Note: Recommended for SQL Server 2012**
Function: Disabling the identity cache. It prevents identity gap after restarting SQL Server 2012 instance, critical for columns with identity and tinyint and smallint data types.
Link: http://www.big.info/2013/01/how-to-solve-sql-server-2012-identity.html
-Link: https://connect.microsoft.com/SQLServer/feedback/details/739013/failover-or-restart-results-in-reseed-of-identity
+Link: https://web.archive.org/web/20160822054721/https://connect.microsoft.com/SQLServer/feedback/details/739013/failover-or-restart-results-in-reseed-of-identity
Link: https://dbafromthecold.com/2017/05/24/disabling-the-identity-cache-in-sql-server-2017/
-Link: [Demo](https://github.com/ktaranov/sqlserver-kit/blob/master/Errors/Identity_gap_sql_server_2012.sql) +Link: [Demo](https://github.com/ktaranov/sqlserver-kit/blob/master/Errors/Identity_gap_sql_server_2012.sql)
+Link: https://stackoverflow.com/q/14146148/2298061
+Scope: global only @@ -437,14 +573,22 @@ Link: None #### Trace Flag: 302 **Undocumented trace flag**
Function: Output Index Selection info
-Link: http://www.databasejournal.com/features/mssql/article.php/1443351/SQL-Server-65-Some-Useful-Trace-Flags.htm +Link: [SQL Server 6.5: Some Useful Trace Flag] + + + +#### Trace Flag: 304 +**Undocumented trace flag**
+Function: Changed the reported CachedPlanSize.
+Link: [New Undocumented Trace Flags]
+Scope: ? #### Trace Flag: 310 **Undocumented trace flag**
Function: Outputs info about actual join order
-Link: http://www.databasejournal.com/features/mssql/article.php/1443351/SQL-Server-65-Some-Useful-Trace-Flags.htm +Link: [SQL Server 6.5: Some Useful Trace Flag] @@ -457,8 +601,8 @@ Link: None #### Trace Flag: 323 Function: Outputs detailed info about updates
-Link: http://www.databasejournal.com/features/mssql/article.php/1443351/SQL-Server-65-Some-Useful-Trace-Flags.htm
-Link: https://support.microsoft.com/en-us/help/153096/fix-sql-server-6.5-service-pack-1-fixlist +Link: [SQL Server 6.5: Some Useful Trace Flag]
+Link: [KB153096] @@ -493,7 +637,7 @@ Link: None #### Trace Flag: 345 **Undocumented trace flag**
Function: Changes join order selection logic in SQL Server 6.5
-Link: http://www.databasejournal.com/features/mssql/article.php/1443351/SQL-Server-65-Some-Useful-Trace-Flags.htm +Link: [SQL Server 6.5: Some Useful Trace Flag] @@ -503,6 +647,28 @@ Function: Prints ”compile issued” message in the errorlog for each compiled Link: None + +#### Trace Flag: 460 +Function: Replace error message ID [8152] with message ID [2628] (`String or binary data would be truncated. The statement has been terminated.`). +Description for [2628] message has useful information - which column had the truncation and which row. +Starting with SQL Server 2019 (15.x) CTP 2.4, to accomplish this at the database level, see the `VERBOSE_TRUNCATION_WARNINGS` option in [ALTER DATABASE SCOPED CONFIGURATION (Transact-SQL)].
+**Note: This trace flag applies to SQL Server 2017 (14.x) CU12 and higher builds.**
+**Note: Starting with database compatibility level 150, message ID [2628] is the default and this trace flag has no effect.**
+**Note: Don’t leave this trace flag enabled on global scope for SQL Server 2017 CU12 and CU13.**
+There’s at least one [bug](https://feedback.azure.com/forums/908035-sql-server/suggestions/36311467-traceflag-460-causing-truncation-errors-on-code-pa) on SQL Server 2017 CU13: table variables will throw errors saying their contents are being truncated even when no data is going into them.**
+Link: [Docs Trace Flags]
+Link: https://www.procuresql.com/blog/2018/09/26/string-or-binary-data-get-truncated/
+Link: https://feedback.azure.com/forums/908035-sql-server/suggestions/32908417-binary-or-string-data-would-be-truncated-error
+Link: https://blogs.msdn.microsoft.com/sql_server_team/string-or-binary-data-would-be-truncated-replacing-the-infamous-error-8152/
+Link: https://support.microsoft.com/kb/4468101
+Link: https://www.brentozar.com/archive/2019/03/how-to-fix-the-error-string-or-binary-data-would-be-truncated/
+Link: https://feedback.azure.com/forums/908035-sql-server/suggestions/36311467-traceflag-460-causing-truncation-errors-on-code-pa
+Link: https://support.microsoft.com/kb/4490142
+Scope: global or session
+SQL Server Version: >= 2017 CU12, >= 2016 SP2 CU6
+Demo: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Trace_Flag/Trace_Flag_460.sql + + #### Trace Flag: 506 **Undocumented trace flag**
@@ -512,7 +678,11 @@ Link: None #### Trace Flag: 610 -Function: Controls minimally logged inserts into indexed tables.
+Function: Controls minimally logged inserts into indexed tables. +This trace flag is not required starting SQL Server 2016 as minimal logging is turned on by default for indexed tables. +In SQL Server 2016, when the bulk load operation causes a new page to be allocated, all of the rows sequentially filling that new page are minimally logged if all the other pre-requisites for minimal logging are met. +Rows inserted into existing pages (no new page allocation) to maintain index order are still fully logged, as are rows that are moved as a result of page splits during the load. +It is also important to have `ALLOW_PAGE_LOCKS` turned `ON` for indexes (which is `ON` by default) for minimal logging operation to work as page locks are acquired during allocation and thereby only page or extent allocations are logged.
Link: http://msdn.microsoft.com/en-us/library/dd425070%28v=SQL.100%29.aspx
Link: https://www.pythian.com/blog/minimally-logged-operations-data-loads/
Link: https://msdn.microsoft.com/library/dd425070.aspx
@@ -549,29 +719,36 @@ Columnstore compression improves query performance but also consumes system reso You can control the timing of columnstore compression manually, by disabling the background compression task with trace flag 634, and then explicitly invoking ALTER INDEX REORGANIZE or ALTER INDEX REBUILD at the time of your choice.
Link: [Niko Neugebauer Columnstore Indexes – part 35]
Link: [Docs Trace Flags]
+Link: http://www.sqlservergeeks.com/trace-flag-634-disable-background-columnstore-compression/
+Link: [SQL Server 2019 Aggressive Clustered Columnstore Cleanup]
Scope: global only #### Trace Flag: 646 +**Undocumented trace flag**
Function: Serves for getting detailed information on which Columnstore were eliminated by the Query Optimiser right into the error log.
Link: [Niko Neugebauer Columnstore Indexes – part 35]
-Link: http://www.sqlskills.com/blogs/joe/exploring-columnstore-index-metadata-segment-distribution-and-elimination-behaviors +Link: http://www.sqlskills.com/blogs/joe/exploring-columnstore-index-metadata-segment-distribution-and-elimination-behaviors
+Scope: global or session #### Trace Flag: 647 Function: Avoids a new-in-SQL 2012 data check (done when adding a column to a table) that can cause ALTER TABLE... ADD operations to take a very long time. The KB has a useful query for determining the row size for a table.
-Link: https://support.microsoft.com/en-us/help/2986423/fix-it-takes-a-long-time-to-add-new-columns-to-a-table-when-the-row-size-exceeds-the-maximum-allowed-size
+Link: https://support.microsoft.com/kb/2986423
#### Trace Flag: 652 -Function: Disable page pre-fetching scans
+Function: Disable page pre-fetching scans. +If you turn on trace flag 652, SQL Server no longer brings database pages into the buffer pool before these database pages are consumed by the scans. +If you turn on trace flag 652, queries that benefit from the page pre-fetching feature exhibit low performance.
Link: [KB920093]
Link: [Docs Trace Flags]
-Scope: global only +Link: https://www.sqlservergeeks.com/sql-server-trace-flag-652/
+Scope: global or session @@ -583,27 +760,35 @@ Link: None #### Trace Flag: 661 -Function: Disables the ghost record removal process.
+Function: Disables the ghost record removal process. A ghost record is the result of a delete operation. +When you delete a record, the deleted record is kept as a ghost record. Later, the deleted record is purged by the ghost record removal process. +When you disable this process, the deleted record is not purged. Therefore, the space that the deleted record consumes is not freed. +This behavior affects space consumption and the performance of scan operations.
Link: [KB920093]
Link: [Docs Trace Flags]
-Scope: global only +Link: [Let’s talk about trace flags]
+Link: https://www.sqlservergeeks.com/sql-server-trace-flag-661/
+Link: [SQL Server 2019 Aggressive Clustered Columnstore Cleanup]
+Scope: global or session #### Trace Flag: 662 **Undocumented trace flag**
-Function: Prints detailed information about the work done by the ghost cleanup task when it runs next. Use TF 3605 to see the output in the errorlog
+Function: Prints detailed information about the work done by the ghost cleanup task when it runs next. +Use TF [3605](#3605) to see the output in the errorlog
Link: http://blogs.msdn.com/b/sqljourney/archive/2012/07/28/an-in-depth-look-at-ghost-records-in-sql-server.aspx #### Trace Flag: 669 Function: “...prevents user queries from queuing requests to the ghost cleanup process”. This flag is a workaround for stack dumps occurring right after SQL Server startup, where user queries (that queue pages for ghost cleanup) were running so quickly after SQL startup that they were queuing pages before the ghost cleanup process had actually initialized.
-Link: https://support.microsoft.com/en-us/help/3027860/error-17066-or-17310-during-sql-server-startup +Link: https://support.microsoft.com/kb/3027860 #### Trace Flag: 683 +**Undocumented trace flag**
Function: According to the KB, used to workaround a bug in SQL 2000 SP3 by reverting to pre-SP3 parallel-scan behavior in parallel queries. Database-Wiki.com: “Disallow row counter and column mod counters to be partitioned”
Link: None @@ -615,26 +800,30 @@ Starting SQL Server 2016, fast inserts is enabled by default leveraging minimal With fast inserts, each bulk load batch acquires new extent(s) bypassing the allocation lookup for existing extent with available free space to optimize insert performance. With fast inserts, bulk loads with small batch sizes can lead to increased unused space consumed by objects hence it is recommended to use large batch size for each batch to fill the extent completely. If increasing batch size is not feasible, this trace flag can help reduce unused space reserved at the expense of performance.
-**Note: This trace flag applies to SQL Server 2016 RTM and higher builds.** +**Note: This trace flag applies to SQL Server 2016 (13.x) RTM and higher builds.**
+Link: [Docs Trace Flags]
Link: https://blogs.msdn.microsoft.com/sql_server_team/sql-server-2016-minimal-logging-and-impact-of-the-batchsize-in-bulk-load-operations/
Scope: global or session #### Trace Flag: 698 +**Undocumented trace flag**
Function: SQL 9 – Performance of INSERT operations against a table with an identity column may be slow when compared to SQL 8
Link: None #### Trace Flag: 699 +**Undocumented trace flag**
Function: Turn off transaction logging for the entire SQL dataserver
Link: None #### Trace Flag: 670, 671 +**Undocumented trace flag**
Function: Disables deferred deallocation. But note Paul White’s comment on the post! The flag # may actuall by 671.
-Link: https://blogs.msdn.microsoft.com/psssql/2009/11/17/how-it-works-controlling-sql-server-memory-dumps/ +Link: [Controlling SQL Server memory dumps] @@ -642,7 +831,7 @@ Link: https://blogs.msdn.microsoft.com/psssql/2009/11/17/how-it-works-controllin Function: Enables table lock for bulk load operations into a heap with no non-clustered indexes. When this trace flag is enabled, bulk load operations acquire bulk update (BU) locks when bulk copying data into a table. Bulk update (BU) locks allow multiple threads to bulk load data concurrently into the same table, while preventing other processes that are not bulk loading data from accessing the table. -The behavior is similar to when the user explicitly specifies TABLOCK hint while performing bulk load, or when the sp_tableoption table lock on bulk load is enabled for a given table. +The behavior is similar to when the user explicitly specifies `TABLOCK` hint while performing bulk load, or when the `sp_tableoption` table lock on bulk load is enabled for a given table. However, when this trace flag is enabled, this behavior becomes default without any query or database changes.
Link: [Docs Trace Flags]
Scope: global or session @@ -650,12 +839,20 @@ Scope: global or session #### Trace Flag: 806 -Function: Turn on Page Audit functionality, to verify page validity
+Function: enables DBCC audit checks to be performed on pages to test for logical consistency problems. +These checks try to detect when a read operation from a disk does not experience any errors but the read operation returns data that is not valid. +Pages will be audited every time that they are read from disk. +Page auditing can affect performance and should only be used in systems where data stability is in question.
Link: http://technet.microsoft.com/en-au/library/cc917726.aspx
-Link: http://www.sqlskills.com/blogs/paul/how-to-tell-if-the-io-subsystem-is-causing-corruptions +Link: http://www.sqlskills.com/blogs/paul/how-to-tell-if-the-io-subsystem-is-causing-corruptions
+Link: [Important Trace Flags That Every DBA Should Know]
+Link: https://technet.microsoft.com/en-au/library/cc917726.aspx
+Scope: ? + #### Trace Flag: 809 +**Undocumented trace flag**
Function: SQL 8 – Limits the amount of Lazy write activity
Link: None @@ -669,21 +866,27 @@ Link: https://blogs.msdn.microsoft.com/psssql/2012/11/12/how-can-reference-count #### Trace Flag: 818 -Function: Turn on ringbuffer to store info about IO write operations. -Used to troubleshoot IO problems
-Link: http://support.microsoft.com/kb/826433
+Function: Enables additional I/O diagnostics to check for Lost Write or Stale Read conditions during file I/O operations. +Trace flag 818 enables an in-memory ring buffer that is used for tracking the last 2,048 successful write operations that are performed by SQL Server, not including sort and workfile I/Os. +When errors such as Error 605, 823, or 3448 occur, the incoming buffer's log sequence number (LSN) value is compared to the recent write list. +If the LSN that is retrieved is older than the one specified during the write operation, a new error message is logged in the SQL Server Errorlog.
+Link: https://support.microsoft.com/kb/826433
Link: https://technet.microsoft.com/en-us/library/cc966500.aspx
-Link: https://support.microsoft.com/en-us/help/828339/error-message-823-may-indicate-hardware-problems-or-system-problems-in-sql-server +Link: https://support.microsoft.com/kb/828339
+Link: [Important Trace Flags That Every DBA Should Know]
+Scope: global only #### Trace Flag: 822 +**Undocumented trace flag**
Function: A workaround for SQL 2000 over-committing memory on the machine
Link: None #### Trace Flag: 825 +**Undocumented trace flag**
Function: In SQL 2000, enables Buffer Pool support for NUMA. TF 888 must be used.
Link: None @@ -691,78 +894,143 @@ Link: None #### Trace Flag: 828 Function: SQL 8 - When enabled checkpoint ignores the recovery interval target and keeps steady I/O otherwise it uses recovery interval setting as a target for the length of time that checkpoint will take
-Link: https://support.microsoft.com/en-gb/kb/906121 +Link: https://support.microsoft.com/kb/906121 Link: https://blogs.msdn.microsoft.com/psssql/2008/04/11/how-it-works-sql-server-checkpoint-flushcache-outstanding-io-target/ #### Trace Flag: 830 Function: SQL 9 – Disable the reporting of CPU Drift errors in the SQL Server errorlog like SQL Server has encountered 2 occurrence(s) of I/O requests taking longer than 15 seconds to complete
-Link: https://support.microsoft.com/en-us/kb/897284
+Link: https://support.microsoft.com/kb/897284
Link: https://technet.microsoft.com/en-us/library/aa175396(v=SQL.80).aspx #### Trace Flag: 831 +**Undocumented trace flag**
Function: Protect unchanged pages in the buffer pool to catch memory corruptions
Link: None + +#### Trace Flag: 833 +**Undocumented trace flag**
+Function: Disable [superlatches](https://www.sqlshack.com/all-about-latches-in-sql-server/). +Starting with SQL Server 2005, superlatches (also called sublatches) were introduced to improve SQL Server efficiency in highly concurrent OLTP workloads for a certain pattern of usage (i.e. very high shared read only access to the page (SH) while write access is very low or not exists). +**Superlatches are used by SQL Server only in NUMA systems with 32+ logical processors.** +A Superlatch will behave as a single latch with sublatch structures and there can be one sublatch per partition per logical CPU core. +So when a superlatch is created, the CPU worker thread will just have to acquire the shared (SH) sublatch that is assigned to the scheduler. +This ensures that a shared (SH) superlatch uses less resources while at the same time access to pages is more efficient comparing to non-partitioned shared latches. +The reason for this is that the superlatch do not require any synchronization of the global state as it will access only the local NUMA memory.
+Link: https://www.sqlservercentral.com/forums/topic/sql-server-trace-flags-complete-list/page/3/#post-3679021
+Scope: global + + #### Trace Flag: 834 -Function: Uses Microsoft Windows large-page allocations for the buffer pool.
-**Note: If you are using the Columnstore Index feature of SQL Server 2012 to SQL Server 2016, we do not recommend turning on trace flag 834.**
-Link: https://support.microsoft.com/en-us/kb/920093
-Link: https://support.microsoft.com/en-us/kb/3210239
+Function: Uses Microsoft Windows large-page allocations for the buffer pool. +Trace flag 834 causes SQL Server to use Microsoft Windows large-page allocations for the memory that is allocated for the buffer pool. +The page size varies depending on the hardware platform, but the page size may be from 2 MB to 16 MB. +Large pages are allocated at startup and are kept throughout the lifetime of the process. +Trace flag 834 improves performance by increasing the efficiency of the translation look-aside buffer (TLB) in the CPU.
+**Note: If you are using the Columnstore Index feature of SQL Server 2012 to SQL Server 2016, we do not recommend turning on trace flag 834. +If using SQL Server 2019 (15.x) and columnstore, see trace flag [876](#876) instead.**
+Link: [KB920093]
+Link: https://support.microsoft.com/kb/3210239
Link: [Docs Trace Flags]
+Link: [Let’s talk about trace flags]
+Link: [KB2964518]
+Link: https://www.sqlservergeeks.com/sql-server-trace-flag-834/
Scope: global only #### Trace Flag: 835 +**Undocumented trace flag**
Function: SQL 9 / 10 – On 64 bit SQL Server it turns off Lock pages in memory
-Link: None +Link: None
+Scope: ? #### Trace Flag: 836 -Function: Use the max server memory option for the buffer pool
+Function: Trace flag 836 causes SQL Server to size the buffer pool at startup based on the value of the max server memory option instead of based on the total physical memory. +You can use trace flag 836 to reduce the number of buffer descriptors that are allocated at startup in 32-bit Address Windowing Extensions (AWE) mode. +Trace flag 836 applies only to 32-bit versions of SQL Server that have the AWE allocation enabled. You can turn on trace flag 836 only at startup.
Link: [KB920093]
Link: https://blogs.msdn.microsoft.com/psssql/2012/12/11/how-it-works-sql-server-32-bit-paeawe-on-sql-2005-2008-and-2008-r2-not-using-as-much-ram-as-expected/
+Scope: global only #### Trace Flag: 839 Function: (Apparently) forces SQL Server to treate all NUMA memory as “flat”, as if it was SMP.
-Link: https://blogs.msdn.microsoft.com/psssql/2010/04/02/how-it-works-soft-numa-io-completion-thread-lazy-writer-workers-and-memory-nodes +Link: https://blogs.msdn.microsoft.com/psssql/2010/04/02/how-it-works-soft-numa-io-completion-thread-lazy-writer-workers-and-memory-nodes
+Scope: global only #### Trace Flag: 840 Function: SQL 9 – When trace turned on, SQL Server can perform larger I/O extent reads to populate the buffer pool when SQL Server starts this populates the buffer pool faster. Additionally, the larger I/O extent reads improve the initial query compilation and the response time when SQL Server starts.
-Link: https://blogs.msdn.microsoft.com/ialonso/2011/12/09/the-read-ahead-that-doesnt-count-as-read-ahead +Link: https://blogs.msdn.microsoft.com/ialonso/2011/12/09/the-read-ahead-that-doesnt-count-as-read-ahead
+Scope: global only #### Trace Flag: 842 +**Undocumented trace flag**
Function: Use sys.dm_os_memory_node_access_stats to verify local vs. foreign memory under NUMA configurations after turning on this flag
Link: None #### Trace Flag: 845 -Function: Enable Lock pages in Memory on Standard Edition
-Link: https://support.microsoft.com/en-gb/kb/970070
-Link: https://support.microsoft.com/en-us/help/2708594/fix-locked-page-allocations-are-enabled-without-any-warning-after-you-upgrade-to-sql-server-2012 +**Undocumented trace flag**
+Function: Enable Lock pages in Memory on Standard Edition for SQL Server 2005 and 2008.
+Link: https://support.microsoft.com/kb/970070
+Link: https://support.microsoft.com/kb/2708594
+Link: https://www.sqlservergeeks.com/sql-server-trace-flag-845/
+Scope: global only +**Undocumented trace flag**
#### Trace Flag: 851 Function: According to Bob Ward’s PASS 2014 talk on SQL Server IO, “disable[s] BPE even if enabled via ALTER SERVER”
Link: None + +#### Trace Flag: 861 +**Undocumented trace flag**
+Function: According to the error log this disables buffer pool extension.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + + +#### Trace Flag: 862 +**Undocumented trace flag**
+Function: According to the error log this enables buffer pool extension. This TF probably doesn’t do anything anymore.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + + +#### Trace Flag: 876 +Function: Uses large-page allocations for columnstore. +Turns 8k page allocations for Column Store segments into 2MB instead.
+**Note: Unlike trace flag [834](#834), using trace flag 876 does not pre-allocate SQLOS memory at instance startup, and unused memory can be released.**
+**Note: This trace flag applies to SQL Server 2019 (15.x) and higher builds.**
+**Note: Please ensure that you thoroughly test this option, before rolling it into a production environment.**
+Link: [Docs Trace Flags]
+Link: https://twitter.com/slava_oks/status/1044257034361757696
+Link: https://github.com/ktaranov/sqlserver-kit/issues/151
+Scope: global only + + +**Undocumented trace flag**
#### Trace Flag: 888 Function: Enables support for locked pages for SQL 2000
Link: None @@ -772,17 +1040,19 @@ Link: None #### Trace Flag: 902 Function: Bypasses execution of database upgrade script when installing a Cumulative Update or Service Pack. If you encounter an error during script upgrade mode, it is recommended to contact Microsoft SQL Customer Service and Support (CSS) for further guidance.
-**Warning: This trace flag is meant for troubleshooting of failed updates during script upgrade mode, and it is not supported to run it continuously -in a production environment. Database upgrade scripts needs to execute successfully for a complete install of Cumulative Updates and Service Packs. +**Warning: This trace flag is meant for troubleshooting of failed updates during script upgrade mode, and it is not supported to run it continuously in a production environment. +Database upgrade scripts needs to execute successfully for a complete install of Cumulative Updates and Service Packs. Not doing so can cause unexpected issues with your SQL Server instance.**
-Link: https://support.microsoft.com/en-us/kb/2163980
+Link: https://support.microsoft.com/kb/2163980
Link: [Docs Trace Flags]
Link: https://blogs.msdn.microsoft.com/luti/2017/05/17/sql-server-offline-after-applying-service-pack/
+Link: https://blog.sqlauthority.com/2018/11/06/sql-server-script-level-upgrade-for-database-master-failed-because-upgrade-step-msdb110_upgrade-sql-encountered-error-926-state-1-severity-25/
Scope: global only #### Trace Flag: 916 +**Undocumented trace flag**
Function: The KB article references the flag in the context of seeing a Profiler dump
Link: None @@ -790,14 +1060,16 @@ Link: None #### Trace Flag: 1106 Function: SQL 9 - Used space in tempdb increases continuously when you run a query that creates internal objects in tempdb
-Link: https://support.microsoft.com/en-gb/kb/947204
+Link: https://support.microsoft.com/kb/947204
Link: https://blogs.msdn.microsoft.com/arvindsh/2014/02/24/tracking-tempdb-internal-object-space-usage-in-sql-2012 #### Trace Flag: 1117 -Function: When a file in the filegroup meets the autogrow threshold, all files in the filegroup grow.
-**Note: Beginning with SQL Server 2016 this behavior is controlled by the AUTOGROW_SINGLE_FILE and AUTOGROW_ALL_FILES option of ALTER DATABASE, and trace flag 1117 has no affect. For more information, see ALTER DATABASE File and Filegroup Options (Transact-SQL).**
+Function: When a file in the filegroup meets the autogrow threshold, all files in the filegroup grow. +This trace flag affects all databases and is recommended only if every database is safe to be grow all files in a filegroup by the same amount.
+**Note: Beginning with SQL Server 2016 this behavior is controlled by the `AUTOGROW_SINGLE_FILE` and `AUTOGROW_ALL_FILES` option of `ALTER DATABASE`, and trace flag 1117 has no affect. +For more information, see [ALTER DATABASE File and Filegroup Options (Transact-SQL)](https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-database-transact-sql-file-and-filegroup-options).**
Link: https://www.littlekendra.com/2017/01/03/parallelism-and-tempdb-data-file-usage-in-sql-server/
Link: [SQL Server 2016 : Getting tempdb a little more right]
Link: [Docs Trace Flags]
@@ -805,24 +1077,29 @@ Link: http://www.sqlskills.com/blogs/paul/tempdb-configuration-survey-results-an Link: https://blogs.msdn.microsoft.com/ialonso/2011/12/01/attempt-to-grow-all-files-in-one-filegroup-and-not-just-the-one-next-in-the-autogrowth-chain-using-trace-flag-1117
Link: http://sql-articles.com/articles/general/day-6trace-flag-1117-auto-grow-equally-in-all-data-file
Link: http://www.ryanjadams.com/2017/05/trace-flag-1117-growth-contention/
+Link: https://www.sqlskills.com/blogs/paul/misconceptions-around-tf-1118/
+Link: [KB2964518]
+Link: https://www.sqlservergeeks.com/sql-server-trace-flag-1117/
Scope: global only #### Trace Flag: 1118 -Function: Removes most single page allocations on the server, reducing contention on the SGAM page. +Function: Forces page allocations on uniform extents instead of mixed extents, reducing contention on the SGAM page. When a new object is created, by default, the first eight pages are allocated from different extents (mixed extents). Afterwards, when more pages are needed, those are allocated from that same extent (uniform extent). The SGAM page is used to track these mixed extents, so can quickly become a bottleneck when numerous mixed page allocations are occurring. This trace flag allocates all eight pages from the same extent when creating new objects, minimizing the need to scan the SGAM page.
-**Note: Beginning with SQL Server 2016 this behavior is controlled by the SET MIXED_PAGE_ALLOCATION option of ALTER DATABASE, and trace flag 1118 has no affect. For more information, see ALTER DATABASE SET Options (Transact-SQL).**
+**Note: Beginning with SQL Server 2016 this behavior is controlled by the `SET MIXED_PAGE_ALLOCATION` option of `ALTER DATABASE`, and trace flag 1118 has no affect. For more information, see [ALTER DATABASE SET Options (Transact-SQL)](https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-database-transact-sql-set-options).**
Link: http://blogs.msdn.com/b/psssql/archive/2008/12/17/sql-server-2005-and-2008-trace-flag-1118-t1118-usage.aspx
Link: http://www.sqlskills.com/blogs/paul/misconceptions-around-tf-1118/
-Link: https://support.microsoft.com/en-us/kb/328551
+Link: https://support.microsoft.com/kb/328551
Link: [SQL Server 2016 : Getting tempdb a little more right]
Link: [Docs Trace Flags]
Link: https://chrisadkin.org/2015/04/14/well-known-and-not-so-well-known-sql-server-tuning-knobs-and-switches
+Link: [KB2964518]
+Link: https://www.sqlservergeeks.com/sql-server-trace-flag-1118/
Scope: global only @@ -830,34 +1107,45 @@ Scope: global only #### Trace Flag: 1119 Function: Turns off mixed extent allocation (Similar to 1118?)
Link: [TECHNET List Of SQL Server Trace Flags] - + #### Trace Flag: 1124 +**Undocumented trace flag**
Function: Unknown. Has been reportedly found turned on in some SQL Server instances running Dynamics AX. Also rumored to be invalid in public builds of SQL Server
Link: None #### Trace Flag: 1140 +**Undocumented trace flag**
Function: A workaround for a bug in SQL 2005 SP2, SP3, and SQL 2008, where mixed page allocations climb continually, due to a change in the way that mixed-page allocations are done.
Link: None #### Trace Flag: 1165 -Function: This [presentation](http://www.youtube.com/watch?v=SvseGMobe2w&feature=youtu.be) by Bob Ward says that this TF outputs the recalculated #’s (every 8192 allocations) for the proportional fill algorithm in database allocation when multiple files are present..
-Link: None +**Undocumented trace flag**
+Function: In the Proportional Fill Algorithm, each database data file will be assigned with a ranking integer number to specify how many times this file will be skipped from the writing process to the next file depending on the free space of that file, this number is called the Skip Target where the minimum value equal to 1 means that a write process will be performed on that file. +The Skip Target can be measured by dividing the number of free extents in the file with the largest free space amount by the number of free extents in the current file, as integer value. The larger the free space in the database data file, the smaller Skip Target value. +To have one file to write on each loop, there should be minimum one data file with Skip Target value equal to 1. +Each time a new database data file is added or removed, or 8192 extents is filled in the database filegroup, the Skip Target value will be calculated again. In this way, all database data files will become full approximately at the same time. +The Skip Target calculation can be monitored by enabling the Trace Flag 1165.
+Link: https://www.sqlshack.com/understanding-sql-server-proportional-fill-algorithm/
+Scope: global or session +Demo: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Trace_Flag/Trace_Flag_1165.sql #### Trace Flag: 1180 +**Undocumented trace flag**
Function: SQL 7 - Forces allocation to use free pages for text or image data and maintain efficiency of storage. Helpful in case when DBCC SHRINKFILE and SHRINKDATABASE commands may not work because of sparsely populated text, ntext, or image columns.
Link: None #### Trace Flag: 1197 +**Undocumented trace flag**
Function: Applies only in the case of SQL 7 – SP3, similar with trace flag 1180
Link: None @@ -867,70 +1155,87 @@ Link: None Function: Prints detailed lock information as every request for a lock is made (the process ID and type of lock requested)
Link: [TECHNET List Of SQL Server Trace Flags]
Link: https://blogs.msdn.microsoft.com/sqlserverstorageengine/2008/03/30/tempdb-table-variable-vs-local-temporary-table
-Link: https://support.microsoft.com/en-us/help/169960/inf-analyzing-and-avoiding-deadlocks-in-sql-server +Link: [KB169960]
+Link: [Important Trace Flags That Every DBA Should Know]
+Scope: ? #### Trace Flag: 1202 +**Undocumented trace flag**
Function: Insert blocked lock requests into syslocks
Link: None #### Trace Flag: 1204 -Function: Returns the resources and types of locks participating in a deadlock and also the current command affected.
-Link: https://support.microsoft.com/en-us/kb/832524
+Function: Returns the resources and types of locks participating in a deadlock and also the current command affected. +Writes information about deadlocks to the ERRORLOG in a "text format". +Trace flag 1204 provides node base information about deadlock in another words you can say that all nodes which are involved in deadlock. +Finally after all nodes information it also provides information about deadlock victim.
+Link: https://support.microsoft.com/kb/832524
Link: [Docs Trace Flags]
+Link: [Important Trace Flags That Every DBA Should Know]
+Link: https://www.sqlservergeeks.com/sql-server-deadlock-trace-flag-1204/
Scope: global only #### Trace Flag: 1205 Function: More detailed information about the command being executed at the time of a deadlock. Documented in SQL 7 BOL.
-Link: https://support.microsoft.com/en-us/help/832524/sql-server-technical-bulletin---how-to-resolve-a-deadlock +Link: https://support.microsoft.com/kb/832524 #### Trace Flag: 1206 Function: Used to complement flag 1204 by displaying other locks held by deadlock parties
-Link: https://support.microsoft.com/en-us/help/169960/inf-analyzing-and-avoiding-deadlocks-in-sql-server +Link: [KB169960] #### Trace Flag: 1208 Function: KB: “Prints the host name and program name supplied by the client. This can help identify a client involved in a deadlock, assuming the client specifies a unique value for each connection.”
-Link: https://support.microsoft.com/en-us/help/169960/inf-analyzing-and-avoiding-deadlocks-in-sql-server +Link: [KB169960] #### Trace Flag: 1211 Function: Disables lock escalation based on memory pressure, or based on number of locks. The SQL Server Database Engine will not escalate row or page locks to table locks. Using this trace flag can generate excessive numbers of locks. This can slow the performance of the Database Engine, or cause 1204 errors (unable to allocate lock resource) because of insufficient memory. -If both trace flag 1211 and 1224 are set, 1211 takes precedence over 1224. -However, because trace flag 1211 prevents escalation in every case, even under memory pressure, we recommend that you use 1224. +If both trace flag 1211 and [1224](#1224) are set, 1211 takes precedence over [1224](#1224). +However, because trace flag 1211 prevents escalation in every case, even under memory pressure, we recommend that you use [1224](#1224). This helps avoid "out-of-locks" errors when many locks are being used.
Link: [Docs Trace Flags]
Link: http://www.sqlskills.com/blogs/paul/a-sql-server-dba-myth-a-day-2330-lock-escalation
+Link: [Important Trace Flags That Every DBA Should Know]
+Link: https://support.microsoft.com/kb/323630
+Link: https://www.sqlservergeeks.com/sql-server-trace-flag-1211/
Scope: global or session #### Trace Flag: 1216 -Function: SQL 7 - Disables Health reporting. Lock monitor when detects a (worker thread) resource level blocking scenario. If a SPID that owns a lock is currently queued to the scheduler, because all the assigned worker threads have been created and all the assigned worker threads are in an un-resolvable wait state, the following error message is written to the SQL Server error log: Error 1223: Process ID %d:%d cannot acquire lock "%s" on resource %s because a potential deadlock exists on Scheduler %d for the resource. Process ID %d:% d holds a lock "%h" on this resource.
+**Undocumented trace flag**
+Function: SQL 7 - Disables Health reporting. Lock monitor when detects a (worker thread) resource level blocking scenario. If a SPID that owns a lock is currently queued to the scheduler, because all the assigned worker threads have been created and all the assigned worker threads are in an un-resolvable wait state, the following error message is written to the SQL Server error log: Error 1223: Process ID %d:%d cannot acquire lock "%s" on resource %s because a potential deadlock exists on Scheduler %d for the resource. Process ID %d:% d holds a lock "%h" on this resource.
Link: None #### Trace Flag: 1217 +**Undocumented trace flag**
Function: Disables (for 7.0) the “UMS Health” reporting messages described in the KB article.
Link: None #### Trace Flag: 1222 -Function: Returns the resources and types of locks that are participating in a deadlock and also the current command affected, in an XML format that does not comply with any XSD schema.
+Function: Returns the resources and types of locks that are participating in a deadlock and also the current command affected, in an XML format that does not comply with any XSD schema. +Write deadlock information to sql server error log.
Link: [Docs Trace Flags]
+Link: https://blogs.msdn.microsoft.com/bartd/2006/09/08/deadlock-troubleshooting-part-1/
Link: https://blog.sqlauthority.com/2017/01/09/sql-server-get-historical-deadlock-information-system-health-extended-events
+Link: [Important Trace Flags That Every DBA Should Know]
+Link:
Scope: global only @@ -940,13 +1245,14 @@ Function: Disables lock escalation based on the number of locks. However, memory The Database Engine escalates row or page locks to table (or partition) locks if the amount of memory used by lock objects exceeds one of the following conditions: - Forty percent of the memory that is used by Database Engine. This is applicable only when the locks parameter of sp_configure is set to 0. - Forty percent of the lock memory that is configured by using the locks parameter of sp_configure. - -For more information, see [Server Configuration Options (SQL Server)](https://msdn.microsoft.com/en-us/library/ms189631.aspx). -If both trace flag 1211 and 1224 are set, 1211 takes precedence over 1224. +For more information, see [Server Configuration Options (SQL Server)](https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/server-configuration-options-sql-server). +If both trace flag [1211](#1211) and 1224 are set, [1211](#1211) takes precedence over 1224. However, because trace flag 1211 prevents escalation in every case, even under memory pressure, we recommend that you use 1224. This helps avoid "out-of-locks" errors when many locks are being used.
-**Note: Lock escalation to the table- or HoBT-level granularity can also be controlled by using the LOCK_ESCALATION option of the ALTER TABLE statement.**
+**Note: Lock escalation to the table- or HoBT-level granularity can also be controlled by using the `LOCK_ESCALATION` option of the `ALTER TABLE` statement.**
Link: [Docs Trace Flags]
+Link: [Important Trace Flags That Every DBA Should Know]
+Link: https://www.sqlservergeeks.com/sql-server-trace-flag-1224/
Scope: global or session @@ -954,80 +1260,96 @@ Scope: global or session #### Trace Flag: 1228 Function: Enable lock partitioning. By default, lock partitioning is enabled when a server has 16 or more CPUs. Otherwise, lock partitioning is disabled. -Trace flag 1228 enables lock partitioning for 2 or more CPUs. Trace flag 1229 disables lock partitioning. -Trace flag 1229 overrides trace flag 1228 if trace flag 1228 is also set. +Trace flag 1228 enables lock partitioning for 2 or more CPUs. Trace flag [1229](#1229) disables lock partitioning. +Trace flag [1229](#1229) overrides trace flag 1228 if trace flag 1228 is also set. Lock partitioning is useful on multiple-CPU servers where some tables have very high lock rates. -You can turn on trace flag 1228 and trace flag 1229 only at startup.
+You can turn on trace flag 1228 and trace flag [1229](#1229) only at startup.
Link: [Trace Flag 1228 and 1229]
-Link: [Microsoft SQL Server 2005 TPC-C Trace Flags] +Link: [Microsoft SQL Server 2005 TPC-C Trace Flags]
+Scope: global only #### Trace Flag: 1229 -Function: Enable lock partitioning. -By default, lock partitioning is enabled when a server has 16 or more CPUs. Otherwise, lock partitioning is disabled. -Trace flag 1228 enables lock partitioning for 2 or more CPUs. Trace flag 1229 disables lock partitioning. -Trace flag 1229 overrides trace flag 1228 if trace flag 1228 is also set. -Lock partitioning is useful on multiple-CPU servers where some tables have very high lock rates. -You can turn on trace flag 1228 and trace flag 1229 only at startup.
+Function: Disables all lock partitioning regardless of the number of CPUs. +By default, SQL Server enables lock partitioning when a server has 16 or more CPUs, to improve the scalability characteristics of larger systems. +For more information on lock partitioning, see the [Transaction Locking and Row Versioning Guide](https://docs.microsoft.com/en-us/sql/relational-databases/sql-server-transaction-locking-and-row-versioning-guide?view=sql-server-2017#lock_partitioning)
+**WARNING: Trace flag 1229 can cause spinlock contention and poor performance.** +Link: [Docs Trace Flags]
Link: [Trace Flag 1228 and 1229]
-Link: [Microsoft SQL Server 2005 TPC-C Trace Flags] +Link: [Microsoft SQL Server 2005 TPC-C Trace Flags]
+Scope: global only #### Trace Flag: 1236 Function: Enables database lock partitioning. Fixes performance problem in scenarios with high lock activity in SQL 2012 and SQL 2014.
**Note: Beginning with SQL Server 2012 SP3 and SQL Server 2014 SP1 this behavior is controlled by the engine and trace flag 1236 has no effect.**
-Link: https://support.microsoft.com/en-us/kb/2926217
+Link: https://support.microsoft.com/kb/2926217
Link: [Docs Trace Flags]
+Link: [KB2964518]
Scope: global only #### Trace Flag: 1237 Function: Allows the `ALTER PARTITION FUNCTION` statement to honor the current user-defined session deadlock priority instead of being the likely deadlock victim by default.
-**Note: Starting with SQL Server 2017 and database [compatibility level] 140 this is the default behavior and trace flag 1237 has no effect.** -Link: http://support.microsoft.com/help/4025261
+**Note: Starting with SQL Server 2017 and database [compatibility level] 140 this is the default behavior and trace flag 1237 has no effect.**
+Link: https://support.microsoft.com/kb/4025261
Link: [Docs Trace Flags]
Scope: global or session or query + + + +#### Trace Flag: 1252 +**Undocumented trace flag**
+Function: It prints some kind of lock related information when [3604](#3604) is also enabled. Example: +``` +SELECT * FROM master..spt_values +OPTION (QUERYTRACEON 1252, QUERYTRACEON 3604); +``` +
+Link: https://github.com/ktaranov/sqlserver-kit/issues/196
+Scope: ? #### Trace Flag: 1260 Function: Disabled mini-dump for non-yield condition. Disables mini-dump generation for "any of the 17883, 17884, 17887, or 17888 errors. -The trace flag can be used in conjunction with trace flag –T1262. For example, you -could enable –T1262 to get 10- and a 60-second interval reporting and also enable – T1260 to avoid getting mini-dumps."
+The trace flag can be used in conjunction with trace flag –T1262. For example, you could enable `–T1262` to get 10- and a 60-second interval reporting and also enable `–T1260` to avoid getting mini-dumps."
Link: [A Topical Collection of SQL Server Flags v6]
Link: [How To Diagnose and Correct Errors 17883, 17884, 17887, and 17888]
Link: [Docs Trace Flags]
+Link: https://www.sqlservergeeks.com/sql-trace-flag-1260/
Scope: global only #### Trace Flag: 1261 +**Undocumented trace flag**
Function: SQL 8 - Disables Health reporting. Lock monitor when detects a (worker thread) resource level blocking scenario. If a SPID that owns a lock is currently queued to the scheduler, because all the assigned worker threads have been created and all the assigned worker threads are in an un-resolvable wait state, the following error message is written to the SQL Server error log: Error 1229: Process ID %d:%d owns resources that are blocking processes on scheduler %d.
Link: None #### Trace Flag: 1262 -Function: The default behavior (for 1788* errors) is for SQL to generate a mini-dump on the first -occurrence, but never after. 1262 changes the behavior: “When –T1262 is enabled, a -mini-dump is generated when the non-yielding condition is declared (15 seconds) and -at subsequent 60-second intervals for the same non-yield occurrence. A new nonDiagCorrect17883etc; -yielding occurrence causes dump captures to occur again.” +Function: The default behavior (for 1788* errors) is for SQL to generate a mini-dump on the first occurrence, but never after. +1262 changes the behavior: “When –T1262 is enabled, a mini-dump is generated when the non-yielding condition is declared (15 seconds) and at subsequent 60-second intervals for the same non-yield occurrence. +A new nonDiagCorrect17883etc; yielding occurrence causes dump captures to occur again.” In SQL 2000 this was a startup-only flag; in 2005+ it can be enabled via TRACEON. Note that the flag is also covered in Khen2005, p400, but with no new information.
Link: [A Topical Collection of SQL Server Flags v6]
-Link: [How To Diagnose and Correct Errors 17883, 17884, 17887, and 17888] +Link: [How To Diagnose and Correct Errors 17883, 17884, 17887, and 17888]
+Link: https://www.sqlservergeeks.com/sql-trace-flag-1262/
+Scope: global or session #### Trace Flag: 1264 Function: Collect process names in non-yielding scenario memory dumps
Link: [A Topical Collection of SQL Server Flags v6]
-Link: http://support.microsoft.com/kb/2630458/en-us +Link: https://support.microsoft.com/kb/2630458 @@ -1055,18 +1377,17 @@ Scope: global only #### Trace Flag: 1449 Function: When you use SNAC to connect to an instance of a principal server in a database mirroring session: "The connection attempted to fail over to a server that does not have a failover partner".
-Link: https://support.microsoft.com/en-gb/kb/936179 +Link: https://support.microsoft.com/kb/936179 #### Trace Flag: 1462 Function: Disables log stream compression for asynchronous availability groups. This feature is enabled by default on asynchronous availability groups in order to optimize network bandwidth.
-Link: [MSDN mt736907]
+Link: [Tune compression for availability group]
Link: [Docs Trace Flags]
Link: http://www.sqlskills.com/blogs/paul/sql-server-2008-performance-boost-for-database-mirroring
Link: http://sqlblog.com/blogs/joe_chang/archive/2014/03/13/hekaton-and-benchmarks.aspx
-Link: https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0CCYQFjAB&url=http%3A%2F%2Fdownload.microsoft.com%2Fdownload%2F0%2FF%2FB%2F0FBFAA46-2BFD-478F-8E56-7BF3C672DF9D%2FSQLCAT%27s%2520Guide%2520to%2520High%2520Availability%2520Disaster%2520Recovery.pdf&ei=4eGJVfzVHI35oASj25ygBg&usg=AFQjCNHWYH0t3bF8HqBuNuutrielPX3hJg&sig2=xno-YS7agP9DRG-CzNe0Ug&bvm=bv.96339352,bs.1,d.b2w
Scope: global only @@ -1141,8 +1462,11 @@ Link: None #### Trace Flag: 1800 -Function: Enables SQL Server optimization when disks of different sector sizes are used for primary and secondary replica log files, in SQL Server AG and Log Shipping environments.
-Link: https://support.microsoft.com/en-us/kb/3009974
+Function: Enables SQL Server optimization when disks of different sector sizes are used for primary and secondary replica log files, in SQL Server Always On and Log Shipping environments. +This trace flag is only required to be enabled on SQL Server instances with transaction log file residing on disk with sector size of 512 bytes. +It is **not** required to be enabled on disk with 4k sector sizes.
+**Note: This trace flag applies to SQL Server 2012 (11.x) SP1 CU13, SQL Server 2012 (11.x) SP2 CU3, SQL Server 2014 (12.x) RTM CU5, and higher builds.**
+Link: https://support.microsoft.com/kb/3009974
Link: [Docs Trace Flags]
Scope: global only @@ -1150,23 +1474,26 @@ Scope: global only #### Trace Flag: 1802 Function: SQL 9 - After detaching a database that resides on network-attached storage, you cannot reattach the SQL Server database
-Link: https://support.microsoft.com/en-us/kb/922804 +Link: https://support.microsoft.com/kb/922804 #### Trace Flag: 1806 -Function: Disable Instant File Initialization
+Function: Disable Instant File Initialization. +Used to guarantee the physical data file space acquisition during data file creation or expansion, on a thin provisioned subsystem
Link: http://technet.microsoft.com/en-au/library/cc917726.aspx
Link: https://blogs.msdn.microsoft.com/sql_pfe_blog/2009/12/22/how-and-why-to-enable-instant-file-initialization
Link: http://www.sqlskills.com/blogs/paul/a-sql-server-dba-myth-a-day-330-instant-file-initialization-can-be-controlled-from-within-sql-server
-Link: https://support.microsoft.com/en-us/help/2574695/file-initialization-takes-a-long-time-for-sql-server-database-related-operations +Link: https://support.microsoft.com/kb/2574695
+Link: [Important Trace Flags That Every DBA Should Know]
+Scope: ? #### Trace Flag: 1807 Function: Enable option to have database files on SMB share for SQL Server 2008 and 2008R2
Link: http://blogs.msdn.com/b/varund/archive/2010/09/02/create-a-sql-server-database-on-a-network-shared-drive.aspx
-Link: https://support.microsoft.com/en-us/help/304261/description-of-support-for-network-database-files-in-sql-server +Link: https://support.microsoft.com/kb/304261 @@ -1187,6 +1514,15 @@ Function: Bob Ward briefly references this flag in his PASS 2014 SQL Server IO t Link: None + +#### Trace Flag: 1819 +Function: Allows [backup to URL](https://docs.microsoft.com/en-gb/sql/relational-databases/backup-restore/sql-server-backup-to-url?view=sql-server-ver15) to leverage a proxy server when accessing Azure block blobs. In addition to this trace flag, you must set the WinHTTP proxy configuration on the server via one of the following methods: +- The [`proxycfg.exe`](https://docs.microsoft.com/en-us/windows/win32/winhttp/proxycfg-exe--a-proxy-configuration-tool) utility on Windows XP or Windows Server 2003 and earlier. +- The [`netsh.exe`]() utility on Windows Vista and Windows Server 2008 or later.
+Link: [Docs Trace Flags] +Scope: global or session or query (QUERYTRACEON) + + #### Trace Flag: 1851 Function: Anecdotally, from a JustDave’s notes on an Amanda Ford talk at SQL Relay Reading 2014: “...disables the automerge functionality for in-memory oltp”
@@ -1201,33 +1537,50 @@ Link: Note #### Trace Flag: 1905 -Function: Unknown +Function: Unknown
Link: [Upgrading an expired SQL Server 2016 Evaluation Edition] + +#### Trace Flag: 1906 +**Undocumented trace flag**
+Function: It enables SQL Server to read ETW tracing templates stored in the `etwcnf.xml` directory on SQL Server 2008. +When the flag is turned off, the file is not read, and a static in-memory ETW template is used instead. +It is not documented because it can cause SQL Server to hang on startup. +We will be supported by Microsoft running this trace flag as long as we do not experience start up "hangs". +Microsoft recommends using Xevents instead the template file.
+Link: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/0489f308-2e0c-479f-85a8-9a5661b2462f/trace-flag-1906?forum=sqldatabaseengine + + #### Trace Flag: 2301 -Function: Enable advanced decision support optimizations
+Function: Trace flag 2301 enables advanced optimizations that are specific to decision support queries. +This option applies to decision support processing of large data sets.
Link: [KB920093]
Link: [Docs Trace Flags]
Link: http://www.queryprocessor.com/ce_join_base_containment_assumption
Link: https://connect.microsoft.com/SQLServer/feedback/details/772232/make-optimizer-estimations-more-accurate-by-using-metadata
-Scope: global and session and query +Link: https://www.sqlservergeeks.com/sql-server-trace-flag-2301/
+Scope: global or session or query #### Trace Flag: 2309 -Function: In SQL 2014, enables output from a 3rd parameter for DBCC SHOW_STATISTICS such that the partial statistics histogram (for just one partition) is shown.
+Function: In SQL 2014, enables output from a 3rd parameter for [DBCC SHOW_STATISTICS] such that the partial statistics histogram (for just one partition) is shown.
Link: https://sqlperformance.com/2015/05/sql-statistics/incremental-statistics-are-not-used-by-the-query-optimizer
Link: http://blog.dbi-services.com/sql-server-2014-new-incremental-statistics #### Trace Flag: 2312 -Function: Enables you to set the query optimizer cardinality estimation model to the SQL Server 2014 through SQL Server 2016 versions, dependent of the compatibility level of the database.
+Function: Sets the query optimizer cardinality estimation model to the SQL Server 2014 (12.x) through SQL Server 2017 versions, dependent of the compatibility level of the database. +Starting with SQL Server 2016 (13.x) SP1, to accomplish this at the query level, add the USE HINT 'FORCE_DEFAULT_CARDINALITY_ESTIMATION' query hint instead of using this trace flag.
+**Note: If the database compatibility level is lower than 120, enabling trace flag 2312 uses the cardinality estimation model of SQL Server 2014 (12.x) (120).** Link: [KB2801413]
Link: [New Features in SQL Server 2016 Service Pack 1]
Link: [Docs Trace Flags]
+Link: http://www.sqlservergeeks.com/sql-server-2014-trace-flags-2312/
+Link: [KB2801413]
Scope: global or session or query @@ -1274,7 +1627,7 @@ Link: https://chrisadkin.org/2015/04/14/well-known-and-not-so-well-known-sql-ser #### Trace Flag: 2332 Function: PWhite: “Force DML Request Sort (CUpdUtil::FDemandRowsSortedForPerformance)”
-Link: http://sqlblog.com/blogs/paul_white/archive/2013/01/26/optimizing-t-sql-queries-that-change-data.aspx +Link: [Optimizing T-SQL queries that change data] @@ -1282,9 +1635,11 @@ Link: http://sqlblog.com/blogs/paul_white/archive/2013/01/26/optimizing-t-sql-qu Function: Causes SQL Server to assume a fixed amount of memory is available during query optimization. It does not limit the memory SQL Server grants to execute the query. The memory configured for SQL Server will still be used by data cache, query execution and other consumers.
**Note: Please ensure that you thoroughly test this option, before rolling it into a production environment.**
-Link: https://support.microsoft.com/en-us/kb/2413549
+Link: https://www.brentozar.com/archive/2018/08/how-trace-flag-2335-affects-memory-grants/
+Link: https://support.microsoft.com/kb/2413549
Link: [Docs Trace Flags]
Link: http://dba.stackexchange.com/questions/53726/difference-in-execution-plans-on-uat-and-prod-server
+Link: [KB2801413]
Scope: global or session or query @@ -1296,46 +1651,67 @@ Link: None #### Trace Flag: 2340 -Function: Causes SQL Server not to use a sort operation (batch sort) for optimized nested loop joins when generating a plan. -Beginning with SQL Server 2016 SP1, to accomplish this at the query level, add the USE HINT query hint instead of using this trace flag.
+Function: Causes SQL Server not to use a sort operation (batch sort) for optimized Nested Loops joins when generating a plan. +By default, SQL Server can use an optimized Nested Loops join instead of a full scan or a Nested Loops join with an explicit Sort, when the Query Optimizer concludes that a sort is most likely not required, but still a possibility in the event that the cardinality or cost estimates are incorrect. +Starting with SQL Server 2016 (13.x) SP1, to accomplish this at the query level, add the USE HINT 'DISABLE_OPTIMIZED_NESTED_LOOP' query hint instead of using this trace flag..
**Note: Please ensure that you thoroughly test this option, before rolling it into a production environment.**
Link: [New Features in SQL Server 2016 Service Pack 1]
Link: [Docs Trace Flags]
Link: https://blogs.msdn.microsoft.com/psssql/2010/01/11/high-cpu-after-upgrading-to-sql-server-2005-from-2000-due-to-batch-sort
Link: http://www.queryprocessor.com/batch-sort-and-nested-loops
+Link: [KB2801413]
+Link: https://www.sqlservergeeks.com/trace-flag-2340/
Scope: global or session or query #### Trace Flag: 2341 Function: Enables the use of a hash join for joins to column store indexes even when the join clause would normally be removed “during query normalization”.
-Link: https://support.microsoft.com/en-us/help/3146123/query-plan-generation-improvement-for-some-columnstore-queries-in-sql-server-2014-or-2016 +Link: https://support.microsoft.com/kb/3146123 #### Trace Flag: 2363 -Function: TF Selectivity
+Function: TF Selectivity. can be used with the new cardinality estimation model to see the derivation of the distinct estimate on the outer input to an apply, and cardinality estimation in general.
Link: [Cardinality Estimation Framework 2014 First Look]
Link: http://www.queryprocessor.com/ce-process
Link: https://sqlperformance.com/2014/01/sql-plan/cardinality-estimation-for-multiple-predicates +Link: [Nested Loops Joins and Performance Spools]
+Link: [Cardinality Estimation for Multiple Predicates]
+Scope: session or query + + + +#### Trace Flag: 2368 +**Undocumented trace flag**
+Function: For one query, this resulted in a parallel plan significantly more expensive than the naturally occurring serial plan. Could be related to trace flag 3651.
+Link: [New Undocumented Trace Flags]
+Scope: ? #### Trace Flag: 2371 -Function: Changes the fixed auto update statistics threshold to dynamic auto update statistics threshold.
-**Note: Beginning with SQL Server 2016 this behavior is controlled by the engine and trace flag 2371 has no effect.**
-Link: https://support.microsoft.com/en-us/kb/2754171
-Link: http://blogs.msdn.com/b/saponsqlserver/archive/2011/09/07/changes-to-automatic-update-statistics-in-sql-server-traceflag-2371.aspx
+Function: Changes the fixed update statistics threshold to a linear update statistics threshold. +Change a fixed rate 20% of rows changed for Recompilation Thresholds (RT) on new formula - **SQRT(1000 * table rows)**
+**Note: Starting with SQL Server 2016 (13.x) and under the database compatibility level 130 or above, this behavior is controlled by the engine and trace flag 2371 has no effect.**
+Link: https://support.microsoft.com/kb/2754171
+Link: https://blogs.msdn.microsoft.com/saponsqlserver/2011/09/07/changes-to-automatic-update-statistics-in-sql-server-traceflag-2371/
Link: https://blogs.msdn.microsoft.com/axinthefield/sql-server-trace-flag-2371-for-dynamics-ax/
Link: [Docs Trace Flags]
-Scope: global only +Link: [KB2964518]
+Link: https://www.sqlservergeeks.com/sql-server-trace-flag-2371/
+Link: [Temporary Table Caching in Stored Procedures]
+Scope: global or session +Demo: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Trace_Flag/Trace_Flag_2371.sql #### Trace Flag: 2372 -Function: Displays memory utilization during the optimization process. Memory for Phases.
+Function: Displays memory utilization during the optimization process. Memory for Phases +Memory before and after deriving properties and rules (verbose)
Link: [More Undocumented Query Optimizer Trace Flags]
-Link: [Cardinality Estimation Framework 2014 First Look] +Link: [Cardinality Estimation Framework 2014 First Look]
+Link: [Query Optimizer Deep Dive - Part 4] @@ -1345,32 +1721,58 @@ Link: [More Undocumented Query Optimizer Trace Flags]
Link: [Cardinality Estimation Framework 2014 First Look] + +#### Trace Flag: 2374 +**Undocumented trace flag**
+Function: Removes QueryHash and QueryPlanHash information from estimated query plans.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + #### Trace Flag: 2382 Function: SSC: “SQL 8 -Statistics collected for system tables.”
Link: None + +#### Trace Flag: 2387 +**Undocumented trace flag**
+Function: can be used to reduce the CPU cost of reading rows from a lazy index spool. +This flag affects general CPU cost estimates for reading a range of rows from a b-tree. +This flag tends to make index spool selection more likely, for cost reasons.
+Link: [New Undocumented Trace Flags]
+Link: [Nested Loops Joins and Performance Spools]
+Scope: ? + + #### Trace Flag: 2388 -Function: Changes the output of DBCC SHOW_STATISTICS. +Function: Changes the output of [DBCC SHOW_STATISTICS]. Instead of the normal Header/Vector/Histogram output, instead we get a single row that gives information related to whether the lead column of the stat object is considered to be ascending or not. -This TF is primarily helpful in watching the state of a stat object change from “Unknown”, to “Ascending” (and potentially to “Stationary”).
-Link: [SQL Server - estimates outside of the histogram - half-baked draft] +This TF is primarily helpful in watching the state of a stat object change from “Unknown”, to “Ascending” (and potentially to “Stationary”). +Also In SQL Server, if you want to see the information of last four statistics update on a statistics object then you can use trace flag 2388. +In simple words, we can say that this trace flag provide us the historical information about statistics update.
+Link: [SQL Server - estimates outside of the histogram - half-baked draft]
+Link: http://www.sqlservergeeks.com/sql-server-trace-flag-2388/
+Link: [Fun with SQL Server Plan Cache, Trace Flag 8666, and Trace Flag 2388]
+Scope: session only #### Trace Flag: 2389 Function: Enable automatically generated quick statistics for ascending keys (histogram amendment). If trace flag 2389 is set, and a leading statistics column is marked as ascending, then the histogram used to estimate cardinality will be adjusted at query compile time.
-Link: [KB2801413]
+**Note: This trace flag does not apply to CE version 120 or above. Use trace flag [4139](#4139) instead.**
+Link:
Link: http://blogs.msdn.com/b/ianjo/archive/2006/04/24/582227.aspx
Link: http://www.sqlmag.com/article/tsql3/making-the-most-of-automatic-statistics-updating--96767
-Link: http://sqlperformance.com/2016/07/sql-statistics/trace-flag-2389-new-cardinality-estimator
+Link: https://sqlperformance.com/2016/07/sql-statistics/trace-flag-2389-new-cardinality-estimator
Link: https://www.sswug.org/sswugresearch/community/trace-flag-2389-and-the-new-cardinality-estimator/
Link: [New Features in SQL Server 2016 Service Pack 1]
Link: [Docs Trace Flags]
Link: [SQL Server - estimates outside of the histogram - half-baked draft]
+Link: http://www.sqlservergeeks.com/sql-server-trace-flag-2389/
Scope: global or session or query @@ -1378,12 +1780,15 @@ Scope: global or session or query #### Trace Flag: 2390 Function: Enable automatically generated quick statistics for ascending or unknown keys (histogram amendment). If trace flag 2390 is set, and a leading statistics column is marked as ascending or unknown, then the histogram used to estimate cardinality will be adjusted at query compile time
+**Use this flag only with [2389](#2389) trace flag.**
+**Note: This trace flag does not apply to CE version 120 or above. Use trace flag [4139](#4139) instead.**
Link: http://blogs.msdn.com/b/ianjo/archive/2006/04/24/582227.aspx
Link: [KB2801413]
Link: http://www.sqlmag.com/article/tsql3/making-the-most-of-automatic-statistics-updating--96767
Link: [Docs Trace Flags]
Link: https://blogs.msdn.microsoft.com/ianjo/2006/04/24/ascending-keys-and-auto-quick-corrected-statistics
Link: [SQL Server - estimates outside of the histogram - half-baked draft]
+Link: http://www.sqlservergeeks.com/sql-server-trace-flag-2390/
Scope: global or session or query @@ -1396,29 +1801,48 @@ The problem is, it will not disable/enable missing index stats collection unless If you set it as a startup TF and restart SQL Server, then no missing index stats are collected. If you then subsequently disable TF 2392 while SQL Server is running, it still won’t collect any missing index stats (despite what you may expect).
Link: https://www.sqlskills.com/blogs/glenn/sql-server-missing-indexes-feature-and-trace-flag-2392/
-Link: https://support.microsoft.com/en-us/help/4042232/fix-access-violation-when-you-cancel-a-pending-query-if-the-missing-in
+Link: https://support.microsoft.com/kb/4042232
Scope: global only #### Trace Flag: 2398 -Function: Another one I stumbled upon myself...outputs info about “Smart Seek costing”: e.g.: “Smart seek costing (75.2) :: 1.34078e+154 , 1”
-Link: None +**Undocumented trace flag**
+Function: Disable SSC (Smart Seek Costing). +SSC attempts to assess inner side seek I/O cost in more detail, perhaps by considering local ordering and/or the range of values to fetch.
+Link: https://dba.stackexchange.com/a/149933/107045
+Scope: session or query + + + +#### Trace Flag: 2399 +**Undocumented trace flag**
+Function: Small changes in operator costs were observed for some queries. These were typically less than 0.01 units.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + + +#### Trace Flag: 2418 +**Undocumented trace flag**
+Function: Disables serial Batch mode processing.
+Link: [New Undocumented Trace Flags]
+Scope: ? #### Trace Flag: 2422 Function: Enables the SQL Server Database Engine to abort a request when the maximum time set by Resource Governor REQUEST_MAX_CPU_TIME_SEC configuration is exceeded.
**Note: This trace flag applies to SQL Server 2017 CU3 and higher builds.**
-Link: http://support.microsoft.com/help/4038419
+Link: https://support.microsoft.com/kb/4038419
Scope: global only #### Trace Flag: 2430 Function: Fixes performance problem when using large numbers of locks
-Link: https://support.microsoft.com/en-us/kb/2754301
-Link: https://support.microsoft.com/en-us/help/2746341/fix-high-cpu-usage-when-you-execute-an-update-statement-that-includes-a-where-current-of-cursor-clause-in-sql-server-2008 +Link: https://support.microsoft.com/kb/2754301
+Link: https://support.microsoft.com/kb/2746341 @@ -1427,14 +1851,26 @@ Function: SQL 10 - Parallel query execution strategy on partitioned tables. SQL Link: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/dc010af9-afa0-4c87-937c-4343b4e1119a/trace-flag-2440 + +#### Trace Flag: 2451 +**Note: This trace flag applies to SQL Server 2019 preview CTP 2.4 and higher builds.** +Function: Enables the equivalent of the last actual execution plan in [`sys.dm_exec_query_plan_stats`](https://docs.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-exec-query-stats-transact-sql).
+Link: [Docs Trace Flags]
+SQL Server Version: >= 2019 CTP 2.4
+Scope: global only + + #### Trace Flag: 2453 Function: Allow a table variable to trigger recompile when enough number of rows are changed with may allow the query optimizer to choose a more efficient plan.
**Note: Please ensure that you thoroughly test this option, before rolling it into a production environment.**
-Link: http://sqlperformance.com/2014/06/t-sql-queries/table-variable-perf-fix
-Link: https://support.microsoft.com/en-us/kb/2952444
+Link: https://sqlperformance.com/2014/06/t-sql-queries/table-variable-perf-fix
+Link: https://support.microsoft.com/kb/2952444
Link: [Docs Trace Flags]
Link: https://www.brentozar.com/archive/2017/02/using-trace-flag-2453-improve-table-variable-performance
+Link: https://www.brentozar.com/archive/2018/03/table-valued-parameters-unexpected-parameter-sniffing
+Link: [TEMPDB – Files and Trace Flags and Updates]
+Link: http://www.sqlservergeeks.com/the-correct-cardinality-estimation-for-table-variable-using-trace-flag-2543/
Scope: global or session or query @@ -1454,27 +1890,45 @@ Link: https://blogs.msdn.microsoft.com/psssql/2013/09/27/how-it-works-maximizing #### Trace Flag: 2467 -Function: “If target MAXDOP target is less than a single node can provide and if trace flag 2467 is enabled attempt to locate least loaded node”
+Function: Enables an alternate parallel worker thread allocation policy, based on which node has the least allocated threads. +For more information, see [Parallel Query Processing](https://docs.microsoft.com/en-us/sql/relational-databases/query-processing-architecture-guide#parallel-query-processing). +Refer to [Configure the max worker threads Server Configuration Option](https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/configure-the-max-worker-threads-server-configuration-option) for information on configuring the max worker threads server option. +**Note: Query degree of parallelism (DOP) has to fit into a single node for this alternate policy to be used, or the default thread allocation policy is used instead. Using this trace flag, it is not recommended to execute queries specifying a DOP over the number of schedulers in a single node, as this could interfere with queries specifying a DOP below or equal to the number of schedulers in a single node. +Note: Please ensure that you thoroughly test this option, before rolling it into a production environment.**
+Link: [Docs Trace Flags]
Link: https://blogs.msdn.microsoft.com/psssql/2013/09/27/how-it-works-maximizing-max-degree-of-parallelism-maxdop
-Link: [SQL Server Parallel Query Placement Decision Logic] +Link: https://erikdarlingdata.com/2019/06/thoughts-on-maxdop/
+Link: [SQL Server Parallel Query Placement Decision Logic]
+Scope: global only #### Trace Flag: 2468 +**Undocumented trace flag**
Function: “Find the next node that can service the DOP request. Unlike full mode, the global, resource manager keeps track of the last node used. Starting from the last position, and moving to the next node, SQL Server checks for query placement opportunities. If a node can’t support the request SQL Server continues advancing nodes and searching.”
Link: [SQL Server Parallel Query Placement Decision Logic] + +#### Trace Flag: 2469 +Function: Enables alternate exchange for `INSERT INTO ... SELECT` into a partitioned columnstore index.
+Link: [Docs Trace Flags]
+Link: https://support.microsoft.com/kb/3204769/
+Scope: global or session or query + + #### Trace Flag: 2470 +**Undocumented trace flag**
Function: Fixes performance problem when using AFTER triggers on partitioned tables
-Link: https://support.microsoft.com/en-us/kb/2606883 +Link: https://support.microsoft.com/kb/2606883 #### Trace Flag: 2479 +**Undocumented trace flag**
Function: When SQL Server is determining the runtime DOP for a parallel plan, this flag directs it to limit the NUMA Node placement for the query to the node that the connection is associated with.
Link: https://blogs.msdn.microsoft.com/psssql/2013/09/27/how-it-works-maximizing-max-degree-of-parallelism-maxdop
Link: [SQL Server Parallel Query Placement Decision Logic] @@ -1482,11 +1936,13 @@ Link: [SQL Server Parallel Query Placement Decision Logic] #### Trace Flag: 2486 +**Undocumented trace flag**
Function: In SQL 2016 (CTP 3.0 at least), enables output for the “query_trace_column_values” Extended Event, allowing the value of output columns from individual plan iterators to be traced.
Link: http://www.queryprocessor.com/query-trace-column-values +**Undocumented trace flag**
#### Trace Flag: 2505 Function: SQL 7 - Prevents DBCC TRACEON 208, SPID 10 errors from appearing in the error log (Note: DBCC TRACEON(208) just means “SET QUOTED IDENTIFIER ON”)
Link: None @@ -1494,24 +1950,28 @@ Link: None #### Trace Flag: 2508 +**Undocumented trace flag**
Function: Disables parallel non-clustered index checking for DBCC CHECKTABLE
Link: None #### Trace Flag: 2509 -Function: Used with DBCC CHECKTABLE to see the total count of forward records in a table
+**Undocumented trace flag**
+Function: Used with `DBCC CHECKTABLE` to see the total count of forward records in a table
Link: None #### Trace Flag: 2514 +**Undocumented trace flag**
Function: Verbose Merge Replication logging to msmerge\_history table for troubleshooting Merger repl performance
Link: http://sqlblog.com/blogs/argenis_fernandez/archive/2012/05/29/ghost-records-backups-and-database-compression-with-a-pinch-of-security-considerations.aspx #### Trace Flag: 2520 +**Undocumented trace flag**
Function: For SQL Server prior 2005. Forces DBCC HELP to return syntax of undocumented DBCC statements. If 2520/2588 is not turned on, DBCC HELP will refuse to give you the syntax stating: "No help available for DBCC statement 'undocumented statement'". Also affects dbcc help ('?')
@@ -1521,35 +1981,36 @@ Scope: session only #### Trace Flag: 2521 +**Undocumented trace flag**
Function: SQL 7 SP2 - Facilitates capturing a Sqlservr.exe user-mode crash dump for postmortem analysis
Link: None #### Trace Flag: 2528 -Function: Disables parallel checking of objects by DBCC CHECKDB, DBCC CHECKFILEGROUP, and DBCC CHECKTABLE. -By default, the degree of parallelism is automatically determined by the query processor. -The maximum degree of parallelism is configured just like that of parallel queries. -For more information, see [Configure the max degree of parallelism Server Configuration Option](https://msdn.microsoft.com/en-us/library/ms189094.aspx). -Parallel DBCC should typically be left enabled. -For DBCC CHECKDB, the query processor reevaluates and automatically adjusts parallelism with each table or batch of tables checked. -Sometimes, checking may start when the server is almost idle. -An administrator who knows that the load will increase before checking is complete may want to manually decrease or disable parallelism. -Disabling parallel checking of DBCC can cause DBCC to take much longer to complete and if DBCC is run with the TABLOCK feature enabled and parallelism set off, tables may be locked for longer periods of time.
+Function: Disables parallel checking of objects by DBCC CHECKDB, DBCC CHECKFILEGROUP, and DBCC CHECKTABLE. By default, the degree of parallelism is automatically determined by the query processor. +The maximum degree of parallelism is configured just like that of parallel queries. For more information, see [Configure the max degree of parallelism Server Configuration Option](https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/configure-the-max-degree-of-parallelism-server-configuration-option). +**Note: Parallel DBCC checks should typically be enabled (default). The query processor reevaluates and automatically adjusts parallelism for each table or batch of tables checked by DBCC CHECKDB.** +The typical use scenario is when a system administrator knows that server load will increase before DBCC CHECKDB completes, and so chooses to manually decrease or disable parallelism, in order to increase concurrency with other user workload. However, disabling parallel checks in DBCC CHECKDB can cause it to take longer to complete. +**Note: If DBCC CHECKDB is executed using the TABLOCK option and parallelism is disabled, tables may be locked for longer periods of time.** +**Note: Starting with SQL Server 2014 (12.x) SP2, a MAXDOP option is available to override the max degree of parallelism configuration option of sp_configure for the DBCC statements.** Link: [Docs Trace Flags]
-Link: https://technet.microsoft.com/en-us/library/ms189094.aspx
Link: http://www.sqlskills.com/blogs/paul/checkdb-from-every-angle-how-long-will-checkdb-take-to-run
+Link: [Important Trace Flags That Every DBA Should Know]
+Link: https://www.sqlservergeeks.com/sql-server-trace-flag-2528/
Scope: global or session #### Trace Flag: 2529 +**Undocumented trace flag**
Function: Displays memory usage for DBCC commands when used with TF 3604
Link: None #### Trace Flag: 2536 +**Undocumented trace flag**
Function: Allows you to see inactive records in transaction log using fn\_dblog. Similar to trace flag 2537 for older version than SQL Server 2008.
Link: http://www.sqlsoldier.com/wp/sqlserver/day19of31daysofdisasterrecoveryhowmuchlogcanabackuplog @@ -1557,65 +2018,80 @@ Link: http://www.sqlsoldier.com/wp/sqlserver/day19of31daysofdisasterrecoveryhowm #### Trace Flag: 2537 -Function: Allows you to see inactive records in transaction log using fn\_dblog
+**Undocumented trace flag**
+Function: By using this trace flag, function `fn_dblog()` will read both active and inactive portions of transaction log.
Link: http://www.sqlsoldier.com/wp/sqlserver/day19of31daysofdisasterrecoveryhowmuchlogcanabackuplog
-Link: http://www.sqlskills.com/blogs/paul/finding-out-who-dropped-a-table-using-the-transaction-log +Link: http://www.sqlskills.com/blogs/paul/finding-out-who-dropped-a-table-using-the-transaction-log
+Link: http://sqlserverandme.blogspot.ru/2014/03/how-to-view-transaction-log.html
+Link: https://www.sqlservergeeks.com/trace-flag-2537/
+Scope: session only #### Trace Flag: 2540 +**Undocumented trace flag**
Function: Unknown, but related to controlling the contents of a memory dump
-Link: http://support.microsoft.com/kb/917825/en-us +Link: [KB917825] #### Trace Flag: 2541 +**Undocumented trace flag**
Function: Unknown, but related to controlling the contents of a memory dump
-Link: http://support.microsoft.com/kb/917825/en-us +Link: [KB917825] #### Trace Flag: 2542 -Function: Unknown, but related to controlling the contents of a memory dump
-Link: http://support.microsoft.com/kb/917825/en-us
-Link: https://blogs.msdn.microsoft.com/psssql/2009/11/17/how-it-works-controlling-sql-server-memory-dumps +**Undocumented trace flag**
+Function: SQL Server error log still tells you about the dump. But it never gets written. +The error log still tells you about the stack text file, which still gets generated even with T2542 in place. Looks like that takes about 6 seconds rather than the dumps which were always over 1 minute. +[@sqL_handLe](https://twitter.com/sqL_handLe) used it to resolve an issue where a production environment (with > 1 TB of RAM) was experiencing unhelpful memory dumps that would take more than 100 seconds to complete. 100 seconds is the max Availability Group lease timeout threshold.
+Link: [KB917825]
+Link: [Controlling SQL Server memory dumps]
+Link: [197](https://github.com/ktaranov/sqlserver-kit/issues/197) #### Trace Flag: 2543 +**Undocumented trace flag**
Function: Unknown, but related to controlling the contents of a memory dump
-Link: http://support.microsoft.com/kb/917825/en-us +Link: [KB917825] #### Trace Flag: 2544 +**Undocumented trace flag**
Function: Produces a full memory dump
-Link: http://support.microsoft.com/kb/917825/en-us
+Link: [KB917825]
Link: https://blogs.msdn.microsoft.com/askjay/2010/02/05/how-can-i-create-a-dump-of-sql-server
-Link: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/13ce4292-b8a7-41fa-a173-645693957d70/sqldumper?forum=sqldisasterrecovery&forum=sqldisasterrecovery +Link: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/13ce4292-b8a7-41fa-a173-645693957d70/sqldumper?forum=sqldisasterrecovery&forum=sqldisasterrecovery
+Link: [SQL Server Trace Flag 2544, Trace Flag 2546 and Trace Flag 2551]
+Scope: Session #### Trace Flag: 2545 -Function: Unknown, but related to controlling the contents of a -memory dump
-Link: http://support.microsoft.com/kb/917825/en-us +Function: Unknown, but related to controlling the contents of a memory dump
+Link: [KB917825] #### Trace Flag: 2546 -Function: Dumps all threads for SQL Server in the dump file
-Link: http://support.microsoft.com/kb/917825/en-us
+Function: Generates dump file for all threads of SQL Server (mini dump).
+Link: [KB917825]
Link: https://blogs.msdn.microsoft.com/askjay/2010/02/05/how-can-i-create-a-dump-of-sql-server
Link: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/13ce4292-b8a7-41fa-a173-645693957d70/sqldumper?forum=sqldisasterrecovery&forum=sqldisasterrecovery
-Link: https://blogs.msdn.microsoft.com/psssql/2008/09/12/sql-server-2000-2005-2008-recoveryrollback-taking-longer-than-expected +Link: https://blogs.msdn.microsoft.com/psssql/2008/09/12/sql-server-2000-2005-2008-recoveryrollback-taking-longer-than-expected
+Link: [SQL Server Trace Flag 2544, Trace Flag 2546 and Trace Flag 2551]
+Scope: Session #### Trace Flag: 2547 Function: Unknown, but related to controlling the contents of a memory dump
-Link: http://support.microsoft.com/kb/917825/en-us +Link: [KB917825] @@ -1623,119 +2099,118 @@ Link: http://support.microsoft.com/kb/917825/en-us Function: Shrink will run faster with this trace flag if there are LOB pages that need conversion and/or compaction, because that actions will be skipped.
Link: http://blogs.msdn.com/b/psssql/archive/2008/03/28/how-it-works-sql-server-2005-dbcc-shrink-may-take-longer-than-sql-server-2000.aspx -*Thanks to: Andrzej Kukula* - #### Trace Flag: 2549 -Function: Runs the DBCC CHECKDB command assuming each database file is on a unique disk drive. -DBCC CHECKDB command builds an internal list of pages to read per unique disk drive across all database files. -This logic determines unique disk drives based on the drive letter of the physical file name of each file.
-**Note: Do not use this trace flag unless you know that each file is based on a unique physical disk. -Although this trace flag improve the performance of the DBCC CHECKDB commands which target usage of the PHYSICAL_ONLY option, some users may not see any improvement in performance. +Function: Forces the `DBCC CHECKDB` command to assume each database file is on a unique disk drive but treating different physical files as one logical file. +`DBCC CHECKDB` command builds an internal list of pages to read per unique disk drive across all database files. +This logic determines unique disk drives based on the drive letter of the physical file name of each file. +**Note: Do not use this trace flag unless you know that each file is based on a unique physical disk.** +**Note: Although this trace flag improve the performance of the DBCC CHECKDB commands which target usage of the `PHYSICAL_ONLY` option, some users may not see any improvement in performance. While this trace flag improves disk I/O resources usage, the underlying performance of disk resources may limit the overall performance of the DBCC CHECKDB command.**
+Link: [Minimizing the impact of DBCC CHECKDB] Link: http://blogs.msdn.com/b/saponsqlserver/archive/2011/12/22/faster-dbcc-checkdb-released-in-sql-2008-r2-sp1-traceflag-2562-amp-2549.aspx
-Link: http://support.microsoft.com/kb/2634571
-Link: https://support.microsoft.com/en-us/kb/2732669
+Link: [KB2634571]
+Link: https://support.microsoft.com/kb/2732669
Link: [Docs Trace Flags]
+Link: [KB2964518]
Scope: global only #### Trace Flag: 2550 -Function: Unknown, but related to controlling the contents of a -memory dump
-Link: http://support.microsoft.com/kb/917825/en-us +**Undocumented trace flag**
+Function: Unknown, but related to controlling the contents of a memory dump
+Link: [KB917825] #### Trace Flag: 2551 +**Undocumented trace flag**
Function: Produces a filtered memory dump
-Link: http://support.microsoft.com/kb/917825/en-us
-Link: https://connect.microsoft.com/SQLServer/feedback/details/477863/sql-server-is-terminating-because-of-fatal-exception-c0150014 +Link: [KB917825]
+Link: https://connect.microsoft.com/SQLServer/feedback/details/477863/sql-server-is-terminating-because-of-fatal-exception-c0150014
+Link: [Let’s talk about trace flags]
+Link: [SQL Server Trace Flag 2544, Trace Flag 2546 and Trace Flag 2551]
+Scope: Session #### Trace Flag: 2552 -Function: Unknown, but related to controlling the contents of a -memory dump
-Link: http://support.microsoft.com/kb/917825/en-us +Function: Unknown, but related to controlling the contents of a memory dump
+Link: [KB917825] #### Trace Flag: 2553 -Function: Unknown, but related to controlling the contents of a -memory dump
-Link: http://support.microsoft.com/kb/917825/en-us +Function: Unknown, but related to controlling the contents of a memory dump
+Link: [KB917825] #### Trace Flag: 2554 -Function: Unknown, but related to controlling the contents of a -memory dump
-Link: http://support.microsoft.com/kb/917825/en-us +Function: Unknown, but related to controlling the contents of a memory dump
+Link: [KB917825] #### Trace Flag: 2555 -Function: Unknown, but related to controlling the contents of a -memory dump
-Link: http://support.microsoft.com/kb/917825/en-us +Function: Unknown, but related to controlling the contents of a memory dump
+Link: [KB917825] #### Trace Flag: 2556 Function: Unknown, but related to controlling the contents of a memory dump
-Link: http://support.microsoft.com/kb/917825/en-us +Link: [KB917825] #### Trace Flag: 2557 -Function: Unknown, but related to controlling the contents of a -memory dump
-Link: http://support.microsoft.com/kb/917825/en-us +Function: Unknown, but related to controlling the contents of a memory dump
+Link: [KB917825] #### Trace Flag: 2558 Function: Disables integration between CHECKDB and Watson
-Link: http://support.microsoft.com/kb/917825/en-us
-Link: https://blogs.msdn.microsoft.com/psssql/2009/11/17/how-it-works-controlling-sql-server-memory-dumps +Link: [KB917825]
+Link: [Controlling SQL Server memory dumps] #### Trace Flag: 2559 -Function: Unknown, but related to controlling the contents of a -memory dump
-Link: http://support.microsoft.com/kb/917825/en-us +Function: Unknown, but related to controlling the contents of a memory dump
+Link: [KB917825] #### Trace Flag: 2562 -Function: Runs the DBCC CHECKDB command in a single "batch" regardless of the number of indexes in the database. -By default, the DBCC CHECKDB command tries to minimize tempdb resources by limiting the number of indexes or "facts" that it generates by using a "batches" concept. -This trace flag forces all processing into one batch. -One effect of using this trace flag is that the space requirements for tempdb may increase. -Tempdb may grow to as much as 5% or more of the user database that is being processed by the DBCC CHECKDB command.
-**Note: Although this trace flag improve the performance of the DBCC CHECKDB commands which target usage of the PHYSICAL_ONLY option, some users may not see any improvement in performance. -While this trace flag improves disk I/O resources usage, the underlying performance of disk resources may limit the overall performance of the DBCC CHECKDB command.**
+Function: Runs the `DBCC CHECKDB` command in a single "batch" regardless of the number of indexes in the database. +By default, the `DBCC CHECKDB` command tries to minimize TempDB resources by limiting the number of indexes or "facts" that it generates by using a "batches" concept. +But this trace flag forces all processing into one batch. +One effect of using this trace flag is that the space requirements for TempDB may increase. TempDB may grow to as much as 5% or more of the user database that is being processed by the DBCC CHECKDB command. +**Note: Although this trace flag improve the performance of the DBCC CHECKDB commands which target usage of the `PHYSICAL_ONLY` option, some users may not see any improvement in performance. While this trace flag improves disk I/O resources usage, the underlying performance of disk resources may limit the overall performance of the DBCC CHECKDB command.**
+Link: [Minimizing the impact of DBCC CHECKDB] Link: http://blogs.msdn.com/b/saponsqlserver/archive/2011/12/22/faster-dbcc-checkdb-released-in-sql-2008-r2-sp1-traceflag-2562-amp-2549.aspx
-Link: http://support.microsoft.com/kb/2634571
-Link: http://support.microsoft.com/kb/2732669/en-us
+Link: [KB2634571]
+Link: https://support.microsoft.com/kb/2732669
Link: [Docs Trace Flags]
+Link: [KB2964518]
Scope: global only #### Trace Flag: 2566 -Function: Runs the DBCC CHECKDB command without data purity check unless DATA_PURITY option is specified.
+Function: Runs the `DBCC CHECKDB` command without data purity check unless `DATA_PURITY` option is specified.
**Note: Column-value integrity checks are enabled by default and do not require the DATA_PURITY option. -For databases upgraded from earlier versions of SQL Server, column-value checks are not enabled by default until DBCC CHECKDB WITH DATA_PURITY has been run error free on the database at least once. -After this, DBCC CHECKDB checks column-value integrity by default.**
+For databases upgraded from earlier versions of SQL Server, column-value checks are not enabled by default until `DBCC CHECKDB WITH DATA_PURITY` has been run error free on the database at least once. +After this, `DBCC CHECKDB` checks column-value integrity by default.**
Link: [Docs Trace Flags]
-Link: https://sqlperformance.com/2012/11/io-subsystem/minimize-impact-of-checkdb
-Link: https://support.microsoft.com/en-us/help/2888996/fix-data-purity-corruption-in-sys.sysbinobjs-table-in-master-database-when-you-log-on-to-sql-server-by-using-the-sa-account-and-then-run-dbcc-checkdb
+Link: [Minimizing the impact of DBCC CHECKDB]
+Link: https://support.microsoft.com/kb/2888996
+Link: [KB2964518]
Scope: global only @@ -1748,19 +2223,38 @@ Link: http://www.sqlskills.com/blogs/paul/dbcc-writepage/
Scope: session only + +#### Trace Flag: 2592 +Function: When used in conjunction with trace flag [3656](#3656), enables symbol resolution on stack dumps when the Debugging Tools for Windows are installed. +For more information, see this [Microsoft Whitepaper](https://www.microsoft.com/download/details.aspx?id=26666).
+**WARNING: This is a debugging trace flag and not meant for production environment use.**
+**Note: This trace flag applies to SQL Server 2019 (15.x) and higher builds.**
+Link: [Docs Trace Flags]
+Scope: global or session + + #### Trace Flag: 2701 -Function: SQL 6.5 - Sets the @@ERROR system function to 50000 for RAISERROR messages with severity levels of 10 or less. When disabled, sets the @@ERROR system function to 0 for RAISERROR messages with severity levels of 10 or less
+Function: SQL 6.5 - Sets the `@@ERROR` system function to 50000 for `RAISERROR` messages with severity levels of 10 or less. When disabled, sets the @@ERROR system function to 0 for RAISERROR messages with severity levels of 10 or less
Link: None #### Trace Flag: 2861 +**Undocumented trace flag**
+**TF2861 only exists in SQL Server 2000 SP3 and SP4, was removed before 2005 shipped, and if you’re using it now you’re definitely incorrect and should removed it from your startup parameters/application code that enables it.** Function: Keep zero cost plans in cache. Tip: Avoid Using Trace Flag 2861 to Cache Zero-Cost Query Plan
+Link: http://www.seangallardy.com/trace-flag-2861-the-trace-flag-the-myth-the-legend/
+Link: https://web.archive.org/web/20121008074923/http://support.microsoft.com/kb/325607
+Scope: global only + + +#### Trace Flag: 2880 +Function: Both 2880 and 2881 are related to a SQL 2000 hotfix introduced to solve problems where ad-hoc queries would cause the procedure cache to get too big
Link: None -#### Trace Flag: 2880, 2881 +#### Trace Flag: 2881 Function: Both 2880 and 2881 are related to a SQL 2000 hotfix introduced to solve problems where ad-hoc queries would cause the procedure cache to get too big
Link: None @@ -1773,28 +2267,37 @@ Link: https://bytes.com/topic/sql-server/answers/162385-how-do-i-prevent-sql-200 #### Trace Flag: 3004 -Function: Returns more info about Instant File Initialization. Shows information about backups and file creations use with 3605 to direct to error log.
+Function: Returns more info about Instant File Initialization. Shows information about backups and file creations use with [3605](#3605) to direct to error log. +Can be used to ensure that SQL Server has been configured to take advantage of IFI correctly.
Link: https://blogs.msdn.microsoft.com/psssql/2008/01/23/how-it-works-what-is-restorebackup-doing/
-Link: http://victorisakov.files.wordpress.com/2011/10/sql_pass_summit_2011-important_trace_flags_that_every_dba_should_know-victor_isakov.pdf
-Link: https://blogs.msdn.microsoft.com/sql_pfe_blog/2009/12/22/how-and-why-to-enable-instant-file-initialization/ +Link: [Important Trace Flags That Every DBA Should Know]
+Link: https://blogs.msdn.microsoft.com/sql_pfe_blog/2009/12/22/how-and-why-to-enable-instant-file-initialization/
+Link: [Undocumented Trace Flags: Inside the Restore Process]
+Link: https://www.sqlservergeeks.com/sql-server-trace-flag-3004/
+Scope: session only #### Trace Flag: 3014 -Function: Returns more info about backups to the errorlog
-Link: http://victorisakov.files.wordpress.com/2011/10/sql_pass_summit_2011-important_trace_flags_that_every_dba_should_know-victor_isakov.pdf
-Link: https://blogs.msdn.microsoft.com/psssql/2008/02/06/how-it-works-how-does-sql-server-backup-and-restore-select-transfer-sizes +Function: Returns more info about backups to the errorlog: Backup activity, Restore activity, File creation.
+Link: [Important Trace Flags That Every DBA Should Know]
+Link: https://blogs.msdn.microsoft.com/psssql/2008/02/06/how-it-works-how-does-sql-server-backup-and-restore-select-transfer-sizes
+Link: [Undocumented Trace Flags: Inside the Restore Process]
+Link: [What’s CHECKDB doing in my database restore?]
+Link: https://www.sqlservergeeks.com/sql-server-trace-flag-3014/
+Scope: session only #### Trace Flag: 3023 -Function: Enables CHECKSUM option as default for BACKUP command
+Function: Enables `CHECKSUM` option as default for `BACKUP` command.
**Note: Beginning with SQL Server 2014 this behavior is controlled by setting the backup checksum default configuration option. For more information, see [Server Configuration Options (SQL Server)](https://msdn.microsoft.com/en-us/library/ms189631.aspx)**.
-Link: https://support.microsoft.com/en-us/kb/2656988
+Link: https://support.microsoft.com/kb/2656988
Link: [Docs Trace Flags]
-Scope: global and session +Link: https://www.sqlservergeeks.com/sql-server-trace-flag-3023/
+Scope: global or session @@ -1819,22 +2322,23 @@ Link: https://blogs.msdn.microsoft.com/ialonso/2012/02/24/vdi-backups-and-backup #### Trace Flag: 3035 Function: Overrides the server default to always avoid compression, unless the backup command explicitly uses the compression clause. If both 3034 and 3035 are enabled, 3035 takes precedence
Link: https://blogs.msdn.microsoft.com/ialonso/2012/02/24/vdi-backups-and-backup-compression-default - - + + #### Trace Flag: 3039 Function: As long as the SQL edition supports backup compression, this will allow VDI backups to be affected by the default compression setting just as non-VDI BACKUP commands are affected.
Link: https://blogs.msdn.microsoft.com/ialonso/2012/02/24/vdi-backups-and-backup-compression-default - + #### Trace Flag: 3042 Function: Bypasses the default backup compression pre-allocation algorithm to allow the backup file to grow only as needed to reach its final size. This trace flag is useful if you need to save on space by allocating only the actual size required for the compressed backup. Using this trace flag might cause a slight performance penalty (a possible increase in the duration of the backup operation). For more information about the pre-allocation algorithm, see [Backup Compression (SQL Server)](https://msdn.microsoft.com/en-us/library/bb964719.aspx).
Link: [Docs Trace Flags]
-Link: https://support.microsoft.com/en-us/help/2001026/inf-space-requirements-for-backup-devices-in-sql-server
+Link: https://support.microsoft.com/kb/2001026
Link: https://blogs.msdn.microsoft.com/psssql/2011/08/11/how-compressed-is-your-backup/
-Link: https://technet.microsoft.com/en-us/library/bb964719.aspx
+Link: https://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/backup-compression-sql-server
+Link: https://sqlstudies.com/2017/03/16/compressed-backup-errors-and-tf-3042/
Scope: global only @@ -1849,13 +2353,13 @@ Scope: global only #### Trace Flag: 3057 Function: Enables functionality after a hotfix that allows a log backup that was taken on a t-logfile hosted on a drive with “Bytes per physical sector”=512 to be restored onto a log file/drive that has “Bytes per physical sector”=4096
-Link: https://support.microsoft.com/en-us/help/2987585/restore-log-with-standby-mode-on-an-advanced-format-disk-may-cause-a-9004-error-in-sql-server-2008-r2-or-sql-server-2012 +Link: https://support.microsoft.com/kb/2987585 #### Trace Flag: 3101 Function: Fix performance problems when restoring database with CDC
-Link: http://support.microsoft.com/kb/2567366/ +Link: https://support.microsoft.com/kb/2567366 @@ -1887,7 +2391,7 @@ Link: None #### Trace Flag: 3205 Function: Disable HW compression for backup to tape drives
Link: [Docs Trace Flags]
-Scope: global +Scope: global only @@ -1912,7 +2416,9 @@ Link: https://blogs.msdn.microsoft.com/ialonso/2012/10/24/why-does-restoring-a-d #### Trace Flag: 3213 Function: Output buffer info for backups to ERRORLOG
Link: https://blogs.msdn.microsoft.com/psssql/2008/02/06/how-it-works-how-does-sql-server-backup-and-restore-select-transfer-sizes
-Link: https://blogs.msdn.microsoft.com/psssql/2008/01/28/how-it-works-sql-server-backup-buffer-exchange-a-vdi-focus/ +Link: https://blogs.msdn.microsoft.com/psssql/2008/01/28/how-it-works-sql-server-backup-buffer-exchange-a-vdi-focus/
+Link: http://www.sqlservergeeks.com/sql-server-trace-flag-3213/
+Scope: global or session @@ -1929,33 +2435,30 @@ Link: [TECHNET List Of SQL Server Trace Flags] #### Trace Flag: 3226 - Function: By default, every successful backup operation adds an entry in the SQL Server error log and in the system event log. If you create very frequent log backups, these success messages accumulate quickly, resulting in huge error logs in which finding other messages is problematic. With this trace flag, you can suppress these log entries. This is useful if you are running frequent log backups and if none of your scripts depend on those entries.
Link: [Docs Trace Flags]
Link: http://www.sqlskills.com/blogs/paul/fed-up-with-backup-success-messages-bloating-your-error-logs
Link: https://blogs.msdn.microsoft.com/sqlserverstorageengine/2007/10/30/when-is-too-much-success-a-bad-thing
+Link: [Important Trace Flags That Every DBA Should Know]
+Link: https://www.sqlservergeeks.com/sql-server-trace-flag-3226/
Scope: global only - -#### Trace Flag: 3422 -Function: Log record auditing
-Link: http://technet.microsoft.com/en-au/library/cc917726.aspx - - #### Trace Flag: 3231 Function: SQL 8/9 - Will turn the NO_LOG and TRUNCATE_ONLY options into no-ops in FULL/BULK_LOGGED recovery mode, and will clear the log in SIMPLE recovery mode. When set, BACKUP LOG with TRUNCATE_ONLY and BACKUP LOG with NO_LOG do not allow a log backup to run if the database's recovery model is FULL or BULK_LOGGED.
Link: http://www.sqlskills.com/blogs/paul/backup-log-with-no_log-use-abuse-and-undocumented-trace-flags-to-stop-it
-Link: http://www.sqlskills.com/blogs/kimberly/understanding-backups-and-log-related-trace-flags-in-sql-server-20002005-and-2008 +Link: http://www.sqlskills.com/blogs/kimberly/understanding-backups-and-log-related-trace-flags-in-sql-server-20002005-and-2008
+Scope: ? #### Trace Flag: 3282 +**Undocumented trace flag**
Function: SQL 6.5 - Used after backup restoration fails
-Link: https://support.microsoft.com/en-us/kb/215458 +Scope: ? @@ -1972,6 +2475,7 @@ Link: https://blogs.msdn.microsoft.com/ialonso/2012/10/08/how-much-is-crash-reco #### Trace Flag: 3412 +**Undocumented trace flag**
Function: The KB article refers to SQL 6.5, but it is possible that the TF still prints out info to the SQL error log, so leaving it here for now. KB: “...reports when each transaction is rolled forward or back [examine the error log for progress]. However, you will not see any progress if SQL Server is rolling a large transaction forward or back. Additionally, this trace flag duplicates the sp_configure setting Recovery flags..."
@@ -1981,16 +2485,25 @@ Link: None #### Trace Flag: 3422 Function: Cause auditing of transaction log records as they're read (during transaction rollback or log recovery). -This is useful because there is no equivalent to page checksums for transaction log records and so no way to detect whether log records are being corrupted e careful with these trace flags - I don't recommend using them unless you are experiencing corruptions that you can't diagnose. Turning them on will cause a big CPU hit because of the extra auditing that's happening.
-Link: https://support.microsoft.com/en-us/kb/215458
-Link: http://www.sqlskills.com/blogs/paul/how-to-tell-if-the-io-subsystem-is-causing-corruptions +This is useful because there is no equivalent to page checksums for transaction log records and so no way to detect whether log records are being corrupted e careful with these trace flags - I don't recommend using them unless you are experiencing corruptions that you can't diagnose. +Turning them on will cause a big CPU hit because of the extra auditing that's happening.
+Link: https://support.microsoft.com/kb/215458
+Link: http://www.sqlskills.com/blogs/paul/how-to-tell-if-the-io-subsystem-is-causing-corruptions
+Link: http://technet.microsoft.com/en-au/library/cc917726.aspx
+Link: [Important Trace Flags That Every DBA Should Know]
+Scope: ? #### Trace Flag: 3427 -Function: Enables fix for issue when many consecutive transactions inserting data into temp table in SQL Server 2016 consume more CPU than in SQL Server 2014.
+Function: Enables fix for issue when many consecutive transactions inserting data into temp table in SQL Server 2016 consume more CPU than in SQL Server 2014. +Another change in SQL Server 2016 behavior that could impact tempdb-heavy workloads has to do with Common Criteria Compliance (CCC), also known as C2 auditing. +We introduced functionality to allow for transaction-level auditing in CCC which can cause some additional overhead, particularly in workloads that do heavy inserts and updates in temp tables +Unfortunately, this overhead is incurred whether you have CCC enabled or not. In SQL Server 2016 you can enable trace flag 3427 to bypass this overhead starting with SP1 CU2. Starting in SQL Server 2017 CU4, we automatically bypass this code if CCC is disabled.
+**Note: This trace flag applies to SQL Server 2016 (13.x) SP1 CU2 through SQL Server 2016 (13.x) SP2 CU2. Starting with SQL Server 2016 (13.x) SP2 CU3 and SQL Server 2017 (14.x), this trace flag has no effect.**
Link: [Docs Trace Flags]
-Link: http://support.microsoft.com/help/3216543
+Link: https://support.microsoft.com/kb/3216543
+Link: [TEMPDB – Files and Trace Flags and Updates]
Scope: global only @@ -1999,49 +2512,93 @@ Scope: global only Function: Introduced in the KB to fix a race condition leading to a hung database in mirroring failover situations. “ This trace flag forces new connections to keep checking for database state every two seconds instead of waiting for a lock for infinite time. It helps ending the connection tasks faster as the mirroring reac hes the start of the recovery phase and releasing more worker threads to be used by database mirroring.”
-Link: https://support.microsoft.com/en-us/help/2970421/fix-the-database-sticks-in-role-configuration-phase-when-you-perform-a-manual-failover-of-a-mirrored-database +Link: https://support.microsoft.com/kb/2970421 #### Trace Flag: 3449 -Function: If you enable global TF 3449 (and you are on SQL Server 2012 SP3 CU3 or later or SQL Server 2014 SP1 CU7 or later), you will get much better performance by avoiding a FlushCache call in a number of different common scenarios, such as backup database, backup transaction log, create database, add a file to a database, restore a transaction log, recover a database, shrink a database file, and a SQL Server “graceful” shutdown. -Link: https://support.microsoft.com/en-us/help/3158396/fix-sql-server-database-creation-on-a-system-with-a-large-volume-of-me
+Function: If you enable global TF 3449 (and you are on SQL Server 2012 SP3 CU3 or later or SQL Server 2014 SP1 CU7 or later), +you will get much better performance by avoiding a FlushCache call in a number of different common scenarios, such as backup database, +backup transaction log, create database, add a file to a database, restore a transaction log, recover a database, shrink a database file, and a SQL Server “graceful” shutdown.
+Link: https://support.microsoft.com/kb/3158396
Link: https://blogs.msdn.microsoft.com/psssql/2017/06/29/sql-server-large-ram-and-db-checkpointing/
+Link: [Hidden Performance & Manageability Improvements in SQL Server 2012 / 2014]
+Link: [KB2964518]
+Scope: global only + + + +#### Trace Flag: 3459 +Function: Disables parallel redo. +Assume that you use an Always On availability group (AG) that contains heap tables. +Starting in SQL Server 2016, parallel thread for redo operations is used in secondary replicas. +In this case, heap tables redo operation may generate a runtime assert dump or the SQL Server may crash with an access violation error in some cases.
+**Note: This trace flag applies to SQL Server 2016 (13.x), SQL Server 2017 (14.x), and higher builds.**
+Link: [Docs Trace Flags]
+Link: https://support.microsoft.com/kb/3200975
+Link: https://support.microsoft.com/kb/4101554
+Link: https://support.microsoft.com/kb/4339858
+Scope: global only + + + +#### Trace Flag: 3468 +Function: Disables [indirect checkpoints](https://docs.microsoft.com/en-us/sql/relational-databases/logs/database-checkpoints-sql-server?view=sql-server-2017#IndirectChkpt) on `tempdb`.
+**Note: This trace flag applies to SQL Server 2016 (13.x) SP1 CU5, SQL Server 2017 (14.x) CU1 and higher builds.**
+Link: [Docs Trace Flags]
+Link: https://techcommunity.microsoft.com/t5/SQL-Server/Indirect-Checkpoint-and-tempdb-8211-the-good-the-bad-and-the-non/bc-p/851152#M1351 Scope: global only #### Trace Flag: 3499 +**Undocumented trace flag**
Function: Provides a workaround for doing a rolling upgrade from SQL 2005 to SQL 2008 with a DB that has a full-text index
Link: None #### Trace Flag: 3502 -Function: Writes info about checkpoints to tech error log
-Link: http://victorisakov.files.wordpress.com/2011/10/sql_pass_summit_2011-important_trace_flags_that_every_dba_should_know-victor_isakov.pdf
+**Undocumented trace flag**
+Function: Write checkpoint start and end messages in the SQL Server error log.
+Link: [Important Trace Flags That Every DBA Should Know]
Link: https://blogs.msdn.microsoft.com/joaol/2008/11/20/sql-server-checkpoint-problems/
-Link: http://www.sqlskills.com/blogs/paul/a-sql-server-dba-myth-a-day-1530-checkpoint-only-writes-pages-from-committed-transactions/ +Link: [A SQL Server DBA myth a day: (15/30) checkpoint only writes pages from committed transactions]
+Link: https://www.sqlservergeeks.com/sql-server-trace-flag-3502/
+Scope: session only #### Trace Flag: 3503 +**Undocumented trace flag**
Function: Indicates whether the checkpoint at the end of automatic recovery was skipped for a database (this applies only to read-only databases)
Link: http://www.sql-server-performance.com/2002/traceflags/ #### Trace Flag: 3504 -Function: For internal testing. Will raise a bogus log-out-of-space condition from checkpoint
+**Undocumented trace flag**
+Function: writes to the error log information about what is written to disk. +For internal testing. Will raise a bogus log-out-of-space condition from checkpoint.
Link: https://blogs.msdn.microsoft.com/joaol/2008/11/20/sql-server-checkpoint-problems/
-Link: http://www.sqlskills.com/blogs/paul/a-sql-server-dba-myth-a-day-1530-checkpoint-only-writes-pages-from-committed-transactions/ +Link: [A SQL Server DBA myth a day: (15/30) checkpoint only writes pages from committed transactions]
+Link: https://www.sqlservergeeks.com/sql-server-trace-flag-3504/
+Link: https://www.sqlshack.com/sql-server-checkpoint-lazy-writer-eager-writer-and-dirty-pages-in-sql-server/
+Link: https://docs.microsoft.com/en-us/archive/blogs/psssql/how-it-works-when-is-the-flushcache-message-added-to-sql-server-error-log
+Scope: session only #### Trace Flag: 3505 -Function: Disables automatic checkpointing
-Link: http://support.microsoft.com/kb/815436
-Link: http://www.sqlskills.com/blogs/paul/benchmarking-1-tb-table-population-part-2-optimizing-log-block-io-size-and-how-log-io-works/ +**Undocumented trace flag**
+Function: Disables automatic checkpoints. +Setting trace flag 3505 may increase recovery time and can prevent log space reuse until the next checkpoint is issued. +Make sure to issue manual checkpoints on all read/write databases at appropriate time intervals. +"For high availability systems, such as clusters, Microsoft recommends that you do not change the recovery interval because it may affect data safety and availability."
+Link: http://www.sqlskills.com/blogs/paul/benchmarking-1-tb-table-population-part-2-optimizing-log-block-io-size-and-how-log-io-works/
+Link: [Important Trace Flags That Every DBA Should Know]
+Link: https://www.sqlservergeeks.com/sql-server-trace-flag-3505/
+Scope: global only @@ -2053,7 +2610,7 @@ Link: https://blogs.msdn.microsoft.com/sqlserverfaq/2009/05/27/info-sql-2000-msd #### Trace Flag: 3602 Function: Records all error and warning messages sent to the client
-Link: https://support.microsoft.com/en-us/help/199037/how-to-capture-error-messages-that-are-sent-to-clients-from-an-instance-of-sql-server +Link: https://support.microsoft.com/kb/199037 @@ -2064,20 +2621,31 @@ Link: https://blogs.msdn.microsoft.com/sqlserverfaq/2009/05/27/info-sql-2000-msd #### Trace Flag: 3604 +**Undocumented trace flag**
Function: Enables the output from a large number of trace flags and DBCC commands to be sent back to the client. The Connect issue notes that problems can occur when using 3604 with a query that executes across a linked server. [This CSS page](https://blogs.msdn.microsoft.com/psssql/2009/05/11/how-do-i-determine-which-dump-triggers-are-enabled/) points out that 3604 is necessary for DBCC DumpTrigger(‘display’)
Link: http://blogs.msdn.com/b/askjay/archive/2011/01/21/why-do-we-need-trace-flag-3604-for-dbcc-statements.aspx
Link: [Internals of the Seven SQL Server Sorts – Part 1]
Link: https://connect.microsoft.com/SQLServer/feedback/details/306380/trace-flag-issue-7300-3604
-Link: [How to Find the Statistics Used to Compile an Execution Plan] +Link: [How to Find the Statistics Used to Compile an Execution Plan]
+Link: [A Row Goal Riddle]
+Link: [Undocumented Trace Flags: Inside the Restore Process]
+Link: [What’s CHECKDB doing in my database restore?]
+Link: https://www.sqlservergeeks.com/sql-server-trace-flag-3604/
+Link: [Cardinality Estimation for Multiple Predicates]
+Scope: session only #### Trace Flag: 3605 Function: Sends a variety of types of information to the SQL Server error log instead of to the user console. Often referenced in KB and blog articles in the context of other trace flags (e.g. 3604).
-Link: https://blogs.msdn.microsoft.com/askjay/2011/01/21/why-do-we-need-trace-flag-3604-for-dbcc-statements/ +Link: https://blogs.msdn.microsoft.com/askjay/2011/01/21/why-do-we-need-trace-flag-3604-for-dbcc-statements/
+Link: [Undocumented Trace Flags: Inside the Restore Process]
+Link: [What’s CHECKDB doing in my database restore?]
+Link: https://www.sqlservergeeks.com/sql-server-trace-flag-3605/
+Scope: session only @@ -2086,16 +2654,17 @@ Function: Skip recovery on startup
Link: http://sqlkbs.blogspot.se/2008/01/trace-flag.html
Link: https://blogs.msdn.microsoft.com/ialonso/2012/10/24/why-does-restoring-a-database-needs-tempdb/ + #### Trace Flag: 3608 Function: Prevents SQL Server from automatically starting and recovering any database except the master database. -If activities that require tempdb are initiated, then model is recovered and tempdb is created. Other databases will be started and recovered when accessed. -Some features, such as snapshot isolation and read committed snapshot, might not work. -Use for Move System Databases and Move User Databases.
+If activities that require TempDB are initiated, then model is recovered and TempDB is created. Other databases will be started and recovered when accessed. +Some features, such as snapshot isolation and read committed snapshot, might not work. Use for [Move System Databases](https://docs.microsoft.com/en-us/sql/relational-databases/databases/move-system-databases?view=sql-server-2017) and [Move User Databases](https://docs.microsoft.com/en-us/sql/relational-databases/databases/move-user-databases?view=sql-server-2017).
**Note: Do not use during normal operation.**
Link: [Docs Trace Flags]
Link: [Importance of Performing DBCC CHECKDB on all SQL Server Databases]
Link: https://blogs.msdn.microsoft.com/ialonso/2012/10/24/why-does-restoring-a-database-needs-tempdb
+Link: http://www.sqlservergeeks.com/sql-server-trace-flag-3608/
Scope: global only @@ -2120,6 +2689,16 @@ Function: Modifies the order of startup operations so that SQL Server can succes Link: None + +#### Trace Flag: 3618 +**Undocumented trace flag**
+Function: Disable the new Metadata-Only Column Changes in SQL Server 2016 and upper versions. +This trace flag is not effective when used at the session level. +There is no way to specify a query-level trace flag with an `ALTER COLUMN` command.
+Link: https://sqlperformance.com/2020/04/database-design/new-metadata-column-changes-sql-server-2016
+Scope: globa only + + #### Trace Flag: 3625 Function: Limits the amount of information returned to users who are not members of the sysadmin fixed server role, by masking the parameters of some error messages using '******'. @@ -2137,13 +2716,13 @@ Link: None #### Trace Flag: 3628 Function: CSS’s mysterious description: “Includes ‘other errors’ in the dump based on a severity.”
-Link: https://blogs.msdn.microsoft.com/psssql/2009/11/17/how-it-works-controlling-sql-server-memory-dumps +Link: [Controlling SQL Server memory dumps] #### Trace Flag: 3629 Function: CSS: A memory dump will “include messages marked to include with this trace flag enabled.”
-Link: https://blogs.msdn.microsoft.com/psssql/2009/11/17/how-it-works-controlling-sql-server-memory-dumps +Link: [Controlling SQL Server memory dumps] @@ -2159,26 +2738,40 @@ Function: Eliminates sending DONE_IN_PROC messages to client for each statement Link: https://blogs.msdn.microsoft.com/selvar/2010/07/13/delete-operation-from-a-reporting-service-2005-report-manager-fails-with-internalcatalogexception-and-throws-watson-mini-dump + +#### Trace Flag: 3651 +**Undocumented trace flag**
+Function: Can cause stack dumps. For one query, this resulted in a parallel plan significantly more expensive than the naturally occurring serial plan.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + #### Trace Flag: 3654 Function: Apparently increases info found in the sys.dm_os_memory_allocations DMV (which appears to have replaced the DBCC MEMOBJLIST command) Bob Ward also discusses it in his PASS 2013 session, saying that it turns on tracing for all memory allocations done by “Memory Objects” (a specific SQLOS memory term). This flag will have a significant impact on system performance.
Link: https://blogs.msdn.microsoft.com/psssql/2012/11/12/how-can-reference-counting-be-a-leading-memory-scribbler-cause
Link: https://blogs.msdn.microsoft.com/slavao/2005/08/30/talking-points-around-memory-manager-in-sql-server-2005
-Link: https://support.microsoft.com/en-us/help/2888658/an-access-violation-occurs-when-the-sys.dm-db-index-physical-stats-function-is-used-in-an-if-exists-statement-in-an-sql-query-in-sql-server-2012 +Link: https://support.microsoft.com/kb/2888658 #### Trace Flag: 3656 -Function: Enables resolve of all call stacks in extended events
+Function: Enables symbol resolution on stack dumps when the Debugging Tools for Windows are installed. +For more information, see this [Microsoft Whitepaper](https://www.microsoft.com/en-us/download/details.aspx?id=26666).
+**WARNING: This is a debugging trace flag and not meant for production environment use.**
+Link: [Docs Trace Flags]
Link: http://sqlcat.com/sqlcat/b/msdnmirror/archive/2010/05/11/resolving-dtc-related-waits-and-tuning-scalability-of-dtc.aspx
-Link: https://blogs.msdn.microsoft.com/psssql/2009/11/17/how-it-works-controlling-sql-server-memory-dumps
-Link: http://www.sqlskills.com/blogs/paul/determine-causes-particular-wait-type +Link: [Controlling SQL Server memory dumps]
+Link: http://www.sqlskills.com/blogs/paul/determine-causes-particular-wait-type
+Scope: global or session #### Trace Flag: 3659 Function: Enables logging all errors to error log during server startup
-Link: http://spaghettidba.com/2011/05/20/trace-flag-3659/ +Link: http://spaghettidba.com/2011/05/20/trace-flag-3659/
+Link: [Change SQL Server Collation – Back to Basics]
+Scope: global only @@ -2197,13 +2790,13 @@ Link: http://blogs.msdn.com/b/psssql/archive/2011/01/07/discussion-about-sql-ser #### Trace Flag: 3688 Function: Removes messages to error log about traces started and stopped
-Link: http://support.microsoft.com/kb/922578/en-us +Link: https://support.microsoft.com/kb/922578 #### Trace Flag: 3689 Function: Logs extended errors to errorlog when network disconnect occurs, turned off by default. Will dump out the socket error code this can sometimes give you a clue as to the root cause.
-Link: http://support.microsoft.com/kb/922578/en-us +Link: https://support.microsoft.com/kb/922578 @@ -2220,8 +2813,19 @@ Link: None #### Trace Flag: 3861 -Function: This flag allows the SQL Server DB startup code to move system tables to the primary filegroup. Introduced due to behavior in the SQL 2014 upgrade process, where system tables could be created in a secondary filegroup (if that FG was the default).
-Link: https://support.microsoft.com/en-us/help/3003760/fix-cannot-remove-the-secondary-filegroup-after-you-upgrade-the-database-to-sql-server-2014 +Function: This flag allows the SQL Server DB startup code to move system tables to the primary filegroup. +Introduced due to behavior in the SQL 2014 upgrade process, where system tables could be created in a secondary filegroup (if that FG was the default).
+Link: https://support.microsoft.com/kb/3003760 + + + +#### Trace Flag: 3895 +**Undocumented trace flag**
+Function: In SQL Server 2019, when you enable the [Memory-Optimized TempDB Metadata](https://docs.microsoft.com/en-us/sql/relational-databases/databases/tempdb-database) feature, this trace flag is automatically enabled as a global session flag after the next restart. +When you disable that feature, the trace flag is automatically removed as a global session flag after the next restart. +Also, if you add trace flag 3895 to startup parameters after restarting SQL Server option `IsTempdbMetadataMemoryOptimized` will be enabled. NOTE: It is NOT recommended to add trace flag 3895 as a startup trace flag to enable TempDB Memory-Optimized Metadata. Although this technically enables the option, you will no longer be able to disable it using sp_configure or ALTER SERVER CONFIGURATION. The only way you'll be able to disable this feature is to manually remove this trace flag from startup parameters in the SQL Server Configuration Manager startup properties
+Link: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Trace_Flag/Trace_Flag_3895.sql
+Scope: global only @@ -2239,13 +2843,15 @@ Link: None #### Trace Flag: 3923 Function: Let SQL Server throw an exception to the application when the 3303 warning message is raised
-Link: https://support.microsoft.com/kb/3014867/en-us +Link: https://support.microsoft.com/kb/3014867 #### Trace Flag: 3924 -Function: Enables a fix where “XA” transactions started within a JDBC-connected Java app are not closed properly and stay open indefinitely.
-Link: https://support.microsoft.com/en-us/help/3145492/fix-xa-transactions-aren-t-cleaned-when-you-exit-a-java-application-in-an-instance-of-sql-server +Function: Enables automatic removal of orphaned DTC transactions with `SPID=-2`, which is a problem for some 3rd party transaction monitors.
+Link: https://support.microsoft.com/kb/4519668
+Link: https://support.microsoft.com/kb/4511816
+Scope: global only @@ -2254,6 +2860,39 @@ Function: According to Bob Ward’s PASS 2014 SQL Server IO talk, forces the Eag Link: None + +#### Trace Flag: 3979 +**Undocumented trace flag**
+Function: **Request Fua Writes**. +SQL Server opens database data and log files with FILE_FLAG_WRITE_THROUGH, mapping to O_DSYNC in the Host Extension, asking for Fua writes. +Linux Default: Trace flag considered **Off** +Windows Default: Trace flag considered **On ** +**The trace flag does not apply to SQL Server on Linux SQL 2017 RTM thru CU5. The behavior is assumed enabled prior to CU 6. +**The trace flag does not apply to Windows. On Windows it is always assumed to be enabled.** +On Linux, you need a file system that provides `DpuFua=1` enabled or you have confirmed your system is O_DIRECT safe. +By enabling the trace flag you disable the batch flush requests from SQL Server and are trusting SQLPAL, HE and the I/O subsystem configuration to achieve durability.
+Link: [SQL Server On Linux: Forced Unit Access (Fua) Internals]
+Scope: global + + + +#### Trace Flag: 3982 +**Undocumented trace flag**
+Function: **Avoid Fua Writes**. +Forces SQL Server to open database data and log files without `FILE_FLAG_WRITE_THROUGH` and issue the `FlushFileBuffers` calls to complete transactions and checkpoint activities. +Linux Default: Trace flag is considered **On** +Windows Default: Trace flag is considered **Off** +**Microsoft retains the policy that SQL Server should always be run on a system with stable media configurations. +The trace flag is NOT supported on Windows.** +[This article](https://support.microsoft.com/kb/86903) highlights these support boundaries. +It was written by David Campbell, Bob Ward, Keith Elmore and I many years ago and the forced flush feature does not alter the intent: “SQL Server requires systems to support ‘ guaranteed delivery to stable media ’ as outlined under the Microsoft SQL Server Always-On Storage Solution Review program. +For more information about the input and output requirements for the SQL Server database engine. +When running on Linux kernels or file systems that do not support optimized Fua capabilities. +The trace flag and forced flush behavior is intended to be a workaround for Linux installations until the SQL Server instance id deployed on a system providing optimized, Fua capabilities.
+Link: [SQL Server On Linux: Forced Unit Access (Fua) Internals]
+Scope: global + + #### Trace Flag: 4001 Function: Very verbose logging of each login attempt to the error log. Includes tons of information
@@ -2271,8 +2910,11 @@ Link: [Upgrading an expired SQL Server 2016 Evaluation Edition] #### Trace Flag: 4013 -Function: Log each new connection the error log
-Link: http://sqlkbs.blogspot.se/2008/01/trace-flag.html +Function: Trace flag 4013 write entries in error log whenever a new connection established. +These entries contain login name and SPID also.
+Link: http://sqlkbs.blogspot.se/2008/01/trace-flag.html
+Link: http://www.sqlservergeeks.com/sql-server-trace-flag-4013/
+Scope: global or session @@ -2285,32 +2927,43 @@ Link: None #### Trace Flag: 4022 Function: Directs the SQL instance to ignore stored procedures that have been configured as “auto-start” procedures. Their auto-start configuration is not affected, so the next time the instance is started w/o this flag they will return to their normal behavior.
Link: https://blogs.msdn.microsoft.com/sqlserverfaq/2011/05/11/inf-hey-my-sql-server-service-is-not-starting-what-do-i-do/
-Link: [Upgrading an expired SQL Server 2016 Evaluation Edition] +Link: [Upgrading an expired SQL Server 2016 Evaluation Edition]
+Link: [Change SQL Server Collation – Back to Basics]
+Scope: global only #### Trace Flag: 4029 -Function: Logs extended errors to errorlog when network disconnect occurs, turned off by default. Will dump out the socket error code this can sometimes give you a clue as to the root cause.
+Function: Logs extended errors to errorlog when network disconnect occurs, turned off by default. +Will dump out the socket error code this can sometimes give you a clue as to the root cause.
Link: https://blogs.msdn.microsoft.com/sql_protocols/2005/12/19/vss-sql-server-does-not-exist-or-access-denied #### Trace Flag: 4030 -Function: Prints both a byte and ASCII representation of the receive buffer. Used when you want to see what queries a client is sending to SQL Server. You can use this trace flag if you experience a protection violation and want to determine which statement caused it. Typically, you can set this flag globally or use SQL Server Enterprise Manager. You can also use DBCC INPUTBUFFER.
-Link: None +Function: Prints both a byte and ASCII representation of the receive buffer. +Used when you want to see what queries a client is sending to SQL Server. +You can use this trace flag if you experience a protection violation and want to determine which statement caused it. +Typically, you can set this flag globally or use SQL Server Enterprise Manager. +You can also use [DBCC INPUTBUFFER](https://docs.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-inputbuffer-transact-sql).
+Link: http://www.sqlservergeeks.com/sql-server-trace-flag-4030/
+Scope: global only #### Trace Flag: 4031 -Function: Prints both a byte and ASCII representation of the send buffers (what SQL Server sends back to the client). You can also use DBCC OUTPUTBUFFER.
-Link: None +Function: Prints both a byte and ASCII representation of the send buffers (what SQL Server sends back to the client). +You can also use [DBCC OUTPUTBUFFER](https://docs.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-outputbuffer-transact-sql).
+Link: http://www.sqlservergeeks.com/sql-server-trace-flag-4031/
+Scope: global only #### Trace Flag: 4032 Function: Traces the SQL commands coming in from the client. When enabled with 3605 it will direct those all to the error log.
-Link: https://support.microsoft.com/en-us/help/199037/how-to-capture-error-messages-that-are-sent-to-clients-from-an-instance-of-sql-server
-Link: https://support.microsoft.com/en-us/help/140895/inf-diagnostic-tips-for-the-microsoft-sql-server-odbc-driver +Link: https://support.microsoft.com/kb/199037
+Link: http://www.sqlservergeeks.com/sql-server-trace-flag-4032/
+Scope: global only @@ -2335,13 +2988,13 @@ Link: None #### Trace Flag: 4101 Function: “FIX: Reorder outer joins with filter criteria before non-selective joins and outer joins” Enabling this flag may increase the chance that selective filter criteria on an OUTER JOIN will influence the OJ earlier in the plan, rather than the more typical behavior of INNER JOINs being prioritized before OJs. Note that 4101 is also required to enable KB942444.
-Link: https://support.microsoft.com/en-us/help/318530/fix-reorder-outer-joins-with-filter-criteria-before-non-selective-joins-and-outer-joins +Link: https://support.microsoft.com/kb/318530 #### Trace Flag: 4102 Function: SQL 9 - Query performance is slow if the execution plan of the query contains semi join operators Typically, semi join operators are generated when the query contains the IN keyword or the EXISTS keyword. Enable flag 4102 and 4118 to overcome this.
-Link: https://support.microsoft.com/en-us/help/946020/fix-error-message-when-you-run-a-complex-query-after-you-install-cumulative-update-3-or-cumulative-update-4-for-sql-server-2005-service-pack-2-the-query-processor-ran-out-of-internal-resources-and-could-not-produce-a-query-plan +Link: https://support.microsoft.com/kb/946020 @@ -2384,7 +3037,7 @@ Link: None #### Trace Flag: 4109 Function: “FIX: Error message when you run a query that uses a fast forward-only cursor in SQL Server 2005: "Query processor could not produce a query plan because of the hints defined in this query”
-Link: https://support.microsoft.com/en-us/help/926773/fix-error-message-when-you-run-a-query-that-uses-a-fast-forward-only-cursor-in-sql-server-2005-query-processor-could-not-produce-a-query-plan-because-of-the-hints-defined-in-this-query +Link: https://support.microsoft.com/kb/926773 @@ -2405,7 +3058,7 @@ Function: Enables a fix for a problem that occurs when a linked server from 2005 execution plan that has a remote query. SQL Server 2005 must execute the remote query against SQL Server 2000 to retrieve the required data. SQL Server 2000 cannot handle the remote query. Therefore, error 107 occurs in SQL Server 2000. Then, error 107 is propagated back to SQL Server 2005. Therefore, error 107 occurs in SQL Server 2005, and error 8180 occurs in SQL Server 2005.”
-Link: https://support.microsoft.com/en-us/help/936223/fix-error-messages-when-you-run-a-query-against-a-linked-server-that-you-create-in-sql-server-2005-statement-s-could-not-be-prepared-and-the-column-prefix-column-prefix-name-does-not-match-with-a-table-name-or-alias-name-... +Link: https://support.microsoft.com/kb/936223 @@ -2435,7 +3088,7 @@ Link: None #### Trace Flag: 4120 Function: “FIX: Error message when you perform an update operation by using a cursor in SQL Server 2005: Transaction (Process ID ) was deadlocked on lock resources with another process and has been chosen as the deadlock victim” This issue is apparently due to deadlock issues related to upgrading a U lock to an X lock.
-Link: https://support.microsoft.com/en-us/help/953948/fix-error-message-when-you-perform-an-update-operation-by-using-a-cursor-in-sql-server-2005-transaction-process-id-spid-was-deadlocked-on-lock-resources-with-another-process-and-has-been-chosen-as-the-deadlock-victim +Link: https://support.microsoft.com/kb/953948 @@ -2465,7 +3118,7 @@ Link: None #### Trace Flag: 4126 Function: “FIX: The synchronization process is slow, and the CPU usage is high on the computer that is configured as the Distributor in SQL Server 2005” The problem manifested as a replication performance issue, but the following phrase found in the KB article indicates that it is a query processor issue: “the query that performs poorly shows that a join predicate is not pushed down to a Clustered Index Seek operator.”
-Link: https://support.microsoft.com/en-us/help/959013/fix-the-synchronization-process-is-slow,-and-the-cpu-usage-is-high-on-the-computer-that-is-configured-as-the-distributor-in-sql-server-2005 +Link: https://support.microsoft.com/kb/959013 @@ -2478,7 +3131,7 @@ Link: Note #### Trace Flag: 4128 Function: “FIX: When you update rows by using a cursor in SQL Server 2005, the update may take a long time to finish”
-Link: https://support.microsoft.com/en-us/help/957872/fix-when-you-update-rows-by-using-a-cursor-in-sql-server-2008,-the-update-may-take-a-long-time-to-finish +Link: https://support.microsoft.com/kb/957872 @@ -2502,7 +3155,7 @@ Link: None #### Trace Flag: 4133 Function: “FIX: The size of the SQL Server 2005 error log file or of the SQL Server 2008 error log file grows very quickly when query notifications are created and destroyed in a high ratio” & “FIX: The restore operation takes a long time when you restore a database that has query notification enabled in SQL Server 2005 or in SQL Server 2008”
-Link: https://support.microsoft.com/en-us/help/958006/fix-the-size-of-the-sql-server-2005-error-log-file-or-of-the-sql-server-2008-error-log-file-grows-very-quickly-when-query-notifications-are-created-and-destroyed-in-a-high-ratio +Link: https://support.microsoft.com/kb/958006 @@ -2511,7 +3164,7 @@ Function: Bugfix for error: parallel query returning different results every tim The trace flag disables an optimization in the query optimizer. The optimization caused the issue described in the KB article when you try to insert into a table by selecting from the table itself. As turning on the trace flag could result in a perf degradation, you only should use it if you run into the issue described in the KB article.
-Link: http://support.microsoft.com/kb/2546901
+Link: https://support.microsoft.com/kb/2546901
Link: http://sql-sasquatch.blogspot.se/2014/04/whaddayaknow-bout-sqlserver-trace-flag.html
Link: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/9ea718c2-e0e0-40cf-b12b-3269130448b7/trace-flag-4135-sql-server-2008?forum=sqldatabaseengine @@ -2519,44 +3172,53 @@ Link: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/9ea718c2-e0e0-40c #### Trace Flag: 4135 Function: Bugfix for error inserting to temp table
-Link: http://support.microsoft.com/kb/960770
+Link: https://support.microsoft.com/kb/960770
Link: https://connect.microsoft.com/SQLServer/feedback/details/541352/tempdb-errors-during-statistics-auto-update #### Trace Flag: 4136 Function: Disables parameter sniffing unless OPTION(RECOMPILE), WITH RECOMPILE or OPTIMIZE FOR value is used. -To accomplish this at the database level, see ALTER DATABASE SCOPED CONFIGURATION (Transact-SQL). -To accomplish this at the query level, add the OPTIMIZE FOR UNKNOWN query hint. -Beginning with SQL Server 2016 SP1, to accomplish this at the query level, add the USE HINT query hint instead of using this trace flag. +Starting with SQL Server 2016 (13.x), to accomplish this at the database level, see the PARAMETER_SNIFFING option in [ALTER DATABASE SCOPED CONFIGURATION (Transact-SQL)]. +To accomplish the same result at the query level, add the OPTIMIZE FOR UNKNOWN [query hint](https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-query?view=sql-server-2017). +The `OPTIMIZE FOR UNKNOWN` hint doesn't disable the parameter sniffing mechanism, but effectively bypasses it to achieve the same intended result. +Starting with SQL Server 2016 (13.x) SP1, a second option to accomplish this at the query level is to add the USE HINT 'DISABLE_PARAMETER_SNIFFING' query hint instead of using this trace flag. **Note: Please ensure that you thoroughly test this option, before rolling it into a production environment.**
Link: http://blogs.msdn.com/b/axinthefield/archive/2010/11/04/sql-server-trace-flags-for-dynamics-ax.aspx
Link: [New Features in SQL Server 2016 Service Pack 1]
Link: [Docs Trace Flags]
+Link: http://kejser.org/trace-flag-4136-2/
+Link: http://www.sqlservergeeks.com/sql-server-trace-flag-4136/
+Link: http://www.sqlservergeeks.com/sql-server-did-you-know-about-trace-flag-4136/
+Link: [KB2801413]
Scope: global or session or query #### Trace Flag: 4137 -Function: Causes SQL Server to generate a plan using minimum selectivity when estimating AND predicates for filters to account for correlation, under the query optimizer cardinality estimation model of SQL Server 2012 and earlier versions
-Beginning with SQL Server 2016 SP1, to accomplish this at the query level, add the USE HINT query hint instead of using this trace flag. +Function: Causes SQL Server to generate a plan using minimum selectivity when estimating AND predicates for filters to account for partial correlation instead of independence, under the query optimizer cardinality estimation model of SQL Server 2012 (11.x) and earlier versions (70).
+Starting with SQL Server 2016 (13.x) SP1, to accomplish this at the query level, add the USE HINT 'ASSUME_MIN_SELECTIVITY_FOR_FILTER_ESTIMATES' query hint instead of using this trace flag when using the CE 70. **Note: Please ensure that you thoroughly test this option, before rolling it into a production environment.**
-Link: http://support.microsoft.com/kb/2658214
+**Note: This trace flag does not apply to CE version 120 or above. Use trace flag [9471](#9471) instead.**
+Link: https://support.microsoft.com/kb/2658214
Link: [New Features in SQL Server 2016 Service Pack 1]
Link: [Docs Trace Flags]
+Link: [KB2801413]
+Link: [Cardinality Estimation for Multiple Predicates]
Scope: global or session or query #### Trace Flag: 4138 -Function: Causes SQL Server to generate a plan that does not use row goal adjustments with queries that contain TOP, OPTION (FAST N), IN, or EXISTS keywords
-Beginning with SQL Server 2016 SP1, to accomplish this at the query level, add the USE HINT query hint instead of using this trace flag. +Function: Causes SQL Server to generate a plan that does not use row goal adjustments with queries that contain `TOP`, `OPTION (FAST N)`, `IN`, or `EXISTS` keywords
+Beginning with SQL Server 2016 SP1, to accomplish this at the query level, add the `USE HINT` query hint instead of using this trace flag. **Note: Please ensure that you thoroughly test this option, before rolling it into a production environment.**
-Link: http://support.microsoft.com/kb/2667211
+Link: https://support.microsoft.com/kb/2667211
Link: [New Features in SQL Server 2016 Service Pack 1]
Link: [Docs Trace Flags]
Link: https://answers.sqlperformance.com/questions/1609/trying-to-figure-out-how-to-resolve-the-data-skew.html
Link: http://dba.stackexchange.com/questions/55198/huge-slowdown-to-sql-server-query-on-adding-wildcard-or-top
+Link: [KB2801413]
Scope: global or session or query @@ -2566,32 +3228,47 @@ Function: Enable automatically generated quick statistics (histogram amendment) If trace flag 4139 is set, regardless of the leading statistics column status (ascending, descending, or stationary), the histogram used to estimate cardinality will be adjusted at query compile time
Beginning with SQL Server 2016 SP1, to accomplish this at the query level, add the USE HINT query hint instead of using this trace flag. **Note: Please ensure that you thoroughly test this option, before rolling it into a production environment.**
-Link : https://support.microsoft.com/en-us/kb/2952101
+Link: https://support.microsoft.com/kb/2952101
Link: [Docs Trace Flags]
Link: [SQL Server - estimates outside of the histogram - half-baked draft]
+Link: [Parallelism in Hekaton (In-Memory OLTP)]
+Link: [Important Trace Flags That Every DBA Should Know]
+Link: https://support.microsoft.com/kb/974006
Scope: global or session or query #### Trace Flag: 4199 +**Important: Query Optimizer fixes that address wrong results or access violation errors are not enabled by trace flag 4199. +Those fixes are not considered optional and become enabled by default once the update package is installed.**
Function: Enables query optimizer (QO) changes released in SQL Server Cumulative Updates and Service Packs. -QO changes that are made to previous releases of SQL Server are enabled by default under the latest database compatibility level in a given product release, without trace flag 4199 enabled.
+QO changes that are made to previous releases of SQL Server are enabled by default under the latest database [compatibility level](https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-database-transact-sql-compatibility-level) in a given product release, without trace flag 4199 enabled.
The following table summarizes the behavior when using specific database compatibility levels and trace flag 4199: -| Database compatibility level | TF 4199 | QO changes from previous database compatibility levels | QO changes for current version post-RTM | -|------------------------------|-------------|--------------------------------------------------------|-----------------------------------------| -| 100 to 120 | Off
On | Disabled
Enabled | Disabled
Enabled | -| 130 | Off
On | Enabled
Enabled | Disabled
Enabled | -| 140 | Off
On | Enabled
Enabled | Disabled
Enabled | - -To enable this at the database level, see [ALTER DATABASE SCOPED CONFIGURATION (Transact-SQL)](https://msdn.microsoft.com/en-us/library/mt629158.aspx).
-**Note: Starting with SQL Server 2016 SP1, to accomplish this at the query level, add the USE HINT [query hint](https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-query) instead of using this trace flag.**
-Link: https://support.microsoft.com/en-us/kb/974006
+|Database Engine (DE) version | Database compatibility level | TF 4199 | QO changes from all previous Database Compatibility Levels | QO changes for DE version post-RTM | +|---------------------------------------------------------------|------------------------------|-------------|------------------------------------------------------------|------------------------------------| +| 13 (SQL Server 2016 (13.x)) | 100 to 120 | Off
On | Disabled
Enabled | Disabled
Enabled | +| | 130 (Default) | Off
On | Enabled
Enabled | Disabled
Enabled | +| 14 (SQL Server 2017 (14.x)) | 100 to 120 | Off
On | Disabled
Enabled | Disabled
Enabled | +| | 130 | Off
On | Enabled
Enabled | Disabled
Enabled | +| | 140 (Default) | Off
On | Enabled
Enabled | Disabled
Enabled | +| 15 (SQL Server 2019 (15.x))
and 12 (Azure SQL Database) | 100 to 120 | Off
On | Disabled
Enabled | Disabled
Enabled | +| | 130 to 140 | Off
On | Enabled
Enabled | Disabled
Enabled | +| | 150 (Default) | Off
On | Enabled
Enabled | Disabled
Enabled | + +Starting with SQL Server 2016 (13.x), to accomplish this at the database level, see the QUERY_OPTIMIZER_HOTFIXES option in [ALTER DATABASE SCOPED CONFIGURATION (Transact-SQL)](https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-database-scoped-configuration-transact-sql). +Starting with SQL Server 2016 (13.x) SP1, to accomplish this at the query level, add the USE HINT [query hint](https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-query) instead of using this trace flag.
+Link: https://support.microsoft.com/kb/974006
Link: [New Features in SQL Server 2016 Service Pack 1]
Link: [Docs Trace Flags]
-Link: https://support.microsoft.com/en-us/help/974006/sql-server-query-optimizer-hotfix-trace-flag-4199-servicing-model
+Link: https://support.microsoft.com/kb/974006
Link: https://sqlworkbooks.com/2017/04/selectively-enabletrace-flag-4199-and-query_optimizer_hotfixes-in-sql-server-2016/
Link: https://sqlworkbooks.com/2017/04/trace-flag-4199-no-per-session-override-if-you-enable-it-globally/
+Link: http://www.sqlservergeeks.com/sql-server-2016-database-scoped-configuration-and-trace-flag-4199/
+Link: https://nebraskasql.blogspot.com/2018/11/things-i-learned-at-summit-v20-trace.html
+Link: [Let’s talk about trace flags]
+Link: [KB2964518]
+Link: [KB2801413]
Scope: global or session or query @@ -2604,8 +3281,9 @@ Link: https://blogs.msdn.microsoft.com/sqlserverfaq/2008/07/31/upgrade-of-sql-se #### Trace Flag: 4610 -Function: When you use trace flag 4618 together with trace flag 4610, the number of entries in the cache store is limited to 8,192. When the limit is reached, SQL 2005 removes some entries from the TokenAndPermUserStore cache store.
-Link: https://support.microsoft.com/en-us/kb/959823
+Function: Increases the size of the hash table that stores the cache entries by a factor of 8. +When used together with trace flag 4618 increases the number of entries in the TokenAndPermUserStore cache store to 8,192.
+Link: https://support.microsoft.com/kb/959823
Link: [Docs Trace Flags]
Link: https://blogs.msdn.microsoft.com/psssql/2008/06/16/query-performance-issues-associated-with-a-large-sized-security-cache/
Scope: global only @@ -2626,7 +3304,7 @@ Link: http://blogs.msdn.com/b/lcris/archive/2007/02/19/sql-server-2005-some-new- #### Trace Flag: 4614 Function: Enables SQL Server authenticated logins that use Windows domain password policy enforcement to log on to the instance even though the SQL Server service account is locked out or disabled on the Windows domain controller.
-Link: https://support.microsoft.com/en-us/kb/925744 +Link: https://support.microsoft.com/kb/925744 @@ -2636,7 +3314,7 @@ In SQL Server, an application role cannot access metadata outside its own databa This is a change of behavior from earlier versions of SQL Server. Setting this global flag disables the new restrictions, and allows for application roles to access server-level metadata.
Link: [Docs Trace Flags]
-Link: https://support.microsoft.com/en-us/help/906549/you-may-receive-a-permission-denied-error-message-when-an-application-role-based-application-tries-to-select-records-from-any-one-of-the-system-tables-in-a-sql-server-2005-master-database
+Link: https://support.microsoft.com/kb/906549
Scope: global only @@ -2647,8 +3325,8 @@ It may incur a small CPU overhead as when removing old cache entries when new en It performs this action to limit the size of the cache store growth. However, the CPU overhead is spread over time. When used together with trace flag 4610 increases the number of entries in the TokenAndPermUserStore cache store to 8192
Link: [Docs Trace Flags]
-Link: https://support.microsoft.com/en-us/kb/933564
-Link: https://support.microsoft.com/en-us/help/959823/how-to-customize-the-quota-for-the-tokenandpermuserstore-cache-store-in-sql-server-2005-service-pack-3
+Link: https://support.microsoft.com/kb/933564
+Link: https://support.microsoft.com/kb/959823
Scope: global only @@ -2662,7 +3340,22 @@ Link: https://connect.microsoft.com/SQLServer/feedback/details/467661/sql-server #### Trace Flag: 4621 Function: SQL 9 – After 4610 & 4618 you can still customize the quota for TokenAndPermUserStore cache store that is based on the current workload
-Link: https://support.microsoft.com/en-us/kb/959823 +Link: https://support.microsoft.com/kb/959823 + + + +#### Trace Flag: 4631 +Function: Disables SHA2_256/AES256 for hashing passwords that generate encryption keys. Starting in SQL Server 2017 (14.x), SHA2 is used instead of SHA1. This means extra steps might be necessary to have your SQL Server 2017 (14.x) installation decrypt items that were encrypted by SQL Server 2016 (13.x)
+Link: [Encryption Changes in SQL Server 2017 CU2](https://learn.microsoft.com/en-us/sql/relational-databases/security/encryption/create-identical-symmetric-keys-on-two-servers?view=sql-server-ver17#encryption-changes-in-sql-server-2017-cu2)
+Link: [KB 4053407: SQL Server 2017 cannot decrypt data encrypted by earlier versions of SQL Server using the same symmetric key](https://support.microsoft.com/kb/4053407)
+Scope: global only + + + +#### Trace Flag: 4675 +Function: Enable checks on create credential for managed identity on a SQL Server on Azure VM if Microsoft Entra authentication is enabled. Enables diagnostics for the CREATE CREDENTAIL WITH IDENTITY = 'Managed Identity' statement. The trace flag provides information about the primary managed identity and its setting for SQL Server on Azure VM.
+Link: [DBCC TRACEON Trace Flags](https://learn.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-traceon-trace-flags-transact-sql?view=sql-server-ver17)
+Scope: global or session @@ -2691,17 +3384,19 @@ Link: http://dba.fyicenter.com/Interview-Questions/SYBASE/What_is_Trace_Flag_Def #### Trace Flag: 5302 Function: Alters default behavior of select…INTO (and other processes) that lock system tables for the duration of the transaction. This trace flag disables such locking during an implicit transaction.
-Link: https://support.microsoft.com/en-us/help/153096/fix-sql-server-6.5-service-pack-1-fixlist +Link: [KB153096] #### Trace Flag: 6498 -Function: Enables more than one large query compilation to gain access to the big gateway when there is sufficient memory available. +Function: Enables more than one large query compilation to gain access to the big gateway when there is sufficient memory available. +This trace flag can be used to keep memory usage for the compilation of incoming queries under control, avoiding compilation waits for concurrent large queries. It is based on the 80 percentage of SQL Server Target Memory, and it allows for one large query compilation per 25 gigabytes (GB) of memory.
**Note: Beginning with SQL Server 2014 SP2 and SQL Server 2016 this behavior is controlled by the engine and trace flag 6498 has no effect.**
-Link: https://support.microsoft.com/en-us/kb/3024815
+Link: https://support.microsoft.com/kb/3024815
Link: [Docs Trace Flags]
Link: http://blogs.msdn.com/b/sql_server_team/archive/2015/10/09/query-compile-big-gateway-policy-changes-in-sql-server.aspx
+Link: [KB2964518]
Scope: global only @@ -2714,7 +3409,7 @@ However, a memory dump may be generated if other trace flags are used. If this trace flag is enabled on a running server, a memory dump will not be automatically generated from that point on. However, if a memory dump has already been generated due to an out-of-memory exception in the CLR, this trace flag will have no effect.
Link: [Docs Trace Flags]
-Scope: global +Scope: global only @@ -2722,7 +3417,7 @@ Scope: global Function: Enables a hotfix for “ FIX: Slow performance in SQL Server 2012 or SQL Server 2014 when you build an index on a spatial data type of a large table”
Link: https://blogs.msdn.microsoft.com/psssql/2013/11/19/spatial-indexing-from-4-days-to-4-hours
-Link: https://support.microsoft.com/en-us/help/2896720/fix-slow-performance-in-sql-server-2012-or-sql-server-2014-when-you-build-an-index-on-a-spatial-data-type-of-a-large-table +Link: https://support.microsoft.com/kb/2896720 #### Trace Flag: 6531 @@ -2730,7 +3425,7 @@ Function: Enables adjustment in the SQLOS scheduling layer to handle queries tha This fix introduces the trace flag 6531 to indicate to the SQLOS hosting layer that the spatial data type should avoid preemptive protections. This can reduce the CPU consumption and improve the overall performance for spatial activities. Only use this trace flag if the individual, spatial method invocations (per row and column) take less than ~4ms. Longer invocations without preemptive protection could lead to scheduler concurrency issues and SQLCLR punishment messages logged to the error log.”
-Link: https://support.microsoft.com/en-us/help/3005300/fix-high-cpu-consumption-when-you-use-spatial-data-type-and-associated-methods-in-sql-server-2012-or-sql-server-2014 +Link: https://support.microsoft.com/kb/3005300 @@ -2739,7 +3434,8 @@ Function: Enables performance improvement of query operations with spatial data The performance gain will vary, depending on the configuration, the types of queries, and the objects.
Link: [KB3107399]
Link: [Docs Trace Flags]
-Scope: global and session +Link: [KB2964518]
+Scope: global or session @@ -2748,32 +3444,90 @@ Function: Enables performance improvement of query operations with spatial data The performance gain will vary, depending on the configuration, the types of queries, and the objects.
Link: [KB3107399]
Link: [Docs Trace Flags]
-Scope: global and session +Link: [KB2964518]
+Scope: global or session #### Trace Flag: 6534 Function: Enables performance improvement of query operations with spatial data types in SQL Server 2012, SQL Server 2014 and SQL Server 2016. The performance gain will vary, depending on the configuration, the types of queries, and the objects.
-Link: https://support.microsoft.com/en-us/kb/3054180
+Link: https://support.microsoft.com/kb/3054180
Link: [KB3107399]
Link: https://blogs.msdn.microsoft.com/bobsql/2016/06/03/sql-2016-it-just-runs-faster-native-spatial-implementations/
Link: [Docs Trace Flags]
-Scope: global and session +Link: [KB2964518]
+Scope: global only + + + +#### Trace Flag: 6545 +Function: Enables "CLR strict security" behavior (introduced in SQL Server 2017) in SQL Server 2012, SQL Server 2014, and SQL Server 2016. +When enabled, this option will require that _all_ assemblies, regardless of `PERMISSION_SET`, be signed, have an associated signature-based Login, and that the associated Login be granted the `UNSAFE ASSEMBLY` permission.
+Please note: +1. This TF can only be specified as a startup parameter!
+1. This TF is only available in instances that have been updated / patched with a Service Pack (SP), Cumulative Update (CU), or GDR that was released on or after 2017-08-08.
+**Note: This trace flag applies to SQL Server 2012 (11.x) SP3 CU10, SQL Server 2014 (12.x) SP2 CU6, SQL Server 2016 (13.x) RTM CU7, SQL Server 2016 (13.x) SP1 CU4, and higher builds. +Starting with SQL Server 2017 (14.x) this feature is enabled by default and trace flag 6545 has no effect.**
+Link: [SQLCLR vs. SQL Server 2012 & 2014 & 2016, Part 7: “CLR strict security” – The Problem Continues … in the Past (Wait, What?!?)][TF6545-b]
+Link: [Update adds the "CLR strict security" feature to SQL Server 2016][TF6545-a] ( KB4018930 )
+Link: https://support.microsoft.com/kb/3107399 +Scope: global only + + + +#### Trace Flag: 6559 +Function: avoids blocking from orphaned CLR sessions. Enables new functionality in SQL Server 2016 SP1 CU10, SQL Server 2017 CU18, and SQL Server 2019 CU1. Based on the description, this behavior will never be the default, and even though it is available in all versions after 2019, you have to opt into it with the trace flag.
+Link: https://support.microsoft.com/kb/4517771
+Scope: global only
+SQL Server Version: >= 2019 CU1, >= 2017 CU18, >= 2016 SP1 CU10 + + + +#### Trace Flag: 6773 +Function: Enables a fix to address an out of memory issue that occurs when bulk copying XML data where the sum of all XML attributes are > 2MB. This flag can help in circumstances where a client is running bulk copy of XML data and it receives sql error 6303 "XML parsing: Document parsing required too much memory".
+Link: https://support.microsoft.com/en-us/topic/kb4019125-fix-system-center-configuration-manager-replication-process-by-using-bcp-apis-fails-when-there-is-a-large-value-in-an-xml-column-53a969d5-801c-63ab-a557-bc89fe264394
+SQL Server Version: >= 2016 CU7, >= 2014 SP2 CU6, >= 2014 SP1 CU13, >= 2012 SP3 CU9 + + + +#### Trace Flag: 6950 +**Undocumented trace flag**
+Function: Disable SQL Server 2022's TempDB contention improvements around GAM/SGAM access.
+Link: [Github disable gamsgam]
+Scope: global only
+SQL Server Version: >= 2022 + + + +#### Trace Flag: 6962 +**Undocumented trace flag**
+Function: Disable SQL Server 2022's TempDB contention improvements around GAM/SGAM access.
+Link: [Github disable gamsgam]
+Scope: global only
+SQL Server Version: >= 2022 + + + +#### Trace Flag: 6981 +Function: Handle large objects (LOBs) when rebuilding the index that has an assertion issue (Location: blobbase.cpp:345; Expression: IS_ON (BLB_TI_END, m_status)). After turning on this trace flag and rebuilding the affected index, the assertion dump shouldn't be generated again. Added in SQL Server 2019 CU29.
+Link: [SQL Server 2019 CU29 Documentation](https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2019/cumulativeupdate29#3370476)
+SQL Server Version: >= 2019 CU29 #### Trace Flag: 7103 +**Undocumented trace flag**
Function: Disable table lock promotion for text columns
-Link: https://support.microsoft.com/en-us/kb/230044 +Link: None #### Trace Flag: 7300 Function: Outputs extra info about linked server errors
-Link: http://support.microsoft.com/kb/314530
-Link: https://support.microsoft.com/en-us/help/280106/how-to-set-up-and-troubleshoot-a-linked-server-to-an-oracle-database-in-sql-server
-Link: https://support.microsoft.com/en-us/help/280102/how-to-set-up-a-linked-server-to-a-sybase-database-server-and-troubleshoot-problems-that-may-occur
+Link: https://support.microsoft.com/kb/314530
+Link: https://support.microsoft.com/kb/280106
+Link: https://support.microsoft.com/kb/280102
Link: https://connect.microsoft.com/SQLServer/feedback/details/306380/trace-flag-issue-7300-3604 @@ -2786,30 +3540,42 @@ Link: None #### Trace Flag: 7311 Function: Offers a new alternative to handling the tricky problem of converting Oracle NUMBER types (across OLEDB linked server queries) with unknown precision/scale to a valid SQL Server data type, by treating all such types as NUMERIC(38,10).
-Link: https://support.microsoft.com/en-us/help/3051993/fix-the-value-of-number-type-is-truncated-when-you-select-data-from-an-oracle-linked-server-by-using-ole-db-provider +Link: https://support.microsoft.com/kb/3051993 #### Trace Flag: 7314 Function: Forces NUMBER values with unknown precision/scale to be treated as double values with OLE DB provider
Link: [Docs Trace Flags]
-Link: https://support.microsoft.com/en-us/kb/3051993
-Scope: global and session +Link: https://support.microsoft.com/kb/3051993
+Scope: global or session #### Trace Flag: 7352 -Function: Show the optimizer output and the post-optimization rewrite in action
+Function: Show the optimizer output and the post-optimization rewrite in action (After Post Optimization Rewrite)
Link: [Internals of the Seven SQL Server Sorts – Part 1]
-Link: http://sqlblog.com/blogs/paul_white/archive/2013/08/31/sql-server-internals-nested-loops-prefetching.aspx
-Link: http://www.queryprocessor.com/batch-sort-and-nested-loops +Link: https://www.sql.kiwi/2013/08/sql-server-internals-nested-loops-prefetching.html
+Link: http://www.queryprocessor.com/batch-sort-and-nested-loops
+Link: [Query Optimizer Deep Dive - Part 4]
+Link: [Few Outer Rows Optimization]
+Related to [8607](#8607) trace flag
+Scope: session only + + + +#### Trace Flag: 7356 +**Undocumented trace flag**
+Function: Added a probe residual to an adaptive join. Full effect unknown.
+Link: [New Undocumented Trace Flags]
+Scope: ? #### Trace Flag: 7357 Function: Outputs info re: hashing operators, including role reversal, recursion levels, whether the Unique Hash optimization could be used, info about the hash-related bitmap, etc. Dima’s article is a must-read. For parallel query plans, 7357 does NOT send output to the console window. However, output to the SQL Server error log can be enabled by enabling 3605.
Link: http://www.queryprocessor.com/hash-join-execution-internals
-Link: http://sqlblog.com/blogs/paul_white/archive/2012/05/01/query-optimizer-deep-dive-part-4.aspx +Link: [Query Optimizer Deep Dive - Part 4] @@ -2818,10 +3584,21 @@ Function: Disables the bitmap associated with hash matching. This bitmap is used Link: www.queryprocessor.com/hash-join-execution-internals + +#### Trace Flag: 7398 +**Undocumented trace flag**
+Function: Changed a nested loop join to have ordered prefetch.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + #### Trace Flag: 7470 -Function: Fixes a problem where under certain (unknown) conditions, a sort spill occurs for large sorts
-Link: https://support.microsoft.com/en-us/help/3088480/fix-sort-operator-spills-to-tempdb-in-sql-server-2012-or-sql-server-2014-when-estimated-number-of-rows-and-row-size-are-correct +Function: Enables additional computations for memory grants required for sort operations.
+**Note: This trace flag applies to SQL Server 2012 (11.x) SP2 CU8, SQL Server 2014 (12.x) RTM CU10, SQL Server 2014 (12.x) SP1 CU3, and higher builds.**
+**WARNING: Trace flag 7470 will increase memory requirements for queries using sort operators and may impact memory availability for other concurrent queries.**
+Link: https://support.microsoft.com/kb/3088480/
+Scope: global or session or query @@ -2829,25 +3606,36 @@ Link: https://support.microsoft.com/en-us/help/3088480/fix-sort-operator-spills- Function: Enables the lightweight query execution statistics profiling infrastructure. unless your server is already CPU bound, like you’re running all the time with 95% CPU, unless you are at that point, turn on this trace flag at any server you have. This would be my advice here because this enables that lightweight profiling infrastructure there and then you’ll see in a few minutes what it unleashes here. -So one thing that happens when I enable the lightweight profiling is that the sys.dm_exec_query_profiles DMV, which is something that actually populates the live query stats ability or feature of SSMS, now also is also populated with this lightweight profiling, which means that for all essence, we are now able to run a live query stats on all fashions at any given point in time, and this is extremely useful for let’s say a production DBA that someone calls and says, “Hey, you have a problem. To tap into running system and look at what it’s doing.”
+So one thing that happens when I enable the lightweight profiling is that the sys.dm_exec_query_profiles DMV, which is something that actually populates the live query stats ability or feature of SSMS, now also is also populated with this lightweight profiling, which means that for all essence, we are now able to run a live query stats on all fashions at any given point in time, and this is extremely useful for let’s say a production DBA that someone calls and says, “Hey, you have a problem. To tap into running system and look at what it’s doing.” +**Applies to: SQL Server 2016 (13.x) Service Pack 1 and later versions. Starting with SQL Server 2019 (15.x), this trace flag has no effect because lightweight profiling is enabled by default.**
Link: [Docs Trace Flags]
-Link: https://support.microsoft.com/en-us/kb/3170113
+Link: https://support.microsoft.com/kb/3170113
Link: https://www.brentozar.com/archive/2017/10/get-live-query-plans-sp_blitzwho/
Link: https://groupby.org/conference-session-abstracts/enhancements-that-will-make-your-sql-database-engine-roar-2016-sp1-edition/
+Link: https://www.scarydba.com/2018/06/11/plan-metrics-without-the-plan-trace-flag-7412/
+Link: [KB2964518]
Scope: global only #### Trace Flag: 7470 Function: Fix for sort operator spills to tempdb in SQL Server 2012 or SQL Server 2014 when estimated number of rows and row size are correct
-Link: https://support.microsoft.com/en-us/kb/3088480 +Link: https://support.microsoft.com/kb/3088480 #### Trace Flag: 7471 -Function: Running multiple UPDATE STATISTICS for different statistics on a single table concurrently
-Link: https://support.microsoft.com/en-us/kb/3156157
-Link: http://sqlperformance.com/2016/05/sql-performance/parallel-rebuilds +Function: Running multiple `UPDATE STATISTICS` for different statistics on a single table concurrently. +Trace Flag 7471 changes the locking behavior of update statistics command such that SQL Server engine no longer acquires `X LOCK` on UPDSTATS resource on the table. +Rather the engine acquires an (update) `U LOCK` on each individual statistics object being updated which doesn't block other parallel threads on the same table running on different statistics. +This behavior improves the overall concurrency of the update statistics job run executing in parallel and improves its performance.
+** TF 7471 can increase the possibility of deadlock especially when creation of new statistics and updating of existing statistics are executed simultaneously. +So the recommended best practice is to use TF 7471 only as a part of maintenance when update statistics jobs are run in parallel and should be turned off otherwise.** +Link: https://support.microsoft.com/kb/3156157
+Link: https://sqlperformance.com/2016/05/sql-performance/parallel-rebuilds
+Link: [KB2964518]
+Link: https://blogs.msdn.microsoft.com/sql_server_team/boosting-update-statistics-performance-with-sql-2014-sp1cu6/
+Scope: global only @@ -2911,6 +3699,12 @@ Function: SQL 9 - Full-text index population for the indexed view is very slow +#### Trace Flag: 7617 +Function: Skip dropping full-text index fragments marked as deletion during a database recovery process. Added in SQL Server 2019 CU29.
+Link: [SQL Server 2019 CU29 Documentation](https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2019/cumulativeupdate29#3540450) + + #### Trace Flag: 7646 Function: SQL 10 - Avoids blocking when using full text indexing. @@ -2931,18 +3725,22 @@ Scope: global only #### Trace Flag: 7752 Function: Enables asynchronous load of Query Store.
-Note: Use this trace flag if SQL Server is experiencing high number of QDS_LOADDB waits related to Query Store synchronous load (default behavior).
+**Note: Use this trace flag if SQL Server is experiencing high number of [QDS_LOADDB](https://www.sqlskills.com/help/waits/qds_loaddb/) waits related to Query Store synchronous load (default behavior).**
+**Note: Starting with SQL Server 2019 this behavior is controlled by the engine and trace flag 7752 has no effect.**
Link: [Docs Trace Flags]
Link: [Query Store Trace Flags]
+Link: [Let’s talk about trace flags]
Scope: global only #### Trace Flag: 7806 -Function: Enables a dedicated administrator connection (DAC) on SQL Server Express. By default, no DAC resources are reserved on SQL Server Express.
+Function: Enables a dedicated administrator connection ([DAC]) on SQL Server Express. +By default, no [DAC] resources are reserved on SQL Server Express.
Link: [Docs Trace Flags]
Link: https://msdn.microsoft.com/en-us/library/ms189595.aspx
Link: https://sqlperformance.com/2012/08/sql-memory/test-your-dac-connection
+Link: http://www.sqlservergeeks.com/sql-server-trace-flag-7806/
Scope: global only @@ -2962,7 +3760,7 @@ Link: https://connect.microsoft.com/SQLServer/feedback/details/518158/-packet-er #### Trace Flag: 7833 Function: SQL 2012 SP2 CU8 introduced a fix for a “silent error” condition in the sqlcmd tool. The CU also included this flag to allow customers to revert to pre-CU fix behavior.
-Link: https://support.microsoft.com/en-us/help/3082877/fix-no-error-is-prompted-when-connection-is-terminated-in-sqlcmd +Link: https://support.microsoft.com/kb/3082877 @@ -3007,23 +3805,34 @@ Link: https://technet.microsoft.com/en-us/library/cc917726.aspx #### Trace Flag: 8010 Function: Disables the “idle state” behavior that a SQL instance can enter (see TF 8009). Fixes problem that SQL Server services can not be stopped
-Link: http://support.microsoft.com/kb/2633271/en-us +Link: https://support.microsoft.com/kb/2633271 Link: https://technet.microsoft.com/en-us/library/cc917726.aspx #### Trace Flag: 8011 -Function: Disable the ring buffer for Resource Monitor
+Function: Trace flag 8011 disables the collection of additional diagnostic information for Resource Monitor. +You can use the information in this ring buffer to diagnose out-of-memory conditions. +Trace flag 8011 always applies across the server and has global scope. You can turn on trace flag 8011 at startup or in a user session.
Link: [KB920093]
Link: [Docs Trace Flags]
-Scope: global and session +Link: http://www.sqlservergeeks.com/sql-server-ring-buffer-trace-flag-8011/
+Scope: global only #### Trace Flag: 8012 -Function: Disable the ring buffer for schedulers
+Function: Disable the ring buffer for schedulers. +SQL Server records an event in the schedule ring buffer every time that one of the following events occurs: +a scheduler switches context to another worker, a worker is suspended, a worker is resumed, a worker enters the preemptive mode or the non-preemptive mode. +You can use the diagnostic information in this ring buffer to analyze scheduling problems. +For example, you can use the information in this ring buffer to troubleshoot problems when SQL Server stops responding. +Trace flag 8012 disables recording of events for schedulers. You can turn on trace flag 8012 only at startup. +The exception ring buffer records the last 256 exceptions that are raised on a node. +Each record contains some information about the error and contains a stack trace. A record is added to the ring buffer when an exception is raised.
Link: [KB920093]
Link: [Docs Trace Flags]
+Link: http://www.sqlservergeeks.com/sql-server-ring-buffer-trace-flag-8012/
Scope: global only @@ -3053,23 +3862,33 @@ Link: http://dba.stackexchange.com/questions/48580/trace-flag-and-which-need-to- #### Trace Flag: 8018 -Function: Disable the exception ring buffer
+Function: Disables the creation of the ring buffer, and no exception information is recorded. +Disabling the exception ring buffer makes it more difficult to diagnose problems that are related to internal server errors.
Link: [KB920093]
Link: [Docs Trace Flags]
+Link: http://www.sqlservergeeks.com/sql-server-ring-buffer-trace-flag-8018/
+Link: http://www.sqlservergeeks.com/sql-server-ring-buffer-trace-flag-8019/
Scope: global only #### Trace Flag: 8019 -Function: Disable stack collection for the exception ring buffer
+Function: Disable stack collection for the exception ring buffer +Disables stack collection during the record creation. +Trace flag 8019 has no effect if trace flag [8018](#8018) is turned on.
Link: [KB920093]
Link: [Docs Trace Flags]
+Link: http://www.sqlservergeeks.com/sql-server-ring-buffer-trace-flag-8019/
Scope: global only #### Trace Flag: 8020 -Function: Disable working set monitoring
+Function: Disable working set monitoring. +SQL Server uses the size of the working set when SQL Server interprets the global memory state signals from the operating system. +Trace flag 8020 removes the size of the working set from consideration when SQL Server interprets the global memory state signals. +If you use this trace flag incorrectly, heavy paging occurs, and the performance is poor. +Therefore, contact Microsoft Support before you turn on trace flag 8020.
Link: [KB920093]
Link: [Docs Trace Flags]
Scope: global only @@ -3085,9 +3904,10 @@ Link: https://blogs.msdn.microsoft.com/psssql/2011/11/11/sql-server-clarifying-t #### Trace Flag: 8022 -Function: This flag gives more information about the conditions when a non-yielding scheduler/situation was encountered. The whitepaper linked to on the right gives example output for this flag
+Function: This flag gives more information about the conditions when a non-yielding scheduler/situation was encountered. +The whitepaper linked to on the right gives example output for this flag
Link: None - + #### Trace Flag: 8024 @@ -3110,14 +3930,14 @@ Link: https://blogs.msdn.microsoft.com/psssql/2011/11/11/sql-server-clarifying-t #### Trace Flag: 8026 Function: SQL Server will clear a dump trigger after generating the dump once
-Link: http://support.microsoft.com/kb/917825/en-us
-Link: https://blogs.msdn.microsoft.com/psssql/2009/11/17/how-it-works-controlling-sql-server-memory-dumps +Link: [KB917825]
+Link: [Controlling SQL Server memory dumps] #### Trace Flag: 8030 Function: Fix for performance bug
-Link: http://support.microsoft.com/kb/917035
+Link: https://support.microsoft.com/kb/917035
@@ -3125,6 +3945,8 @@ Link: http://support.microsoft.com/kb/917035
Function: Alters cache limit settings
**Warning: Trace flag 8032 can cause poor performance if large caches make less memory available for other memory consumers, such as the buffer pool.**
Link: [Docs Trace Flags]
+Link: [SQL Server Plan Cache Limits]
+Link: [KB2964518]
Scope: global only @@ -3132,7 +3954,7 @@ Scope: global only #### Trace Flag: 8033 Function: Suppresses messages of the form “The time stamp counter of CPU on scheduler id 1 is not synchronized with other CPUs” from being placed in the SQL Error log when CPU drift is noticed
**Warning: SQL 9 - Disable the reporting of CPU Drift errors in the SQL Server error log like time stamp counter of CPU on scheduler id 1 is not synchronized with other CPUs.**
-Link: https://support.microsoft.com/en-us/help/931279/sql-server-timing-values-may-be-incorrect-when-you-use-utilities-or-technologies-that-change-cpu-frequencies
+Link: https://support.microsoft.com/kb/931279
Link: https://blogs.msdn.microsoft.com/psssql/2007/08/19/sql-server-2005-rdtsc-truths-and-myths-discussed @@ -3152,18 +3974,20 @@ Link: http://www.sqlservergeeks.com/blogs/AmitBansal/sql-server-bi/64/sql-server #### Trace Flag: 8048 +According [Docs Trace Flags]: Beginning with SQL Server 2014 SP2 and SQL Server 2016 this behavior is controlled by the engine and trace flag 8048 has no effect.
+**BUT [according SQL Server ultra expert Erik Darling](https://github.com/ktaranov/sqlserver-kit/issues/195): The trace flag does still has effect. The engine behavior will partition memory if `CMEMTHREAD` contention is detected. Turning on TF 8048 forces the partitioning without having to hit the internal thresholds. +I trust Eric's opinion (and bold it).**
Function: Converts NUMA partitioned memory objects into CPU partitioned
Link: http://sql-sasquatch.blogspot.se/2013/04/startup-trace-flags-i-love.html
-Link: https://support.microsoft.com/en-us/kb/2809338
+Link: https://support.microsoft.com/kb/2809338
Link: http://blogs.msdn.com/b/psssql/archive/2012/12/20/how-it-works-cmemthread-and-debugging-them.aspx
Link: [Docs Trace Flags]
Link: http://blogs.msdn.com/b/psssql/archive/2011/09/01/sql-server-2008-2008-r2-on-newer-machines-with-more-than-8-cpus-presented-per-numa-node-may-need-trace-flag-8048.aspx
-**Note: Beginning with SQL Server 2014 SP2 and SQL Server 2016 this behavior is controlled by the engine and trace flag 8048 has no effect.**
+Link: [Hidden Performance & Manageability Improvements in SQL Server 2012 / 2014]
+Link: [KB2964518]
+Related to: [8015](#8015), [9024](#9024)
Scope: global only -*Thanks to: @sql\_handle (https://twitter.com/sql_handle)* -Related to: [8015](#8015), [9024](#9024) - #### Trace Flag: 8049 @@ -3180,8 +4004,13 @@ Link: https://blogs.msdn.microsoft.com/psssql/2009/11/02/the-sql-server-wait-typ #### Trace Flag: 8075 -Function: Enables a fix (after applying the appropriate CU) for x64 VAS exhaustion.
-Link: https://support.microsoft.com/en-us/help/3074434/fix-out-of-memory-error-when-the-virtual-address-space-of-the-sql-server-process-is-very-low-on-available-memory +Function: Enables a fix (after applying the appropriate CU) for x64 VAS exhaustion. +Assume that you install the 64-bit version of Microsoft SQL Server 2014, 2016 or 2017 on a computer that's running Windows Server 2012 or an earlier version of Windows operating system. +When SQL Server uses up all the user-mode virtual address space, you may receive an out of memory error message in the SQL Server error log. +Additionally, queries take a long time to finish execution, and the `SOS_MEMORY_TOPLEVELBLOCKALLOCATOR` wait occurs.
+Link: https://support.microsoft.com/kb/3074434
+Link: [KB2964518]
+Scope: global only @@ -3195,13 +4024,22 @@ It is recommended to first test the performance of workload with Auto-Soft NUMA Link: [KB972767]
Link: [Docs Trace Flags]
Link: https://blogs.msdn.microsoft.com/sqlreleaseservices/sql-server-2012-service-pack-4-sp4-released/
+Link: [Hidden Performance & Manageability Improvements in SQL Server 2012 / 2014]
+Link: [KB2964518]
+Scope: global only + + + +#### Trace Flag: 8101 +Function: Enables a spinlock contention fix for high-end systems running SQL Server 2019 (15.x) serving many concurrent users.
+Note: This trace flag applies to SQL Server 2019 (15.x) CU2 and higher builds.
+Link: https://support.microsoft.com/kb/4538688
Scope: global only #### Trace Flag: 8202 -Function: Used to replicate UPDATE as DELETE/INSERT pair at the publisher. i.e. -UPDATE commands at the publisher can be run as an "on-page DELETE/INSERT" or a "full DELETE/INSERT". +Function: Used to replicate `UPDATE` as `DELETE/INSERT` pair at the publisher. i.e. UPDATE commands at the publisher can be run as an "on-page DELETE/INSERT" or a "full DELETE/INSERT". If the UPDATE command is run as an "on-page DELETE/INSERT," the Logreader send UDPATE command to the subscriber, If the UPDATE command is run as a "full DELETE/INSERT," the Logreader send UPDATE as DELETE/INSERT Pair. If you turn on trace flag 8202, then UPDATE commands at the publisher will be always send to the subscriber as DELETE/INSERT pair.
@@ -3247,16 +4085,15 @@ Link: None #### Trace Flag: 8295 Function: Creates a secondary index on the identifying columns on the change tracking side table at enable time
Link: https://social.msdn.microsoft.com/forums/sqlserver/en-US/00250311-7991-47b0-b788-7fae2e102254/trace-flag-8295
-Link: https://support.microsoft.com/en-us/help/2476322/fix-a-common-table-expression-based-query-that-uses-the-changetable-function-runs-very-slowly-in-sql-server-2008-service-pack-1-or-sql-server-2008-r2
+Link: https://support.microsoft.com/kb/2476322
Link: https://www.brentozar.com/archive/2014/06/performance-tuning-sql-server-change-tracking
Link: https://blogs.technet.microsoft.com/smartinez/2013/03/06/sql-server-for-configmgr-2012-ebook-and-top-10-database-issues
-Thanks to: Wilfred van Dijk #### Trace Flag: 8446 Function: Databases in SQL 8 do not have a Service Broker ID. If you restore these databases on SQL 9 by using the WITH NORECOVERY option, these databases will not be upgraded causing mirroring & log-shipping configurations to fail.
-Link: https://support.microsoft.com/en-us/kb/959008 +Link: https://support.microsoft.com/kb/959008 @@ -3265,6 +4102,12 @@ Function: Writes detailed information about Ms-DTC context & state changes to th Link: None + +#### Trace Flag: 8531 +Function: Fixes a contention issue with high KTM_RECOVERY_MANAGER wait times that you might encounter when running XA distributed transactions. Note: You need to turn on trace flag 8531 as a startup trace flag.
+Link: [SQL Server 2019 CU29 Documentation](https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2019/cumulativeupdate29#3417392) + + #### Trace Flag: 8599 Function: Allows you to use a save-point within a distributed transaction
@@ -3273,31 +4116,44 @@ Link: None #### Trace Flag: 8602 -Function: Ignore index hints that are specified in query/procedure.
-Link: download.microsoft.com/download/6/e/5/6e52bf39-0519-42b7-b806-c32905f4a066/eim_perf_flowchart_final.pdf
+Function: This trace flag is used to ignore all the index hints specified in query or stored procedure. +We can use this trace flag to troubleshooting the query performance without changing index hints.
+Link: http://download.microsoft.com/download/6/e/5/6e52bf39-0519-42b7-b806-c32905f4a066/eim_perf_flowchart_final.pdf
Link: http://sqlblog.com/blogs/kalen_delaney/archive/2008/02/26/lost-without-a-trace.aspx
+Link: http://www.sqlservergeeks.com/sql-server-trace-flag-8602/
+Scope: global only
+Demo: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Trace_Flag/Trace_Flag_8602.sql #### Trace Flag: 8605 +**Undocumented trace flag**
Function: Displays logical and physical trees used during the optimization process
Link: [More Undocumented Query Optimizer Trace Flags]
-Link: [Yet another X-Ray for the QP] +Link: [Yet another X-Ray for the QP]
+Link: [Query Optimizer Deep Dive - Part 4]
+Link: [Query Optimizer Deep Dive - Part 1]
+Scope: session or query #### Trace Flag: 8606 +**Undocumented trace flag**
Function: Show LogOp Trees
Link: [Cardinality Estimation Framework 2014 First Look]
-Link: [Yet another X-Ray for the QP] +Link: [Yet another X-Ray for the QP]
+Link: [Query Optimizer Deep Dive - Part 4] #### Trace Flag: 8607 -Function: Displays the optimization output tree during the optimization process
+Function: Displays the optimization output tree during the optimization process (Before Post Optimization Rewrite).
Link: [Internals of the Seven SQL Server Sorts – Part 1]
Link: [More Undocumented Query Optimizer Trace Flags]
-Link: [Yet another X-Ray for the QP] +Link: [Yet another X-Ray for the QP]
+Link: [Query Optimizer Deep Dive - Part 4]
+Link: [Few Outer Rows Optimization]
+Scope: session only @@ -3305,70 +4161,102 @@ Link: [Yet another X-Ray for the QP] Function: Shows the initial Memo structure
Link: http://www.queryprocessor.ru/optimizer-part-3-full-optimiztion-optimization-search0
Link: http://www.benjaminnevarez.com/2012/04/inside-the-query-optimizer-memo-structure
-Link: http://sqlblog.com/blogs/paul_white/archive/2012/04/29/query-optimizer-deep-dive-part-3.aspx +Link: [Query Optimizer Deep Dive – Part 3]
+Link: [Query Optimizer Deep Dive - Part 4] #### Trace Flag: 8609 -Function: PWhite: “Task and operation type counts”
-Link: http://sqlblog.com/blogs/paul_white/archive/2012/05/01/query-optimizer-deep-dive-part-4.aspx
-Link: http://www.queryprocessor.ru/good-enough-plan +Function: PWhite: “Task and operation type counts”.
+Link: [Query Optimizer Deep Dive - Part 4]
+Link: http://www.queryprocessor.ru/good-enough-plan
+Scope: session only #### Trace Flag: 8612 Function: Add Extra Info to the Trees Output
Link: [Cardinality Estimation Framework 2014 First Look]
-Link: http://sqlblog.com/blogs/paul_white/archive/2013/06/11/hello-operator-my-switch-is-bored.aspx +Link: [Hello Operator, My Switch Is Bored] #### Trace Flag: 8615 +**Undocumented trace flag**
Function: Display the final memo structure
Link: http://www.benjaminnevarez.com/2012/04/inside-the-query-optimizer-memo-structure/
-Link: http://www.somewheresomehow.ru/optimizer-part-3-full-optimiztion-optimization-search0/ +Link: http://www.somewheresomehow.ru/optimizer-part-3-full-optimiztion-optimization-search0/
+Link: [A Row Goal Riddle]
+Scope: session only #### Trace Flag: 8619 +**Undocumented trace flag**
Function: Show Applied Transformation Rules
-Link: http://sqlblog.com/blogs/paul_white/archive/2013/02/06/incorrect-results-with-indexed-views.aspx
+Link: https://www.sql.kiwi/2013/02/incorrect-results-with-indexed-views.html
Link: [Cardinality Estimation Framework 2014 First Look]
-Link: [Yet another X-Ray for the QP] +Link: [Yet another X-Ray for the QP]
+Link: [A Row Goal Riddle]
+Scope: session only #### Trace Flag: 8620 +**Undocumented trace flag**
Function: Add memo arguments to trace flag 8619
Link: [Query Optimizer Deep Dive - Part 4]
-Link: [Yet another X-Ray for the QP] +Link: [Yet another X-Ray for the QP]
+Link: [A Row Goal Riddle]
+Scope: session only #### Trace Flag: 8621 +**Undocumented trace flag**
Function: Rule with resulting tree
Link: [Query Optimizer Deep Dive - Part 4]
-Link: [Yet another X-Ray for the QP] +Link: [Yet another X-Ray for the QP]
+Link: [A Row Goal Riddle]
+Scope: session only #### Trace Flag: 8628 -Function: When used with TF 8666, causes extra information about the transformation rules applied to be put into the XML showplan.
+**Undocumented trace flag**
+Function: When used with TF [8666](#8666), causes extra information about the transformation rules applied to be put into the XML showplan.
Link: [Yet another X-Ray for the QP] #### Trace Flag: 8633 Function: PWhite: “Enable prefetch (CUpdUtil::FPrefetchAllowedForDML and CPhyOp_StreamUpdate::FDoNotPrefetch)”
-Link: http://sqlblog.com/blogs/paul_white/archive/2013/01/26/optimizing-t-sql-queries-that-change-data.aspx +Link: [Optimizing T-SQL queries that change data] #### Trace Flag: 8649 -Function: Set Cost Threshold for parallelism from 1 to 0
-Link: http://sqlblog.com/blogs/paul_white/archive/2011/12/23/forcing-a-parallel-query-execution-plan.aspx
-Link: http://sqlblog.com/blogs/adam_machanic/archive/2013/07/11/next-level-parallel-plan-porcing.aspx
-Link: [What You Need to Know about the Batch Mode Window Aggregate Operator in SQL Server 2016: Part 1] +**Undocumented trace flag**
+Function: Set Cost Threshold for parallelism from 1 to 0, Forcing a Parallel Query Execution Plan. +Possible drawbacks: you'll run out of worker threads (if max worker threads is at default value) and unintentionally reduce DOP for queries that could really use parallelism. +Also be queries that looked fine with a serial merge join that, with a parallel merge join now have an order-preserving repartition streams and their performance will go to crap. +In the new version of SQL Server 2017 there is one more way to force parallel plan, that involves using the undocumented hint `ENABLE_PARALLEL_PLAN_PREFERENCE`.
+Link: https://www.sql.kiwi/2011/12/forcing-a-parallel-query-execution-plan.html
+Link: https://www.sqlshack.com/sql-server-2017-how-to-get-a-parallel-plan/
+Link: [What You Need to Know about the Batch Mode Window Aggregate Operator in SQL Server 2016: Part 1]
+Link: [Few Outer Rows Optimization]
+Link: [Next-Level Parallel Plan Forcing: An Alternative to 8649]
+Link: https://logicalread.com/2015/10/30/sql-server-query-parallelizing-mc11/
+Link: https://twitter.com/erikdarlingdata/status/1233449807907303425
+Scope: global or session or query + + + +#### Trace Flag: 8665 +**Undocumented trace flag**
+Function: Disables local/global aggregation.
+Link: [New Undocumented Trace Flags]
+Scope: ? @@ -3381,12 +4269,26 @@ Link: [Internals of the Seven SQL Server Sorts – Part 1]
Link: [Yet another X-Ray for the QP]
Link: https://blogfabiano.com/2012/07/03/statistics-used-in-a-cached-query-plan
Link: http://dataidol.com/davebally/2014/04/12/reasons-why-your-plans-suck-no-56536
-Link: https://www.mssqltips.com/sqlservertip/4269/how-to-identify-useful-sql-server-table-statistics/ +Link: https://www.mssqltips.com/sqlservertip/4269/how-to-identify-useful-sql-server-table-statistics/
+Link: http://sql-sasquatch.blogspot.com/2018/06/harvesting-sql-server-trace-flag-8666.html
+Link: https://sql-sasquatch.blogspot.com/2018/12/fun-with-sql-server-plan-cache-trace.html
+Link: [Fun with SQL Server Plan Cache, Trace Flag 8666, and Trace Flag 2388]
+Scope: global or session + + +#### Trace Flag: 8670 +**Undocumented trace flag**
+Function: Skip search 2 in plan?
+Link: [Query Optimizer Deep Dive - Part 4]
+Scope: ? + #### Trace Flag: 8671 -Function: According to Dima, disables the logic that prunes the memo and prevents the optimization process from stopping due to “Good Enough Plan found”. Can significantly increase the amount of time, CPU, and memory used in the compilation process
+**Undocumented trace flag**
+Function: According to Dimitriy Pilugin, disables the logic that prunes the memo and prevents the optimization process from stopping due to “Good Enough Plan found”. +Can significantly increase the amount of time, CPU, and memory used in the compilation process
Link: http://www.queryprocessor.ru/optimizer_unleashed_2 @@ -3394,28 +4296,47 @@ Link: http://www.queryprocessor.ru/optimizer_unleashed_2 #### Trace Flag: 8675 Function: Displays the query optimization phases for a specific optimization
Link: [More Undocumented Query Optimizer Trace Flags]
-Link: http://sqlblog.com/blogs/paul_white/archive/2012/04/29/query-optimizer-deep-dive-part-3.aspx
+Link: [Query Optimizer Deep Dive – Part 3]
Link: https://sqlperformance.com/2013/06/sql-indexes/recognizing-missed-optimizations #### Trace Flag: 8677 +**Undocumented trace flag**
Function: Skips “Search 1” phase of query optimization, and only Search 0 and Search 2 execute.
Link: https://sqlbits.com/Sessions/Event12/Query_Optimizer_Internals_Traceflag_fun + +#### Trace Flag: 8678 +**Undocumented trace flag**
+Function: For one query this changed a bushy plan to a left deep one. There was no change in cost. Full effect unknown.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + #### Trace Flag: 8679 +**Undocumented trace flag**
Function: Prevents the SQL Server optimizer from using a Hash Match Team operator
Link: None #### Trace Flag: 8687 +**Undocumented trace flag**
Function: Prevents the SQL Server optimizer from using a Hash Match Team operator
Link: None + +#### Trace Flag: 8688 +**Undocumented trace flag**
+Function: Disables parallel scans.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + #### Trace Flag: 8690 **Undocumented trace flag**
@@ -3426,6 +4347,16 @@ But in vast majority of situations, you don’t need to manually disable spool w Link: https://blogs.msdn.microsoft.com/psssql/2015/12/15/spool-operator-and-trace-flag-8690/
Link: http://dba.stackexchange.com/questions/52552/index-not-making-execution-faster-and-in-some-cases-is-slowing-down-the-query
Link: http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=453982 +Link: [Nested Loops Joins and Performance Spools]
+Scope: ? + + +#### Trace Flag: 8691 +**Undocumented trace flag**
+Function: 'performance spool' optimization to the RegEx execution, reduces the number of executions of the RegEx function.
+Link: [Splitting Strings Based on Patterns]
+Link: [Nested Loops Joins and Performance Spools]
+Scope: ? @@ -3450,8 +4381,9 @@ Link: http://www.hanlincrest.com/SQLserverStoredProcRecompiles.htm #### Trace Flag: 8721 Function: Reports to the error log when auto-update statistics executes
-Link: https://support.microsoft.com/en-us/kb/195565
+Link: https://support.microsoft.com/kb/195565
Link: [Docs Trace Flags]
+Link: http://www.sqlservergeeks.com/sql-server-trace-flag-8721/
Scope: global only @@ -3461,6 +4393,28 @@ Function: Disable all hints except locking hints
Link: http://sqlmag.com/sql-server/investigating-trace-flags + +#### Trace Flag: 8726
+**Undocumented trace flag**
+Function: Disables the heuristic that discourages the optimizer from producing an index union plan.
+Link: [Why are (seemingly) suitable indexes not used on a LEFT JOIN with OR]
+Link: https://github.com/ktaranov/sqlserver-kit/issues/170
+Link: https://dba.stackexchange.com/a/23779
+Link: https://dba.stackexchange.com/a/261790
+Scope: query only
+Demo: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Trace_Flag/Trace_Flag_8726.sql + + + +#### Trace Flag: 8727
+**Undocumented trace flag**
+Function: Can be used to prevent unwanted index union plans.
+Link: [Why are (seemingly) suitable indexes not used on a LEFT JOIN with OR]
+Link: https://github.com/ktaranov/sqlserver-kit/issues/170
+Scope: query only
+Demo: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Trace_Flag/Trace_Flag_8727.sql + + #### Trace Flag: 8738 Function: (Apparently) disables an optimization where rows are sorted before a Key Lookup operator. (The optimization is meant to promote Sequential IO rather than the random nature of IO from Key Lookups). @@ -3470,18 +4424,43 @@ Link: https://answers.sqlperformance.com/questions/603/why-is-the-sort-operator- #### Trace Flag: 8739 -Function: Dima: “Group Optimization Info”
+Function: Group Optimization Information
Link: http://www.queryprocessor.ru/good-enough-plan + +#### Trace Flag: 8741 +**Undocumented trace flag**
+Function: Resulted in a different join order for some queries with a higher estimated cost. Perhaps this disables Transitive Predicates? Full effect unknown.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + + +#### Trace Flag: 8742 +**Undocumented trace flag**
+Function: Resulted in a different join order for some queries. Full effect unknown.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + + +#### Trace Flag: 8743 +**Undocumented trace flag**
+Function: Disable SM join.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + #### Trace Flag: 8744 -Function: Disable pre-fetching for the Nested Loop operator
+Function: Disable pre-fetching for the Nested Loop operator. +**WARNING: Incorrect use of this trace flag may cause additional physical reads when SQL Server executes plans that contain the Nested Loops operator.**
Link: [KB920093]
Link: [Docs Trace Flags]
-Link: http://sqlblog.com/blogs/paul_white/archive/2013/03/08/execution-plan-analysis-the-mystery-work-table.aspx
+Link: https://www.sql.kiwi/2013/03/execution-plan-analysis-the-mystery-work-table.html
Link: https://connect.microsoft.com/SQLServer/feedback/details/780194/make-dbcc-trace-flags-available-as-option-querytraceon
-Scope: global only +Scope: global or session @@ -3490,6 +4469,14 @@ Function: Whatever else it does, one effect is to disable the “rowset sharing Link: https://sqlperformance.com/2016/03/sql-plan/changes-to-a-writable-partition-may-fail + +#### Trace Flag: 8750 +**Undocumented trace flag**
+Function: Skips search 0 optimization phase and moves to search 1.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + #### Trace Flag: 8755 Function: Disable all locking hints
@@ -3500,28 +4487,39 @@ Link: http://sqlmag.com/sql-server/investigating-trace-flags #### Trace Flag: 8757 Function: Skip trivial plan optimization and force a full optimization
Link: [More Undocumented Query Optimizer Trace Flags]
-Link: http://sqlblog.com/blogs/paul_white/archive/2012/04/28/query-optimizer-deep-dive-part-1.aspx +Link: [Query Optimizer Deep Dive - Part 1]
+Scope: session or query #### Trace Flag: 8758 Function: “A [workaround to the MERGE bug described] is to apply Trace Flag 8758 –unfortunately this disables a number of optimisations, not just the one above, so it’s not really recommended for long term use.” “Disable rewrite to a single operator plan (CPhyOp_StreamUpdate::PqteConvert)”
-Link: http://sqlblog.com/blogs/paul_white/archive/2010/08/04/another-interesting-merge-bug.aspx
-Link: http://sqlblog.com/blogs/paul_white/archive/2013/01/26/optimizing-t-sql-queries-that-change-data.aspx
+Link: https://www.sql.kiwi/2010/08/another-interesting-merge-bug.html
+Link: [Optimizing T-SQL queries that change data]
+ + + +#### Trace Flag: 8759 +**Undocumented trace flag**
+Function: Detect and write part of the query to the error log when it has been autoparameterized.
+Link: https://github.com/ktaranov/sqlserver-kit/issues/146#issue-358855110
+Scope: ? #### Trace Flag: 8765 Function: Allows use of variable length data, from ODBC driver; fixes the issue of a field returning the wrong data length
Link: http://jacob.steelsmith.org/content/sql-server-and-ole-db
-Link: https://bugs.mysql.com/bug.php?id=46857 +Scope: global or session #### Trace Flag: 8780 Function: Give the optimizer more time to find a better plan
-Link: http://www.queryprocessor.ru/optimizer_unleashed_1 +Link: http://www.queryprocessor.ru/optimizer_unleashed_1
+Link: http://www.sqlservice.se/sql-server-trace-flag-8780/
+Scope: global or session @@ -3533,18 +4531,26 @@ Link: None #### Trace Flag: 8790 Function: PWhite: “Undocumented trace flag 8790 forces a wide update plan for any data-changing query (remember that a wide update plan is always possible)”
-Link: https://support.microsoft.com/en-us/help/956718/fix-a-merge-statement-may-not-enforce-a-foreign-key-constraint-when-the-statement-updates-a-unique-key-column-that-is-not-part-of-a-clustering-key-and-there-is-a-single-row-as-the-update-source-in-sql-server-2008
-Link: http://sqlblog.com/blogs/paul_white/archive/2012/12/10/merge-bug-with-filtered-indexes.aspx
+Link: https://support.microsoft.com/kb/956718
+Link: https://www.sql.kiwi/2012/12/merge-bug-with-filtered-indexes.html
Link: https://sqlperformance.com/2014/06/sql-plan/filtered-index-side-effect #### Trace Flag: 8795 Function: PWhite: “Disable DML Request Sort (CUpdUtil::FDemandRowsSortedForPerformance)”
-Link: http://sqlblog.com/blogs/paul_white/archive/2013/01/26/optimizing-t-sql-queries-that-change-data.aspx
+Link: [Optimizing T-SQL queries that change data]
Link: https://sqlperformance.com/2014/10/t-sql-queries/performance-tuning-whole-plan + +#### Trace Flag: 8799 +**Undocumented trace flag**
+Function: Forces unordered scans.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + #### Trace Flag: 8809 Function: Extended Page Heap Activities. @@ -3568,7 +4574,7 @@ Link: None #### Trace Flag: 8903 Function: Allows SQL Server to use a specific API (SetFileIoOverlappedRange) when Locked Pages in Memory is enabled.
Link: https://blogs.msdn.microsoft.com/psssql/2012/03/20/setfileiooverlappedrange-can-lead-to-unexpected-behavior-for-sql-server-2008-r2-or-sql-server-2012-denali
-Link: https://support.microsoft.com/en-us/help/2679255/sql-server-data-corruption-when-a-memory-range-is-accessed-by-the-setfileiooverlappedrange-function-and-an-i-o-operation-in-windows-vista,-in-windows-server-2008,-in-windows-7,-or-in-windows-server-2008-r2
+Link: https://support.microsoft.com/kb/2679255
Link: https://blogs.msdn.microsoft.com/psssql/2013/10/16/every-time-i-attach-database-sql-logs-error-1314-for-setfileiooverlappedrange @@ -3576,8 +4582,9 @@ Link: https://blogs.msdn.microsoft.com/psssql/2013/10/16/every-time-i-attach-dat #### Trace Flag: 9024 Function: Converts a global log pool memory object into NUMA node partitioned memory object
**Note: Beginning with SQL Server 2012 SP3 and SQL Server 2014 SP1 this behavior is controlled by the engine and trace flag 9024 has no effect.**
-Link: https://support.microsoft.com/en-us/kb/2809338
+Link: https://support.microsoft.com/kb/2809338
Link: [Docs Trace Flags]
+Link: [KB2964518]
Scope: global only
Related to: [8048](#8048) @@ -3662,32 +4669,46 @@ Link: None #### Trace Flag: 9109 Function: Used to workaround a problem with query notifications and restoring a DB with the NEW_BROKER option enabled.
-Link: https://support.microsoft.com/en-us/help/2483090/restore-or-recovery-may-fail-or-take-a-long-time-if-query-notification-is-used-in-a-database +Link: https://support.microsoft.com/kb/2483090 + + + +#### Trace Flag: 9114 +**Undocumented trace flag**
+Function: Prevents the optimizer rewriting the apply as a join.
+Link: [New Undocumented Trace Flags]
+Link: https://dba.stackexchange.com/a/274195/107045
+Scope: global or session or query
+Versions: 2008-2019 #### Trace Flag: 9115 Function: PWhite: “Disable prefetch (CUpdUtil::FPrefetchAllowedForDML)” Dima: “Disables both [NLoop Implicit Batch Sort {TF 2340} and NL Prefetching {TF 8744}], and not only on the Post Optimization, but the explicit Sort also”
-Link: http://sqlblog.com/blogs/paul_white/archive/2013/01/26/optimizing-t-sql-queries-that-change-data.aspx
+Link: [Optimizing T-SQL queries that change data]
Link: http://www.hanlincrest.com/SQLServerLockEscalation.htm
Link: http://www.queryprocessor.com/batch-sort-and-nested-loops #### Trace Flag: 9130 +**Undocumented trace flag**
Function: Disables the particular copy out stage rewrite from Filter + (Scan or Seek) to (Scan or Seek) + Residual Predicate. -Enabling this flag retains the Filter in the final execution plan, resulting in a SQL Server 2008+ plan that mirrors the 2005 version.
-Link: http://sqlblog.com/blogs/paul_white/archive/2012/10/15/cardinality-estimation-bug-with-lookups-in-sql-server-2008-onward.aspx
+Enabling this flag retains the Filter in the final execution plan, resulting in a SQL Server 2008+ plan that mirrors the 2005 version. +Before Service Pack 3 of SQL Server 2012, we didn't have property `Number of Rows Read` in execution plan, and to get a feel for the difference between the `Number of Rows Read` and the `Actual Number of Rows`, we'd need to use trace flag 9130.
+Link: https://www.sql.kiwi/2012/10/cardinality-estimation-bug-with-lookups-in-sql-server-2008-onward.html
Link: http://sqlblogcasts.com/blogs/sqlandthelike/archive/2012/12/06/my-new-favourite-traceflag.aspx
-Link: http://sqlblog.com/blogs/paul_white/archive/2013/06/11/hello-operator-my-switch-is-bored.aspx
+Link: [Hello Operator, My Switch Is Bored]
Link: https://connect.microsoft.com/SQLServer/feedback/details/767395/cardinality-estimation-error-with-pushed-predicate-on-a-lookup
-Link: http://www.theboreddba.com/Categories/FunWithFlags/Revealing-Predicates-in-Execution-Plans-(TF-9130).aspx +Link: http://www.theboreddba.com/Categories/FunWithFlags/Revealing-Predicates-in-Execution-Plans-(TF-9130).aspx
+Link: https://sqlperformance.com/2016/06/sql-indexes/actual-rows-read-warnings-plan-explorer
+Scope: global or session or query #### Trace Flag: 9134 Function: SQL 8 - Does additional reads to test if the page is allocated & linked correctly this checks IAM & PFS. Fixes error 601 for queries under Isolation level read uncommitted. In case performance is affected (because of a bug) apply SP4.
-Link: https://support.microsoft.com/en-us/help/815008/fix-query-with-transaction-isolation-level-set-to-read-uncommitted-fails-with-error-601 +Link: https://support.microsoft.com/kb/815008 @@ -3696,6 +4717,38 @@ Function: “PRB: You receive error message 8623 when you try to run a query tha Link: None + +#### Trace Flag: 9164 +**Undocumented trace flag**
+Function: Disables HM (hash joins).
+Link: [New Undocumented Trace Flags]
+Scope: ? + + + +#### Trace Flag: 9165 +**Undocumented trace flag**
+Function: Disable NL join and remove an index recommendation from a plan.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + + +#### Trace Flag: 9182 +**Undocumented trace flag**
+Function: Resulted in a very strange cost change to a clustered index delete.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + + +#### Trace Flag: 9183 +**Undocumented trace flag**
+Function: Resulted in a very strange cost change to a clustered index delete.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + #### Trace Flag: 9185 Function: Cardinality estimates for literals that are outside the @@ -3704,10 +4757,21 @@ Link: None Related to: [9205](#9205) + +#### Trace Flag: 9198 +**Undocumented trace flag**
+Function: Ccan be used to disable lazy index performance spools specifically. +You may still get a lazy table or row count spool instead (with or without sort optimization), depending on costing.
+Link: [Nested Loops Joins and Performance Spools]
+Scope: ? + #### Trace Flag: 9204 Function: Output Statistics used by Query Optimizer. When enabled and a plan is compiled or recompiled there is a listing of statistics which is being fully loaded & used to produce cardinality and distribution estimates for some plan alternative or other.
Link: [How to Find the Statistics Used to Compile an Execution Plan]
+Link: http://www.sqlservergeeks.com/sql-server-trace-flag-9204/
+Link: https://www.sqlpassion.at/archive/2013/10/29/fixing-cardinality-estimation-errors-with-filtered-statistics/
+Scope: global or query Related to: [9292](#9292) @@ -3736,6 +4800,22 @@ Function: “FIX: A query filter condition that has a LEFT OUTER JOIN clause may Link: None + +#### Trace Flag: 9236 +**Undocumented trace flag**
+Function: Resulted in a different join order for some queries. Full effect unknown.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + + +#### Trace Flag: 9251 +**Undocumented trace flag**
+Function: Change in cardinality estimates for some queries. It might only work with the legacy CE. Full effect unknown.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + #### Trace Flag: 9259 Function: Disables Project Normalization step
@@ -3743,6 +4823,23 @@ Function: Disables Project Normalization step
Link: http://www.queryprocessor.com/sudf-ce/ + +#### Trace Flag: 9260 +**Undocumented trace flag**
+Function: Adds an explicit sort before creation of an index spool. Almost doesn’t change the total estimated cost. Might be identical plans with just more detail shown at that step.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + + +#### Trace Flag: 9265 +**Undocumented trace flag**
+Function: MS engineering team has decided to generate a DUMP from SQL 2019+ every time a “PLAN cannot be generated”. Once a Dump freezes connections during the generation, the cluster will probably lost the connectivity to the cluster and the AG can be down/failover if it has automatic failover configured. The mitigation for this issue (avoid DUMP generation) is to enable TF Trace Flag 9265 on Startup. +Once TF 9265 is enabled, SQL Server stops generating DUMP on the “PLAN cannot be generated” error but only writes a message to ERRORLOG file (Internal Query Processor Error: The query processor could not produce a query plan. For more information, contact Customer Support Services). +
+Link: None + + #### Trace Flag: 9268 Function: SQL 8 - When SQL Server runs a parameterized query that contains several IN clauses, each with a large number of values, SQL Server may return the following error message after a minute or more of high CPU utilization: KB 325658. Server: Msg 8623, Level 16, State 1. Internal Query Processor Error: The query processor could not produce a query plan. Contact your primary support provider for more information.
@@ -3755,34 +4852,68 @@ Function: “FIX: A DML Operation on a Large Table Can Cause Performance Problem Link: None + +#### Trace Flag: 9284 +**Undocumented trace flag**
+Function: Changed the order of a scalar operator comparison in a single join for certain queries. Full effect unknown.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + + +#### Trace Flag: 9287 +**Undocumented trace flag**
+Function: Appears to disable partial aggreation.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + + +#### Trace Flag: 9288 +**Undocumented trace flag**
+Function: Effects around local and global aggregates - choose coerce partial and global aggregation over scalar aggregation.
+Link: https://github.com/ktaranov/sqlserver-kit/issues/93
+Scope: session only + + #### Trace Flag: 9292 Function: Output Statistics considered to be used by Query Optimizer
Link: [How to Find the Statistics Used to Compile an Execution Plan]
+Link: http://www.sqlservergeeks.com/sql-server-trace-flag-9292/
+Scope: session only Related to: [9204](#9204) - -#### Trace Flag: 9288 + +#### Trace Flag: 9341 **Undocumented trace flag**
-Function: Effects around local and global aggregates - choose coerce partial and global aggregation over scalar aggregation.
-Link: https://github.com/ktaranov/sqlserver-kit/issues/93
-Scope: local only +Function: Resulted in a rather odd plan for a COUNT(DISTINCT) query against a CCI.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + + +#### Trace Flag: 9346 +**Undocumented trace flag**
+Function: Appears to disable batch mode window aggregates.
+Link: [New Undocumented Trace Flags]
+Scope: ? #### Trace Flag: 9347 Function: Disables batch mode for sort operator. SQL Server 2016 introduces a new batch mode sort operator that boosts performance for many analytical queries.
-Link: https://support.microsoft.com/en-us/kb/3172787
+Link: https://support.microsoft.com/kb/3172787
Link: [Docs Trace Flags]
Link: [Niko Neugebauer Columnstore Indexes – part 86]
-Scope: global only +Scope: global or session or query #### Trace Flag: 9348 Function: Sets a row limit (based on cardinality estimates) that controls whether a bulk insert is attempted or not (assuming conditions are met for a bulk insert). Introduced as a workaround for memory errors encountered with bulk insert.
-Link: https://support.microsoft.com/en-us/help/2998301/fix-error-8654-when-you-run-insert-into-select-on-a-table-with-clustered-columnstore-index-in-sql-server-2014 +Link: https://support.microsoft.com/kb/2998301 @@ -3790,7 +4921,7 @@ Link: https://support.microsoft.com/en-us/help/2998301/fix-error-8654-when-you-r Function: Disables batch mode for top N sort operator. SQL Server 2016 introduces a new batch mode top sort operator that boosts performance for many analytical queries.
Link: [Docs Trace Flags]
Link: [Niko Neugebauer Columnstore Indexes – part 86]
-Link: https://support.microsoft.com/en-us/kb/3172787
+Link: https://support.microsoft.com/kb/3172787
Scope: global or session or query @@ -3818,30 +4949,121 @@ set statistics xml, time off; #### Trace Flag: 9358 Function: Disable batch mode sort operations in a complex parallel query. For example, this flag could apply if the query contains merge join operations.
Link: [Niko Neugebauer Columnstore Indexes – part 86]
-Link: https://support.microsoft.com/en-us/kb/3171555 +Link: https://support.microsoft.com/kb/3171555
+Scope: global or session or query + + + +#### Trace Flag: 9384 +**Undocumented trace flag**
+Function: Very slightly changed the memory grant of a query with a batch mode window aggregate.
+Link: [New Undocumented Trace Flags]
+Scope: ? #### Trace Flag: 9389 -Function: Enables dynamic memory grant for batch mode operators. If a query does not get all the memory it needs, it spills data to tempdb, incurring additional I/O and potentially impacting query performance. -If the dynamic memory grant trace flag is enabled, a batch mode operator may ask for additional memory and avoid spilling to tempdb if additional memory is available.
+Function: Enables additional dynamic memory grant for batch mode operators. +If a query does not get all the memory it needs, it spills data to TempDB, incurring additional I/O and potentially impacting query performance. +If the dynamic memory grant trace flag is enabled, a batch mode operator may ask for additional memory and avoid spilling to TempDB if additional memory is available. +For more information, see the *Effects of min memory per query* section of the [Memory Management Architecture Guide](https://docs.microsoft.com/en-us/sql/relational-databases/memory-management-architecture-guide?view=sql-server-2017#effects-of-min-memory-per-query).
Link: [Niko Neugebauer Columnstore Indexes – part 86]
Link: [Docs Trace Flags]
Scope: global or session + +#### Trace Flag: 9390 +**Undocumented trace flag**
+Function: Resulted in plan changes including parallelism for queries that shouldn’t have been eligible for parallelism based on CTFP. Full effect unknown.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + #### Trace Flag: 9394 Function: Apparently enables a fix for an access violation when a table with Japanese characters has an indexed changed.
-Link: https://support.microsoft.com/en-us/help/3142595/fix-an-access-violation-occurs-when-a-database-table-name-contains-japanese-characters-in-sql-server-2012-or-sql-server-2014
-Link: https://support.microsoft.com/en-us/help/3138659/fix-slow-performance-when-you-query-numeric-data-types-from-an-oracle-database +Link: https://support.microsoft.com/kb/3142595
+Link: https://support.microsoft.com/kb/3138659 + + + +#### Trace Flag: 9398 +**Undocumented trace flag**
+Function: Disable adaptive join.
+Link: [SQL Server 2017: Adaptive Join Internals]
+Scope: ? + + + +#### Trace Flag: 9399 +**Undocumented trace flag**
+Function: Optimization adaptive threshold rows. The adaptive threshold to the minimum estimate.
+Link: [SQL Server 2017: Adaptive Join Internals]
+Scope: ? + + + +#### Trace Flag: 9410 +**Undocumented trace flag**
+Function: Fix slowly query runs when SQL Server uses hash aggregate in the query plan.
+Link: https://support.microsoft.com/kb/3167159
+Scope: ? + + + +#### Trace Flag: 9412 +**Undocumented trace flag**
+Function: Removes the new OptimizerStatsUsage information from estimated query plans.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + + +#### Trace Flag: 9415 +**Undocumented trace flag**
+Function: Optimization adaptive join internals.
+Link: [SQL Server 2017: Adaptive Join Internals]
+Scope: ? + + + +#### Trace Flag: 9424 +**Undocumented trace flag**
+Function: Sets the number of splits to four. +The SQL Server 2019 query optimizer has a new trick available to improve the performance of large aggregations. +The new exploration abilities are encoded in two new closely-related optimizer rules: `GbAggSplitToRanges` and `SelOnGbAggSplitToRanges`. +The extended event `query_optimizer_batch_mode_agg_split is` provided to track when this new optimization is considered. +The description of this event is: Occurs when the query optimizer detects batch mode aggregation is likely to spill and tries to split it into multiple smaller aggregations.
+Link: [SQL Server 2019 Aggregate Splitting]
+Scope: session or query + + + +#### Trace Flag: 9426 +**Undocumented trace flag**
+Function: Disables the aggregate splitting feature. +The SQL Server 2019 query optimizer has a new trick available to improve the performance of large aggregations. +The new exploration abilities are encoded in two new closely-related optimizer rules: `GbAggSplitToRanges` and `SelOnGbAggSplitToRanges`. +The extended event `query_optimizer_batch_mode_agg_split is` provided to track when this new optimization is considered. +The description of this event is: Occurs when the query optimizer detects batch mode aggregation is likely to spill and tries to split it into multiple smaller aggregations.
+Link: [SQL Server 2019 Aggregate Splitting]
+Scope: session or query + + + +#### Trace Flag: 9447 +**Undocumented trace flag**
+Function: Forces query plans to use the new referential integrity operator when validating UPDATE and DELETE queries against foreign key parent tables.
+Link: [New Undocumented Trace Flags]
+Scope: ? #### Trace Flag: 9448 **Undocumented trace flag**
Function: Disables the referential integrity operator.
-Link: https://orderbyselectnull.com/2017/12/05/the-referential-integrity-operator/
+Link: https://orderbyselectnull.com/2017/12/05/the-referential-integrity-operator/ @@ -3855,19 +5077,42 @@ Link: [What You Need to Know about the Batch Mode Window Aggregate Operator in S #### Trace Flag: 9471 -Function: Causes SQL Server to generate a plan using minimum selectivity for single-table filters, under the query optimizer cardinality estimation model of SQL Server 2014 through SQL Server 2016 versions. -Beginning with SQL Server 2016 SP1, to accomplish this at the query level, add the USE HINT query hint instead of using this trace flag.
+Function: Causes SQL Server to generate a plan using minimum selectivity for single-table filters, under the query optimizer cardinality estimation model of SQL Server 2014 (12.x) and later versions. +Starting with SQL Server 2016 (13.x) SP1, to accomplish this at the query level, add the USE HINT 'ASSUME_MIN_SELECTIVITY_FOR_FILTER_ESTIMATES' query hint instead of using this trace flag.
**Note: Please ensure that you thoroughly test this option, before rolling it into a production environment.**
+**Note: This trace flag does not apply to CE version 70. Use trace flag [4137](#4137) instead.**
Link: [New Features in SQL Server 2016 Service Pack 1]
Link: [Docs Trace Flags]
+Link: [Cardinality Estimation for Multiple Predicates]
Scope: global or session or query #### Trace Flag: 9472 -Function: Assumes independence for multiple WHERE predicates in the SQL 2014 cardinality estimation model. Predicate independence was the default for versions prior to SQL Server 2014, and thus this flag can be used to more closely emulate pre-SQL 2014 cardinality estimate behavior in a more specific fashion than TF 9481.
+**Undocumented trace flag**
+Function: Assumes independence for multiple WHERE predicates in the SQL 2014 cardinality estimation model. +Predicate independence was the default for versions prior to SQL Server 2014, and thus this flag can be used to more closely emulate pre-SQL 2014 cardinality estimate behavior in a more specific fashion than TF 9481.
Link: https://sqlperformance.com/2014/01/sql-plan/cardinality-estimation-for-multiple-predicates
-Link: https://connect.microsoft.com/SQLServer/feedback/details/801908/sql-server-2014-cardinality-estimation-regression +Link: https://connect.microsoft.com/SQLServer/feedback/details/801908/sql-server-2014-cardinality-estimation-regression
+Link: [Cardinality Estimation for Multiple Predicates]
+Scope: global or session or query + + + +#### Trace Flag: 9473 +**Undocumented trace flag**
+Function: Allowing the outer join to keep a zero-row inner-side estimate (instead of raising to one row) (so all outer rows qualify) gives a 'bug-free' join estimation with either calculator. +If you're interested in exploring this, the undocumented trace flag is 9473 (alone).
+Link: https://dba.stackexchange.com/a/141533/107045
+Scope: ? + + + +#### Trace Flag: 9474 +**Undocumented trace flag**
+Function: Change in cardinality estimates for some joins in certain queries. Full effect unknown.
+Link: [New Undocumented Trace Flags]
+Scope: ? @@ -3875,26 +5120,64 @@ Link: https://connect.microsoft.com/SQLServer/feedback/details/801908/sql-server Function: Causes SQL Server to generate a plan using the Simple Containment assumption instead of the default Base Containment assumption, under the query optimizer cardinality estimation model of SQL Server 2014 through SQL Server 2016 versions. Beginning with SQL Server 2016 SP1, to accomplish this at the query level, add the USE HINT query hint instead of using this trace flag. **Note: Please ensure that you thoroughly test this option, before rolling it into a production environment.**
-Link: https://support.microsoft.com/en-us/kb/3189675
+Link: https://support.microsoft.com/kb/3189675
Link: [New Features in SQL Server 2016 Service Pack 1]
Link: [Docs Trace Flags]
Scope: global or session or query + +#### Trace Flag: 9477 +**Undocumented trace flag**
+Function: Slight change in ratio of EstimateRebinds and EstimateRewinds was observed. Full effect unknown.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + + +#### Trace Flag: 9478 +**Undocumented trace flag**
+Function: Change in cardinality estimates for some joins in certain queries. Full effect unknown.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + + +#### Trace Flag: 9479 +**Undocumented trace flag**
+Function: Forces the optimizer to use Simple Join [estimation] even if a histogram is available. +Will force optimizer to use a simple join estimation algorithm, it may be CSelCalcSimpleJoinWithDistinctCounts, CSelCalcSimpleJoin or CSelCalcSimpleJoinWithUpperBound, depending on the compatibility level and predicate comparison type.
+Link: [Statistics and Cardinality Estimation]
+Scope: ? + + + +#### Trace Flag: 9480 +**Undocumented trace flag**
+Function: Reduced the selectivity of a bitmap filter from 0.001 to 0.000001. Full effect unknown.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + #### Trace Flag: 9481 Function: Enables you to set the query optimizer cardinality estimation model to the SQL Server 2012 and earlier version independent of the compatibility level of the database. -To accomplish this at the database level, see [ALTER DATABASE SCOPED CONFIGURATION (Transact-SQL)](https://msdn.microsoft.com/en-us/library/mt629158.aspx). -To accomplish this at the query level, add the QUERYTRACEON query hint
+To accomplish this at the database level, see [ALTER DATABASE SCOPED CONFIGURATION (Transact-SQL)]. +To accomplish this at the query level, add the QUERYTRACEON query hint.
Link: [New Features in SQL Server 2016 Service Pack 1]
Link: https://sqlserverscotsman.wordpress.com/2016/11/28/a-guide-on-forcing-the-legacy-ce/
Link: [Docs Trace Flags]
Link: [KB2801413]
+Link: http://www.sqlservergeeks.com/sql-server-2014-trace-flags-9481/
+Link: https://sqlperformance.com/2019/01/sql-performance/compatibility-levels-and-cardinality-estimation-primer
+Link: [KB2801413]
+Link: [Cardinality Estimation for Multiple Predicates]
Scope: global or session or query #### Trace Flag: 9482 +**Undocumented trace flag**
Function: Implements a “model variation” in the SQL 2014 cardinality estimator. The flag turns off the “overpopulated primary key” adjustment that the optimizer might use when determining that a “dimension” table (the schema could be OLTP as well) has many more distinct values than the “fact” table. (The seminal example is where a Date dimension is populated out into the future, but the fact table only has rows up to the current date). Since join cardinality estimation occurs based on the contents of the histograms of the joined columns, an “overpopulated primary key” can result in higher selectivity estimates, causing rowcount estimates to be too low.
@@ -3903,16 +5186,25 @@ Link: http://www.queryprocessor.com/ce_opk #### Trace Flag: 9483 +**Undocumented trace flag**
Function: Implements a “model variation” in the SQL 2014 cardinality estimator. The flag will force the optimizer to create (if possible) a filtered statistics object based on a predicate in the query. This filtered stat object is not persisted and thus would be extremely resource intensive for frequent compilations. In Dima’s example, the filtered stat object is actually created on the join column...i.e. “CREATE STATISTICS [filtered stat obj] ON [table] (Join column) WHERE (predicate column = ‘literal’)”
Link: http://www.queryprocessor.com/ce_filteredstats + +#### Trace Flag: 9484 +**Undocumented trace flag**
+Function: Slight change in estimated number of rewinds. Full effect unknown.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + #### Trace Flag: 9485 Function: Disables SELECT permission for DBCC SHOW\_STATISTICS
-Link: https://support.microsoft.com/en-us/kb/2683304
+Link: https://support.microsoft.com/kb/2683304
Link: [Docs Trace Flags]
Link: http://www.benjaminnevarez.com/2013/02/dbcc-show_statistics-works-with-select-permission
Scope: global only @@ -3920,24 +5212,52 @@ Scope: global only #### Trace Flag: 9488 +**Undocumented trace flag**
Function: Implements a “model variation” in the SQL 2014 cardinality estimator. This flag reverts the estimation behavior for multi-statement TVFs back to 1 row (instead of the 100-row estimate behavior that was adopted in SQL 2014).
Link: http://www.queryprocessor.com/ce_mtvf #### Trace Flag: 9489 +**Undocumented trace flag**
Function: Implements a “model variation” in the SQL 2014 cardinality estimator and turns off the new logic that handles ascending keys.
Link: http://www.queryprocessor.com/ce_asckey + +#### Trace Flag: 9490 +**Undocumented trace flag**
+Function: Change in cardinality estimate. Full effect unknown.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + + +#### Trace Flag: 9494 +**Undocumented trace flag**
+Function: The behaviour of the join cardinality estimation with CSelCalcExpressionComparedToExpression can also be modified to not account for ``bId` with another undocumented variation flag (9494)
+Link: https://dba.stackexchange.com/a/141533/107045
+Scope: ? + + #### Trace Flag: 9495 Function: Disables parallelism during insertion for INSERT...SELECT operations and it applies to both user and temporary tables
-Link: https://support.microsoft.com/en-us/kb/3180087
+Link: https://support.microsoft.com/kb/3180087
Link: [Docs Trace Flags]
Scope: global or session + +#### Trace Flag: 9497 +**Undocumented trace flag**
+Function: For SQL Server versions where the behaviour previously enabled under TF [2371](#2371) is the default, start-up trace flag 9497 reverts to the original behaviour for the statistics update recompilation threshold. +The formula to compute RT (Recompilation Thresholds) values is different when trace flag [2371](#2371) is enabled (or for versions and compatibility settings where the sublinear behaviour is default (if trace flag 9497 is off)). +The new formula for RT is SQRT(1000 * table rows).
+Link: [Temporary Table Caching in Stored Procedures]
+Scope: global only + + #### Trace Flag: 9532 Function: SQL 11 CTP3 - to get more than 1 availability group replica in CTP3 Scope Startup
@@ -3946,6 +5266,7 @@ Link: http://connect.microsoft.com/SQLServer/feedback/details/682581/denali-hadr #### Trace Flag: 9559 +**Undocumented trace flag**
Function: For AGs, “when enabled on the secondary ignores the redo target provided from the primary progress message and always set the redo target at the Max LSN value.”
Link: https://blogs.msdn.microsoft.com/alwaysonpro/2013/12/04/recovery-on-secondary-lagging-shared-redo-target @@ -3957,10 +5278,25 @@ Compression can significantly reduce the transfer time during automatic seeding Link: [Docs Trace Flags]
Link: https://www.mssqltips.com/sqlservertip/4537/sql-server-2016-availability-group-automatic-seeding/
Link: https://msdn.microsoft.com/en-us/library/mt735149.aspx
-Link: [MSDN mt736907]
+Link: [Tune compression for availability group]
+Scope: global or session + + + +#### Trace Flag: 9571 +Function: Disables Availability Groups Auto seeding to the default database path.
+Link: https://docs.microsoft.com/en-us/sql/database-engine/availability-groups/windows/automatic-seeding-secondary-replicas
Scope: global or session + +#### Trace Flag: 9576 +Function: Revert to the original (SQL Server 2016) implementation of database level health detection using TF 9576 as either a startup parameter or enabled using DBCC TRACEON command. +This new implementation is currently only available for SQL Server running on Windows and will be ported to SQL Server 2017 on Linux in an upcoming cumulative update.
+Link: https://blogs.msdn.microsoft.com/sql_server_team/sql-server-availability-groups-enhanced-database-level-failover/
+Scope: global only + + #### Trace Flag: 9591 Function: Disables log block compression in Always On Availability Groups. @@ -3975,30 +5311,34 @@ Scope: global or session Function: Enables log stream compression for synchronous availability groups. This feature is disabled by default on synchronous availability groups because compression adds latency.
Link: [Docs Trace Flags]
-Link: [MSDN mt736907]
+Link: [Tune compression for availability group]
Scope: global or session #### Trace Flag: 9706 +**Undocumented trace flag**
Function: Software Usage Metrics is disabled.
Link: [Bad Idea Jeans: Finding Undocumented Trace Flags] #### Trace Flag: 9806 +**Undocumented trace flag**
Function: Unknown. Is turned on on SQL Server 2014 CTP1 standard installation in Windows Azure VM
Link: None #### Trace Flag: 9807 +**Undocumented trace flag**
Function: Unknown. Is turned on on SQL Server 2014 CTP1 standard installation in Windows Azure VM
Link: None #### Trace Flag: 9808 +**Undocumented trace flag**
Function: Unknown. Is turned on on SQL Server 2014 CTP1 standard installation in Windows Azure VM
Link: None @@ -4014,6 +5354,7 @@ Link: https://web.archive.org/web/20160327221828/http://speedysql.com/2015/10/28 #### Trace Flag: 9837 +**Undocumented trace flag**
Function: According to Bob Ward’s PASS 2014 talk on SQL Server IO, enables “extra tracing but massive output” for Hekaton checkpoint files.
Link: None @@ -4036,27 +5377,35 @@ Link: http://gsl.azurewebsites.net/Portals/0/Users/dewitt/talks/HekatonWhitePape #### Trace Flag: 9929 -Function: Enables an update that reduces the “disk footprint [of In-Memory OLTP] by reducing the In-Memory checkpoint files to 1 MB (megabytes) each.”
-Link: https://support.microsoft.com/en-us/help/3147012/fix-large-disk-checkpoint-usage-occurs-for-an-in-memory-optimized-filegroup-during-heavy-non-in-memory-workloads +Function: Enables an update that reduces the “disk footprint [of In-Memory OLTP] by reducing the In-Memory checkpoint files to 1 MB (megabytes) each.” + Because this traceflag is instance level, it affects the size of checkpoint files for all databases with a memory optimized filegroup on that instance. + Be cautious when you use this traceflag.
+Link: https://support.microsoft.com/kb/3147012/ +Scope: global or session #### Trace Flag: 9939 Function: Disables merge/recompress during columnstore index reorganization. -In SQL Server 2016, when a columnstore index is reorganized, there is new functionality to automatically merge any small compressed rowgroups into larger compressed rowgroups, as well as recompressing any rowgroups that have a large number of deleted rows. -**Note: Trace flag 10204 does not apply to columnstore indexes which are created on memory-optimized tables.** -Link: [Docs Trace Flags] +In SQL Server 2016, when a columnstore index is reorganized, there is new functionality to automatically merge any small compressed rowgroups into larger compressed rowgroups, as well as recompressing any rowgroups that have a large number of deleted rows.
+**Note: Trace flag 10204 does not apply to columnstore indexes which are created on memory-optimized tables.**
+Link: [Docs Trace Flags]
+Link: [Parallelism in Hekaton (In-Memory OLTP)] Scope: global or session + #### Trace Flag: 9989 +**Undocumented trace flag**
Function: In CTP2, enabled functionality for reading in-memory tables on a readable secondary
Link: https://connect.microsoft.com/SQLServer/feedback/details/795360/secondary-db-gets-suspect-when-i-add-in-memory-table-to-db-which-is-part-of-alwayson-availability-group #### Trace Flag: 10202 -Function: According to demo scripts from a Sunil Agarwal session at PASS 2014, enables a new DMV named sys.dm_db_column_store_row_group_physical_stats. This DMV is not in SQL 2014 RTM and Sunil did not perform this demo during the session, so this DMV appears to be in a future (or internal) version of SQL Server.
+**Undocumented trace flag**
+Function: According to demo scripts from a Sunil Agarwal session at PASS 2014, enables a new DMV named sys.dm_db_column_store_row_group_physical_stats. +This DMV is not in SQL 2014 RTM and Sunil did not perform this demo during the session, so this DMV appears to be in a future (or internal) version of SQL Server.
Link: None @@ -4067,21 +5416,23 @@ In SQL Server 2016, when a columnstore index is reorganized, there is new functi into larger compressed rowgroups, as well as recompressing any rowgroups that have a large number of deleted rows.
**Note: Trace flag 10204 does not apply to column store indexes which are created on memory-optimized tables.**
Link: [Docs Trace Flags]
-Scope: global or session +Link: [Niko Neugebauer Columnstore Indexes – part 86]
+Scope: global or session or query #### Trace Flag: 10207 Function: When a Clustered Columnstore index has corrupted segments, turning on this flag suppresses errors 5288 and 5289 and allows a scan of a clustered columns store to skip corrupt segments and complete (though with results that do not include the corrupted segment(s)). This flag is helpful when attempting to copy-out data in a corrupt CCI.
-Link: https://support.microsoft.com/en-us/help/3067257/fix-partial-results-in-a-query-of-a-clustered-columnstore-index-in-sql-server-2014
+Link: https://support.microsoft.com/kb/3067257/
Link: https://blogs.msdn.microsoft.com/sqlreleaseservices/partial-results-in-a-query-of-a-clustered-columnstore-index-in-sql-server-2014 #### Trace Flag: 10213 +**Undocumented trace flag**
Function: Enables the option to configure compression delay in columnstore indexes in SQL Server 2016
Link: http://www.nikoport.com/2016/02/04/columnstore-indexes-part-76-compression-delay/
-Scope: session +Scope: session only @@ -4099,15 +5450,31 @@ If you have specific query pattern that includes columns which are not covered b Please be aware that creating additional indexes may introduce overhead for DML operations that update or delete rows in the current table. With the additional indexes you should aim to find the right balance between performance of temporal queries and additional DML overhead.**
Link: [Docs Trace Flags]
-Link: https://support.microsoft.com/en-us/kb/3198846
+Link: https://support.microsoft.com/kb/3198846
Link: https://blogs.msdn.microsoft.com/sqlcat/2016/12/08/improve-query-performance-on-memory-optimized-tables-with-temporal-using-new-index-creation-enhancement-in-sp1/
Scope: global or session + +#### Trace Flag: 10809 +**Undocumented trace flag**
+Function: Force stream Aggregates for scalar aggregation in batch mode.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + + +#### Trace Flag: 11001 +**Undocumented trace flag**
+Function: Results in a different join order for some queries. Full effect unknown.
+Link: [New Undocumented Trace Flags]
+Scope: ? + + #### Trace Flag: 11023 Function: Disables the use of the last persisted sample rate, for all subsequent statistics update where a sample rate is not specified explicitly as part of the [UPDATE STATISTICS](https://docs.microsoft.com/en-us/sql/t-sql/statements/update-statistics-transact-sql) statement.
-Link: http://support.microsoft.com/kb/4039284
+Link: https://support.microsoft.com/kb/4039284
Link: [Docs Trace Flags]
Scope: global or session @@ -4115,46 +5482,270 @@ Scope: global or session #### Trace Flag: 11024 Function: In Microsoft SQL Server 2017, when incremental statistics are built on the top of partitioned tables, the sum of modification counts of all partitions is stored as the modification count of the root node. -When the modification count of the root node exceeds a threshold, the auto update of statistics is triggered. +When the modification count of the root node exceeds a [threshold](https://docs.microsoft.com/en-us/sql/relational-databases/statistics/statistics#AutoUpdateStats), the auto update of statistics is triggered. However, if the modification count of any single partition does not exceed the local threshold, the statistics are not updated. Additionally, the modification count of the root node is reset to zero. This may cause delay in the auto update of incremental statistics. When trace flag 11024 is enabled, the modification count of the root node is kept as the sum of modification counts of all partitions.
-**Note: This trace flag applies to SQL Server 2017 CU3 and higher builds.**
-Link: http://support.microsoft.com/en-us/kb/4041811
-Scope: global or session +**Note: This trace flag applies to SQL Server 2016 (13.x) SP2, SQL Server 2017 (14.x) CU3, and higher builds.**
+Link: https://support.microsoft.com/kb/4041811
+Link: [Docs Trace Flags]
+Scope: global or session
+SQL Server Version: >= 2019 RTM, >= 2017 CU3, >= 2016 SP2 + + + +#### Trace Flag: 11029 +**Undocumented trace flag**
+Function: Prevents new information about row goals from getting logged to the plan cache.
+Link: [New Undocumented Trace Flags]
+Scope: ? + +#### Trace Flag: 11047 +Function: Applies the default timeout set by `query wait (s)` or the Resource Governor `REQUEST_MEMORY_GRANT_TIMEOUT_SEC` configuration to Columnstore index build operations.
+**Note: This trace flag applies to SQL Server 2016 (13.x) SP2 CU5, SQL Server 2017 (14.x) CU14, and higher builds.**
+Link: [Docs Trace Flags]
+Link: https://support.microsoft.com/kb/4480641
+Scope: global or session
+SQL Server Version: >= 2019 RTM, >= 2017 CU14, >= 2016 SP2 CU5 + + + +#### Trace Flag: 11064 +Function: Improves the scalability of data loading operations into columnstore indexes, by optimizing memory distribution between the `SELECT` and `INSERT` statements.
+For more information on loading data into a columnstore index, see [Columnstore indexes - Data loading guidance](https://docs.microsoft.com/en-gb/sql/relational-databases/indexes/columnstore-indexes-data-loading-guidance). +**Note: This trace flag applies to SQL Server 2019 (15.x) and higher builds.**
+Link: [Docs Trace Flags]
+Link: https://support.microsoft.com/en-us/topic/kb4588980-fix-higher-than-expected-number-of-single-row-columnstore-rowgroups-may-be-generated-for-columnstore-bulk-insert-when-both-large-page-allocator-and-scalable-columnstore-bulk-insert-features-are-turned-on-0d74afa4-96e7-2026-b486-122d2619554a - if you turn on trace flags 876, 11064, and 11068, SQL Server may generate single row columnstore rowgroups. Fixed in 2019 CU9.
+Scope: global only
+SQL Server Version: >= 2019 RTM + + + +#### Trace Flag: 11068 +Function: Uses the configured max degree of parallelism (MAXDOP) value for columnstore index insert operations. +For more information on overriding degrees of parallelism, see the [Query Processing Architecture Guide](https://docs.microsoft.com/en-gb/sql/relational-databases/query-processing-architecture-guide#overriding-degrees-of-parallelism).
+**Important: This trace flag is only effective if trace flag [11064](#11064) is also enabled.**
+**Important: Use this trace flag when faster data loads are preferred over maintaining [columnstore segment](https://docs.microsoft.com/en-gb/sql/relational-databases/indexes/columnstore-indexes-overview#column-segment) quality. +For example, using this trace flag when loading 1,048,577 rows into a columnstore may result in more than one compressed rowgroup, if the insert operation is executing in parallel mode. +Without this trace flag, the insert operation would result in one compressed rowgroup.**
+**Note: This trace flag applies to SQL Server 2019 (15.x) and higher builds.**
+Link: [Docs Trace Flags]
+Link: https://support.microsoft.com/en-us/topic/kb4588980-fix-higher-than-expected-number-of-single-row-columnstore-rowgroups-may-be-generated-for-columnstore-bulk-insert-when-both-large-page-allocator-and-scalable-columnstore-bulk-insert-features-are-turned-on-0d74afa4-96e7-2026-b486-122d2619554a - if you turn on trace flags [876](#876), [11064](#11064), and [11068](#11068), SQL Server may generate single row columnstore rowgroups. Fixed in 2019 CU9.
+Scope: global only
+SQL Server Version: >= 2019 RTM + + + +#### Trace Flag: 11631 +Function: When reorganizing a columnstore index, use a threshold of 10% of the actual number of rows in the rowgroup. By default, without this trace flag, SQL Server uses 10% of a theoretical max of ~1M rows in the rowgroup, 100K rows, which meant that small rowgroups would never get reorganized. +**Note: This trace flag applies to SQL Server 2019 CU9 (15.x) and higher builds.**
+Link: https://techcommunity.microsoft.com/t5/sql-server-support/new-trace-flags-for-better-maintenance-of-deleted-rows-in/ba-p/2127034 +Link: [Docs Trace Flags]
+Scope: global only
+SQL Server Version: >= 2019 CU9 + + + +#### Trace Flag: 11634 +Function: When reorganizing a columnstore index, use a threshold of 1% of the rows in the rowgroup rather than the default of 10%. Keep in mind that unless you also enable trace flag [11631](#11631), then it's 1% of the theoretical maximum number of rows in the rowgroup (~1M) rather than the actual number of rows in the rowgroup. Use both [11631](#11631) and 11634 trace flags together for the most accurate thresholds of when to rebuild a rowgroup. +**Note: This trace flag applies to SQL Server 2019 CU9 (15.x) and higher builds.**
+Link: https://techcommunity.microsoft.com/t5/sql-server-support/new-trace-flags-for-better-maintenance-of-deleted-rows-in/ba-p/2127034 +Link: [Docs Trace Flags]
+Scope: global only
+SQL Server Version: >= 2019 CU9 + + + +#### Trace Flag: 12306 +Function: Enable setting maximum [group commit time](https://www.sqlshack.com/sql-server-wait-type-hadr-group-commit/). This TF can be enabled during SQL Server startup or dynamically (through `DBCC TRACEON(12306, -1)`).
+After TF 12306 is enabled, you can further enable 12311, 12312, 12314, 12318. These represent maximum group commit times of 1ms, 2ms, 4ms, and 8ms, respectively. They settings are additive. The maximum group commit time setting is capped at 10ms. However, these should not be repeated. For example, do not specify the same TF more than one time.
+If you do not want to set maximum group commit time but want, instead, to revert to the default behavior of 10ms, disable TF 12306. +The effect of TFs 12311, 12312, 12314, and 12318 occurs when there is a checkpoint in the database. You can rely on the setting of SQL Server or the database to let the checkpoint automatically occur. If you want to let the TFs take effect immediately, you can issue a manual checkpoint. +In the SQL Server error log, you can see entries about this actions.
+Link: [KB4565944]
+Link: https://aboutsqlserver.com/2019/06/09/hadr-sync-commit/
+Scope: global or session
+SQL Server Version: >= 2019 CU9, >= 2017 CU21 + + + +#### Trace Flag: 12311 +Function: After TF [12306](#12306) is enabled, you can further enable 12311 trace flag that represent maximum group commit times of **1ms**. This TF is additive whith [12312](#12312), [12314](#12314), and [12318](#12318). The maximum group commit time setting is capped at 10ms. However, these should not be repeated. For example, do not specify the same TF more than one time.
+If you do not want to set maximum group commit time but want, instead, to revert to the default behavior of 10ms, disable TF [12306](#12306). +The effect of TFs 12311, [12312](#12312), [12314](#12314), and [12318](#12318) occurs when there is a checkpoint in the database. You can rely on the setting of SQL Server or the database to let the checkpoint automatically occur. If you want to let the TFs take effect immediately, you can issue a manual checkpoint. +In the SQL Server error log, you can see entries about this actions.
+Link: [KB4565944]
+Link: https://aboutsqlserver.com/2019/06/09/hadr-sync-commit/
+Scope: global or session
+SQL Server Version: >= 2019 CU9, >= 2017 CU21 + + + +#### Trace Flag: 12312 +Function: After TF [12306](#12306) is enabled, you can further enable 12312 trace flag that represent maximum group commit times of **2ms**. This TF is additive whith [12311](#12311), [12314](#12314), and [12318](#12318). The maximum group commit time setting is capped at 10ms. However, these should not be repeated. For example, do not specify the same TF more than one time.
+If you do not want to set maximum group commit time but want, instead, to revert to the default behavior of 10ms, disable TF [12306](#12306). +The effect of TFs [12311](#12311), 12312, [12314](#12314), and [12318](#12318) occurs when there is a checkpoint in the database. You can rely on the setting of SQL Server or the database to let the checkpoint automatically occur. If you want to let the TFs take effect immediately, you can issue a manual checkpoint. +In the SQL Server error log, you can see entries about this actions.
+Link: [KB4565944]
+Link: https://aboutsqlserver.com/2019/06/09/hadr-sync-commit/
+Scope: global or session
+SQL Server Version: >= 2019 CU9, >= 2017 CU21 + + + +#### Trace Flag: 12314 +Function: After TF [12306](#12306) is enabled, you can further enable 12314 trace flag that represent maximum group commit times of **4ms**. This TF is additive whith [12311](#12311), [12312](#12312), and [12318](#12318). The maximum group commit time setting is capped at 10ms. However, these should not be repeated. For example, do not specify the same TF more than one time.
+If you do not want to set maximum group commit time but want, instead, to revert to the default behavior of 10ms, disable TF [12306](#12306). +The effect of TFs [12311](#12311), [12312](#12312), 12314, and [12318](#12318) occurs when there is a checkpoint in the database. You can rely on the setting of SQL Server or the database to let the checkpoint automatically occur. If you want to let the TFs take effect immediately, you can issue a manual checkpoint. +In the SQL Server error log, you can see entries about this actions.
+Link: [KB4565944]
+Link: https://aboutsqlserver.com/2019/06/09/hadr-sync-commit/
+Scope: global or session
+SQL Server Version: >= 2019 CU9, >= 2017 CU21 + + + +#### Trace Flag: 12318 +Function: After TF [12306](#12306) is enabled, you can further enable 12318 trace flag that represent maximum group commit times of **8ms**. This TF is additive whith [12311](#12311), [12312](#12312), and [12314](#12314). The maximum group commit time setting is capped at 10ms. However, these should not be repeated. For example, do not specify the same TF more than one time.
+If you do not want to set maximum group commit time but want, instead, to revert to the default behavior of 10ms, disable TF [12306](#12306). +The effect of TFs [12311](#12311), [12312](#12312), [12314](#12314), and 12318 occurs when there is a checkpoint in the database. You can rely on the setting of SQL Server or the database to let the checkpoint automatically occur. If you want to let the TFs take effect immediately, you can issue a manual checkpoint. +In the SQL Server error log, you can see entries about this actions.
+Link: [KB4565944]
+Link: https://aboutsqlserver.com/2019/06/09/hadr-sync-commit/
+Scope: global or session
+SQL Server Version: >= 2019 CU9, >= 2017 CU21 + + +### Trace Flag: 12502 +Function: Disables external authorization policies for on-premises SQL Server instances. +Use this flag when you see increased PREEMPTIVE_OS_QUERYREGISTRY waits to occur. Due to a bug a SQL Server might lookup Windows Registry values even for a simple queries which do not work with operating system at all. +Link: [Docs Trace Flags](https://docs.microsoft.com/sql/t-sql/database-console-commands/dbcc-traceon-trace-flags-transact-sql) +Link: [SQL Server 2022 CU5 Documentation](https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2022/cumulativeupdate5#2351584) +Scope: global
+SQL Server Version: >= 2022 CU5 + + +Note: In my case vast majority of queries executed against SQL Server started looking up non-existing registry value at: +`HKLM\Software\Microsoft\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQLServer\PurviewConfig` +so this buggy behavior might be triggered only after other software gets integrated with SQL Server 2022. + + + +#### Trace Flag: 12606 +Function: Enables Query Store for secondary replicas.
+Link: https://learn.microsoft.com/en-us/sql/relational-databases/performance/query-store-for-secondary-replicas?view=sql-server-ver16
+Scope: global
+SQL Server Version: >= 2022 + + + +#### Trace Flag: 12618 +Function: Introduces a new plan regression detection model for Automatic Plan Correction that includes multiple consecutive checks.
+Link: [SQL Server 2022 CU4 Documentation](https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2022/cumulativeupdate4#2344871)
+Scope: global
+SQL Server Version: >= 2022 CU4 + + + +#### Trace Flag: 12656 +Function: For Automatic Plan Correction, introduces the ability to use a time-based plan regression check that will occur five minutes after a plan change is discovered, which avoids biasing the regression checks by queries that execute quickly.
+Link: [SQL Server 2022 CU4 Documentation](https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2022/cumulativeupdate4#2344871)
+Scope: global
+SQL Server Version: >= 2022 CU4 + + +#### Trace Flag: 15915 +Function: Fixes a performance issue that you might encounter only when sp_lock is called frequently from multiple connections, which might cause a memory leak. The memory isn't cleaned up until you restart the SQL Server service. Added in SQL Server 2019 CU29.
+Link: [SQL Server 2019 CU29 Documentation](https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2019/cumulativeupdate29#3180085)
+SQL Server Version: >= 2019 CU29 + + + +[Docs Trace Flags]:https://docs.microsoft.com/sql/t-sql/database-console-commands/dbcc-traceon-trace-flags-transact-sql [Query Store Trace Flags]:https://www.sqlskills.com/blogs/erin/query-store-trace-flags/ -[Docs Trace Flags]:https://docs.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-traceon-trace-flags-transact-sql -[DBCC CHECKDB]:https://msdn.microsoft.com/en-us/library/ms176064.aspx -[DBCC CHECKTABLE]:https://msdn.microsoft.com/en-us/library/ms174338.aspx -[DBCC CHECKCONSTRAINTS]:https://msdn.microsoft.com/en-us/library/ms189496.aspx +[DBCC TRACEON]:https://docs.microsoft.com/sql/t-sql/database-console-commands/dbcc-traceon-transact-sql +[DBCC TRACEOFF]:https://docs.microsoft.com/sql/t-sql/database-console-commands/dbcc-traceoff-transact-sql +[DBCC TRACESTATUS]:https://docs.microsoft.com/sql/t-sql/database-console-commands/dbcc-tracestatus-transact-sql +[DBCC CHECKDB]:https://docs.microsoft.com/sql/t-sql/database-console-commands/dbcc-checkdb-transact-sql +[DBCC CHECKTABLE]:https://docs.microsoft.com/sql/t-sql/database-console-commands/dbcc-checktable-transact-sql +[DBCC CHECKCONSTRAINTS]:https://docs.microsoft.com/sql/t-sql/database-console-commands/dbcc-checkconstraints-transact-sql +[KB2801413]:https://support.microsoft.com/kb/2801413 [Niko Neugebauer Columnstore Indexes – part 86]:http://www.nikoport.com/2016/07/29/columnstore-indexes-part-86-new-trace-flags-in-sql-server-2016/ [Niko Neugebauer Columnstore Indexes – part 35]:http://www.nikoport.com/2014/07/24/clustered-columnstore-indexes-part-35-trace-flags-query-optimiser-rules/ [Microsoft SQL Server 2005 TPC-C Trace Flags]:http://webcache.googleusercontent.com/search?q=cache:Nttlt2Dp8egJ:blogs.msmvps.com/gladchenko/2009/08/21/sql_trace_flags_tpc-c/+&cd=6&hl=en&ct=clnk&gl=ru [Trace Flag 1228 and 1229]:http://www.sqlservercentral.com/Forums/Topic741825-146-1.aspx [A Topical Collection of SQL Server Flags v6]:https://sqlcrossjoin.files.wordpress.com/2016/04/sqlcrossjoin_traceflagrepository_v6.pdf -[How To Diagnose and Correct Errors 17883, 17884, 17887, and 17888]:https://msdn.microsoft.com/en-us/library/cc917684.aspx +[How To Diagnose and Correct Errors 17883, 17884, 17887, and 17888]:https://msdn.microsoft.com/library/cc917684.aspx [Trace flags in sql server from trace flag 902 to trace flag 1462]:http://www.sqlserverf1.com/tag/sql-server-trace-flag-1448/ [TECHNET List Of SQL Server Trace Flags]:http://social.technet.microsoft.com/wiki/contents/articles/13105.trace-flags-in-sql-server.aspx [Cardinality Estimation Framework 2014 First Look]:http://www.somewheresomehow.ru/cardinality-estimation-framework-2014-first-look/ -[Query Optimizer Deep Dive - Part 4]:http://sqlblog.com/blogs/paul_white/archive/2012/05/01/query-optimizer-deep-dive-part-4.aspx -[KB920093]:https://support.microsoft.com/en-us/kb/920093 -[KB972767]:https://support.microsoft.com/en-us/kb/972767 -[MSDN mt736907]:https://msdn.microsoft.com/en-us/library/mt736907.aspx +[Query Optimizer Deep Dive - Part 4]:https://www.sql.kiwi/2012/05/query-optimizer-deep-dive-part-4.html +[KB920093]:https://support.microsoft.com/kb/920093 +[KB972767]:https://support.microsoft.com/kb/972767 +[Tune compression for availability group]:https://docs.microsoft.com/sql/database-engine/availability-groups/windows/tune-compression-for-availability-group [More Undocumented Query Optimizer Trace Flags]:http://www.benjaminnevarez.com/2012/04/more-undocumented-query-optimizer-trace-flags/ -[KB3107399]:https://support.microsoft.com/en-us/kb/3107399 -[KB2801413]:https://support.microsoft.com/en-us/kb/2801413 +[KB3107399]:https://support.microsoft.com/kb/3107399 +[KB2801413]:https://web.archive.org/web/20131202110153/https://support.microsoft.com/kb/2801413 [New Features in SQL Server 2016 Service Pack 1]:https://www.mssqltips.com/sqlservertip/4574/new-features-in-sql-server-2016-service-pack-1/ [Internals of the Seven SQL Server Sorts – Part 1]:https://sqlperformance.com/2015/04/sql-plan/internals-of-the-seven-sql-server-sorts-part-1 [Yet another X-Ray for the QP]:http://www.queryprocessor.com/tf_8628/ [How It Works: SQL Server 2012 Database Engine Task Scheduling]:https://blogs.msdn.microsoft.com/psssql/2013/08/13/how-it-works-sql-server-2012-database-engine-task-scheduling/ [What You Need to Know about the Batch Mode Window Aggregate Operator in SQL Server 2016: Part 1]:http://sqlmag.com/sql-server/what-you-need-know-about-batch-mode-window-aggregate-operator-sql-server-2016-part-1 -[SQL Server 2016 : Getting tempdb a little more right]:https://blogs.sentryone.com/aaronbertrand/sql-server-2016-tempdb-fixes/ +[SQL Server 2016 : Getting tempdb a little more right]:https://www.sentryone.com/blog/aaronbertrand/sql-server-2016-tempdb-fixes [Importance of Performing DBCC CHECKDB on all SQL Server Databases]:https://www.mssqltips.com/sqlservertip/4581/importance-of-performing-dbcc-checkdb-on-all-sql-server-databases/ [SQL Server Parallel Query Placement Decision Logic]:https://blogs.msdn.microsoft.com/psssql/2016/03/04/sql-server-parallel-query-placement-decision-logic/ -[compatibility level]:https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-database-transact-sql-compatibility-level +[compatibility level]:https://docs.microsoft.com/sql/t-sql/statements/alter-database-transact-sql-compatibility-level [Bad Idea Jeans: Finding Undocumented Trace Flags]:https://www.brentozar.com/archive/2017/10/bad-idea-jeans-finding-undocumented-trace-flags/ [SQL Server - estimates outside of the histogram - half-baked draft]:http://sql-sasquatch.blogspot.ru/2017/09/sql-server-estimates-outside-of.html [Upgrading an expired SQL Server 2016 Evaluation Edition]:https://www.codykonior.com/2017/11/30/upgrading-an-expired-sql-server-2016-evaluation-edition/ -[How to Find the Statistics Used to Compile an Execution Plan]:http://sqlblog.com/blogs/paul_white/archive/2011/09/21/how-to-find-the-statistics-used-to-compile-an-paul_white +[How to Find the Statistics Used to Compile an Execution Plan]:https://www.sql.kiwi/2011/09/how-to-find-the-statistics-used-to-compile-an-execution-plan.html +[New Undocumented Trace Flags]:https://orderbyselectnull.com/2018/01/09/45-new-trace-flags/ +[Statistics and Cardinality Estimation]:http://topicaltraceflags.readthedocs.io/en/latest/cat/qry_StatsAndEst.html +[Splitting Strings Based on Patterns]:https://www.sqlservercentral.com/Forums/Topic1390297-3122-5.aspx +[SQL Server 2017: Adaptive Join Internals]:http://www.queryprocessor.com/adaptive-join-internals/ +[Parallelism in Hekaton (In-Memory OLTP)]:http://www.nikoport.com/2018/01/20/parallelism-in-hekaton-in-memory-oltp/ +[Hidden Performance & Manageability Improvements in SQL Server 2012 / 2014]:https://sqlperformance.com/2018/01/sql-performance/hidden-performance-manageability-improvements-sql-server-2012-2014 +[KB917825]:https://support.microsoft.com/kb/917825 +[TF6545-a]:https://support.microsoft.com/kb/4018930 +[TF6545-b]:https://SqlQuantumLeap.com/2018/02/23/sqlclr-vs-sql-server-2012-2014-2016-part-7-clr-strict-security-the-problem-continues-in-the-past-wait-what/ +[Controlling SQL Server memory dumps]:https://blogs.msdn.microsoft.com/psssql/2009/11/17/how-it-works-controlling-sql-server-memory-dumps +[Change SQL Server Collation – Back to Basics]:http://jasonbrimhall.info/2018/04/12/change-sql-server-collation/ +[Important Trace Flags That Every DBA Should Know]:http://victorisakov.files.wordpress.com/2011/10/sql_pass_summit_2011-important_trace_flags_that_every_dba_should_know-victor_isakov.pdf +[A Row Goal Riddle]:https://orderbyselectnull.com/2018/03/30/a-row-goal-riddle/ +[Undocumented Trace Flags: Inside the Restore Process]:https://blog.rdx.com/undocumented-trace-flags-inside-the-restore-process/ +[What’s CHECKDB doing in my database restore?]:http://www.mikefal.net/2018/04/10/whats-checkdb-doing-in-my-database-restore/ +[Few Outer Rows Optimization]:https://www.sqlshack.com/few-outer-rows-optimization/ +[TEMPDB – Files and Trace Flags and Updates]:https://blogs.msdn.microsoft.com/sql_server_team/tempdb-files-and-trace-flags-and-updates-oh-my/ +[Next-Level Parallel Plan Forcing: An Alternative to 8649]:http://dataeducation.com/next-level-parallel-plan-forcing-an-alternative-to-8649/ +[SQL Server 6.5: Some Useful Trace Flag]:http://www.databasejournal.com/features/mssql/article.php/1443351/SQL-Server-65-Some-Useful-Trace-Flags.htm +[DAC]:https://docs.microsoft.com/sql/database-engine/configure-windows/diagnostic-connection-for-database-administrators +[DBCC SHOW_STATISTICS]:https://docs.microsoft.com/sql/t-sql/database-console-commands/dbcc-show-statistics-transact-sql +[ALTER DATABASE SCOPED CONFIGURATION (Transact-SQL)]:https://docs.microsoft.com/sql/t-sql/statements/alter-database-scoped-configuration-transact-sql +[KB169960]:https://web.archive.org/web/20150111103047/http://support.microsoft.com:80/kb/169960 +[2628]:https://docs.microsoft.com/en-us/sql/relational-databases/errors-events/database-engine-events-and-errors?view=sql-server-2017#errors-2000-to-2999 +[8152]:https://docs.microsoft.com/en-us/sql/relational-databases/errors-events/database-engine-events-and-errors?view=sql-server-2017#errors-8000-to-8999 +[Fun with SQL Server Plan Cache, Trace Flag 8666, and Trace Flag 2388]:http://sql-sasquatch.blogspot.com/2018/12/fun-with-sql-server-plan-cache-trace_6.html +[Let’s talk about trace flags]:https://blogs.msdn.microsoft.com/sql_server_team/lets-talk-about-trace-flags/ +[SQL Server Plan Cache Limits]:https://www.sqlskills.com/blogs/erin/sql-server-plan-cache-limits/ +[KB2964518]:https://support.microsoft.com/kb/2964518 +[SQL Server On Linux: Forced Unit Access (Fua) Internals]:http://bobsql.com/sql-server-on-linux-forced-unit-access-fua-internals/ +[SQL Server Trace Flag 2544, Trace Flag 2546 and Trace Flag 2551]:https://www.sqlservergeeks.com/trace-flag-2544/ +[Nested Loops Joins and Performance Spools]:https://sqlperformance.com/2019/09/sql-performance/nested-loops-joins-performance-spools +[Query Optimizer Deep Dive - Part 1]:https://www.sql.kiwi/2012/04/query-optimizer-deep-dive-part-1.html +[Optimizing T-SQL queries that change data]:https://www.sql.kiwi/2013/01/optimizing-t-sql-queries-that-change-data.html +[Query Optimizer Deep Dive – Part 3]:https://www.sql.kiwi/2012/04/query-optimizer-deep-dive-part-3.html +[Hello Operator, My Switch Is Bored]:https://www.sql.kiwi/2013/06/hello-operator-my-switch-is-bored.html +[Cardinality Estimation for Multiple Predicates]:https://sqlperformance.com/2014/01/sql-plan/cardinality-estimation-for-multiple-predicates +[Temporary Table Caching in Stored Procedures]:https://www.sql.kiwi/2012/08/temporary-tables-in-stored-procedures.html +[Replication Merge Agent]:https://docs.microsoft.com/en-us/sql/relational-databases/replication/agents/replication-merge-agent +[Why are (seemingly) suitable indexes not used on a LEFT JOIN with OR]:https://topanswers.xyz/databases?q=815#a960 +[A SQL Server DBA myth a day: (15/30) checkpoint only writes pages from committed transactions]:http://www.sqlskills.com/blogs/paul/a-sql-server-dba-myth-a-day-1530-checkpoint-only-writes-pages-from-committed-transactions/ +[SQL Server 2019 Aggressive Clustered Columnstore Cleanup]:https://www.tarynpivots.com/post/aggressive-clustered-columnstore-cleanup/ +[KB153096]:https://support.microsoft.com/kb/153096 +[SQL Server 2019 Aggregate Splitting]:https://www.sql.kiwi/2020/08/sql-server-2019-aggregate-splitting.html +[Minimizing the impact of DBCC CHECKDB]:https://sqlperformance.com/2012/11/io-subsystem/minimize-impact-of-checkdb +[KB2634571]:https://web.archive.org/web/20150303213855/http://support.microsoft.com/kb/2634571 +[KB4565944]:https://support.microsoft.com/kb/4565944 +[Github disable gamsgam]:https://github.com/microsoft/bobsql/blob/master/demos/sqlserver2022/tempdb/disablegamsgam.cmd diff --git a/SQL Server Version.md b/SQL Server Version.md index 9a7ebf27..2aae3268 100644 --- a/SQL Server Version.md +++ b/SQL Server Version.md @@ -9,7 +9,7 @@ Headers: - [SQL Server Developer Edition Info](#sql-server-developer-edition-info) - [SQL Server Express direct download links](#sql-server-express-direct-download-links) - [Internal Database Version and Compatibility Level](#internal-database-version-and-compatibility-level) - - [Quick summary for SQL Server Service Packs](#quick-summary-for-sql-server-service-packs) + - [Microsoft SQL Server 2019 Builds](#microsoft-sql-server-2019-builds) - [Microsoft SQL Server 2017 Builds](#microsoft-sql-server-2017-builds) - [Microsoft SQL Server 2016 Builds](#microsoft-sql-server-2016-builds) - [Microsoft SQL Server 2014 Builds](#microsoft-sql-server-2014-builds) @@ -23,35 +23,39 @@ Headers: - [Microsoft SQL Server 6.0 Builds](#microsoft-sql-server-60-builds) Useful links: - - **Awesome official Microsoft article** - How to determine the version, edition and update level of SQL Server and its components: [KB321185](https://support.microsoft.com/en-us/kb/321185) - - Naming schema for Microsoft SQL Server software update packages: [KB822499](https://support.microsoft.com/en-us/kb/822499) - - [Microsoft SQL Server Support Lifecycle](https://support.microsoft.com/en-us/lifecycle?x=5&y=11&c2=1044) + - [KB321185 How to determine the version, edition and update level of SQL Server and its components](https://support.microsoft.com/help/321185) + - [KB822499 Naming schema for Microsoft SQL Server software update packages](https://support.microsoft.com/help/822499) + - [Microsoft SQL Server Support Lifecycle](https://support.microsoft.com/lifecycle?x=5&y=11&c2=1044) - [Microsoft Update Catalog](http://www.catalog.update.microsoft.com) - - Description of the standard terminology that is used to describe Microsoft software updates: [KB824684](https://support.microsoft.com/en-us/kb/824684) - - An Incremental Servicing Model is available from the SQL Server team to deliver hotfixes for reported problems: [KB935897](https://support.microsoft.com/en-us/kb/935897) - - Recommended updates and configuration options for SQL Server 2012 and SQL Server 2014 with high-performance workloads: [KB2964518](https://support.microsoft.com/en-us/kb/2964518) - - [Azure SQL Server Updates](https://azure.microsoft.com/en-us/updates/?product=sql-database&update-type=general-availability) - - [Most Recent KBs for Microsoft SQL Server RSS](https://support.microsoft.com/en-us/rss?rssid=1044) + - [SQL Server packages for Linux](https://packages.microsoft.com/) + - [Release notes for SQL Server 2017 on Linux](https://docs.microsoft.com/sql/linux/sql-server-linux-release-notes?view=sql-server-linux-2017) + - [KB824684 Description of the standard terminology that is used to describe Microsoft software updates](https://support.microsoft.com/help/824684) + - [KB935897 An Incremental Servicing Model is available from the SQL Server team to deliver hotfixes for reported problems](https://support.microsoft.com/help/935897) + - [KB2964518 Recommended updates and configuration options for SQL Server 2012 and SQL Server 2014 with high-performance workloads](https://support.microsoft.com/help/2964518) + - [Azure SQL Server Updates](https://azure.microsoft.com/updates/?product=sql-database&update-type=general-availability) + - [Most Recent KBs for Microsoft SQL Server RSS](https://support.microsoft.com/rss?rssid=1044) - [Testing and Developing Supportability Roadmaps for ISV Applications (PDF)](http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-85-48-files/0827.testing-and-developing-supportability-roadmaps-for-isv-applications.pdf) - [SQL Server Updates by Brent Ozar team](http://sqlserverupdates.com/) + - [Which Version of SQL Server Should You Use?](https://www.brentozar.com/archive/2019/01/which-version-of-sql-server-should-you-use/) - [SQL Server Builds by SQLSentry](http://blogs.sqlsentry.com/category/sql-server-builds/) + - [SQL Server Builds by SQLPerformance.com](https://sqlperformance.com/latest-builds) - [SQL Server Release Services](https://blogs.msdn.microsoft.com/sqlreleaseservices/) - [Why I have high hopes for the quality of SQL Server 2016 release by Remus Rusanu](https://medium.com/@rusanu/why-i-have-high-hopes-for-the-quality-of-sql-server-2016-release-6173bc1fbc82#.44kg2ktmg) - [Unofficial SQL Server build chart lists](http://sqlserverbuilds.blogspot.ru/) - [Unofficial SQL Server build chart lists in table representation](http://sqlbuilds.ekelmans.com/) - - [Hardware and Software Requirements for Installing SQL Server](https://msdn.microsoft.com/en-us//library/ms143506.aspx) + - [Hardware and Software Requirements for Installing SQL Server](https://msdn.microsoft.com//library/ms143506.aspx) - [Wikipedia Microsoft SQL Server](https://en.wikipedia.org/wiki/Microsoft_SQL_Server) - - [SQL Server 2005 Downloads](https://msdn.microsoft.com/en-us/sqlserver/bb671254.aspx) - - [SQL Server 2000 Downloads](https://msdn.microsoft.com/en-us/sqlserver/bb895925) - - [SQL Server 7.0 Downloads](https://msdn.microsoft.com/en-us/sqlserver/bb671066) + - [SQL Server 2005 Downloads](https://msdn.microsoft.com/sqlserver/bb671254.aspx) + - [SQL Server 2000 Downloads](https://msdn.microsoft.com/sqlserver/bb895925) + - [SQL Server 7.0 Downloads](https://msdn.microsoft.com/sqlserver/bb671066) Useful articles: - [How to identify your SQL Server version and edition](http://support.microsoft.com/kb/321185/en-us) - [SQL Server Internal Database Versions](http://sqlserverbuilds.blogspot.ru/2014/01/sql-server-internal-database-versions.html) - - [Microsoft SQL Server Support Lifecycle](https://support.microsoft.com/en-us/lifecycle/) + - [Microsoft SQL Server Support Lifecycle](https://support.microsoft.com/lifecycle/) - [Microsoft SQL Server Home](http://www.microsoft.com/sql) - [Microsoft SQL Server Developer Center](http://msdn.microsoft.com/sqlserver) - - [Microsoft TechNet: Microsoft SQL Server](http://technet.microsoft.com/en-us/sqlserver) + - [Microsoft TechNet: Microsoft SQL Server](http://technet.microsoft.com/sqlserver) - [SQL Server Patching Shortcut](http://www.sqlservercentral.com/articles/SQL+Server+patching/138693/) **All SQL Server service packs and Cumulative Updates are cumulative, meaning that each new service pack and cumulative update contains all the fixes that are included with previous service packs and any new fixes.** @@ -90,12 +94,12 @@ The delay between RTM and GA is much shorter now that software is generally dist - **SP** *Service Pack*: A Service Pack is, now, essentially a Cumulative Update with slightly different labeling. It is a roll-up of updates (including bug fixes and security updates) and sometimes contains new features. Like Cumulative Updates, Service Packs are cumulative. If you are applying SP3, you do not need to first deploy SP1 and SP2. - - **SU**: Security update. + - **SU** or **CVE**: Security update. - **Hotfix**: A single, cumulative package that includes one or more files that are used to address a problem in a product and are cumulative at the binary and file level. A hotfix addresses a specific customer situation and may not be distributed outside the customers organization. ### References - - [KB #824684 : Description of the standard terminology that is used to describe Microsoft software updates](https://support.microsoft.com/en-us/kb/824684) - - [KB #935897 : An Incremental Servicing Model is available from the SQL Server team to deliver hotfixes for reported problems](https://support.microsoft.com/en-us/kb/935897) + - [KB #824684 : Description of the standard terminology that is used to describe Microsoft software updates](https://support.microsoft.com/kb/824684) + - [KB #935897 : An Incremental Servicing Model is available from the SQL Server team to deliver hotfixes for reported problems](https://support.microsoft.com/kb/935897) - [QFE vs GDR/LDR hotfixes](https://blogs.technet.microsoft.com/instan/2009/03/04/qfe-vs-gdrldr-hotfixes/) - [GDR, QFE, LDR… WTH?](http://blogs.technet.com/b/mrsnrub/archive/2009/05/14/gdr-qfe-ldr-wth.aspx) - [GDR & LDR : The Next Generation](http://blogs.technet.com/b/mrsnrub/archive/2009/05/14/gdr-qfe-ldr-wth.aspx) @@ -123,39 +127,44 @@ Profits: ## What are the most recent updates for SQL Server? -| Version | Latest Update | Build Number | Release Date | Lifecycle Start | Mainstream Support | Extended Support | Other Updates | -|---------|----------------------------------------------------------------------|----------------------------------------------|------------------------------------------|-----------------|--------------------|------------------|-------------------------------------------------------------------| -| 2017 | [Install 2017 RTM] then [CU3 KB4052987] | 14.0.1000.169
14.0.3015.40 | 2017-10-02
2018-01-03 | 2017-09-29 | 2022-11-10 | 2027-12-10 | [Other SQL 2017 Updates](#microsoft-sql-server-2017-builds) | -| 2016 | [Install 2016 SP1] Or [Developer Free] then
[SP1 CU7 KB4057119] | 13.0.4001.0
13.0.4466.4 | 2016-11-16
2018-01-03 | 2016-11-16 | 2021-07-13 | 2026-07-14 | [Other SQL 2016 Updates](#microsoft-sql-server-2016-builds) | -| 2014 | [Install 2014 SP2] Or [Developer Free] then
[SP2 CU9 KB4055557] | 12.0.5000.0
12.0.5563.0 | 2016-07-11
2017-12-18 | 2016-07-14 | 2019-07-09 | 2024-07-09 | [Other SQL 2014 Updates](#microsoft-sql-server-2014-builds) | -| 2012 | [Install 2012] then
[SP4 2012] | 11.0.2100.60
11.0.7001.0 | 2012-02-14
2017-10-05 | 2015-12-01 | 2017-07-11 | 2022-07-12 | [Other SQL 2012 Updates](#microsoft-sql-server-2012-builds) | -| 2008 R2 | [Install 2008 R2] then
[SP3 2008 R2] then
[SU KB3045311] | 10.50.1600
10.50.6000
10.50.6220.0 | 2010-11-21
2014-09-30
2015-07-14 | Review Note | 2014-07-08 | 2019-07-09 | [Other SQL 2008 R2 Updates](#microsoft-sql-server-2008-r2-builds) | -| 2008 | [Install 2008] then
[SP4 2008] then
[SU KB3045316] | 10.0.1600.0
10.0.6000
10.0.6241.0 | 2008-01-19
2014-09-30
2015-07-14 | 2014-07-07 | 2014-07-08 | 2019-07-09 | [Other SQL 2008 Updates](#microsoft-sql-server-2008-builds) | - -**For downloading distributive for SQL Server 2008 R2 and SQL Server 2008 you must have MSDN subscription, see [Install 2008 R2] and [Install 2008] links.** - -[Install 2017 RTM]:https://www.microsoft.com/en-us/sql-server/sql-server-downloads -[CU3 KB4052987]:https://support.microsoft.com/en-us/help/4052987/cumulative-update-3-for-sql-server-2017 -[Install 2016 SP1]:https://go.microsoft.com/fwlink/?LinkID=799011 -[SP1 CU7 KB4057119]:https://support.microsoft.com/en-us/help/4057119/cumulative-update-7-for-sql-server-2016-sp1 -[Install 2014 SP2]:https://www.microsoft.com/en-us/evalcenter/evaluate-sql-server-2014-sp2 -[SP2 CU9 KB4055557]:https://support.microsoft.com/en-us/help/4055557/cumulative-update-9-for-sql-server-2014-sp2 -[Install 2012]:https://www.microsoft.com/en-us/evalcenter/evaluate-sql-server-2012 -[SP4 2012]:https://support.microsoft.com/en-us/help/4018073/sql-server-2012-service-pack-4-release-information -[KB4016762]:https://support.microsoft.com/en-us/help/4016762/cumulative-update-9-for-sql-server-2012-sp3 -[CU9 KB3098512]:https://support.microsoft.com/en-us/kb/3098512 +| Version | Latest Update | Build Number | Release Date | Lifecycle Start | Mainstream Support | Extended Support | Other Updates | +|---------|-----------------------------------------------------------------------|----------------------------------------------|------------------------------------------|-----------------|--------------------|------------------|-------------------------------------------------------------------| +| 2019 | [Install 2019 RTM] then [CU12 KB5004524] | 15.0.2070.41
15.0.4153.1 | 2019-11-04
2021-08-04 | 2019-11-04 | 2025-01-07 | 2030-01-08 | [Other SQL 2019 Updates](#microsoft-sql-server-2019-builds) | +| 2017 | [Install 2017 RTM] then [CU26 KB5005226] | 14.0.1000.169
14.0.3411.3 | 2017-10-02
2021-09-14 | 2017-09-29 | 2022-11-10 | 2027-12-10 | [Other SQL 2017 Updates](#microsoft-sql-server-2017-builds) | +| 2016 | [Install 2016 SP2] then [SP3 2016] | 13.0.5026.0
13.0.5026.0 | 2018-04-24
2021-09-15 | 2016-01-06 | 2021-07-13 | 2026-07-14 | [Other SQL 2016 Updates](#microsoft-sql-server-2016-builds) | +| 2014 | [Install 2014 SP3] then [KB4583462] | 12.0.6024.0
12.0.6433.1 | 2018-10-30
2021-01-12 | 2016-07-14 | 2019-07-09 | 2024-07-09 | [Other SQL 2014 Updates](#microsoft-sql-server-2014-builds) | +| 2012 | [Install 2012] then
[SP4 2012] then
[KB4583465] | 11.0.2100.60
11.0.7001.0
11.0.7507.2 | 2012-02-14
2017-10-05
2021-01-12 | 2015-12-01 | 2017-07-11 | 2022-07-12 | [Other SQL 2012 Updates](#microsoft-sql-server-2012-builds) | +| 2019 | [Install 2019 RTM] then [CU7 KB4570012] | 15.0.2070.41
15.0.4063.15 | 2019-11-04
2020-09-02 | 2019-11-04 | 2025-01-07 | 2030-01-08 | [Other SQL 2019 Updates](#microsoft-sql-server-2019-builds) | +| 2017 | [Install 2017 RTM] then [CU21 KB4557397] | 14.0.1000.169
14.0.3335.7 | 2017-10-02
2020-07-01 | 2017-09-29 | 2022-11-10 | 2027-12-10 | [Other SQL 2017 Updates](#microsoft-sql-server-2017-builds) | +| 2016 | [Install 2016 SP2] then [CU14 KB4564903] | 13.0.5026.0
13.0.5830.85 | 2018-04-24
2020-08-06 | 2016-01-06 | 2021-07-13 | 2026-07-14 | [Other SQL 2016 Updates](#microsoft-sql-server-2016-builds) | +| 2014 | [Install 2014 SP3] then
[KB4583462] | 12.0.6024.0
12.0.6433.1 | 2018-10-30
2021-01-07 | 2016-07-14 | 2019-07-09 | 2024-07-09 | [Other SQL 2014 Updates](#microsoft-sql-server-2014-builds) | +| 2012 | [Install 2012] then
[SP4 2012] then
[KB4532098] | 11.0.2100.60
11.0.7001.0
11.0.7493.4 | 2012-02-14
2017-10-05
2020-02-11 | 2015-12-01 | 2017-07-11 | 2022-07-12 | [Other SQL 2012 Updates](#microsoft-sql-server-2012-builds) | +| 2008 R2 | [Install 2008 R2] then
[SP3 2008 R2] then
[SU KB3045311] | 10.50.1600
10.50.6000
10.50.6220.0 | 2010-11-21
2014-09-30
2015-07-14 | 2010-07-20 | 2014-07-08 | 2019-07-09 | [Other SQL 2008 R2 Updates](#microsoft-sql-server-2008-r2-builds) | +| 2008 | [Install 2008] then
[SP4 2008] then
[SU KB3045316] | 10.0.1600.0
10.0.6000
10.0.6241.0 | 2008-01-19
2014-09-30
2015-07-14 | 2010-07-20 | 2014-07-08 | 2019-07-09 | [Other SQL 2008 Updates](#microsoft-sql-server-2008-builds) | + +[Install 2019 RTM]:https://www.microsoft.com/sql-server/sql-server-2019#Install +[CU12 KB5005226]:https://support.microsoft.com/help/5005226 +[Install 2017 RTM]:https://www.microsoft.com/en-us/sql-server/sql-server-2017 +[CU25 KB5003830]:https://support.microsoft.com/help/50038307 +[Install 2016 SP3]:https://www.microsoft.com/en-us/download/details.aspx?id=103440 +[Install 2014 SP3]:https://www.microsoft.com/evalcenter/evaluate-sql-server-2014-sp3 +[KB4583462]:https://support.microsoft.com/help/4583462 +[Install 2012]:https://www.microsoft.com/evalcenter/evaluate-sql-server-2012 +[SP4 2012]:https://support.microsoft.com/help/4018073 +[KB4583465]:https://support.microsoft.com/help/4583465 +[CU9 KB3098512]:https://support.microsoft.com/kb/3098512 [Install 2008 R2]:https://msdn.microsoft.com/subscriptions/securedownloads/#searchTerm=sql%20server%202008%20r2&ProductFamilyId=0&Languages=en&FileExtensions=.iso&PageSize=10&PageIndex=0&FileId=0 -[SP3 2008 R2]:http://www.microsoft.com/en-us/download/details.aspx?id=44271 +[SP3 2008 R2]:http://www.microsoft.com/download/details.aspx?id=44271 [SU KB3045311]:https://www.microsoft.com/downloads/details.aspx?familyid=7af16cb8-c944-41cb-a897-c6fc373869cd [Install 2008]:https://msdn.microsoft.com/subscriptions/securedownloads/#searchTerm=sql%20server%202008&ProductFamilyId=0&Languages=en&FileExtensions=.iso&PageSize=10&PageIndex=0&FileId=0 -[SP4 2008]:http://www.microsoft.com/en-us/download/details.aspx?id=44278 -[SU KB3045316]:https://support.microsoft.com/en-us/kb/3045311 -[Developer Free]:https://www.microsoft.com/en-us/cloud-platform/sql-server-editions-developers +[SP4 2008]:http://www.microsoft.com/download/details.aspx?id=44278 +[SU KB3045316]:https://support.microsoft.com/help/3045311 +[Developer Free]:https://www.microsoft.com/cloud-platform/sql-server-editions-developers ## Microsoft SQL Server installation files info -SHA1 hash you can easy get with default Windows utility [certutil](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/certutil 'certutil Microsoft docs'). +`SHA1` hash you can easy get with default Windows utility [certutil](https://docs.microsoft.com/windows-server/administration/windows-commands/certutil 'certutil Microsoft docs'). For example, for single file: ```bat @@ -169,39 +178,44 @@ FOR /R "d:\SQL Server" %I IN (*.exe) DO certUtil -hashfile "%I" sha1 Alternative download link for all English x64 distributives: https://rebrand.ly/sql-server-distribs -| Direct x64 Download Link | File Name | Release Date | Build Number | Size, MB | SHA1 | -|---------------------------------|-------------------------------------------------------------------|--------------|--------------:|---------:|------------------------------------------| -| [SQL Server 2017] | SQLServer2017-x64-ENU-Dev.iso | 2017-10-02 | 14.0.1000.169 | 1476 | 0280ff6c1447d287a6bd3b86b81e459fe252d17a | -| [SQL Server 2017 KB4052987] | SQLServer2017-KB4052987-x64.exe | 2018-01-03 | 14.0.3015.40 | 459 | a533b82e49cb9a5eea52cd2339db18aa4017587b | -| [SQL Server 2016] | SQLServer2016-x64-ENU.iso | 2016-06-01 | 13.0.1601.5 | 2050 | ce21bf1c08ec1ac48ebb4988a8602c7813034ea3 | -| [SQL Server 2016 SP1] | SQLServer2016SP1-KB3182545-x64-ENU.exe | 2016-11-16 | 13.0.4001.0 | 552 | 8c6cf18878931d8efd44b952e79420002b8a4885 | -| [SQL Server 2016 SP1 KB4057119] | SQLServer2016-KB4057119-x64.exe | 2018-01-03 | 13.0.4466.4 | 759 | c6f298b1e0d79c208f59590354823ebefffdae60 | -| [SQL Server 2014 SP2] | SQLServer2014SP2-FullSlipstream-x64-ENU.iso | 2016-07-11 | 12.0.5000.0 | 3010 | 16f1934dc1f47994cd924439f884a05c6ad4d173 | -| [SQL Server 2014 SP2 KB4055557] | SQLServer2014-KB4055557-x64.exe | 2017-12-18 | 12.0.5563.0 | 540 | 58cc168f6f345abd5afef7ef2125896b04fd7541 | -| [SQL Server 2012] | SQLFULL_ENU.iso | 2012-02-14 | 11.0.2100.60 | 4300 | be00942cc56d033e2c9dce8a17a6f2654f5184a3 | +| Direct x64 Download Link | File Name | Release Date | Build Number | Size, MB | SHA1 | +|:--------------------------------|:------------------------------------------------------------------|:-------------|--------------:|---------:|------------------------------------------| +| [SQL Server 2019 RTM] | SQLServer2019-x64-ENU.iso | 2019-11-04 | 15.0.2000.5 | 1360 | d41eb957a037add32441e2302a734268bda94709 | +| [SQL Server 2019 CU12] | SQLServer2019-KB5004524-x64.exe | 2021-08-04 | 15.0.4153.1 | 669 | f145a82e48219e5bf80c7dcf57ea3c902c4d395f | +| [SQL Server 2017 RTM] | SQLServer2017-x64-ENU-Dev.iso | 2017-10-02 | 14.0.1000.169 | 1476 | 0280ff6c1447d287a6bd3b86b81e459fe252d17a | +| [SQL Server 2017 CU26] | SQLServer2017-KB5005226-x64.exe | 2021-09-14 | 14.0.3411.3 | 533 | e31b28ba9c4c0b63ddbb356f630e8ea631da97fe | +| [SQL Server 2016 SP2] | SQLServer2016SP2-FullSlipstream-x64-ENU.iso | 2018-04-24 | 13.0.5026.0 | 2832 | 6309d729a0f063d11c0bb7f840f1069483406755 | +| [SQL Server 2016 SP3] | SQLServer2016SP3-KB5003279-x64-ENU.exe | 2021-09-15 | 13.0.6300.2 | 821 | 1a97cb64a8807bde83443b911fd84616432612f3 | +| [SQL Server 2014 SP3] | SQLServer2014SP3-FullSlipstream-x64-ENU.iso | 2018-10-30 | 12.0.6024.0 | 3190 | 6041e06548c46862c9f3536e28113f598bb6ae00 | +| [SQL Server 2014 SP3 KB4583462] | SQLServer2014-KB4583462-x64.exe | 2021-01-12 | 12.0.6433.1 | 596 | 0dc4f56583828865365340dcb95436f1a41754b9 | +| [SQL Server 2012 RTM] | SQLFULL_ENU.iso | 2012-02-14 | 11.0.2100.60 | 4300 | be00942cc56d033e2c9dce8a17a6f2654f5184a3 | | [SQL Server 2012 SP4] | SQLServer2012SP4-KB4018073-x64-ENU.exe | 2017-10-05 | 11.0.7001.0 | 1024 | 95127ee2e8dfef180752e531a83cd948c24a3a87 | +| [SQL Server 2012 SP4 KB4583465] | SQLServer2012-KB4583465-x64.exe | 2021-01-12 | 11.0.7507.2 | 856 | c6e5ea14425fed26b885ab6b70aba8622817fd8c | | SQL Server 2008 R2 RTM | SW_DVD9_SQL_Svr_Enterprise_Edtn_2008_R2_English_MLF_X16-29540.ISO | 2010-04-21 | 10.50.1600.1 | 4177 | 18105db70f0f0b23418f5005a6ce4b25317c6d03 | | [SQL Server 2008 R2 SP3] | SQLServer2008R2SP3-KB2979597-x64-ENU.exe | 2014-09-30 | 10.50.6220.0 | 358 | 194cd740d5812b12639b47886ebde0d04774b4ec | | [SQL Server 2008 R2 SU] | SQLServer2008R2-KB3045316-x64.exe | 2015-07-14 | 10.50.6000 | 58 | 3aa4d820553b1e5d96735541cbb55d97322c286e | -| [SQL Server 2008] | ? | 2008-01-19 | 10.0.1600.0 | ? | ? | +| SQL Server 2008 | ? | 2008-01-19 | 10.0.1600.0 | ? | ? | | [SQL Server 2008 SP4] | SQLServer2008SP4-KB2979596-x64-ENU.exe | 2014-09-30 | 10.0.6241.0 | 378 | 13610d6cb39e37fcd4a3338244a3ca2a8a404cd8 | | [SQL Server 2008 SU] | SQLServer2008-KB3045311-x64.exe | 2015-07-14 | 10.00.6000 | 61 | 37a197c60990d2e83e98d1090109a4ab3f2abe4b | -**For downloading distributive for SQL Server 2008 R2 and SQL Server 2008 you must have MSDN subscription, see [Install 2008 R2] and [Install 2008] links.** - -[SQL Server 2017]:https://go.microsoft.com/fwlink/?linkid=853016 -[SQL Server 2017 KB4052987]:https://download.microsoft.com/download/C/4/F/C4F908C9-98ED-4E5F-88D5-7D6A5004AEBD/SQLServer2017-KB4052987-x64.exe -[SQL Server 2016]:http://care.dlservice.microsoft.com/dl/download/F/E/9/FE9397FA-BFAB-4ADD-8B97-91234BC774B2/SQLServer2016-x64-ENU.iso -[SQL Server 2016 SP1]:https://download.microsoft.com/download/3/0/D/30D3ECDD-AC0B-45B5-B8B9-C90E228BD3E5/ENU/SQLServer2016SP1-KB3182545-x64-ENU.exe -[SQL Server 2016 SP1 KB4057119]:https://download.microsoft.com/download/D/3/3/D33543E3-770F-4053-AE0F-A883696668FF/SQLServer2016-KB4057119-x64.exe -[SQL Server 2014 SP2]:http://care.dlservice.microsoft.com/dl/download/6/D/9/6D90C751-6FA3-4A78-A78E-D11E1C254700/SQLServer2014SP2-FullSlipstream-x64-ENU.iso -[SQL Server 2014 SP2 KB4055557]:https://download.microsoft.com/download/5/E/E/5EEAC4AB-1635-44B9-BFBD-4A1405EB5EC8/SQLServer2014-KB4055557-x64.exe -[SQL Server 2012]:https://download.microsoft.com/download/4/C/7/4C7D40B9-BCF8-4F8A-9E76-06E9B92FE5AE/ENU/SQLFULL_ENU.iso +**For downloading distributive for SQL Server 2008 R2 and SQL Server 2008 you must have MSDN subscription, see [SQL Server 2008 R2] and [SQL Server 2008] links.** + +[SQL Server 2019 RTM]:https://go.microsoft.com/fwlink/?linkid=866664 +[SQL Server 2019 CU12]:https://download.microsoft.com/download/6/e/7/6e72dddf-dfa4-4889-bc3d-e5d3a0fd11ce/SQLServer2019-KB5004524-x64.exe +[SQL Server 2017 RTM]:https://go.microsoft.com/fwlink/?linkid=853016 +[SQL Server 2017 CU26]:https://download.microsoft.com/download/C/4/F/C4F908C9-98ED-4E5F-88D5-7D6A5004AEBD/SQLServer2017-KB5005226-x64.exe +[SQL Server 2016 SP2]:https://www.microsoft.com/en-us/evalcenter/evaluate-sql-server-2016 +[SQL Server 2016 SP3]:https://download.microsoft.com/download/a/7/7/a77b5753-8fe7-4804-bfc5-591d9a626c98/SQLServer2016SP3-KB5003279-x64-ENU.exe +[SQL Server 2016 SP2 CU17]:https://download.microsoft.com/download/6/0/6/606B3A2E-0EAE-4DCD-930D-178686370921/SQLServer2016-KB5001092-x64.exe +[SQL Server 2014 SP3]:https://www.microsoft.com/en-us/evalcenter/evaluate-sql-server-2014-sp3 +[SQL Server 2014 SP3 KB4583462]:https://www.microsoft.com/en-us/download/details.aspx?id=102623 +[SQL Server 2012 RTM]:https://download.microsoft.com/download/4/C/7/4C7D40B9-BCF8-4F8A-9E76-06E9B92FE5AE/ENU/SQLFULL_ENU.iso [SQL Server 2012 SP4]:https://download.microsoft.com/download/E/A/B/EABF1E75-54F0-42BB-B0EE-58E837B7A17F/SQLServer2012SP4-KB4018073-x64-ENU.exe +[SQL Server 2012 SP4 KB4583465]:https://www.microsoft.com/en-us/download/confirmation.aspx?id=102625 [SQL Server 2008 R2]:https://msdn.microsoft.com/subscriptions/securedownloads/#searchTerm=sql%20server%202008%20r2&ProductFamilyId=0&Languages=en&FileExtensions=.iso&PageSize=10&PageIndex=0&FileId=0 [SQL Server 2008 R2 SP3]:https://download.microsoft.com/download/D/7/A/D7A28B6C-FCFE-4F70-A902-B109388E01E9/ENU/SQLServer2008R2SP3-KB2979597-x64-ENU.exe [SQL Server 2008 R2 SU]:https://download.microsoft.com/download/4/D/A/4DAE6F9E-960E-4A59-BDE7-1D92DA508315/SQLServer2008R2-KB3045316-x64.exe -[SQL Server 2008]:https://download.microsoft.com/download/D/D/B/DDB17DC1-A879-44DD-BD11-C0991D292AD7/6001.18000.080118-1840_amd64fre_Server_en-us-KRMSXFRE_EN_DVD.exe +[SQL Server 2008]:https://msdn.microsoft.com/subscriptions/securedownloads/#searchTerm=sql%20server%202008&ProductFamilyId=0&Languages=en&FileExtensions=.iso&PageSize=10&PageIndex=0&FileId=0 [SQL Server 2008 SP4]:https://download.microsoft.com/download/5/E/7/5E7A89F7-C013-4090-901E-1A0F86B6A94C/ENU/SQLServer2008SP4-KB2979596-x64-ENU.exe [SQL Server 2008 SU]:https://download.microsoft.com/download/E/C/0/EC0A7C15-9A6D-4F41-9B9F-BCA10CC3937C/SQLServer2008-KB3045311-x64.exe @@ -210,62 +224,67 @@ Alternative download link for all English x64 distributives: https://rebrand.ly/ **Now it is free!!!** [SQL Server Developer Edition Download page](https://my.visualstudio.com/downloads?q=sql%20server%20developer) -For downloading your copy SQL Server Developer Edition you just need to join the [Visual Studio Dev Essentials program](https://www.visualstudio.com/en-us/products/visual-studio-dev-essentials-vs.aspx) +For downloading your copy SQL Server Developer Edition you just need to join the [Visual Studio Dev Essentials program](https://www.visualstudio.com/products/visual-studio-dev-essentials-vs.aspx) | Edition\Direct Download Link | Release Date | File name | Size, Mb | SHA1 | |-----------------------------------------------------------------------------|--------------|------------------------------------------------------------------------------|---------:|------------------------------------------| -| SQL Server 2017 Developer | 2017-10-02 | en_sql_server_2017_developer_x64_dvd_11296168 | 1475 | 0280ff6c1447d287a6bd3b86b81e459fe252d17a | -| SQL Server 2014 Developer Edition with Service Pack 1 (x64) - DVD (English) | 2015-05-21 | en_sql_server_2014_developer_edition_with_service_pack_1_x64_dvd_6668542.iso | 3025 | BFEE1F300C39638DA0D2CD594636698C6207C852 | -| SQL Server 2014 Developer Edition with Service Pack 1 (x86) - DVD (English) | 2015-05-21 | en_sql_server_2014_developer_edition_with_service_pack_1_x86_dvd_6668541.iso | 2462 | ED3C70507A73BCC63D67CFA272CD849B9418A18E | -| SQL Server 2014 Developer Edition (x64) - DVD (English) | 2014-04-01 | en_sql_server_2014_developer_edition_x64_dvd_3940406.iso | 2486 | F73F430F55A71DA219FC7257A3A28E8FC142530F | -| SQL Server 2014 Developer Edition (x86) - DVD (English) | 2014-04-01 | en_sql_server_2014_developer_edition_x86_dvd_3938200.iso | 2039 | 395B35FD80AA959B02B0C399DA1BB0C020DB6310 | +| SQL Server 2019 Developer (x64) - DVD (English) | 2019-11-05 | en_sql_server_2019_developer_x64_dvd_baea4195.iso | 1367 | 22974e466987d7d4659437aab06ac0798657c700 | +| SQL Server 2017 Developer (x64) - DVD (English) | 2017-10-02 | en_sql_server_2017_developer_x64_dvd_11296168.iso | 1475 | 0280ff6c1447d287a6bd3b86b81e459fe252d17a | +| SQL Server 2016 Developer with Service Pack 2 (x64) - DVD (English) | 2018-05-22 | en_sql_server_2016_developer_with_service_pack_2_x64_dvd_12194995.iso | 2800 | 74279286c2abfba9e9ff6dbee60b71669bd234d2 | +| SQL Server 2016 Developer with Service Pack 1 (x64) - DVD (English) | 2016-11-16 | en_sql_server_2016_developer_with_service_pack_1_x64_dvd_9548071.iso | 2590 | b12af2cc5112f22a784a14f8d32b49ee56d296b3 | +| SQL Server 2016 Developer (x64) - DVD (English) | 2016-06-01 | en_sql_server_2016_developer_x64_dvd_8777069.iso | 2100 | 1b23982fe56df3bfe0456bdf0702612eb72abf75 | +| SQL Server 2014 Developer Edition with Service Pack 1 (x64) - DVD (English) | 2015-05-21 | en_sql_server_2014_developer_edition_with_service_pack_1_x64_dvd_6668542.iso | 3025 | bfee1f300c39638da0d2cd594636698c6207c852 | +| SQL Server 2014 Developer Edition with Service Pack 1 (x86) - DVD (English) | 2015-05-21 | en_sql_server_2014_developer_edition_with_service_pack_1_x86_dvd_6668541.iso | 2462 | ed3c70507a73bcc63d67cfa272cd849b9418a18e | +| SQL Server 2014 Developer Edition (x64) - DVD (English) | 2014-04-01 | en_sql_server_2014_developer_edition_x64_dvd_3940406.iso | 2486 | f73f430f55a71da219fc7257a3a28e8fc142530f | +| SQL Server 2014 Developer Edition (x86) - DVD (English) | 2014-04-01 | en_sql_server_2014_developer_edition_x86_dvd_3938200.iso | 2039 | 395b35fd80aa959b02b0c399da1bb0c020db6310 | ## SQL Server Express direct download links -Original post written by Scott Hanselman: http://www.hanselman.com/blog/DownloadSQLServerExpress.aspx
-Official Microsoft SQL Server Express page: https://www.microsoft.com/en-us/server-cloud/products/sql-server-editions/sql-server-express.aspx - - -### [Download SQL Server 2016 Express](https://www.microsoft.com/en-us/download/details.aspx?id=52679) - - -### [Download SQL Server 2014 Express](http://www.microsoft.com/en-us/download/details.aspx?id=42299) -[Download Microsoft SQL Server 2014 Service Pack 1 (SP1) Express ](https://www.microsoft.com/en-us/download/details.aspx?id=46697)
-You likely just want SQL Server 2014 Express with Tools. This download includes SQL Management Studio: - - [SQL Server 2014 Express x64](http://download.microsoft.com/download/E/A/E/EAE6F7FC-767A-4038-A954-49B8B05D04EB/ExpressAndTools%2064BIT/SQLEXPRWT_x64_ENU.exe) - - [SQL Server 2014 Express x86](http://download.microsoft.com/download/E/A/E/EAE6F7FC-767A-4038-A954-49B8B05D04EB/ExpressAndTools%2032BIT/SQLEXPRWT_x86_ENU.exe) - -Here's just SQL Server 2014 Management Studio: - - [SQL Management Studio x64](http://download.microsoft.com/download/E/A/E/EAE6F7FC-767A-4038-A954-49B8B05D04EB/MgmtStudio%2064BIT/SQLManagementStudio_x64_ENU.exe) - - [SQL Management Studio x86](http://download.microsoft.com/download/E/A/E/EAE6F7FC-767A-4038-A954-49B8B05D04EB/MgmtStudio%2032BIT/SQLManagementStudio_x86_ENU.exe) - -SQL Server 2014 Express with Advanced Services: - - [Advanced Services x64](http://download.microsoft.com/download/E/A/E/EAE6F7FC-767A-4038-A954-49B8B05D04EB/ExpressAdv%2064BIT/SQLEXPRADV_x64_ENU.exe) - - [Advanced Services x86](http://download.microsoft.com/download/E/A/E/EAE6F7FC-767A-4038-A954-49B8B05D04EB/ExpressAdv%2032BIT/SQLEXPRADV_x86_ENU.exe) - - -### [Download SQL Server 2012 Express](http://www.microsoft.com/en-us/download/details.aspx?id=29062) -[Download Microsoft SQL Server 2012 Service Pack 1 (SP1) Express ](https://www.microsoft.com/en-us/download/details.aspx?id=35579)
-You likely just want SQL Server 2012 Express with Tools. This download includes SQL Management Studio: - - [SQL Server 2012 Express x64](http://download.microsoft.com/download/8/D/D/8DD7BDBA-CEF7-4D8E-8C16-D9F69527F909/ENU/x64/SQLEXPRWT_x64_ENU.exe) - -Here's just SQL Server 2012 Management Studio: - - [SQL Management Studio x64](http://download.microsoft.com/download/8/D/D/8DD7BDBA-CEF7-4D8E-8C16-D9F69527F909/ENU/x64/SQLManagementStudio_x64_ENU.exe) - - [SQL Management Studio x86](http://download.microsoft.com/download/8/D/D/8DD7BDBA-CEF7-4D8E-8C16-D9F69527F909/ENU/x86/SQLManagementStudio_x86_ENU.exe) - - -### [Download SQL Server 2008 Express R2 SP2](http://www.microsoft.com/en-us/download/details.aspx?id=30438) -You likely just want SQL Server 2008 Express with Tools. This download includes SQL Management Studio: - - [SQL Server 2008 Express x64](http://download.microsoft.com/download/0/4/B/04BE03CD-EAF3-4797-9D8D-2E08E316C998/SQLEXPRWT_x64_ENU.exe) - - [SQL Server 2008 Express x86](http://download.microsoft.com/download/0/4/B/04BE03CD-EAF3-4797-9D8D-2E08E316C998/SQLEXPRWT_x86_ENU.exe) - -Here's just SQL Server 2008 Management Studio: - - [SQL Management Studio x64](http://download.microsoft.com/download/0/4/B/04BE03CD-EAF3-4797-9D8D-2E08E316C998/SQLManagementStudio_x64_ENU.exe) - - [SQL Management Studio x86](http://download.microsoft.com/download/0/4/B/04BE03CD-EAF3-4797-9D8D-2E08E316C998/SQLManagementStudio_x86_ENU.exe) - - -### [Download SQL Server 2005 Express](https://www.microsoft.com/en-us/download/details.aspx?id=21844) +Great thanks Scott Hanselman for Original post: [Download SQL Server Express](http://downloadsqlserverexpress.com) + +- [SQL Server 2019 Express Edition](https://www.microsoft.com/Download/details.aspx?id=101064) + - [Download SQL Server 2019 Express Basic (English)](https://download.microsoft.com/download/7/c/1/7c14e92e-bdcb-4f89-b7cf-93543e7112d1/SQLEXPR_x64_ENU.exe) + - [Download SQL Server 2019 Express Advanced (English)](https://download.microsoft.com/download/7/c/1/7c14e92e-bdcb-4f89-b7cf-93543e7112d1/SQLEXPRADV_x64_ENU.exe) + - [Download SQL Server 2019 Express LocalDB (English)](https://download.microsoft.com/download/7/c/1/7c14e92e-bdcb-4f89-b7cf-93543e7112d1/SqlLocalDB.msi) +- [Download SQL Server 2017 Express](https://www.microsoft.com/download/details.aspx?id=55994) + - [Download SQL Server 2017 Express Basic (English)](https://download.microsoft.com/download/E/F/2/EF23C21D-7860-4F05-88CE-39AA114B014B/SQLEXPR_x64_ENU.exe) + - [Download SQL Server 2017 Express Advanced (English)](https://download.microsoft.com/download/E/F/2/EF23C21D-7860-4F05-88CE-39AA114B014B/SQLEXPRADV_x64_ENU.exe) + - [Download SQL Server 2017 Express LocalDB (English)](https://download.microsoft.com/download/E/F/2/EF23C21D-7860-4F05-88CE-39AA114B014B/SqlLocalDB.msi) +- SQL Server 2016 Express + - [Download SQL Server 2016 SP2 Express Basic (English)](https://download.microsoft.com/download/4/1/A/41AD6EDE-9794-44E3-B3D5-A1AF62CD7A6F/sql16_sp2_dlc/en-us/SQLEXPR_x64_ENU.exe) + - [Download SQL Server 2016 SP2 Express Advanced (English)](https://download.microsoft.com/download/4/1/A/41AD6EDE-9794-44E3-B3D5-A1AF62CD7A6F/sql16_sp2_dlc/en-us/SQLEXPRADV_x64_ENU.exe) + - [Download SQL Server 2016 SP2 Express LocalDB (English)](https://download.microsoft.com/download/4/1/A/41AD6EDE-9794-44E3-B3D5-A1AF62CD7A6F/sql16_sp2_dlc/en-us/SqlLocalDB.msi) +- SQL Server 2016 Express + - [Download SQL Server 2016 SP1 Express Basic (English)](https://download.microsoft.com/download/9/0/7/907AD35F-9F9C-43A5-9789-52470555DB90/ENU/SQLEXPR_x64_ENU.exe) + - [Download SQL Server 2016 SP1 Express Advanced (English)](https://download.microsoft.com/download/9/0/7/907AD35F-9F9C-43A5-9789-52470555DB90/ENU/SQLEXPRADV_x64_ENU.exe) + - [Download SQL Server 2016 SP1 Express LocalDB (English)](https://download.microsoft.com/download/9/0/7/907AD35F-9F9C-43A5-9789-52470555DB90/ENU/SqlLocalDB.msi) +- [Download SQL Server 2014 Express](http://www.microsoft.com/download/details.aspx?id=42299) +- [Download Microsoft SQL Server 2014 Service Pack 1 (SP1) Express](https://www.microsoft.com/download/details.aspx?id=46697) + - You likely just want SQL Server 2014 Express with Tools. This download includes SQL Management Studio: + - [SQL Server 2014 Express x64](http://download.microsoft.com/download/E/A/E/EAE6F7FC-767A-4038-A954-49B8B05D04EB/ExpressAndTools%2064BIT/SQLEXPRWT_x64_ENU.exe) + - [SQL Server 2014 Express x86](http://download.microsoft.com/download/E/A/E/EAE6F7FC-767A-4038-A954-49B8B05D04EB/ExpressAndTools%2032BIT/SQLEXPRWT_x86_ENU.exe) + - Here's just SQL Server 2014 Management Studio: + - [SQL Management Studio x64](http://download.microsoft.com/download/E/A/E/EAE6F7FC-767A-4038-A954-49B8B05D04EB/MgmtStudio%2064BIT/SQLManagementStudio_x64_ENU.exe) + - [SQL Management Studio x86](http://download.microsoft.com/download/E/A/E/EAE6F7FC-767A-4038-A954-49B8B05D04EB/MgmtStudio%2032BIT/SQLManagementStudio_x86_ENU.exe) + - SQL Server 2014 Express with Advanced Services: + - [Advanced Services x64](http://download.microsoft.com/download/E/A/E/EAE6F7FC-767A-4038-A954-49B8B05D04EB/ExpressAdv%2064BIT/SQLEXPRADV_x64_ENU.exe) + - [Advanced Services x86](http://download.microsoft.com/download/E/A/E/EAE6F7FC-767A-4038-A954-49B8B05D04EB/ExpressAdv%2032BIT/SQLEXPRADV_x86_ENU.exe) +- [Download SQL Server 2012 Express](http://www.microsoft.com/download/details.aspx?id=29062) +- [Download Microsoft SQL Server 2012 Service Pack 1 (SP1) Express ](https://www.microsoft.com/download/details.aspx?id=35579) + - You likely just want SQL Server 2012 Express with Tools. This download includes SQL Management Studio: + - [SQL Server 2012 Express x64](http://download.microsoft.com/download/8/D/D/8DD7BDBA-CEF7-4D8E-8C16-D9F69527F909/ENU/x64/SQLEXPRWT_x64_ENU.exe) + - Here's just SQL Server 2012 Management Studio: + - [SQL Management Studio x64](http://download.microsoft.com/download/8/D/D/8DD7BDBA-CEF7-4D8E-8C16-D9F69527F909/ENU/x64/SQLManagementStudio_x64_ENU.exe) + - [SQL Management Studio x86](http://download.microsoft.com/download/8/D/D/8DD7BDBA-CEF7-4D8E-8C16-D9F69527F909/ENU/x86/SQLManagementStudio_x86_ENU.exe) +- [Download SQL Server 2008 Express R2 SP2](http://www.microsoft.com/download/details.aspx?id=30438) + - You likely just want SQL Server 2008 Express with Tools. This download includes SQL Management Studio: + - [SQL Server 2008 Express x64](http://download.microsoft.com/download/0/4/B/04BE03CD-EAF3-4797-9D8D-2E08E316C998/SQLEXPRWT_x64_ENU.exe) + - [SQL Server 2008 Express x86](http://download.microsoft.com/download/0/4/B/04BE03CD-EAF3-4797-9D8D-2E08E316C998/SQLEXPRWT_x86_ENU.exe) + - Here's just SQL Server 2008 Management Studio: + - [SQL Management Studio x64](http://download.microsoft.com/download/0/4/B/04BE03CD-EAF3-4797-9D8D-2E08E316C998/SQLManagementStudio_x64_ENU.exe) + - [SQL Management Studio x86](http://download.microsoft.com/download/0/4/B/04BE03CD-EAF3-4797-9D8D-2E08E316C998/SQLManagementStudio_x86_ENU.exe) +- [Download SQL Server 2005 Express](https://www.microsoft.com/download/details.aspx?id=21844) ## Internal Database Version and Compatibility Level @@ -296,10 +315,12 @@ SELECT name, cmptlevel FROM sysdatabases WHERE name = 'DatabaseNameHere'; To ALTER DATABASE Compatibility Level use simple command: ```sql -ALTER DATABASE database_name SET COMPATIBILITY_LEVEL = { 140 | 130 | 120 | 110 | 100 | 90 } +ALTER DATABASE database_name SET COMPATIBILITY_LEVEL = { 150 | 140 | 130 | 120 | 110 | 100 | 90 } ``` -### Internal Database Version +### Internal Database Version and Compatibility level +[The Importance of Database Compatibility Level in SQL Server](https://www.sqlskills.com/blogs/glenn/the-importance-of-database-compatibility-level-in-sql-server/) + The database version is a number stamped in the boot page of a database that indicates the SQL Server version of the most recent SQL Server instance the database was attached to. **The database version number does not equal the SQL Server version and does not equal the compatibility level should be considered as a completely different attribute of the database.** @@ -313,23 +334,25 @@ As you upgrade the database to new SQL Server edition (you can not go backward) This is done automatically regardless of what method you use to upgrade the database to the new version of SQL Server. ```sql --- 1 using DBCC PAGE to look at the boot page (9) of the database +/* 1 using DBCC PAGE to look at the boot page (9) of the database +Search dbi_version string + */ DBCC TRACEON(3604); DBCC PAGE('DatabaseName', 1, 9, 3); DBCC TRACEOFF(3604); GO --- 2 using DBCC DBINFO +/* 2 using DBCC DBINFO */ DBCC TRACEON(3604); DBCC DBINFO; DBCC TRACEOFF(3604); GO --- 3 using database property -SELECT DatabaseProperty('DatabaseNameHere','version'); +/* 3 using database property */ +SELECT DatabaseProperty('DatabaseNameHere', 'version'); GO --- 4 using RESTORE HEADERONLY for backup files, field DatabaseVersion +/* 4 using RESTORE HEADERONLY for backup files, field DatabaseVersion */ RESTORE HEADERONLY FROM DISK=N'd:\DatabseBackupFile.bak' WITH NOUNLOAD; GO ``` @@ -346,31 +369,31 @@ Execute the following query to determine the version of the Database Engine that SELECT SERVERPROPERTY('ProductVersion'); ``` -| SQL Server Version | Database Engine | Code Name | Release Year | Internal Database Version | Compatibility Level Designation | Supported Compatibility Level | -|:---------------------------------------------|----------------:|:-------------|-------------:|--------------------------:|--------------------------------:|------------------------------:| -| SQL Server 2017 | 14 | 2017 | 2017 | 869 | 140 | 140, 130, 120, 110, 100 | -| SQL Server 2016 | 13 | 2016 | 2016 | 852 | 130 | 130, 120, 110, 100 | -| Azure SQL Database | 14 | CloudDB | 2010 (2017) | 862 | 140 | 130, 120, 110, 100 | -| SQL Server 2014 | 12 | SQL14 | 2014 | 782 | 120 | 120, 110, 100 | -| SQL Server 2012 | 11 | Denali | 2012 | 706 | 110 | 110, 100, 90 | -| SQL Server 2012 CTP1 | 11 | Denali | 2010 | 684 | 110 | 110, 100, 90 | -| SQL Server 2008 R2 | 10.5 | Kilimanjaro | 2010 | 660 / 661 | 100 | 100, 90, 80 | -| SQL Server 2008 | 10 | Katmai | 2008 | 655 | 100 | 100, 90, 80 | -| SQL Server 2005 SP2+ with VarDecimal enabled | 9 | Yukon | 2005 | 612 | 90 | 90, 80 | -| SQL Server 2005 | 9 | Yukon | 2005 | 611 | 90 | 90, 80 | -| SQL Server 2000 | 8 | Shiloh | 2000 | 539 | 80 | 80 | -| SQL Server 7.0 | ? | Sphinx | 1998 | 515 | 70 | 70 | -| SQL Server 6.5 | ? | Hydra | 1996 | 408 | 65 | 65 | -| SQL Server 6.0 | ? | SQL95 | 1995 | ? | 60 | ? | -| SQL Server 4.21 | ? | SQLNT | 1993 | ? | 60 | ? | -| SQL Server 1.1 (16 bit) | ? | ? | 1991 | ? | 60 | ? | -| SQL Server 1.0 (16 bit) | ? | Ashton-Tate | 1989 | ? | 60 | ? | +| SQL Server Version | Database Engine | Code Name | Release Year | Internal DB Version | Compatibility Level Designation | Supported Compatibility Level | +|:---------------------------------------------|----------------:|:------------|-------------:|--------------------:|--------------------------------:|------------------------------:| +| SQL Server 2019 | 15 | 2019 | 2019 | 895-904 | 150 | 150, 140, 130, 120, 110 | +| SQL Server 2017 | 14 | 2017 | 2017 | 869-894 | 140 | 140, 130, 120, 110, 100 | +| SQL Server 2016 | 13 | Helsinki | 2016 | 852 | 130 | 130, 120, 110, 100 | +| Azure SQL Database | 14 | CloudDB | 2010 (2018) | 862 | 140 | 140, 130, 120, 110, 100 | +| SQL Server 2014 | 12 | Hekaton | 2014 | 782 | 120 | 120, 110, 100 | +| SQL Server 2012 | 11 | Denali | 2012 | 706 | 110 | 110, 100, 90 | +| SQL Server 2008 R2 | 10.5 | Kilimanjaro | 2010 | 660 / 661 | 100 | 100, 90, 80 | +| SQL Server 2008 | 10 | Katmai | 2008 | 655 | 100 | 100, 90, 80 | +| SQL Server 2005 SP2+ with VarDecimal enabled | 9 | Yukon | 2005 | 612 | 90 | 90, 80 | +| SQL Server 2005 | 9 | Yukon | 2005 | 611 | 90 | 90, 80 | +| SQL Server 2000 | 8 | Shiloh | 2000 | 539 | 80 | 80 | +| SQL Server 7.0 | ? | Sphinx | 1998 | 515 | 70 | 70 | +| SQL Server 6.5 | ? | Hydra | 1996 | 408 | 65 | 65 | +| SQL Server 6.0 | ? | SQL95 | 1995 | ? | 60 | ? | +| SQL Server 4.21 | ? | SQLNT | 1993 | ? | 60 | ? | +| SQL Server 1.1 (16 bit) | ? | Pietro | 1991 | ? | 60 | ? | +| SQL Server 1.0 (16 bit) | ? | Filipi | 1989 | ? | 60 | ? | **Azure SQL Database V12** was released in December 2014. One aspect of that release was that newly created databases had their compatibility level set to 120. In 2015 SQL Database began support for level 130, although the default remained 120. Starting in mid-June 2016, in Azure SQL Database, the default compatibility level will be 130 instead of 120 for newly created databases. Existing databases created before mid-June 2016 will not be affected, and will maintain their current compatibility level (100, 110, or 120). -If you want level 130 for your database generally, but you have reason to prefer the level 110 cardinality estimation algorithm, see [ALTER DATABASE SCOPED CONFIGURATION (Transact-SQL)](https://msdn.microsoft.com/en-us/library/mt629158.aspx), and in particular its keyword LEGACY_CARDINALITY_ESTIMATION =ON. +If you want level 130 for your database generally, but you have reason to prefer the level 110 cardinality estimation algorithm, see [ALTER DATABASE SCOPED CONFIGURATION (Transact-SQL)](https://msdn.microsoft.com/library/mt629158.aspx), and in particular its keyword LEGACY_CARDINALITY_ESTIMATION =ON. For details about how to assess the performance differences of your most important queries, between two compatibility levels on Azure SQL Database, see [Improved Query Performance with Compatibility Level 130 in Azure SQL Database](http://azure.microsoft.com/documentation/articles/sql-database-compatibility-level-query-performance-130/). @@ -382,642 +405,908 @@ For details about how to assess the performance differences of your most importa - [Database Version vs Database Compatibility Level](http://sqlblog.com/blogs/jonathan_kehayias/archive/2009/07/28/database-version-vs-database-compatibility-level.aspx) (by Jonathan Kehayias) -## Quick summary for SQL Server Service Packs - - -| Version | Codename | RTM (no SP) | SP1 | SP2 | SP3 | SP4 | -|:-------------------|:------------|:----------------|:---------------|:--------------------------------|:----------------------------------|:--------------------------------| -| SQL Server 2017 | 2017 | [14.0.1000.169] | | | | | -| SQL Server 2016 | 2016 | [13.0.1601.5] | [13.0.4001.0] | | | | -| SQL Server 2014 | SQL14 | 12.0.2000.8 | [12.0.4100.1] | [12.0.5000.0] | | | -| SQL Server 2012 | Denali | 11.0.2100.60 | [11.0.3000.0] | [11.0.5058.0] | [11.0.6020.0] | [11.0.7001.0] | -| SQL Server 2008 R2 | Kilimanjaro | 10.50.1600.1 | [10.50.2500.0] | [10.50.4000.0]
10.52.4000.0 | [10.50.6000.34]
10.53.6000.34 | | -| SQL Server 2008 | Katmai | 10.0.1600.22 | [10.0.2531.0] | [10.0.4000.0]
10.2.4000.0 | [10.0.5500.0]
10.3.5500.0 | [10.0.6000.29]
10.4.6000.29 | -| SQL Server 2005 | Yukon | 9.0.1399.06 | [9.0.2047] | [9.0.3042] | [9.0.4035] | [9.0.5000] | -| SQL Server 2000 | Shiloh | 8.0.194 | [8.0.384] | [8.0.532] | [8.0.760] | [8.0.2039] | -| SQL Server 7.0 | Sphinx | 7.0.623 | 7.0.699 | 7.0.842 | 7.0.961 | [7.0.1063] | - -[14.0.1000.169]:https://www.microsoft.com/en-us/sql-server/sql-server-downloads -[13.0.1601.5]:https://www.microsoft.com/en-in/evalcenter/evaluate-sql-server-2016 -[13.0.4001.0]:https://support.microsoft.com/en-us/kb/3182545 -[12.0.5000.0]:https://support.microsoft.com/en-us/kb/3171021 -[12.0.4100.1]:http://www.microsoft.com/en-us/download/details.aspx?id=46694 -[11.0.3000.0]:http://www.microsoft.com/en-us/download/details.aspx?id=35575 -[11.0.5058.0]:http://www.microsoft.com/en-us/download/details.aspx?id=43340 -[11.0.6020.0]:http://www.microsoft.com/en-us/download/details.aspx?id=49996 -[11.0.7001.0]:https://www.microsoft.com/en-us/download/details.aspx?id=56040 -[10.50.2500.0]:http://www.microsoft.com/en-us/download/details.aspx?id=26727 -[10.50.4000.0]:http://www.microsoft.com/en-us/download/details.aspx?id=30437 -[10.50.6000.34]:http://www.microsoft.com/en-us/download/details.aspx?id=44271 -[10.0.2531.0]:http://www.microsoft.com/downloads/details.aspx?familyid=66AB3DBB-BF3E-4F46-9559-CCC6A4F9DC19 -[10.0.4000.0]:http://www.microsoft.com/downloads/en/details.aspx?FamilyID=8FBFC1DE-D25E-4790-88B5-7DDA1F1D4E17 -[10.0.5500.0]:http://www.microsoft.com/download/en/details.aspx?id=27594 -[10.0.6000.29]:http://www.microsoft.com/en-us/download/details.aspx?id=44278 -[9.0.2047]:http://www.microsoft.com/downloads/details.aspx?FamilyID=CB6C71EA-D649-47FF-9176-E7CAC58FD4BC -[9.0.3042]:http://www.microsoft.com/downloads/details.aspx?FamilyId=d07219b2-1e23-49c8-8f0c-63fa18f26d3a -[9.0.4035]:http://www.microsoft.com/downloads/details.aspx?FamilyId=ae7387c3-348c-4faa-8ae5-949fdfbe59c4 -[9.0.5000]:http://www.microsoft.com/downloads/details.aspx?FamilyId=b953e84f-9307-405e-bceb-47bd345baece -[8.0.384]:http://www.microsoft.com/downloads/details.aspx?FamilyID=DFF43C50-51DF-4FE0-9717-DE41FB48556E -[8.0.532]:http://www.microsoft.com/downloads/details.aspx?FamilyID=75672496-af8e-40dc-853e-ad2c9fe96882 -[8.0.760]:http://www.microsoft.com/downloads/details.aspx?familyid=90DCD52C-0488-4E46-AFBF-ACACE5369FA3 -[8.0.2039]:http://www.microsoft.com/downloads/details.aspx?FamilyId=8E2DFC8D-C20E-4446-99A9-B7F0213F8BC5 -[7.0.1063]:https://www.microsoft.com/en-us/download/details.aspx?id=7959 +## Microsoft SQL Server 2019 Builds + +More additional information about latest vNext SQL Server release you can find in this articles: + - [What's new in SQL Server 2019](https://docs.microsoft.com/sql/sql-server/what-s-new-in-sql-server-ver15?view=sql-server-ver15#utf-8-support) + - [What’s New in SQL Server 2019 System Tables](https://www.brentozar.com/archive/2018/09/whats-new-in-sql-server-2019-system-tables/) + - [What’s New in SQL Server 2019’s sys.messages: More Unannounced Features](https://www.brentozar.com/archive/2018/09/whats-new-in-sql-server-2019s-sys-messages-more-unannounced-features/) + - [What’s New in SQL Server 2019: Faster Table Variables (And New Parameter Sniffing Issues)](https://www.brentozar.com/archive/2018/09/sql-server-2019-faster-table-variables-and-new-parameter-sniffing-issues/) + - [What’s New in SQL Server 2019: Adaptive Memory Grants](https://www.brentozar.com/archive/2018/09/whats-new-in-sql-server-2019-adaptive-memory-grants/) + - [Leaked: SQL Server 2019 Big Data Clusters Introduction Video](https://www.brentozar.com/archive/2018/09/leaked-sql-server-2019-big-data-clusters-introduction-video/) + +Here is the latest output from `SELECT @@VERSION` for SQL Server 2019 CTP Developer Edition: + +``` +Microsoft SQL Server 2019 (RTM-CU12) (KB5004524) - 15.0.4153.1 (X64) + Jul 19 2021 15:37:34 + Copyright (C) 2019 Microsoft Corporation + Developer Edition (64-bit) on … +``` + +| Build | File version | Branch | Type | Info | KB | Description/Link | Release Date | Build Date | Fixes | Public | Size, Mb | DB Version | +|---------------|-------------------|--------|------|---------------|---------|-------------------------------------------------------------|--------------|------------|------:|-------:|---------:|-----------:| +| 15.0.4153.1 | 2019.150.4153.1 | RTM | CU | **Latest CU** | 5004524 | [Cumulative Update 12 for SQL Server 2019] | 2021-08-04 | ? | 40 | 29 | 669 | 904 | +| 15.0.4138.2 | 2019.150.4138.2 | RTM | CU | | 5003249 | [Cumulative Update 11 for SQL Server 2019] | 2021-06-10 | ? | 62 | 35 | ? | 904 | +| 15.0.4123.1 | 2019.150.4123.1 | RTM | CU | | 5001090 | [Cumulative Update 10 for SQL Server 2019] | 2021-04-06 | ? | 63 | 39 | ? | 904 | +| 15.0.4102.2 | 2019.150.4102.2 | RTM | CU | | 5000642 | [Cumulative Update 9 for SQL Server 2019] | 2021-02-11 | ? | 140 | 89 | ? | 904 | +| 15.0.4083.2 | 2019.150.4083.2 | RTM | GDR | CVE-2021-1636 | 4583459 | [Security update for SQL Server 2019 CU8: January 12, 2021] | 2021-01-12 | ? | 1 | 1 | ? | 904 | +| 15.0.4073.23 | 2019.150.4073.23 | RTM | CU | | 4577194 | [Cumulative Update 8 for SQL Server 2019] | 2020-10-01 | 2020-07-25 | 104 | 81 | 607 | 904 | +| 15.0.4063.15 | 2019.150.4063.15 | RTM | CU | **Withdrawn** | 4570012 | [Cumulative Update 7 for SQL Server 2019] | 2020-09-02 | 2020-07-25 | 56 | 49 | 604 | 904 | +| 15.0.4053.23 | 2019.150.4053.23 | RTM | CU | | 4563110 | [Cumulative Update 6 for SQL Server 2019] | 2020-08-04 | 2020-07-25 | 51 | 42 | 604 | 904 | +| 15.0.4043.16 | 2019.150.4043.16 | RTM | CU | | 4552255 | [Cumulative Update 5 for SQL Server 2019] | 2020-06-22 | 2020-06-10 | 86 | 58 | 603 | 904 | +| 15.0.4033.1 | 2019.150.4033.1 | RTM | CU | | 4548597 | [Cumulative Update 4 for SQL Server 2019] | 2020-03-31 | 2020-03-04 | 50 | 38 | 571 | 904 | +| 15.0.4023.6 | 2019.150.4023.6 | RTM | CU | | 4538853 | [Cumulative Update 3 for SQL Server 2019] | 2020-03-12 | 2020-02-20 | 56 | 11 | 572 | 904 | +| 15.0.4013.40 | 2019.150.4013.40 | RTM | CU | | 4536075 | [Cumulative Update 2 for SQL Server 2019] | 2020-02-07 | 2020-02-03 | 134 | 88 | 537 | 904 | +| 15.0.4003.23 | 2019.150.4003.23 | RTM | CU | | 4527376 | [Cumulative Update 1 for SQL Server 2019] | 2020-01-07 | 2019-12-06 | 83 | 62 | 452 | 904 | +| 15.0.2070.41 | 2019.150.2070.41 | RTM | GDR | | 4517790 | [Servicing Update for SQL Server 2019 RTM] | 2019-11-04 | 2019-10-28 | 1 | 1 | 452 | 904 | +| 15.0.2000.5 | 2019.150.2000.5 | RTM | RTM | | | [Microsoft SQL Server 2019 RTM] | 2019-11-04 | 2019-09-24 | | | 1360 | 904 | +| 15.0.1900.47 | 2019.150.1900.47 | CTP | RC | | | Microsoft SQL Server 2019 Release Candidate 1.1 (RC1.1) | 2019-08-28 | 2019-08-17 | | | 1360 | 904 | +| 15.0.1900.25 | 2019.150.1900.25 | CTP | RC | | | Microsoft SQL Server 2019 Release Candidate 1 (RC1) | 2019-08-21 | 2019-08-17 | | | 1360 | 904 | +| 15.0.1800.32 | 2019.150.1800.32 | CTP | CTP | | | Microsoft SQL Server 2019 CTP3.2 | 2019-07-24 | 2019-07-18 | | | 1358 | 904 | +| 15.0.1700.0 | 2019.150.1700.0 | CTP | CTP | | | Microsoft SQL Server 2019 CTP3.1 | 2019-06-26 | 2019-06-20 | | | 1341 | 902 | +| 15.0.1600.8 | 2019.150.1600.8 | CTP | CTP | | | Microsoft SQL Server 2019 CTP3.0 | 2019-05-22 | 2019-05-17 | | | 1339 | 902 | +| 15.0.1500.28 | 2019.150.1500.28 | CTP | CTP | | | Microsoft SQL Server 2019 CTP2.5 | 2019-04-23 | 2019-04-16 | | | 1340 | 897 | +| 15.0.1400.75 | 2019.150.1400.75 | CTP | CTP | | | Microsoft SQL Server 2019 CTP2.4 | 2019-03-27 | 2019-03-17 | | | 1331 | 897 | +| 15.0.1300.359 | 2019.150.1200.359 | CTP | CTP | | | Microsoft SQL Server 2019 CTP2.3 | 2019-03-01 | 2019-02-16 | | | 1331 | 897 | +| 15.0.1200.24 | 2018.150.1200.24 | CTP | CTP | | | Microsoft SQL Server 2019 CTP2.2 | 2018-12-11 | 2018-11-02 | | | 1302 | 896 | +| 15.0.1100.94 | 2018.150.1100.34 | CTP | CTP | | | Microsoft SQL Server 2019 CTP2.1 | 2018-11-06 | 2018-11-02 | | | 1299 | 896 | +| 15.0.1000.34 | 2018.150.1000.34 | CTP | CTP | | | Microsoft SQL Server 2019 CTP2.0 | 2018-09-24 | 2018-09-18 | | | 1532 | 895 | + +[Cumulative Update 12 for SQL Server 2019]:https://support.microsoft.com/help/5003249 +[Cumulative Update 11 for SQL Server 2019]:https://support.microsoft.com/help/5003249 +[Cumulative Update 10 for SQL Server 2019]:https://support.microsoft.com/help/5001090 +[Cumulative Update 9 for SQL Server 2019]:https://support.microsoft.com/help/5000642 +[Security update for SQL Server 2019 CU8: January 12, 2021]:https://support.microsoft.com/help/4583459 +[Cumulative Update 8 for SQL Server 2019]:https://support.microsoft.com/help/4577194 +[Cumulative Update 7 for SQL Server 2019]:https://support.microsoft.com/help/4570012 +[Cumulative Update 6 for SQL Server 2019]:https://support.microsoft.com/help/4563110 +[Cumulative Update 5 for SQL Server 2019]:https://support.microsoft.com/help/4552255 +[Cumulative Update 4 for SQL Server 2019]:https://support.microsoft.com/help/4548597 +[Cumulative Update 3 for SQL Server 2019]:https://support.microsoft.com/help/4538853 +[Cumulative Update 2 for SQL Server 2019]:https://support.microsoft.com/help/4536075 +[Cumulative Update 1 for SQL Server 2019]:https://support.microsoft.com/help/4527376 +[Servicing Update for SQL Server 2019 RTM]:https://support.microsoft.com/help/4517790 +[Microsoft SQL Server 2019 RTM]:https://www.microsoft.com/sql-server/sql-server-2019#Install ## Microsoft SQL Server 2017 Builds + +All SQL Server 2017 CU downloads: [Catalog Update Microsoft SQL Server 2017](http://www.catalog.update.microsoft.com/Search.aspx?q=sql%20server%202017) + Here is the latest output from `SELECT @@VERSION` for SQL Server 2017 Developer Edition: ``` -Microsoft SQL Server 2017 (RTM-CU3-GDR) (KB4052987) - 14.0.3015.40 (X64) - Dec 22 2017 16:13:22 - Copyright (C) 2017 Microsoft Corporation - Developer Edition (64-bit) on … +Microsoft SQL Server 2017 (RTM-CU26) (KB5005226) - 14.0.3411.3 (X64) + Aug 28 2021 21:00:00 + Copyright (C) 2017 Microsoft Corporation + Developer Edition (64-bit) on … ``` -Useful articles: - - [How I spot not-yet-documented features in SQL Server CTPs](https://blogs.sentryone.com/aaronbertrand/fishing-for-features-in-ctps/) - - [More ways to discover changes in new versions of SQL Server](https://blogs.sentryone.com/aaronbertrand/more-changes-sql-server/) - -| Build | File version | Branch | Type | KB / Description | Release Date | Build Date | Fixes | Public | Size, Mb | -|---------------|-------------------|--------|------|----------------------------------------------------------------------|--------------|------------|------:|-------:|---------:| -| 14.0.3015.40 | 2017.140.3015.40 | RTM | CU | [4052987 Microsoft SQL Server 2017 CU3] | 2017-01-03 | 2017-12-23 | 14 | 13 | 459 | -| 14.0.3008.27 | 2017.140.3008.27 | RTM | CU | [4052574 Microsoft SQL Server 2017 CU2] | 2017-11-28 | 2017-11-16 | 56 | 33 | 276 | -| 14.0.3006.16 | 2017.140.3006.16 | RTM | CU | [4038634 Microsoft SQL Server 2017 CU1] | 2017-10-24 | 2017-10-19 | 72 | 68 | 250 | -| 14.0.1000.169 | 2017.140.1000.169 | RTM | RTM | [Microsoft SQL Server 2017 RTM] | 2017-10-02 | 2017-08-23 | | | 1475 | -| 14.0.900.75 | 2017.140.900.75 | RC | RC | Microsoft SQL Server 2017 Release Candidate 2 | 2017-08-02 | 2017-07-27 | | | 1473 | -| 14.0.800.90 | 2017.140.800.90 | RC | RC | Microsoft SQL Server 2017 Release Candidate 1 | 2017-07-17 | 2017-07-11 | | | 1473 | -| 14.0.600.250 | 2017.140.600.250 | CTP | CTP | Microsoft SQL Server 2017 Community Technology Preview 2.1 (CTP2.1) | 2017-05-17 | 2017-05-10 | | | 1606 | -| 14.0.500.272 | 2017.140.500.272 | CTP | CTP | Microsoft SQL Server vNext Community Technology Preview 2.0 (CTP2.0) | 2017-04-19 | 2017-04-13 | | | 1721 | -| 14.0.405.198 | 2017.140.405.198 | CTP | CTP | Microsoft SQL Server vNext Community Technology Preview 1.4 (CTP1.4) | 2017-03-17 | 2017-03-11 | | | 2001 | -| 14.0.304.138 | 2016.140.304.138 | CTP | CTP | Microsoft SQL Server vNext Community Technology Preview 1.3 (CTP1.3) | 2017-02-17 | 2017-02-14 | | | 1978 | -| 14.0.200.24 | 2016.140.200.24 | CTP | CTP | Microsoft SQL Server vNext Community Technology Preview 1.2 (CTP1.2) | 2017-01-18 | 2017-01-11 | | | 1975 | -| 14.0.100.187 | 2016.140.100.187 | CTP | CTP | Microsoft SQL Server vNext Community Technology Preview 1.1 (CTP1.1) | 2016-12-16 | 2016-12-11 | | | 1975 | -| 14.0.1.246 | 2016.140.1.246 | CTP | CTP | Microsoft SQL Server vNext Community Technology Preview 1 (CTP1) | 2016-11-16 | 2016-11-02 | | | 1983 | - -[4052987 Microsoft SQL Server 2017 CU3]:https://support.microsoft.com/en-us/help/4052987/cumulative-update-3-for-sql-server-2017 -[4052574 Microsoft SQL Server 2017 CU2]:https://support.microsoft.com/en-us/help/4052574/cumulative-update-2-for-sql-server-2017 -[4038634 Microsoft SQL Server 2017 CU1]:https://support.microsoft.com/en-us/help/4038634/cumulative-update-1-for-sql-server-2017 -[Microsoft SQL Server 2017 RTM]:https://www.microsoft.com/en-us/sql-server/sql-server-downloads +| Build | File version | Branch | Type | Info | KB | Description/Link | Release Date | Build Date | Fixes | Public | Size, Mb | +|---------------|-------------------|--------|------|-----------------------------------|---------|-------------------------------------------------------------------------------------|--------------|------------|------:|-------:|---------:| +| 14.0.3411.3 | 2017.140.3411.3 | RTM | CU | **Latest CU** | 5005226 | [Microsoft SQL Server 2017 CU26] | 2021-07-12 | 2021-09-14 | 31 | 22 | 533 | +| 14.0.3401.7 | 2017.140.3401.7 | RTM | CU | | 5003830 | [Microsoft SQL Server 2017 CU25] | 2021-07-12 | 2021-06-26 | 19 | 18 | 533 | +| 14.0.3391.2 | 2017.140.3391.2 | RTM | CU | | 5001228 | [Microsoft SQL Server 2017 CU24] | 2021-05-10 | ? | 30 | 24 | 533 | +| 14.0.3381.3 | 2017.140.3381.3 | RTM | CU | | 5000685 | [Microsoft SQL Server 2017 CU23] | 2021-02-24 | ? | 58 | 47 | 533 | +| 14.0.3370.1 | 2017.140.3370.1 | RTM | GDR | CVE-2021-1636 | 4583457 | [Description of the security update for SQL Server 2017 CU22: January 12, 2021] | 2021-01-12 | ? | 1 | 1 | 533 | +| 14.0.3356.20 | 2017.140.3356.20 | RTM | CU | | 4577467 | [Microsoft SQL Server 2017 CU22] | 2020-09-10 | ? | 42 | 38 | 533 | +| 14.0.3335.7 | 2017.140.3335.7 | RTM | CU | | 4535007 | [Microsoft SQL Server 2017 CU21] | 2020-07-01 | 2020-06-13 | 35 | 33 | 533 | +| 14.0.3294.2 | 2017.140.3294.2 | RTM | CU | | 4541283 | [Microsoft SQL Server 2017 CU20] | 2020-04-07 | 2020-03-14 | 40 | 36 | 530 | +| 14.0.3281.6 | 2017.140.3281.6 | RTM | CU | | 4535007 | [Microsoft SQL Server 2017 CU19] | 2020-02-05 | 2020-01-23 | 38 | 31 | 530 | +| 14.0.3257.3 | 2017.140.3257.3 | RTM | CU | | 4527377 | [Microsoft SQL Server 2017 CU18] | 2019-12-09 | 2019-11-16 | 35 | 28 | 529 | +| 14.0.3238.1 | 2017.140.3238.1 | RTM | CU | | 4515579 | [Microsoft SQL Server 2017 CU17] | 2019-10-01 | 2019-09-14 | 41 | 34 | 528 | +| 14.0.3223.3 | 2017.140.3223.3 | RTM | CU | | 4508218 | [Microsoft SQL Server 2017 CU16] | 2019-08-01 | 2019-07-13 | 50 | 37 | 529 | +| 14.0.3208.1 | 2017.140.3208.1 | RTM | COD | | 4510083 | [On-demand hotfix update package 2 for SQL Server 2017 Cumulative update 15 (CU15)] | 2019-07-09 | 2019-06-26 | 2 | 2 | 528 | +| 14.0.3192.2 | 2017.140.3192.2 | RTM | GDR | CVE-2019-1068 | 4505225 | [Security update for SQL Server 2017 CU15 GDR: July 9, 2019] | 2019-07-09 | 2019-06-26 | 1 | 1 | 528 | +| 14.0.3164.1 | 2017.140.3164.1 | RTM | COD | | 4506633 | [On-demand hotfix update package for SQL Server 2017 Cumulative update 15 (CU15)] | 2019-06-20 | 2019-05-16 | 1 | 1 | 528 | +| 14.0.3162.1 | 2017.140.3162.1 | RTM | CU | | 4498951 | [Microsoft SQL Server 2017 CU15] | 2019-05-23 | 2019-05-16 | 52 | 45 | 528 | +| 14.0.3103.1 | 2017.140.3103.1 | RTM | GDR | CVE-2019-0819 | 4494352 | [Description of the security update for SQL Server 2017 CU 14 GDR: May 14, 2019] | 2019-05-14 | 2019-03-23 | 1 | 1 | 491 | +| 14.0.3076.1 | 2017.140.3076.1 | RTM | CU | | 4484710 | [Microsoft SQL Server 2017 CU14] | 2019-03-25 | 2019-03-12 | 51 | 34 | 491 | +| 14.0.3049.1 | 2017.140.3049.1 | RTM | COD | | 4483666 | [On-demand hotfix update package for SQL Server 2017 CU13] | 2019-01-08 | 2018-12-15 | 3 | 3 | 488 | +| 14.0.3048.4 | 2017.140.3048.4 | RTM | CU | **Withdrawn** | 4466404 | [Microsoft SQL Server 2017 CU13] | 2018-12-18 | 2018-12-01 | 62 | 50 | 488 | +| 14.0.3045.24 | 2017.140.3045.24 | RTM | CU | | 4464082 | [Microsoft SQL Server 2017 CU12] | 2018-10-24 | 2018-10-19 | 22 | 18 | 488 | +| 14.0.3038.14 | 2017.140.3038.14 | RTM | CU | | 4462262 | [Microsoft SQL Server 2017 CU11] | 2018-09-20 | 2018-09-14 | 21 | 14 | 487 | +| 14.0.3037.1 | 2017.140.3037.1 | RTM | CU | | 4342123 | [Microsoft SQL Server 2017 CU10] | 2018-08-27 | 2018-07-27 | 30 | 22 | 486 | +| 14.0.3035.2 | 2017.140.3035.2 | RTM | COD | CVE-2018-8273 | 4293805 | [Security update for SQL Server 2017 CU: August 14, 2018] | 2018-08-14 | 2018-07-07 | 1 | 1 | 486 | +| 14.0.3030.27 | 2017.140.3030.27 | RTM | CU | | 4341265 | [Microsoft SQL Server 2017 CU9] | 2018-07-18 | 2018-06-30 | 27 | 18 | 486 | +| 14.0.3029.16 | 2017.140.3029.16 | RTM | CU | | 4338363 | [Microsoft SQL Server 2017 CU8] | 2018-06-21 | 2018-06-13 | 60 | 31 | 475 | +| 14.0.3026.27 | 2017.140.3026.27 | RTM | CU | | 4229789 | [Microsoft SQL Server 2017 CU7] | 2018-05-24 | 2018-05-10 | 47 | 28 | 473 | +| 14.0.3025.34 | 2017.140.3025.34 | RTM | CU | | 4101464 | [Microsoft SQL Server 2017 CU6] | 2018-04-19 | 2018-03-03 | 39 | 39 | 473 | +| 14.0.3023.8 | 2017.140.3023.8 | RTM | CU | | 4092643 | [Microsoft SQL Server 2017 CU5] | 2018-03-20 | 2018-03-03 | 22 | 13 | 472 | +| 14.0.3022.28 | 2017.140.3022.28 | RTM | CU | | 4056498 | [Microsoft SQL Server 2017 CU4] | 2018-02-20 | 2018-02-10 | 81 | 55 | 472 | +| 14.0.3015.40 | 2017.140.3015.40 | RTM | CU | | 4052987 | [Microsoft SQL Server 2017 CU3] | 2017-01-03 | 2017-12-23 | 14 | 13 | 459 | +| 14.0.3008.27 | 2017.140.3008.27 | RTM | CU | | 4052574 | [Microsoft SQL Server 2017 CU2] | 2017-11-28 | 2017-11-16 | 56 | 33 | 276 | +| 14.0.3006.16 | 2017.140.3006.16 | RTM | CU | | 4038634 | [Microsoft SQL Server 2017 CU1] | 2017-10-24 | 2017-10-19 | 72 | 68 | 250 | +| 14.0.2027.2 | 2017.140.2027.2 | RTM | GDR | CVE-2019-1068 | 4505224 | [Security update for SQL Server 2017 GDR: July 9, 2019] | 2019-07-09 | 2019-06-15 | 1 | 1 | 447 | +| 14.0.2014.14 | 2017.140.2014.14 | RTM | GDR | CVE-2019-0819 | 4494351 | [Security update for SQL Server 2017 GDR: May 14, 2019] | 2019-05-14 | 2019-04-05 | 1 | 1 | 447 | +| 14.0.2002.14 | 2017.140.2002.14 | RTM | GDR | CVE-2018-8273 | 4293803 | [Security update for SQL Server 2017 GDR: August 14, 2018] | 2018-08-14 | 2018-07-21 | 1 | 1 | 433 | +| 14.0.2000.63 | 2017.140.2000.63 | RTM | GDR | CVE-2017-5715,2017-5753,2017-5754 | 4057122 | [Security update for SQL Server 2017 GDR: January 3, 2018] | 2018-01-03 | 2017-12-23 | 1 | 1 | 431 | +| 14.0.1000.169 | 2017.140.1000.169 | RTM | RTM | | | [Microsoft SQL Server 2017 RTM] | 2017-10-02 | 2017-08-23 | | | 1475 | +| 14.0.900.75 | 2017.140.900.75 | RC | RC | | | Microsoft SQL Server 2017 Release Candidate 2 | 2017-08-02 | 2017-07-27 | | | 1473 | +| 14.0.800.90 | 2017.140.800.90 | RC | RC | | | Microsoft SQL Server 2017 Release Candidate 1 | 2017-07-17 | 2017-07-11 | | | 1473 | +| 14.0.600.250 | 2017.140.600.250 | CTP | CTP | | | Microsoft SQL Server 2017 Community Technology Preview 2.1 (CTP2.1) | 2017-05-17 | 2017-05-10 | | | 1606 | +| 14.0.500.272 | 2017.140.500.272 | CTP | CTP | | | Microsoft SQL Server vNext Community Technology Preview 2.0 (CTP2.0) | 2017-04-19 | 2017-04-13 | | | 1721 | +| 14.0.405.198 | 2017.140.405.198 | CTP | CTP | | | Microsoft SQL Server vNext Community Technology Preview 1.4 (CTP1.4) | 2017-03-17 | 2017-03-11 | | | 2001 | +| 14.0.304.138 | 2016.140.304.138 | CTP | CTP | | | Microsoft SQL Server vNext Community Technology Preview 1.3 (CTP1.3) | 2017-02-17 | 2017-02-14 | | | 1978 | +| 14.0.200.24 | 2016.140.200.24 | CTP | CTP | | | Microsoft SQL Server vNext Community Technology Preview 1.2 (CTP1.2) | 2017-01-18 | 2017-01-11 | | | 1975 | +| 14.0.100.187 | 2016.140.100.187 | CTP | CTP | | | Microsoft SQL Server vNext Community Technology Preview 1.1 (CTP1.1) | 2016-12-16 | 2016-12-11 | | | 1975 | +| 14.0.1.246 | 2016.140.1.246 | CTP | CTP | | | Microsoft SQL Server vNext Community Technology Preview 1 (CTP1) | 2016-11-16 | 2016-11-02 | | | 1983 | + +[Microsoft SQL Server 2017 CU26]:https://support.microsoft.com/help/5005226 +[Microsoft SQL Server 2017 CU25]:https://support.microsoft.com/help/5003830 +[Microsoft SQL Server 2017 CU24]:https://support.microsoft.com/help/5001228 +[Microsoft SQL Server 2017 CU23]:https://support.microsoft.com/help/5000685 +[Description of the security update for SQL Server 2017 CU22: January 12, 2021]:https://support.microsoft.com/help/4583457 +[Microsoft SQL Server 2017 CU22]:https://support.microsoft.com/help/4577467 +[Microsoft SQL Server 2017 CU21]:https://support.microsoft.com/help/4557397 +[Microsoft SQL Server 2017 CU20]:https://support.microsoft.com/help/4541283 +[Microsoft SQL Server 2017 CU19]:https://support.microsoft.com/help/4535007 +[Microsoft SQL Server 2017 CU18]:https://support.microsoft.com/help/4527377 +[Microsoft SQL Server 2017 CU17]:https://support.microsoft.com/help/4515579 +[Microsoft SQL Server 2017 CU16]:https://support.microsoft.com/help/4508218 +[On-demand hotfix update package 2 for SQL Server 2017 Cumulative update 15 (CU15)]:https://support.microsoft.com/help/4510083/ +[Security update for SQL Server 2017 CU15 GDR: July 9, 2019]:https://support.microsoft.com/help/4505225/ +[On-demand hotfix update package for SQL Server 2017 Cumulative update 15 (CU15)]:https://support.microsoft.com/help/4506633/ +[Microsoft SQL Server 2017 CU15]:https://support.microsoft.com/help/4498951/ +[Description of the security update for SQL Server 2017 CU 14 GDR: May 14, 2019]:https://support.microsoft.com/help/4494352 +[Microsoft SQL Server 2017 CU14]:https://support.microsoft.com/help/4484710 +[On-demand hotfix update package for SQL Server 2017 CU13]:https://support.microsoft.com/help/4483666 +[Microsoft SQL Server 2017 CU13]:https://support.microsoft.com/help/4466404 +[Microsoft SQL Server 2017 CU12]:https://support.microsoft.com/help/4464082 +[Microsoft SQL Server 2017 CU11]:https://support.microsoft.com/help/4462262 +[Microsoft SQL Server 2017 CU10]:https://support.microsoft.com/help/4342123 +[Security update for SQL Server 2017 CU: August 14, 2018]:https://support.microsoft.com/help/4293805 +[Microsoft SQL Server 2017 CU9]:https://support.microsoft.com/help/4341265 +[Microsoft SQL Server 2017 CU8]:https://support.microsoft.com/help/4338363 +[Microsoft SQL Server 2017 CU7]:https://support.microsoft.com/help/4229789 +[Microsoft SQL Server 2017 CU6]:https://support.microsoft.com/help/4101464 +[Microsoft SQL Server 2017 CU5]:https://support.microsoft.com/help/4092643 +[Microsoft SQL Server 2017 CU4]:https://support.microsoft.com/help/4056498 +[Microsoft SQL Server 2017 CU3]:https://support.microsoft.com/help/4052987 +[Microsoft SQL Server 2017 CU2]:https://support.microsoft.com/help/4052574 +[Security update for SQL Server 2017 GDR: July 9, 2019]:https://support.microsoft.com/help/4505224 +[Security update for SQL Server 2017 GDR: May 14, 2019]:https://support.microsoft.com/help/4494351 +[Microsoft SQL Server 2017 CU1]:https://support.microsoft.com/help/4038634 +[Security update for SQL Server 2017 GDR: August 14, 2018]:https://support.microsoft.com/help/4293803 +[Security update for SQL Server 2017 GDR: January 3, 2018]:https://support.microsoft.com/help/4057122 +[Microsoft SQL Server 2017 RTM]:https://www.microsoft.com/sql-server/sql-server-downloads -## Microsoft SQL Server 2016 Builds -Here is the latest output from `SELECT @@VERSION` for SQL Server 2016 Developer Edition on Windows: +## Microsoft SQL Server 2016 Builds + +All SQL Server 2016 CU downloads: [Catalog Update Microsoft SQL Server 2016](http://www.catalog.update.microsoft.com/Search.aspx?q=sql%20server%202016) +Here is the latest output from `SELECT @@VERSION` for SQL Server 2016 SP2 Developer Edition on Windows: ``` -Microsoft SQL Server 2016 (SP1-CU6) (KB4037354) – 13.0.4457.0 (X64) - Nov 8 2017 17:32:23 - Copyright (c) Microsoft Corporation - Developer Edition (64-bit) on Windows … +Microsoft SQL Server 2016 (SP2-CU17) (KB5001092) - 13.0.5888.11 (X64) + Mar 20 2021 08:57:07 + Copyright (c) Microsoft Corporation + Developer Edition (64-bit) on … ``` -| Build | File version | Branch | Type | KB / Description | Release Date | Build Date | Fixes | Public | Size, Mb | -|---------------|-------------------|--------|------|--------------------------------------------------------------------------------------------------------------------------------|--------------|------------|------:|-------:|---------:| -| 13.0.4466.4 | 2015.130.4466.4 | SP1 | CU | [4057119 Cumulative Update 7 for SQL Server 2016 SP1] | 2018-01-03 | 2017-11-09 | 15 | 14 | 758 | -| 13.0.4457.0 | 2015.130.4457.0 | SP1 | CU | [4037354 Cumulative Update 6 for SQL Server 2016 SP1] | 2017-11-21 | 2017-11-09 | 55 | 41 | 689 | -| 13.0.4451.0 | 2015.130.4451.0 | SP1 | CU | [4040714 Cumulative Update 5 for SQL Server 2016 SP1] | 2017-09-18 | 2017-09-06 | 49 | 44 | 689 | -| 13.0.4446.0 | 2015.130.4446.0 | SP1 | CU | [4024305 Cumulative Update 4 for SQL Server 2016 SP1] | 2017-08-08 | 2017-07-16 | 63 | 49 | 534 | -| 13.0.4435.0 | 2015.130.4435.0 | SP1 | CU | [4019916 Cumulative Update 3 for SQL Server 2016 SP1] | 2017-05-15 | 2017-04-27 | 70 | 57 | 534 | -| 13.0.4422.0 | 2015.130.4422.0 | SP1 | CU | [4013106 Cumulative Update 2 for SQL Server 2016 SP1] | 2017-03-20 | 2017-03-06 | 117 | 100 | 415 | -| 13.0.4411.0 | 2015.130.4411.0 | SP1 | CU | [3208177 Cumulative update 1 for SQL Server 2016 Service Pack 1] | 2017-01-18 | 2017-01-06 | 63 | 55 | 439 | -| 13.0.4206.0 | 2015.130.4206.0 | SP1 | COD | [4019089 Description of the security update for SQL Server 2016 Service Pack 1 GDR: August 8, 2017] | 2017-07-16 | ? | 1 | 1 | 364 | -| 13.0.4202.0 | 2015.130.4202.0 | SP1 | COD | [3210089 GDR update package for SQL Server 2016 SP1] | 2016-12-16 | 2016-12-13 | 3 | 3 | 378 | -| 13.0.4199.0 | 2015.130.4199.0 | SP1 | COD | [3207512 Important update for SQL Server 2016 SP1 Reporting Services] | 2016-11-23 | 2016-11-18 | 2 | 2 | 521 | -| 13.0.4001.0 | 2015.130.4001.0 | SP1 | SP | [3182545 SQL Server 2016 Service Pack 1 release information] | 2016-11-16 | 2016-10-29 | 33 | 33 | 552 | -| 13.0.2216.0 | 2015.130.2216.0 | RTM | CU | [4037357 Cumulative Update 9 for SQL Server 2016] | 2017-11-21 | 2017-11-09 | 26 | 21 | 865 | -| 13.0.2213.0 | 2015.130.2213.0 | RTM | CU | [4040713 Cumulative Update 8 for SQL Server 2016] | 2017-09-18 | 2017-09-06 | 19 | 17 | 864 | -| 13.0.2210.0 | 2015.130.2210.0 | RTM | CU | [4024304 Cumulative Update 7 for SQL Server 2016] | 2017-08-08 | 2017-07-16 | 33 | 30 | 815 | -| 13.0.2204.0 | 2015.130.2204.0 | RTM | CU | [4019914 Cumulative Update 6 for SQL Server 2016] | 2017-05-15 | 2017-04-20 | 28 | 22 | 814 | -| 13.0.2197.0 | 2015.130.2197.0 | RTM | CU | [4013105 Cumulative Update 5 for SQL Server 2016] | 2017-03-20 | 2017-02-25 | 56 | 47 | 700 | -| 13.0.2193.0 | 2015.130.2193.0 | RTM | CU | [3205052 Cumulative update 4 for SQL Server 2016] | 2017-01-18 | 2017-01-06 | 65 | 57 | 699 | -| 13.0.2190.2 | 2015.130.2190.2 | RTM | COD | [3210110 On-demand hotfix update package for SQL Server 2016 CU3] | 2016-12-16 | 2016-12-13 | 3 | 3 | 691 | -| 13.0.2186.6 | 2015.130.2186.6 | RTM | CU | [3194717 MS16-136: Description of the security update for SQL Server 2016 CU] | 2016-11-08 | 2016-10-31 | 31 | 31 | 691 | -| 13.0.2186.6 | 2015.130.2186.6 | RTM | CU | [3205413 Cumulative update 3 for SQL Server 2016] **Duplicate KB3194717** | 2016-11-08 | 2016-10-31 | | | 691 | -| 13.0.2170.0 | 2015.130.2170.0 | RTM | COD | [3199171 On-demand hotfix update package for SQL Server 2016 CU2] | 2016-11-01 | 2016-10-11 | 4 | 4 | 689 | -| 13.0.2169.0 | 2015.130.2169.0 | RTM | COD | [3195813 On-demand hotfix update package for SQL Server 2016 CU2] | 2016-10-26 | 2016-10-05 | 4 | 4 | 689 | -| 13.0.2164.0 | 2015.130.2164.0 | RTM | CU | [3182270 Cumulative Update 2 for SQL Server 2016] | 2016-09-22 | 2016-09-09 | 68 | 64 | 689 | -| 13.0.2149.0 | 2015.130.2149.0 | RTM | CU | [3164674 Cumulative Update 1 for SQL Server 2016] | 2016-07-25 | 2016-07-11 | 192 | 146 | 665 | -| 13.0.1722.0 | 2015.130.1722.0 | RTM | COD | [3194716 MS16-136: Description of the security update for SQL Server 2016 GDR] | 2016-11-08 | 2016-10-31 | 3 | 3 | 342 | -| 13.0.1711.0 | 2015.130.1711.0 | RTM | COD | [3179258 Processing a partition causes data loss on other partitions after the database is restored in SQL Server 2016 (1200)] | 2016-08-17 | 2016-07-30 | | | 282 | -| 13.0.1708.0 | 2015.130.1708.0 | RTM | COD | [3164398 Critical update for SQL Server 2016 MSVCRT prerequisites] | 2016-06-04 | 2016-06-02 | | | 265 | -| 13.0.1601.5 | 2015.130.1601.5 | RTM | RTM | [Microsoft SQL Server 2016 RTM] | 2016-06-01 | 2016-04-29 | | | 2050 | -| 13.0.1400.361 | 2015.130.1400.361 | RC | RC | Microsoft SQL Server 2016 Community Technology Release Candidate 3 (RC3) | 2016-04-15 | 2016-04-09 | | | 2114 | -| 13.0.1300.275 | 2015.130.1300.275 | RC | RC | Microsoft SQL Server 2016 Community Technology Release Candidate 2 (RC2) | 2016-04-01 | 2016-03-26 | | | 2101 | -| 13.0.1200.242 | 2015.130.1200.242 | RC | RC | Microsoft SQL Server 2016 Community Technology Release Candidate 1 (RC1) | 2016-03-18 | 2016-03-10 | | | 2083 | -| 13.0.1100.288 | 2015.130.1100.288 | RC | RC | Microsoft SQL Server 2016 Community Technology Release Candidate 0 (RC0) | 2016-03-07 | 2016-02-29 | | | | -| 13.0.1000.281 | 2015.130.1000.281 | CTP | CTP | Microsoft SQL Server 2016 Community Technology Preview 3.3 (CTP3.3) | 2016-02-03 | 2016-01-28 | | | | -| 13.0.900.73 | 2015.130.900.73 | CTP | CTP | Microsoft SQL Server 2016 Community Technology Preview 3.2 (CTP3.2) | 2015-12-17 | 2015-12-10 | | | | -| 13.0.801.12 | 2015.130.801.12 | CTP | CTP | Microsoft SQL Server 2016 Community Technology Preview 3.1 (CTP3.1 refresh) | 2015-12-05 | 2015-12-01 | | | | -| 13.0.801.111 | 2015.130.801.111 | CTP | CTP | Microsoft SQL Server 2016 Community Technology Preview 3.1 (CTP3.1) | 2015-11-30 | 2015-11-21 | | | | -| 13.0.700.242 | 2015.130.700.242 | CTP | CTP | Microsoft SQL Server 2016 Community Technology Preview 3.0 (CTP3.0) | 2015-10-29 | 2015-10-26 | | | | -| 13.0.600.65 | 2015.130.600.65 | CTP | CTP | Microsoft SQL Server 2016 Community Technology Preview 2.4 (CTP2.4) | 2015-09-30 | 2015-09-20 | | | | -| 13.0.500.53 | 2015.130.500.53 | CTP | CTP | Microsoft SQL Server 2016 Community Technology Preview 2.3 (CTP2.3) | 2015-08-28 | 2015-08-24 | | | | -| 13.0.407.1 | 2015.130.407.1 | CTP | CTP | Microsoft SQL Server 2016 Community Technology Preview 2.2 (CTP2.2) | 2015-07-29 | 2015-07-22 | | | | -| 13.0.400.91 | 2015.130.400.91 | CTP | CTP | Microsoft SQL Server 2016 Community Technology Preview 2.2 (CTP2.2) (withdrawn) | 2015-07-22 | 2015-07-16 | | | | -| 13.0.300.44 | 2015.130.300.444 | CTP | CTP | Microsoft SQL Server 2016 Community Technology Preview 2.1 (CTP2.1) | 2015-06-14 | 2015-06-12 | | | | -| 13.0.200.172 | 2015.130.200.172 | CTP | CTP | Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2) | 2015-05-26 | 2015-05-21 | | | | - -[4057119 Cumulative Update 7 for SQL Server 2016 SP1]:https://support.microsoft.com/en-us/help/4057119/cumulative-update-7-for-sql-server-2016-sp1 -[4037354 Cumulative Update 6 for SQL Server 2016 SP1]:https://support.microsoft.com/en-us/help/4037354/cumulative-update-6-for-sql-server-2016-sp1 -[4040714 Cumulative Update 5 for SQL Server 2016 SP1]:https://support.microsoft.com/en-us/help/4040714/cumulative-update-5-for-sql-server-2016-sp1 -[4024305 Cumulative Update 4 for SQL Server 2016 SP1]:https://support.microsoft.com/en-us/help/4024305/cumulative-update-4-for-sql-server-2016-sp1 -[4019916 Cumulative Update 3 for SQL Server 2016 SP1]:https://support.microsoft.com/en-us/help/4019916/cumulative-update-3-for-sql-server-2016-sp1 -[4013106 Cumulative Update 2 for SQL Server 2016 SP1]:https://support.microsoft.com/en-us/help/4013106/cumulative-update-2-for-sql-server-2016-sp1 -[3208177 Cumulative update 1 for SQL Server 2016 Service Pack 1]:https://support.microsoft.com/en-us/help/3208177/cumulative-update-1-for-sql-server-2016-sp1 -[4019089 Description of the security update for SQL Server 2016 Service Pack 1 GDR: August 8, 2017]:https://support.microsoft.com/en-us/help/4019089/description-of-the-security-update-for-sql-server-2016-service-pack-1 -[3210089 GDR update package for SQL Server 2016 SP1]:https://support.microsoft.com/en-us/kb/3210089 -[3207512 Important update for SQL Server 2016 SP1 Reporting Services]:https://support.microsoft.com/en-us/kb/3207512 -[3182545 SQL Server 2016 Service Pack 1 release information]:https://support.microsoft.com/en-us/kb/3182545 -[4037357 Cumulative Update 9 for SQL Server 2016]:https://support.microsoft.com/en-us/help/4037357/cumulative-update-9-for-sql-server-2016 -[4040713 Cumulative Update 8 for SQL Server 2016]:https://support.microsoft.com/en-us/help/4040713/cumulative-update-8-for-sql-server-2016 -[4024304 Cumulative Update 7 for SQL Server 2016]:https://support.microsoft.com/en-us/help/4024304/cumulative-update-7-for-sql-server-2016 -[4019914 Cumulative Update 6 for SQL Server 2016]:https://support.microsoft.com/en-us/help/4019914/cumulative-update-6-for-sql-server-2016 -[4013105 Cumulative Update 5 for SQL Server 2016]:https://support.microsoft.com/en-us/help/4013105/cumulative-update-5-for-sql-server-2016 -[3205052 Cumulative update 4 for SQL Server 2016]:https://support.microsoft.com/en-us/help/3205052/cumulative-update-4-for-sql-server-2016 -[3210110 On-demand hotfix update package for SQL Server 2016 CU3]:https://support.microsoft.com/en-us/kb/3210110 -[3194717 MS16-136: Description of the security update for SQL Server 2016 CU]:https://support.microsoft.com/en-us/kb/3194717 -[3205413 Cumulative update 3 for SQL Server 2016]:https://support.microsoft.com/en-us/kb/3205413 -[3199171 On-demand hotfix update package for SQL Server 2016 CU2]:https://support.microsoft.com/en-us/kb/3199171 -[3195813 On-demand hotfix update package for SQL Server 2016 CU2]:https://support.microsoft.com/en-us/kb/3195813 -[3182270 Cumulative Update 2 for SQL Server 2016]:https://support.microsoft.com/en-us/kb/3182270 -[3164674 Cumulative Update 1 for SQL Server 2016]:https://support.microsoft.com/en-us/kb/3164674 -[3194716 MS16-136: Description of the security update for SQL Server 2016 GDR]:https://support.microsoft.com/en-us/kb/3194716 -[3179258 Processing a partition causes data loss on other partitions after the database is restored in SQL Server 2016 (1200)]:http://support.microsoft.com/en-us/kb/3179258 -[3164398 Critical update for SQL Server 2016 MSVCRT prerequisites]:https://support.microsoft.com/en-us/kb/3164398 -[Microsoft SQL Server 2016 RTM]:https://www.microsoft.com/en-us/evalcenter/evaluate-sql-server-2016 +| Build | File version |Branch | Type | Info | KB | Description/Link | Release Date | Build Date | Fixes | Public | Size, Mb | +|---------------|-------------------|-------|------|-----------------------------------|---------|------------------------------------------------------------------------------------------------------------------------|--------------|------------|------:|-------:|---------:| +| 13.0.6300.2 | 2015.131.5300.2 | SP3 | SP | **Latest SP** | 5003279 | [Microsoft SQL Server 2016 Service Pack 3 (SP3)] | 2021-09-15 | 2021-08-07 | 43 | 43 | 821 | +| 13.0.5888.11 | 2015.131.5888.11 | SP2 | CU | **Latest CU SP2** | 5001092 | [Cumulative Update 17 for SQL Server 2016 SP2] | 2021-03-29 | 2021-03-20 | 20 | 17 | 753 | +| 13.0.5882.1 | 2015.131.5882.1 | SP2 | CU | | 5000645 | [Cumulative Update 16 for SQL Server 2016 SP2] | 2021-02-11 | ? | 22 | 21 | 753 | +| 13.0.5865.1 | 2015.131.5865.1 | SP2 | CU | CVE-2021-1636 | 4583461 | [Description of the security update for SQL Server 2016 SP2 CU15: January 12, 2021] | 2021-01-12 | 2020-10-31 | 1 | 1 | 753 | +| 13.0.5850.14 | 2015.131.5850.14 | SP2 | CU | | 4577775 | [Cumulative Update 15 for SQL Server 2016 SP2] | 2020-09-28 | 2020-09-18 | 21 | 20 | 753 | +| 13.0.5830.85 | 2015.131.5830.85 | SP2 | CU | | 4564903 | [Cumulative Update 14 for SQL Server 2016 SP2] | 2020-08-06 | 2020-08-01 | 18 | 16 | 753 | +| 13.0.5820.21 | 2015.131.5820.21 | SP2 | CU | | 4549825 | [Cumulative Update 13 for SQL Server 2016 SP2] | 2020-05-28 | 2020-05-23 | 29 | 26 | 748 | +| 13.0.5698.0 | 2015.131.5698.0 | SP2 | CU | | 4536648 | [Cumulative Update 12 for SQL Server 2016 SP2] | 2020-02-25 | 2020-02-16 | 39 | 33 | 746 | +| 13.0.5622.0 | 2015.131.5622.0 | SP2 | GDR | CVE-2020-0618 | 4535706 | [Description of the security update for SQL Server 2016 SP2 CU11: February 11, 2020] | 2020-02-11 | 2019-11-28 | 1 | 1 | 752 | +| 13.0.5598.27 | 2015.131.5598.27 | SP2 | CU | | 4527378 | [Cumulative Update 11 for SQL Server 2016 SP2] | 2019-12-09 | 2019-11-28 | 29 | 26 | 752 | +| 13.0.5492.2 | 2015.131.5492.2 | SP2 | CU | | 4524334 | [Cumulative Update 10 for SQL Server 2016 SP2] | 2019-10-08 | 2019-10-05 | 21 | 21 | 752 | +| 13.0.5479.0 | 2015.131.5479.0 | SP2 | CU | **Withdrawn** | 4515435 | Cumulative Update 9 for SQL Server 2016 SP2 | 2019-09-30 | 2019-09-13 | 21 | 21 | 752 | +| 13.0.5426.0 | 2015.131.5426.0 | SP2 | CU | | 4505830 | [Cumulative Update 8 for SQL Server 2016 SP2] | 2019-07-31 | 2019-06-15 | 33 | 28 | 752 | +| 13.0.5382.0 | 2015.131.5382.0 | SP2 | COD | | 4510807 | [On-demand hotfix update package 2 for SQL Server 2016 Service Pack 2 (SP2) Cumulative update 7 (CU7)] | 2019-07-09 | 2019-06-15 | 2 | 2 | 714 | +| 13.0.5366.0 | 2015.131.5366.0 | SP2 | GDR | CVE-2019-1068 | 4505222 | [Security update for SQL Server 2016 SP2 CU7 GDR: July 9, 2019] | 2019-07-09 | 2019-06-15 | 2 | 2 | 714 | +| 13.0.5343.1 | 2015.131.5343.1 | SP2 | COD | | 4508636 | [On-demand hotfix update package for SQL Server 2016 Service Pack 2 (SP2) Cumulative update 7 (CU7)] | 2019-06-24 | 2019-06-15 | 2 | 2 | 714 | +| 13.0.5337.0 | 2015.131.5337.0 | SP2 | CU | | 4495256 | [Cumulative Update 7 for SQL Server 2016 SP2] | 2019-05-22 | 2019-05-16 | 28 | 27 | 714 | +| 13.0.5292.0 | 2015.131.5292.0 | SP2 | CU | | 4488536 | [Cumulative Update 6 for SQL Server 2016 SP2] | 2019-03-19 | 2019-03-12 | 29 | 24 | 714 | +| 13.0.5270.0 | 2015.131.5270.0 | SP2 | COD | | 4490133 | [On-demand hotfix update package for SQL Server 2016 SP2 CU5] | 2019-02-14 | 2019-02-08 | 1 | 1 | 712 | +| 13.0.5264.1 | 2015.131.5264.1 | SP2 | CU | | 4475776 | [Cumulative Update 5 for SQL Server 2016 SP2] | 2019-01-23 | 2019-01-11 | 52 | 43 | 712 | +| 13.0.5239.0 | 2015.131.5239.0 | SP2 | COD | | 4482972 | [On-demand hotfix update package 2 for SQL Server 2016 SP2 CU4] | 2018-12-20 | 2018-12-03 | 3 | 3 | 690 | +| 13.0.5233.0 | 2015.131.5233.0 | SP2 | CU | | 4464106 | [Cumulative Update 4 for SQL Server 2016 SP2] | 2018-11-13 | 2018-11-03 | 42 | 36 | 690 | +| 13.0.5216.0 | 2015.131.5216.0 | SP2 | CU | | 4458871 | [Cumulative Update 3 for SQL Server 2016 SP2] | 2018-09-21 | 2018-09-14 | 41 | 27 | 688 | +| 13.0.5201.2 | 2015.131.5201.2 | SP2 | CU | CVE-2018-8273 | 4458621 | [Security update for SQL Server 2016 SP2 CU: August 19, 2018] | 2018-08-19 | 2018-08-18 | 1 | 0 | 672 | +| 13.0.5161.0 | 2015.131.5161.0 | SP2 | CU | **Withdrawn**,CVE-2018-8273 | 4293807 | [Security update for SQL Server 2016 SP2 (CU): August 14, 2018] | 2018-08-14 | 2018-07-18 | 1 | 0 | 672 | +| 13.0.5153.0 | 2015.131.5153.0 | SP2 | CU | | 4340355 | [Cumulative Update 2 for SQL Server 2016 SP2] | 2018-07-16 | 2018-06-29 | 29 | 21 | 671 | +| 13.0.5149.0 | 2015.131.5149.0 | SP2 | CU | | 4135048 | [Cumulative Update 1 for SQL Server 2016 SP2] | 2018-05-30 | 2018-05-19 | 45 | 28 | 549 | +| 13.0.5102.14 | 2015.131.5102.14 | SP2 | GDR | CVE-2019-1332,2020-0618 | 4532097 | [Security update for SQL Server 2016 SP2 GDR: February 11, 2020] | 2020-02-11 | 2019-06-15 | 1 | 1 | 495 | +| 13.0.5101.9 | 2015.131.5101.9 | SP2 | GDR | CVE-2019-1068 | 4505220 | [Security update for SQL Server 2016 SP2 GDR: July 9, 2019] | 2019-07-09 | 2019-06-15 | 2 | 2 | 491 | +| 13.0.5081.1 | 2015.131.5081.1 | SP2 | COD | CVE-2018-8273 | 4293802 | [Security update for SQL Server 2016 SP2 GDR: August 14, 2018] | 2018-05-30 | 2018-05-19 | 1 | 0 | 492 | +| 13.0.5026.0 | 2015.131.5026.0 | SP2 | SP | | 4052908 | [SQL Server 2016 Service Pack 2 release information] | 2018-04-24 | 2018-03-18 | 50 | 50 | 774 | +| 13.0.4604.0 | 2015.130.4604.0 | SP1 | GDR | **Latest CU SP1**,CVE-2019-1068 | 4505221 | [Security update for SQL Server 2016 SP1 CU15 GDR: July 9, 2019] | 2019-07-09 | 2019-06-15 | 2 | 2 | 761 | +| 13.0.4577.0 | 2015.130.4577.0 | SP1 | COD | | 4508471 | [On-demand hotfix update package for SQL Server 2016 Service Pack 1 (SP1) Cumulative update 15 (CU15)] | 2019-06-20 | 2019-06-15 | 2 | 2 | 761 | +| 13.0.4574.0 | 2015.130.4574.0 | SP1 | CU | | 4495257 | [Cumulative Update 15 for SQL Server 2016 SP1] | 2019-05-16 | 2019-04-28 | 7 | 7 | 761 | +| 13.0.4560.0 | 2015.130.4560.0 | SP1 | CU | | 4488535 | [Cumulative update 14 (CU14) for SQL Server 2016 Service Pack 1] | 2019-03-19 | 2019-03-12 | 7 | 7 | 761 | +| 13.0.4550.1 | 2015.130.4550.1 | SP1 | CU | | 4475775 | [Cumulative Update 13 for SQL Server 2016 SP1] | 2019-01-23 | 2019-01-11 | 12 | 9 | 761 | +| 13.0.4541.0 | 2015.130.4541.0 | SP1 | CU | | 4464343 | [Cumulative Update 12 for SQL Server 2016 SP1] | 2018-11-13 | 2018-10-27 | 21 | 16 | 761 | +| 13.0.4531.0 | 2015.130.4531.0 | SP1 | COD | | 4465443 | [FIX: The "modification_counter" in DMV sys.dm_db_stats_properties shows incorrect value when partitions are merged] | 2018-09-27 | 2018-09-22 | 1 | 1 | 759 | +| 13.0.4528.0 | 2015.130.4528.0 | SP1 | CU | | 4459676 | [Cumulative Update 11 for SQL Server 2016 SP1] | 2018-09-18 | 2018-08-31 | 14 | 8 | 762 | +| 13.0.4522.0 | 2015.130.4522.0 | SP1 | CU | **Withdrawn**,CVE-2018-8273 | 4293808 | [Security update for SQL Server 2016 SP1 (CU): August 14, 2018] | 2018-08-14 | 2018-07-18 | 1 | 0 | 774 | +| 13.0.4514.0 | 2015.130.4514.0 | SP1 | CU | | 4341569 | [Cumulative Update 10 for SQL Server 2016 SP1] | 2018-07-16 | 2018-06-23 | 26 | 21 | 761 | +| 13.0.4502.0 | 2015.130.4502.0 | SP1 | CU | | 4100997 | [Cumulative Update 9 for SQL Server 2016 SP1] | 2018-05-30 | 2018-05-15 | 39 | 25 | 761 | +| 13.0.4474.0 | 2015.130.4474.0 | SP1 | CU | | 4077064 | [Cumulative Update 8 for SQL Server 2016 SP1] | 2018-03-19 | 2018-02-24 | 57 | 37 | 760 | +| 13.0.4466.4 | 2015.130.4466.4 | SP1 | CU | | 4057119 | [Cumulative Update 7 for SQL Server 2016 SP1] | 2018-01-03 | 2017-11-09 | 15 | 14 | 758 | +| 13.0.4457.0 | 2015.130.4457.0 | SP1 | CU | | 4037354 | [Cumulative Update 6 for SQL Server 2016 SP1] | 2017-11-21 | 2017-11-09 | 55 | 41 | 689 | +| 13.0.4451.0 | 2015.130.4451.0 | SP1 | CU | | 4040714 | [Cumulative Update 5 for SQL Server 2016 SP1] | 2017-09-18 | 2017-09-06 | 49 | 44 | 689 | +| 13.0.4446.0 | 2015.130.4446.0 | SP1 | CU | | 4024305 | [Cumulative Update 4 for SQL Server 2016 SP1] | 2017-08-08 | 2017-07-16 | 63 | 49 | 534 | +| 13.0.4435.0 | 2015.130.4435.0 | SP1 | CU | | 4019916 | [Cumulative Update 3 for SQL Server 2016 SP1] | 2017-05-15 | 2017-04-27 | 70 | 57 | 534 | +| 13.0.4422.0 | 2015.130.4422.0 | SP1 | CU | | 4013106 | [Cumulative Update 2 for SQL Server 2016 SP1] | 2017-03-20 | 2017-03-06 | 117 | 100 | 415 | +| 13.0.4411.0 | 2015.130.4411.0 | SP1 | CU | | 3208177 | [Cumulative update 1 for SQL Server 2016 Service Pack 1] | 2017-01-18 | 2017-01-06 | 63 | 55 | 439 | +| 13.0.4259.0 | 2015.130.4223.10 | SP1 | GDR | CVE-2019-1068 | 4505219 | [Security update for SQL Server 2016 SP1 GDR: July 9, 2019] | 2019-07-09 | 2019-06-15 | 2 | 2 | 699 | +| 13.0.4224.16 | 2015.130.4224.16 | SP1 | CU | CVE-2018-8273 | 4458842 | [Security update for SQL Server 2016 SP1 GDR: August 22, 2018] | 2018-08-22 | | 1 | 0 | 700 | +| 13.0.4223.10 | 2015.130.4223.10 | SP1 | CU | **Withdrawn**,CVE-2018-8273 | 4293801 | [Security update for SQL Server 2016 SP1 GDR: August 14, 2018] | 2018-08-14 | | 1 | 0 | | +| 13.0.4210.6 | 2015.130.4210.6 | SP1 | CU | CVE-2017-5715,2017-5753,2017-5754 | 4057118 | [Description of the security update for SQL Server 2016 SP1 GDR: January 3, 2018] | 2018-01-03 | | 1 | 0 | 696 | +| 13.0.4206.0 | 2015.130.4206.0 | SP1 | COD | | 4019089 | [Description of the security update for SQL Server 2016 Service Pack 1 GDR: August 8, 2017] | 2017-07-16 | | 1 | 1 | 364 | +| 13.0.4202.0 | 2015.130.4202.0 | SP1 | COD | | 3210089 | [GDR update package for SQL Server 2016 SP1] | 2016-12-16 | 2016-12-13 | 3 | 3 | 378 | +| 13.0.4199.0 | 2015.130.4199.0 | SP1 | COD | | 3207512 | [Important update for SQL Server 2016 SP1 Reporting Services] | 2016-11-23 | 2016-11-18 | 2 | 2 | 521 | +| 13.0.4001.0 | 2015.130.4001.0 | SP1 | SP | | 3182545 | [SQL Server 2016 Service Pack 1 release information] | 2016-11-16 | 2016-10-29 | 33 | 33 | 552 | +| 13.0.2218.0 | 2015.130.2218.0 | RTM | COD | CVE-2017-5715,2017-5753,2017-5754 | 4058559 | [Security update for SQL Server 2016 CU: January 6, 2018] | 2018-01-06 | | | | 918 | +| 13.0.2216.0 | 2015.130.2216.0 | RTM | CU | **Latest CU RTM** | 4037357 | [Cumulative Update 9 for SQL Server 2016] | 2017-11-21 | 2017-11-09 | 26 | 21 | 865 | +| 13.0.2213.0 | 2015.130.2213.0 | RTM | CU | | 4040713 | [Cumulative Update 8 for SQL Server 2016] | 2017-09-18 | 2017-09-06 | 19 | 17 | 864 | +| 13.0.2210.0 | 2015.130.2210.0 | RTM | CU | | 4024304 | [Cumulative Update 7 for SQL Server 2016] | 2017-08-08 | 2017-07-16 | 33 | 30 | 815 | +| 13.0.2204.0 | 2015.130.2204.0 | RTM | CU | | 4019914 | [Cumulative Update 6 for SQL Server 2016] | 2017-05-15 | 2017-04-20 | 28 | 22 | 814 | +| 13.0.2197.0 | 2015.130.2197.0 | RTM | CU | | 4013105 | [Cumulative Update 5 for SQL Server 2016] | 2017-03-20 | 2017-02-25 | 56 | 47 | 700 | +| 13.0.2193.0 | 2015.130.2193.0 | RTM | CU | | 3205052 | [Cumulative update 4 for SQL Server 2016] | 2017-01-18 | 2017-01-06 | 65 | 57 | 699 | +| 13.0.2190.2 | 2015.130.2190.2 | RTM | COD | | 3210110 | [On-demand hotfix update package for SQL Server 2016 CU3] | 2016-12-16 | 2016-12-13 | 3 | 3 | 691 | +| 13.0.2186.6 | 2015.130.2186.6 | RTM | CU | | 3194717 | [MS16-136: Description of the security update for SQL Server 2016 CU] | 2016-11-08 | 2016-10-31 | 31 | 31 | 691 | +| 13.0.2186.6 | 2015.130.2186.6 | RTM | CU | | 3205413 | [Cumulative update 3 for SQL Server 2016] **Duplicate KB3194717** | 2016-11-08 | 2016-10-31 | | | 691 | +| 13.0.2170.0 | 2015.130.2170.0 | RTM | COD | | 3199171 | [On-demand hotfix update package for SQL Server 2016 CU2] | 2016-11-01 | 2016-10-11 | 4 | 4 | 689 | +| 13.0.2169.0 | 2015.130.2169.0 | RTM | COD | | 3195813 | [On-demand hotfix update package for SQL Server 2016 CU2] | 2016-10-26 | 2016-10-05 | 4 | 4 | 689 | +| 13.0.2164.0 | 2015.130.2164.0 | RTM | CU | | 3182270 | [Cumulative Update 2 for SQL Server 2016] | 2016-09-22 | 2016-09-09 | 68 | 64 | 689 | +| 13.0.2149.0 | 2015.130.2149.0 | RTM | CU | | 3164674 | [Cumulative Update 1 for SQL Server 2016] | 2016-07-25 | 2016-07-11 | 192 | 146 | 665 | +| 13.0.1745.2 | 2015.130.1745.2 | RTM | COD | CVE-2017-5715,2017-5753,2017-5754 | 4058560 | [Description of the security update for SQL Server 2016 GDR: January 6, 2018] | 2018-01-06 | | | | 687 | +| 13.0.1742.0 | 2015.130.1742.0 | RTM | COD | CVE-2017-8516 | 4019088 | [Security update for SQL Server 2016 RTM GDR: August 8, 2017] | 2017-08-08 | | | | 451 | +| 13.0.1728.2 | 2015.130.1728.2 | RTM | COD | | 3210111 | [GDR update package for SQL Server 2016 RTM] | 2016-12-16 | | | | 339 | +| 13.0.1722.0 | 2015.130.1722.0 | RTM | COD | | 3194716 | [MS16-136: Description of the security update for SQL Server 2016 GDR] | 2016-11-08 | 2016-10-31 | 3 | 3 | 342 | +| 13.0.1711.0 | 2015.130.1711.0 | RTM | COD | | 3179258 | [Processing a partition causes data loss on other partitions after the database is restored in SQL Server 2016 (1200)] | 2016-08-17 | 2016-07-30 | | | 282 | +| 13.0.1708.0 | 2015.130.1708.0 | RTM | COD | | 3164398 | [Critical update for SQL Server 2016 MSVCRT prerequisites] | 2016-06-04 | 2016-06-02 | | | 265 | +| 13.0.1601.5 | 2015.130.1601.5 | RTM | RTM | | | [Microsoft SQL Server 2016 RTM] | 2016-06-01 | 2016-04-29 | | | 2050 | +| 13.0.1400.361 | 2015.130.1400.361 | RC | RC | | | Microsoft SQL Server 2016 Community Technology Release Candidate 3 (RC3) | 2016-04-15 | 2016-04-09 | | | 2114 | +| 13.0.1300.275 | 2015.130.1300.275 | RC | RC | | | Microsoft SQL Server 2016 Community Technology Release Candidate 2 (RC2) | 2016-04-01 | 2016-03-26 | | | 2101 | +| 13.0.1200.242 | 2015.130.1200.242 | RC | RC | | | Microsoft SQL Server 2016 Community Technology Release Candidate 1 (RC1) | 2016-03-18 | 2016-03-10 | | | 2083 | +| 13.0.1100.288 | 2015.130.1100.288 | RC | RC | | | Microsoft SQL Server 2016 Community Technology Release Candidate 0 (RC0) | 2016-03-07 | 2016-02-29 | | | | +| 13.0.1000.281 | 2015.130.1000.281 | CTP | CTP | | | Microsoft SQL Server 2016 Community Technology Preview 3.3 (CTP3.3) | 2016-02-03 | 2016-01-28 | | | | +| 13.0.900.73 | 2015.130.900.73 | CTP | CTP | | | Microsoft SQL Server 2016 Community Technology Preview 3.2 (CTP3.2) | 2015-12-17 | 2015-12-10 | | | | +| 13.0.801.12 | 2015.130.801.12 | CTP | CTP | | | Microsoft SQL Server 2016 Community Technology Preview 3.1 (CTP3.1 refresh) | 2015-12-05 | 2015-12-01 | | | | +| 13.0.801.111 | 2015.130.801.111 | CTP | CTP | | | Microsoft SQL Server 2016 Community Technology Preview 3.1 (CTP3.1) | 2015-11-30 | 2015-11-21 | | | | +| 13.0.700.242 | 2015.130.700.242 | CTP | CTP | | | Microsoft SQL Server 2016 Community Technology Preview 3.0 (CTP3.0) | 2015-10-29 | 2015-10-26 | | | | +| 13.0.600.65 | 2015.130.600.65 | CTP | CTP | | | Microsoft SQL Server 2016 Community Technology Preview 2.4 (CTP2.4) | 2015-09-30 | 2015-09-20 | | | | +| 13.0.500.53 | 2015.130.500.53 | CTP | CTP | | | Microsoft SQL Server 2016 Community Technology Preview 2.3 (CTP2.3) | 2015-08-28 | 2015-08-24 | | | | +| 13.0.407.1 | 2015.130.407.1 | CTP | CTP | | | Microsoft SQL Server 2016 Community Technology Preview 2.2 (CTP2.2) | 2015-07-29 | 2015-07-22 | | | | +| 13.0.400.91 | 2015.130.400.91 | CTP | CTP | **Withdrawn** | | Microsoft SQL Server 2016 Community Technology Preview 2.2 (CTP2.2) (withdrawn) | 2015-07-22 | 2015-07-16 | | | | +| 13.0.300.44 | 2015.130.300.444 | CTP | CTP | | | Microsoft SQL Server 2016 Community Technology Preview 2.1 (CTP2.1) | 2015-06-14 | 2015-06-12 | | | | +| 13.0.200.172 | 2015.130.200.172 | CTP | CTP | | | Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2) | 2015-05-26 | 2015-05-21 | | | | + +[Microsoft SQL Server 2016 Service Pack 3 (SP3)]:https://support.microsoft.com/help/5003279 +[Cumulative Update 17 for SQL Server 2016 SP2]:https://support.microsoft.com/help/5001092 +[Cumulative Update 16 for SQL Server 2016 SP2]:https://support.microsoft.com/help/5000645 +[Description of the security update for SQL Server 2016 SP2 CU15: January 12, 2021]:https://support.microsoft.com/4583461 +[Cumulative Update 15 for SQL Server 2016 SP2]:https://support.microsoft.com/help/4577775 +[Cumulative Update 14 for SQL Server 2016 SP2]:https://support.microsoft.com/help/4564903 +[Cumulative Update 13 for SQL Server 2016 SP2]:https://support.microsoft.com/help/4549825 +[Cumulative Update 12 for SQL Server 2016 SP2]:https://support.microsoft.com/help/4536648 +[Description of the security update for SQL Server 2016 SP2 CU11: February 11, 2020]:https://support.microsoft.com/help/4535706 +[Cumulative Update 11 for SQL Server 2016 SP2]:https://support.microsoft.com/help/4527378 +[Cumulative Update 10 for SQL Server 2016 SP2]:https://support.microsoft.com/help/4524334 +[Cumulative Update 8 for SQL Server 2016 SP2]:https://support.microsoft.com/help/4505830 +[On-demand hotfix update package 2 for SQL Server 2016 Service Pack 2 (SP2) Cumulative update 7 (CU7)]:https://support.microsoft.com/help/4510807 +[Security update for SQL Server 2016 SP2 CU7 GDR: July 9, 2019]:https://support.microsoft.com/help/4505222 +[On-demand hotfix update package for SQL Server 2016 Service Pack 2 (SP2) Cumulative update 7 (CU7)]:https://support.microsoft.com/help/4508636 +[Cumulative Update 7 for SQL Server 2016 SP2]:https://support.microsoft.com/help/4495256 +[Cumulative Update 6 for SQL Server 2016 SP2]:https://support.microsoft.com/help/4488536 +[On-demand hotfix update package for SQL Server 2016 SP2 CU5]:https://support.microsoft.com/help/4490133 +[Cumulative Update 5 for SQL Server 2016 SP2]:https://support.microsoft.com/help/4475776 +[On-demand hotfix update package 2 for SQL Server 2016 SP2 CU4]:https://support.microsoft.com/help/4482972 +[Cumulative Update 4 for SQL Server 2016 SP2]:https://support.microsoft.com/help/4464106 +[Cumulative Update 3 for SQL Server 2016 SP2]:https://support.microsoft.com/help/4458871 +[Security update for SQL Server 2016 SP2 CU: August 19, 2018]:https://support.microsoft.com/help/4458621 +[Security update for SQL Server 2016 SP2 (CU): August 14, 2018]:https://support.microsoft.com/help/4293807/ +[Cumulative Update 2 for SQL Server 2016 SP2]:https://support.microsoft.com/help/4340355 +[Cumulative Update 1 for SQL Server 2016 SP2]:https://support.microsoft.com/help/4135048 +[Security update for SQL Server 2016 SP2 GDR: February 11, 2020]:https://support.microsoft.com/help/4532097 +[Security update for SQL Server 2016 SP2 GDR: July 9, 2019]:https://support.microsoft.com/help/4505220 +[Security update for SQL Server 2016 SP2 GDR: August 14, 2018]:https://support.microsoft.com/help/4293802 +[Cumulative Update 12 for SQL Server 2016 SP1]:https://support.microsoft.com/help/4464343 +[FIX: The "modification_counter" in DMV sys.dm_db_stats_properties shows incorrect value when partitions are merged]:https://support.microsoft.com/help/4465443/ +[SQL Server 2016 Service Pack 2 release information]:https://support.microsoft.com/help/4052908 +[Security update for SQL Server 2016 SP1 CU15 GDR: July 9, 2019]:https://support.microsoft.com/help/4505221 +[On-demand hotfix update package for SQL Server 2016 Service Pack 1 (SP1) Cumulative update 15 (CU15)]:https://support.microsoft.com/help/4508471 +[Cumulative Update 15 for SQL Server 2016 SP1]:https://support.microsoft.com/help/4495257 +[Cumulative Update 14 for SQL Server 2016 SP1]:https://support.microsoft.com/help/4488535 +[Cumulative Update 13 for SQL Server 2016 SP1]:https://support.microsoft.com/help/4475775 +[Cumulative Update 11 for SQL Server 2016 SP1]:https://support.microsoft.com/help/4459676 +[Security update for SQL Server 2016 SP1 (CU): August 14, 2018]:https://support.microsoft.com/help/4293808 +[Cumulative Update 10 for SQL Server 2016 SP1]:https://support.microsoft.com/help/4341569 +[Cumulative Update 9 for SQL Server 2016 SP1]:https://support.microsoft.com/help/4100997 +[Cumulative Update 8 for SQL Server 2016 SP1]:https://support.microsoft.com/help/4077064 +[Cumulative Update 7 for SQL Server 2016 SP1]:https://support.microsoft.com/help/4057119 +[Cumulative Update 6 for SQL Server 2016 SP1]:https://support.microsoft.com/help/4037354 +[Cumulative Update 5 for SQL Server 2016 SP1]:https://support.microsoft.com/help/4040714 +[Cumulative Update 4 for SQL Server 2016 SP1]:https://support.microsoft.com/help/4024305 +[Cumulative Update 3 for SQL Server 2016 SP1]:https://support.microsoft.com/help/4019916 +[Cumulative Update 2 for SQL Server 2016 SP1]:https://support.microsoft.com/help/4013106 +[Cumulative update 1 for SQL Server 2016 Service Pack 1]:https://support.microsoft.com/help/3208177 +[Security update for SQL Server 2016 SP1 GDR: July 9, 2019]:https://support.microsoft.com/help/4505219 +[Security update for SQL Server 2016 SP1 GDR: August 22, 2018]:https://support.microsoft.com/help/4458842 +[Security update for SQL Server 2016 SP1 GDR: August 14, 2018]:https://support.microsoft.com/help/4293801 +[Description of the security update for SQL Server 2016 SP1 GDR: January 3, 2018]:https://support.microsoft.com/help/4057118 +[Description of the security update for SQL Server 2016 Service Pack 1 GDR: August 8, 2017]:https://support.microsoft.com/help/4019089 +[GDR update package for SQL Server 2016 SP1]:https://support.microsoft.com/help/3210089 +[Important update for SQL Server 2016 SP1 Reporting Services]:https://support.microsoft.com/help/3207512 +[SQL Server 2016 Service Pack 1 release information]:https://support.microsoft.com/help/3182545 +[Security update for SQL Server 2016 CU: January 6, 2018]:https://support.microsoft.com/help/4058559 +[Cumulative Update 9 for SQL Server 2016]:https://support.microsoft.com/help/4037357 +[Cumulative Update 8 for SQL Server 2016]:https://support.microsoft.com/help/4040713 +[Cumulative Update 7 for SQL Server 2016]:https://support.microsoft.com/help/4024304 +[Cumulative Update 6 for SQL Server 2016]:https://support.microsoft.com/help/4019914 +[Cumulative Update 5 for SQL Server 2016]:https://support.microsoft.com/help/4013105 +[Cumulative update 4 for SQL Server 2016]:https://support.microsoft.com/help/3205052 +[Description of the security update for SQL Server 2016 GDR: January 6, 2018]:https://support.microsoft.com/help/4058560 +[Security update for SQL Server 2016 RTM GDR: August 8, 2017]:https://support.microsoft.com/help/4019088 +[GDR update package for SQL Server 2016 RTM]:https://support.microsoft.com/help/3210111 +[On-demand hotfix update package for SQL Server 2016 CU3]:https://support.microsoft.com/help/3210110 +[MS16-136: Description of the security update for SQL Server 2016 CU]:https://support.microsoft.com/help/3194717 +[Cumulative update 3 for SQL Server 2016]:https://support.microsoft.com/help/3205413 +[On-demand hotfix update package for SQL Server 2016 CU2]:https://support.microsoft.com/help/3199171 +[On-demand hotfix update package for SQL Server 2016 CU2]:https://support.microsoft.com/help/3195813 +[Cumulative Update 2 for SQL Server 2016]:https://support.microsoft.com/help/3182270 +[Cumulative Update 1 for SQL Server 2016]:https://support.microsoft.com/help/3164674 +[MS16-136: Description of the security update for SQL Server 2016 GDR]:https://support.microsoft.com/help/3194716 +[Processing a partition causes data loss on other partitions after the database is restored in SQL Server 2016 (1200)]:http://support.microsoft.com/help/3179258 +[Critical update for SQL Server 2016 MSVCRT prerequisites]:https://support.microsoft.com/help/3164398 +[Microsoft SQL Server 2016 RTM]:https://www.microsoft.com/evalcenter/evaluate-sql-server-2016 -## Microsoft SQL Server 2014 Builds +## Microsoft SQL Server 2014 Builds + +⚠ End-of-Life: SQL Server 2014 reached [end of mainstream support on July 9th, 2019](https://support.microsoft.com/en-us/lifecycle/search?alpha=SQL%20Server%202014%20Service%20Pack%203). + +All SQL Server 2014 CU downloads: [Catalog Update Microsoft SQL Server 2014](http://www.catalog.update.microsoft.com/Search.aspx?q=sql%20server%202014) + Here is the latest output from `SELECT @@VERSION` for SQL Server 2014 Developer Edition on Windows: ``` -Microsoft SQL Server 2014 (SP2-CU9) (KB4055557) - 12.0.5563.0 (X64) - Dec 7 2017 01:00:06 - Copyright (c) Microsoft Corporation - Developer Edition (64-bit) on Windows … +Microsoft SQL Server 2014 (SP3-CU4) (KB4583462) - 12.0.6433.1 (X64) + Dec 20 2020 21:42:29 + Copyright (c) Microsoft Corporation + Developer Edition (64-bit) on … ``` -| Build | File version | Branch | Type | KB / Description | Release Date | Fixes | Public | Size, Mb | -|--------------|------------------|--------|------|------------------------------------------------------------------------------------------------------------------------------------|--------------|------:|-------:|---------:| -| 12.0.5563.0 | 2014.120.5563.0 | SP2 | CU | [4055557 Cumulative Update 9 for SQL Server 2014 SP2] | 2017-12-18 | 8 | 7 | 540 | -| 12.0.5557.0 | 2014.120.5557.0 | SP2 | CU | [4037356 Cumulative Update 8 for SQL Server 2014 SP2] | 2017-10-17 | 15 | 8 | 539 | -| 12.0.5556.0 | 2014.120.5556.0 | SP2 | CU | [4032541 Cumulative Update 7 for SQL Server 2014 SP2] | 2017-08-28 | 15 | 8 | 539 | -| 12.0.5553.0 | 2014.120.5553.0 | SP2 | CU | [4019094 Cumulative Update 6 for SQL Server 2014 SP2] | 2017-08-08 | 29 | 29 | 539 | -| 12.0.5207.0 | 2014.120.5207.0 | SP2 | GDR | [4019093 Description of the security update for SQL Server 2014 Service Pack 2 GDR: August 8, 2017] | 2017-08-08 | 1 | 1 | 413 | -| 12.0.5546.0 | 2014.120.5546.0 | SP2 | CU | [4013098 Cumulative Update 5 for SQL Server 2014 SP2] | 2017-04-18 | 24 | 21 | 557 | -| 12.0.5540.0 | 2014.120.5540.0 | SP2 | CU | [4010394 Cumulative Update 4 for SQL Server 2014 SP2] | 2017-02-21 | 30 | 27 | 555 | -| 12.0.5538.0 | 2014.120.5538.0 | SP2 | CU | [3204388 Cumulative update 3 for SQL Server 2014 SP2] | 2016-12-28 | 44 | 39 | 555 | -| 12.0.5532.0 | 2014.120.5532.0 | SP2 | CU | [3194718 MS16-136: Description of the security update for SQL Server 2014 Service Pack 2 CU: November 8, 2016] | 2016-11-08 | 1 | 1 | 551 | -| 12.0.5522.0 | 2014.120.5522.0 | SP2 | CU | [3188778 Cumulative update 2 for SQL Server 2014 SP2] | 2016-10-18 | 18 | 18 | 550 | -| 12.0.5511.0 | 2014.120.5511.0 | SP2 | CU | [3178925 Cumulative update 1 for SQL Server 2014 SP2] | 2016-08-24 | 45 | 36 | 556 | -| 12.0.5203.0 | 2014.120.5203.0 | SP2 | GDR | [3194714 MS16-136: Description of the security update for SQL Server 2014 Service Pack 2 GDR: November 8, 2016] | 2016-11-08 | 1 | 1 | 463 | -| 12.0.5000.0 | 2014.120.5000.0 | SP2 | SP | [3171021 SQL Server 2014 Service Pack 2 release information] | 2016-07-11 | 133 | 55 | 681 | -| 12.0.4522.0 | 2014.120.4522.0 | SP1 | CU | [4019099 Cumulative Update 13 for SQL Server 2014 SP1] **Last CU for 2014 SP1** | 2017-08-08 | 11 | 11 | 577 | -| 12.0.4511.0 | 2014.120.4511.0 | SP1 | CU | [4017793 Cumulative Update 12 for SQL Server 2014 SP1] | 2017-04-17 | 12 | 11 | 573 | -| 12.0.4502.0 | 2014.120.4502.0 | SP1 | CU | [4010392 Cumulative Update 11 for SQL Server 2014 SP1] | 2017-02-21 | 15 | 15 | 571 | -| 12.0.4491.0 | 2014.120.4491.0 | SP1 | CU | [3204399 Cumulative update package 10 for SQL Server 2014 Service Pack 1] | 2016-12-28 | 33 | 27 | 571 | -| 12.0.4487.0 | 2014.120.4487.0 | SP1 | CU | [3194722 MS16-136: Description of the security update for SQL Server 2014 Service Pack 1 CU: November 8, 2016] | 2016-11-08 | 1 | 1 | 569 | -| 12.0.4474.0 | 2014.120.4474.0 | SP1 | CU | [3186964 Cumulative update 9 for SQL Server 2014 SP1] | 2016-10-18 | 14 | 14 | | -| 12.0.4468.0 | 2014.120.4468.0 | SP1 | CU | [3174038 Cumulative update 8 for SQL Server 2014 SP1] | 2016-08-16 | 38 | 38 | | -| 12.0.4463.0 | 2014.120.4463.0 | SP1 | COD | [3174370 COD Hotfix A memory leak occurs when you use Azure Storage in SQL Server 2014] | 2016-08-04 | 1 | 1 | | -| 12.0.4459.0 | 2014.120.4459.0 | SP1 | CU | [3167392 Cumulative Update 7 for SQL Server 2014 SP1] | 2016-06-20 | 35 | 33 | | -| 12.0.4457.0 | 2014.120.4457.0 | SP1 | CU | [3167392 Cumulative Update 6 for SQL Server 2014 Service Pack 1] **Refresh** | 2016-05-31 | 44 | 43 | | -| 12.0.4452.0 | 2014.120.4452.0 | SP1 | COD | 3147825 COD Hotfix **Deprecated** | 2016-04-05 | 1 | 1 | | -| 12.0.4449.0 | 2014.120.4449.0 | SP1 | CU | [3144524 Cumulative update 6 for SQL Server 2014 SP1 (deprecated)] **Deprecated** | 2016-04-18 | N/A | N/A | | -| 12.0.4439.1 | 2014.120.4439.1 | SP1 | CU | [3130926 Cumulative Update 5 (CU5) for SQL Server 2014 Service Pack 1] | 2016-02-22 | 20 | 20 | | -| 12.0.4437.0 | 2014.120.4437.0 | SP1 | COD | [3130999 On-demand hotfix update package for SQL Server 2014 Service Pack 1 Cumulative Update 4] | 2016-02-05 | 2 | 2 | | -| 12.0.4436.0 | 2014.120.4436.0 | SP1 | CU | [3106660 Cumulative update package 4 (CU4) for SQL Server 2014 Service Pack 1] | 2015-12-21 | 34 | 34 | | -| 12.0.4433.0 | 2014.120.4433.0 | SP1 | COD | [3119148 FIX: Error 3203 occurs and a SQL Server 2014 backup job can't restart after a network failure] | 2015-12-09 | 1 | 1 | | -| 12.0.4432.0 | 2014.120.4432.0 | SP1 | COD | [3097972 FIX: Error when your stored procedure calls another stored procedure on a linked server in SQL Server 2014] | 2015-11-19 | 3 | 3 | | -| 12.0.4427.24 | 2014.120.4427.24 | SP1 | CU | [3094221 Cumulative update package 3 (CU3) for SQL Server 2014 Service Pack 1] | 2015-10-21 | 40 | 36 | | -| 12.0.4422.0 | 2014.120.4422.0 | SP1 | CU | [3075950 Cumulative update package 2 (CU2) for SQL Server 2014 Service Pack 1] | 2015-08-17 | 51 | 46 | | -| 12.0.4419.0 | 2014.120.4419.0 | SP1 | COD | [3078973 An on-demand hotfix update package is available for SQL Server 2014 SP1] | 2015-07-24 | 13 | 13 | | -| 12.0.4416.0 | 2014.120.4416.0 | SP1 | CU | [3067839 Cumulative update package 1 (CU1) for SQL Server 2014 Service Pack 1] | 2015-06-22 | 141 | 121 | | -| 12.0.4232.0 | 2014.120.4232.0 | SP1 | CU | [3194720 MS16-136: Description of the security update for SQL Server 2014 Service Pack 1 GDR: November 8, 2016] | 2016-11-08 | 1 | 1 | | -| 12.0.4219.0 | 2014.120.4219.0 | SP1 | GDR | [3098852 SP1 GDR TLS 1.2 Update] | 2016-01-29 | | | | -| 12.0.4213.0 | 2014.120.4213.0 | SP1 | GDR | [3070446 MS15-058: Description of the nonsecurity update for SQL Server 2014 Service Pack 1 GDR: July 14, 2015] | 2015-07-14 | | | | -| 12.0.4100.1 | 2014.120.4100.1 | SP1 | SP | [3058865 SQL Server 2014 Service Pack 1 release information] | 2015-05-14 | 29 | 29 | | -| 12.0.4050.0 | 2014.120.4050.0 | SP1 | SP | SQL Server 2014 Service Pack 1 (SP1) (initial) | 2015-04-15 | | | | -| 12.0.2569.0 | 2014.120.2569.0 | RTM | CU | [3158271 Cumulative update package 14 (CU14) for SQL Server 2014] **Last CU for 2014 RTM** | 2016-06-20 | 21 | 20 | | -| 12.0.2568.0 | 2014.120.2568.0 | RTM | CU | [3144517 Cumulative update package 13 (CU13) for SQL Server 2014] | 2016-04-18 | 30 | 30 | | -| 12.0.2564.0 | 2014.120.2564.0 | RTM | CU | [3130923 Cumulative update package 12 (CU12) for SQL Server 2014] | 2016-02-22 | 7 | 7 | | -| 12.0.2560.0 | 2014.120.2550.0 | RTM | CU | [3106659 Cumulative update package 11 (CU11) for SQL Server 2014] | 2015-12-21 | 19 | 19 | | -| 12.0.2556.4 | 2014.120.2556.4 | RTM | CU | [3094220 Cumulative update package 10 (CU10) for SQL Server 2014] | 2015-10-20 | 33 | 30 | | -| 12.0.2553 | 2014.120.2553.0 | RTM | CU | [3075949 Cumulative update package 9 (CU9) for SQL Server 2014] | 2015-08-17 | 31 | 30 | | -| 12.0.2548 | 2014.120.2548.0 | RTM | CU | [3045323 MS15-058: Description of the security update for SQL Server 2014 QFE: July 14, 2015] | 2015-07-14 | 1 | 1 | | -| 12.0.2546 | 2014.120.2546.0 | RTM | CU | [3067836 Cumulative update package 8 (CU8) for SQL Server 2014] | 2015-06-22 | 40 | 38 | | -| 12.0.2506 | 2014.120.2506.0 | RTM | COD | [3063054 Update enables Premium Storage support for Data files on Azure Storage and resolves backup failures] | 2015-05-19 | 1 | 1 | | -| 12.0.2505 | 2014.120.2505.0 | RTM | COD | [3052167 FIX: Error 1205 when you execute parallel query that contains outer join operators in SQL Server 2014] | 2015-05-19 | 1 | 1 | | -| 12.0.2504 | 2014.120.2504.0 | RTM | COD | [2999809 FIX: Poor performance when a query contains table joins in SQL Server 2014] | 2015-05-05 | 2 | 2 | | -| 12.0.2504 | 2014.120.2504.0 | RTM | COD | [3058512 FIX: Unpivot Transformation task changes null to zero or empty strings in SSIS 2014] | 2015-05-05 | | | | -| 12.0.2495 | 2014.120.2495.0 | RTM | CU | [3046038 Cumulative update package 7 (CU7) for SQL Server 2014] | 2015-04-23 | 47 | 41 | | -| 12.0.2488 | 2014.120.2488.0 | RTM | COD | [3048751 FIX: Deadlock cannot be resolved automatically when you run a SELECT query that can result in a parallel batch-mode scan] | 2015-04-01 | 1 | 1 | | -| 12.0.2485 | 2014.120.2485.0 | RTM | COD | [3043788 An on-demand hotfix update package is available for SQL Server 2014] | 2015-03-16 | 1 | 1 | | -| 12.0.2480 | 2014.120.2480.0 | RTM | CU | [3031047 Cumulative update package 6 (CU6) for SQL Server 2014] | 2015-02-16 | 64 | 55 | | -| 12.0.2474 | 2014.120.2474.0 | RTM | COD | [3034679 FIX: AlwaysOn availability groups are reported as NOT SYNCHRONIZING] | 2015-02-04 | 1 | 1 | | -| 12.0.2472 | 2014.120.2472.0 | RTM | COD | [3032087 FIX: Cannot show requested dialog after you connect to the latest SQL Database Update V12 (preview) with SQL Server 2014] | 2015-01-28 | 1 | 1 | | -| 12.0.2464 | 2014.120.2464.0 | RTM | COD | [3024815 Large query compilation waits on RESOURCE_SEMAPHORE_QUERY_COMPILE in SQL Server 2014] | 2015-01-05 | 1 | 1 | | -| 12.0.2456 | 2014.120.2456.0 | RTM | CU | [3011055 Cumulative update package 5 (CU5) for SQL Server 2014] | 2014-12-18 | 54 | 48 | | -| 12.0.2436 | 2014.120.2436.0 | RTM | COD | [3014867 FIX: "Remote hardening failure" exception cannot be caught and a potential data loss when you use SQL Server 2014] | 2014-11-27 | 1 | 1 | | -| 12.0.2430 | 2014.120.2430.0 | RTM | CU | [2999197 Cumulative update package 4 (CU4) for SQL Server 2014] | 2014-10-21 | 66 | 54 | | -| 12.0.2423 | 2014.120.2423.0 | RTM | COD | [3007050 FIX: RTDATA_LIST waits when you run natively stored procedures that encounter expected failures in SQL Server 2014] | 2014-10-22 | | | | -| 12.0.2405 | 2014.120.2405.0 | RTM | COD | [2999809 FIX: Poor performance when a query contains table joins in SQL Server 2014] | 2014-09-25 | | | | -| 12.0.2402 | 2014.120.2402.0 | RTM | CU | [2984923 Cumulative update package 3 (CU3) for SQL Server 2014] | 2014-08-18 | 40 | 32 | | -| 12.0.2381 | 2014.120.2381.0 | RTM | QFE | [2977316 MS14-044: Description of the security update for SQL Server 2014 (QFE)] | 2014-08-12 | 1 | 1 | | -| 12.0.2370 | 2014.120.2370.0 | RTM | CU | [2967546 Cumulative update package 2 (CU2) for SQL Server 2014] | 2014-06-27 | 52 | 48 | | -| 12.0.2342 | 2014.120.2342.0 | RTM | CU | [2931693 Cumulative update package 1 (CU1) for SQL Server 2014] | 2014-04-21 | 121 | 114 | | -| 12.0.2271.0 | 2014.120.2271.0 | RTM | GDR | [TLS 1.2 support for SQL Server 2014 RTM] | 2016-01-29 | 3 | 3 | | -| 12.0.2269 | 2014.120.2269.0 | RTM | GDR | [3045324 MS15-058: Description of the security update for SQL Server 2014 GDR: July 14, 2015] | 2015-07-14 | 2 | 2 | | -| 12.0.2254 | 2014.120.2254.0 | RTM | GDR | [2977315 MS14-044: Description of the security update for SQL Server 2014 (GDR)] | 2014-08-12 | 1 | 1 | | -| 12.0.2000 | 2014.120.2000.8 | RTM | RTM | SQL Server 2014 RTM | 2014-04-01 | - | - | | -| 12.0.1524 | 2014.120.1524.0 | CTP | CTP | Microsoft SQL Server 2014 Community Technology Preview 2 (CTP2) | 2013-10-15 | | | | -| 11.0.9120 | 2013.110.9120.0 | CTP | CTP | Microsoft SQL Server 2014 Community Technology Preview 1 (CTP1) | 2013-06-25 | | | | - -[4055557 Cumulative Update 9 for SQL Server 2014 SP2]:https://support.microsoft.com/en-us/help/4055557/cumulative-update-9-for-sql-server-2014-sp2 -[4037356 Cumulative Update 8 for SQL Server 2014 SP2]:https://support.microsoft.com/en-us/help/4037356/cumulative-update-8-for-sql-server-2014-sp2 -[4032541 Cumulative Update 7 for SQL Server 2014 SP2]:https://support.microsoft.com/en-us/help/4032541/cumulative-update-7-for-sql-server-2014-sp2 -[4019094 Cumulative Update 6 for SQL Server 2014 SP2]:https://support.microsoft.com/en-us/help/4019094/cumulative-update-6-for-sql-server-2014-sp2 -[4019093 Description of the security update for SQL Server 2014 Service Pack 2 GDR: August 8, 2017]:https://support.microsoft.com/en-us/help/4019093/description-of-the-security-update-for-sql-server-2014-service-pack-2 -[4013098 Cumulative Update 5 for SQL Server 2014 SP2]:https://support.microsoft.com/en-us/help/4013098/cumulative-update-5-for-sql-server-2014-sp2 -[4010394 Cumulative Update 4 for SQL Server 2014 SP2]:https://support.microsoft.com/en-us/help/4010394/cumulative-update-4-for-sql-server-2014-sp2 -[3204388 Cumulative update 3 for SQL Server 2014 SP2]:https://support.microsoft.com/en-us/kb/3204388 -[3194718 MS16-136: Description of the security update for SQL Server 2014 Service Pack 2 CU: November 8, 2016]:https://support.microsoft.com/en-us/kb/3194718 -[3188778 Cumulative update 2 for SQL Server 2014 SP2]:https://support.microsoft.com/en-us/kb/3188778 -[3178925 Cumulative update 1 for SQL Server 2014 SP2]:https://support.microsoft.com/en-us/kb/3178925 -[3194714 MS16-136: Description of the security update for SQL Server 2014 Service Pack 2 GDR: November 8, 2016]:https://support.microsoft.com/en-us/help/3194714/ms16-136-description-of-the-security-update-for-sql-server-2014-service-pack-2-gdr-november-8,-2016 -[3171021 SQL Server 2014 Service Pack 2 release information]:https://support.microsoft.com/en-us/kb/3171021 -[4019099 Cumulative Update 13 for SQL Server 2014 SP1]:https://support.microsoft.com/en-us/help/4019099/cumulative-update-13-for-sql-server-2014-sp1 -[4017793 Cumulative Update 12 for SQL Server 2014 SP1]:https://support.microsoft.com/en-us/help/4017793/cumulative-update-12-for-sql-server-2014-sp1 -[4010392 Cumulative Update 11 for SQL Server 2014 SP1]:https://support.microsoft.com/en-us/help/4010392/cumulative-update-11-for-sql-server-2014-sp1 -[3204399 Cumulative update package 10 for SQL Server 2014 Service Pack 1]:https://support.microsoft.com/en-us/kb/3204399 -[3194722 MS16-136: Description of the security update for SQL Server 2014 Service Pack 1 CU: November 8, 2016]:https://support.microsoft.com/en-us/kb/3194722 -[3186964 Cumulative update 9 for SQL Server 2014 SP1]:https://support.microsoft.com/en-us/kb/3186964 -[3174038 Cumulative update 8 for SQL Server 2014 SP1]:https://support.microsoft.com/en-us/kb/3174038 -[3174370 COD Hotfix A memory leak occurs when you use Azure Storage in SQL Server 2014]:https://support.microsoft.com/en-us/kb/3174370 -[3167392 Cumulative Update 7 for SQL Server 2014 SP1]:https://support.microsoft.com/en-us/kb/3162659 -[3167392 Cumulative Update 6 for SQL Server 2014 Service Pack 1]:https://support.microsoft.com/en-us/kb/3167392 -[3144524 Cumulative update 6 for SQL Server 2014 SP1 (deprecated)]:https://support.microsoft.com/en-us/kb/3144524 -[3130926 Cumulative Update 5 (CU5) for SQL Server 2014 Service Pack 1]:https://support.microsoft.com/en-us/kb/3130926 -[3130999 On-demand hotfix update package for SQL Server 2014 Service Pack 1 Cumulative Update 4]:https://support.microsoft.com/en-us/kb/3130999 -[3106660 Cumulative update package 4 (CU4) for SQL Server 2014 Service Pack 1]:https://support.microsoft.com/en-us/kb/3106660 -[3119148 FIX: Error 3203 occurs and a SQL Server 2014 backup job can't restart after a network failure]:http://support.microsoft.com/kb/3119148 -[3097972 FIX: Error when your stored procedure calls another stored procedure on a linked server in SQL Server 2014]:http://support.microsoft.com/kb/3097972 -[3094221 Cumulative update package 3 (CU3) for SQL Server 2014 Service Pack 1]:http://support.microsoft.com/kb/3094221 -[3075950 Cumulative update package 2 (CU2) for SQL Server 2014 Service Pack 1]:http://support.microsoft.com/kb/3075950 -[3078973 An on-demand hotfix update package is available for SQL Server 2014 SP1]:http://support.microsoft.com/kb/3078973 -[3067839 Cumulative update package 1 (CU1) for SQL Server 2014 Service Pack 1]:http://support.microsoft.com/kb/3067839 -[3194720 MS16-136: Description of the security update for SQL Server 2014 Service Pack 1 GDR: November 8, 2016]:https://support.microsoft.com/en-us/kb/3194720 -[3098852 SP1 GDR TLS 1.2 Update]:https://support.microsoft.com/en-us/hotfix/kbhotfix?kbnum=3098852&kbln=en-us -[3070446 MS15-058: Description of the nonsecurity update for SQL Server 2014 Service Pack 1 GDR: July 14, 2015]:https://support.microsoft.com/en-us/kb/3070446 -[3058865 SQL Server 2014 Service Pack 1 release information]:https://support.microsoft.com/en-us/kb/3058865 -[3158271 Cumulative update package 14 (CU14) for SQL Server 2014]:https://support.microsoft.com/en-us/kb/3158271 -[3144517 Cumulative update package 13 (CU13) for SQL Server 2014]:https://support.microsoft.com/en-us/kb/3144517 -[3130923 Cumulative update package 12 (CU12) for SQL Server 2014]:https://support.microsoft.com/en-us/kb/3130923 -[3106659 Cumulative update package 11 (CU11) for SQL Server 2014]:http://support.microsoft.com/kb/3106659 -[3094220 Cumulative update package 10 (CU10) for SQL Server 2014]:http://support.microsoft.com/kb/3094220 -[3075949 Cumulative update package 9 (CU9) for SQL Server 2014]:http://support.microsoft.com/kb/3075949 -[3045323 MS15-058: Description of the security update for SQL Server 2014 QFE: July 14, 2015]:https://support.microsoft.com/en-us/kb/3045323 -[3067836 Cumulative update package 8 (CU8) for SQL Server 2014]:http://support.microsoft.com/kb/3067836 -[3063054 Update enables Premium Storage support for Data files on Azure Storage and resolves backup failures]:http://support.microsoft.com/kb/3063054 -[3052167 FIX: Error 1205 when you execute parallel query that contains outer join operators in SQL Server 2014]:http://support.microsoft.com/kb/3052167 -[2999809 FIX: Poor performance when a query contains table joins in SQL Server 2014]:http://support.microsoft.com/kb/2999809 -[3058512 FIX: Unpivot Transformation task changes null to zero or empty strings in SSIS 2014]:http://support.microsoft.com/kb/3058512 -[3046038 Cumulative update package 7 (CU7) for SQL Server 2014]:http://support.microsoft.com/kb/3046038 -[3048751 FIX: Deadlock cannot be resolved automatically when you run a SELECT query that can result in a parallel batch-mode scan]:http://support.microsoft.com/kb/3048751 -[3043788 An on-demand hotfix update package is available for SQL Server 2014]:http://support.microsoft.com/kb/3043788 -[3031047 Cumulative update package 6 (CU6) for SQL Server 2014]:http://support.microsoft.com/kb/3031047 -[3034679 FIX: AlwaysOn availability groups are reported as NOT SYNCHRONIZING]:http://support.microsoft.com/kb/3034679 -[3032087 FIX: Cannot show requested dialog after you connect to the latest SQL Database Update V12 (preview) with SQL Server 2014]:http://support.microsoft.com/kb/3032087 -[3024815 Large query compilation waits on RESOURCE_SEMAPHORE_QUERY_COMPILE in SQL Server 2014]:http://support.microsoft.com/kb/3024815 -[3011055 Cumulative update package 5 (CU5) for SQL Server 2014]:http://support.microsoft.com/kb/3011055 -[3014867 FIX: "Remote hardening failure" exception cannot be caught and a potential data loss when you use SQL Server 2014]:http://support.microsoft.com/kb/3014867 -[2999197 Cumulative update package 4 (CU4) for SQL Server 2014]:http://support.microsoft.com/kb/2999197 -[3007050 FIX: RTDATA_LIST waits when you run natively stored procedures that encounter expected failures in SQL Server 2014]:http://support.microsoft.com/kb/3007050 -[2999809 FIX: Poor performance when a query contains table joins in SQL Server 2014]:http://support.microsoft.com/kb/2999809 -[2984923 Cumulative update package 3 (CU3) for SQL Server 2014]:http://support.microsoft.com/kb/2984923 -[2977316 MS14-044: Description of the security update for SQL Server 2014 (QFE)]:http://support.microsoft.com/kb/2977316 -[2967546 Cumulative update package 2 (CU2) for SQL Server 2014]:http://support.microsoft.com/kb/2967546 -[2931693 Cumulative update package 1 (CU1) for SQL Server 2014]:http://support.microsoft.com/kb/2931693 -[TLS 1.2 support for SQL Server 2014 RTM]:https://support.microsoft.com/en-us/hotfix/kbhotfix?kbnum=3098856&kbln=en-us -[3045324 MS15-058: Description of the security update for SQL Server 2014 GDR: July 14, 2015]:https://support.microsoft.com/en-us/kb/3045324 -[2977315 MS14-044: Description of the security update for SQL Server 2014 (GDR)]:http://support.microsoft.com/kb/2977315 +| Build | File version | Branch | Type | Info | KB | Description/Link | Release Date | Fixes | Public | Size, Mb | +|--------------|------------------|--------|------|-----------------------------------|---------|----------------------------------------------------------------------------------------------------------------------------|--------------|------:|-------:|---------:| +| 12.0.6433.1 | 2014.120.6433.1 | SP3 | GDR | CVE-2021-1636 | 4583462 | [Description of the security update for SQL Server 2014 SP3 CU4: January 12, 2021] | 2021-01-12 | 1 | 1 | 596 | +| 12.0.6372.1 | 2014.120.6372.1 | SP3 | GDR | CVE-2020-0618 | 4535288 | [Security update for SQL Server 2014 SP3 CU4: February 11, 2020] | 2020-02-11 | 1 | 1 | 604 | +| 12.0.6329.1 | 2014.120.6329.1 | SP3 | CU | **Latest CU SP3** | 4500181 | [Cumulative Update 4 for SQL Server 2014 SP3] | 2019-07-29 | 25 | 19 | 658 | +| 12.0.6293.0 | 2014.120.6293.0 | SP3 | GDR | CVE-2019-1068 | 4505422 | [Security update for SQL Server 2014 SP3 CU3 GDR: July 9, 2019] | 2019-07-09 | 1 | 1 | 656 | +| 12.0.6259.0 | 2014.120.6259.0 | SP3 | CU | | 4491539 | [Cumulative Update 3 for SQL Server 2014 SP3] | 2019-04-16 | 4 | 4 | 656 | +| 12.0.6214.1 | 2014.120.6214.1 | SP3 | CU | | 4482960 | [Cumulative Update 2 for SQL Server 2014 SP3] | 2019-02-19 | 5 | 5 | 602 | +| 12.0.6205.1 | 2014.120.6205.1 | SP3 | CU | | 4470220 | [Cumulative Update 1 for SQL Server 2014 SP3] | 2018-12-12 | 16 | 13 | 601 | +| 12.0.6118.4 | 2014.120.6118.4 | SP3 | GDR | CVE-2020-0618 | 4532095 | [Security update for SQL Server 2014 SP3 GDR: February 11, 2020] | 2020-02-11 | 1 | 1 | 656 | +| 12.0.6108.1 | 2014.120.6108.1 | SP3 | GDR | CVE-2019-1068 | 4505218 | [Security update for SQL Server 2014 SP3 GDR: July 9, 2019] | 2019-07-09 | 1 | 1 | 654 | +| 12.0.6024.0 | 2014.120.6024.0 | SP3 | SP | | 4022619 | [SQL Server 2014 Service Pack 3 release information] | 2018-10-30 | 31 | 6 | 791 | +| 12.0.5687.1 | 2014.120.5687.1 | SP2 | CU | **Latest CU SP2** | 4500180 | [Cumulative Update 18 for SQL Server 2014 SP2] | 2019-07-29 | 7 | 4 | 681 | +| 12.0.5659.1 | 2014.120.5659.1 | SP2 | GDR | CVE-2019-1068 | 4505419 | [Security update for SQL Server 2014 SP2 CU17 GDR: July 9, 2019] | 2019-07-09 | 1 | 1 | 679 | +| 12.0.5632.1 | 2014.120.5632.1 | SP2 | CU | | 4491540 | [Cumulative Update 17 for SQL Server 2014 SP2] | 2019-04-16 | 3 | 3 | 678 | +| 12.0.5626.1 | 2014.120.5626.1 | SP2 | CU | | 4482967 | [Cumulative Update 16 for SQL Server 2014 SP2] | 2019-02-19 | 3 | 3 | 678 | +| 12.0.5605.1 | 2014.120.5605.1 | SP2 | SP | | 4469137 | [Cumulative Update 15 for SQL Server 2014 SP2] | 2018-12-12 | 8 | 7 | 679 | +| 12.0.5600.1 | 2014.120.5600.1 | SP2 | CU | | 4459860 | [Cumulative Update 14 for SQL Server 2014 SP2] | 2018-10-15 | 8 | 6 | 678 | +| 12.0.5590.1 | 2014.120.5590.1 | SP2 | CU | | 4456287 | [Cumulative Update 13 for SQL Server 2014 SP2] | 2018-08-27 | 4 | 4 | 679 | +| 12.0.5589.7 | 2014.120.5589.7 | SP2 | CU | | 4130489 | [Cumulative Update 12 for SQL Server 2014 SP2] | 2018-06-18 | 27 | 16 | 678 | +| 12.0.5579.0 | 2014.120.5579.0 | SP2 | CU | | 4077063 | [Cumulative Update 11 for SQL Server 2014 SP2] | 2018-03-19 | 12 | 10 | 677 | +| 12.0.5571.0 | 2014.120.5571.0 | SP2 | CU | | 4052725 | [Cumulative Update 10 for SQL Server 2014 SP2] | 2018-01-16 | 5 | 4 | 676 | +| 12.0.5563.0 | 2014.120.5563.0 | SP2 | CU | | 4055557 | [Cumulative Update 9 for SQL Server 2014 SP2] | 2017-12-18 | 8 | 7 | 540 | +| 12.0.5557.0 | 2014.120.5557.0 | SP2 | CU | | 4037356 | [Cumulative Update 8 for SQL Server 2014 SP2] | 2017-10-17 | 15 | 8 | 539 | +| 12.0.5556.0 | 2014.120.5556.0 | SP2 | CU | | 4032541 | [Cumulative Update 7 for SQL Server 2014 SP2] | 2017-08-28 | 15 | 8 | 539 | +| 12.0.5553.0 | 2014.120.5553.0 | SP2 | CU | | 4019094 | [Cumulative Update 6 for SQL Server 2014 SP2] | 2017-08-08 | 29 | 29 | 539 | +| 12.0.5546.0 | 2014.120.5546.0 | SP2 | CU | | 4013098 | [Cumulative Update 5 for SQL Server 2014 SP2] | 2017-04-18 | 24 | 21 | 557 | +| 12.0.5540.0 | 2014.120.5540.0 | SP2 | CU | | 4010394 | [Cumulative Update 4 for SQL Server 2014 SP2] | 2017-02-21 | 30 | 27 | 555 | +| 12.0.5538.0 | 2014.120.5538.0 | SP2 | CU | | 3204388 | [Cumulative update 3 for SQL Server 2014 SP2] | 2016-12-28 | 44 | 39 | 555 | +| 12.0.5532.0 | 2014.120.5532.0 | SP2 | CU | | 3194718 | [MS16-136: Description of the security update for SQL Server 2014 Service Pack 2 CU: November 8, 2016] | 2016-11-08 | 1 | 1 | 551 | +| 12.0.5522.0 | 2014.120.5522.0 | SP2 | CU | | 3188778 | [Cumulative update 2 for SQL Server 2014 SP2] | 2016-10-18 | 18 | 18 | 550 | +| 12.0.5511.0 | 2014.120.5511.0 | SP2 | CU | | 3178925 | [Cumulative update 1 for SQL Server 2014 SP2] | 2016-08-24 | 45 | 36 | 556 | +| 12.0.5223.6 | 2014.120.5223.6 | SP2 | GDR | CVE-2019-1068 | 4505217 | [Security update for SQL Server 2014 SP2 GDR: July 9, 2019] | 2019-07-09 | 1 | 1 | 588 | +| 12.0.5214.6 | 2014.120.5214.6 | SP2 | GDR | CVE-2017-5715,2017-5753,2017-5754 | 4057120 | [Security update for SQL Server 2014 Service Pack 2 GDR: January 16, 2018] | 2018-01-16 | | | 960 | +| 12.0.5207.0 | 2014.120.5207.0 | SP2 | GDR | | 4019093 | [Description of the security update for SQL Server 2014 Service Pack 2 GDR: August 8, 2017] | 2017-08-08 | 1 | 1 | 413 | +| 12.0.5203.0 | 2014.120.5203.0 | SP2 | GDR | | 3194714 | [MS16-136: Description of the security update for SQL Server 2014 Service Pack 2 GDR: November 8, 2016] | 2016-11-08 | 1 | 1 | 463 | +| 12.0.5000.0 | 2014.120.5000.0 | SP2 | SP | | 3171021 | [SQL Server 2014 Service Pack 2 release information] | 2016-07-11 | 133 | 55 | 681 | +| 12.0.5626.1 | 2014.120.5626.1 | SP1 | CU | **Latest CU SP1** | 4482967 | [Cumulative Update 13 for SQL Server 2014 SP1] | 2017-08-08 | 11 | 11 | 577 | +| 12.0.4511.0 | 2014.120.4511.0 | SP1 | CU | | 4017793 | [Cumulative Update 12 for SQL Server 2014 SP1] | 2017-04-17 | 12 | 11 | 573 | +| 12.0.4502.0 | 2014.120.4502.0 | SP1 | CU | | 4010392 | [Cumulative Update 11 for SQL Server 2014 SP1] | 2017-02-21 | 15 | 15 | 571 | +| 12.0.4491.0 | 2014.120.4491.0 | SP1 | CU | | 3204399 | [Cumulative update package 10 for SQL Server 2014 Service Pack 1] | 2016-12-28 | 33 | 27 | 571 | +| 12.0.4487.0 | 2014.120.4487.0 | SP1 | CU | | 3194722 | [MS16-136: Description of the security update for SQL Server 2014 Service Pack 1 CU: November 8, 2016] | 2016-11-08 | 1 | 1 | 569 | +| 12.0.4474.0 | 2014.120.4474.0 | SP1 | CU | | 3186964 | [Cumulative update 9 for SQL Server 2014 SP1] | 2016-10-18 | 14 | 14 | 912 | +| 12.0.4468.0 | 2014.120.4468.0 | SP1 | CU | | 3174038 | [Cumulative update 8 for SQL Server 2014 SP1] | 2016-08-16 | 38 | 38 | 929 | +| 12.0.4463.0 | 2014.120.4463.0 | SP1 | COD | | 3174370 | [COD Hotfix A memory leak occurs when you use Azure Storage in SQL Server 2014] | 2016-08-04 | 1 | 1 | | +| 12.0.4459.0 | 2014.120.4459.0 | SP1 | CU | | 3162659 | [Cumulative Update 7 for SQL Server 2014 SP1] | 2016-06-20 | 35 | 33 | 928 | +| 12.0.4457.0 | 2014.120.4457.0 | SP1 | CU | **Refresh** | 3167392 | [Cumulative Update 6 for SQL Server 2014 Service Pack 1] | 2016-05-31 | 44 | 43 | 927 | +| 12.0.4452.0 | 2014.120.4452.0 | SP1 | COD | **Withdrawn** | 3147825 | 3147825 COD Hotfix | 2016-04-05 | 1 | 1 | | +| 12.0.4449.0 | 2014.120.4449.0 | SP1 | CU | **Withdrawn** | 3144524 | [Cumulative update 6 for SQL Server 2014 SP1 (deprecated)] | 2016-04-18 | | | | +| 12.0.4439.1 | 2014.120.4439.1 | SP1 | CU | | 3130926 | [Cumulative Update 5 (CU5) for SQL Server 2014 Service Pack 1] | 2016-02-22 | 20 | 20 | 924 | +| 12.0.4437.0 | 2014.120.4437.0 | SP1 | COD | | 3130999 | [On-demand hotfix update package for SQL Server 2014 Service Pack 1 Cumulative Update 4] | 2016-02-05 | 2 | 2 | | +| 12.0.4436.0 | 2014.120.4436.0 | SP1 | CU | | 3106660 | [Cumulative update package 4 (CU4) for SQL Server 2014 Service Pack 1] | 2015-12-21 | 34 | 34 | | +| 12.0.4433.0 | 2014.120.4433.0 | SP1 | COD | | 3119148 | [FIX: Error 3203 occurs and a SQL Server 2014 backup job can't restart after a network failure] | 2015-12-09 | 1 | 1 | | +| 12.0.4432.0 | 2014.120.4432.0 | SP1 | COD | | 3097972 | [FIX: Error when your stored procedure calls another stored procedure on a linked server in SQL Server 2014] | 2015-11-19 | 3 | 3 | | +| 12.0.4427.24 | 2014.120.4427.24 | SP1 | CU | | 3094221 | [Cumulative update package 3 (CU3) for SQL Server 2014 Service Pack 1] | 2015-10-21 | 40 | 36 | | +| 12.0.4422.0 | 2014.120.4422.0 | SP1 | CU | | 3075950 | [Cumulative update package 2 (CU2) for SQL Server 2014 Service Pack 1] | 2015-08-17 | 51 | 46 | | +| 12.0.4419.0 | 2014.120.4419.0 | SP1 | COD | | 3078973 | [An on-demand hotfix update package is available for SQL Server 2014 SP1] | 2015-07-24 | 13 | 13 | | +| 12.0.4416.0 | 2014.120.4416.0 | SP1 | CU | | 3067839 | [Cumulative update package 1 (CU1) for SQL Server 2014 Service Pack 1] | 2015-06-22 | 141 | 121 | | +| 12.0.4237.0 | 2014.120.4237.0 | SP1 | GDR | | 4019091 | [Security update for SQL Server 2014 Service Pack 1 GDR: August 8, 2017] | 2017-08-08 | 1 | 1 | 391 | +| 12.0.4232.0 | 2014.120.4232.0 | SP1 | CU | | 3194720 | [MS16-136: Description of the security update for SQL Server 2014 Service Pack 1 GDR: November 8, 2016] | 2016-11-08 | 1 | 1 | 371 | +| 12.0.4219.0 | 2014.120.4219.0 | SP1 | GDR | | 3098852 | [SP1 GDR TLS 1.2 Update] | 2016-01-29 | | | | +| 12.0.4213.0 | 2014.120.4213.0 | SP1 | GDR | | 3070446 | [MS15-058: Description of the nonsecurity update for SQL Server 2014 Service Pack 1 GDR: July 14, 2015] | 2015-07-14 | | | 381 | +| 12.0.4100.1 | 2014.120.4100.1 | SP1 | SP | | 3058865 | [SQL Server 2014 Service Pack 1 release information] | 2015-05-14 | 29 | 29 | 1025 | +| 12.0.4050.0 | 2014.120.4050.0 | SP1 | SP | | | SQL Server 2014 Service Pack 1 (SP1) (initial) | 2015-04-15 | | | | +| 12.0.2569.0 | 2014.120.2569.0 | RTM | CU | **Latest CU RTM** | 3158271 | [Cumulative update package 14 (CU14) for SQL Server 2014] | 2016-06-20 | 21 | 20 | 1049 | +| 12.0.2568.0 | 2014.120.2568.0 | RTM | CU | | 3144517 | [Cumulative update package 13 (CU13) for SQL Server 2014] | 2016-04-18 | 30 | 30 | 1047 | +| 12.0.2564.0 | 2014.120.2564.0 | RTM | CU | | 3130923 | [Cumulative update package 12 (CU12) for SQL Server 2014] | 2016-02-22 | 7 | 7 | 1045 | +| 12.0.2560.0 | 2014.120.2550.0 | RTM | CU | | 3106659 | [Cumulative update package 11 (CU11) for SQL Server 2014] | 2015-12-21 | 19 | 19 | | +| 12.0.2556.4 | 2014.120.2556.4 | RTM | CU | | 3094220 | [Cumulative update package 10 (CU10) for SQL Server 2014] | 2015-10-20 | 33 | 30 | | +| 12.0.2553.0 | 2014.120.2553.0 | RTM | CU | | 3075949 | [Cumulative update package 9 (CU9) for SQL Server 2014] | 2015-08-17 | 31 | 30 | | +| 12.0.2548.0 | 2014.120.2548.0 | RTM | CU | | 3045323 | [MS15-058: Description of the security update for SQL Server 2014 QFE: July 14, 2015] | 2015-07-14 | 1 | 1 | 1038 | +| 12.0.2546.0 | 2014.120.2546.0 | RTM | CU | | 3067836 | [Cumulative update package 8 (CU8) for SQL Server 2014] | 2015-06-22 | 40 | 38 | | +| 12.0.2506.0 | 2014.120.2506.0 | RTM | COD | | 3063054 | [Update enables Premium Storage support for Data files on Azure Storage and resolves backup failures] | 2015-05-19 | 1 | 1 | | +| 12.0.2505.0 | 2014.120.2505.0 | RTM | COD | | 3052167 | [FIX: Error 1205 when you execute parallel query that contains outer join operators in SQL Server 2014] | 2015-05-19 | 1 | 1 | | +| 12.0.2504.0 | 2014.120.2504.0 | RTM | COD | | 2999809 | [FIX: Poor performance when a query contains table joins in SQL Server 2014] | 2015-05-05 | 2 | 2 | | +| 12.0.2504.0 | 2014.120.2504.0 | RTM | COD | | 3058512 | [FIX: Unpivot Transformation task changes null to zero or empty strings in SSIS 2014] | 2015-05-05 | | | | +| 12.0.2495.0 | 2014.120.2495.0 | RTM | CU | | 3046038 | [Cumulative update package 7 (CU7) for SQL Server 2014] | 2015-04-23 | 47 | 41 | | +| 12.0.2488.0 | 2014.120.2488.0 | RTM | COD | | 3048751 | [FIX: Deadlock cannot be resolved automatically when you run a SELECT query that can result in a parallel batch-mode scan] | 2015-04-01 | 1 | 1 | | +| 12.0.2485.0 | 2014.120.2485.0 | RTM | COD | | 3043788 | [An on-demand hotfix update package is available for SQL Server 2014] | 2015-03-16 | 1 | 1 | | +| 12.0.2480.0 | 2014.120.2480.0 | RTM | CU | | 3031047 | [Cumulative update package 6 (CU6) for SQL Server 2014] | 2015-02-16 | 64 | 55 | | +| 12.0.2474.0 | 2014.120.2474.0 | RTM | COD | | 3034679 | [FIX: AlwaysOn availability groups are reported as NOT SYNCHRONIZING] | 2015-02-04 | 1 | 1 | | +| 12.0.2472.0 | 2014.120.2472.0 | RTM | COD | | 3032087 | [FIX: Cannot show requested dialog after you connect to the latest SQL Database Update V12 (preview) with SQL Server 2014] | 2015-01-28 | 1 | 1 | | +| 12.0.2464.0 | 2014.120.2464.0 | RTM | COD | | 3024815 | [Large query compilation waits on RESOURCE_SEMAPHORE_QUERY_COMPILE in SQL Server 2014] | 2015-01-05 | 1 | 1 | | +| 12.0.2456.0 | 2014.120.2456.0 | RTM | CU | | 3011055 | [Cumulative update package 5 (CU5) for SQL Server 2014] | 2014-12-18 | 54 | 48 | | +| 12.0.2436.0 | 2014.120.2436.0 | RTM | COD | | 3014867 | [FIX: "Remote hardening failure" exception cannot be caught and a potential data loss when you use SQL Server 2014] | 2014-11-27 | 1 | 1 | | +| 12.0.2430.0 | 2014.120.2430.0 | RTM | CU | | 2999197 | [Cumulative update package 4 (CU4) for SQL Server 2014] | 2014-10-21 | 66 | 54 | | +| 12.0.2423.0 | 2014.120.2423.0 | RTM | COD | | 3007050 | [FIX: RTDATA_LIST waits when you run natively stored procedures that encounter expected failures in SQL Server 2014] | 2014-10-22 | | | | +| 12.0.2405.0 | 2014.120.2405.0 | RTM | COD | | 2999809 | [FIX: Poor performance when a query contains table joins in SQL Server 2014] | 2014-09-25 | | | | +| 12.0.2402.0 | 2014.120.2402.0 | RTM | CU | | 2984923 | [Cumulative update package 3 (CU3) for SQL Server 2014] | 2014-08-18 | 40 | 32 | | +| 12.0.2381.0 | 2014.120.2381.0 | RTM | QFE | | 2977316 | [MS14-044: Description of the security update for SQL Server 2014 (QFE)] | 2014-08-12 | 1 | 1 | 602 | +| 12.0.2370.0 | 2014.120.2370.0 | RTM | CU | | 2967546 | [Cumulative update package 2 (CU2) for SQL Server 2014] | 2014-06-27 | 52 | 48 | | +| 12.0.2342.0 | 2014.120.2342.0 | RTM | CU | | 2931693 | [Cumulative update package 1 (CU1) for SQL Server 2014] | 2014-04-21 | 121 | 114 | | +| 12.0.2271.0 | 2014.120.2271.0 | RTM | GDR | | | [TLS 1.2 support for SQL Server 2014 RTM] | 2016-01-29 | 3 | 3 | | +| 12.0.2269.0 | 2014.120.2269.0 | RTM | GDR | | 3045324 | [MS15-058: Description of the security update for SQL Server 2014 GDR: July 14, 2015] | 2015-07-14 | 2 | 2 | 388 | +| 12.0.2254.0 | 2014.120.2254.0 | RTM | GDR | | 2977315 | [MS14-044: Description of the security update for SQL Server 2014 (GDR)] | 2014-08-12 | 1 | 1 | 183 | +| 12.0.2000.8 | 2014.120.2000.8 | RTM | RTM | | | SQL Server 2014 RTM | 2014-04-01 | | | | +| 12.0.1524.0 | 2014.120.1524.0 | CTP | CTP | | | Microsoft SQL Server 2014 Community Technology Preview 2 (CTP2) | 2013-10-15 | | | | +| 11.0.9120.0 | 2013.110.9120.0 | CTP | CTP | | | Microsoft SQL Server 2014 Community Technology Preview 1 (CTP1) | 2013-06-25 | | | | + +[Description of the security update for SQL Server 2014 SP3 CU4: January 12, 2021]:https://support.microsoft.com/help/4583462 +[Security update for SQL Server 2014 SP3 CU4: February 11, 2020]:https://support.microsoft.com/help/4535288 +[Cumulative Update 4 for SQL Server 2014 SP3]:https://support.microsoft.com/help/4500181 +[Security update for SQL Server 2014 SP3 CU3 GDR: July 9, 2019]:https://support.microsoft.com/help/4505422 +[Cumulative Update 3 for SQL Server 2014 SP3]:https://support.microsoft.com/help/4491539 +[Cumulative Update 2 for SQL Server 2014 SP3]:https://support.microsoft.com/help/4482960 +[Cumulative Update 1 for SQL Server 2014 SP3]:https://support.microsoft.com/help/4470220 +[Security update for SQL Server 2014 SP3 GDR: February 11, 2020]:https://support.microsoft.com/help/4532095 +[Security update for SQL Server 2014 SP3 GDR: July 9, 2019]:https://support.microsoft.com/help/4505218 +[SQL Server 2014 Service Pack 3 release information]:https://support.microsoft.com/help/4022619 +[Cumulative Update 18 for SQL Server 2014 SP2]:https://support.microsoft.com/help/4500180 +[Security update for SQL Server 2014 SP2 CU17 GDR: July 9, 2019]:https://support.microsoft.com/help/4505419 +[Cumulative Update 17 for SQL Server 2014 SP2]:https://support.microsoft.com/help/4491540 +[Cumulative Update 16 for SQL Server 2014 SP2]:https://support.microsoft.com/help/4482967 +[Cumulative Update 15 for SQL Server 2014 SP2]:https://support.microsoft.com/help/4469137 +[Cumulative Update 14 for SQL Server 2014 SP2]:https://support.microsoft.com/help/4459860 +[Cumulative Update 13 for SQL Server 2014 SP2]:https://support.microsoft.com/help/4456287 +[Cumulative Update 12 for SQL Server 2014 SP2]:https://support.microsoft.com/help/4130489 +[Cumulative Update 11 for SQL Server 2014 SP2]:https://support.microsoft.com/help/4077063 +[Cumulative Update 10 for SQL Server 2014 SP2]:https://support.microsoft.com/help/4052725/cumulative-update-10-for-sql-server-2014-sp2 +[Cumulative Update 9 for SQL Server 2014 SP2]:https://support.microsoft.com/help/4055557/cumulative-update-9-for-sql-server-2014-sp2 +[Cumulative Update 8 for SQL Server 2014 SP2]:https://support.microsoft.com/help/4037356/cumulative-update-8-for-sql-server-2014-sp2 +[Cumulative Update 7 for SQL Server 2014 SP2]:https://support.microsoft.com/help/4032541/cumulative-update-7-for-sql-server-2014-sp2 +[Cumulative Update 6 for SQL Server 2014 SP2]:https://support.microsoft.com/help/4019094/cumulative-update-6-for-sql-server-2014-sp2 +[Cumulative Update 5 for SQL Server 2014 SP2]:https://support.microsoft.com/help/4013098/cumulative-update-5-for-sql-server-2014-sp2 +[Cumulative Update 4 for SQL Server 2014 SP2]:https://support.microsoft.com/help/4010394/cumulative-update-4-for-sql-server-2014-sp2 +[Cumulative update 3 for SQL Server 2014 SP2]:https://support.microsoft.com/help/3204388 +[MS16-136: Description of the security update for SQL Server 2014 Service Pack 2 CU: November 8, 2016]:https://support.microsoft.com/help/3194718 +[Cumulative update 2 for SQL Server 2014 SP2]:https://support.microsoft.com/help/3188778 +[Cumulative update 1 for SQL Server 2014 SP2]:https://support.microsoft.com/help/3178925 +[Security update for SQL Server 2014 SP2 GDR: July 9, 2019]:https://support.microsoft.com/help/4505217 +[MS16-136: Description of the security update for SQL Server 2014 Service Pack 2 GDR: November 8, 2016]:https://support.microsoft.com/help/3194714/ +[SQL Server 2014 Service Pack 2 release information]:https://support.microsoft.com/help/3171021 +[Cumulative Update 13 for SQL Server 2014 SP1]:https://support.microsoft.com/help/4019099/cumulative-update-13-for-sql-server-2014-sp1 +[Cumulative Update 12 for SQL Server 2014 SP1]:https://support.microsoft.com/help/4017793/cumulative-update-12-for-sql-server-2014-sp1 +[Cumulative Update 11 for SQL Server 2014 SP1]:https://support.microsoft.com/help/4010392/cumulative-update-11-for-sql-server-2014-sp1 +[Cumulative update package 10 for SQL Server 2014 Service Pack 1]:https://support.microsoft.com/help/3204399 +[MS16-136: Description of the security update for SQL Server 2014 Service Pack 1 CU: November 8, 2016]:https://support.microsoft.com/kb/3194722 +[Cumulative update 9 for SQL Server 2014 SP1]:https://support.microsoft.com/help/3186964 +[Security update for SQL Server 2014 Service Pack 2 GDR: January 16, 2018]:https://support.microsoft.com/help/4057120 +[Description of the security update for SQL Server 2014 Service Pack 2 GDR: August 8, 2017]:https://support.microsoft.com/help/4019093/ +[Cumulative update 8 for SQL Server 2014 SP1]:https://support.microsoft.com/kb/3174038 +[COD Hotfix A memory leak occurs when you use Azure Storage in SQL Server 2014]:https://support.microsoft.com/kb/3174370 +[Cumulative Update 7 for SQL Server 2014 SP1]:https://support.microsoft.com/kb/3162659 +[Cumulative Update 6 for SQL Server 2014 Service Pack 1]:https://support.microsoft.com/kb/3167392 +[Cumulative update 6 for SQL Server 2014 SP1 (deprecated)]:https://support.microsoft.com/kb/3144524 +[Cumulative Update 5 (CU5) for SQL Server 2014 Service Pack 1]:https://support.microsoft.com/kb/3130926 +[On-demand hotfix update package for SQL Server 2014 Service Pack 1 Cumulative Update 4]:https://support.microsoft.com/kb/3130999 +[Cumulative update package 4 (CU4) for SQL Server 2014 Service Pack 1]:https://support.microsoft.com/kb/3106660 +[FIX: Error 3203 occurs and a SQL Server 2014 backup job can't restart after a network failure]:http://support.microsoft.com/kb/3119148 +[FIX: Error when your stored procedure calls another stored procedure on a linked server in SQL Server 2014]:http://support.microsoft.com/kb/3097972 +[Cumulative update package 3 (CU3) for SQL Server 2014 Service Pack 1]:http://support.microsoft.com/kb/3094221 +[Cumulative update package 2 (CU2) for SQL Server 2014 Service Pack 1]:http://support.microsoft.com/kb/3075950 +[An on-demand hotfix update package is available for SQL Server 2014 SP1]:http://support.microsoft.com/kb/3078973 +[Cumulative update package 1 (CU1) for SQL Server 2014 Service Pack 1]:http://support.microsoft.com/kb/3067839 +[Security update for SQL Server 2014 Service Pack 1 GDR: August 8, 2017]:http://support.microsoft.com/help/4019091 +[MS16-136: Description of the security update for SQL Server 2014 Service Pack 1 GDR: November 8, 2016]:https://support.microsoft.com/kb/3194720 +[SP1 GDR TLS 1.2 Update]:https://support.microsoft.com/hotfix/kbhotfix?kbnum=3098852&kbln=en-us +[MS15-058: Description of the nonsecurity update for SQL Server 2014 Service Pack 1 GDR: July 14, 2015]:https://support.microsoft.com/kb/3070446 +[SQL Server 2014 Service Pack 1 release information]:https://support.microsoft.com/kb/3058865 +[Cumulative update package 14 (CU14) for SQL Server 2014]:https://support.microsoft.com/kb/3158271 +[Cumulative update package 13 (CU13) for SQL Server 2014]:https://support.microsoft.com/kb/3144517 +[Cumulative update package 12 (CU12) for SQL Server 2014]:https://support.microsoft.com/kb/3130923 +[Cumulative update package 11 (CU11) for SQL Server 2014]:http://support.microsoft.com/kb/3106659 +[Cumulative update package 10 (CU10) for SQL Server 2014]:http://support.microsoft.com/kb/3094220 +[Cumulative update package 9 (CU9) for SQL Server 2014]:http://support.microsoft.com/kb/3075949 +[MS15-058: Description of the security update for SQL Server 2014 QFE: July 14, 2015]:https://support.microsoft.com/kb/3045323 +[Cumulative update package 8 (CU8) for SQL Server 2014]:http://support.microsoft.com/kb/3067836 +[Update enables Premium Storage support for Data files on Azure Storage and resolves backup failures]:http://support.microsoft.com/kb/3063054 +[FIX: Error 1205 when you execute parallel query that contains outer join operators in SQL Server 2014]:http://support.microsoft.com/kb/3052167 +[FIX: Poor performance when a query contains table joins in SQL Server 2014]:http://support.microsoft.com/kb/2999809 +[FIX: Unpivot Transformation task changes null to zero or empty strings in SSIS 2014]:http://support.microsoft.com/kb/3058512 +[Cumulative update package 7 (CU7) for SQL Server 2014]:http://support.microsoft.com/kb/3046038 +[FIX: Deadlock cannot be resolved automatically when you run a SELECT query that can result in a parallel batch-mode scan]:http://support.microsoft.com/kb/3048751 +[An on-demand hotfix update package is available for SQL Server 2014]:http://support.microsoft.com/kb/3043788 +[Cumulative update package 6 (CU6) for SQL Server 2014]:http://support.microsoft.com/kb/3031047 +[FIX: AlwaysOn availability groups are reported as NOT SYNCHRONIZING]:http://support.microsoft.com/kb/3034679 +[FIX: Cannot show requested dialog after you connect to the latest SQL Database Update V12 (preview) with SQL Server 2014]:http://support.microsoft.com/kb/3032087 +[Large query compilation waits on RESOURCE_SEMAPHORE_QUERY_COMPILE in SQL Server 2014]:http://support.microsoft.com/kb/3024815 +[Cumulative update package 5 (CU5) for SQL Server 2014]:http://support.microsoft.com/kb/3011055 +[FIX: "Remote hardening failure" exception cannot be caught and a potential data loss when you use SQL Server 2014]:http://support.microsoft.com/kb/3014867 +[Cumulative update package 4 (CU4) for SQL Server 2014]:http://support.microsoft.com/kb/2999197 +[FIX: RTDATA_LIST waits when you run natively stored procedures that encounter expected failures in SQL Server 2014]:http://support.microsoft.com/kb/3007050 +[FIX: Poor performance when a query contains table joins in SQL Server 2014]:http://support.microsoft.com/kb/2999809 +[Cumulative update package 3 (CU3) for SQL Server 2014]:http://support.microsoft.com/kb/2984923 +[MS14-044: Description of the security update for SQL Server 2014 (QFE)]:http://support.microsoft.com/kb/2977316 +[Cumulative update package 2 (CU2) for SQL Server 2014]:http://support.microsoft.com/kb/2967546 +[Cumulative update package 1 (CU1) for SQL Server 2014]:http://support.microsoft.com/kb/2931693 +[TLS 1.2 support for SQL Server 2014 RTM]:https://support.microsoft.com/hotfix/kbhotfix?kbnum=3098856&kbln=en-us +[MS15-058: Description of the security update for SQL Server 2014 GDR: July 14, 2015]:https://support.microsoft.com/kb/3045324 +[MS14-044: Description of the security update for SQL Server 2014 (GDR)]:http://support.microsoft.com/kb/2977315 ## Microsoft SQL Server 2012 Builds -| Build | File version | Branch | Type | KB / Description | Release Date | -|---------------|------------------|--------|------|----------------------------------------------------------------------------------------------------------------------------------------|--------------| -| 11.0.7001.0 | 2011.110.7001.0 | SP4 | SP | [4018073 SQL Server 2012 Service Pack 4 release information] | 2017-10-05 | -| 11.0.6607.3 | 2011.110.6607.3 | SP3 | CU | [4016762 Cumulative Update 10 for SQL Server 2012 SP3] | 2017-08-08 | -| 11.0.6598.0 | 2011.110.6598.0 | SP3 | CU | [4016762 Cumulative Update 9 for SQL Server 2012 SP3] | 2017-05-15 | -| 11.0.6594.0 | 2011.110.6594.0 | SP3 | CU | [4013104 Cumulative Update 8 for SQL Server 2012 SP3] | 2017-03-21 | -| 11.0.6579.0 | 2011.110.6579.0 | SP3 | CU | [3205051 Cumulative Update Package 7 for SQL Server 2012 SP3] | 2017-01-18 | -| 11.0.6567.0 | 2011.110.6567.0 | SP3 | COD | [3194724 MS16-136: Description of the security update for SQL Server 2012 Service Pack 3 CU: November 8, 2016] | 2016-11-17 | -| 11.0.6544.0 | 2011.110.6544.0 | SP3 | CU | [3180915 Cumulative update 5 for SQL Server 2012 Service Pack 3] | 2016-09-20 | -| 11.0.6540.0 | 2011.110.6540.0 | SP3 | CU | [3165264 Cumulative Update 4 for SQL Server 2012 SP3] | 2016-07-18 | -| 11.0.6537.0 | 2011.110.6537.0 | SP3 | CU | [3152635 Cumulative update package 3 for SQL Server 2012 SP3] | 2016-05-16 | -| 11.0.6523.0 | 2011.110.6523.0 | SP3 | CU | [3137746 Cumulative update package 2 for SQL Server 2012 SP3] | 2016-03-21 | -| 11.0.6518.0 | 2011.110.6518.0 | SP3 | CU | [3123299 Cumulative update package 1 for SQL Server 2012 SP3] | 2016-01-19 | -| 11.0.6248.0 | 2011.110.6248.0 | SP3 | GDR | [3194721 MS16-136: Description of the security update for SQL Server 2012 Service Pack 3 GDR: November 8, 2016] | 2016-11-08 | -| 11.0.6216.27 | 2011.110.6216.27 | SP3 | GDR | [3135244 TLS 1.2 support for SQL Server 2012 SP3 GDR] | 2016-01-27 | -| 11.3.6020.0 | 2011.110.6020.0 | SP3 | SP | [3072779 Microsoft SQL Server 2012 Service Pack 3 (SP3)] | 2015-11-21 | -| 11.0.5678.0 | 2011.110.5678.0 | SP2 | CU | [3205054 Cumulative Update 16 for SQL Server 2012 SP2] | 2017-01-18 | -| 11.0.5676.0 | 2011.110.5676.0 | SP2 | CU | [3205416 Cumulative update package 15 (CU15) for SQL Server 2012 Service Pack 2] | 2016-11-17 | -| 11.0.5676.0 | 2011.110.5676.0 | SP2 | COD | [3194725 MS16-136: Description of the security update for SQL Server 2012 Service Pack 2 CU: November 8, 2016] | 2016-11-17 | -| 11.0.5657.0 | 2011.110.5657.0 | SP2 | CU | [3180914 Cumulative Update 14 for SQL Server 2012 SP2] | 2016-09-20 | -| 11.0.5655.0 | 2011.110.5655.0 | SP2 | CU | [3165266 Cumulative Update 13 for SQL Server 2012 SP2] | 2016-07-18 | -| 11.0.5649.0 | 2011.110.5649.0 | SP2 | CU | [3152637 Cumulative update package 12 for SQL Server 2012 SP2] | 2016-05-16 | -| 11.0.5646.2 | 2011.110.5646.2 | SP2 | CU | [3137745 Cumulative update package 11 for SQL Server 2012 SP2] | 2016-03-21 | -| 11.0.5644.2 | 2011.110.5644.2 | SP2 | CU | [3120313 Cumulative update package 10 for SQL Server 2012 SP2] | 2016-01-19 | -| 11.0.5641.0 | 2011.110.5641.0 | SP2 | CU | [3098512 Cumulative update package 9 for SQL Server 2012 SP2] | 2015-11-16 | -| 11.0.5636 | 2011.110.5636.3 | SP2 | COD | [3097636 FIX: Performance decrease when application with connection pooling frequently connects or disconnects in SQL Server] | 2015-09-22 | -| 11.0.5634 | 2011.110.5634.0 | SP2 | CU | [3082561 Cumulative update package 8 (CU8) for SQL Server 2012 Service Pack 2] | 2015-09-21 | -| 11.0.5629 | 2011.110.5629.0 | SP2 | COD | [3087872 FIX: Access violations when you use the FileTable feature in SQL Server 2012] | 2015-08-31 | -| 11.0.5623 | 2011.110.5623.0 | SP2 | CU | [3072100 Cumulative update package 7 (CU7) for SQL Server 2012 Service Pack 2] | 2015-07-20 | -| 11.0.5613 | 2011.110.5613.0 | SP2 | COD | [3045319 MS15-058: Description of the security update for SQL Server 2012 Service Pack 2 QFE: July 14, 2015] | 2015-07-14 | -| 11.0.5592 | 2011.110.5592.0 | SP2 | CU | [3052468 Cumulative update package 6 (CU6) for SQL Server 2012 Service Pack 2] | 2015-05-19 | -| 11.0.5582 | 2011.110.5582.0 | SP2 | CU | [3037255 Cumulative update package 5 (CU5) for SQL Server 2012 Service Pack 2] | 2015-03-16 | -| 11.0.5571 | 2011.110.5571.0 | SP2 | COD | [3034679 FIX: AlwaysOn availability groups are reported as NOT SYNCHRONIZING] | 2015-05-15 | -| 11.0.5569 | 2011.110.5569.0 | SP2 | CU | [3007556 Cumulative update package 4 (CU4) for SQL Server 2012 Service Pack 2] | 2015-01-20 | -| 11.0.5556 | 2011.110.5556.0 | SP2 | CU | [3002049 Cumulative update package 3 (CU3) for SQL Server 2012 Service Pack 2] | 2014-11-17 | -| 11.0.5548 | 2011.110.5548.0 | SP2 | CU | [2983175 Cumulative update package 2 (CU2) for SQL Server 2012 Service Pack 2] | 2014-09-15 | -| 11.0.5532 | 2011.110.5532.0 | SP2 | CU | [2976982 Cumulative update package 1 (CU1) for SQL Server 2012 Service Pack 2] | 2014-07-24 | -| 11.0.5522 | 2011.110.5522.0 | SP2 | COD | [2969896 FIX: Data loss in clustered index occurs when you run online build index in SQL Server 2012 (Hotfix for SQL2012 SP2)] | 2014-06-20 | -| 11.0.5388 | 2012.110.5388.0 | SP2 | GDR | [3194719 MS16-136: Description of the security update for SQL Server 2012 Service Pack 2 GDR: November 8, 2016] | 2016-11-08 | -| 11.0.5352 | 2012.110.5352.0 | SP2 | GDR | [3135244 TLS 1.2 support for SQL Server 2012 SP2 GDR] | 2016-01-27 | -| 11.0.5343 | 2011.110.5343.0 | SP2 | GDR | [3045321 MS15-058: Description of the security update for SQL Server 2012 Service Pack 2 GDR: July 14, 2015] | 2015-07-14 | -| 11.0.5058 | 2011.110.5058.0 | SP2 | SP | [SQL Server 2012 Service Pack 2 (SP2)] | 2014-06-10 | -| 11.0.3513 | 2011.110.3513.0 | SP1 | QFE | [3045317 MS15-058: Description of the security update for SQL Server 2012 SP1 QFE: July 14, 2015] | 2015-07-14 | -| 11.0.3492 | 2011.110.3492.0 | SP1 | CU | [3052476 Cumulative update package 16 (CU16) for SQL Server 2012 Service Pack 1] | 2015-05-18 | -| 11.0.3487 | 2011.110.3487.0 | SP1 | CU | [3038001 Cumulative update package 15 (CU15) for SQL Server 2012 Service Pack 1] | 2015-03-16 | -| 11.0.3486 | 2011.110.3486.0 | SP1 | QFE | [3023636 Cumulative update package 14 (CU14) for SQL Server 2012 Service Pack 1] | 2015-01-19 | -| 11.0.3460 | 2011.110.3460.0 | SP1 | COD | [2977325 MS14-044: Description of the security update for SQL Server 2012 Service Pack 1 (QFE)] | 2014-08-12 | -| 11.0.3482 | 2011.110.3482.0 | SP1 | CU | [3002044 Cumulative update package 13 (CU13) for SQL Server 2012 Service Pack 1] | 2014-11-17 | -| 11.0.3470 | 2011.110.3470.0 | SP1 | CU | [2991533 Cumulative update package 12 (CU12) for SQL Server 2012 Service Pack 1] | 2014-09-15 | -| 11.0.3449 | 2011.110.3449.0 | SP1 | CU | [2975396 Cumulative update package 11 (CU11) for SQL Server 2012 Service Pack 1] | 2014-07-21 | -| 11.0.3437 | 2011.110.3437.0 | SP1 | COD | [2969896 FIX: Data loss in clustered index occurs when you run online build index in SQL Server 2012 (Hotfix for SQL2012 SP1)] | 2014-06-10 | -| 11.0.3431 | 2011.110.3431.0 | SP1 | CU | [2954099 Cumulative update package 10 (CU10) for SQL Server 2012 Service Pack 1] | 2014-05-19 | -| 11.0.3412 | 2011.110.3412.0 | SP1 | CU | [2931078 Cumulative update package 9 (CU9) for SQL Server 2012 Service Pack 1] | 2014-03-18 | -| 11.0.3401 | 2011.110.3401.0 | SP1 | CU | [2917531 Cumulative update package 8 (CU8) for SQL Server 2012 Service Pack 1] | 2014-01-20 | -| 11.0.3393 | 2011.110.3393.0 | SP1 | CU | [2894115 Cumulative update package 7 (CU7) for SQL Server 2012 Service Pack 1] | 2013-11-18 | -| 11.0.3381 | 2011.110.3381.0 | SP1 | CU | [2874879 Cumulative update package 6 (CU6) for SQL Server 2012 Service Pack 1] | 2013-09-16 | -| 11.0.3373 | 2011.110.3373.0 | SP1 | CU | [2861107 Cumulative update package 5 (CU5) for SQL Server 2012 Service Pack 1] | 2013-07-16 | -| 11.0.3368 | 2011.110.3368.0 | SP1 | CU | [2833645 Cumulative update package 4 (CU4) for SQL Server 2012 Service Pack 1] | 2013-05-31 | -| 11.0.3350 | 2011.110.3350.0 | SP1 | COD | [2832017 FIX: You can’t create or open SSIS projects or maintenance plans after you apply Cumulative Update 3 for SQL Server 2012 SP1] | 2013-04-17 | -| 11.0.3349 | 2011.110.3349.0 | SP1 | CU | [2812412 Cumulative update package 3 (CU3) for SQL Server 2012 Service Pack 1] | 2013-03-18 | -| 11.0.3339 | 2011.110.3339.0 | SP1 | CU | [2790947 Cumulative update package 2 (CU2) for SQL Server 2012 Service Pack 1] | 2013-01-25 | -| 11.0.3335 | 2011.110.3335.0 | SP1 | COD | [2800050 FIX: Component installation process fails after you install SQL Server 2012 SP1] | 2013-01-14 | -| 11.0.3321 | 2011.110.3321.0 | SP1 | CU | [2765331 Cumulative update package 1 (CU1) for SQL Server 2012 Service Pack 1] | 2012-11-20 | -| 11.0.3156 | 2011.110.3156.0 | SP1 | COD | [3045318 MS15-058: Description of the security update for SQL Server 2012 SP1 GDR: July 14, 2015] | 2015-07-14 | -| 11.0.3153 | 2011.110.3153.0 | SP1 | GDR | [2977326 MS14-044: Description of the security update for SQL Server 2012 Service Pack 1 (GDR)] | 2014-08-12 | -| 11.0.3128 | 2011.110.3128.0 | SP1 | COD | [2793634 Windows Installer starts repeatedly after you install SQL Server 2012 SP1] | 2013-01-03 | -| 11.0.3000 | 2011.110.3000.0 | SP1 | SP | [SQL Server 2012 Service Pack 1 (SP1)] | 2012-11-06 | -| 11.0.2845 | 2011.110.2845.0 | SP1 | CTP | SQL Server 2012 Service Pack 1 Customer Technology Preview 4 (CTP4) | 2012-09-20 | -| 11.0.2809 | 2011.110.2809.24 | SP1 | CTP | SQL Server 2012 Service Pack 1 Customer Technology Preview 3 (CTP3) | 2012-07-05 | -| 11.0.2424 | 2011.110.2424.0 | RTM | CU | [2908007 Cumulative update package 11 (CU11) for SQL Server 2012] | 2013-12-17 | -| 11.0.2420 | 2011.110.2420.0 | RTM | CU | [2891666 Cumulative update package 10 (CU10) for SQL Server 2012] | 2013-10-21 | -| 11.0.2419 | 2011.110.2419.0 | RTM | CU | [2867319 Cumulative update package 9 (CU9) for SQL Server 2012] | 2013-08-21 | -| 11.0.2410 | 2011.110.2410.0 | RTM | CU | [2844205 Cumulative update package 8 (CU8) for SQL Server 2012] | 2013-06-18 | -| 11.0.2405 | 2011.110.2405.0 | RTM | CU | [2823247 Cumulative update package 7 (CU7) for SQL Server 2012] | 2013-04-15 | -| 11.0.2401 | 2011.110.2401.0 | RTM | CU | [2728897 Cumulative update package 6 (CU6) for SQL Server 2012] | 2013-02-18 | -| 11.0.2395 | 2011.110.2395.0 | RTM | CU | [2777772 Cumulative update package 5 (CU5) for SQL Server 2012] | 2012-12-18 | -| 11.0.9000 | 2011.110.9000.5 | RTM | CTP | Microsoft SQL Server 2012 With Power View For Multidimensional Models Customer Technology Preview (CTP3) | 2012-11-27 | -| 11.0.2383 | 2011.110.2383.0 | RTM | CU | [2758687 Cumulative update package 4 (CU4) for SQL Server 2012] | 2012-10-18 | -| 11.0.2376 | 2011.110.2376.0 | RTM | COD | [Microsoft Security Bulletin MS12-070] | 2012-10-09 | -| 11.0.2332 | 2011.110.2332.0 | RTM | CU | [2723749 Cumulative update package 3 (CU3) for SQL Server 2012] | 2012-08-29 | -| 11.0.2325 | 2011.110.2325.0 | RTM | CU | [2703275 Cumulative update package 2 (CU2) for SQL Server 2012] | 2012-06-18 | -| 11.0.2316 | 2011.110.2316.0 | RTM | CU | [2679368 Cumulative update package 1 (CU1) for SQL Server 2012] | 2012-04-12 | -| 11.0.2218 | 2011.110.2218.0 | RTM | COD | [Microsoft Security Bulletin MS12-070] | 2012-10-09 | -| 11.0.2214 | 2011.110.2214.0 | RTM | COD | 2685308 FIX: SSAS uses only 20 cores in SQL Server 2012 Business Intelligence | 2012-04-06 | -| 11.0.2100 | 2011.110.2100.60 | RTM | RTM | SQL Server 2012 RTM | 2012-03-06 | -| 11.0.1913 | 2011.110.1913.37 | RC | RC | Microsoft SQL Server 2012 Release Candidate 1 (RC1) | 2011-12-16 | -| 11.0.1750 | 2011.110.1750.32 | RC | RC | Microsoft SQL Server 2012 Release Candidate 0 (RC0) | 2011-11-17 | -| 11.0.1440 | 2010.110.1440.19 | CTP | CTP | Microsoft SQL Server 2012 (codename Denali) Community Technology Preview 3 (CTP3) | 2011-07-11 | -| 11.0.1103 | 2010.110.1103.9 | CTP | CTP | Microsoft SQL Server 2012 (codename Denali) Community Technology Preview 1 (CTP1) | 2010-11-08 | - -[4018073 SQL Server 2012 Service Pack 4 release information]:https://support.microsoft.com/en-us/help/4018073/sql-server-2012-service-pack-4-release-information -[4016762 Cumulative Update 10 for SQL Server 2012 SP3]:https://support.microsoft.com/en-us/help/4025925/cumulative-update-10-for-sql-server-2012-sp3 -[4016762 Cumulative Update 9 for SQL Server 2012 SP3]:https://support.microsoft.com/en-us/help/4016762/cumulative-update-9-for-sql-server-2012-sp3 -[4013104 Cumulative Update 8 for SQL Server 2012 SP3]:https://support.microsoft.com/en-us/help/4013104/cumulative-update-8-for-sql-server-2012-sp3 -[3205051 Cumulative Update Package 7 for SQL Server 2012 SP3]:https://support.microsoft.com/en-us/help/3205051/cumulative-update-7-for-sql-server-2012-sp3 -[3194724 MS16-136: Description of the security update for SQL Server 2012 Service Pack 3 CU: November 8, 2016]:https://support.microsoft.com/en-us/kb/3194724 -[3194725 MS16-136: Description of the security update for SQL Server 2012 Service Pack 2 CU: November 8, 2016]:https://support.microsoft.com/en-us/kb/3194725 -[3180914 Cumulative Update 14 for SQL Server 2012 SP2]:https://support.microsoft.com/en-us/kb/3180914 -[3180915 Cumulative update 5 for SQL Server 2012 Service Pack 3]:https://support.microsoft.com/en-us/kb/3180915 -[3165264 Cumulative Update 4 for SQL Server 2012 SP3]:https://support.microsoft.com/en-us/kb/3165264 -[3165266 Cumulative Update 13 for SQL Server 2012 SP2]:https://support.microsoft.com/en-us/kb/3165266 -[3152635 Cumulative update package 3 for SQL Server 2012 SP3]:https://support.microsoft.com/en-us/kb/3152635 -[3152637 Cumulative update package 12 for SQL Server 2012 SP2]:https://support.microsoft.com/en-us/kb/3152637 -[3137746 Cumulative update package 2 for SQL Server 2012 SP3]:https://support.microsoft.com/en-us/kb/3137746 -[3137745 Cumulative update package 11 for SQL Server 2012 SP2]:https://support.microsoft.com/en-us/kb/3137745 -[3123299 Cumulative update package 1 for SQL Server 2012 SP3]:https://support.microsoft.com/en-us/kb/3123299 -[3205416 Cumulative update package 15 (CU15) for SQL Server 2012 Service Pack 2]:https://support.microsoft.com/en-us/kb/3205416 -[3194721 MS16-136: Description of the security update for SQL Server 2012 Service Pack 3 GDR: November 8, 2016]:https://support.microsoft.com/en-us/kb/3194721 -[3135244 TLS 1.2 support for SQL Server 2012 SP3 GDR]:https://support.microsoft.com/en-us/kb/3135244 -[3120313 Cumulative update package 10 for SQL Server 2012 SP2]:https://support.microsoft.com/en-us/kb/3120313 -[3072779 Microsoft SQL Server 2012 Service Pack 3 (SP3)]:https://support.microsoft.com/en-us/kb/3072779 -[3205054 Cumulative Update 16 for SQL Server 2012 SP2]:https://support.microsoft.com/en-us/help/3205054/cumulative-update-16-for-sql-server-2012-sp2 -[3098512 Cumulative update package 9 for SQL Server 2012 SP2]:https://support.microsoft.com/en-us/kb/3098512 -[3097636 FIX: Performance decrease when application with connection pooling frequently connects or disconnects in SQL Server]:https://support.microsoft.com/en-us/kb/3097636 -[3082561 Cumulative update package 8 (CU8) for SQL Server 2012 Service Pack 2]:http://support.microsoft.com/kb/3082561 -[3087872 FIX: Access violations when you use the FileTable feature in SQL Server 2012]:https://support.microsoft.com/en-us/kb/3087872 -[3072100 Cumulative update package 7 (CU7) for SQL Server 2012 Service Pack 2]:http://support.microsoft.com/kb/3072100 -[3045319 MS15-058: Description of the security update for SQL Server 2012 Service Pack 2 QFE: July 14, 2015]:https://support.microsoft.com/en-us/kb/3045319 -[3052468 Cumulative update package 6 (CU6) for SQL Server 2012 Service Pack 2]:http://support.microsoft.com/kb/3052468 -[3037255 Cumulative update package 5 (CU5) for SQL Server 2012 Service Pack 2]:http://support.microsoft.com/kb/3037255 -[3034679 FIX: AlwaysOn availability groups are reported as NOT SYNCHRONIZING]:http://support.microsoft.com/kb/3034679 -[3007556 Cumulative update package 4 (CU4) for SQL Server 2012 Service Pack 2]:http://support.microsoft.com/kb/3007556 -[3002049 Cumulative update package 3 (CU3) for SQL Server 2012 Service Pack 2]:http://support.microsoft.com/kb/3002049 -[2983175 Cumulative update package 2 (CU2) for SQL Server 2012 Service Pack 2]:http://support.microsoft.com/kb/2983175 -[2976982 Cumulative update package 1 (CU1) for SQL Server 2012 Service Pack 2]:http://support.microsoft.com/kb/2976982 -[2969896 FIX: Data loss in clustered index occurs when you run online build index in SQL Server 2012 (Hotfix for SQL2012 SP2)]:http://support.microsoft.com/kb/2969896 -[3194719 MS16-136: Description of the security update for SQL Server 2012 Service Pack 2 GDR: November 8, 2016]:https://support.microsoft.com/en-us/kb/3194719 -[3135244 TLS 1.2 support for SQL Server 2012 SP2 GDR]:https://support.microsoft.com/en-us/kb/3135244 -[3045321 MS15-058: Description of the security update for SQL Server 2012 Service Pack 2 GDR: July 14, 2015]:https://support.microsoft.com/en-us/kb/3045321 -[SQL Server 2012 Service Pack 2 (SP2)]:http://www.microsoft.com/en-us/download/details.aspx?id=43340 -[3045317 MS15-058: Description of the security update for SQL Server 2012 SP1 QFE: July 14, 2015]:https://support.microsoft.com/en-us/kb/3045317 -[3052476 Cumulative update package 16 (CU16) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/3052476 -[3038001 Cumulative update package 15 (CU15) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/3038001 -[3023636 Cumulative update package 14 (CU14) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/3023636 -[2977325 MS14-044: Description of the security update for SQL Server 2012 Service Pack 1 (QFE)]:http://support.microsoft.com/kb/2977325 -[3002044 Cumulative update package 13 (CU13) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/3002044 -[2991533 Cumulative update package 12 (CU12) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/2991533 -[2975396 Cumulative update package 11 (CU11) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/2975396 -[2969896 FIX: Data loss in clustered index occurs when you run online build index in SQL Server 2012 (Hotfix for SQL2012 SP1)]:http://support.microsoft.com/kb/2969896 -[2954099 Cumulative update package 10 (CU10) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/2954099 -[2931078 Cumulative update package 9 (CU9) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/2931078 -[2917531 Cumulative update package 8 (CU8) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/2917531 -[2894115 Cumulative update package 7 (CU7) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/2894115 -[2874879 Cumulative update package 6 (CU6) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/2874879 -[2861107 Cumulative update package 5 (CU5) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/2861107 -[2833645 Cumulative update package 4 (CU4) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/2833645 -[2832017 FIX: You can’t create or open SSIS projects or maintenance plans after you apply Cumulative Update 3 for SQL Server 2012 SP1]:http://support.microsoft.com/kb/2832017 -[2812412 Cumulative update package 3 (CU3) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/2812412 -[2790947 Cumulative update package 2 (CU2) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/2790947 -[2800050 FIX: Component installation process fails after you install SQL Server 2012 SP1]:http://support.microsoft.com/kb/2800050 -[2765331 Cumulative update package 1 (CU1) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/2765331 -[3045318 MS15-058: Description of the security update for SQL Server 2012 SP1 GDR: July 14, 2015]:https://support.microsoft.com/en-us/kb/3045318 -[2977326 MS14-044: Description of the security update for SQL Server 2012 Service Pack 1 (GDR)]:http://support.microsoft.com/kb/2977326 -[2793634 Windows Installer starts repeatedly after you install SQL Server 2012 SP1]:http://support.microsoft.com/kb/2793634 -[SQL Server 2012 Service Pack 1 (SP1)]:http://www.microsoft.com/en-us/download/details.aspx?id=35575 -[2908007 Cumulative update package 11 (CU11) for SQL Server 2012]:http://support.microsoft.com/kb/2908007 -[2891666 Cumulative update package 10 (CU10) for SQL Server 2012]:http://support.microsoft.com/kb/2891666 -[2867319 Cumulative update package 9 (CU9) for SQL Server 2012]:http://support.microsoft.com/kb/2867319 -[2844205 Cumulative update package 8 (CU8) for SQL Server 2012]:http://support.microsoft.com/kb/2844205 -[2823247 Cumulative update package 7 (CU7) for SQL Server 2012]:http://support.microsoft.com/kb/2823247 -[2728897 Cumulative update package 6 (CU6) for SQL Server 2012]:http://support.microsoft.com/kb/2728897 -[2777772 Cumulative update package 5 (CU5) for SQL Server 2012]:http://support.microsoft.com/kb/2777772 -[2758687 Cumulative update package 4 (CU4) for SQL Server 2012]:http://support.microsoft.com/kb/2758687 -[Microsoft Security Bulletin MS12-070]:http://technet.microsoft.com/en-us/security/bulletin/ms12-070 -[2723749 Cumulative update package 3 (CU3) for SQL Server 2012]:http://support.microsoft.com/kb/2723749 -[2703275 Cumulative update package 2 (CU2) for SQL Server 2012]:http://support.microsoft.com/kb/2703275 -[2679368 Cumulative update package 1 (CU1) for SQL Server 2012]:http://support.microsoft.com/kb/2679368 -[2685308 FIX: SSAS uses only 20 cores in SQL Server 2012 Business Intelligence]:http://support.microsoft.com/kb/2685308 +⚠ End-of-Life: SQL Server 2012 reached [end of mainstream support on July 11th, 2017](https://support.microsoft.com/en-us/lifecycle/search?alpha=sql%20server%202012%20Service%20Pack%204). + +All SQL Server 2012 CU downloads: [Catalog Update Microsoft SQL Server 2012](http://www.catalog.update.microsoft.com/Search.aspx?q=sql%20server%202012) + +| Build | File version | Branch | Type | Info | KB | Description/Link | Release Date | Fixes | Public | +|---------------|------------------|--------|------|-----------------------------------|---------|--------------------------------------------------------------------------------------------------------------------------------|--------------|-------|--------| +| 11.0.7507.2 | 2011.110.7507.2 | SP4 | GDR | CVE-2021-1636 | 4583465 | [Description of the security update for SQL Server 2012 SP4 GDR: January 12, 2021] | 2021-01-12 | 1 | 1 | +| 11.0.7493.4 | 2011.110.7462.6 | SP4 | GDR | CVE-2020-0618 | 4532098 | [Security update for SQL Server 2012 SP4 GDR: February 11, 2020] | 2020-02-11 | 1 | 1 | +| 11.0.7469.6 | 2011.110.7469.6 | SP4 | CU | **Latest CU SP4** | 4091266 | [On-demand hotfix update package for SQL Server 2012 SP4] | 2018-03-28 | 2 | 2 | +| 11.0.7462.6 | 2011.110.7462.6 | SP4 | GDR | CVE-2017-5715,2017-5753,2017-5754 | 4057116 | [Security Advisory ADV180002 (GDR)] | 2018-01-12 | 1 | 1 | +| 11.0.7001.0 | 2011.110.7001.0 | SP4 | SP | | 4018073 | [SQL Server 2012 Service Pack 4 release information] | 2017-10-05 | 23 | 23 | +| 11.0.6615.2 | 2012.110.6615.2 | SP3 | CU | CVE-2017-5715,2017-5753,2017-5754 | 4057121 | [Description of the security update for SQL Server 2012 SP3 CU: January 16, 2018] | 2018-01-16 | 1 | 1 | +| 11.0.6607.3 | 2011.110.6607.3 | SP3 | CU | **Latest CU SP3** | 4016762 | [Cumulative Update 10 for SQL Server 2012 SP3] | 2017-08-08 | 5 | 15 | +| 11.0.6598.0 | 2011.110.6598.0 | SP3 | CU | | 4016762 | [Cumulative Update 9 for SQL Server 2012 SP3] | 2017-05-15 | 12 | 10 | +| 11.0.6594.0 | 2011.110.6594.0 | SP3 | CU | | 4013104 | [Cumulative Update 8 for SQL Server 2012 SP3] | 2017-03-21 | 17 | 17 | +| 11.0.6579.0 | 2011.110.6579.0 | SP3 | CU | | 3205051 | [Cumulative Update Package 7 for SQL Server 2012 SP3] | 2017-01-18 | 12 | 12 | +| 11.0.6567.0 | 2011.110.6567.0 | SP3 | COD | | 3194724 | [MS16-136: Description of the security update for SQL Server 2012 Service Pack 3 CU: November 8, 2016] | 2016-11-17 | 16 | 11 | +| 11.0.6544.0 | 2011.110.6544.0 | SP3 | CU | | 3180915 | [Cumulative update 5 for SQL Server 2012 Service Pack 3] | 2016-09-20 | 21 | 18 | +| 11.0.6540.0 | 2011.110.6540.0 | SP3 | CU | | 3165264 | [Cumulative Update 4 for SQL Server 2012 SP3] | 2016-07-18 | 23 | 22 | +| 11.0.6537.0 | 2011.110.6537.0 | SP3 | CU | | 3152635 | [Cumulative update package 3 for SQL Server 2012 SP3] | 2016-05-17 | 21 | 21 | +| 11.0.6523.0 | 2011.110.6523.0 | SP3 | CU | | 3137746 | [Cumulative update package 2 for SQL Server 2012 SP3] | 2016-03-22 | 21 | 19 | +| 11.0.6518.0 | 2011.110.6518.0 | SP3 | CU | | 3123299 | [Cumulative update package 1 for SQL Server 2012 SP3] | 2016-01-19 | 8 | 8 | +| 11.0.6260.1 | 2011.110.6260.1 | SP3 | GDR | CVE-2017-5715,2017-5753,2017-5754 | 4057115 | [Description of the security update for SQL Server 2012 SP3 GDR: January 16, 2018 – Security Advisory ADV180002] | 2018-01-16 | 1 | 1 | +| 11.0.6248.0 | 2011.110.6248.0 | SP3 | GDR | | 3194721 | [MS16-136: Description of the security update for SQL Server 2012 Service Pack 3 GDR: November 8, 2016] | 2016-11-08 | 1 | 1 | +| 11.0.6216.27 | 2011.110.6216.27 | SP3 | GDR | | 3135244 | [TLS 1.2 support for SQL Server 2012 SP3 GDR] | 2016-01-27 | 1 | 1 | +| 11.3.6020.0 | 2011.110.6020.0 | SP3 | SP | | 3072779 | [Microsoft SQL Server 2012 Service Pack 3 (SP3)] | 2015-11-21 | 37 | 37 | +| 11.0.5678.0 | 2011.110.5678.0 | SP2 | CU | **Latest CU SP2** | 3205054 | [Cumulative Update 16 for SQL Server 2012 SP2] | 2017-01-18 | 5 | 4 | +| 11.0.5676.0 | 2011.110.5676.0 | SP2 | CU | | 3205416 | [Cumulative update package 15 (CU15) for SQL Server 2012 Service Pack 2] | 2016-11-17 | 2 | 1 | +| 11.0.5676.0 | 2011.110.5676.0 | SP2 | COD | | 3194725 | [MS16-136: Description of the security update for SQL Server 2012 Service Pack 2 CU: November 8, 2016] | 2016-11-08 | 2 | 1 | +| 11.0.5657.0 | 2011.110.5657.0 | SP2 | CU | | 3180914 | [Cumulative Update 14 for SQL Server 2012 SP2] | 2016-09-20 | 1 | 1 | +| 11.0.5655.0 | 2011.110.5655.0 | SP2 | CU | | 3165266 | [Cumulative Update 13 for SQL Server 2012 SP2] | 2016-07-18 | 7 | 6 | +| 11.0.5649.0 | 2011.110.5649.0 | SP2 | CU | | 3152637 | [Cumulative update package 12 for SQL Server 2012 SP2] | 2016-05-16 | 7 | 7 | +| 11.0.5646.2 | 2011.110.5646.2 | SP2 | CU | | 3137745 | [Cumulative update package 11 for SQL Server 2012 SP2] | 2016-03-22 | 14 | 13 | +| 11.0.5644.2 | 2011.110.5644.2 | SP2 | CU | | 3120313 | [Cumulative update package 10 for SQL Server 2012 SP2] | 2016-01-19 | 14 | 12 | +| 11.0.5641.0 | 2011.110.5641.0 | SP2 | CU | | 3098512 | [Cumulative update package 9 for SQL Server 2012 SP2] | 2015-11-18 | 14 | 13 | +| 11.0.5636 | 2011.110.5636.3 | SP2 | COD | | 3097636 | [FIX: Performance decrease when application with connection pooling frequently connects or disconnects in SQL Server] | 2015-09-22 | 1 | 1 | +| 11.0.5634 | 2011.110.5634.0 | SP2 | CU | | 3082561 | [Cumulative update package 8 (CU8) for SQL Server 2012 Service Pack 2] | 2015-09-21 | 24 | 23 | +| 11.0.5629 | 2011.110.5629.0 | SP2 | COD | | 3087872 | [FIX: Access violations when you use the FileTable feature in SQL Server 2012] | 2015-08-31 | 1 | 1 | +| 11.0.5623 | 2011.110.5623.0 | SP2 | CU | | 3072100 | [Cumulative update package 7 (CU7) for SQL Server 2012 Service Pack 2] | 2015-07-20 | 38 | 33 | +| 11.0.5613 | 2011.110.5613.0 | SP2 | COD | | 3045319 | [MS15-058: Description of the security update for SQL Server 2012 Service Pack 2 QFE: July 14, 2015] | 2015-07-14 | 1 | 1 | +| 11.0.5592 | 2011.110.5592.0 | SP2 | CU | | 3052468 | [Cumulative update package 6 (CU6) for SQL Server 2012 Service Pack 2] | 2015-05-19 | 23 | 23 | +| 11.0.5582 | 2011.110.5582.0 | SP2 | CU | | 3037255 | [Cumulative update package 5 (CU5) for SQL Server 2012 Service Pack 2] | 2015-03-16 | 27 | 27 | +| 11.0.5571 | 2011.110.5571.0 | SP2 | COD | | 3034679 | [FIX: AlwaysOn availability groups are reported as NOT SYNCHRONIZING] | 2015-02-04 | 1 | 1 | +| 11.0.5569 | 2011.110.5569.0 | SP2 | CU | | 3007556 | [Cumulative update package 4 (CU4) for SQL Server 2012 Service Pack 2] | 2015-01-20 | 42 | 36 | +| 11.0.5556 | 2011.110.5556.0 | SP2 | CU | | 3002049 | [Cumulative update package 3 (CU3) for SQL Server 2012 Service Pack 2] | 2014-11-17 | 40 | 33 | +| 11.0.5548 | 2011.110.5548.0 | SP2 | CU | | 2983175 | [Cumulative update package 2 (CU2) for SQL Server 2012 Service Pack 2] | 2014-09-15 | 52 | 50 | +| 11.0.5532 | 2011.110.5532.0 | SP2 | CU | | 2976982 | [Cumulative update package 1 (CU1) for SQL Server 2012 Service Pack 2] | 2014-07-24 | 46 | 45 | +| 11.0.5522 | 2011.110.5522.0 | SP2 | COD | | 2969896 | [FIX: Data loss in clustered index occurs when you run online build index in SQL Server 2012 (Hotfix for SQL2012 SP2)] | 2014-06-20 | 1 | 1 | +| 11.0.5388 | 2012.110.5388.0 | SP2 | GDR | | 3194719 | [MS16-136: Description of the security update for SQL Server 2012 Service Pack 2 GDR: November 8, 2016] | 2016-11-08 | 1 | 1 | +| 11.0.5352 | 2012.110.5352.0 | SP2 | GDR | | 3135244 | [TLS 1.2 support for SQL Server 2012 SP2 GDR] | 2016-01-27 | 2 | 2 | +| 11.0.5343 | 2011.110.5343.0 | SP2 | GDR | | 3045321 | [MS15-058: Description of the security update for SQL Server 2012 Service Pack 2 GDR: July 14, 2015] | 2015-07-14 | 1 | 1 | +| 11.0.5058 | 2011.110.5058.0 | SP2 | SP | | | [SQL Server 2012 Service Pack 2 (SP2)] | 2014-06-10 | 37 | 37 | +| 11.0.3513 | 2011.110.3513.0 | SP1 | QFE | **Latest CU SP1** | 3045317 | [MS15-058: Description of the security update for SQL Server 2012 SP1 QFE: July 14, 2015] | 2015-07-14 | 1 | 1 | +| 11.0.3492 | 2011.110.3492.0 | SP1 | CU | | 3052476 | [Cumulative update package 16 (CU16) for SQL Server 2012 Service Pack 1] | 2015-05-18 | 4 | 4 | +| 11.0.3487 | 2011.110.3487.0 | SP1 | CU | | 3038001 | [Cumulative update package 15 (CU15) for SQL Server 2012 Service Pack 1] | 2015-03-16 | 1 | 1 | +| 11.0.3486 | 2011.110.3486.0 | SP1 | QFE | | 3023636 | [Cumulative update package 14 (CU14) for SQL Server 2012 Service Pack 1] | 2015-01-19 | 9 | 8 | +| 11.0.3482 | 2011.110.3482.0 | SP1 | CU | | 3002044 | [Cumulative update package 13 (CU13) for SQL Server 2012 Service Pack 1] | 2014-11-17 | 13 | 10 | +| 11.0.3470 | 2011.110.3470.0 | SP1 | CU | | 2991533 | [Cumulative update package 12 (CU12) for SQL Server 2012 Service Pack 1] | 2014-09-15 | 16 | 14 | +| 11.0.3467 | 2011.110.3467.0 | SP1 | COD | | 2975402 | [COD Hotfix 2975402] | 2014-08-28 | 1 | 1 | +| 11.0.3460 | 2011.110.3460.0 | SP1 | COD | | 2977325 | [MS14-044: Description of the security update for SQL Server 2012 Service Pack 1 (QFE)] | 2014-08-12 | 1 | 1 | +| 11.0.3449 | 2011.110.3449.0 | SP1 | CU | | 2975396 | [Cumulative update package 11 (CU11) for SQL Server 2012 Service Pack 1] | 2014-07-21 | 32 | 32 | +| 11.0.3437 | 2011.110.3437.0 | SP1 | COD | | 2969896 | [FIX: Data loss in clustered index occurs when you run online build index in SQL Server 2012 (Hotfix for SQL2012 SP1)] | 2014-06-10 | 1 | 1 | +| 11.0.3431 | 2011.110.3431.0 | SP1 | CU | | 2954099 | [Cumulative update package 10 (CU10) for SQL Server 2012 Service Pack 1] | 2014-05-19 | 38 | 36 | +| 11.0.3412 | 2011.110.3412.0 | SP1 | CU | | 2931078 | [Cumulative update package 9 (CU9) for SQL Server 2012 Service Pack 1] | 2014-03-18 | | | +| 11.0.3401 | 2011.110.3401.0 | SP1 | CU | | 2917531 | [Cumulative update package 8 (CU8) for SQL Server 2012 Service Pack 1] | 2014-01-20 | | | +| 11.0.3393 | 2011.110.3393.0 | SP1 | CU | | 2894115 | [Cumulative update package 7 (CU7) for SQL Server 2012 Service Pack 1] | 2013-11-18 | | | +| 11.0.3381 | 2011.110.3381.0 | SP1 | CU | | 2874879 | [Cumulative update package 6 (CU6) for SQL Server 2012 Service Pack 1] | 2013-09-16 | | | +| 11.0.3373 | 2011.110.3373.0 | SP1 | CU | | 2861107 | [Cumulative update package 5 (CU5) for SQL Server 2012 Service Pack 1] | 2013-07-16 | | | +| 11.0.3368 | 2011.110.3368.0 | SP1 | CU | | 2833645 | [Cumulative update package 4 (CU4) for SQL Server 2012 Service Pack 1] | 2013-05-31 | | | +| 11.0.3350 | 2011.110.3350.0 | SP1 | COD | | 2832017 | [FIX: You can’t create or open SSIS projects or maintenance plans after you apply Cumulative Update 3 for SQL Server 2012 SP1] | 2013-04-17 | | | +| 11.0.3349 | 2011.110.3349.0 | SP1 | CU | | 2812412 | [Cumulative update package 3 (CU3) for SQL Server 2012 Service Pack 1] | 2013-03-18 | | | +| 11.0.3339 | 2011.110.3339.0 | SP1 | CU | | 2790947 | [Cumulative update package 2 (CU2) for SQL Server 2012 Service Pack 1] | 2013-01-25 | | | +| 11.0.3335 | 2011.110.3335.0 | SP1 | COD | | 2800050 | [FIX: Component installation process fails after you install SQL Server 2012 SP1] | 2013-01-14 | | | +| 11.0.3321 | 2011.110.3321.0 | SP1 | CU | | 2765331 | [Cumulative update package 1 (CU1) for SQL Server 2012 Service Pack 1] | 2012-11-20 | | | +| 11.0.3156 | 2011.110.3156.0 | SP1 | COD | | 3045318 | [MS15-058: Description of the security update for SQL Server 2012 SP1 GDR: July 14, 2015] | 2015-07-14 | 1 | 1 | +| 11.0.3153 | 2011.110.3153.0 | SP1 | GDR | | 2977326 | [MS14-044: Description of the security update for SQL Server 2012 Service Pack 1 (GDR)] | 2014-08-12 | 1 | 1 | +| 11.0.3128 | 2011.110.3128.0 | SP1 | COD | | 2793634 | [Windows Installer starts repeatedly after you install SQL Server 2012 SP1] | 2013-01-03 | | | +| 11.0.3000 | 2011.110.3000.0 | SP1 | SP | | | [SQL Server 2012 Service Pack 1 (SP1)] | 2012-11-06 | 92 | 92 | +| 11.0.2845 | 2011.110.2845.0 | SP1 | CTP | | | SQL Server 2012 Service Pack 1 Customer Technology Preview 4 (CTP4) | 2012-09-20 | | | +| 11.0.2809 | 2011.110.2809.24 | SP1 | CTP | | | SQL Server 2012 Service Pack 1 Customer Technology Preview 3 (CTP3) | 2012-07-05 | | | +| 11.0.2424 | 2011.110.2424.0 | RTM | CU | **Latest CU RTM** | 2908007 | [Cumulative update package 11 (CU11) for SQL Server 2012] | 2013-12-17 | 16 | 15 | +| 11.0.2420 | 2011.110.2420.0 | RTM | CU | | 2891666 | [Cumulative update package 10 (CU10) for SQL Server 2012] | 2013-10-21 | 4 | 4 | +| 11.0.2419 | 2011.110.2419.0 | RTM | CU | | 2867319 | [Cumulative update package 9 (CU9) for SQL Server 2012] | 2013-08-21 | | | +| 11.0.2410 | 2011.110.2410.0 | RTM | CU | | 2844205 | [Cumulative update package 8 (CU8) for SQL Server 2012] | 2013-06-18 | | | +| 11.0.2405 | 2011.110.2405.0 | RTM | CU | | 2823247 | [Cumulative update package 7 (CU7) for SQL Server 2012] | 2013-04-15 | | | +| 11.0.2401 | 2011.110.2401.0 | RTM | CU | | 2728897 | [Cumulative update package 6 (CU6) for SQL Server 2012] | 2013-02-18 | | | +| 11.0.2395 | 2011.110.2395.0 | RTM | CU | | 2777772 | [Cumulative update package 5 (CU5) for SQL Server 2012] | 2012-12-18 | | | +| 11.0.9000 | 2011.110.9000.5 | RTM | CTP | | | Microsoft SQL Server 2012 With Power View For Multidimensional Models Customer Technology Preview (CTP3) | 2012-11-27 | | | +| 11.0.2383 | 2011.110.2383.0 | RTM | CU | | 2758687 | [Cumulative update package 4 (CU4) for SQL Server 2012] | 2012-10-18 | | | +| 11.0.2376 | 2011.110.2376.0 | RTM | COD | [MS12-070] | 2716441 | [Security Update for SQL Server 2012 RTM (KB2716441)] | 2012-10-09 | | | +| 11.0.2332 | 2011.110.2332.0 | RTM | CU | | 2723749 | [Cumulative update package 3 (CU3) for SQL Server 2012] | 2012-08-29 | | | +| 11.0.2325 | 2011.110.2325.0 | RTM | CU | | 2703275 | [Cumulative update package 2 (CU2) for SQL Server 2012] | 2012-06-18 | | | +| 11.0.2316 | 2011.110.2316.0 | RTM | CU | | 2679368 | [Cumulative update package 1 (CU1) for SQL Server 2012] | 2012-04-12 | | | +| 11.0.2218 | 2011.110.2218.0 | RTM | COD | [MS12-070] | 2716442 | [Security Update for SQL Server 2012 RTM (KB2716442)] | 2012-10-09 | | | +| 11.0.2214 | 2011.110.2214.0 | RTM | COD | | 2685308 | [FIX: SSAS uses only 20 cores in SQL Server 2012 Business Intelligence | 2012-04-06 | | | +| 11.0.2100 | 2011.110.2100.60 | RTM | RTM | | | SQL Server 2012 RTM | 2012-03-06 | | | +| 11.0.1913 | 2011.110.1913.37 | RC | RC | | | Microsoft SQL Server 2012 Release Candidate 1 (RC1) | 2011-12-16 | | | +| 11.0.1750 | 2011.110.1750.32 | RC | RC | | | Microsoft SQL Server 2012 Release Candidate 0 (RC0) | 2011-11-17 | | | +| 11.0.1440 | 2010.110.1440.19 | CTP | CTP | | | Microsoft SQL Server 2012 (codename Denali) Community Technology Preview 3 (CTP3) | 2011-07-11 | | | +| 11.0.1103 | 2010.110.1103.9 | CTP | CTP | | | Microsoft SQL Server 2012 (codename Denali) Community Technology Preview 1 (CTP1) | 2010-11-08 | | | + +[Description of the security update for SQL Server 2012 SP4 GDR: January 12, 2021]:https://support.microsoft.com/help/4583465 +[Security update for SQL Server 2012 SP4 GDR: February 11, 2020]:https://support.microsoft.com/help/4532098 +[On-demand hotfix update package for SQL Server 2012 SP4]:https://support.microsoft.com/help/4091266 +[Security Advisory ADV180002 (GDR)]:https://support.microsoft.com/help/4057116/security-update-for-vulnerabilities-in-sql-server +[SQL Server 2012 Service Pack 4 release information]:https://support.microsoft.com/help/4018073/sql-server-2012-service-pack-4-release-information +[Description of the security update for SQL Server 2012 SP3 CU: January 16, 2018]:https://support.microsoft.com/help/4057121 +[Cumulative Update 10 for SQL Server 2012 SP3]:https://support.microsoft.com/help/4025925/cumulative-update-10-for-sql-server-2012-sp3 +[Cumulative Update 9 for SQL Server 2012 SP3]:https://support.microsoft.com/help/4016762/cumulative-update-9-for-sql-server-2012-sp3 +[Cumulative Update 8 for SQL Server 2012 SP3]:https://support.microsoft.com/help/4013104/cumulative-update-8-for-sql-server-2012-sp3 +[Cumulative Update Package 7 for SQL Server 2012 SP3]:https://support.microsoft.com/help/3205051/cumulative-update-7-for-sql-server-2012-sp3 +[MS16-136: Description of the security update for SQL Server 2012 Service Pack 3 CU: November 8, 2016]:https://support.microsoft.com/kb/3194724 +[MS16-136: Description of the security update for SQL Server 2012 Service Pack 2 CU: November 8, 2016]:https://support.microsoft.com/kb/3194725 +[Cumulative Update 14 for SQL Server 2012 SP2]:https://support.microsoft.com/kb/3180914 +[Cumulative update 5 for SQL Server 2012 Service Pack 3]:https://support.microsoft.com/kb/3180915 +[Cumulative Update 4 for SQL Server 2012 SP3]:https://support.microsoft.com/kb/3165264 +[Cumulative Update 13 for SQL Server 2012 SP2]:https://support.microsoft.com/kb/3165266 +[Cumulative update package 3 for SQL Server 2012 SP3]:https://support.microsoft.com/kb/3152635 +[Cumulative update package 12 for SQL Server 2012 SP2]:https://support.microsoft.com/kb/3152637 +[Cumulative update package 2 for SQL Server 2012 SP3]:https://support.microsoft.com/kb/3137746 +[Cumulative update package 11 for SQL Server 2012 SP2]:https://support.microsoft.com/kb/3137745 +[Cumulative update package 1 for SQL Server 2012 SP3]:https://support.microsoft.com/kb/3123299 +[Cumulative update package 15 (CU15) for SQL Server 2012 Service Pack 2]:https://support.microsoft.com/kb/3205416 +[MS16-136: Description of the security update for SQL Server 2012 Service Pack 3 GDR: November 8, 2016]:https://support.microsoft.com/kb/3194721 +[TLS 1.2 support for SQL Server 2012 SP3 GDR]:https://support.microsoft.com/kb/3135244 +[Cumulative update package 10 for SQL Server 2012 SP2]:https://support.microsoft.com/kb/3120313 +[Microsoft SQL Server 2012 Service Pack 3 (SP3)]:https://support.microsoft.com/kb/3072779 +[Cumulative Update 16 for SQL Server 2012 SP2]:https://support.microsoft.com/help/3205054/cumulative-update-16-for-sql-server-2012-sp2 +[Cumulative update package 9 for SQL Server 2012 SP2]:https://support.microsoft.com/kb/3098512 +[FIX: Performance decrease when application with connection pooling frequently connects or disconnects in SQL Server]:https://support.microsoft.com/kb/3097636 +[Cumulative update package 8 (CU8) for SQL Server 2012 Service Pack 2]:http://support.microsoft.com/kb/3082561 +[FIX: Access violations when you use the FileTable feature in SQL Server 2012]:https://support.microsoft.com/kb/3087872 +[Cumulative update package 7 (CU7) for SQL Server 2012 Service Pack 2]:http://support.microsoft.com/kb/3072100 +[MS15-058: Description of the security update for SQL Server 2012 Service Pack 2 QFE: July 14, 2015]:https://support.microsoft.com/kb/3045319 +[Cumulative update package 6 (CU6) for SQL Server 2012 Service Pack 2]:http://support.microsoft.com/kb/3052468 +[Cumulative update package 5 (CU5) for SQL Server 2012 Service Pack 2]:http://support.microsoft.com/kb/3037255 +[FIX: AlwaysOn availability groups are reported as NOT SYNCHRONIZING]:http://support.microsoft.com/kb/3034679 +[Cumulative update package 4 (CU4) for SQL Server 2012 Service Pack 2]:http://support.microsoft.com/kb/3007556 +[Cumulative update package 3 (CU3) for SQL Server 2012 Service Pack 2]:http://support.microsoft.com/kb/3002049 +[Cumulative update package 2 (CU2) for SQL Server 2012 Service Pack 2]:http://support.microsoft.com/kb/2983175 +[Cumulative update package 1 (CU1) for SQL Server 2012 Service Pack 2]:http://support.microsoft.com/kb/2976982 +[FIX: Data loss in clustered index occurs when you run online build index in SQL Server 2012 (Hotfix for SQL2012 SP2)]:http://support.microsoft.com/kb/2969896 +[MS16-136: Description of the security update for SQL Server 2012 Service Pack 2 GDR: November 8, 2016]:https://support.microsoft.com/kb/3194719 +[TLS 1.2 support for SQL Server 2012 SP2 GDR]:https://support.microsoft.com/kb/3135244 +[MS15-058: Description of the security update for SQL Server 2012 Service Pack 2 GDR: July 14, 2015]:https://support.microsoft.com/kb/3045321 +[SQL Server 2012 Service Pack 2 (SP2)]:http://www.microsoft.com/download/details.aspx?id=43340 +[MS15-058: Description of the security update for SQL Server 2012 SP1 QFE: July 14, 2015]:https://support.microsoft.com/kb/3045317 +[Cumulative update package 16 (CU16) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/3052476 +[Cumulative update package 15 (CU15) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/3038001 +[Cumulative update package 14 (CU14) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/3023636 +[Cumulative update package 13 (CU13) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/3002044 +[Cumulative update package 12 (CU12) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/2991533 +[COD Hotfix 2975402]:http://support.microsoft.com/kb/2975402 +[MS14-044: Description of the security update for SQL Server 2012 Service Pack 1 (QFE)]:http://support.microsoft.com/kb/2977325 +[Cumulative update package 11 (CU11) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/2975396 +[FIX: Data loss in clustered index occurs when you run online build index in SQL Server 2012 (Hotfix for SQL2012 SP1)]:http://support.microsoft.com/kb/2969896 +[Cumulative update package 10 (CU10) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/2954099 +[Cumulative update package 9 (CU9) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/2931078 +[Cumulative update package 8 (CU8) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/2917531 +[Cumulative update package 7 (CU7) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/2894115 +[Cumulative update package 6 (CU6) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/2874879 +[Cumulative update package 5 (CU5) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/2861107 +[Cumulative update package 4 (CU4) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/2833645 +[FIX: You can’t create or open SSIS projects or maintenance plans after you apply Cumulative Update 3 for SQL Server 2012 SP1]:http://support.microsoft.com/kb/2832017 +[Cumulative update package 3 (CU3) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/2812412 +[Cumulative update package 2 (CU2) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/2790947 +[FIX: Component installation process fails after you install SQL Server 2012 SP1]:http://support.microsoft.com/kb/2800050 +[Cumulative update package 1 (CU1) for SQL Server 2012 Service Pack 1]:http://support.microsoft.com/kb/2765331 +[MS15-058: Description of the security update for SQL Server 2012 SP1 GDR: July 14, 2015]:https://support.microsoft.com/kb/3045318 +[MS14-044: Description of the security update for SQL Server 2012 Service Pack 1 (GDR)]:http://support.microsoft.com/kb/2977326 +[Windows Installer starts repeatedly after you install SQL Server 2012 SP1]:http://support.microsoft.com/kb/2793634 +[SQL Server 2012 Service Pack 1 (SP1)]:http://www.microsoft.com/download/details.aspx?id=35575 +[Cumulative update package 11 (CU11) for SQL Server 2012]:http://support.microsoft.com/kb/2908007 +[Cumulative update package 10 (CU10) for SQL Server 2012]:http://support.microsoft.com/kb/2891666 +[Cumulative update package 9 (CU9) for SQL Server 2012]:http://support.microsoft.com/kb/2867319 +[Cumulative update package 8 (CU8) for SQL Server 2012]:http://support.microsoft.com/kb/2844205 +[Cumulative update package 7 (CU7) for SQL Server 2012]:http://support.microsoft.com/kb/2823247 +[Cumulative update package 6 (CU6) for SQL Server 2012]:http://support.microsoft.com/kb/2728897 +[Cumulative update package 5 (CU5) for SQL Server 2012]:http://support.microsoft.com/kb/2777772 +[Cumulative update package 4 (CU4) for SQL Server 2012]:http://support.microsoft.com/kb/2758687 +[Security Update for SQL Server 2012 RTM (KB2716441)]:https://www.microsoft.com/en-us/download/details.aspx?id=34917 +[Cumulative update package 3 (CU3) for SQL Server 2012]:http://support.microsoft.com/kb/2723749 +[Cumulative update package 2 (CU2) for SQL Server 2012]:http://support.microsoft.com/kb/2703275 +[Cumulative update package 1 (CU1) for SQL Server 2012]:http://support.microsoft.com/kb/2679368 +[Security Update for SQL Server 2012 RTM (KB2716442)]:https://www.microsoft.com/en-us/download/details.aspx?id=34884 +[FIX: SSAS uses only 20 cores in SQL Server 2012 Business Intelligence]:http://support.microsoft.com/kb/2685308 +[MS12-070]:http://technet.microsoft.com/security/bulletin/ms12-070 -## Microsoft SQL Server 2008 R2 Builds +## Microsoft SQL Server 2008 R2 Builds -| Build | File version | KB / Description | Release Date | -|---------------|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------| -| 10.50.6542 | 2009.100.6542.0 | [3146034 Intermittent service terminations occur after you install any SQL Server 2008 or SQL Server 2008 R2 versions from KB3135244] | 2016-03-03 | -| 10.50.6537 | 2009.100.6537.0 | [3135244 TLS 1.2 support for SQL Server 2008 R2 SP3] | 2016-01-27 | -| 10.50.6529 | 2009.100.6529.0 | [3045314 MS15-058: Description of the security update for SQL Server 2008 R2 Service Pack 3 QFE: July 14, 2015] | 2015-07-14 | -| 10.50.6525 | 2009.100.6525.0 | [3033860 An on-demand hotfix update package is available for SQL Server 2008 R2 Service Pack 3 (SP3)] | 2015-02-09 | -| 10.50.6220 | 2009.100.6220.0 | [3045316 MS15-058: Description of the security update for SQL Server 2008 R2 Service Pack 3 GDR: July 14, 2015] | 2015-07-14 | -| 10.50.6000.34 | 2009.100.6000.34 | [SQL Server 2008 R2 Service Pack 3 (SP3)] | 2014-09-26 | -| 10.50.4343 | 2009.100.4343.0 | [3135244 TLS 1.2 support for SQL Server 2008 R2 SP2 (IA-64 only)] | 2016-01-27 | -| 10.50.4339 | 2009.100.4339.0 | [3045312 MS15-058: Description of the security update for SQL Server 2008 R2 Service Pack 2 QFE: July 14, 2015] | 2015-07-14 | -| 10.50.4331 | 2009.100.4331.0 | [2987585 Restore Log with Standby Mode on an Advanced Format disk may cause a 9004 error in SQL Server 2008 R2 or SQL Server 2012] | 2014-08-27 | -| 10.50.4321 | 2009.100.4321.0 | [2977319 MS14-044: Description of the security update for SQL Server 2008 R2 Service Pack 2 (QFE)] | 2014-08-12 | -| 10.50.4319 | 2009.100.4319.0 | [2967540 Cumulative update package 13 (CU13) for SQL Server 2008 R2 Service Pack 2] | 2014-06-30 | -| 10.50.4305 | 2009.100.4305.0 | [2938478 Cumulative update package 12 (CU12) for SQL Server 2008 R2 Service Pack 2] | 2014-04-21 | -| 10.50.4302 | 2009.100.4302.0 | [2926028 Cumulative update package 11 (CU11) for SQL Server 2008 R2 Service Pack 2] | 2014-02-18 | -| 10.50.4297 | 2009.100.4297.0 | [2908087 Cumulative update package 10 (CU10) for SQL Server 2008 R2 Service Pack 2] | 2013-12-16 | -| 10.50.4295 | 2009.100.4295.0 | [2887606 Cumulative update package 9 (CU9) for SQL Server 2008 R2 Service Pack 2] | 2013-10-29 | -| 10.50.4290 | 2009.100.4290.0 | [2871401 Cumulative update package 8 (CU8) for SQL Server 2008 R2 Service Pack 2] | 2013-08-30 | -| 10.50.4286 | 2009.100.4286.0 | [2844090 Cumulative update package 7 (CU7) for SQL Server 2008 R2 Service Pack 2] | 2013-06-17 | -| 10.50.4285 | 2009.100.4285.0 | [2830140 Cumulative update package 6 (CU6) for SQL Server 2008 R2 Service Pack 2 (updated)] | 2013-06-13 | -| 10.50.4279 | 2009.100.4279.0 | 2830140 Cumulative update package 6 (CU6) for SQL Server 2008 R2 Service Pack 2 (replaced) | 2013-04-15 | -| 10.50.4276 | 2009.100.4276.0 | [2797460 Cumulative update package 5 (CU5) for SQL Server 2008 R2 Service Pack 2] | 2013-02-18 | -| 10.50.4270 | 2009.100.4270.0 | [2777358 Cumulative update package 4 (CU4) for SQL Server 2008 R2 Service Pack 2] | 2012-12-17 | -| 10.50.4266 | 2009.100.4266.0 | [2754552 Cumulative update package 3 (CU3) for SQL Server 2008 R2 Service Pack 2] | 2012-10-15 | -| 10.50.4263 | 2009.100.4263.0 | [2740411 Cumulative update package 2 (CU2) for SQL Server 2008 R2 Service Pack 2] | 2012-08-29 | -| 10.50.4260 | 2009.100.4260.0 | [2720425 Cumulative update package 1 (CU1) for SQL Server 2008 R2 Service Pack 2] | 2012-08-01 | -| 10.50.4042 | 2009.100.4042.0 | [3045313 MS15-058: MS15-058: Description of the security update for SQL Server 2008 R2 Service Pack 2 GDR: July 14, 2015] | 2015-07-14 | -| 10.50.4033 | 2009.100.4033.0 | [2977320 MS14-044: Description of the security update for SQL Server 2008 R2 Service Pack 2 (GDR)] | 2014-08-12 | -| 10.50.4000 | 2009.100.4000.0 | [SQL Server 2008 R2 Service Pack 2 (SP2)] | 2012-06-26 | -| 10.50.3720 | 2009.100.3720.0 | SQL Server 2008 R2 Service Pack 2 Community Technology Preview (CTP) | 2012-05-13 | -| 10.50.2881 | 2009.100.2881.0 | [2868244 An on-demand hotfix update package for SQL Server 2008 R2 Service Pack 1] | 2013-08-12 | -| 10.50.2876 | 2009.100.2876.0 | [2855792 Cumulative update package 13 (CU13) for SQL Server 2008 R2 Service Pack 1] | 2013-06-17 | -| 10.50.2875 | 2009.100.2875.0 | [2828727 Cumulative update package 12 (CU12) for SQL Server 2008 R2 Service Pack 1 (updated)] | 2013-06-13 | -| 10.50.2874 | 2009.100.2874.0 | 2828727 Cumulative update package 12 (CU12) for SQL Server 2008 R2 Service Pack 1 (replaced) | 2013-04-15 | -| 10.50.2861 | 2009.100.2861.0 | [Microsoft Security Bulletin MS12-070] | 2012-10-09 | -| 10.50.2869 | 2009.100.2869.0 | [2812683 Cumulative update package 11 (CU11) for SQL Server 2008 R2 Service Pack 1] | 2013-02-18 | -| 10.50.2868 | 2009.100.2868.0 | [2783135 Cumulative update package 10 (CU10) for SQL Server 2008 R2 Service Pack 1] | 2012-12-17 | -| 10.50.2866 | 2009.100.2866.0 | [2756574 Cumulative update package 9 (CU9) for SQL Server 2008 R2 Service Pack 1] | 2012-11-06 | -| 10.50.2861 | 2009.100.2861.0 | [2716439 MS12-070: Description of the security update for SQL Server 2008 R2 Service Pack 1 QFE: October 9, 2012] | 2012-10-09 | -| 10.50.2822 | 2009.100.2822.0 | [2723743 Cumulative update package 8 (CU8) for SQL Server 2008 R2 Service Pack 1] | 2012-08-29 | -| 10.50.2817 | 2009.100.2817.0 | [2703282 Cumulative update package 7 (CU7) for SQL Server 2008 R2 Service Pack 1] | 2012-06-18 | -| 10.50.2811 | 2009.100.2811.0 | [2679367 Cumulative update package 6 (CU6) for SQL Server 2008 R2 Service Pack 1] | 2012-04-16 | -| 10.50.2807 | 2009.100.2807.0 | [2675522 FIX: Access violation when you run DML statements against a table that has partitioned indexes in SQL Server 2008 R2] | 2012-03-12 | -| 10.50.2806 | 2009.100.2806.0 | [2659694 Cumulative update package 5 (CU5) for SQL Server 2008 R2 Service Pack 1] | 2012-02-22 | -| 10.50.2799 | 2009.100.2799.0 | [2633357 FIX: "Non-yielding Scheduler" error might occur when you run a query that uses the CHARINDEX function in SQL Server 2008 R2] | 2012-02-22 | -| 10.50.2796 | 2009.100.2796.0 | [2633146 Cumulative update package 4 (CU4) for SQL Server 2008 R2 Service Pack 1] | 2011-12-20 | -| 10.50.2789 | 2009.100.2789.0 | [2591748 Cumulative update package 3 (CU3) for SQL Server 2008 R2 Service Pack 1] | 2011-10-17 | -| 10.50.2776 | 2009.100.2776.0 | [2606883 FIX: Slow performance when an AFTER trigger runs on a partitioned table in SQL Server 2008 R2] | 2011-10-18 | -| 10.50.2772 | 2009.100.2772.0 | [2567714 Cumulative update package 2 (CU2) for SQL Server 2008 R2 Service Pack 1] | 2011-08-15 | -| 10.50.2769 | 2009.100.2769.0 | [2544793 Cumulative update package 1 (CU1) for SQL Server 2008 R2 Service Pack 1] | 2011-07-18 | -| 10.50.2550 | 2009.100.2550.0 | [Microsoft Security Bulletin MS12-070] | 2012-10-09 | -| 10.50.2500 | 2009.100.2500.0 | [SQL Server 2008 R2 Service Pack 1 (SP1)] | 2011-07-11 | -| 10.50.1817 | 2009.100.1817.0 | [2703280 Cumulative update package 14 (CU14) for SQL Server 2008 R2] | 2012-06-18 | -| 10.50.1815 | 2009.100.1815.0 | [2679366 Cumulative update package 13 (CU13) for SQL Server 2008 R2] | 2012-04-17 | -| 10.50.1810 | 2009.100.1810.0 | [2659692 Cumulative update package 12 (CU12) for SQL Server 2008 R2] | 2012-02-21 | -| 10.50.1809 | 2009.100.1809.0 | [2633145 Cumulative update package 11 (CU11) for SQL Server 2008 R2] | 2012-01-09 | -| 10.50.1807 | 2009.100.1807.0 | [2591746 Cumulative update package 10 (CU10) for SQL Server 2008 R2] | 2011-10-19 | -| 10.50.1804 | 2009.100.1804.0 | [2567713 Cumulative update package 9 (CU9) for SQL Server 2008 R2] | 2011-08-16 | -| 10.50.1800 | 2009.100.1800.0 | [2574699 FIX: Database data files might be incorrectly marked as sparse in SQL Server 2008 R2 or in SQL Server 2008 even when the physical files are marked as not sparse in the file system] | 2011-10-18 | -| 10.50.1797 | 2009.100.1797.0 | [2534352 Cumulative update package 8 (CU8) for SQL Server 2008 R2] | 2011-06-20 | -| 10.50.1790 | 2009.100.1790.0 | [2494086 MS11-049: Description of the security update for SQL Server 2008 R2 QFE: June 14, 2011] | 2011-06-17 | -| 10.50.1777 | 2009.100.1777.0 | [2507770 Cumulative update package 7 (CU7) for SQL Server 2008 R2] | 2011-06-16 | -| 10.50.1769 | 2009.100.1769.0 | [2520808 FIX: Non-yielding scheduler error when you run a query that uses a TVP in SQL Server 2008 or in SQL Server 2008 R2 if SQL Profiler or SQL Server Extended Events is used] | 2011-04-18 | -| 10.50.1765 | 2009.100.1765.0 | [2489376 Cumulative update package 6 (CU6) for SQL Server 2008 R2] | 2011-02-21 | -| 10.50.1753 | 2009.100.1753.0 | [2438347 Cumulative update package 5 (CU5) for SQL Server 2008 R2] | 2010-12-23 | -| 10.50.1746 | 2009.100.1746.0 | [2345451 Cumulative update package 4 (CU4) for SQL Server 2008 R2] | 2010-10-18 | -| 10.50.1734 | 2009.100.1734.0 | [2261464 Cumulative update package 3 (CU3) for SQL Server 2008 R2] | 2010-08-20 | -| 10.50.1720 | 2009.100.1720.0 | [2072493 Cumulative update package 2 (CU2) for SQL Server 2008 R2] | 2010-06-25 | -| 10.50.1702 | 2009.100.1702.0 | [981355 Cumulative update package 1 (CU1) for SQL Server 2008 R2] | 2010-05-18 | -| 10.50.1617 | 2009.100.1617.0 | [2494088 MS11-049: Description of the security update for SQL Server 2008 R2 GDR: June 14, 2011] | 2011-06-14 | -| 10.50.1600.1 | 2009.100.1600.1 | SQL Server 2008 R2 RTM | 2010-04-21 | -| 10.50.1352 | 2009.100.1352.12 | Microsoft SQL Server 2008 R2 November Community Technology Preview (CTP) | 2009-11-12 | -| 10.50.1092 | 2009.100.1092.20 | Microsoft SQL Server 2008 R2 August Community Technology Preview (CTP) | 2009-06-30 | - -[3146034 Intermittent service terminations occur after you install any SQL Server 2008 or SQL Server 2008 R2 versions from KB3135244]:http://support.microsoft.com/en-us/kb/3146034 -[3135244 TLS 1.2 support for SQL Server 2008 R2 SP3]:http://support.microsoft.com/en-us/kb/3135244 -[3045314 MS15-058: Description of the security update for SQL Server 2008 R2 Service Pack 3 QFE: July 14, 2015]:http://support.microsoft.com/kb/3045314 -[3033860 An on-demand hotfix update package is available for SQL Server 2008 R2 Service Pack 3 (SP3)]:http://support.microsoft.com/kb/3033860 -[3045316 MS15-058: Description of the security update for SQL Server 2008 R2 Service Pack 3 GDR: July 14, 2015]:http://support.microsoft.com/kb/3045316 -[SQL Server 2008 R2 Service Pack 3 (SP3)]:http://www.microsoft.com/en-us/download/details.aspx?id=44271 -[3135244 TLS 1.2 support for SQL Server 2008 R2 SP2 (IA-64 only)]:http://support.microsoft.com/en-us/kb/3135244 -[3045312 MS15-058: Description of the security update for SQL Server 2008 R2 Service Pack 2 QFE: July 14, 2015]:http://support.microsoft.com/kb/3045312 -[2987585 Restore Log with Standby Mode on an Advanced Format disk may cause a 9004 error in SQL Server 2008 R2 or SQL Server 2012]:http://support.microsoft.com/kb/2987585 -[2977319 MS14-044: Description of the security update for SQL Server 2008 R2 Service Pack 2 (QFE)]:http://support.microsoft.com/kb/2977319 -[2967540 Cumulative update package 13 (CU13) for SQL Server 2008 R2 Service Pack 2]:http://support.microsoft.com/kb/2967540 -[2938478 Cumulative update package 12 (CU12) for SQL Server 2008 R2 Service Pack 2]:http://support.microsoft.com/kb/2938478 -[2926028 Cumulative update package 11 (CU11) for SQL Server 2008 R2 Service Pack 2]:http://support.microsoft.com/kb/2926028 -[2908087 Cumulative update package 10 (CU10) for SQL Server 2008 R2 Service Pack 2]:http://support.microsoft.com/kb/2908087 -[2887606 Cumulative update package 9 (CU9) for SQL Server 2008 R2 Service Pack 2]:http://support.microsoft.com/kb/2887606 -[2871401 Cumulative update package 8 (CU8) for SQL Server 2008 R2 Service Pack 2]:http://support.microsoft.com/kb/2871401 -[2844090 Cumulative update package 7 (CU7) for SQL Server 2008 R2 Service Pack 2]:http://support.microsoft.com/kb/2844090 -[2830140 Cumulative update package 6 (CU6) for SQL Server 2008 R2 Service Pack 2 (updated)]:http://support.microsoft.com/kb/2830140 -[2797460 Cumulative update package 5 (CU5) for SQL Server 2008 R2 Service Pack 2]:http://support.microsoft.com/kb/2797460 -[2777358 Cumulative update package 4 (CU4) for SQL Server 2008 R2 Service Pack 2]:http://support.microsoft.com/kb/2777358 -[2754552 Cumulative update package 3 (CU3) for SQL Server 2008 R2 Service Pack 2]:http://support.microsoft.com/kb/2754552 -[2740411 Cumulative update package 2 (CU2) for SQL Server 2008 R2 Service Pack 2]:http://support.microsoft.com/kb/2740411 -[2720425 Cumulative update package 1 (CU1) for SQL Server 2008 R2 Service Pack 2]:http://support.microsoft.com/kb/2720425 -[3045313 MS15-058: MS15-058: Description of the security update for SQL Server 2008 R2 Service Pack 2 GDR: July 14, 2015]:http://support.microsoft.com/kb/3045313 -[2977320 MS14-044: Description of the security update for SQL Server 2008 R2 Service Pack 2 (GDR)]:http://support.microsoft.com/kb/2977320 -[SQL Server 2008 R2 Service Pack 2 (SP2)]:http://www.microsoft.com/en-us/download/details.aspx?id=30437 -[2868244 An on-demand hotfix update package for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2868244 -[2855792 Cumulative update package 13 (CU13) for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2855792 -[2828727 Cumulative update package 12 (CU12) for SQL Server 2008 R2 Service Pack 1 (updated)]:http://support.microsoft.com/kb/2828727 -[2812683 Cumulative update package 11 (CU11) for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2812683 -[2783135 Cumulative update package 10 (CU10) for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2783135 -[2756574 Cumulative update package 9 (CU9) for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2756574 -[2716439 MS12-070: Description of the security update for SQL Server 2008 R2 Service Pack 1 QFE: October 9, 2012]:http://support.microsoft.com/kb/2716439 -[2723743 Cumulative update package 8 (CU8) for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2723743 -[2703282 Cumulative update package 7 (CU7) for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2703282 -[2679367 Cumulative update package 6 (CU6) for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2679367 -[2675522 FIX: Access violation when you run DML statements against a table that has partitioned indexes in SQL Server 2008 R2]:http://support.microsoft.com/kb/2675522 -[2659694 Cumulative update package 5 (CU5) for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2659694 -[2633357 FIX: "Non-yielding Scheduler" error might occur when you run a query that uses the CHARINDEX function in SQL Server 2008 R2]:http://support.microsoft.com/kb/2633357 -[2633146 Cumulative update package 4 (CU4) for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2633146 -[2591748 Cumulative update package 3 (CU3) for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2591748 -[2606883 FIX: Slow performance when an AFTER trigger runs on a partitioned table in SQL Server 2008 R2]:http://support.microsoft.com/kb/2606883 -[2567714 Cumulative update package 2 (CU2) for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2567714 -[2544793 Cumulative update package 1 (CU1) for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2544793 +### All SQL Server 2008 R2 CU downloads +[Catalog Update Microsoft SQL Server 2008 R2]:http://www.catalog.update.microsoft.com/Search.aspx?q=sql%20server%202008%20R2 + +| Build | File version | Branch | Type | Info | KB | Description/Link | Release Date | +|---------------|------------------|--------|------|------------------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------| +| 10.50.6542 | 2009.100.6542.0 | SP3 | CU |**Latest CU SP3** | 3146034 | [Intermittent service terminations occur after you install any SQL Server 2008 or SQL Server 2008 R2 versions from KB3135244] | 2016-03-03 | +| 10.50.6537 | 2009.100.6537.0 | SP3 | CU | | 3135244 | [TLS 1.2 support for SQL Server 2008 R2 SP3] | 2016-01-27 | +| 10.50.6529 | 2009.100.6529.0 | SP3 | QFE | | 3045314 | [MS15-058: Description of the security update for SQL Server 2008 R2 Service Pack 3 QFE: July 14, 2015] | 2015-07-14 | +| 10.50.6525 | 2009.100.6525.0 | SP3 | COD | | 3033860 | [An on-demand hotfix update package is available for SQL Server 2008 R2 Service Pack 3 (SP3)] | 2015-02-09 | +| 10.50.6220 | 2009.100.6220.0 | SP3 | COD | | 3045316 | [MS15-058: Description of the security update for SQL Server 2008 R2 Service Pack 3 GDR: July 14, 2015] | 2015-07-14 | +| 10.50.6000.34 | 2009.100.6000.34 | SP3 | SP |**Latest SP** | | [SQL Server 2008 R2 Service Pack 3 (SP3)] | 2014-09-26 | +| 10.50.4343 | 2009.100.4343.0 | SP2 | CU | | 3135244 | [TLS 1.2 support for SQL Server 2008 R2 SP2 (IA-64 only)] | 2016-01-27 | +| 10.50.4339 | 2009.100.4339.0 | SP2 | QFE | | 3045312 | [MS15-058: Description of the security update for SQL Server 2008 R2 Service Pack 2 QFE: July 14, 2015] | 2015-07-14 | +| 10.50.4331 | 2009.100.4331.0 | SP2 | | | 2987585 | [Restore Log with Standby Mode on an Advanced Format disk may cause a 9004 error in SQL Server 2008 R2 or SQL Server 2012] | 2014-08-27 | +| 10.50.4321 | 2009.100.4321.0 | SP2 | QFE | | 2977319 | [MS14-044: Description of the security update for SQL Server 2008 R2 Service Pack 2 (QFE)] | 2014-08-12 | +| 10.50.4319 | 2009.100.4319.0 | SP2 | CU | | 2967540 | [Cumulative update package 13 (CU13) for SQL Server 2008 R2 Service Pack 2] | 2014-06-30 | +| 10.50.4305 | 2009.100.4305.0 | SP2 | CU | | 2938478 | [Cumulative update package 12 (CU12) for SQL Server 2008 R2 Service Pack 2] | 2014-04-21 | +| 10.50.4302 | 2009.100.4302.0 | SP2 | CU | | 2926028 | [Cumulative update package 11 (CU11) for SQL Server 2008 R2 Service Pack 2] | 2014-02-18 | +| 10.50.4297 | 2009.100.4297.0 | SP2 | CU | | 2908087 | [Cumulative update package 10 (CU10) for SQL Server 2008 R2 Service Pack 2] | 2013-12-16 | +| 10.50.4295 | 2009.100.4295.0 | SP2 | CU | | 2887606 | [Cumulative update package 9 (CU9) for SQL Server 2008 R2 Service Pack 2] | 2013-10-29 | +| 10.50.4290 | 2009.100.4290.0 | SP2 | CU | | 2871401 | [Cumulative update package 8 (CU8) for SQL Server 2008 R2 Service Pack 2] | 2013-08-30 | +| 10.50.4286 | 2009.100.4286.0 | SP2 | CU | | 2844090 | [Cumulative update package 7 (CU7) for SQL Server 2008 R2 Service Pack 2] | 2013-06-17 | +| 10.50.4285 | 2009.100.4285.0 | SP2 | CU | | 2830140 | [Cumulative update package 6 (CU6) for SQL Server 2008 R2 Service Pack 2 (updated)] | 2013-06-13 | +| 10.50.4279 | 2009.100.4279.0 | SP2 | CU |**Withdrawn** | 2830140 | Cumulative update package 6 (CU6) for SQL Server 2008 R2 Service Pack 2 (replaced) | 2013-04-15 | +| 10.50.4276 | 2009.100.4276.0 | SP2 | CU | | 2797460 | [Cumulative update package 5 (CU5) for SQL Server 2008 R2 Service Pack 2] | 2013-02-18 | +| 10.50.4270 | 2009.100.4270.0 | SP2 | CU | | 2777358 | [Cumulative update package 4 (CU4) for SQL Server 2008 R2 Service Pack 2] | 2012-12-17 | +| 10.50.4266 | 2009.100.4266.0 | SP2 | CU | | 2754552 | [Cumulative update package 3 (CU3) for SQL Server 2008 R2 Service Pack 2] | 2012-10-15 | +| 10.50.4263 | 2009.100.4263.0 | SP2 | CU | | 2740411 | [Cumulative update package 2 (CU2) for SQL Server 2008 R2 Service Pack 2] | 2012-08-29 | +| 10.50.4260 | 2009.100.4260.0 | SP2 | CU | | 2720425 | [Cumulative update package 1 (CU1) for SQL Server 2008 R2 Service Pack 2] | 2012-08-01 | +| 10.50.4042 | 2009.100.4042.0 | SP2 | GDR | | 3045313 | [MS15-058: MS15-058: Description of the security update for SQL Server 2008 R2 Service Pack 2 GDR: July 14, 2015] | 2015-07-14 | +| 10.50.4033 | 2009.100.4033.0 | SP2 | GDR | | 2977320 | [MS14-044: Description of the security update for SQL Server 2008 R2 Service Pack 2 (GDR)] | 2014-08-12 | +| 10.50.4000 | 2009.100.4000.0 | SP2 | SP | | | [SQL Server 2008 R2 Service Pack 2 (SP2)] | 2012-06-26 | +| 10.50.3720 | 2009.100.3720.0 | SP2 | CTP | | | SQL Server 2008 R2 Service Pack 2 Community Technology Preview (CTP) | 2012-05-13 | +| 10.50.2881 | 2009.100.2881.0 | SP1 | | | 2868244 | [An on-demand hotfix update package for SQL Server 2008 R2 Service Pack 1] | 2013-08-12 | +| 10.50.2876 | 2009.100.2876.0 | SP1 | CU | | 2855792 | [Cumulative update package 13 (CU13) for SQL Server 2008 R2 Service Pack 1] | 2013-06-17 | +| 10.50.2875 | 2009.100.2875.0 | SP1 | CU | | 2828727 | [Cumulative update package 12 (CU12) for SQL Server 2008 R2 Service Pack 1 (updated)] | 2013-06-13 | +| 10.50.2874 | 2009.100.2874.0 | SP1 | CU |**Withdrawn** | 2828727 | Cumulative update package 12 (CU12) for SQL Server 2008 R2 Service Pack 1 (replaced) | 2013-04-15 | +| 10.50.2861 | 2009.100.2861.0 | SP1 | | | | [Microsoft Security Bulletin MS12-070] | 2012-10-09 | +| 10.50.2869 | 2009.100.2869.0 | SP1 | CU | | 2812683 | [Cumulative update package 11 (CU11) for SQL Server 2008 R2 Service Pack 1] | 2013-02-18 | +| 10.50.2868 | 2009.100.2868.0 | SP1 | CU | | 2783135 | [Cumulative update package 10 (CU10) for SQL Server 2008 R2 Service Pack 1] | 2012-12-17 | +| 10.50.2866 | 2009.100.2866.0 | SP1 | CU | | 2756574 | [Cumulative update package 9 (CU9) for SQL Server 2008 R2 Service Pack 1] | 2012-11-06 | +| 10.50.2861 | 2009.100.2861.0 | SP1 | QFE | | 2716439 | [MS12-070: Description of the security update for SQL Server 2008 R2 Service Pack 1 QFE: October 9, 2012] | 2012-10-09 | +| 10.50.2822 | 2009.100.2822.0 | SP1 | CU | | 2723743 | [Cumulative update package 8 (CU8) for SQL Server 2008 R2 Service Pack 1] | 2012-08-29 | +| 10.50.2817 | 2009.100.2817.0 | SP1 | CU | | 2703282 | [Cumulative update package 7 (CU7) for SQL Server 2008 R2 Service Pack 1] | 2012-06-18 | +| 10.50.2811 | 2009.100.2811.0 | SP1 | CU | | 2679367 | [Cumulative update package 6 (CU6) for SQL Server 2008 R2 Service Pack 1] | 2012-04-16 | +| 10.50.2807 | 2009.100.2807.0 | SP1 | | | 2675522 | [FIX: Access violation when you run DML statements against a table that has partitioned indexes in SQL Server 2008 R2] | 2012-03-12 | +| 10.50.2806 | 2009.100.2806.0 | SP1 | CU | | 2659694 | [Cumulative update package 5 (CU5) for SQL Server 2008 R2 Service Pack 1] | 2012-02-22 | +| 10.50.2799 | 2009.100.2799.0 | SP1 | | | 2633357 | [FIX: "Non-yielding Scheduler" error might occur when you run a query that uses the CHARINDEX function in SQL Server 2008 R2] | 2012-02-22 | +| 10.50.2796 | 2009.100.2796.0 | SP1 | CU | | 2633146 | [Cumulative update package 4 (CU4) for SQL Server 2008 R2 Service Pack 1] | 2011-12-20 | +| 10.50.2789 | 2009.100.2789.0 | SP1 | CU | | 2591748 | [Cumulative update package 3 (CU3) for SQL Server 2008 R2 Service Pack 1] | 2011-10-17 | +| 10.50.2776 | 2009.100.2776.0 | SP1 | | | 2606883 | [FIX: Slow performance when an AFTER trigger runs on a partitioned table in SQL Server 2008 R2] | 2011-10-18 | +| 10.50.2772 | 2009.100.2772.0 | SP1 | CU | | 2567714 | [Cumulative update package 2 (CU2) for SQL Server 2008 R2 Service Pack 1] | 2011-08-15 | +| 10.50.2769 | 2009.100.2769.0 | SP1 | CU | | 2544793 | [Cumulative update package 1 (CU1) for SQL Server 2008 R2 Service Pack 1] | 2011-07-18 | +| 10.50.2550 | 2009.100.2550.0 | SP1 | | [MS12-070] | | [Microsoft Security Bulletin MS12-070] | 2012-10-09 | +| 10.50.2500 | 2009.100.2500.0 | SP1 | SP | | | [SQL Server 2008 R2 Service Pack 1 (SP1)] | 2011-07-11 | +| 10.50.1817 | 2009.100.1817.0 | RTM | CU | | 2703280 | [Cumulative update package 14 (CU14) for SQL Server 2008 R2] | 2012-06-18 | +| 10.50.1815 | 2009.100.1815.0 | RTM | CU | | 2679366 | [Cumulative update package 13 (CU13) for SQL Server 2008 R2] | 2012-04-17 | +| 10.50.1810 | 2009.100.1810.0 | RTM | CU | | 2659692 | [Cumulative update package 12 (CU12) for SQL Server 2008 R2] | 2012-02-21 | +| 10.50.1809 | 2009.100.1809.0 | RTM | CU | | 2633145 | [Cumulative update package 11 (CU11) for SQL Server 2008 R2] | 2012-01-09 | +| 10.50.1807 | 2009.100.1807.0 | RTM | CU | | 2591746 | [Cumulative update package 10 (CU10) for SQL Server 2008 R2] | 2011-10-19 | +| 10.50.1804 | 2009.100.1804.0 | RTM | CU | | 2567713 | [Cumulative update package 9 (CU9) for SQL Server 2008 R2] | 2011-08-16 | +| 10.50.1800 | 2009.100.1800.0 | RTM | | | 2574699 | [FIX: Database data files might be incorrectly marked as sparse in SQL Server 2008 R2 or in SQL Server 2008 even when the physical files are marked as not sparse in the file system] | 2011-10-18 | +| 10.50.1797 | 2009.100.1797.0 | RTM | CU | | 2534352 | [Cumulative update package 8 (CU8) for SQL Server 2008 R2] | 2011-06-20 | +| 10.50.1790 | 2009.100.1790.0 | RTM | QFE | | 2494086 | [MS11-049: Description of the security update for SQL Server 2008 R2 QFE: June 14, 2011] | 2011-06-17 | +| 10.50.1777 | 2009.100.1777.0 | RTM | CU | | 2507770 | [Cumulative update package 7 (CU7) for SQL Server 2008 R2] | 2011-06-16 | +| 10.50.1769 | 2009.100.1769.0 | RTM | | | 2520808 | [FIX: Non-yielding scheduler error when you run a query that uses a TVP in SQL Server 2008 or in SQL Server 2008 R2 if SQL Profiler or SQL Server Extended Events is used] | 2011-04-18 | +| 10.50.1765 | 2009.100.1765.0 | RTM | CU | | 2489376 | [Cumulative update package 6 (CU6) for SQL Server 2008 R2] | 2011-02-21 | +| 10.50.1753 | 2009.100.1753.0 | RTM | CU | | 2438347 | [Cumulative update package 5 (CU5) for SQL Server 2008 R2] | 2010-12-23 | +| 10.50.1746 | 2009.100.1746.0 | RTM | CU | | 2345451 | [Cumulative update package 4 (CU4) for SQL Server 2008 R2] | 2010-10-18 | +| 10.50.1734 | 2009.100.1734.0 | RTM | CU | | 2261464 | [Cumulative update package 3 (CU3) for SQL Server 2008 R2] | 2010-08-20 | +| 10.50.1720 | 2009.100.1720.0 | RTM | CU | | 2072493 | [Cumulative update package 2 (CU2) for SQL Server 2008 R2] | 2010-06-25 | +| 10.50.1702 | 2009.100.1702.0 | RTM | CU | | 981355 | [Cumulative update package 1 (CU1) for SQL Server 2008 R2] | 2010-05-18 | +| 10.50.1617 | 2009.100.1617.0 | RTM | GDR | | 2494088 | [MS11-049: Description of the security update for SQL Server 2008 R2 GDR: June 14, 2011] | 2011-06-14 | +| 10.50.1600.1 | 2009.100.1600.1 | RTM | RTM |**RTM** | | SQL Server 2008 R2 RTM | 2010-04-21 | +| 10.50.1352 | 2009.100.1352.12 | CTP | CTP | | | Microsoft SQL Server 2008 R2 November Community Technology Preview (CTP) | 2009-11-12 | +| 10.50.1092 | 2009.100.1092.20 | CTP | CTP | | | Microsoft SQL Server 2008 R2 August Community Technology Preview (CTP) | 2009-06-30 | + +[Intermittent service terminations occur after you install any SQL Server 2008 or SQL Server 2008 R2 versions from KB3135244]:http://support.microsoft.com/kb/3146034 +[TLS 1.2 support for SQL Server 2008 R2 SP3]:http://support.microsoft.com/kb/3135244 +[MS15-058: Description of the security update for SQL Server 2008 R2 Service Pack 3 QFE: July 14, 2015]:http://support.microsoft.com/kb/3045314 +[An on-demand hotfix update package is available for SQL Server 2008 R2 Service Pack 3 (SP3)]:http://support.microsoft.com/kb/3033860 +[MS15-058: Description of the security update for SQL Server 2008 R2 Service Pack 3 GDR: July 14, 2015]:http://support.microsoft.com/kb/3045316 +[SQL Server 2008 R2 Service Pack 3 (SP3)]:http://www.microsoft.com/download/details.aspx?id=44271 +[TLS 1.2 support for SQL Server 2008 R2 SP2 (IA-64 only)]:http://support.microsoft.com/kb/3135244 +[MS15-058: Description of the security update for SQL Server 2008 R2 Service Pack 2 QFE: July 14, 2015]:http://support.microsoft.com/kb/3045312 +[Restore Log with Standby Mode on an Advanced Format disk may cause a 9004 error in SQL Server 2008 R2 or SQL Server 2012]:http://support.microsoft.com/kb/2987585 +[MS14-044: Description of the security update for SQL Server 2008 R2 Service Pack 2 (QFE)]:http://support.microsoft.com/kb/2977319 +[Cumulative update package 13 (CU13) for SQL Server 2008 R2 Service Pack 2]:http://support.microsoft.com/kb/2967540 +[Cumulative update package 12 (CU12) for SQL Server 2008 R2 Service Pack 2]:http://support.microsoft.com/kb/2938478 +[Cumulative update package 11 (CU11) for SQL Server 2008 R2 Service Pack 2]:http://support.microsoft.com/kb/2926028 +[Cumulative update package 10 (CU10) for SQL Server 2008 R2 Service Pack 2]:http://support.microsoft.com/kb/2908087 +[Cumulative update package 9 (CU9) for SQL Server 2008 R2 Service Pack 2]:http://support.microsoft.com/kb/2887606 +[Cumulative update package 8 (CU8) for SQL Server 2008 R2 Service Pack 2]:http://support.microsoft.com/kb/2871401 +[Cumulative update package 7 (CU7) for SQL Server 2008 R2 Service Pack 2]:http://support.microsoft.com/kb/2844090 +[Cumulative update package 6 (CU6) for SQL Server 2008 R2 Service Pack 2 (updated)]:http://support.microsoft.com/kb/2830140 +[Cumulative update package 5 (CU5) for SQL Server 2008 R2 Service Pack 2]:http://support.microsoft.com/kb/2797460 +[Cumulative update package 4 (CU4) for SQL Server 2008 R2 Service Pack 2]:http://support.microsoft.com/kb/2777358 +[Cumulative update package 3 (CU3) for SQL Server 2008 R2 Service Pack 2]:http://support.microsoft.com/kb/2754552 +[Cumulative update package 2 (CU2) for SQL Server 2008 R2 Service Pack 2]:http://support.microsoft.com/kb/2740411 +[Cumulative update package 1 (CU1) for SQL Server 2008 R2 Service Pack 2]:http://support.microsoft.com/kb/2720425 +[MS15-058: MS15-058: Description of the security update for SQL Server 2008 R2 Service Pack 2 GDR: July 14, 2015]:http://support.microsoft.com/kb/3045313 +[MS14-044: Description of the security update for SQL Server 2008 R2 Service Pack 2 (GDR)]:http://support.microsoft.com/kb/2977320 +[SQL Server 2008 R2 Service Pack 2 (SP2)]:http://www.microsoft.com/download/details.aspx?id=30437 +[An on-demand hotfix update package for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2868244 +[Cumulative update package 13 (CU13) for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2855792 +[Cumulative update package 12 (CU12) for SQL Server 2008 R2 Service Pack 1 (updated)]:http://support.microsoft.com/kb/2828727 +[Cumulative update package 11 (CU11) for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2812683 +[Cumulative update package 10 (CU10) for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2783135 +[Cumulative update package 9 (CU9) for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2756574 +[MS12-070: Description of the security update for SQL Server 2008 R2 Service Pack 1 QFE: October 9, 2012]:http://support.microsoft.com/kb/2716439 +[Cumulative update package 8 (CU8) for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2723743 +[Cumulative update package 7 (CU7) for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2703282 +[Cumulative update package 6 (CU6) for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2679367 +[FIX: Access violation when you run DML statements against a table that has partitioned indexes in SQL Server 2008 R2]:http://support.microsoft.com/kb/2675522 +[Cumulative update package 5 (CU5) for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2659694 +[FIX: "Non-yielding Scheduler" error might occur when you run a query that uses the CHARINDEX function in SQL Server 2008 R2]:http://support.microsoft.com/kb/2633357 +[Cumulative update package 4 (CU4) for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2633146 +[Cumulative update package 3 (CU3) for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2591748 +[FIX: Slow performance when an AFTER trigger runs on a partitioned table in SQL Server 2008 R2]:http://support.microsoft.com/kb/2606883 +[Cumulative update package 2 (CU2) for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2567714 +[Cumulative update package 1 (CU1) for SQL Server 2008 R2 Service Pack 1]:http://support.microsoft.com/kb/2544793 [SQL Server 2008 R2 Service Pack 1 (SP1)]:http://www.microsoft.com/download/en/details.aspx?id=26727 -[2703280 Cumulative update package 14 (CU14) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2703280 -[2679366 Cumulative update package 13 (CU13) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2679366 -[2659692 Cumulative update package 12 (CU12) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2659692 -[2633145 Cumulative update package 11 (CU11) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2633145 -[2591746 Cumulative update package 10 (CU10) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2591746 -[2567713 Cumulative update package 9 (CU9) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2567713 -[2574699 FIX: Database data files might be incorrectly marked as sparse in SQL Server 2008 R2 or in SQL Server 2008 even when the physical files are marked as not sparse in the file system]:http://support.microsoft.com/kb/2574699 -[2534352 Cumulative update package 8 (CU8) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2534352 -[2494086 MS11-049: Description of the security update for SQL Server 2008 R2 QFE: June 14, 2011]:http://support.microsoft.com/kb/2494086 -[2507770 Cumulative update package 7 (CU7) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2507770 -[2520808 FIX: Non-yielding scheduler error when you run a query that uses a TVP in SQL Server 2008 or in SQL Server 2008 R2 if SQL Profiler or SQL Server Extended Events is used]:http://support.microsoft.com/kb/2520808 -[2489376 Cumulative update package 6 (CU6) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2489376 -[2438347 Cumulative update package 5 (CU5) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2438347 -[2345451 Cumulative update package 4 (CU4) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2345451 -[2261464 Cumulative update package 3 (CU3) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2261464 -[2072493 Cumulative update package 2 (CU2) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2072493 -[981355 Cumulative update package 1 (CU1) for SQL Server 2008 R2]:http://support.microsoft.com/kb/981355 -[2494088 MS11-049: Description of the security update for SQL Server 2008 R2 GDR: June 14, 2011]:http://support.microsoft.com/kb/2494088 +[Cumulative update package 14 (CU14) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2703280 +[Cumulative update package 13 (CU13) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2679366 +[Cumulative update package 12 (CU12) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2659692 +[Cumulative update package 11 (CU11) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2633145 +[Cumulative update package 10 (CU10) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2591746 +[Cumulative update package 9 (CU9) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2567713 +[FIX: Database data files might be incorrectly marked as sparse in SQL Server 2008 R2 or in SQL Server 2008 even when the physical files are marked as not sparse in the file system]:http://support.microsoft.com/kb/2574699 +[Cumulative update package 8 (CU8) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2534352 +[MS11-049: Description of the security update for SQL Server 2008 R2 QFE: June 14, 2011]:http://support.microsoft.com/kb/2494086 +[Cumulative update package 7 (CU7) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2507770 +[FIX: Non-yielding scheduler error when you run a query that uses a TVP in SQL Server 2008 or in SQL Server 2008 R2 if SQL Profiler or SQL Server Extended Events is used]:http://support.microsoft.com/kb/2520808 +[Cumulative update package 6 (CU6) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2489376 +[Cumulative update package 5 (CU5) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2438347 +[Cumulative update package 4 (CU4) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2345451 +[Cumulative update package 3 (CU3) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2261464 +[Cumulative update package 2 (CU2) for SQL Server 2008 R2]:http://support.microsoft.com/kb/2072493 +[Cumulative update package 1 (CU1) for SQL Server 2008 R2]:http://support.microsoft.com/kb/981355 +[MS11-049: Description of the security update for SQL Server 2008 R2 GDR: June 14, 2011]:http://support.microsoft.com/kb/2494088 ## Microsoft SQL Server 2008 Builds @@ -1116,14 +1405,14 @@ Microsoft SQL Server 2014 (SP2-CU9) (KB4055557) - 12.0.5563.0 (X64) | 10.0.1049 | 2007.100.1049.14 | SQL Server 2008 CTP, July 2007 | 2007-07-31 | | 10.0.1019 | 2007.100.1019.17 | SQL Server 2008 CTP, June 2007 | 2007-05-21 | -[3146034 Intermittent service terminations occur after you install any SQL Server 2008 or SQL Server 2008 R2 versions from KB3135244]:http://support.microsoft.com/en-us/kb/3146034 -[3135244 TLS 1.2 support for SQL Server 2008 SP4]:http://support.microsoft.com/en-us/kb/3135244 +[3146034 Intermittent service terminations occur after you install any SQL Server 2008 or SQL Server 2008 R2 versions from KB3135244]:http://support.microsoft.com/kb/3146034 +[3135244 TLS 1.2 support for SQL Server 2008 SP4]:http://support.microsoft.com/kb/3135244 [3045308 MS15-058: Description of the security update for SQL Server 2008 Service Pack 4 QFE: July 14, 2015]:http://support.microsoft.com/kb/3045308 [3034373 An on-demand hotfix update package is available for SQL Server 2008 Service Pack 4 (SP4)]:http://support.microsoft.com/kb/3034373 -[3045311 MS15-058: Description of the security update for SQL Server 2008 Service Pack 4 GDR: July 14, 2015]:https://support.microsoft.com/en-us/kb/3045311 -[2979596 SQL Server 2008 Service Pack 4 release information]:https://support.microsoft.com/en-us/kb/2979596 -[3135244 TLS 1.2 support for SQL Server 2008 SP3 (IA-64 only)]:http://support.microsoft.com/en-us/kb/3135244 -[3045303 MS15-058: Description of the security update for SQL Server 2008 Service Pack 3 QFE: July 14, 2015]:https://support.microsoft.com/en-us/kb/3045303 +[3045311 MS15-058: Description of the security update for SQL Server 2008 Service Pack 4 GDR: July 14, 2015]:https://support.microsoft.com/kb/3045311 +[2979596 SQL Server 2008 Service Pack 4 release information]:https://support.microsoft.com/kb/2979596 +[3135244 TLS 1.2 support for SQL Server 2008 SP3 (IA-64 only)]:http://support.microsoft.com/kb/3135244 +[3045303 MS15-058: Description of the security update for SQL Server 2008 Service Pack 3 QFE: July 14, 2015]:https://support.microsoft.com/kb/3045303 [2977322 MS14-044: Description of the security update for SQL Server 2008 SP3 (QFE)]:http://support.microsoft.com/kb/2977322 [2877204 FIX: Error 8985 when you run the "dbcc shrinkfile" statement by using the logical name of a file in SQL Server 2008 R2 or SQL Server 2008]:http://support.microsoft.com/kb/2877204 [2958696 Cumulative update package 17 (CU17) for SQL Server 2008 Service Pack 3]:http://support.microsoft.com/kb/2958696 @@ -1144,11 +1433,11 @@ Microsoft SQL Server 2014 (SP2-CU9) (KB4055557) - 12.0.5563.0 (X64) [2648098 Cumulative update package 3 (CU3) for SQL Server 2008 Service Pack 3]:http://support.microsoft.com/kb/2648098 [2633143 Cumulative update package 2 (CU2) for SQL Server 2008 Service Pack 3]:http://support.microsoft.com/kb/2633143 [2617146 Cumulative update package 1 (CU1) for SQL Server 2008 Service Pack 3]:http://support.microsoft.com/kb/2617146 -[3045305 MS15-058: Description of the security update for SQL Server 2008 Service Pack 3 GDR: July 14, 2015]:https://support.microsoft.com/en-us/kb/3045305 +[3045305 MS15-058: Description of the security update for SQL Server 2008 Service Pack 3 GDR: July 14, 2015]:https://support.microsoft.com/kb/3045305 [2977321 MS14-044: Description of the security update for SQL Server 2008 SP3 (GDR)]:http://support.microsoft.com/kb/2977321 -[Microsoft Security Bulletin MS12-070]:http://technet.microsoft.com/en-us/security/bulletin/ms12-070 +[Microsoft Security Bulletin MS12-070]:http://technet.microsoft.com/security/bulletin/ms12-070 [SQL Server 2008 Service Pack 3 (SP3)]:http://www.microsoft.com/download/en/details.aspx?id=27594 -[Microsoft Security Bulletin MS12-070]:http://technet.microsoft.com/en-us/security/bulletin/ms12-070 +[Microsoft Security Bulletin MS12-070]:http://technet.microsoft.com/security/bulletin/ms12-070 [2715951 Cumulative update package 11 (CU11) for SQL Server 2008 Service Pack 2]:http://support.microsoft.com/kb/2715951 [2696625 Cumulative update package 10 (CU10) for SQL Server 2008 Service Pack 2]:http://support.microsoft.com/kb/2696625 [2673382 Cumulative update package 9 (CU9) for SQL Server 2008 Service Pack 2]:http://support.microsoft.com/kb/2673382 @@ -1160,7 +1449,7 @@ Microsoft SQL Server 2014 (SP2-CU9) (KB4055557) - 12.0.5563.0 (X64) [2498535 Cumulative update package 3 (CU3) for SQL Server 2008 Service Pack 2]:http://support.microsoft.com/kb/2498535 [2467239 Cumulative update package 2 (CU2) for SQL Server 2008 Service Pack 2]:http://support.microsoft.com/kb/2467239 [2289254 Cumulative update package 1 (CU1) for SQL Server 2008 Service Pack 2]:http://support.microsoft.com/kb/2289254 -[Microsoft Security Bulletin MS12-070]:http://technet.microsoft.com/en-us/security/bulletin/ms12-070 +[Microsoft Security Bulletin MS12-070]:http://technet.microsoft.com/security/bulletin/ms12-070 [2494089 MS11-049: Description of the security update for SQL Server 2008 Service Pack 2 GDR: June 14, 2011]:http://support.microsoft.com/kb/2494089 [SQL Server 2008 Service Pack 2 (SP2)]:http://www.microsoft.com/downloads/en/details.aspx?FamilyID=8FBFC1DE-D25E-4790-88B5-7DDA1F1D4E17 [2582282 Cumulative update package 16 (CU16) for SQL Server 2008 Service Pack 1]:http://support.microsoft.com/kb/2582282 @@ -1183,7 +1472,7 @@ Microsoft SQL Server 2014 (SP2-CU9) (KB4055557) - 12.0.5563.0 (X64) [970507 FIX: Error message in SQL Server 2008 when you run an INSERT SELECT statement on a table: "Violation of PRIMARY KEY constraint ''. Cannot insert duplicate key in object ''"]:http://support.microsoft.com/kb/970507 [969099 Cumulative update package 1 (CU1) for SQL Server 2008 Service Pack 1]:http://support.microsoft.com/kb/969099 [2494096 MS11-049: Description of the security update for SQL Server 2008 Service Pack 1 GDR: June 14, 2011]:http://support.microsoft.com/kb/2494096 -[SQL Server 2008 Service Pack 1 (SP1)]:http://www.microsoft.com/en-us/download/details.aspx?id=20302 +[SQL Server 2008 Service Pack 1 (SP1)]:http://www.microsoft.com/download/details.aspx?id=20302 [979064 Cumulative update package 10 (CU10) for SQL Server 2008]:http://support.microsoft.com/kb/979064 [977444 Cumulative update package 9 (CU9) for SQL Server 2008]:http://support.microsoft.com/kb/977444 [975976 Cumulative update package 8 (CU8) for SQL Server 2008]:http://support.microsoft.com/kb/975976 @@ -1196,7 +1485,7 @@ Microsoft SQL Server 2014 (SP2-CU9) (KB4055557) - 12.0.5563.0 (X64) [958611 FIX: You may receive incorrect results when you run a query that references three or more tables in the FROM clause in SQL Server 2008]:http://support.microsoft.com/kb/958611 [956717 Cumulative update package 1 (CU1) for SQL Server 2008]:http://support.microsoft.com/kb/956717 [956718 FIX: A MERGE statement may not enforce a foreign key constraint when the statement updates a unique key column that is not part of a clustering key that has a single row as the update source in SQL Server 2008]:http://support.microsoft.com/kb/956718 -[SQL Server 2008 RTM]:http://msdn.microsoft.com/en-us/subscriptions/downloads/details/default.aspx?pm=pid%3a334 +[SQL Server 2008 RTM]:http://msdn.microsoft.com/subscriptions/downloads/details/default.aspx?pm=pid%3a334 ## Microsoft SQL Server 2005 Builds @@ -1441,14 +1730,14 @@ Microsoft SQL Server 2014 (SP2-CU9) (KB4055557) - 12.0.5563.0 (X64) | 9.00.1528 | 2005.90.1528.0 | [915306 FIX: The merge agent fails and a "permission denied" error message is logged when you synchronize a SQL Server 2005-based merge publication] | 2007-01-08 | | 9.00.1528 | 2005.90.1528.0 | [915112 FIX: Error message when an ADO.NET-connected application tries to reuse a connection from the connection pool in SQL Server 2005: "The request failed to run because the batch is aborted"] | 2006-07-26 | | 9.00.1519 | 2005.90.1519.0 | [913494 FIX: The merge agent does not use a specified custom user update to handle conflicting UPDATE statements in SQL Server 2005] | 2007-01-20 | -| 9.00.1518 | 2005.90.1518.0 | [913941 FIX: A SQL Server login may have more permissions when you log on to an instance of SQL Server 2005] | 2006-09-22 | -| 9.00.1518 | 2005.90.1518.0 | [912472 FIX: An incorrect result may appear in the subscribing database when you set database mirroring for a database and database failover occurs in SQL Server 2005] | 2006-07-26 | -| 9.00.1518 | 2005.90.1518.0 | [913371 FIX: You may receive error messages when you use the sp_cursoropen statement to open a cursor on a user-defined stored procedure in SQL Server 2005] | 2006-07-26 | -| 9.00.1514 | 2005.90.1514.0 | [912471 FIX: The replication on the server does not work any longer when you manually fail over databases in SQL Server 2005] | 2006-07-26 | -| 9.00.1503 | 2005.90.1503.0 | [911662 FIX: You may receive an access violation error message when you run a SELECT query in SQL Server 2005] | 2006-07-26 | -| 9.00.1502 | 2005.90.1502.0 | [915793 FIX: You cannot restore the log backups on the mirror server after you remove database mirroring for the mirror database in SQL Server 2005] | 2006-07-26 | -| 9.00.1500 | 2005.90.1500.0 | [910416 FIX: Error message when you run certain queries or certain stored procedures in SQL Server 2005: "A severe error occurred on the current command"] | 2006-06-01 | -| 9.00.1406 | 2005.90.1406.0 | [932557 FIX: A script task or a script component may not run correctly when you run an SSIS package in SQL Server 2005 build 1399] | 2007-07-11 | +| 9.00.1518 | 2005.90.1518.0 | 913941 FIX: A SQL Server login may have more permissions when you log on to an instance of SQL Server 2005 | 2006-09-22 | +| 9.00.1518 | 2005.90.1518.0 | 912472 FIX: An incorrect result may appear in the subscribing database when you set database mirroring for a database and database failover occurs in SQL Server 2005 | 2006-07-26 | +| 9.00.1518 | 2005.90.1518.0 | 913371 FIX: You may receive error messages when you use the sp_cursoropen statement to open a cursor on a user-defined stored procedure in SQL Server 2005 | 2006-07-26 | +| 9.00.1514 | 2005.90.1514.0 | 912471 FIX: The replication on the server does not work any longer when you manually fail over databases in SQL Server 2005 | 2006-07-26 | +| 9.00.1503 | 2005.90.1503.0 | 911662 FIX: You may receive an access violation error message when you run a SELECT query in SQL Server 2005 | 2006-07-26 | +| 9.00.1502 | 2005.90.1502.0 | 915793 FIX: You cannot restore the log backups on the mirror server after you remove database mirroring for the mirror database in SQL Server 2005 | 2006-07-26 | +| 9.00.1500 | 2005.90.1500.0 | 910416 FIX: Error message when you run certain queries or certain stored procedures in SQL Server 2005: "A severe error occurred on the current command" | 2006-06-01 | +| 9.00.1406 | 2005.90.1406.0 | 932557 FIX: A script task or a script component may not run correctly when you run an SSIS package in SQL Server 2005 build 1399 | 2007-07-11 | | 9.00.1399 | 2005.90.1399.0 | SQL Server 2005 RTM | 2005-11-07 | [2716427 MS12-070: Description of the security update for SQL Server 2005 Service Pack 4 QFE]:http://support.microsoft.com/kb/2716427 @@ -1459,7 +1748,7 @@ Microsoft SQL Server 2014 (SP2-CU9) (KB4055557) - 12.0.5563.0 (X64) [2507769 Cumulative update package 3 (CU3) for SQL Server 2005 Service Pack 4]:http://support.microsoft.com/kb/2507769 [2489409 Cumulative update package 2 (CU2) for SQL Server 2005 Service Pack 4]:http://support.microsoft.com/kb/2489409 [2464079 Cumulative update package 1 (CU1) for SQL Server 2005 Service Pack 4]:http://support.microsoft.com/kb/2464079 -[Microsoft Security Bulletin MS12-070]:http://technet.microsoft.com/en-us/security/bulletin/ms12-070 +[Microsoft Security Bulletin MS12-070]:http://technet.microsoft.com/security/bulletin/ms12-070 [2494120 MS11-049: Description of the security update for SQL Server 2005 Service Pack 4 GDR: June 14, 2011]:http://support.microsoft.com/kb/2494120 [SQL Server 2005 Service Pack 4 (SP4)]:http://www.microsoft.com/downloads/en/details.aspx?FamilyID=b953e84f-9307-405e-bceb-47bd345baece [2598903 FIX: SQL Server Agent job randomly stops when you schedule the job to run past midnight on specific days in SQL Server 2005, in SQL Server 2008 or in SQL Server 2008 R2]:http://support.microsoft.com/kb/2598903 @@ -1585,7 +1874,7 @@ Microsoft SQL Server 2014 (SP2-CU9) (KB4055557) - 12.0.5563.0 (X64) [940286 FIX: A Service Broker endpoint stops passing messages in a database mirroring session of SQL Server 2005]:http://support.microsoft.com/kb/940286 [937343 FIX: SQL Server 2005 stops and then restarts unexpectedly and errors occur in the tempdb database]:http://support.microsoft.com/kb/937343 [937545 FIX: Error message when you use the BULK INSERT statement to import a data file into a table in SQL Server 2005 with SP1: "The OLE DB provider "BULK" for linked server "(null)" reported an error"]:http://support.microsoft.com/kb/937545 -[933499 FIX: Error message when you use transactional replication to replicate the execution of stored procedures to subscribers in SQL Server 2005: "Insufficient memory to run query"]:https://support.microsoft.com/en-us/kb/933499 +[933499 FIX: Error message when you use transactional replication to replicate the execution of stored procedures to subscribers in SQL Server 2005: "Insufficient memory to run query"]:https://support.microsoft.com/kb/933499 [937544 FIX: You may receive error 3456 when you try to restore a transaction log for a SQL Server 2005 database]:http://support.microsoft.com/kb/937544 [937277 FIX: A memory leak occurs when you use the sp_OAMethod stored procedure to call a method of a COM object in SQL Server 2005]:http://support.microsoft.com/kb/937277 [934812 FIX: You cannot bring the SQL Server group online in a cluster environment after you rename the virtual server name of the default instance of SQL Server 2005]:http://support.microsoft.com/kb/934812 @@ -1659,7 +1948,7 @@ Microsoft SQL Server 2014 (SP2-CU9) (KB4055557) - 12.0.5563.0 (X64) [932555 FIX: A script task or a script component may not run correctly when you run an SSIS package in SQL Server 2005 build 2047]:http://support.microsoft.com/kb/932555 [SQL Server 2005 Service Pack 1 (SP1)]:http://www.microsoft.com/downloads/details.aspx?FamilyID=CB6C71EA-D649-47FF-9176-E7CAC58FD4BC [932556 FIX: A script task or a script component may not run correctly when you run an SSIS package in SQL Server 2005 build 1500 and later builds]:http://support.microsoft.com/kb/932556 -[926493 FIX: Error message when you restore a transaction-log backup that is generated in SQL Server 2000 SP4 to an instance of SQL Server 2005: "Msg 3456, Level 16, State 1, Line 1. Could not redo log record"]:https://support.microsoft.com/en-us/kb/926493 +[926493 FIX: Error message when you restore a transaction-log backup that is generated in SQL Server 2000 SP4 to an instance of SQL Server 2005: "Msg 3456, Level 16, State 1, Line 1. Could not redo log record"]:https://support.microsoft.com/kb/926493 [926292 FIX: When you query through a view that uses the ORDER BY clause in SQL Server 2005, the result is still returned in random order]:http://support.microsoft.com/kb/926292 [922527 FIX: Error message when you schedule some SQL Server 2005 Integration Services packages to run as jobs: "Package has been cancelled"]:http://support.microsoft.com/kb/922527 [922804 FIX: After you detach a Microsoft SQL Server 2005 database that resides on network-attached storage, you cannot reattach the SQL Server database]:http://support.microsoft.com/kb/922804 @@ -1682,14 +1971,7 @@ Microsoft SQL Server 2014 (SP2-CU9) (KB4055557) - 12.0.5563.0 (X64) [915306 FIX: The merge agent fails and a "permission denied" error message is logged when you synchronize a SQL Server 2005-based merge publication]:http://support.microsoft.com/kb/915306 [915112 FIX: Error message when an ADO.NET-connected application tries to reuse a connection from the connection pool in SQL Server 2005: "The request failed to run because the batch is aborted"]:http://support.microsoft.com/kb/915112 [913494 FIX: The merge agent does not use a specified custom user update to handle conflicting UPDATE statements in SQL Server 2005]:http://support.microsoft.com/kb/913494 -[913941 FIX: A SQL Server login may have more permissions when you log on to an instance of SQL Server 2005]:http://support.microsoft.com/kb/913941 -[912472 FIX: An incorrect result may appear in the subscribing database when you set database mirroring for a database and database failover occurs in SQL Server 2005]:http://support.microsoft.com/kb/912472 -[913371 FIX: You may receive error messages when you use the sp_cursoropen statement to open a cursor on a user-defined stored procedure in SQL Server 2005]:http://support.microsoft.com/kb/913371 -[912471 FIX: The replication on the server does not work any longer when you manually fail over databases in SQL Server 2005]:http://support.microsoft.com/kb/912471 -[911662 FIX: You may receive an access violation error message when you run a SELECT query in SQL Server 2005]:http://support.microsoft.com/kb/911662 -[915793 FIX: You cannot restore the log backups on the mirror server after you remove database mirroring for the mirror database in SQL Server 2005]:http://support.microsoft.com/kb/915793 -[910416 FIX: Error message when you run certain queries or certain stored procedures in SQL Server 2005: "A severe error occurred on the current command"]:http://support.microsoft.com/kb/910416 -[932557 FIX: A script task or a script component may not run correctly when you run an SSIS package in SQL Server 2005 build 1399]:http://support.microsoft.com/kb/932557 +[913941 FIX: A SQL Server login may have more permissions when you log on to an instance of SQL Server 2005]:https://web.archive.org/web/20170712163528/https://support.microsoft.com/en-us/help/913494 ## Microsoft SQL Server 2000 Builds @@ -1699,167 +1981,167 @@ Microsoft SQL Server 2014 (SP2-CU9) (KB4055557) - 12.0.5563.0 (X64) |-----------|----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------| | 8.00.2305 | 2000.80.2305.0 | [983811 MS12-060: Description of the security update for SQL Server 2000 Service Pack 4 QFE: August 14, 2012] | 2012-08-14 | | 8.00.2301 | 2000.80.2301.0 | [983809 MS12-027: Description of the security update for Microsoft SQL Server 2000 Service Pack 4 QFE: April 10, 2012] | 2012-04-10 | -| 8.00.2283 | 2000.80.2283.0 | [971524 FIX: An access violation occurs when you run a DELETE statement or an UPDATE statement in the Itanium-based versions of SQL Server 2000 after you install security update MS09-004] | 2009-06-15 | +| 8.00.2283 | 2000.80.2283.0 | 971524 FIX: An access violation occurs when you run a DELETE statement or an UPDATE statement in the Itanium-based versions of SQL Server 2000 after you install security update MS09-004] | 2009-06-15 | | 8.00.2282 | 2000.80.2282.0 | [960083 MS09-004: Description of the security update for SQL Server 2000 QFE and for MSDE 2000: February 10, 2009] | 2009-02-10 | -| 8.00.2279 | 2000.80.2279.0 | [959678 FIX: When you run the SPSBackup.exe utility to back up a SQL Server 2000 database that is configured as a back-end database for a Windows SharePoint Services server, the backup operation fails] | 2009-04-08 | -| 8.00.2273 | 2000.80.2273.0 | [948111 MS08-040: Description of the security update for SQL Server 2000 QFE and MSDE 2000 July 8, 2008] | 2008-08-05 | -| 8.00.2271 | 2000.80.2271.0 | [946584 FIX: The SPACE function always returns one space in SQL Server 2000 if the SPACE function uses a collation that differs from the collation of the current database] | 2008-03-12 | -| 8.00.2265 | 2000.80.2265.0 | [944985 FIX: The data on the publisher does not match the data on the subscriber when you synchronize a SQL Server 2005 Mobile Edition subscriber with a SQL Server 2000 "merge replication" publisher] | 2007-12-19 | -| 8.00.2253 | 2000.80.2253.0 | [939317 FIX: The CPU utilization may suddenly increase to 100 percent when there are many connections to an instance of SQL Server 2000 on a computer that has multiple processors] | 2007-10-09 | -| 8.00.2249 | 2000.80.2249.0 | [936232 FIX: An access violation may occur when you try to log in to an instance of SQL Server 2000] | 2007-05-25 | -| 8.00.2248 | 2000.80.2248.0 | [935950 FIX: The foreign key that you created between two tables does not work after you run the CREATE INDEX statement in SQL Server 2000] | 2007-06-14 | -| 8.00.2246 | 2000.80.2246.0 | [935465 An updated version of Sqlvdi.dll is now available for SQL Server 2000] | 2007-06-18 | -| 8.00.2245 | 2000.80.2245.0 | [933573 FIX: You may receive an assertion or database corruption may occur when you use the bcp utility or the "Bulk Insert" Transact-SQL command to import data in SQL Server 2000] | 2007-04-24 | -| 8.00.2244 | 2000.80.2244.0 | [934203 FIX: A hotfix for Microsoft SQL Server 2000 Service Pack 4 may not update all the necessary files on an x64-based computer] | 2007-05-10 | -| 8.00.2242 | 2000.80.2242.0 | [929131 FIX: In SQL Server 2000, the synchronization process is slow, and the CPU usage is high on the computer that is configured as the Distributor] | 2007-03-28 | -| 8.00.2238 | 2000.80.2238.0 | [931932 FIX: The merge agent fails intermittently when you use merge replication that uses a custom resolver after you install SQL Server 2000 Service Pack 4] | 2007-02-21 | -| 8.00.2236 | 2000.80.2236.0 | [930484 FIX: CPU utilization may approach 100 percent on a computer that is running SQL Server 2000 after you run the BACKUP DATABASE statement or the BACKUP LOG statement] | 2007-02-02 | -| 8.00.2234 | 2000.80.2234.0 | [929440 FIX: Error messages when you try to update table rows or insert table rows into a table in SQL Server 2000: "644" or "2511"] | 2007-02-22 | -| 8.00.2232 | 2000.80.2232.0 | [928568 FIX: SQL Server 2000 stops responding when you cancel a query or when a query time-out occurs, and error messages are logged in the SQL Server error log file] | 2007-01-15 | -| 8.00.2231 | 2000.80.2231.0 | [928079 FIX: The Sqldumper.exe utility cannot generate a filtered SQL Server dump file when you use the Remote Desktop Connection service or Terminal Services to connect to a Windows 2000 Server-based computer in SQL Server 2000] | 2007-06-19 | -| 8.00.2229 | 2000.80.2229.0 | [927186 FIX: Error message when you create a merge replication for tables that have computed columns in SQL Server 2000 Service Pack 4: "The process could not log conflict information"] | 2007-07-24 | -| 8.00.2226 | 2000.80.2226.0 | [925684 FIX: You may experience one or more symptoms when you run a "CREATE INDEX" statement on an instance of SQL Server 2000] | 2006-11-20 | -| 8.00.2226 | 2000.80.2226.0 | [925732 FIX: You may receive inconsistent comparison results when you compare strings by using a width sensitive collation in SQL Server 2000] | 2006-11-13 | -| 8.00.2223 | 2000.80.2223.0 | [925419 FIX: The server stops responding, the performance is slow, and a time-out occurs in SQL Server 2000] | 2007-07-20 | -| 8.00.2223 | 2000.80.2223.0 | [925678 FIX: Error message when you schedule a Replication Merge Agent job to run after you install SQL Server 2000 Service Pack 4: "The process could not enumerate changes at the 'Subscriber'"] | 2006-10-31 | -| 8.00.2218 | 2000.80.2218.0 | [925297 FIX: The result may be sorted in the wrong order when you run a query that uses the ORDER BY clause to sort a column in a table in SQL Server 2000] | 2007-06-19 | -| 8.00.2217 | 2000.80.2217.0 | [924664 FIX: You cannot stop the SQL Server service, or many minidump files and many log files are generated in SQL Server 2000] | 2007-10-25 | -| 8.00.2215 | 2000.80.2215.0 | [923796 FIX: Data in a subscriber of a merge publication in SQL Server 2000 differs from the data in the publisher] | 2007-01-12 | -| 8.00.2215 | 2000.80.2215.0 | [924662 FIX: The query performance may be slow when you query data from a view in SQL Server 2000] | 2006-10-05 | -| 8.00.2215 | 2000.80.2215.0 | [923563 FIX: Error message when you configure an immediate updating transactional replication in SQL Server 2000: "Implicit conversion from datatype 'text' to 'nvarchar' is not allowed"] | 2006-10-30 | -| 8.00.2215 | 2000.80.2215.0 | [923327 FIX: You may receive an access violation error message when you import data by using the "Bulk Insert" command in SQL Server 2000] | 2006-12-28 | -| 8.00.2209 | 2000.80.2209.0 | [923797 The Knowledge Base (KB) Article You Requested Is Currently Not Available] | ??? | -| 8.00.2207 | 2000.80.2207.0 | [923344 FIX: A SQL Server 2000 session may be blocked for the whole time that a Snapshot Agent job runs] | 2006-08-28 | -| 8.00.2201 | 2000.80.2201.0 | [920930 FIX: Error message when you try to run a query on a linked server in SQL Server 2000] | 2006-08-21 | -| 8.00.2199 | 2000.80.2199.0 | [919221 FIX: SQL Server 2000 may take a long time to complete the synchronization phase when you create a merge publication] | 2006-07-26 | -| 8.00.2197 | 2000.80.2197.0 | [919133 FIX: Each query takes a long time to compile when you execute a single query or when you execute multiple concurrent queries in SQL Server 2000] | 2006-08-02 | -| 8.00.2197 | 2000.80.2197.0 | [919068 FIX: The query may return incorrect results, and the execution plan for the query may contain a "Table Spool" operator in SQL Server 2000] | 2006-08-08 | -| 8.00.2197 | 2000.80.2197.0 | [919399 FIX: A profiler trace in SQL Server 2000 may stop logging events unexpectedly, and you may receive the following error message: "Failed to read trace data"] | 2006-10-18 | -| 8.00.2196 | 2000.80.2196.0 | [919165 FIX: A memory leak occurs when you run a remote query by using a linked server in SQL Server 2000] | 2006-08-14 | -| 8.00.2194 | 2000.80.2194.0 | [917565 FIX: Error 17883 is logged in the SQL Server error log, and the instance of SQL Server 2000 temporarily stops responding] | 2007-02-21 | -| 8.00.2194 | 2000.80.2194.0 | [917972 FIX: You receive an access violation error message when you try to perform a read of a large binary large object column in SQL Server 2000] | 2006-09-22 | -| 8.00.2192 | 2000.80.2192.0 | [917606 FIX: You may notice a decrease in performance when you run a query that uses the UNION ALL operator in SQL Server 2000 Service Pack 4] | 2006-08-04 | -| 8.00.2191 | 2000.80.2191.0 | [916698 FIX: Error message when you run SQL Server 2000: "Failed assertion = 'lockFound == TRUE'"] | 2006-07-26 | -| 8.00.2191 | 2000.80.2191.0 | [916950 FIX: You may experience heap corruption, and SQL Server 2000 may shut down with fatal access violations when you try to browse files in SQL Server 2000 Enterprise Manager on a Windows Server 2003 x64-based computer] | 2006-10-03 | -| 8.00.2189 | 2000.80.2189.0 | [916652 FIX: An access violation may occur when you run a query on a table that has a multicolumn index in SQL Server 2000] | 2006-07-26 | -| 8.00.2189 | 2000.80.2189.0 | [913438 FIX: The SQL Server process may end unexpectedly when you turn on trace flag -T1204 and a profiler trace is capturing the Lock:DeadLock Chain event in SQL Server 2000 SP4] | 2006-07-19 | -| 8.00.2187 | 2000.80.2187.0 | [915340 FIX: A deadlock occurs when the scheduled SQL Server Agent job that you add or that you update is running in SQL Server 2000] | 2007-06-18 | -| 8.00.2187 | 2000.80.2187.0 | [916287 A cumulative hotfix package is available for SQL Server 2000 Service Pack 4 build 2187] | 2006-10-16 | -| 8.00.2187 | 2000.80.2187.0 | [914384 FIX: The database status changes to Suspect when you perform a bulk copy in a transaction and then roll back the transaction in SQL Server 2000] | 2006-07-26 | -| 8.00.2187 | 2000.80.2187.0 | [915065 FIX: Error message when you try to apply a hotfix on a SQL Server 2000-based computer that is configured as a MSCS node: "An error in updating your system has occurred"] | 2006-12-11 | -| 8.00.2180 | 2000.80.2180.0 | [913789 FIX: The password that you specify in a BACKUP statement appears in the SQL Server Errorlog file or in the Application event log if the BACKUP statement does not run in SQL Server 2000] | 2007-02-19 | -| 8.00.2180 | 2000.80.2180.0 | [913684 FIX: You may receive error messages when you use linked servers in SQL Server 2000 on a 64-bit Itanium processor] | 2006-07-26 | -| 8.00.2175 | 2000.80.2175.0 | [911678 FIX: No rows may be returned, and you may receive an error message when you try to import SQL Profiler trace files into tables by using the fn_trace_gettable function in SQL Server 2000] | 2006-07-26 | -| 8.00.2172 | 2000.80.2172.0 | [910707 FIX: When you query a view that was created by using the VIEW_METADATA option, an access violation may occur in SQL Server 2000] | 2006-07-26 | -| 8.00.2171 | 2000.80.2171.0 | [909369 FIX: Automatic checkpoints on some SQL Server 2000 databases do not run as expected] | 2006-07-26 | -| 8.00.2168 | 2000.80.2168.0 | [907813 FIX: An error occurs when you try to access the Analysis Services performance monitor counter object after you apply Windows Server 2003 SP1] | 2006-11-21 | -| 8.00.2166 | 2000.80.2166.0 | [909734 FIX: An error message is logged, and new diagnostics do not capture the thread stack when the SQL Server User Mode Scheduler (UMS) experiences a nonyielding thread in SQL Server 2000 Service Pack 4] | 2006-07-26 | -| 8.00.2162 | 2000.80.2162.0 | [904660 A cumulative hotfix package is available for SQL Server 2000 Service Pack 4 build 2162] | 2006-09-15 | -| 8.00.2159 | 2000.80.2159.0 | [907250 FIX: You may experience concurrency issues when you run the DBCC INDEXDEFRAG statement in SQL Server 2000] | 2006-07-26 | -| 8.00.2156 | 2000.80.2156.0 | [906790 FIX: You receive an error message when you try to rebuild the master database after you have installed hotfix builds in SQL Server 2000 SP4 64-bit] | 2006-07-25 | -| 8.00.2151 | 2000.80.2151.0 | [903742 FIX: You receive an "Error: 8526, Severity: 16, State: 2" error message in SQL Profiler when you use SQL Query Analyzer to start or to enlist into a distributed transaction after you have installed SQL Server 2000 SP4] | 2006-07-25 | -| 8.00.2151 | 2000.80.2151.0 | [904244 FIX: Incorrect data is inserted unexpectedly when you perform a bulk copy operation by using the DB-Library API in SQL Server 2000 Service Pack 4] | 2007-06-13 | -| 8.00.2148 | 2000.80.2148.0 | [899430 FIX: An access violation may occur when you run a SELECT query and the NO_BROWSETABLE option is set to ON in Microsoft SQL Server 2000] | 2006-07-25 | -| 8.00.2148 | 2000.80.2148.0 | [899431 FIX: An access violation occurs in the Mssdi98.dll file, and SQL Server crashes when you use SQL Query Analyzer to debug a stored procedure in SQL Server 2000 Service Pack 4] | 2006-07-25 | -| 8.00.2148 | 2000.80.2148.0 | [900390 FIX: The Mssdmn.exe process may use lots of CPU capacity when you perform a SQL Server 2000 full text search of Office Word documents] | 2006-06-01 | -| 8.00.2148 | 2000.80.2148.0 | [900404 FIX: The results of the query may be returned much slower than you expect when you run a query that includes a GROUP BY statement in SQL Server 2000] | 2006-06-01 | -| 8.00.2148 | 2000.80.2148.0 | [901212 FIX: You receive an error message if you use the sp_addalias or sp_dropalias procedures when the IMPLICIT_TRANSACTIONS option is set to ON in SQL Server 2000 SP4] | 2006-07-25 | -| 8.00.2148 | 2000.80.2148.0 | [902150 FIX: Some 32-bit applications that use SQL-DMO and SQL-VDI APIs may stop working after you install SQL Server 2000 Service Pack 4 on an Itanium-based computer] | 2006-06-01 | -| 8.00.2148 | 2000.80.2148.0 | [902955 FIX: You receive a "Getting registry information" message when you run the Sqldiag.exe utility after you install SQL Server 2000 SP4] | 2006-07-25 | -| 8.00.2147 | 2000.80.2147.0 | [899410 FIX: You may experience slow server performance when you start a trace in an instance of SQL Server 2000 that runs on a computer that has more than four processors] | 2006-06-01 | -| 8.00.2145 | 2000.80.2145.0 | [826906 FIX: A query that uses a view that contains a correlated subquery and an aggregate runs slowly] | 2005-10-25 | -| 8.00.2145 | 2000.80.2145.0 | [836651 FIX: You receive query results that were not expected when you use both ANSI joins and non-ANSI joins] | 2006-06-07 | -| 8.00.2066 | 2000.80.2066.0 | [Microsoft Security Bulletin MS12-060] | 2012-08-14 | -| 8.00.2065 | 2000.80.2065.0 | [983808 MS12-027: Description of the security update for Microsoft SQL Server 2000 Service Pack 4 GDR: April 10, 2012] | 2012-04-10 | -| 8.00.2055 | 2000.80.2055.0 | [959420 MS09-004: Vulnerabilities in Microsoft SQL Server could allow remote code execution] | 2009-02-10 | -| 8.00.2040 | 2000.80.2040.0 | [899761 FIX: Not all memory is available when AWE is enabled on a computer that is running a 32-bit version of SQL Server 2000 SP4] | 2006-08-15 | -| 8.00.2039 | 2000.80.2039.0 | [SQL Server 2000 Service Pack 4 (SP4)] | 2005-05-06 | +| 8.00.2279 | 2000.80.2279.0 | 959678 FIX: When you run the SPSBackup.exe utility to back up a SQL Server 2000 database that is configured as a back-end database for a Windows SharePoint Services server, the backup operation fails | 2009-04-08 | +| 8.00.2273 | 2000.80.2273.0 | 948111 MS08-040: Description of the security update for SQL Server 2000 QFE and MSDE 2000 July 8, 2008 | 2008-08-05 | +| 8.00.2271 | 2000.80.2271.0 | 946584 FIX: The SPACE function always returns one space in SQL Server 2000 if the SPACE function uses a collation that differs from the collation of the current database | 2008-03-12 | +| 8.00.2265 | 2000.80.2265.0 | 944985 FIX: The data on the publisher does not match the data on the subscriber when you synchronize a SQL Server 2005 Mobile Edition subscriber with a SQL Server 2000 "merge replication" publisher | 2007-12-19 | +| 8.00.2253 | 2000.80.2253.0 | 939317 FIX: The CPU utilization may suddenly increase to 100 percent when there are many connections to an instance of SQL Server 2000 on a computer that has multiple processors | 2007-10-09 | +| 8.00.2249 | 2000.80.2249.0 | 936232 FIX: An access violation may occur when you try to log in to an instance of SQL Server 2000 | 2007-05-25 | +| 8.00.2248 | 2000.80.2248.0 | 935950 FIX: The foreign key that you created between two tables does not work after you run the CREATE INDEX statement in SQL Server 2000 | 2007-06-14 | +| 8.00.2246 | 2000.80.2246.0 | 935465 An updated version of Sqlvdi.dll is now available for SQL Server 2000 | 2007-06-18 | +| 8.00.2245 | 2000.80.2245.0 | 933573 FIX: You may receive an assertion or database corruption may occur when you use the bcp utility or the "Bulk Insert" Transact-SQL command to import data in SQL Server 2000 | 2007-04-24 | +| 8.00.2244 | 2000.80.2244.0 | 934203 FIX: A hotfix for Microsoft SQL Server 2000 Service Pack 4 may not update all the necessary files on an x64-based computer | 2007-05-10 | +| 8.00.2242 | 2000.80.2242.0 | 929131 FIX: In SQL Server 2000, the synchronization process is slow, and the CPU usage is high on the computer that is configured as the Distributor | 2007-03-28 | +| 8.00.2238 | 2000.80.2238.0 | 931932 FIX: The merge agent fails intermittently when you use merge replication that uses a custom resolver after you install SQL Server 2000 Service Pack 4 | 2007-02-21 | +| 8.00.2236 | 2000.80.2236.0 | 930484 FIX: CPU utilization may approach 100 percent on a computer that is running SQL Server 2000 after you run the BACKUP DATABASE statement or the BACKUP LOG statement | 2007-02-02 | +| 8.00.2234 | 2000.80.2234.0 | 929440 FIX: Error messages when you try to update table rows or insert table rows into a table in SQL Server 2000: "644" or "2511" | 2007-02-22 | +| 8.00.2232 | 2000.80.2232.0 | 928568 FIX: SQL Server 2000 stops responding when you cancel a query or when a query time-out occurs, and error messages are logged in the SQL Server error log file | 2007-01-15 | +| 8.00.2231 | 2000.80.2231.0 | 928079 FIX: The Sqldumper.exe utility cannot generate a filtered SQL Server dump file when you use the Remote Desktop Connection service or Terminal Services to connect to a Windows 2000 Server-based computer in SQL Server 2000 | 2007-06-19 | +| 8.00.2229 | 2000.80.2229.0 | 927186 FIX: Error message when you create a merge replication for tables that have computed columns in SQL Server 2000 Service Pack 4: "The process could not log conflict information" | 2007-07-24 | +| 8.00.2226 | 2000.80.2226.0 | 925684 FIX: You may experience one or more symptoms when you run a "CREATE INDEX" statement on an instance of SQL Server 2000 | 2006-11-20 | +| 8.00.2226 | 2000.80.2226.0 | 925732 FIX: You may receive inconsistent comparison results when you compare strings by using a width sensitive collation in SQL Server 2000 | 2006-11-13 | +| 8.00.2223 | 2000.80.2223.0 | 925419 FIX: The server stops responding, the performance is slow, and a time-out occurs in SQL Server 2000 | 2007-07-20 | +| 8.00.2223 | 2000.80.2223.0 | 925678 FIX: Error message when you schedule a Replication Merge Agent job to run after you install SQL Server 2000 Service Pack 4: "The process could not enumerate changes at the 'Subscriber'" | 2006-10-31 | +| 8.00.2218 | 2000.80.2218.0 | 925297 FIX: The result may be sorted in the wrong order when you run a query that uses the ORDER BY clause to sort a column in a table in SQL Server 2000 | 2007-06-19 | +| 8.00.2217 | 2000.80.2217.0 | 924664 FIX: You cannot stop the SQL Server service, or many minidump files and many log files are generated in SQL Server 2000 | 2007-10-25 | +| 8.00.2215 | 2000.80.2215.0 | 923796 FIX: Data in a subscriber of a merge publication in SQL Server 2000 differs from the data in the publisher | 2007-01-12 | +| 8.00.2215 | 2000.80.2215.0 | 924662 FIX: The query performance may be slow when you query data from a view in SQL Server 2000 | 2006-10-05 | +| 8.00.2215 | 2000.80.2215.0 | 923563 FIX: Error message when you configure an immediate updating transactional replication in SQL Server 2000: "Implicit conversion from datatype 'text' to 'nvarchar' is not allowed" | 2006-10-30 | +| 8.00.2215 | 2000.80.2215.0 | 923327 FIX: You may receive an access violation error message when you import data by using the "Bulk Insert" command in SQL Server 2000 | 2006-12-28 | +| 8.00.2209 | 2000.80.2209.0 | 923797 The Knowledge Base (KB) Article You Requested Is Currently Not Available | ??? | +| 8.00.2207 | 2000.80.2207.0 | 923344 FIX: A SQL Server 2000 session may be blocked for the whole time that a Snapshot Agent job runs | 2006-08-28 | +| 8.00.2201 | 2000.80.2201.0 | 920930 FIX: Error message when you try to run a query on a linked server in SQL Server 2000 | 2006-08-21 | +| 8.00.2199 | 2000.80.2199.0 | 919221 FIX: SQL Server 2000 may take a long time to complete the synchronization phase when you create a merge publication | 2006-07-26 | +| 8.00.2197 | 2000.80.2197.0 | 919133 FIX: Each query takes a long time to compile when you execute a single query or when you execute multiple concurrent queries in SQL Server 2000 | 2006-08-02 | +| 8.00.2197 | 2000.80.2197.0 | 919068 FIX: The query may return incorrect results, and the execution plan for the query may contain a "Table Spool" operator in SQL Server 2000 | 2006-08-08 | +| 8.00.2197 | 2000.80.2197.0 | 919399 FIX: A profiler trace in SQL Server 2000 may stop logging events unexpectedly, and you may receive the following error message: "Failed to read trace data" | 2006-10-18 | +| 8.00.2196 | 2000.80.2196.0 | 919165 FIX: A memory leak occurs when you run a remote query by using a linked server in SQL Server 2000 | 2006-08-14 | +| 8.00.2194 | 2000.80.2194.0 | 917565 FIX: Error 17883 is logged in the SQL Server error log, and the instance of SQL Server 2000 temporarily stops responding | 2007-02-21 | +| 8.00.2194 | 2000.80.2194.0 | 917972 FIX: You receive an access violation error message when you try to perform a read of a large binary large object column in SQL Server 2000 | 2006-09-22 | +| 8.00.2192 | 2000.80.2192.0 | 917606 FIX: You may notice a decrease in performance when you run a query that uses the UNION ALL operator in SQL Server 2000 Service Pack 4 | 2006-08-04 | +| 8.00.2191 | 2000.80.2191.0 | 916698 FIX: Error message when you run SQL Server 2000: "Failed assertion = 'lockFound == TRUE'" | 2006-07-26 | +| 8.00.2191 | 2000.80.2191.0 | 916950 FIX: You may experience heap corruption, and SQL Server 2000 may shut down with fatal access violations when you try to browse files in SQL Server 2000 Enterprise Manager on a Windows Server 2003 x64-based computer | 2006-10-03 | +| 8.00.2189 | 2000.80.2189.0 | 916652 FIX: An access violation may occur when you run a query on a table that has a multicolumn index in SQL Server 2000 | 2006-07-26 | +| 8.00.2189 | 2000.80.2189.0 | 913438 FIX: The SQL Server process may end unexpectedly when you turn on trace flag -T1204 and a profiler trace is capturing the Lock:DeadLock Chain event in SQL Server 2000 SP4 | 2006-07-19 | +| 8.00.2187 | 2000.80.2187.0 | 915340 FIX: A deadlock occurs when the scheduled SQL Server Agent job that you add or that you update is running in SQL Server 2000 | 2007-06-18 | +| 8.00.2187 | 2000.80.2187.0 | 916287 A cumulative hotfix package is available for SQL Server 2000 Service Pack 4 build 2187 | 2006-10-16 | +| 8.00.2187 | 2000.80.2187.0 | 914384 FIX: The database status changes to Suspect when you perform a bulk copy in a transaction and then roll back the transaction in SQL Server 2000 | 2006-07-26 | +| 8.00.2187 | 2000.80.2187.0 | 915065 FIX: Error message when you try to apply a hotfix on a SQL Server 2000-based computer that is configured as a MSCS node: "An error in updating your system has occurred" | 2006-12-11 | +| 8.00.2180 | 2000.80.2180.0 | 913789 FIX: The password that you specify in a BACKUP statement appears in the SQL Server Errorlog file or in the Application event log if the BACKUP statement does not run in SQL Server 2000 | 2007-02-19 | +| 8.00.2180 | 2000.80.2180.0 | 913684 FIX: You may receive error messages when you use linked servers in SQL Server 2000 on a 64-bit Itanium processor | 2006-07-26 | +| 8.00.2175 | 2000.80.2175.0 | 911678 FIX: No rows may be returned, and you may receive an error message when you try to import SQL Profiler trace files into tables by using the fn_trace_gettable function in SQL Server 2000 | 2006-07-26 | +| 8.00.2172 | 2000.80.2172.0 | 910707 FIX: When you query a view that was created by using the VIEW_METADATA option, an access violation may occur in SQL Server 2000 | 2006-07-26 | +| 8.00.2171 | 2000.80.2171.0 | 909369 FIX: Automatic checkpoints on some SQL Server 2000 databases do not run as expected | 2006-07-26 | +| 8.00.2168 | 2000.80.2168.0 | 907813 FIX: An error occurs when you try to access the Analysis Services performance monitor counter object after you apply Windows Server 2003 SP1 | 2006-11-21 | +| 8.00.2166 | 2000.80.2166.0 | 909734 FIX: An error message is logged, and new diagnostics do not capture the thread stack when the SQL Server User Mode Scheduler (UMS) experiences a nonyielding thread in SQL Server 2000 Service Pack 4 | 2006-07-26 | +| 8.00.2162 | 2000.80.2162.0 | 904660 A cumulative hotfix package is available for SQL Server 2000 Service Pack 4 build 2162 | 2006-09-15 | +| 8.00.2159 | 2000.80.2159.0 | 907250 FIX: You may experience concurrency issues when you run the DBCC INDEXDEFRAG statement in SQL Server 2000 | 2006-07-26 | +| 8.00.2156 | 2000.80.2156.0 | 906790 FIX: You receive an error message when you try to rebuild the master database after you have installed hotfix builds in SQL Server 2000 SP4 64-bit | 2006-07-25 | +| 8.00.2151 | 2000.80.2151.0 | 903742 FIX: You receive an "Error: 8526, Severity: 16, State: 2" error message in SQL Profiler when you use SQL Query Analyzer to start or to enlist into a distributed transaction after you have installed SQL Server 2000 SP4 | 2006-07-25 | +| 8.00.2151 | 2000.80.2151.0 | 904244 FIX: Incorrect data is inserted unexpectedly when you perform a bulk copy operation by using the DB-Library API in SQL Server 2000 Service Pack 4 | 2007-06-13 | +| 8.00.2148 | 2000.80.2148.0 | 899430 FIX: An access violation may occur when you run a SELECT query and the NO_BROWSETABLE option is set to ON in Microsoft SQL Server 2000 | 2006-07-25 | +| 8.00.2148 | 2000.80.2148.0 | 899431 FIX: An access violation occurs in the Mssdi98.dll file, and SQL Server crashes when you use SQL Query Analyzer to debug a stored procedure in SQL Server 2000 Service Pack 4 | 2006-07-25 | +| 8.00.2148 | 2000.80.2148.0 | 900390 FIX: The Mssdmn.exe process may use lots of CPU capacity when you perform a SQL Server 2000 full text search of Office Word documents | 2006-06-01 | +| 8.00.2148 | 2000.80.2148.0 | 900404 FIX: The results of the query may be returned much slower than you expect when you run a query that includes a GROUP BY statement in SQL Server 2000 | 2006-06-01 | +| 8.00.2148 | 2000.80.2148.0 | 901212 FIX: You receive an error message if you use the sp_addalias or sp_dropalias procedures when the IMPLICIT_TRANSACTIONS option is set to ON in SQL Server 2000 SP4 | 2006-07-25 | +| 8.00.2148 | 2000.80.2148.0 | 902150 FIX: Some 32-bit applications that use SQL-DMO and SQL-VDI APIs may stop working after you install SQL Server 2000 Service Pack 4 on an Itanium-based computer | 2006-06-01 | +| 8.00.2148 | 2000.80.2148.0 | 902955 FIX: You receive a "Getting registry information" message when you run the Sqldiag.exe utility after you install SQL Server 2000 SP4 | 2006-07-25 | +| 8.00.2147 | 2000.80.2147.0 | 899410 FIX: You may experience slow server performance when you start a trace in an instance of SQL Server 2000 that runs on a computer that has more than four processors | 2006-06-01 | +| 8.00.2145 | 2000.80.2145.0 | 826906 FIX: A query that uses a view that contains a correlated subquery and an aggregate runs slowly | 2005-10-25 | +| 8.00.2145 | 2000.80.2145.0 | 836651 FIX: You receive query results that were not expected when you use both ANSI joins and non-ANSI joins | 2006-06-07 | +| 8.00.2066 | 2000.80.2066.0 | Microsoft Security Bulletin MS12-060 | 2012-08-14 | +| 8.00.2065 | 2000.80.2065.0 | 983808 MS12-027: Description of the security update for Microsoft SQL Server 2000 Service Pack 4 GDR: April 10, 2012 | 2012-04-10 | +| 8.00.2055 | 2000.80.2055.0 | 959420 MS09-004: Vulnerabilities in Microsoft SQL Server could allow remote code execution | 2009-02-10 | +| 8.00.2040 | 2000.80.2040.0 | 899761 FIX: Not all memory is available when AWE is enabled on a computer that is running a 32-bit version of SQL Server 2000 SP4 | 2006-08-15 | +| 8.00.2039 | 2000.80.2039.0 | SQL Server 2000 Service Pack 4 (SP4) | 2005-05-06 | | 8.00.2026 | 2000.80.2026.0 | SQL Server 2000 Service Pack 4 (SP4) Beta | ??? | -| 8.00.1547 | 2000.80.1547.0 | [899410 FIX: You may experience slow server performance when you start a trace in an instance of SQL Server 2000 that runs on a computer that has more than four processors] | 2006-06-01 | -| 8.00.1077 | 2000.80.1077.0 | [983814 MS12-070: Description of the security update for SQL Server 2000 Reporting Services Service Pack 2] | 2012-10-09 | -| 8.00.1037 | 2000.80.1037.0 | [930484 FIX: CPU utilization may approach 100 percent on a computer that is running SQL Server 2000 after you run the BACKUP DATABASE statement or the BACKUP LOG statement] | 2007-02-02 | -| 8.00.1036 | 2000.80.1036.0 | [929410 FIX: Error message when you run a full-text query in SQL Server 2000: "Error: 17883, Severity: 1, State: 0"] | 2007-01-11 | -| 8.00.1035 | 2000.80.1035.0 | [917593 FIX: The "Audit Logout" event does not appear in the trace results file when you run a profiler trace against a linked server instance in SQL Server 2000] | 2006-09-22 | -| 8.00.1034 | 2000.80.1034.0 | [915328 FIX: You may intermittently experience an access violation error when a query is executed in a parallel plan and the execution plan contains either a HASH JOIN operation or a Sort operation in SQL Server 2000] | 2006-08-09 | -| 8.00.1029 | 2000.80.1029.0 | [902852 FIX: Error message when you run an UPDATE statement that uses two JOIN hints to update a table in SQL Server 2000: "Internal SQL Server error"] | 2006-06-01 | -| 8.00.1027 | 2000.80.1027.0 | [900416 FIX: A 17883 error may occur you run a query that uses a hash join in SQL Server 2000] | 2006-07-25 | -| 8.00.1025 | 2000.80.1025.0 | [899428 FIX: You receive incorrect results when you run a query that uses a cross join operator in SQL Server 2000 SP3] | 2006-06-01 | -| 8.00.1025 | 2000.80.1025.0 | [899430 FIX: An access violation may occur when you run a SELECT query and the NO_BROWSETABLE option is set to ON in Microsoft SQL Server 2000] | 2006-07-25 | -| 8.00.1024 | 2000.80.1024.0 | [898709 FIX: Error message when you use SQL Server 2000: "Time out occurred while waiting for buffer latch type 3"] | 2006-07-25 | -| 8.00.1021 | 2000.80.1021.0 | [887700 FIX: Server Network Utility may display incorrect protocol properties in SQL Server 2000] | 2006-07-25 | -| 8.00.1020 | 2000.80.1020.0 | [896985 FIX: The Subscriber may not be able to upload changes to the Publisher when you incrementally add an article to a publication in SQL Server 2000 SP3] | 2006-07-25 | -| 8.00.1019 | 2000.80.1019.0 | [897572 FIX: You may receive a memory-related error message when you repeatedly create and destroy an out-of-process COM object within the same batch or stored procedure in SQL Server 2000] | 2006-06-01 | -| 8.00.1017 | 2000.80.1017.0 | [896425 FIX: The BULK INSERT statement silently skips insert attempts when the data value is NULL and the column is defined as NOT NULL for INT, SMALLINT, and BIGINT data types in SQL Server 2000] | 2006-06-01 | -| 8.00.1014 | 2000.80.1014.0 | [895123 FIX: You may receive error message 701, error message 802, and error message 17803 when many hashed buffers are available in SQL Server 2000] | 2006-06-01 | -| 8.00.1014 | 2000.80.1014.0 | [895187 FIX: You receive an error message when you try to delete records by running a Delete Transact-SQL statement in SQL Server 2000] | 2006-07-25 | -| 8.00.1013 | 2000.80.1013.0 | [891866 FIX: The query runs slower than you expected when you try to parse a query in SQL Server 2000] | 2006-06-01 | -| 8.00.1009 | 2000.80.1009.0 | [894257 FIX: You receive an "Incorrect syntax near ')'" error message when you run a script that was generated by SQL-DMO for an Operator object in SQL Server 2000] | 2006-06-01 | -| 8.00.1007 | 2000.80.1007.0 | [893312 FIX: You may receive a "SQL Server could not spawn process_loginread thread" error message, and a memory leak may occur when you cancel a remote query in SQL Server 2000] | 2006-06-01 | -| 8.00.1003 | 2000.80.1003.0 | [892923 FIX: Differential database backups may not contain database changes in the Page Free Space (PFS) pages in SQL Server 2000] | 2006-06-01 | -| 8.00.1001 | 2000.80.1001.0 | [892205 FIX: You may receive a 17883 error message when SQL Server 2000 performs a very large hash operation] | 2006-06-01 | -| 8.00.1000 | 2000.80.1000.0 | [891585 FIX: Database recovery does not occur, or a user database is marked as suspect in SQL Server 2000] | 2006-06-01 | -| 8.00.997 | 2000.80.997.0 | [891311 FIX: You cannot create new TCP/IP socket based connections after error messages 17882 and 10055 are written to the Microsoft SQL Server 2000 error log] | 2006-07-18 | -| 8.00.996 | 2000.80.996.0 | [891017 FIX: SQL Server 2000 may stop responding to other requests when you perform a large deallocation operation] | 2006-06-01 | -| 8.00.996 | 2000.80.996.0 | [891268 FIX: You receive a 17883 error message and SQL Server 2000 may stop responding to other requests when you perform large in-memory sort operations] | 2006-06-01 | -| 8.00.994 | 2000.80.994.0 | [890942 FIX: Some complex queries are slower after you install SQL Server 2000 Service Pack 2 or SQL Server 2000 Service Pack 3] | 2006-06-01 | -| 8.00.994 | 2000.80.994.0 | [890768 FIX: You experience non-convergence in a replication topology when you unpublish or drop columns from a dynamically filtered publication in SQL Server 2000] | 2006-06-01 | -| 8.00.994 | 2000.80.994.0 | [890767 FIX: You receive a "Server: Msg 107, Level 16, State 3, Procedure TEMP_VIEW_Merge, Line 1" error message when the sum of the length of the published column names in a merge publication exceeds 4,000 characters in SQL Server 2000] | 2006-06-01 | -| 8.00.993 | 2000.80.993.0 | [890925 FIX: The @@ERROR system function may return an incorrect value when you execute a Transact-SQL statement that uses a parallel execution plan in SQL Server 2000 32-bit or in SQL Server 2000 64-bit] | 2006-06-01 | -| 8.00.993 | 2000.80.993.0 | [888444 FIX: You receive a 17883 error in SQL Server 2000 Service Pack 3 or in SQL Server 2000 Service Pack 3a when a worker thread becomes stuck in a registry call] | 2006-06-01 | -| 8.00.993 | 2000.80.993.0 | [890742 FIX: Error message when you use a loopback linked server to run a distributed query in SQL Server 2000: "Could not perform the requested operation because the minimum query memory is not available"] | 2006-05-15 | -| 8.00.991 | 2000.80.991.0 | [889314 FIX: Non-convergence may occur in a merge replication topology if the primary connection to the publisher is disconnected] | 2006-06-01 | -| 8.00.990 | 2000.80.990.0 | [890200 FIX: SQL Server 2000 stops listening for new TCP/IP Socket connections unexpectedly after error message 17882 is written to the SQL Server 2000 error log] | 2006-06-01 | -| 8.00.988 | 2000.80.988.0 | [889166 FIX: You receive a "Msg 3628" error message when you run an inner join query in SQL Server 2000] | 2006-06-01 | -| 8.00.985 | 2000.80.985.0 | [889239 FIX: Start times in the SQL Profiler are different for the Audit:Login and Audit:Logout Events in SQL Server 2000] | 2006-06-01 | -| 8.00.980 | 2000.80.980.0 | [887974 FIX: A fetch on a dynamic cursor can cause unexpected results in SQL Server 2000 Service Pack 3] | 2006-06-01 | -| 8.00.977 | 2000.80.977.0 | [888007 You receive a "The product does not have a prerequisite update installed" error message when you try to install a SQL Server 2000 post-Service Pack 3 hotfix] | 2005-08-31 | -| 8.00.973 | 2000.80.973.0 | [884554 FIX: A SPID stops responding with a NETWORKIO (0x800) waittype in SQL Server Enterprise Manager when SQL Server tries to process a fragmented TDS network packet] | 2006-06-01 | -| 8.00.972 | 2000.80.972.0 | [885290 FIX: An assertion error occurs when you insert data in the same row in a table by using multiple connections to an instance of SQL Server] | 2006-06-01 | -| 8.00.970 | 2000.80.970.0 | [872842 FIX: A CHECKDB statement reports a 2537 corruption error after SQL Server transfers data to a sql_variant column in SQL Server 2000] | 2006-06-01 | -| 8.00.967 | 2000.80.967.0 | [878501 FIX: You may receive an error message when you run a SET IDENTITY_INSERT ON statement on a table and then try to insert a row into the table in SQL Server 2000] | 2006-06-01 | -| 8.00.962 | 2000.80.962.0 | [883415 FIX: A user-defined function returns results that are not correct for a query] | 2006-06-01 | -| 8.00.961 | 2000.80.961.0 | [873446 FIX: An access violation exception may occur when multiple users try to perform data modification operations at the same time that fire triggers that reference a deleted or an inserted table in SQL Server 2000 on a computer that is running SMP] | 2006-06-01 | -| 8.00.959 | 2000.80.959.0 | [878500 FIX: An Audit Object Permission event is not produced when you run a TRUNCATE TABLE statement] | 2006-06-01 | -| 8.00.957 | 2000.80.957.0 | [870994 FIX: An access violation exception may occur when you run a query that uses index names in the WITH INDEX option to specify an index hint] | 2006-06-01 | -| 8.00.955 | 2000.80.955.0 | [867798 FIX: The @date_received parameter of the xp_readmail extended stored procedure incorrectly returns the date and the time that an e-mail message is submitted by the sender in SQL Server 2000] | 2007-01-08 | -| 8.00.954 | 2000.80.954.0 | [843282 FIX: The Osql.exe utility does not run a Transact-SQL script completely if you start the program from a remote session by using a background service and then log off the console session] | 2007-01-05 | -| 8.00.952 | 2000.80.952.0 | [867878 FIX: The Log Reader Agent may cause 17883 error messages] | 2006-06-01 | -| 8.00.952 | 2000.80.952.0 | [867879 FIX: Merge replication non-convergence occurs with SQL Server CE subscribers] | 2006-06-01 | -| 8.00.952 | 2000.80.952.0 | [867880 FIX: Merge Agent may fail with an "Invalid character value for cast specification" error message] | 2006-06-01 | -| 8.00.949 | 2000.80.949.0 | [843266 FIX: Shared page locks can be held until end of the transaction and can cause blocking or performance problems in SQL Server 2000 Service Pack 3 (SP3)] | 2006-06-02 | -| 8.00.948 | 2000.80.948.0 | [843263 FIX: You may receive an 8623 error message when you try to run a complex query on an instance of SQL Server] | 2006-06-01 | -| 8.00.944 | 2000.80.944.0 | [839280 FIX: SQL debugging does not work in Visual Studio .NET after you install Windows XP Service Pack 2] | 2006-06-05 | -| 8.00.937 | 2000.80.937.0 | [841776 FIX: Additional diagnostics have been added to SQL Server 2000 to detect unreported read operation failures] | 2006-06-01 | -| 8.00.936 | 2000.80.936.0 | [841627 FIX: SQL Server 2000 may underestimate the cardinality of a query expression under certain circumstances] | 2006-06-01 | -| 8.00.935 | 2000.80.935.0 | [841401 FIX: You may notice incorrect values for the "Active Transactions" counter when you perform multiple transactions on an instance of SQL Server 2000 that is running on an SMP computer] | 2006-06-01 | -| 8.00.934 | 2000.80.934.0 | [841404 FIX: You may receive a "The query processor could not produce a query plan" error message in SQL Server when you run a query that includes multiple subqueries that use self-joins] | 2006-06-01 | -| 8.00.933 | 2000.80.933.0 | [840856 FIX: The MSSQLServer service exits unexpectedly in SQL Server 2000 Service Pack 3] | 2006-06-02 | -| 8.00.929 | 2000.80.929.0 | [839529 FIX: 8621 error conditions may cause SQL Server 2000 64-bit to close unexpectedly] | 2006-06-01 | -| 8.00.928 | 2000.80.928.0 | [839589 FIX: The thread priority is raised for some threads in a parallel query] | 2006-06-01 | -| 8.00.927 | 2000.80.927.0 | [839688 FIX: Profiler RPC events truncate parameters that have a text data type to 16 characters] | 2006-06-01 | -| 8.00.926 | 2000.80.926.0 | [839523 FIX: An access violation exception may occur when you update a text column by using a stored procedure in SQL Server 2000] | 2006-06-01 | -| 8.00.923 | 2000.80.923.0 | [838460 FIX: The xp_logininfo procedure may fail with error 8198 after you install Q825042 or any hotfix with SQL Server 8.00.0840 or later] | 2006-06-01 | -| 8.00.922 | 2000.80.922.0 | [837970 FIX: You may receive an "Invalid object name..." error message when you run the DBCC CHECKCONSTRAINTS Transact-SQL statement on a table in SQL Server 2000] | 2005-10-25 | -| 8.00.919 | 2000.80.919.0 | [837957 FIX: When you use Transact-SQL cursor variables to perform operations that have large iterations, memory leaks may occur in SQL Server 2000] | 2005-10-25 | -| 8.00.916 | 2000.80.916.0 | [317989 FIX: Sqlakw32.dll May Corrupt SQL Statements] | 2005-09-27 | -| 8.00.915 | 2000.80.915.0 | [837401 FIX: Rows are not successfully inserted into a table when you use the BULK INSERT command to insert rows] | 2005-10-25 | -| 8.00.913 | 2000.80.913.0 | [836651 FIX: You receive query results that were not expected when you use both ANSI joins and non-ANSI joins] | 2006-06-07 | -| 8.00.911 | 2000.80.911.0 | [837957 FIX: When you use Transact-SQL cursor variables to perform operations that have large iterations, memory leaks may occur in SQL Server 2000] | 2005-10-25 | -| 8.00.910 | 2000.80.910.0 | [834798 FIX: SQL Server 2000 may not start if many users try to log in to SQL Server when SQL Server is trying to start] | 2005-10-25 | -| 8.00.908 | 2000.80.908.0 | [834290 FIX: You receive a 644 error message when you run an UPDATE statement and the isolation level is set to READ UNCOMMITTED] | 2005-10-25 | -| 8.00.904 | 2000.80.904.0 | [834453 FIX: The Snapshot Agent may fail after you make schema changes to the underlying tables of a publication] | 2005-04-22 | -| 8.00.892 | 2000.80.892.0 | [833710 FIX: You receive an error message when you try to restore a database backup that spans multiple devices] | 2005-10-25 | -| 8.00.891 | 2000.80.891.0 | [836141 FIX: An access violation exception may occur when SQL Server runs many parallel query processing operations on a multiprocessor computer] | 2005-04-01 | -| 8.00.879 | 2000.80.879.0 | [832977 FIX: The DBCC PSS Command may cause access violations and 17805 errors in SQL Server 2000] | 2005-10-25 | -| 8.00.878 | 2000.80.878.0 | [831950 FIX: You receive error message 3456 when you try to apply a transaction log to a server] | 2005-10-25 | -| 8.00.876 | 2000.80.876.0 | [830912 FIX: Key Names Read from an .Ini File for a Dynamic Properties Task May Be Truncated] | 2005-10-25 | -| 8.00.876 | 2000.80.876.0 | [831997 FIX: An invalid cursor state occurs after you apply Hotfix 8.00.0859 or later in SQL Server 2000] | 2005-10-25 | -| 8.00.876 | 2000.80.876.0 | [831999 FIX: An AWE system uses more memory for sorting or for hashing than a non-AWE system in SQL Server 2000] | 2005-10-25 | -| 8.00.873 | 2000.80.873.0 | [830887 FIX: Some queries that have a left outer join and an IS NULL filter run slower after you install SQL Server 2000 post-SP3 hotfix] | 2005-10-25 | -| 8.00.871 | 2000.80.871.0 | [830767 FIX: SQL Query Analyzer may stop responding when you close a query window or open a file] | 2005-10-25 | -| 8.00.871 | 2000.80.871.0 | [830860 FIX: The performance of a computer that is running SQL Server 2000 degrades when query execution plans against temporary tables remain in the procedure cache] | 2005-10-25 | -| 8.00.870 | 2000.80.870.0 | [830262 FIX: Unconditional Update May Not Hold Key Locks on New Key Values] | 2005-10-25 | -| 8.00.869 | 2000.80.869.0 | [830588 FIX: Access violation when you trace keyset-driven cursors by using SQL Profiler] | 2005-10-25 | +| 8.00.1547 | 2000.80.1547.0 | 899410 FIX: You may experience slow server performance when you start a trace in an instance of SQL Server 2000 that runs on a computer that has more than four processors | 2006-06-01 | +| 8.00.1077 | 2000.80.1077.0 | 983814 MS12-070: Description of the security update for SQL Server 2000 Reporting Services Service Pack 2 | 2012-10-09 | +| 8.00.1037 | 2000.80.1037.0 | 930484 FIX: CPU utilization may approach 100 percent on a computer that is running SQL Server 2000 after you run the BACKUP DATABASE statement or the BACKUP LOG statement | 2007-02-02 | +| 8.00.1036 | 2000.80.1036.0 | 929410 FIX: Error message when you run a full-text query in SQL Server 2000: "Error: 17883, Severity: 1, State: 0" | 2007-01-11 | +| 8.00.1035 | 2000.80.1035.0 | 917593 FIX: The "Audit Logout" event does not appear in the trace results file when you run a profiler trace against a linked server instance in SQL Server 2000 | 2006-09-22 | +| 8.00.1034 | 2000.80.1034.0 | 915328 FIX: You may intermittently experience an access violation error when a query is executed in a parallel plan and the execution plan contains either a HASH JOIN operation or a Sort operation in SQL Server 2000 | 2006-08-09 | +| 8.00.1029 | 2000.80.1029.0 | 902852 FIX: Error message when you run an UPDATE statement that uses two JOIN hints to update a table in SQL Server 2000: "Internal SQL Server error" | 2006-06-01 | +| 8.00.1027 | 2000.80.1027.0 | 900416 FIX: A 17883 error may occur you run a query that uses a hash join in SQL Server 2000 | 2006-07-25 | +| 8.00.1025 | 2000.80.1025.0 | 899428 FIX: You receive incorrect results when you run a query that uses a cross join operator in SQL Server 2000 SP3 | 2006-06-01 | +| 8.00.1025 | 2000.80.1025.0 | 899430 FIX: An access violation may occur when you run a SELECT query and the NO_BROWSETABLE option is set to ON in Microsoft SQL Server 2000 | 2006-07-25 | +| 8.00.1024 | 2000.80.1024.0 | 898709 FIX: Error message when you use SQL Server 2000: "Time out occurred while waiting for buffer latch type 3" | 2006-07-25 | +| 8.00.1021 | 2000.80.1021.0 | 887700 FIX: Server Network Utility may display incorrect protocol properties in SQL Server 2000 | 2006-07-25 | +| 8.00.1020 | 2000.80.1020.0 | 896985 FIX: The Subscriber may not be able to upload changes to the Publisher when you incrementally add an article to a publication in SQL Server 2000 SP3 | 2006-07-25 | +| 8.00.1019 | 2000.80.1019.0 | 897572 FIX: You may receive a memory-related error message when you repeatedly create and destroy an out-of-process COM object within the same batch or stored procedure in SQL Server 2000 | 2006-06-01 | +| 8.00.1017 | 2000.80.1017.0 | 896425 FIX: The BULK INSERT statement silently skips insert attempts when the data value is NULL and the column is defined as NOT NULL for INT, SMALLINT, and BIGINT data types in SQL Server 2000 | 2006-06-01 | +| 8.00.1014 | 2000.80.1014.0 | 895123 FIX: You may receive error message 701, error message 802, and error message 17803 when many hashed buffers are available in SQL Server 2000 | 2006-06-01 | +| 8.00.1014 | 2000.80.1014.0 | 895187 FIX: You receive an error message when you try to delete records by running a Delete Transact-SQL statement in SQL Server 2000 | 2006-07-25 | +| 8.00.1013 | 2000.80.1013.0 | 891866 FIX: The query runs slower than you expected when you try to parse a query in SQL Server 2000 | 2006-06-01 | +| 8.00.1009 | 2000.80.1009.0 | 894257 FIX: You receive an "Incorrect syntax near ')'" error message when you run a script that was generated by SQL-DMO for an Operator object in SQL Server 2000 | 2006-06-01 | +| 8.00.1007 | 2000.80.1007.0 | 893312 FIX: You may receive a "SQL Server could not spawn process_loginread thread" error message, and a memory leak may occur when you cancel a remote query in SQL Server 2000 | 2006-06-01 | +| 8.00.1003 | 2000.80.1003.0 | 892923 FIX: Differential database backups may not contain database changes in the Page Free Space (PFS) pages in SQL Server 2000 | 2006-06-01 | +| 8.00.1001 | 2000.80.1001.0 | 892205 FIX: You may receive a 17883 error message when SQL Server 2000 performs a very large hash operation | 2006-06-01 | +| 8.00.1000 | 2000.80.1000.0 | 891585 FIX: Database recovery does not occur, or a user database is marked as suspect in SQL Server 2000 | 2006-06-01 | +| 8.00.997 | 2000.80.997.0 | 891311 FIX: You cannot create new TCP/IP socket based connections after error messages 17882 and 10055 are written to the Microsoft SQL Server 2000 error log | 2006-07-18 | +| 8.00.996 | 2000.80.996.0 | 891017 FIX: SQL Server 2000 may stop responding to other requests when you perform a large deallocation operation | 2006-06-01 | +| 8.00.996 | 2000.80.996.0 | 891268 FIX: You receive a 17883 error message and SQL Server 2000 may stop responding to other requests when you perform large in-memory sort operations | 2006-06-01 | +| 8.00.994 | 2000.80.994.0 | 890942 FIX: Some complex queries are slower after you install SQL Server 2000 Service Pack 2 or SQL Server 2000 Service Pack 3 | 2006-06-01 | +| 8.00.994 | 2000.80.994.0 | 890768 FIX: You experience non-convergence in a replication topology when you unpublish or drop columns from a dynamically filtered publication in SQL Server 2000 | 2006-06-01 | +| 8.00.994 | 2000.80.994.0 | 890767 FIX: You receive a "Server: Msg 107, Level 16, State 3, Procedure TEMP_VIEW_Merge, Line 1" error message when the sum of the length of the published column names in a merge publication exceeds 4,000 characters in SQL Server 2000 | 2006-06-01 | +| 8.00.993 | 2000.80.993.0 | 890925 FIX: The @@ERROR system function may return an incorrect value when you execute a Transact-SQL statement that uses a parallel execution plan in SQL Server 2000 32-bit or in SQL Server 2000 64-bit | 2006-06-01 | +| 8.00.993 | 2000.80.993.0 | 888444 FIX: You receive a 17883 error in SQL Server 2000 Service Pack 3 or in SQL Server 2000 Service Pack 3a when a worker thread becomes stuck in a registry call | 2006-06-01 | +| 8.00.993 | 2000.80.993.0 | 890742 FIX: Error message when you use a loopback linked server to run a distributed query in SQL Server 2000: "Could not perform the requested operation because the minimum query memory is not available" | 2006-05-15 | +| 8.00.991 | 2000.80.991.0 | 889314 FIX: Non-convergence may occur in a merge replication topology if the primary connection to the publisher is disconnected | 2006-06-01 | +| 8.00.990 | 2000.80.990.0 | 890200 FIX: SQL Server 2000 stops listening for new TCP/IP Socket connections unexpectedly after error message 17882 is written to the SQL Server 2000 error log | 2006-06-01 | +| 8.00.988 | 2000.80.988.0 | 889166 FIX: You receive a "Msg 3628" error message when you run an inner join query in SQL Server 2000 | 2006-06-01 | +| 8.00.985 | 2000.80.985.0 | 889239 FIX: Start times in the SQL Profiler are different for the Audit:Login and Audit:Logout Events in SQL Server 2000 | 2006-06-01 | +| 8.00.980 | 2000.80.980.0 | 887974 FIX: A fetch on a dynamic cursor can cause unexpected results in SQL Server 2000 Service Pack 3 | 2006-06-01 | +| 8.00.977 | 2000.80.977.0 | 888007 You receive a "The product does not have a prerequisite update installed" error message when you try to install a SQL Server 2000 post-Service Pack 3 hotfix | 2005-08-31 | +| 8.00.973 | 2000.80.973.0 | 884554 FIX: A SPID stops responding with a NETWORKIO (0x800) waittype in SQL Server Enterprise Manager when SQL Server tries to process a fragmented TDS network packet | 2006-06-01 | +| 8.00.972 | 2000.80.972.0 | 885290 FIX: An assertion error occurs when you insert data in the same row in a table by using multiple connections to an instance of SQL Server | 2006-06-01 | +| 8.00.970 | 2000.80.970.0 | 872842 FIX: A CHECKDB statement reports a 2537 corruption error after SQL Server transfers data to a sql_variant column in SQL Server 2000 | 2006-06-01 | +| 8.00.967 | 2000.80.967.0 | 878501 FIX: You may receive an error message when you run a SET IDENTITY_INSERT ON statement on a table and then try to insert a row into the table in SQL Server 2000 | 2006-06-01 | +| 8.00.962 | 2000.80.962.0 | 883415 FIX: A user-defined function returns results that are not correct for a query | 2006-06-01 | +| 8.00.961 | 2000.80.961.0 | 873446 FIX: An access violation exception may occur when multiple users try to perform data modification operations at the same time that fire triggers that reference a deleted or an inserted table in SQL Server 2000 on a computer that is running SMP | 2006-06-01 | +| 8.00.959 | 2000.80.959.0 | 878500 FIX: An Audit Object Permission event is not produced when you run a TRUNCATE TABLE statement | 2006-06-01 | +| 8.00.957 | 2000.80.957.0 | 870994 FIX: An access violation exception may occur when you run a query that uses index names in the WITH INDEX option to specify an index hint | 2006-06-01 | +| 8.00.955 | 2000.80.955.0 | 867798 FIX: The @date_received parameter of the xp_readmail extended stored procedure incorrectly returns the date and the time that an e-mail message is submitted by the sender in SQL Server 2000 | 2007-01-08 | +| 8.00.954 | 2000.80.954.0 | 843282 FIX: The Osql.exe utility does not run a Transact-SQL script completely if you start the program from a remote session by using a background service and then log off the console session | 2007-01-05 | +| 8.00.952 | 2000.80.952.0 | 867878 FIX: The Log Reader Agent may cause 17883 error messages | 2006-06-01 | +| 8.00.952 | 2000.80.952.0 | 867879 FIX: Merge replication non-convergence occurs with SQL Server CE subscribers | 2006-06-01 | +| 8.00.952 | 2000.80.952.0 | 867880 FIX: Merge Agent may fail with an "Invalid character value for cast specification" error message | 2006-06-01 | +| 8.00.949 | 2000.80.949.0 | 843266 FIX: Shared page locks can be held until end of the transaction and can cause blocking or performance problems in SQL Server 2000 Service Pack 3 (SP3) | 2006-06-02 | +| 8.00.948 | 2000.80.948.0 | 843263 FIX: You may receive an 8623 error message when you try to run a complex query on an instance of SQL Server | 2006-06-01 | +| 8.00.944 | 2000.80.944.0 | 839280 FIX: SQL debugging does not work in Visual Studio .NET after you install Windows XP Service Pack 2 | 2006-06-05 | +| 8.00.937 | 2000.80.937.0 | 841776 FIX: Additional diagnostics have been added to SQL Server 2000 to detect unreported read operation failures | 2006-06-01 | +| 8.00.936 | 2000.80.936.0 | 841627 FIX: SQL Server 2000 may underestimate the cardinality of a query expression under certain circumstances | 2006-06-01 | +| 8.00.935 | 2000.80.935.0 | 841401 FIX: You may notice incorrect values for the "Active Transactions" counter when you perform multiple transactions on an instance of SQL Server 2000 that is running on an SMP computer | 2006-06-01 | +| 8.00.934 | 2000.80.934.0 | 841404 FIX: You may receive a "The query processor could not produce a query plan" error message in SQL Server when you run a query that includes multiple subqueries that use self-joins | 2006-06-01 | +| 8.00.933 | 2000.80.933.0 | 840856 FIX: The MSSQLServer service exits unexpectedly in SQL Server 2000 Service Pack 3 | 2006-06-02 | +| 8.00.929 | 2000.80.929.0 | 839529 FIX: 8621 error conditions may cause SQL Server 2000 64-bit to close unexpectedly | 2006-06-01 | +| 8.00.928 | 2000.80.928.0 | 839589 FIX: The thread priority is raised for some threads in a parallel query | 2006-06-01 | +| 8.00.927 | 2000.80.927.0 | 839688 FIX: Profiler RPC events truncate parameters that have a text data type to 16 characters | 2006-06-01 | +| 8.00.926 | 2000.80.926.0 | 839523 FIX: An access violation exception may occur when you update a text column by using a stored procedure in SQL Server 2000 | 2006-06-01 | +| 8.00.923 | 2000.80.923.0 | 838460 FIX: The xp_logininfo procedure may fail with error 8198 after you install Q825042 or any hotfix with SQL Server 8.00.0840 or later | 2006-06-01 | +| 8.00.922 | 2000.80.922.0 | 837970 FIX: You may receive an "Invalid object name..." error message when you run the DBCC CHECKCONSTRAINTS Transact-SQL statement on a table in SQL Server 2000 | 2005-10-25 | +| 8.00.919 | 2000.80.919.0 | 837957 FIX: When you use Transact-SQL cursor variables to perform operations that have large iterations, memory leaks may occur in SQL Server 2000 | 2005-10-25 | +| 8.00.916 | 2000.80.916.0 | 317989 FIX: Sqlakw32.dll May Corrupt SQL Statements | 2005-09-27 | +| 8.00.915 | 2000.80.915.0 | 837401 FIX: Rows are not successfully inserted into a table when you use the BULK INSERT command to insert rows | 2005-10-25 | +| 8.00.913 | 2000.80.913.0 | 836651 FIX: You receive query results that were not expected when you use both ANSI joins and non-ANSI joins | 2006-06-07 | +| 8.00.911 | 2000.80.911.0 | 837957 FIX: When you use Transact-SQL cursor variables to perform operations that have large iterations, memory leaks may occur in SQL Server 2000 | 2005-10-25 | +| 8.00.910 | 2000.80.910.0 | 834798 FIX: SQL Server 2000 may not start if many users try to log in to SQL Server when SQL Server is trying to start | 2005-10-25 | +| 8.00.908 | 2000.80.908.0 | 834290 FIX: You receive a 644 error message when you run an UPDATE statement and the isolation level is set to READ UNCOMMITTED | 2005-10-25 | +| 8.00.904 | 2000.80.904.0 | 834453 FIX: The Snapshot Agent may fail after you make schema changes to the underlying tables of a publication | 2005-04-22 | +| 8.00.892 | 2000.80.892.0 | 833710 FIX: You receive an error message when you try to restore a database backup that spans multiple devices | 2005-10-25 | +| 8.00.891 | 2000.80.891.0 | 836141 FIX: An access violation exception may occur when SQL Server runs many parallel query processing operations on a multiprocessor computer | 2005-04-01 | +| 8.00.879 | 2000.80.879.0 | 832977 FIX: The DBCC PSS Command may cause access violations and 17805 errors in SQL Server 2000 | 2005-10-25 | +| 8.00.878 | 2000.80.878.0 | 831950 FIX: You receive error message 3456 when you try to apply a transaction log to a server | 2005-10-25 | +| 8.00.876 | 2000.80.876.0 | 830912 FIX: Key Names Read from an .Ini File for a Dynamic Properties Task May Be Truncated | 2005-10-25 | +| 8.00.876 | 2000.80.876.0 | 831997 FIX: An invalid cursor state occurs after you apply Hotfix 8.00.0859 or later in SQL Server 2000 | 2005-10-25 | +| 8.00.876 | 2000.80.876.0 | 831999 FIX: An AWE system uses more memory for sorting or for hashing than a non-AWE system in SQL Server 2000 | 2005-10-25 | +| 8.00.873 | 2000.80.873.0 | 830887 FIX: Some queries that have a left outer join and an IS NULL filter run slower after you install SQL Server 2000 post-SP3 hotfix | 2005-10-25 | +| 8.00.871 | 2000.80.871.0 | 830767 FIX: SQL Query Analyzer may stop responding when you close a query window or open a file | 2005-10-25 | +| 8.00.871 | 2000.80.871.0 | 830860 FIX: The performance of a computer that is running SQL Server 2000 degrades when query execution plans against temporary tables remain in the procedure cache | 2005-10-25 | +| 8.00.870 | 2000.80.870.0 | 830262 FIX: Unconditional Update May Not Hold Key Locks on New Key Values | 2005-10-25 | +| 8.00.869 | 2000.80.869.0 | 830588 FIX: Access violation when you trace keyset-driven cursors by using SQL Profiler | 2005-10-25 | | 8.00.866 | 2000.80.866.0 | 830366 FIX: An access violation occurs in SQL Server 2000 when a high volume of local shared memory connections occur after you install security update MS03-031 | 2006-01-16 | | 8.00.865 | 2000.80.865.0 | 830395 FIX: An access violation occurs during compilation if the table contains statistics for a computed column | 2005-10-25 | | 8.00.865 | 2000.80.865.0 | 828945 FIX: You cannot insert explicit values in an IDENTITY column of a SQL Server table by using the SQLBulkOperations function or the SQLSetPos ODBC function in SQL Server 2000 | 2005-10-25 | @@ -2032,233 +2314,9 @@ Microsoft SQL Server 2014 (SP2-CU9) (KB4055557) - 12.0.5563.0 (X64) | 8.00.078 | 2000.80.078.0 | SQL Server 2000 EAP5 | ??? | | 8.00.047 | 2000.80.047.0 | SQL Server 2000 EAP4 | ??? | -[983811 MS12-060: Description of the security update for SQL Server 2000 Service Pack 4 QFE: August 14, 2012]:http://support.microsoft.com/kb/983811/ -[983809 MS12-027: Description of the security update for Microsoft SQL Server 2000 Service Pack 4 QFE: April 10, 2012]:http://support.microsoft.com/kb/983809/ -[971524 FIX: An access violation occurs when you run a DELETE statement or an UPDATE statement in the Itanium-based versions of SQL Server 2000 after you install security update MS09-004]:http://support.microsoft.com/kb/971524/ -[960083 MS09-004: Description of the security update for SQL Server 2000 QFE and for MSDE 2000: February 10, 2009]:http://support.microsoft.com/kb/960083/ -[959678 FIX: When you run the SPSBackup.exe utility to back up a SQL Server 2000 database that is configured as a back-end database for a Windows SharePoint Services server, the backup operation fails]:http://support.microsoft.com/kb/959678/ -[948111 MS08-040: Description of the security update for SQL Server 2000 QFE and MSDE 2000 July 8, 2008]:http://support.microsoft.com/kb/948111/ -[946584 FIX: The SPACE function always returns one space in SQL Server 2000 if the SPACE function uses a collation that differs from the collation of the current database]:http://support.microsoft.com/kb/946584/ -[944985 FIX: The data on the publisher does not match the data on the subscriber when you synchronize a SQL Server 2005 Mobile Edition subscriber with a SQL Server 2000 "merge replication" publisher]:http://support.microsoft.com/kb/944985/ -[939317 FIX: The CPU utilization may suddenly increase to 100 percent when there are many connections to an instance of SQL Server 2000 on a computer that has multiple processors]:http://support.microsoft.com/kb/939317/ -[936232 FIX: An access violation may occur when you try to log in to an instance of SQL Server 2000]:http://support.microsoft.com/kb/936232/ -[935950 FIX: The foreign key that you created between two tables does not work after you run the CREATE INDEX statement in SQL Server 2000]:http://support.microsoft.com/kb/935950/ -[935465 An updated version of Sqlvdi.dll is now available for SQL Server 2000]:http://support.microsoft.com/kb/935465/ -[933573 FIX: You may receive an assertion or database corruption may occur when you use the bcp utility or the "Bulk Insert" Transact-SQL command to import data in SQL Server 2000]:http://support.microsoft.com/kb/933573/ -[934203 FIX: A hotfix for Microsoft SQL Server 2000 Service Pack 4 may not update all the necessary files on an x64-based computer]:http://support.microsoft.com/kb/934203/ -[929131 FIX: In SQL Server 2000, the synchronization process is slow, and the CPU usage is high on the computer that is configured as the Distributor]:http://support.microsoft.com/kb/929131/ -[931932 FIX: The merge agent fails intermittently when you use merge replication that uses a custom resolver after you install SQL Server 2000 Service Pack 4]:http://support.microsoft.com/kb/931932/ -[930484 FIX: CPU utilization may approach 100 percent on a computer that is running SQL Server 2000 after you run the BACKUP DATABASE statement or the BACKUP LOG statement]:http://support.microsoft.com/kb/930484/ -[929440 FIX: Error messages when you try to update table rows or insert table rows into a table in SQL Server 2000: "644" or "2511"]:http://support.microsoft.com/kb/929440/ -[928568 FIX: SQL Server 2000 stops responding when you cancel a query or when a query time-out occurs, and error messages are logged in the SQL Server error log file]:http://support.microsoft.com/kb/928568/ -[928079 FIX: The Sqldumper.exe utility cannot generate a filtered SQL Server dump file when you use the Remote Desktop Connection service or Terminal Services to connect to a Windows 2000 Server-based computer in SQL Server 2000]:http://support.microsoft.com/kb/928079/ -[927186 FIX: Error message when you create a merge replication for tables that have computed columns in SQL Server 2000 Service Pack 4: "The process could not log conflict information"]:http://support.microsoft.com/kb/927186/ -[925684 FIX: You may experience one or more symptoms when you run a "CREATE INDEX" statement on an instance of SQL Server 2000]:http://support.microsoft.com/kb/925684/ -[925732 FIX: You may receive inconsistent comparison results when you compare strings by using a width sensitive collation in SQL Server 2000]:http://support.microsoft.com/kb/925732/ -[925419 FIX: The server stops responding, the performance is slow, and a time-out occurs in SQL Server 2000]:http://support.microsoft.com/kb/925419/ -[925678 FIX: Error message when you schedule a Replication Merge Agent job to run after you install SQL Server 2000 Service Pack 4: "The process could not enumerate changes at the 'Subscriber'"]:http://support.microsoft.com/kb/925678/ -[925297 FIX: The result may be sorted in the wrong order when you run a query that uses the ORDER BY clause to sort a column in a table in SQL Server 2000]:http://support.microsoft.com/kb/925297/ -[924664 FIX: You cannot stop the SQL Server service, or many minidump files and many log files are generated in SQL Server 2000]:http://support.microsoft.com/kb/924664/ -[923796 FIX: Data in a subscriber of a merge publication in SQL Server 2000 differs from the data in the publisher]:http://support.microsoft.com/kb/923796/ -[924662 FIX: The query performance may be slow when you query data from a view in SQL Server 2000]:http://support.microsoft.com/kb/924662/ -[923563 FIX: Error message when you configure an immediate updating transactional replication in SQL Server 2000: "Implicit conversion from datatype 'text' to 'nvarchar' is not allowed"]:http://support.microsoft.com/kb/923563/ -[923327 FIX: You may receive an access violation error message when you import data by using the "Bulk Insert" command in SQL Server 2000]:http://support.microsoft.com/kb/923327/ -[923797 The Knowledge Base (KB) Article You Requested Is Currently Not Available]:http://support.microsoft.com/kb/923797/ -[923344 FIX: A SQL Server 2000 session may be blocked for the whole time that a Snapshot Agent job runs]:http://support.microsoft.com/kb/923344/ -[920930 FIX: Error message when you try to run a query on a linked server in SQL Server 2000]:http://support.microsoft.com/kb/920930/ -[919221 FIX: SQL Server 2000 may take a long time to complete the synchronization phase when you create a merge publication]:http://support.microsoft.com/kb/919221/ -[919133 FIX: Each query takes a long time to compile when you execute a single query or when you execute multiple concurrent queries in SQL Server 2000]:http://support.microsoft.com/kb/919133/ -[919068 FIX: The query may return incorrect results, and the execution plan for the query may contain a "Table Spool" operator in SQL Server 2000]:http://support.microsoft.com/kb/919068/ -[919399 FIX: A profiler trace in SQL Server 2000 may stop logging events unexpectedly, and you may receive the following error message: "Failed to read trace data"]:http://support.microsoft.com/kb/919399/ -[919165 FIX: A memory leak occurs when you run a remote query by using a linked server in SQL Server 2000]:http://support.microsoft.com/kb/919165/ -[917565 FIX: Error 17883 is logged in the SQL Server error log, and the instance of SQL Server 2000 temporarily stops responding]:http://support.microsoft.com/kb/917565/ -[917972 FIX: You receive an access violation error message when you try to perform a read of a large binary large object column in SQL Server 2000]:http://support.microsoft.com/kb/917972/ -[917606 FIX: You may notice a decrease in performance when you run a query that uses the UNION ALL operator in SQL Server 2000 Service Pack 4]:http://support.microsoft.com/kb/917606/ -[916698 FIX: Error message when you run SQL Server 2000: "Failed assertion = 'lockFound == TRUE'"]:http://support.microsoft.com/kb/916698/ -[916950 FIX: You may experience heap corruption, and SQL Server 2000 may shut down with fatal access violations when you try to browse files in SQL Server 2000 Enterprise Manager on a Windows Server 2003 x64-based computer]:http://support.microsoft.com/kb/916950/ -[916652 FIX: An access violation may occur when you run a query on a table that has a multicolumn index in SQL Server 2000]:http://support.microsoft.com/kb/916652/ -[913438 FIX: The SQL Server process may end unexpectedly when you turn on trace flag -T1204 and a profiler trace is capturing the Lock:DeadLock Chain event in SQL Server 2000 SP4]:http://support.microsoft.com/kb/913438/ -[915340 FIX: A deadlock occurs when the scheduled SQL Server Agent job that you add or that you update is running in SQL Server 2000]:http://support.microsoft.com/kb/915340/ -[916287 A cumulative hotfix package is available for SQL Server 2000 Service Pack 4 build 2187]:http://support.microsoft.com/kb/916287/ -[914384 FIX: The database status changes to Suspect when you perform a bulk copy in a transaction and then roll back the transaction in SQL Server 2000]:http://support.microsoft.com/kb/914384/ -[915065 FIX: Error message when you try to apply a hotfix on a SQL Server 2000-based computer that is configured as a MSCS node: "An error in updating your system has occurred"]:http://support.microsoft.com/kb/915065/ -[913789 FIX: The password that you specify in a BACKUP statement appears in the SQL Server Errorlog file or in the Application event log if the BACKUP statement does not run in SQL Server 2000]:http://support.microsoft.com/kb/913789/ -[913684 FIX: You may receive error messages when you use linked servers in SQL Server 2000 on a 64-bit Itanium processor]:http://support.microsoft.com/kb/913684/ -[911678 FIX: No rows may be returned, and you may receive an error message when you try to import SQL Profiler trace files into tables by using the fn_trace_gettable function in SQL Server 2000]:http://support.microsoft.com/kb/911678/ -[910707 FIX: When you query a view that was created by using the VIEW_METADATA option, an access violation may occur in SQL Server 2000]:http://support.microsoft.com/kb/910707/ -[909369 FIX: Automatic checkpoints on some SQL Server 2000 databases do not run as expected]:http://support.microsoft.com/kb/909369/ -[907813 FIX: An error occurs when you try to access the Analysis Services performance monitor counter object after you apply Windows Server 2003 SP1]:http://support.microsoft.com/kb/907813/ -[909734 FIX: An error message is logged, and new diagnostics do not capture the thread stack when the SQL Server User Mode Scheduler (UMS) experiences a nonyielding thread in SQL Server 2000 Service Pack 4]:http://support.microsoft.com/kb/909734/ -[904660 A cumulative hotfix package is available for SQL Server 2000 Service Pack 4 build 2162]:http://support.microsoft.com/kb/904660/ -[907250 FIX: You may experience concurrency issues when you run the DBCC INDEXDEFRAG statement in SQL Server 2000]:http://support.microsoft.com/kb/907250/ -[906790 FIX: You receive an error message when you try to rebuild the master database after you have installed hotfix builds in SQL Server 2000 SP4 64-bit]:http://support.microsoft.com/kb/906790/ -[903742 FIX: You receive an "Error: 8526, Severity: 16, State: 2" error message in SQL Profiler when you use SQL Query Analyzer to start or to enlist into a distributed transaction after you have installed SQL Server 2000 SP4]:http://support.microsoft.com/kb/903742/ -[904244 FIX: Incorrect data is inserted unexpectedly when you perform a bulk copy operation by using the DB-Library API in SQL Server 2000 Service Pack 4]:http://support.microsoft.com/kb/904244/ -[899430 FIX: An access violation may occur when you run a SELECT query and the NO_BROWSETABLE option is set to ON in Microsoft SQL Server 2000]:http://support.microsoft.com/kb/899430/ -[899431 FIX: An access violation occurs in the Mssdi98.dll file, and SQL Server crashes when you use SQL Query Analyzer to debug a stored procedure in SQL Server 2000 Service Pack 4]:http://support.microsoft.com/kb/899431/ -[900390 FIX: The Mssdmn.exe process may use lots of CPU capacity when you perform a SQL Server 2000 full text search of Office Word documents]:http://support.microsoft.com/kb/900390/ -[900404 FIX: The results of the query may be returned much slower than you expect when you run a query that includes a GROUP BY statement in SQL Server 2000]:http://support.microsoft.com/kb/900404/ -[901212 FIX: You receive an error message if you use the sp_addalias or sp_dropalias procedures when the IMPLICIT_TRANSACTIONS option is set to ON in SQL Server 2000 SP4]:http://support.microsoft.com/kb/901212/ -[902150 FIX: Some 32-bit applications that use SQL-DMO and SQL-VDI APIs may stop working after you install SQL Server 2000 Service Pack 4 on an Itanium-based computer]:http://support.microsoft.com/kb/902150/ -[902955 FIX: You receive a "Getting registry information" message when you run the Sqldiag.exe utility after you install SQL Server 2000 SP4]:http://support.microsoft.com/kb/902955/ -[899410 FIX: You may experience slow server performance when you start a trace in an instance of SQL Server 2000 that runs on a computer that has more than four processors]:http://support.microsoft.com/kb/899410/ -[826906 FIX: A query that uses a view that contains a correlated subquery and an aggregate runs slowly]:http://support.microsoft.com/kb/826906/ -[836651 FIX: You receive query results that were not expected when you use both ANSI joins and non-ANSI joins]:http://support.microsoft.com/kb/836651/ -[Microsoft Security Bulletin MS12-060]:https://technet.microsoft.com/en-us/security/bulletin/MS12-060 -[983808 MS12-027: Description of the security update for Microsoft SQL Server 2000 Service Pack 4 GDR: April 10, 2012]:http://support.microsoft.com/kb/983808/ -[959420 MS09-004: Vulnerabilities in Microsoft SQL Server could allow remote code execution]:http://support.microsoft.com/kb/959420/ -[899761 FIX: Not all memory is available when AWE is enabled on a computer that is running a 32-bit version of SQL Server 2000 SP4]:http://support.microsoft.com/kb/899761/ -[SQL Server 2000 Service Pack 4 (SP4)]:http://www.microsoft.com/downloads/details.aspx?FamilyId=8E2DFC8D-C20E-4446-99A9-B7F0213F8BC5 -[899410 FIX: You may experience slow server performance when you start a trace in an instance of SQL Server 2000 that runs on a computer that has more than four processors]:http://support.microsoft.com/kb/899410/ -[983814 MS12-070: Description of the security update for SQL Server 2000 Reporting Services Service Pack 2]:http://support.microsoft.com/kb/983814 -[930484 FIX: CPU utilization may approach 100 percent on a computer that is running SQL Server 2000 after you run the BACKUP DATABASE statement or the BACKUP LOG statement]:http://support.microsoft.com/kb/930484/ -[929410 FIX: Error message when you run a full-text query in SQL Server 2000: "Error: 17883, Severity: 1, State: 0"]:http://support.microsoft.com/kb/929410/ -[917593 FIX: The "Audit Logout" event does not appear in the trace results file when you run a profiler trace against a linked server instance in SQL Server 2000]:http://support.microsoft.com/kb/917593/ -[915328 FIX: You may intermittently experience an access violation error when a query is executed in a parallel plan and the execution plan contains either a HASH JOIN operation or a Sort operation in SQL Server 2000]:http://support.microsoft.com/kb/915328/ -[902852 FIX: Error message when you run an UPDATE statement that uses two JOIN hints to update a table in SQL Server 2000: "Internal SQL Server error"]:http://support.microsoft.com/kb/902852/ -[900416 FIX: A 17883 error may occur you run a query that uses a hash join in SQL Server 2000]:http://support.microsoft.com/kb/900416/ -[899428 FIX: You receive incorrect results when you run a query that uses a cross join operator in SQL Server 2000 SP3]:http://support.microsoft.com/kb/899428/ -[899430 FIX: An access violation may occur when you run a SELECT query and the NO_BROWSETABLE option is set to ON in Microsoft SQL Server 2000]:http://support.microsoft.com/kb/899430/ -[898709 FIX: Error message when you use SQL Server 2000: "Time out occurred while waiting for buffer latch type 3"]:http://support.microsoft.com/kb/898709/ -[887700 FIX: Server Network Utility may display incorrect protocol properties in SQL Server 2000]:http://support.microsoft.com/kb/887700/ -[896985 FIX: The Subscriber may not be able to upload changes to the Publisher when you incrementally add an article to a publication in SQL Server 2000 SP3]:http://support.microsoft.com/kb/896985/ -[897572 FIX: You may receive a memory-related error message when you repeatedly create and destroy an out-of-process COM object within the same batch or stored procedure in SQL Server 2000]:http://support.microsoft.com/kb/897572/ -[896425 FIX: The BULK INSERT statement silently skips insert attempts when the data value is NULL and the column is defined as NOT NULL for INT, SMALLINT, and BIGINT data types in SQL Server 2000]:http://support.microsoft.com/kb/896425/ -[895123 FIX: You may receive error message 701, error message 802, and error message 17803 when many hashed buffers are available in SQL Server 2000]:http://support.microsoft.com/kb/895123/ -[895187 FIX: You receive an error message when you try to delete records by running a Delete Transact-SQL statement in SQL Server 2000]:http://support.microsoft.com/kb/895187/ -[891866 FIX: The query runs slower than you expected when you try to parse a query in SQL Server 2000]:http://support.microsoft.com/kb/891866/ -[894257 FIX: You receive an "Incorrect syntax near ')'" error message when you run a script that was generated by SQL-DMO for an Operator object in SQL Server 2000]:http://support.microsoft.com/kb/894257/ -[893312 FIX: You may receive a "SQL Server could not spawn process_loginread thread" error message, and a memory leak may occur when you cancel a remote query in SQL Server 2000]:http://support.microsoft.com/kb/893312/ -[892923 FIX: Differential database backups may not contain database changes in the Page Free Space (PFS) pages in SQL Server 2000]:http://support.microsoft.com/kb/892923/ -[892205 FIX: You may receive a 17883 error message when SQL Server 2000 performs a very large hash operation]:http://support.microsoft.com/kb/892205/ -[891585 FIX: Database recovery does not occur, or a user database is marked as suspect in SQL Server 2000]:http://support.microsoft.com/kb/891585/ -[891311 FIX: You cannot create new TCP/IP socket based connections after error messages 17882 and 10055 are written to the Microsoft SQL Server 2000 error log]:http://support.microsoft.com/kb/891311/ -[891017 FIX: SQL Server 2000 may stop responding to other requests when you perform a large deallocation operation]:http://support.microsoft.com/kb/891017/ -[891268 FIX: You receive a 17883 error message and SQL Server 2000 may stop responding to other requests when you perform large in-memory sort operations]:http://support.microsoft.com/kb/891268/ -[890942 FIX: Some complex queries are slower after you install SQL Server 2000 Service Pack 2 or SQL Server 2000 Service Pack 3]:http://support.microsoft.com/kb/890942/ -[890768 FIX: You experience non-convergence in a replication topology when you unpublish or drop columns from a dynamically filtered publication in SQL Server 2000]:http://support.microsoft.com/kb/890768/ -[890767 FIX: You receive a "Server: Msg 107, Level 16, State 3, Procedure TEMP_VIEW_Merge, Line 1" error message when the sum of the length of the published column names in a merge publication exceeds 4,000 characters in SQL Server 2000]:http://support.microsoft.com/kb/890767/ -[890925 FIX: The @@ERROR system function may return an incorrect value when you execute a Transact-SQL statement that uses a parallel execution plan in SQL Server 2000 32-bit or in SQL Server 2000 64-bit]:http://support.microsoft.com/kb/890925/ -[888444 FIX: You receive a 17883 error in SQL Server 2000 Service Pack 3 or in SQL Server 2000 Service Pack 3a when a worker thread becomes stuck in a registry call]:http://support.microsoft.com/kb/888444/ -[890742 FIX: Error message when you use a loopback linked server to run a distributed query in SQL Server 2000: "Could not perform the requested operation because the minimum query memory is not available"]:http://support.microsoft.com/kb/890742/ -[889314 FIX: Non-convergence may occur in a merge replication topology if the primary connection to the publisher is disconnected]:http://support.microsoft.com/kb/889314/ -[890200 FIX: SQL Server 2000 stops listening for new TCP/IP Socket connections unexpectedly after error message 17882 is written to the SQL Server 2000 error log]:http://support.microsoft.com/kb/890200/ -[889166 FIX: You receive a "Msg 3628" error message when you run an inner join query in SQL Server 2000]:http://support.microsoft.com/kb/889166/ -[889239 FIX: Start times in the SQL Profiler are different for the Audit:Login and Audit:Logout Events in SQL Server 2000]:http://support.microsoft.com/kb/889239/ -[887974 FIX: A fetch on a dynamic cursor can cause unexpected results in SQL Server 2000 Service Pack 3]:http://support.microsoft.com/kb/887974/ -[888007 You receive a "The product does not have a prerequisite update installed" error message when you try to install a SQL Server 2000 post-Service Pack 3 hotfix]:http://support.microsoft.com/kb/888007/ -[884554 FIX: A SPID stops responding with a NETWORKIO (0x800) waittype in SQL Server Enterprise Manager when SQL Server tries to process a fragmented TDS network packet]:http://support.microsoft.com/kb/884554/ -[885290 FIX: An assertion error occurs when you insert data in the same row in a table by using multiple connections to an instance of SQL Server]:http://support.microsoft.com/kb/885290/ -[872842 FIX: A CHECKDB statement reports a 2537 corruption error after SQL Server transfers data to a sql_variant column in SQL Server 2000]:http://support.microsoft.com/kb/872842/ -[878501 FIX: You may receive an error message when you run a SET IDENTITY_INSERT ON statement on a table and then try to insert a row into the table in SQL Server 2000]:http://support.microsoft.com/kb/878501/ -[883415 FIX: A user-defined function returns results that are not correct for a query]:http://support.microsoft.com/kb/883415/ -[873446 FIX: An access violation exception may occur when multiple users try to perform data modification operations at the same time that fire triggers that reference a deleted or an inserted table in SQL Server 2000 on a computer that is running SMP]:http://support.microsoft.com/kb/873446/ -[878500 FIX: An Audit Object Permission event is not produced when you run a TRUNCATE TABLE statement]:http://support.microsoft.com/kb/878500/ -[870994 FIX: An access violation exception may occur when you run a query that uses index names in the WITH INDEX option to specify an index hint]:http://support.microsoft.com/kb/870994/ -[867798 FIX: The @date_received parameter of the xp_readmail extended stored procedure incorrectly returns the date and the time that an e-mail message is submitted by the sender in SQL Server 2000]:http://support.microsoft.com/kb/867798/ -[843282 FIX: The Osql.exe utility does not run a Transact-SQL script completely if you start the program from a remote session by using a background service and then log off the console session]:http://support.microsoft.com/kb/843282/ -[867878 FIX: The Log Reader Agent may cause 17883 error messages]:http://support.microsoft.com/kb/867878/ -[867879 FIX: Merge replication non-convergence occurs with SQL Server CE subscribers]:http://support.microsoft.com/kb/867879/ -[867880 FIX: Merge Agent may fail with an "Invalid character value for cast specification" error message]:http://support.microsoft.com/kb/867880/ -[843266 FIX: Shared page locks can be held until end of the transaction and can cause blocking or performance problems in SQL Server 2000 Service Pack 3 (SP3)]:http://support.microsoft.com/kb/843266/ -[843263 FIX: You may receive an 8623 error message when you try to run a complex query on an instance of SQL Server]:http://support.microsoft.com/kb/843263/ -[839280 FIX: SQL debugging does not work in Visual Studio .NET after you install Windows XP Service Pack 2]:http://support.microsoft.com/kb/839280/ -[841776 FIX: Additional diagnostics have been added to SQL Server 2000 to detect unreported read operation failures]:http://support.microsoft.com/kb/841776/ -[841627 FIX: SQL Server 2000 may underestimate the cardinality of a query expression under certain circumstances]:http://support.microsoft.com/kb/841627/ -[841401 FIX: You may notice incorrect values for the "Active Transactions" counter when you perform multiple transactions on an instance of SQL Server 2000 that is running on an SMP computer]:http://support.microsoft.com/kb/841401/ -[841404 FIX: You may receive a "The query processor could not produce a query plan" error message in SQL Server when you run a query that includes multiple subqueries that use self-joins]:http://support.microsoft.com/kb/841404/ -[840856 FIX: The MSSQLServer service exits unexpectedly in SQL Server 2000 Service Pack 3]:http://support.microsoft.com/kb/840856/ -[839529 FIX: 8621 error conditions may cause SQL Server 2000 64-bit to close unexpectedly]:http://support.microsoft.com/kb/839529/ -[839589 FIX: The thread priority is raised for some threads in a parallel query]:http://support.microsoft.com/kb/839589/ -[839688 FIX: Profiler RPC events truncate parameters that have a text data type to 16 characters]:http://support.microsoft.com/kb/839688/ -[839523 FIX: An access violation exception may occur when you update a text column by using a stored procedure in SQL Server 2000]:http://support.microsoft.com/kb/839523/ -[838460 FIX: The xp_logininfo procedure may fail with error 8198 after you install Q825042 or any hotfix with SQL Server 8.00.0840 or later]:http://support.microsoft.com/kb/838460/ -[837970 FIX: You may receive an "Invalid object name..." error message when you run the DBCC CHECKCONSTRAINTS Transact-SQL statement on a table in SQL Server 2000]:http://support.microsoft.com/kb/837970/ -[837957 FIX: When you use Transact-SQL cursor variables to perform operations that have large iterations, memory leaks may occur in SQL Server 2000]:http://support.microsoft.com/kb/837957/ -[317989 FIX: Sqlakw32.dll May Corrupt SQL Statements]:http://support.microsoft.com/kb/317989/ -[837401 FIX: Rows are not successfully inserted into a table when you use the BULK INSERT command to insert rows]:http://support.microsoft.com/kb/837401/ -[836651 FIX: You receive query results that were not expected when you use both ANSI joins and non-ANSI joins]:http://support.microsoft.com/kb/836651/ -[837957 FIX: When you use Transact-SQL cursor variables to perform operations that have large iterations, memory leaks may occur in SQL Server 2000]:http://support.microsoft.com/kb/837957/ -[834798 FIX: SQL Server 2000 may not start if many users try to log in to SQL Server when SQL Server is trying to start]:http://support.microsoft.com/kb/834798/ -[834290 FIX: You receive a 644 error message when you run an UPDATE statement and the isolation level is set to READ UNCOMMITTED]:http://support.microsoft.com/kb/834290/ -[834453 FIX: The Snapshot Agent may fail after you make schema changes to the underlying tables of a publication]:http://support.microsoft.com/kb/834453/ -[833710 FIX: You receive an error message when you try to restore a database backup that spans multiple devices]:http://support.microsoft.com/kb/833710/ -[836141 FIX: An access violation exception may occur when SQL Server runs many parallel query processing operations on a multiprocessor computer]:http://support.microsoft.com/kb/836141/ -[832977 FIX: The DBCC PSS Command may cause access violations and 17805 errors in SQL Server 2000]:http://support.microsoft.com/kb/832977/ -[831950 FIX: You receive error message 3456 when you try to apply a transaction log to a server]:http://support.microsoft.com/kb/831950/ -[830912 FIX: Key Names Read from an .Ini File for a Dynamic Properties Task May Be Truncated]:http://support.microsoft.com/kb/830912/ -[831997 FIX: An invalid cursor state occurs after you apply Hotfix 8.00.0859 or later in SQL Server 2000]:http://support.microsoft.com/kb/831997/ -[831999 FIX: An AWE system uses more memory for sorting or for hashing than a non-AWE system in SQL Server 2000]:http://support.microsoft.com/kb/831999/ -[830887 FIX: Some queries that have a left outer join and an IS NULL filter run slower after you install SQL Server 2000 post-SP3 hotfix]:http://support.microsoft.com/kb/830887/ -[830767 FIX: SQL Query Analyzer may stop responding when you close a query window or open a file]:http://support.microsoft.com/kb/830767/ -[830860 FIX: The performance of a computer that is running SQL Server 2000 degrades when query execution plans against temporary tables remain in the procedure cache]:http://support.microsoft.com/kb/830860/ -[830262 FIX: Unconditional Update May Not Hold Key Locks on New Key Values]:http://support.microsoft.com/kb/830262/ -[830588 FIX: Access violation when you trace keyset-driven cursors by using SQL Profiler]:http://support.microsoft.com/kb/830588/ -[829205 FIX: Query performance may be slow and may be inconsistent when you run a query while another query that contains an IN operator with many values is compiled]:http://support.microsoft.com/kb/829205/ -[829444 FIX: A floating point exception occurs during the optimization of a query]:http://support.microsoft.com/kb/829444/ -[821334 FIX: Issues that are resolved in SQL Server 2000 build 8.00.0859]:http://support.microsoft.com/kb/821334/ -[828637 FIX: Users Can Control the Compensating Change Process in Merge Replication]:http://support.microsoft.com/kb/828637/ -[828017 The Knowledge Base (KB) Article You Requested Is Currently Not Available]:http://support.microsoft.com/kb/828017/ -[827714 FIX: A query may fail with retail assertion when you use the NOLOCK hint or the READ UNCOMMITTED isolation level]:http://support.microsoft.com/kb/827714/ -[828308 FIX: An Internet Explorer script error occurs when you access metadata information by using DTS in SQL Server Enterprise Manager]:http://support.microsoft.com/kb/828308/ -[828096 FIX: Key Locks Are Held Until the End of the Statement for Rows That Do Not Pass Filter Criteria]:http://support.microsoft.com/kb/828096/ -[828699 FIX: An Access Violation Occurs When You Run DBCC UPDATEUSAGE on a Database That Has Many Objects]:http://support.microsoft.com/kb/828699/ -[830466 FIX: You may receive an "Internal SQL Server error" error message when you run a Transact-SQL SELECT statement on a view that has many subqueries in SQL Server 2000]:http://support.microsoft.com/kb/830466/ -[827954 FIX: Slow Execution Times May Occur When You Run DML Statements Against Tables That Have Cascading Referential Integrity]:http://support.microsoft.com/kb/827954/ -[826754 FIX: A Deadlock Occurs If You Run an Explicit UPDATE STATISTICS Command]:http://support.microsoft.com/kb/826754/ -[826860 FIX: Linked Server Query May Return NULL If It Is Performed Through a Keyset Cursor]:http://support.microsoft.com/kb/826860/ -[826815 FIX: You receive an 8623 error message in SQL Server when you try to run a query that has multiple correlated subqueries]:http://support.microsoft.com/kb/826815/ -[826906 FIX: A query that uses a view that contains a correlated subquery and an aggregate runs slowly]:http://support.microsoft.com/kb/826906/ -[826822 FIX: A Member of the db_accessadmin Fixed Database Role Can Create an Alias for the dbo Special User]:http://support.microsoft.com/kb/826822/ -[826433 PRB: Additional SQL Server Diagnostics Added to Detect Unreported I/O Problems]:http://support.microsoft.com/kb/826433/ -[826364 FIX: A Query with a LIKE Comparison Results in a Non-Optimal Query Plan When You Use a Hungarian SQL Server Collation]:http://support.microsoft.com/kb/826364/ -[825854 FIX: No Exclusive Locks May Be Taken If the DisAllowsPageLocks Value Is Set to True]:http://support.microsoft.com/kb/825854/ -[826080 FIX: SQL Server 2000 protocol encryption applies to JDBC clients]:http://support.microsoft.com/kb/826080/ -[825043 FIX: Rows are unexpectedly deleted when you run a distributed query to delete or to update a linked server table]:http://support.microsoft.com/kb/825043/ -[825225 FIX: You receive an error message when you run a parallel query that uses an aggregation function or the GROUP BY clause]:http://support.microsoft.com/kb/825225/ -[319477 FIX: Extremely Large Number of User Tables on AWE System May Cause BPool::Map Errors]:http://support.microsoft.com/kb/319477/ -[319477 FIX: Extremely Large Number of User Tables on AWE System May Cause BPool::Map Errors]:http://support.microsoft.com/kb/319477/ -[823877 FIX: An Access Violation May Occur When You Run a Query That Contains 32,000 or More OR Clauses]:http://support.microsoft.com/kb/823877/ -[824027 FIX: A Cursor with a Large Object Parameter May Cause an Access Violation on CStmtCond::XretExecute]:http://support.microsoft.com/kb/824027/ -[820788 FIX: Delayed domain authentication may cause SQL Server to stop responding]:http://support.microsoft.com/kb/820788/ -[821741 FIX: Lock monitor exception in DeadlockMonitor::ResolveDeadlock]:http://support.microsoft.com/kb/821741/ -[821548 FIX: A Parallel Query May Generate an Access Violation After You Install SQL Server 2000 SP3]:http://support.microsoft.com/kb/821548/ -[821740 FIX: MS DTC Transaction Commit Operation Blocks Itself]:http://support.microsoft.com/kb/821740/ -[823514 FIX: Build 8.00.0837: A query that contains a correlated subquery runs slowly]:http://support.microsoft.com/kb/823514/ -[826161 FIX: You are prompted for password confirmation after you change a standard SQL Server login]:http://support.microsoft.com/kb/826161/ -[821277 MS03-031: Security patch for SQL Server 2000 Service Pack 3]:http://support.microsoft.com/kb/821277/ -[821337 FIX: Localized versions of SQL Mail and the Web Assistant Wizard may not work as expected in SQL Server 2000 64 bit]:http://support.microsoft.com/kb/821337/ -[818388 FIX: A Transact-SQL Statement That Is Embedded in the Database Name Runs with System Administrator Permissions]:http://support.microsoft.com/kb/818388/ -[826161 FIX: You are prompted for password confirmation after you change a standard SQL Server login]:http://support.microsoft.com/kb/826161/ -[821280 MS03-031: Security Patch for SQL Server 2000 64-bit]:http://support.microsoft.com/kb/821280/ -[818766 FIX: Intense SQL Server activity results in spinloop wait]:http://support.microsoft.com/kb/818766/ -[819662 FIX: Distribution Cleanup Agent Incorrectly Cleans Up Entries for Anonymous Subscribers]:http://support.microsoft.com/kb/819662/ -[819248 FIX: An access violation exception may occur when you insert a row in a table that is referenced by indexed views in SQL Server 2000]:http://support.microsoft.com/kb/819248/ -[819662 FIX: Distribution Cleanup Agent Incorrectly Cleans Up Entries for Anonymous Subscribers]:http://support.microsoft.com/kb/819662/ -[818897 FIX: Invalid TDS Sent to SQL Server Results in Access Violation]:http://support.microsoft.com/kb/818897/ -[818899 FIX: Error Message 3628 May Occur When You Run a Complex Query]:http://support.microsoft.com/kb/818899/ -[818729 FIX: Internal Query Processor Error 8623 When Microsoft SQL Server Tries to Compile a Plan for a Complex Query]:http://support.microsoft.com/kb/818729/ -[818540 FIX: SQL Server Enterprise Manager unexpectedly quits when you modify a DTS package]:http://support.microsoft.com/kb/818540/ -[818414 FIX: The Sqldumper.exe File Does Not Generate a Userdump File When It Runs Against a Windows Service]:http://support.microsoft.com/kb/818414/ -[818097 FIX: An Access Violation May Occur When You Run DBCC DBREINDEX on a Table That Has Hypothetical Indexes]:http://support.microsoft.com/kb/818097/ -[818188 FIX: Query on the sysmembers Virtual Table May Fail with a Stack Overflow]:http://support.microsoft.com/kb/818188/ -[817464 FIX: Using Sp_executesql in Merge Agent Operations]:http://support.microsoft.com/kb/817464/ -[817464 FIX: Using Sp_executesql in Merge Agent Operations]:http://support.microsoft.com/kb/817464/ -[813524 FIX: OLE DB conversion errors may occur after you select a literal string that represents datetime data as a column]:http://support.microsoft.com/kb/813524/ -[816440 FIX: Error 8623 is Raised When SQL Server Compiles a Complex Query]:http://support.microsoft.com/kb/816440/ -[817709 FIX: SQL Server 2000 might produce an incorrect cardinality estimate for outer joins]:http://support.microsoft.com/kb/817709/ -[815249 FIX: Performance of a query that is run from a client program on a SQL Server SP3 database is slow after you restart the instance of SQL Server]:http://support.microsoft.com/kb/815249/ -[817081 FIX: You receive an error message when you use the SQL-DMO BulkCopy object to import data into a SQL Server table]:http://support.microsoft.com/kb/817081/ -[816840 FIX: Error 17883 May Display Message Text That Is Not Correct]:http://support.microsoft.com/kb/816840/ -[816985 FIX: You cannot install SQL Server 2000 SP3 on the Korean version of SQL Server 2000]:http://support.microsoft.com/kb/816985/ -[815057 FIX: SQL Server 2000 Uninstall Option Does Not Remove All Files]:http://support.microsoft.com/kb/815057/ -[816039 FIX: Code Point Comparison Semantics for SQL_Latin1_General_Cp850_BIN Collation]:http://support.microsoft.com/kb/816039/ -[816084 FIX: sysindexes.statblob Column May Be Corrupted After You Run a DBCC DBREINDEX Statement]:http://support.microsoft.com/kb/816084/ -[810185 SQL Server 2000 hotfix update for SQL Server 2000 Service Pack 3 and 3a]:http://support.microsoft.com/kb/810185/ -[814035 FIX: A Full-Text Population Fails After You Apply SQL Server 2000 Service Pack 3]:http://support.microsoft.com/kb/814035/ -[815115 FIX: A DTS package that uses global variables ignores an error message raised by RAISERROR]:http://support.microsoft.com/kb/815115/ -[814889 FIX: A DELETE statement with a JOIN might fail and you receive a 625 error]:http://support.microsoft.com/kb/814889/ -[814893 FIX: Error Message: "Insufficient key column information for updating" Occurs in SQL Server 2000 SP3]:http://support.microsoft.com/kb/814893/ +[983811 MS12-060: Description of the security update for SQL Server 2000 Service Pack 4 QFE: August 14, 2012]:https://support.microsoft.com/help/983811/ +[983809 MS12-027: Description of the security update for Microsoft SQL Server 2000 Service Pack 4 QFE: April 10, 2012]:https://support.microsoft.com/help/983809/ +[960083 MS09-004: Description of the security update for SQL Server 2000 QFE and for MSDE 2000: February 10, 2009]:https://support.microsoft.com/help/960083/ ## Microsoft SQL Server 7.0 Builds @@ -2273,7 +2331,7 @@ Microsoft SQL Server 2014 (SP2-CU9) (KB4055557) - 12.0.5563.0 (X64) | 7.00.1097 | 822756 A Complex UPDATE Statement That Uses an Index Spool Operation May Cause an Assertion | 2005-10-25 | | 7.00.1094 | 821279 MS03-031: Security patch for SQL Server 7.0 Service Pack 4 | 2006-05-11 | | 7.00.1094 | 815495 MS03-031: Cumulative security patch for SQL Server | 2006-05-10 | -| 7.00.1092 | [820788 FIX: Delayed domain authentication may cause SQL Server to stop responding] | 2005-10-25 | +| 7.00.1092 | 820788 FIX: Delayed domain authentication may cause SQL Server to stop responding | 2005-10-25 | | 7.00.1087 | 814693 FIX: SQL Server 7.0 Scheduler May Periodically Stop Responding During Large Sort Operation | 2005-09-27 | | 7.00.1079 | 329499 FIX: Replication Removed from Database After Restore WITH RECOVERY | 2005-10-11 | | 7.00.1078 | 327068 INF: SQL Server 7.0 Security Update for Service Pack 4 | 2005-09-27 | @@ -2316,9 +2374,8 @@ Microsoft SQL Server 2014 (SP2-CU9) (KB4055557) - 12.0.5563.0 (X64) | 7.00.583 | SQL Server 7.0 RC1 | | | 7.00.517 | SQL Server 7.0 Beta 3 | | -[948113 MS08-040: Description of the security update for SQL Server 7.0: July 8, 2008]:https://support.microsoft.com/ru-ru/help/941203/ms08-040-vulnerabilities-in-microsoft-sql-server-could-allow-elevation-of-privilege -[820788 FIX: Delayed domain authentication may cause SQL Server to stop responding]:http://support.microsoft.com/kb/820788/ -[SQL Server 7.0 Service Pack 4 (SP4)]:https://www.microsoft.com/en-us/download/details.aspx?id=7959 +[948113 MS08-040: Description of the security update for SQL Server 7.0: July 8, 2008]:https://support.microsoft.com/help/941203 +[SQL Server 7.0 Service Pack 4 (SP4)]:https://www.microsoft.com/download/details.aspx?id=7959 ## Microsoft SQL Server 6.5 Builds @@ -2345,11 +2402,9 @@ Microsoft SQL Server 2014 (SP2-CU9) (KB4055557) - 12.0.5563.0 (X64) | 6.50.258 | Microsoft SQL Server 6.5 Service Pack 3a (SP3a) | | | 6.50.252 | Microsoft SQL Server 6.5 Service Pack 3 (SP3) | | | 6.50.240 | 160727 Microsoft SQL Server 6.5 Service Pack 2 (SP2) | | -| 6.50.213 | [153096 Microsoft SQL Server 6.5 Service Pack 1 (SP1)] | | +| 6.50.213 | 153096 Microsoft SQL Server 6.5 Service Pack 1 (SP1) | | | 6.50.201 | Microsoft SQL Server 6.5 RTM | 1996-06-30 | -[153096 Microsoft SQL Server 6.5 Service Pack 1 (SP1)]:https://support.microsoft.com/en-us/help/153096/fix-sql-server-6.5-service-pack-1-fixlist - ## Microsoft SQL Server 6.0 Builds diff --git a/SSMS/README.md b/SSMS/README.md index 2b056a75..54a9b822 100644 --- a/SSMS/README.md +++ b/SSMS/README.md @@ -3,20 +3,26 @@ SQL Server Management Studio is an integrated environment for managing your SQL Management Studio provides tools to configure, monitor, and administer instances of SQL Server. It also provides tools to deploy, monitor, and upgrade the data-tier components, such as databases and data warehouses used by your applications, and to build queries and scripts. - - [SSMS Tips](SSMS_Tips.md) - - [SSMS Addins](SSMS_Addins.md) - - [SSMS Snippets](SSMS_Snippets) - - [SSMS Shortcuts](SSMS_Shortcuts.md) - - [Download SQL Server Management Studio (SSMS)](https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms) - - [SQL Server Management Studio - Changelog (SSMS)](https://docs.microsoft.com/en-us/sql/ssms/sql-server-management-studio-changelog-ssms) - - [SQL Server Management Studio (SSMS) - Release Candidate](https://docs.microsoft.com/en-us/sql/ssms/sql-server-management-studio-ssms-release-candidate) - - [Previous SQL Server Management Studio Releases](https://docs.microsoft.com/en-us/sql/ssms/previous-sql-server-management-studio-releases) - - [SQLSentry Latest Builds of Management Studio](http://blogs.sqlsentry.com/team-posts/latest-builds-management-studio/) - - [SQL Server Tools](https://docs.microsoft.com/en-us/sql/ssdt/sql-server-tools) - - [SQL Server Management Studio (SSMS)](https://docs.microsoft.com/en-us/sql/ssms/sql-server-management-studio-ssms) - - [Microsoft Download Center SSMS](https://www.microsoft.com/en-us/download/search.aspx?q=sql%20server%20management%20studio&p=0&r=10&t=&s=Relevancy~Descending) - - [MSDN Code Snippets Schema Reference](https://msdn.microsoft.com/en-us/library/ms171418.aspx) - - [MSDN Add Transact-SQL Snippets](https://msdn.microsoft.com/en-us/library/gg492130.aspx) + +## SSMS Guides +- [40 SSMS Tips](SSMS_Tips.md) (by Konstantin Taranov) +- [36 SSMS Addins](SSMS_Addins.md) (by Konstantin Taranov) +- [SSMS Snippets](SSMS_Snippets) +- [SSMS Shortcuts](SSMS_Shortcuts.md) (by Konstantin Taranov) +- [A month of SSMS tips and tricks](https://blog.waynesheffield.com/wayne/archive/2018/02/ssms-tips-tricks/) (by Wayne Sheffield) +- [SSMS Tricks & Shortcuts](http://www.e-squillace.com/ssms-tricks-shortcuts/) (by George Squillace) +- [SSMS Tricks and Tips Ebook](https://sql-down-under.newzenler.com/f/ssms-tips-tricks-book) (by Greg Low) + +### Useful Resources +- [Download SQL Server Management Studio (SSMS)](https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms) +- [SQL Server Management Studio - Changelog (SSMS)](https://docs.microsoft.com/en-us/sql/ssms/sql-server-management-studio-changelog-ssms) +- [SQL Server Management Studio (SSMS) - Release Candidate](https://docs.microsoft.com/en-us/sql/ssms/sql-server-management-studio-ssms-release-candidate) +- [Previous SQL Server Management Studio Releases](https://docs.microsoft.com/en-us/sql/ssms/previous-sql-server-management-studio-releases) +- [SQLSentry Latest Builds of Management Studio](https://www.sentryone.com/blog/team-posts/latest-builds-management-studio/) +- [SQL Server Tools](https://docs.microsoft.com/en-us/sql/ssdt/sql-server-tools) +- [SQL Server Management Studio (SSMS)](https://docs.microsoft.com/en-us/sql/ssms/sql-server-management-studio-ssms) +- [Microsoft Download Center SSMS](https://www.microsoft.com/en-us/download/search.aspx?q=sql%20server%20management%20studio&p=0&r=10&t=&s=Relevancy~Descending) +- [Add Transact-SQL Snippets](https://docs.microsoft.com/en-us/sql/relational-databases/scripting/add-transact-sql-snippets) ## Supported SQL Server versions @@ -26,77 +32,120 @@ Additionally, SSMS 17.x can be installed side-by-side with SSMS 16.X or SQL Serv ## Supported Operating systems -This release of SSMS supports the following platforms when used with the latest available service pack: - - Windows 10 - - Windows 8 - - Windows 8.1 - - Windows 7 (SP1) - - Windows Server 2016 - - Windows Server 2012 (64-bit) - - Windows Server 2012 R2 (64-bit) - - Windows Server 2008 R2 (64-bit) - -### Note +This release of **SSMS 17.x Version** supports the following platforms when used with the latest available service pack: Windows 10, Windows 8, Windows 8.1, Windows 7 (SP1), Windows Server 2016, Windows Server 2012 (64-bit), Windows Server 2012 R2 (64-bit), Windows Server 2008 R2 (64-bit) + +SSMS 18.x is not supported on Windows 8. Windows 10 / Windows Server 2016 requires version 1607 (10.0.14393) or later: +Due to the new dependency on NetFx 4.7.2, SSMS 18.0 does not install on Windows 8, older versions of Windows 10, and Windows Server 2016. SSMS setup will block on those operating systems. Windows 8.1 is still supported. + + +### SSMS Version Notes SSMS 17.X is based on the Visual Studio 2015 Isolated shell, which was released before Windows Server 2016. Microsoft takes app compatibility very seriously and ensures that already-shipped applications continue to run on the latest Windows releases. Because of this, we do not anticipate that SSMS with all latest updates applied) will encounter issues when running on Windows Server 2016. Customers are advised to contact support, should they encounter any issues with SSMS on Windows Server 2016. Support will then work with customers to determine if the issue is with SSMS or Visual Studio or with Windows compatibility, and route the issue appropriately. -## Available Languages -SQL Server Management Studio for another languages: - - [Chinese (People's Republic of China)](https://go.microsoft.com/fwlink/?linkid=854085&clcid=0x804) - - [Chinese (Taiwan)](https://go.microsoft.com/fwlink/?linkid=854085&clcid=0x404) - - [English (United States)](https://go.microsoft.com/fwlink/?linkid=854085&clcid=0x804) - - [French](https://go.microsoft.com/fwlink/?linkid=854085&clcid=0x804) - - [German](https://go.microsoft.com/fwlink/?linkid=854085&clcid=0x804) - - [Italian](https://go.microsoft.com/fwlink/?linkid=854085&clcid=0x804) - - [Japanese](https://go.microsoft.com/fwlink/?linkid=854085&clcid=0x804) - - [Korean](https://go.microsoft.com/fwlink/?linkid=854085&clcid=0x804) - - [Portuguese (Brazil)](https://go.microsoft.com/fwlink/?linkid=854085&clcid=0x804) - - [Russian](https://go.microsoft.com/fwlink/?linkid=854085&clcid=0x804) - - [Spanish](https://go.microsoft.com/fwlink/?linkid=854085&clcid=0x804) - -SQL Server Management Studio 17.3 Upgrade Package (upgrades 17.x to 17.3): - - [Chinese (People's Republic of China)](https://go.microsoft.com/fwlink/?linkid=854087&clcid=0x804) - - [Chinese (Taiwan)](https://go.microsoft.com/fwlink/?linkid=854087&clcid=0x404) - - [English (United States)](https://go.microsoft.com/fwlink/?linkid=854087&clcid=0x409) - - [French](https://go.microsoft.com/fwlink/?linkid=854087&clcid=0x40c) - - [German](https://go.microsoft.com/fwlink/?linkid=854087&clcid=0x407) - - [Italian](https://go.microsoft.com/fwlink/?linkid=854087&clcid=0x410) - - [Japanese](https://go.microsoft.com/fwlink/?linkid=854087&clcid=0x411) - - [Korean](https://go.microsoft.com/fwlink/?linkid=854087&clcid=0x412) - - [Portuguese (Brazil)](https://go.microsoft.com/fwlink/?linkid=854087&clcid=0x416) - - [Russian](https://go.microsoft.com/fwlink/?linkid=854087&clcid=0x419) - - [Spanish](https://go.microsoft.com/fwlink/?linkid=854087&clcid=0x40a) +SSMS 18.x is based on the new Visual Studio 2017 Isolated Shell: The new shell unlocks all the accessibility fixes that went in to both SSMS and Visual Studio. -## SQL Server Management Studio Download Links and Release Info +## Available Languages +**SQL Server Management Studio 18.9.2 GA**: + [Chinese (People's Republic of China)](https://go.microsoft.com/fwlink/?linkid=2168063&clcid=0x804) | + [Chinese (Taiwan)](https://go.microsoft.com/fwlink/?linkid=2168063&clcid=0x404) | + [English (United States)](https://go.microsoft.com/fwlink/?linkid=2168063&clcid=0x409) | + [French](https://go.microsoft.com/fwlink/?linkid=2168063&clcid=0x40c) | + [German](https://go.microsoft.com/fwlink/?linkid=2168063&clcid=0x407) | + [Italian](https://go.microsoft.com/fwlink/?linkid=2168063&clcid=0x410) | + [Japanese](https://go.microsoft.com/fwlink/?linkid=2168063&clcid=0x411) | + [Korean](https://go.microsoft.com/fwlink/?linkid=2168063&clcid=0x412) | + [Portuguese (Brazil)](https://go.microsoft.com/fwlink/?linkid=2168063&clcid=0x416) | + [Russian](https://go.microsoft.com/fwlink/?linkid=2168063&clcid=0x419) | + [Spanish](https://go.microsoft.com/fwlink/?linkid=2168063&clcid=0x40a) -| Version/Download Link | Build | Release Date | Size, Mb | -|----------------------------------|---------------|--------------|---------:| -| [17.4 Release] **Latest** | 14.0.17213.0 | 2017-12-07 | 802 | -| [17.3 Release] | 14.0.17199.0 | 2017-10-09 | 801 | -| [17.2 Release] | 14.0.17177.0 | 2017-08-07 | 819 | -| [17.1 Release] | 14.0.17119.0 | 2017-05-24 | 784 | -| [17.0 Release] | 14.0.17099.0 | 2017-04-25 | 729 | -| [17.0 RC3 Release] | 14.0.17028.0 | 2017-03-09 | 677 | -| [17.0 RC2 Release] | 14.0.16150.0 | 2017-02-01 | 682 | -| [17.0 RC1 Release] | 14.0.16000.64 | 2016-11-16 | 687 | -| [16.5.3 Release] | 13.0.16106.4 | 2017-01-26 | 898 | -| 16.5.2 Release **Deprecated** | 13.0.16105.4 | 2017-01-18 | 898 | -| [16.5.1 Release] | 13.0.16100.1 | 2016-12-05 | 894 | -| [16.5 Release] | 13.0.16000.28 | 2016-10-26 | 894 | -| [16.4.1 Release] | 13.0.15900.1 | 2016-09-23 | 894 | -| 16.4 Release **Deprecated** | 13.0.15800.18 | 2016-09-20 | | -| [16.3 Release] | 13.0.15700.28 | 2016-08-15 | 806 | -| [July 2016 Hotfix Update] | 13.0.15600.2 | 2016-07-13 | 825 | -| July 2016 Release **Deprecated** | 13.0.15500.91 | 2016-07-01 | | -| [June 2016 Release] | 13.0.15000.23 | 2016-06-01 | 825 | -| [SQL Server 2014 SP1] | 12.0.4100.1 | 2015-05-14 | 815 | -| [SQL Server 2012 SP3] | 11.0.6020.0 | 2015-11-21 | 964 | -| [SQL Server 2008 R2] | 10.50.4000 | 2012-07-02 | 161 | +## SQL Server Management Studio Download Links and Release Info +- **GA** - General Availability +- **PP** - Public Preview +- Size in Megabytes for English version + +| Version/Download Link | Info | Build | Release Date | Size, Mb | +| --------------------------|----------------|---------------|--------------|---------:| +| [18.9.2 GA Release] | **Latest GA** | 15.0.18386.0 | 2021-07-15 | 642 | +| [18.9.1 GA Release] | | 15.0.18384.0 | 2021-04-20 | 635 | +| [18.9 GA Release] | | 15.0.18382.0 | 2021-04-15 | 635 | +| [18.8 GA Release] | | 15.0.18369.0 | 2020-12-17 | 640 | +| [18.7.1 GA Release] | | 15.0.18358.0 | 2020-10-27 | 635 | +| [18.7 GA Release] | | 15.0.18357.0 | 2020-10-20 | 635 | +| [18.6 GA Release] | | 15.0.18338.0 | 2020-07-22 | 534 | +| [18.5.1 GA Release] | | 15.0.18333.0 | 2020-06-09 | 535 | +| [18.5 GA Release] | | 15.0.18183.0 | 2020-04-07 | 535 | +| [18.4 GA Release] | | 15.0.18206.0 | 2019-11-04 | 539 | +| [18.3.1 GA Release] | | 15.0.18183.0 | 2019-10-02 | 534 | +| [18.3 GA Release] | | 15.0.18178.0 | 2019-09-23 | 534 | +| [18.2 GA Release] | | 15.0.18142.0 | 2019-07-25 | 528 | +| [18.1 GA Release] | | 15.0.18131.0 | 2019-06-11 | 527 | +| [18.0 GA Release] | | 15.0.18118.0 | 2019-04-24 | 524 | +| [18.0 RC1 Release] | | 15.0.18098.0 | 2019-03-28 | 484 | +| [18.0 Preview 7 Release] | | 15.0.18092.0 | 2019-03-01 | 478 | +| [18.0 Preview 6 Release] | | 15.0.18075.0 | 2018-12-18 | 457 | +| [18.0 Preview 5 Release] | | 15.0.18068.0 | 2018-11-15 | 457 | +| [18.0 Preview 4 Release] | | 15.0.18040.0 | 2018-09-24 | 456 | +| [17.9.1 Release] | **Latest 17** | 14.0.17289.0 | 2018-11-21 | 807 | +| [17.9 Release] | | 14.0.17285.0 | 2018-09-04 | 807 | +| [17.8.1 Release] | | 14.0.17277.0 | 2018-06-26 | 806 | +| [17.8 Release] | **Deprecated** | 14.0.17276.0 | 2018-06-21 | 806 | +| [17.7 Release] | | 14.0.17254.0 | 2018-05-09 | 803 | +| [17.6 Release] | | 14.0.17230.0 | 2018-03-20 | 802 | +| [17.5 Release] | | 14.0.17224.0 | 2018-02-15 | 802 | +| [17.4 Release] | | 14.0.17213.0 | 2017-12-07 | 802 | +| [17.3 Release] | | 14.0.17199.0 | 2017-10-09 | 801 | +| [17.2 Release] | | 14.0.17177.0 | 2017-08-07 | 819 | +| [17.1 Release] | | 14.0.17119.0 | 2017-05-24 | 784 | +| [17.0 Release] | | 14.0.17099.0 | 2017-04-25 | 729 | +| [17.0 RC3 Release] | | 14.0.17028.0 | 2017-03-09 | 677 | +| [17.0 RC2 Release] | | 14.0.16150.0 | 2017-02-01 | 682 | +| [17.0 RC1 Release] | | 14.0.16000.64 | 2016-11-16 | 687 | +| [16.5.3 Release] | **Latest 16** | 13.0.16106.4 | 2017-01-26 | 898 | +| 16.5.2 Release | **Deprecated** | 13.0.16105.4 | 2017-01-18 | 898 | +| [16.5.1 Release] | | 13.0.16100.1 | 2016-12-05 | 894 | +| [16.5 Release] | | 13.0.16000.28 | 2016-10-26 | 894 | +| [16.4.1 Release] | | 13.0.15900.1 | 2016-09-23 | 894 | +| 16.4 Release | **Deprecated** | 13.0.15800.18 | 2016-09-20 | | +| [16.3 Release] | | 13.0.15700.28 | 2016-08-15 | 806 | +| [July 2016 Hotfix Update] | | 13.0.15600.2 | 2016-07-13 | 825 | +| July 2016 Release | **Deprecated** | 13.0.15500.91 | 2016-07-01 | | +| [June 2016 Release] | | 13.0.15000.23 | 2016-06-01 | 825 | +| [SQL Server 2014 SP1] | | 12.0.4100.1 | 2015-05-14 | 815 | +| [SQL Server 2012 SP3] | | 11.0.6020.0 | 2015-11-21 | 964 | +| [SQL Server 2008 R2] | | 10.50.4000 | 2012-07-02 | 161 | + +[18.9.2 GA Release]:https://go.microsoft.com/fwlink/?linkid=2168063 +[18.9.1 GA Release]:https://go.microsoft.com/fwlink/?linkid=2161193 +[18.9 GA Release]:https://go.microsoft.com/fwlink/?linkid=2160964 +[18.8 GA Release]:https://go.microsoft.com/fwlink/?linkid=2151644 +[18.7.1 GA Release]:https://go.microsoft.com/fwlink/?linkid=2147207 +[18.7 GA Release]:https://go.microsoft.com/fwlink/?linkid=2146265 +[18.6 GA Release]:https://go.microsoft.com/fwlink/?linkid=2135491 +[18.5.1 GA Release]:https://go.microsoft.com/fwlink/?linkid=2132606 +[18.5 GA Release]:https://go.microsoft.com/fwlink/?linkid=2125901 +[18.4 GA Release]:https://go.microsoft.com/fwlink/?linkid=2108895 +[18.3.1 GA Release]:https://go.microsoft.com/fwlink/?linkid=2105412 +[18.3 GA Release]:https://go.microsoft.com/fwlink/?linkid=2104251 +[18.2 GA Release]:https://go.microsoft.com/fwlink/?linkid=2099720 +[18.1 GA Release]:https://go.microsoft.com/fwlink/?linkid=2094583 +[18.0 GA Release]:https://go.microsoft.com/fwlink/?linkid=2088649 +[18.0 RC1 Release]:https://go.microsoft.com/fwlink/?linkid=2085742 +[18.0 Preview 7 Release]:https://go.microsoft.com/fwlink/?linkid=2078638 +[18.0 Preview 6 Release]:https://go.microsoft.com/fwlink/?linkid=2052501 +[18.0 Preview 5 Release]:https://go.microsoft.com/fwlink/?linkid=2041155 +[18.0 Preview 4 Release]:https://go.microsoft.com/fwlink/?linkid=2014662 +[17.9.1 Release]:https://go.microsoft.com/fwlink/?linkid=2043154 +[17.9 Release]:https://go.microsoft.com/fwlink/?linkid=2014306 +[17.8.1 Release]:https://go.microsoft.com/fwlink/?linkid=875802 +[17.8 Release]:https://go.microsoft.com/fwlink/?linkid=875673 +[17.7 Release]:https://go.microsoft.com/fwlink/?linkid=873126 +[17.6 Release]:https://go.microsoft.com/fwlink/?linkid=870039 +[17.5 Release]:https://go.microsoft.com/fwlink/?linkid=867670 [17.4 Release]:https://go.microsoft.com/fwlink/?linkid=864329 [17.3 Release]:https://go.microsoft.com/fwlink/?linkid=858904 [17.2 Release]:https://go.microsoft.com/fwlink/?linkid=854085 diff --git a/SSMS/SSMS_Addins.md b/SSMS/SSMS_Addins.md index 5ec8ece3..985fc505 100644 --- a/SSMS/SSMS_Addins.md +++ b/SSMS/SSMS_Addins.md @@ -1,66 +1,117 @@ # SQL Server Management Studio add-ins -Complete list of useful and must have add-ins for SQL Server Management Studio - **34** SSMS add-ins - -| Name | Download page | Release Date | Support SSMS Version | Developer | Free version | Price | -|-------------------------------------------------------|-------------------------------|--------------|:-----------------------------------|----------------------|--------------|------:| -| [SSMSBoost](#ssmsboost) | [SSMSBoost] | 2017-09-06 | 2008/2012/2014/2016/2017 | Solutions Crew GmbH | Yes | €150 | -| [SqlSmash](#SqlSmash) | [SqlSmash] | 2017-06-10 | 2008/2012/2014/2016/2017 | Smashing Jedis LLC | Yes | $99 | -| [SQL Code Guard](#sql-code-guard) | [Red Gate SQL Code Guard] | 2017-07-03 | 2016 | Red Gate | Yes | No | -| [SQL Search](#sql-search) | [SQL Search] | 2017-02-27 | 2008/2012/2014/2016/2017 | Red Gate | Yes | No | -| [SQL Scripts Manager](#sql-scripts-manager) | [SQL Scripts Manager] | 2015-05-31 | 2008/2012/2014 | Red Gate | Yes | No | -| [Red Gate SQL Test](#red-gate-sql-test) | [Red Gate SQL Test] | 2017-03-21 | 2008/2012/2014/2016/2017 | Red Gate | No | $369 | -| [Red Gate SQL Source Control](#red-gate-control) | [Red Gate SQL Source Control] | 2017-06-30 | 2012/2014/2016/2017 | Red Gate | No | $495 | -| [Supratimas](#supratimas) | [Supratimas] | 2017-07-11 | 2008/2012/2014/2016/2017 | TTRider LLC | Yes | No | -| [SSMS Tools Pack](#ssms-tools-pack) | [SSMS Tools Pack] | 2016-11-28 | 2012/2014/2016/2017 | Mladen Prajdić | No | €30 | -| [SQL Pretty Printer](#sql-pretty-printer) | [SQL Pretty Printer] | 2015-11-05 | 2008/2012/2014 | Gudu Software | No | $50 | -| [SQL Sentry Plan Explorer](#sql-sentry-plan-explorer) | [SQL Sentry Plan Explorer] | 2017-05-25 | 2008/2012/2014/2016/2017 | SQL Sentry | Yes | No | -| [TSQL Code Smells Finder](#tsql-code-smells-finder) | [TSQL Code Smells Finder] | 2013-02-15 | 2008/2012/2014 | Dave ballantyne | Yes | No | -| [SQLTreeo](#sqltreeo) | [SQLTreeo] | 2017-06-06 | 2008/2012/2014/2016/2017 | SQLTreeo | No | €50 | -| [ApexSQL Complete](#apexsql-complete) | [ApexSQL Complete] | 2017-10-26 | 2008/2012/2014/2016/2017 | ApexSQL tools | Yes | No | -| [ApexSQL Refactor](#apexsql-refactor) | [ApexSQL Refactor] | 2017-07-13 | 2008/2012/2014/2016/2017 | ApexSQL tools | Yes | No | -| [ApexSQL Search](#apexsql-search) | [ApexSQL Search] | 2017-06-19 | 2008/2012/2014/2016/2017 | ApexSQL tools | Yes | No | -| [ApexSQL Source Control](#apexsql-source-control) | [ApexSQL Source Control] | 2017-10-12 | 2008/2012/2014/2016/2017 | ApexSQL tools | No | $299 | -| [ApexSQL Unit Test](#apexsql-unit-test) | [ApexSQL Unit Test] | 2017-08-16 | 2008/2012/2014/2016/2017 | ApexSQL tools | Yes | $499 | -| [Spotlight Developer](#spotlight-developer) | [Spotlight Developer] | 2016-02-04 | 2008/2012/2014 | Spotlight Essentials | Yes | No | -| [dbForge Source Control](#dbforge-source-control) | [dbForge Source Control] | 2017-09-30 | 2005/2008/2012/2014/2016/2017 | Devart | No | $249 | -| [dbForge Unit Test](#dbforge-unit-test) | [dbForge Unit Test] | 2017-09-30 | 2005/2008/2012/2014/2016/2017 | Devart | No | $199 | -| [dbForge Data Pump](#dbforge-data-pump) | [dbForge Data Pump] | 2017-09-30 | 2008/2012/2014/2016 | Devart | No | $149 | -| [dbForge Index Manager](#dbforge-index-manager) | [dbForge Index Manager] | 2017-09-30 | 2008/2012/2014/2016 | Devart | No | $99 | -| [dbForge Search](#dbforge-search) | [dbForge Search] | 2017-09-30 | 2008/2012/2014/2016/2017 | Devart | Yes | No | -| [dbForge Monitor](#dbforge-monitor) | [dbForge Monitor] | 2017-09-30 | 2008/2012/2014/2016 | Devart | Yes | No | -| [dbForge SQL Complete](#dbforge-sql-complete) | [dbForge SQL Complete] | 2017-09-30 | 2000/2005/2008/2012/2014/2016/2017 | Devart | Yes | $149 | -| [SoftTree SQL Assistant](#softtree-sql-assistant) | [SoftTree SQL Assistant] | 2016-03-18 | 2008/2012/2014 | SoftTree | No | $179 | -| [SQL Enlight For SSMS](#sql-enlight-for-ssms) | [SQL Enlight For SSMS] | 2016-04-25 | 2008/2012/2014 | UbitSoft | No | $195 | -| [SQL Hunting Dog](#sql-hunting-dog) | [SQL Hunting Dog] | 2016-03-03 | 2008/2012/2014 | Alex Maslyukov | Yes | No | -| [Poor Mans T-SQL Formatter](#poor-mans) | [Poor Mans T-SQL Formatter] | 2013-10-23 | 2008/2012 | Tao Klerks | Yes | No | -| [Tabs Studio](#tabs-studio) | [Tabs Studio] | 2017-08-24 | 2012/2014/2016/2017 | Vlasov Studio | No | $49 | -| [Workload Addin](#workload-addin) | [Workload Addin] | 2017-02-07 | 2008/2012 | Tomáš Bauer | Yes | No | -| [SQL Server Diagnostics](#sql-server-diagnostics) | [SQL Server Diagnostics] | 2017-06-22 | 2016/2017 | Microsoft | Yes | No | -| [VersionSQL](#versionsql) | [VersionSQL] | 2017-02-16 | 2012/2014/2016/2017 | VersionSQL | Yes | $149 | +Complete list of useful and must have add-ins for SQL Server Management Studio - **38** SSMS add-ins + +| Name | Download page | Release Date | Support SSMS Version | Developer | Free version | Price | +|-------------------------------------------------------|-------------------------------|--------------|:---------------------|----------------------|--------------|------:| +| [SSMSBoost](#ssmsboost) | [SSMSBoost] | 2019-08-19 | 2008-2018 | Solutions Crew GmbH | Yes | $150 | +| [SQL Refactor Studio](#sql-refactor-studio) | [SQL Refactor Studio] | 2013-09-01 | 2013-2016 | SQL Refactor Studio Team | Yes | $17-25 | +| [SqlSmash](#sqlsmash) | [SqlSmash] | 2017-06-10 | 2008-2017 | Smashing Jedis LLC | Yes | $99 | +| [SQL Search](#sql-search) | [SQL Search] | 2017-02-27 | 2008-2017 | Red Gate | Yes | No | +| [Red Gate SQL Test](#red-gate-sql-test) | [Red Gate SQL Test] | 2017-03-21 | 2008-2017 | Red Gate | No | $369 | +| [Red Gate SQL Source Control](#red-gate-control) | [Red Gate SQL Source Control] | 2017-06-30 | 2012-2017 | Red Gate | No | $495 | +| [Supratimas](#supratimas) | [Supratimas] | 2017-07-11 | 2008-2017 | TTRider LLC | Yes | No | +| [SSMS Tools Pack](#ssms-tools-pack) | [SSMS Tools Pack] | 2016-11-28 | 2012-2017 | Mladen Prajdić | No | €30 | +| [SQL Pretty Printer](#sql-pretty-printer) | [SQL Pretty Printer] | 2015-11-05 | 2008-2014 | Gudu Software | No | $50 | +| [SQL Sentry Plan Explorer](#sql-sentry-plan-explorer) | [SQL Sentry Plan Explorer] | 2017-05-25 | 2008-2017 | SQL Sentry | Yes | No | +| [TSQL Code Smells Finder](#tsql-code-smells-finder) | [TSQL Code Smells Finder] | 2013-02-15 | 2008-2014 | Dave ballantyne | Yes | No | +| [SQLTreeo](#sqltreeo) | [SQLTreeo] | 2017-06-06 | 2012-2017 | SQLTreeo | No | €50 | +| [ApexSQL Complete](#apexsql-complete) | [ApexSQL Complete] | 2021-01-20 | 2012-2019 | ApexSQL tools | No | $514 | +| [ApexSQL Refactor](#apexsql-refactor) | [ApexSQL Refactor] | 2021-01-20 | 2008-2019 | ApexSQL tools | No | $514 | +| [ApexSQL Search](#apexsql-search) | [ApexSQL Search] | 2021-01-20 | 2008-2019 | ApexSQL tools | No | $514 | +| [ApexSQL Source Control](#apexsql-source-control) | [ApexSQL Source Control] | 2021-01-20 | 2008-2019 | ApexSQL tools | No | $257 | +| [ApexSQL Unit Test](#apexsql-unit-test) | [ApexSQL Unit Test] | 2021-01-20 | 2008-2019 | ApexSQL tools | No | $514 | +| [Spotlight Developer](#spotlight-developer) | [Spotlight Developer] | 2016-02-04 | 2008-2014 | Spotlight Essentials | Yes | No | +| [dbForge Source Control](#dbforge-source-control) | [dbForge Source Control] | 2019-10-10 | 2005-2018 | Devart | No | $249 | +| [dbForge Unit Test](#dbforge-unit-test) | [dbForge Unit Test] | 2019-10-10 | 2005-2018 | Devart | No | $199 | +| [dbForge Data Pump](#dbforge-data-pump) | [dbForge Data Pump] | 2019-10-10 | 2008-2018 | Devart | No | $149 | +| [dbForge Index Manager](#dbforge-index-manager) | [dbForge Index Manager] | 2021-09-10 | 2008-2018 | Devart | No | $119 | +| [dbForge Search](#dbforge-search) | [dbForge Search] | 2019-10-10 | 2008-2018 | Devart | Yes | No | +| [dbForge Monitor](#dbforge-monitor) | [dbForge Monitor] | 2019-10-10 | 2012-2018 | Devart | Yes | No | +| [dbForge SQL Complete](#dbforge-sql-complete) | [dbForge SQL Complete] | 2021-10-05 | 2000-2018 | Devart | Yes | $199 | +| [SoftTree SQL Assistant](#softtree-sql-assistant) | [SoftTree SQL Assistant] | 2016-03-18 | 2008-2014 | SoftTree | No | $179 | +| [SQL Enlight For SSMS](#sql-enlight-for-ssms) | [SQL Enlight For SSMS] | 2016-04-25 | 2008-2014 | UbitSoft | No | $195 | +| [SQL Hunting Dog](#sql-hunting-dog) | [SQL Hunting Dog] | 2016-03-03 | 2008-2014 | Alex Maslyukov | Yes | No | +| [Poor Mans T-SQL Formatter](#poor-mans) | [Poor Mans T-SQL Formatter] | 2013-10-23 | 2008-2012 | Tao Klerks | Yes | No | +| [Tabs Studio](#tabs-studio) | [Tabs Studio] | 2017-08-24 | 2012-2017 | Vlasov Studio | No | $49 | +| [Workload Addin](#workload-addin) | [Workload Addin] | 2017-02-07 | 2008-2012 | Tomáš Bauer | Yes | No | +| [SQL Server Diagnostics](#sql-server-diagnostics) | [SQL Server Diagnostics] | 2017-06-22 | 2016-2017 | Microsoft | Yes | No | +| [VersionSQL](#versionsql) | [VersionSQL] | 2017-02-16 | 2012-2017 | Wrism Innovations | Yes | $199 | +| [Spotlight Tuning Pack](#spotlight-tuning-pack) | [Spotlight Tuning Pack] | 2018-06-01 | 2012-2017 | Quest Software Inc | Yes | $180 | +| [Michel Max - SSMS Tools](#michel-max) | [Michel Max - SSMS Tools] | 2018-11-16 | 2012-2018 | Michel Max | Yes | No | +| [SSMS Schema Folders](#ssms-schema-folders) | [SSMS Schema Folders] | 2018-10-06 | 2012-2018 | Nicholas Ross | Yes | No | +| [Statistics Reporter](#statistics-reporter) | [Statistics Reporter] | 2019-04-17 | 2014-2018 | Analytics Bar | Yes | No | +| [SSMS Lizard](#ssms-lizard) | [SSMS Lizard] | 2020-06-15 | 2018-2018 | Lizard Labs Software | Yes | No | +| [SSMS Object Explorer Menu](#ssms-menu) | [SSMS Object Explorer Menu] | 2023-07-10 | 2018-2022 | Daniel Brink | Yes | No | +| [SQL Shades dark mode](#sql-shades) | [SQL Shades] | 2022-08-03 | 2018-2022 | Wrism Innovations | Yes | No | +| [Axial SQL Tools](#axial-sql-tools) | [Axial SQL Tools] | 2025-01-26 | 2022-2025 | Alex Bochkov | Yes | No | ## SSMSBoost Download page: [SSMSBoost]
-Release date: 2017-09-06
-Support Version: 2008/2012/2014/2016/2017
+Release date: 2019-01-09
+Support Version: 2008-2018
Developer: Solutions Crew GmbH
Free version: Yes
-Price: €150 +Price: $150 SSMSBoost add-in adds missing features and improves your productivity when working with Microsoft SQL Server in SQL Server Management Studio. - -The main goal of the project is to speed-up daily tasks of SQL DBA and SQL developers and to help you avoid destructive DML executions in production environments. + - SQL Code formatting + - GoTo Definition + - Run current statement + - Restore last session + - Export data to Excel + - Prohibit execution of UPDATE/DELETE without WHERE + - Connections manager + - Save/Visualize files stored in BLOB/TEXT fields + - Regions + - Code highlighting within INSERT/VALUES statement + - Connection coloring + - and even more... Licensing options: after 30 day trial period register and get free community license or buy the professional version. + [Features list / SSMSBoost version comparison](http://www.ssmsboost.com/VersionCompare) + +## SQL Refactor Studio +Download page: [SQL Refactor Studio]
+Release date: 2013-09-01
+Support Version: 2013-2016
+Developer: SQL Refactor Studio Team
+Free version: Yes
+Price: $17-25 + +SQL Refactor Studio is a SQL Server Management Studio addin. It contains a lot of useful tools that help SQL Server developers to perform their daily routines. + +Key features of SQL Refactor Studio: +- Group Databases and Database Objects +- SQL Query History +- Generate C# classes +- Refactoring «Rename» +- View Dependencies +- Find Code +- Displaying calculations on the SSMS status bar +- Refactoring «Add CRUD Methods» +- Refactoring «Introduce Trigger for History» +- Refactoring «Add Lookup Table» +- Refactoring «Move Columns» +- Find Data +- Generate Select Statement +- Script Table Data +- Change collation of table columns +- Highlight all occurrences of selected word +- Scripting an object as ALTER +- Get row count +- Get Top(N) rows + + ## SqlSmash Download page: [SqlSmash]
Release date: 2017-06-10
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Developer: Smashing Jedis LLC
Free version: Yes
Price: $99 @@ -82,30 +133,11 @@ Write maintainable SQL scripts, Understand code better and Navigate faster with - Go To Definition - -## SQL Code Guard -Download link: [Red Gate SQL Code Guard]
-Release date: 2017-02-17
-Support Version: 2016
-Developer: Red Gate
-Free version: Yes
-Price: No - -SQL Code Guard is a free solution for SQL Server that provides fast and comprehensive static analysis for T-Sql code, shows code complexity and objects dependencies. - - - Integration with SSMS 2016 - - Integration with Visual Studio 2012/2013 - - Checkin Policy for TFS (how to install & use) - - Support of msbuild (how to use msbuild) - - Command line utility (how to use command line utility). - - API for custom tool development (demo projects can be found in SQL Code Guard folder) - - ## SQL Search Download page: [SQL Search]
Release date: 2017-02-27
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Developer: Red Gate
Free version: Yes
Price: No @@ -119,23 +151,11 @@ SQL Search is a free add-in for SQL Server Management Studio that lets you quick - Search with booleans and wildcards - -## SQL Scripts Manager -Download page: [SQL Scripts Manager]
-Release date: 2015-05-31
-Support Version: 2008/2012/2014
-Developer: Red Gate
-Free version: Yes
-Price: No - -Powerful and reliable scripts written by SQL Server experts - - ## Red Gate SQL Test Download page: [Red Gate SQL Test]
Release date: 2017-03-21
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Developer: Red Gate
Free version: No
Price: $369 @@ -147,7 +167,7 @@ Write unit tests (using the open-source [tSQLt framework](https://github.com/tSQ ## Red Gate SQL Source Control Download page: [Red Gate SQL Source Control]
Release date: 2017-06-30
-Support Version: 2012/2014/2016/2017
+Support Version: 2012-2017
Developer: Red Gate
Free version: No
Price: $495 @@ -168,7 +188,7 @@ Connect your databases to your source control system ## Supratimas Download page: [Supratimas]
Release date: 2017-07-11
-Support Version: 2008/2012/2014/2017
+Support Version: 2008-2017
Developer: TTRider LLC
Free version: Yes
Price: No @@ -180,7 +200,7 @@ SQL Server query plan execution visualizer ## SSMS Tools Pack Download page: [SSMS Tools Pack]
Release date: 2016-11-28
-Support Version: 2012/2014/2016/2017
+Support Version: 2012-2017
Developer: Mladen Prajdić
Free version: No
Price: €30 @@ -199,7 +219,7 @@ Price: €30 ## SQL Pretty Printer Download page: [SQL Pretty Printer]
Release date: 2015-11-05
-Support Version: 2008/2012/2014
+Support Version: 2008-2014
Developer: Gudu Software
Free version: No
Price: No @@ -216,7 +236,7 @@ Price: No ## SQL Sentry Plan Explorer Download page: [SQL Sentry Plan Explorer]
Release date: 2017-05-25
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Developer: SQL Sentry
Free version: Yes
Price: No @@ -229,7 +249,7 @@ It is a lightweight standalone app that contains many of the plan analysis featu ## TSQL Code Smells Finder Download page: [TSQL Code Smells Finder]
Release date: 2013-02-15
-Support Version: 2008/2012/2014
+Support Version: 2008-2014
Developer: Dave ballantyne
Free version: Yes
Price: No @@ -242,7 +262,7 @@ This is a proof of concept work which will analyze TSQL scripts in an attempt to ## SQLTreeo Download page: [SQLTreeo]
Release date: 2017-06-06
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Developer: Jakub Dvorak
Free version: No
Price: €50 @@ -259,11 +279,11 @@ Price: €50 ## ApexSQL Complete Download page: [ApexSQL Complete]
-Release date: 2017-10-26
-Support Version: 2008/2012/2014/2016/2017
+Release date: 2021-01-20
+Support Version: 2008-2019
Developer: ApexSQL tools
-Free version: Yes
-Price: No +Free version: No
+Price: $514 - Automatically complete SQL statements - Review an objects script and description @@ -278,11 +298,11 @@ Price: No ## ApexSQL Refactor Download page: [ApexSQL Refactor]
-Release date: 2017-05-08
-Support Version: 2008/2012/2014/2016/2017
+Release date: 2021-01-20
+Support Version: 2008-2019
Developer: ApexSQL tools
-Free version: Yes
-Price: No +Free version: No
+Price: $514 With ApexSQL Refactor you can: - Format SQL with over 160 options @@ -298,11 +318,11 @@ With ApexSQL Refactor you can: ## ApexSQL Search Download page: [ApexSQL Search]
-Release date: 2017-06-19
-Support Version: 2008/2012/2014/2016/2017
+Release date: 2021-01-20
+Support Version: 2008-2019
Developer: ApexSQL tools
-Free version: Yes
-Price: No +Free version: No
+Price: $514 With ApexSQL Search you can: - Search for SQL objects @@ -316,11 +336,11 @@ With ApexSQL Search you can: ## ApexSQL Source Control Download page: [ApexSQL Source Control]
-Release date: 2017-10-12
-Support Version: 2008/2012/2014/2016/2017
+Release date: 2021-01-20
+Support Version: 2008-2019
Developer: ApexSQL tools
Free version: No
-Price: $299 +Price: $257 - Integrate SQL source control directly into SSMS - Use dedicated or shared development models @@ -335,8 +355,8 @@ Price: $299 ## ApexSQL Unit Test Download page: [ApexSQL Unit Test]
-Release date: 2017-08-22
-Support Version: 2008/2012/2014/2016/2017
+Release date: 2021-01-20
+Support Version: 2008-2019
Developer: ApexSQL tools
Free version: No
Price: $499 @@ -355,7 +375,7 @@ Price: $499 ## Spotlight Developer Download page: [Spotlight Developer]
Release date: 2016-02-14
-Support Version: 2008/2012/2014
+Support Version: 2008-2014
Developer: Spotlight Essentials
Free version: Yes
Price: No @@ -372,8 +392,8 @@ You also get a FREE System health Check, Performance Health Analysis and compreh ## dbForge Source Control Download page: [dbForge Source Control]
-Release date: 2017-09-30
-Support Version: 2005/2008/2008R2/2012/2014/2016/2017
+Release date: 2019-10-10
+Support Version: 2005-2018
Developer: Devart
Free version: No
Price: $249 @@ -385,8 +405,8 @@ The tool can link your databases to all popular source control systems, and deli ## dbForge Unit Test Download page: [dbForge Unit Test]
-Release date: 2017-09-30
-Support Version: 2005/2008/2008R2/2012/2014/2016
+Release date: 2019-10-10
+Support Version: 2005-2018
Developer: Devart
Free version: No
Price: $199 @@ -399,24 +419,24 @@ dbForge Unit Test for SQL Server functionality allows you to develop stable and ## dbForge Data Pump Download page: [dbForge Data Pump]
-Release date: 2017-09-30
-Support Version: 2005/2008/2008R2/2012/2014/2016/2017
+Release date: 2019-10-10
+Support Version: 2008-2018
Developer: Devart
Free version: No
Price: $149 -dbForge Data Pump for SQL Server is an SSMS add-in for filling SQL databases with external source data and migrating data between systems. -The tool supports 10+ widely used data formats and includes a number of advanced options and templates for recurring scenarios. +dbForge Data Pump is an SSMS add-in for filling SQL databases with external source data and migrating data between systems. +The tool supports import and export from 10+ widely used data formats (Text, MS Excel, XML, CSV, JSON etc.) and includes a number of advanced options and templates for recurring scenarios. ## dbForge Index Manager Download page: [dbForge Index Manager]
-Release date: 2017-09-30
-Support Version: 2005/2008/2008R2/2012/2014/2016/2017
+Release date: 2021-09-10
+Support Version: 2008-2018
Developer: Devart
Free version: No
-Price: $99 +Price: $119 dbForge Index Manager for SQL Server is a handy SSMS add-in for analyzing the status of SQL indexes and fixing issues with index fragmentation. The tool allows you to quickly collect index fragmentation statistics and detect databases that require maintenance. @@ -427,8 +447,8 @@ dbForge Index Manager for SQL Server will significantly boost SQL Server perform ## dbForge Search Download page: [dbForge Search]
-Release date: 2017-09-30
-Support Version: 2005/2008/2008R2/2012/2014/2016/2017
+Release date: 2019-10-10
+Support Version: 2008-2018
Developer: Devart
Free version: Yes
Price: No @@ -441,8 +461,8 @@ With dbForge Object Search for SQL Server you no longer need to look through the ## dbForge Monitor Download page: [dbForge Monitor]
-Release date: 2017-04-20
-Support Version: 2008/2008R2/2012/2014/2016
+Release date: 2019-10-10
+Support Version: 2012-2018
Developer: Devart
Free version: Yes
Price: No @@ -456,11 +476,11 @@ Price: No ## dbForge SQL Complete Download page: [dbForge SQL Complete]
-Release date: 2017-09-30
-Support Version: SQL Server Compact/SQL Azure/2000/2005/2008/2008R2/2012/2014/2016
+Release date: 2021-10-05
+Support Version: 2000-2018
Developer: Devart
Free version: Yes
-Price: $149 +Price: $199 dbForge SQL Complete provides a wide range of code completion features that relieve users from remembering long and complex object names, column names, SQL operators, etc., but instead allows concentrating on writing high-quality SQL code with proper formatting that is easy to understand and interpret. @@ -470,7 +490,7 @@ column names, SQL operators, etc., but instead allows concentrating on writing h ## SoftTree SQL Assistant Download page: [SoftTree SQL Assistant]
Release date: 2016-03-18
-Support Version: 2008/2012/2014
+Support Version: 2008-2014
Developer: SoftTree
Free version: No
Price: $179 @@ -482,7 +502,7 @@ SQL Assistant equips database developers and DBAs with the productivity tools th ## SQL Enlight for SSMS Download page: [SQL Enlight for SSMS]
Release date: 2016-04-25
-Support Version: 2008/2012/2014
+Support Version: 2008-2014
Developer: UbitSoft
Free version: No
Price: $195 @@ -500,7 +520,7 @@ Price: $195 ## SQL Hunting Dog Download page: [SQL Hunting Dog]
Release date: 2016-03-03
-Support Version: 2008/2012/2014
+Support Version: 2008-2014
Developer: Alex Maslyukov
Free version: Yes
Price: No @@ -515,7 +535,7 @@ Price: No ## Poor Mans T-SQL Formatter Download page: [Poor Mans T-SQL Formatter]
Release date: 2013-10-23
-Support Version: 2008/2012
+Support Version: 2008-2012
Developer: Tao Klerks
Free version: Yes
Price: No @@ -528,7 +548,7 @@ It does not distinguish between different types of DML, it does not parse full e ## Tabs Studio Download page: [Tabs Studio]
Release date: 2017-08-24
-Support Version: 2012/2014/2016/2017
+Support Version: 2012-2017
Developer: Vlasov Studio
Free version: No
Price: $49 @@ -549,7 +569,7 @@ Tabs Studio is a Visual Studio and SSMS extension empowering you to work comfort ## Workload Addin Download page: [Workload Addin]
Release date: 2017-02-07
-Support Version: 2008/2012
+Support Version: 2008-2012
Developer: Tomáš Bauer
Free version: Yes
Price: No @@ -565,7 +585,7 @@ This tool can automatically collect information about executed SQL statements an ## SQL Server Diagnostics Download page: [SQL Server Diagnostics]
Release date: 2017-06-22
-Support Version: 2016/2017
+Support Version: 2016-2017
Developer: Microsoft
Free version: Yes
Price: No @@ -577,7 +597,7 @@ SQL Server Diagnostics is a collection of micro-services which enables SQL Serve ## VersionSQL Download page: [VersionSQL]
Release date: 2017-02-16
-Support Version: 2012/2014/2016/2017
+Support Version: 2012-2017
Developer: VersionSQL
Free version: Yes
Price: $149 @@ -585,18 +605,154 @@ Price: $149 Lightweight add-in to connect your databases to your source control system + +## Spotlight Tuning Pack +Download page: [Spotlight Tuning Pack]
+Release date: 2018-06-01
+Support Version: 2012-2017
+Developer: Quest Software Inc
+Free version: Yes
+Price: $180 + +Powerful SQL optimization and query plan analysis. +The analysis will indicate whether the Query Plan can be tuned to improve performance, or whether the SQL Statement can be rewritten to optimize its efficiency. + + + +## Michel Max - SSMS Tools +Download page: [Michel Max - SSMS Tools]
+Release date: 2018-11-16
+Support Version: 2012-2018
+Developer: Michel Max
+Free version: Yes
+Price: No + + - Format SQL Code. + - Prepare the Procedures/Functions to be called. + - Regions to organize the code. + - Retrieve the complete Information of a Table. + - Tab Colorize, base in the configuration window you can colorize the existing session based in the filters that you applied, making easy to the developer to identify each server/database he/she is working on. + - Selection Highlight for the same word in the SQL Code. + - Style Markers for the same word in the SQL Code. + - Configurable CRUD creation. + - Copy/Paste Table Structure and Data (Client Side). + - Grid Search, with advanced Extended and Regular Expression. + - Grid Search Highlight. + - Grid Style Markers. + - Grid Export to JSON, Excel XML. + - Grid Image Capture. + - Configurable Header Text Template, with quick insert, so you can easily sign you codes. + - Quick encapsulate code in region. + +Other versions: + - https://sourceforge.net/projects/michelmaxssmstools2012/ + - https://sourceforge.net/projects/michelmaxssmstools2014/ + - https://sourceforge.net/projects/michelmaxssmstools2016/ + - https://sourceforge.net/projects/michelmaxssmstools2017/ + - https://sourceforge.net/projects/michelmaxssmstools2019/ + + + +## SSMS Schema Folders +Download page: [SSMS Schema Folders]
+Release date: 2018-10-06
+Support Version: 2012-2018
+Developer: Michel Max
+Free version: Yes
+Price: No + +This an extension for SQL Server Management Studio 2012, 2014, 2016 and 17. +It groups sql objects in Object Explorer (tables, views, etc.) into schema folders. + + + +## Statistics Reporter +Download page: [Statistics Reporter]
+Release date: 2019-04-17
+Support Version: 2014-2018
+Developer: Analytics Bar
+Free version: Yes
+Price: No + +Statistics Reporter SSMS Extension is a SQL Server Management Studio Add-in for parsing SET STATISTICS IO, TIME ON into a beautiful report. + + +## SSMS Lizard +Download page: [SSMS Lizard]
+Release date: 2020-06-15
+Support Version: 2018-2018
+Developer: Lizard Labs Software
+Free version: Yes
+Price: No + +SSMS Lizard extends SQL Server Management Studio with a number of new features not previously seen on its user interfaces: + +- Show query results in advanced data grid (sorting, grouping, searching, filtering, tabs, conditional formatting, formula fields, column chooser, bookmarks, split view, etc...) +- Extend SQL quires with in-line Visual Basic (VB.Net) code. +- Print or export data to Excel, Word, PDF, HTML, TSV, CSV, RTF or TXT documents. +- Quickly attach the query results to an e-mail, FTP or even Google Drive with a single click of a button; and more. + + + +## SSMS Object Explorer Menu +Download page: [SSMS Object Explorer Menu]
+Release date: 2023-07-10
+Support Version: 2018-2023
+Developer: Daniel Brink
+Free version: Yes
+Price: No + +SSMS extension for adding custom menu items to the Object Explorer's right-click context menu. + + +## SQL Shades +Download page: [SQL Shades]
+Release date: 2022-08-03
+Support Version: 18+
+Developer: Wrism Innovations
+Free version: Yes
+Price: No + +Adds a true dark theme to SSMS. + + +## Axial SQL Tools +Download page: [Axial SQL Tools]
+Release date: 2025-01-26
+Support Version: 20+
+Developer: Alex Bochkov
+Free version: Yes
+Price: No + +Axial SQL Tools is a productivity add-in for SQL Server Management Studio 20/21, designed to streamline your workflow and address common limitations in SSMS. Built from the personal experience of a seasoned SQL Server engineer, this tool incorporates community feedback to continuously improve and simplify routine tasks. + +Main Features: +- Transaction Warning: Instantly see if you’ve left any transactions open. +- Precise Execution Time: Monitor query execution times down to the millisecond on the status bar. +- Format Any TSQL Code: Validate and format your TSQL code using the Microsoft TSQL parser for improved readability. +- Query Templates and Snippets: Access a library of query templates for common tasks, saving time on routine queries. +- Export Grid to Excel: Quickly export grid results directly into an Excel file. +- Export Grid to Email: Export grid results and send the file via email directly from SSMS. +- Export Grid as Temp Table: Convert grid results into temporary tables using generated INSERT statements. +- Script Selected Object Definition: Easily generate scripts for the definitions of selected objects from your query. +- Server Health Dashboard: Get a quick overview of the server’s key metrics. +- Right Alignment for Numeric Values in Grid: Automatically align numeric values to the right in the grid for better readability. +- BULK Data Transfer Between Two Open Connections: Seamlessly transfer bulk data between two open connections with a single click. +- Query History: Maintain a detailed log of executed queries for auditing and easy retrieval. + + [SSMSBoost]:http://www.ssmsboost.com/ +[SQL Refactor Studio]: https://sqlrefactorstudio.com/ [SqlSmash]:http://www.sqlsmash.com/ [Red Gate SQL Code Guard]:https://www.red-gate.com/products/sql-development/sql-code-guard/ [SQL Search]:http://www.red-gate.com/products/sql-development/sql-search/ -[SQL Scripts Manager]:http://www.red-gate.com/products/dba/sql-scripts-manager/ [Red Gate SQL Test]:http://www.red-gate.com/products/sql-development/sql-test/ [Red Gate SQL Source Control]:http://www.red-gate.com/products/sql-development/sql-source-control/ [Supratimas]:http://www.supratimas.com/Home/Downloads [dbForge SQL Complete]:https://www.devart.com/dbforge/sql/sqlcomplete/ordering.html [SSMS Tools Pack]:http://www.ssmstoolspack.com/Features [SQL Pretty Printer]:http://www.excel-sql-server.com/excel-sql-server-import-export-using-excel-add-ins.htm -[SQL Sentry Plan Explorer]:https://www.sqlsentry.com/products/plan-explorer/sql-server-query-view +[SQL Sentry Plan Explorer]:https://www.sentryone.com/plan-explorer [TSQL Code Smells Finder]:https://tsqlsmells.codeplex.com/releases/view/101979 [SQLTreeo]:http://www.sqltreeo.com/ [ApexSQL Complete]:http://www.apexsql.com/sql_tools_complete.aspx @@ -614,13 +770,21 @@ Lightweight add-in to connect your databases to your source control system [dbForge SQL Complete]:https://www.devart.com/dbforge/sql/sqlcomplete/ [SoftTree SQL Assistant]:http://www.softtreetech.com/isql.htm [SQL Enlight for SSMS]:http://www.ubitsoft.com/products/sqlenlight-for-ssms/index.php -[SQL Hunting Dog]:http://sql-hunting-dog.com/ +[SQL Hunting Dog]:http://www.sql-hunting-dog.com/ [Poor Mans T-SQL Formatter]:http://architectshack.com/PoorMansTSqlFormatter.ashx [Tabs Studio]:https://tabsstudio.com [Workload Addin]:https://www.codeproject.com/Articles/1188027/Capture-of-a-Typical-SQL-Server-Database-Workload [SQL Server Diagnostics]:https://blogs.msdn.microsoft.com/sql_server_team/sql-server-diagnostics-preview/ [VersionSQL]:https://www.versionsql.com/ +[Spotlight Tuning Pack]:https://www.spotlightcloud.io/spotlight-cloud-tuning-pack +[Michel Max - SSMS Tools]:https://sourceforge.net/projects/michelmaxssmstools2017/ +[SSMS Schema Folders]:https://github.com/nicholas-ross/SSMS-Schema-Folders +[Statistics Reporter]:https://analyticsbar.com/blog/statistics-reporter-ssms-extension/ +[SSMS Object Explorer Menu]:https://github.com/brink-daniel/ssms-object-explorer-menu [SQL_Search Download]:https://download.red-gate.com/SQL_Search.exe [Apex SQL Search Download]:https://www.apexsql.com/zips/ApexSQLSearch.exe [DbForge Search Download]:https://www.devart.com/dbforge/sql/search/searchsql22std.exe +[SSMS Lizard]:https://www.lizard-labs.com/sql_server_management_studio_ssms_extesnsion_lizard.aspx +[SQL Shades]:https://www.sqlshades.com/ +[Axial SQL Tools]:(https://github.com/Axial-SQL/AxialSqlTools) diff --git a/SSMS/SSMS_Errors.md b/SSMS/SSMS_Errors.md new file mode 100644 index 00000000..9aa198e8 --- /dev/null +++ b/SSMS/SSMS_Errors.md @@ -0,0 +1,14 @@ +# SSMS known errors and bugs + +- [What to Do When You Get a "Cache is Out of Date" Error Message](https://www.databasejournal.com/features/mssql/what-to-do-when-you-get-a-cache-is-out-of-date-error-message.html) +- [CTRL+R does not hide the Query Result window in SSMS](https://stackoverflow.com/questions/17068661/ctrlr-does-not-hide-the-query-result-window-in-ssms) +- [SQL SERVER – Unable to Launch SSMS Error – Cannot Find One or More Components. Please Reinstall the Application](https://blog.sqlauthority.com/2017/12/06/sql-server-unable-launch-ssms-error-cannot-find-one-components-please-reinstall-application/) +- [Object Reference Not Set to an Instance of an Object’ When Failing Over an Availability Group Using SSMS <= 17.5](https://sqlundercover.com/2018/03/29/object-reference-not-set-to-an-instance-of-an-object-when-failing-over-an-availability-group-using-ssms-17-5/) +- [File Growth Rate – The GUI Lies](https://sqlrus.com/2018/06/file-growth-rate-the-gui-lies/) +- [SSMS: Allow forcing case-insensitive matching in Object Explorer filters](https://feedback.azure.com/forums/908035-sql-server/suggestions/36679522-ssms-allow-forcing-case-insensitive-matching-in-o) +- [SSMS: Object Explorer Filtering allows for SQL Injection (oops)](https://feedback.azure.com/forums/908035-sql-server/suggestions/36678803-ssms-object-explorer-filtering-allows-for-sql-inj) +- [SSMS won't open scripts on double-click](https://stackoverflow.com/q/1726577/2298061) +- [SSMS Crash While Using Backup to URL or Connecting to Storage](https://blog.sqlauthority.com/2018/10/09/sql-server-sql-server-management-studio-crash-while-using-backup-to-url-or-connecting-to-storage/) +- [Error in SSMS: Attempted to read or write protected memory.](https://sqlstudies.com/2019/02/18/error-in-ssms-attempted-to-read-or-write-protected-memory/) +- [SSMS Sequence Contains No Elements](https://thomaslarock.com/2020/01/sequence-contains-no-elements/) +- [SQL Server Management Studio Connection to Integration Services Error Class Not Registered](https://www.mssqltips.com/sqlservertip/6479/sql-server-management-studio-connection-to-integration-services-error-class-not-registered/) diff --git a/SSMS/SSMS_Tips.md b/SSMS/SSMS_Tips.md index 3ee4d86d..01f6acaa 100644 --- a/SSMS/SSMS_Tips.md +++ b/SSMS/SSMS_Tips.md @@ -1,10 +1,26 @@ # SQL Server Management Studio Tips Most tips works for SSMS higher 2008 but some of them only works for SSMS 2016 and above -Content: +## Road map + - [ ] https://blogs.technet.microsoft.com/dataplatforminsider/2018/02/20/whats-new-in-ssms-17-5-data-discovery-and-classification/ + - [ ] https://bertwagner.com/2018/02/27/splitting-it-up-easy-side-by-side-queries-in-ssms/ + - [ ] https://sqlrus.com/2018/03/ssms-output-window/ + - [ ] https://www.sqlshack.com/whats-new-in-ssms-17-5-data-discovery-and-classification-and-more/ + - [ ] Add gifs or images for all tips + - [ ] Add some tips from excellent ebook http://insiders.sqldownunder.com/ssms-tips-and-tricks/ + - [ ] Add Memory Optimiser Advisor tip https://www.red-gate.com/simple-talk/sql/t-sql-programming/converting-database-memory-oltp/ + - [ ] Add Removing Connections from the SSMS connection dialog https://blog.waynesheffield.com/wayne/archive/2018/05/removing-servers-ssms-connection-dialog/ + - [ ] Add Save the Connection String Parameters http://www.sqlservercentral.com/blogs/sql-geek/2018/07/26/save-the-connection-string-parameters-in-ssms-alwayson/ + - [ ] Analyze Actual Execution Plan https://www.scarydba.com/2018/08/06/analyze-actual-execution-plan/ + - [ ] Compare Actual Execution Plans + - [ ] [Database Upgrade using the Query Tuning Assistant wizard in SSMS 18](https://www.sqlshack.com/database-upgrade-using-the-query-tuning-assistant-wizard-in-ssms-18/) + - [ ] [Export Data From SSMS Query to Excel](https://blog.sqlauthority.com/2019/01/16/sql-server-export-data-from-ssms-query-to-excel/) + - [ ] [Starting SSMS with a specific connection and script file](http://dbamastery.com/tips/ssms-cmdline-utility/) + +**Table of Content**: 1. [Import and Export Settings](#1) 2. [SSMS Shortcuts](#2) -3. [Keyboard Shortcuts for Favorite Stored Procedures](#3) +3. [Keyboard Shortcuts for Favorite Stored Procedures and Scripts](#3) 4. [SSMS Scripting Option](#4) 5. [Selecting a block of text using the ALT Key](#5) 6. [Script Table and Column Names by Dragging from Object Explorer](#6) @@ -37,38 +53,53 @@ Content: 33. [Working with Azure SQL](#33) 34. [Using Extended Events and Profiler in SSMS](#34) 35. [Vulnerability Assessment in SSMS](#35) -36. [Reference](#reference) - - -Great thanks to: - - Kendra Little ([b](http://www.littlekendra.com/) | [t](https://twitter.com/Kendra_Little)) - - Slava Murygin ([b](http://slavasql.blogspot.ru/)) - - Mike Milligan ([b](http://www.bidn.com/Blogs/userid/43/author/mike-milligan)) - - Kenneth Fisher ([b](https://twitter.com/sqlstudent144) | [t](https://twitter.com/sqlstudent144)) - - William Durkin ([b](http://www.williamdurkin.com/) | [t](https://twitter.com/sql_williamd)) - - John Morehouse ([b](http://sqlrus.com/) | [t](http://twitter.com/sqlrus)) - - Phil Factor ([b](https://www.red-gate.com/simple-talk/author/phil-factor/) | [t](https://twitter.com/phil_factor)) - - Klaus Aschenbrenner ([b](https://www.sqlpassion.at/) | [t](https://twitter.com/Aschenbrenner)) - - Latish Sehgal ([b](http://www.dotnetsurfers.com/)) - - Arvind Shyamsundar ([b](https://blogs.msdn.microsoft.com/arvindsh/)) - - [SQLMatters](http://www.sqlmatters.com/) - - [MSSQLTips](https://www.mssqltips.com/) - - Anthony Zanevsky, Andrew Zanevsky and Katrin Zanevsky - - Andy Mallon ([b](http://www.am2.co/) | [t](https://twitter.com/AMtwo)) - - Aaron Bertrand ([b](http://sqlperformance.com/author/abertrand) | [t](https://twitter.com/AaronBertrand)) - - Daniel Calbimonte ([b](https://www.sqlshack.com/author/daniel-calbimonte/) | [t](https://twitter.com/dcalbimonte)) - - Ahmad Yaseen ([b](https://www.sqlshack.com/author/ahmad-yaseen/) | [t](https://twitter.com/AhmadZYaseen)) - - Solomon Rutzky ([b](https://sqlquantumleap.com/) | [t](https://twitter.com/SqlQuantumLeap)) - - Bert Wagner ([b](https://blogs.sentryone.com) | [t](https://twitter.com/bertwagner)) - - Thomas LaRock ([b](https://thomaslarock.com/) | [t](https://twitter.com/SQLRockstar)) +36. [Import Flat File to SQL Wizard](#36) +37. [AutoRecover in SSMS](#37) +38. [View and query Power BI .pbix files in SSMS](#38) +39. [Using SSMS to analyze Power BI with XMLA](#39) +40. [SSMS shortcut to comment/uncomment a specific part of the query](#40) +41. [Reference](#reference) + + +**Great thanks to**: +- Kendra Little ([b](http://www.littlekendra.com/) | [t](https://twitter.com/Kendra_Little)) +- Slava Murygin ([b](http://slavasql.blogspot.ru/)) +- Mike Milligan ([b](http://www.bidn.com/Blogs/userid/43/author/mike-milligan)) +- Kenneth Fisher ([b](https://twitter.com/sqlstudent144) | [t](https://twitter.com/sqlstudent144)) +- William Durkin ([b](http://www.williamdurkin.com/) | [t](https://twitter.com/sql_williamd)) +- John Morehouse ([b](http://sqlrus.com/) | [t](http://twitter.com/sqlrus)) +- Phil Factor ([b](https://www.red-gate.com/simple-talk/author/phil-factor/) | [t](https://twitter.com/phil_factor)) +- Klaus Aschenbrenner ([b](https://www.sqlpassion.at/) | [t](https://twitter.com/Aschenbrenner)) +- Latish Sehgal ([b](http://www.dotnetsurfers.com/)) +- Arvind Shyamsundar ([b](https://blogs.msdn.microsoft.com/arvindsh/)) +- [SQLMatters](http://www.sqlmatters.com/) +- [MSSQLTips](https://www.mssqltips.com/) +- Anthony Zanevsky, Andrew Zanevsky and Katrin Zanevsky +- Andy Mallon ([b](http://www.am2.co/) | [t](https://twitter.com/AMtwo)) +- Aaron Bertrand ([b](http://sqlperformance.com/author/abertrand) | [t](https://twitter.com/AaronBertrand)) +- Daniel Calbimonte ([b](https://www.sqlshack.com/author/daniel-calbimonte/) | [t](https://twitter.com/dcalbimonte)) +- Ahmad Yaseen ([b](https://www.sqlshack.com/author/ahmad-yaseen/) | [t](https://twitter.com/AhmadZYaseen)) +- Solomon Rutzky ([b](https://sqlquantumleap.com/) | [t](https://twitter.com/SqlQuantumLeap)) +- Bert Wagner ([b](https://bertwagner.com/category/sql.html) | [t](https://twitter.com/bertwagner)) +- Thomas LaRock ([b](https://thomaslarock.com/) | [t](https://twitter.com/SQLRockstar)) +- Jen Mccown ([b](http://www.midnightdba.com/Jen/author/jen/)) +- Louis Davidson ([b](https://www.red-gate.com/simple-talk/author/louis-davidson/) | [t](https://twitter.com/drsql)) +- Solomon Rutzky ([b](https://sqlquantumleap.com) | [t](https://twitter.com/srutzky)) +- Michelle Haarhues ([b](https://witsociety.wordpress.com/) | [t](https://twitter.com/mhaarhues)) +- Christian Wade ([b](https://witsociety.wordpress.com/) | [t](https://twitter.com/_christianWade)) +- Kellyn Pot’Vin-Gorman ([b](https://dbakevlar.com/) | [t](https://twitter.com/DBAKevlar)) +- Kevin Feasel ([b](https://36chambers.wordpress.com) | [t](https://twitter.com/feaselkl)) +- Brent Ozar ([b](https://www.brentozar.com/) | [@BrentO](https://twitter.com/BrentO)) -## Import and Export Settings +## 1. Import and Export Settings `Tools > Options > Environment > Import and Export Settings` +Default settings (if you need to compare with yours) you can find here: [SSMS settings files](https://github.com/ktaranov/sqlserver-kit/tree/master/SSMS/SSMS_vssettings) + You can configure so many settings in SSMS and then export it and use on all your computers. -Below link provide detailed instruction and awesome Dark theme configuration: [Making SSMS Pretty: My Dark Theme](https://blogs.sentryone.com/aaronbertrand/making-ssms-pretty-my-dark-theme/) +Below link provide detailed instruction and awesome Dark theme configuration: [Making SSMS Pretty: My Dark Theme](https://www.sentryone.com/blog/aaronbertrand/making-ssms-pretty-my-dark-theme/) Also you can create shared team settings file and use it from network location. Detailed information you can find in this article [Symbolic Links for Sharing Template Files or "How I Broke Management Studio with Symbolic Links"](http://sqlmag.com/sql-server/symbolic-links-sharing-template-files-or-how-i-broke-management-studio-symbolic-links) @@ -77,70 +108,83 @@ Detailed information you can find in this article [Symbolic Links for Sharing Te -## SSMS Shortcuts -All shortcuts you can find [here](https://github.com/ktaranov/sqlserver-kit/blob/master/SSMS/SSMS_Shortcuts.md) +## 2. SSMS Shortcuts +All shortcuts you can find [here](https://github.com/ktaranov/sqlserver-kit/blob/master/SSMS/SSMS_Shortcuts.md). Known problem for SSMS 2012 and 2014: [CTRL+R does not hide the Query Result window in SSMS] +Create custom shortcut as simple as possible: +1. `Tools > Options > Environment > Keyboard` +2. Use the search bar `Show Commands Containing` to find and select the command. +3. In `Press Shortcut Keys`, press the shortcut combination you want to use. +4. Click `Assign`. If you don’t click `Assign`, and just click `OK`, your shortcut won’t be assigned. +5. Click `OK`. (Note that some shortcut changes take effect in query windows you open after the change.) +More details here: [MANAGEMENT STUDIO SHORTCUT – CHANGE CONNECTION](http://www.midnightdba.com/Jen/2018/03/management-studio-shortcut-change-connection/) + Most useful are: -| Shortcut | Description | -|-----------------------|----------------------------------------| -| `Ctrl + U` | Change Selected Database | -| `Ctrl + R` | Toggle Results Pane | -| `Ctrl + Space` | Activate Autocomplete | -| `Ctrl + Shift + V` | [Cycle through clipboard ring] | -| `Ctrl + ]` | Navigate to matching parenthesis | -| `Ctrl + –` | Navigate to last cursor location | -| `Ctrl + Shift + –` | Navigate forward to cursor location | -| `Ctrl + K, Ctrl + C` | Comments selected text | -| `Ctrl + K, Ctrl + U` | Uncomments selected text | -| `Ctrl + K, Ctrl + K` | Toggle Bookmark | -| `Ctrl + K, Ctrl + N` | Go to Next Bookmark | -| `Ctrl + L` | Display Estimated Query Execution plan | -| `Shift + Alt + Enter` | View Code Editor in Full Screen | -| `Ctrl + I` | Quick Search | -| `Ctrl + F4` | Close the current MDI child window | -| `Ctrl + F5` | Parse query to check for errors | -| `Shift + F10` | Simulate right mouse button | -| `Ctrl + Alt + T` | Display Template Explorer | -| `Ctrl + Shift + M` | Specify values for template parameters | -| `Ctrl + Shift + R` | Refresh local cache | -| `Ctrl + Alt + S` | Include Client Statistics | +| Shortcut | Description | +|--------------------------------|----------------------------------------| +| Ctrl + U | Change Selected Database | +| Ctrl + R | Toggle Results Pane | +| Ctrl + Space | Activate Autocomplete | +| Ctrl + Shift + V | [Cycle through clipboard ring] | +| Ctrl + ] | Navigate to matching parenthesis | +| Ctrl + – | Navigate to last cursor location | +| Ctrl + Shift + – | Navigate forward to cursor location | +| Ctrl + K, Ctrl + C | Comments selected text | +| Ctrl + K, Ctrl + U | Uncomments selected text | +| Ctrl + K, Ctrl + K | Toggle Bookmark | +| Ctrl + K, Ctrl + N | Go to Next Bookmark | +| Ctrl + L | Display Estimated Query Execution plan | +| Shift + Alt + Enter | View Code Editor in Full Screen | +| Ctrl + I | Quick Search | +| Ctrl + F4 | Close the current MDI child window | +| Ctrl + F5 | Parse query to check for errors | +| Shift + F10 | Simulate right mouse button | +| Ctrl + Alt + T | Display Template Explorer | +| Ctrl + Shift + M | Specify values for template parameters | +| Ctrl + Shift + R | Refresh local cache | +| Ctrl + Alt + S | Include Client Statistics | -## Keyboard Shortcuts for Favorite Stored Procedures +## 3. Keyboard Shortcuts for Favorite Stored Procedures and Scripts +A query shortcut allows you to execute code simply by hitting Ctrl and a number key. Cool. But first, there are a few things to know about query shortcuts: + +1. The window in SSMS where you configure the query shortcuts has the text field for the shortcut labeled as **Stored Procedure**, which is misleading because you can specify a query. You can even specify multiple queries. +2. Whatever you specify needs to be a single line: no newlines / CRLFs. Any text past the first return will be truncated. +3. When using the keyboard query shortcuts, if nothing is highlighted then only the code in the shortcut is executed. But, if any T-SQL is highlighted when you execute the shortcut, then the highlighted code is executed after the code stored in the shortcut finishes. Adding a `RETURN;` at the end of the shortcut simply stops the processing after the code stored in the shortcut finishes. BUT, if anything is highlighted when you execute a query shortcut, it is still parsed, even if not executed. Hence, you can still get parse errors even with the `RETURN;` added at the end. + `Tools > Options > Environment > Keyboard > Query Shortcuts` ![Keyboard Shortcuts for Favorite Stored Procedures](/SSMS/SSMS_Tips/keyboard_shortcuts_for_stored_procedures.png) -3 Shortcuts can not be changed: `Alt + F1`, `Ctrl + 1` and `Ctrl + 2`. -For another 9 shortcuts my recommendation awesome open source Brent Ozar teams procedures and with some limitations Adam Machanic `sp_WhoIsActive`: - -| Query Shortcut | Stored Procedure | -|----------------|----------------------| -| `Alt + F1` | [sp_help] | -| `Ctrl + F1` | [sp_WhoIsActive] | -| `Ctrl + 1` | [sp_who] | -| `Ctrl + 2` | [sp_lock] | -| `Ctrl + 3` | [sp_Blitz] | -| `Ctrl + 4` | [sp_BlitzCache] | -| `Ctrl + 5` | [sp_BlitzWho] | -| `Ctrl + 6` | [sp_BlitzQueryStore] | -| `Ctrl + 7` | [sp_BlitzFirst] | -| `Ctrl + 8` | [usp_BulkUpload] | -| `Ctrl + 9` | [sp_BlitzTrace] | -| `Ctrl + 0` | [sp_foreachdb] | +3 Shortcuts can not be changed: Alt + F1 - [sp_help], Ctrl + 1 - [sp_who] and Ctrl + 2 - [sp_lock]. +For another 9 shortcuts my recommendation awesome open source Brent Ozar teams procedures and with some limitations in License usage Adam Machanic [sp_WhoIsActive]: + +| Query Shortcut | Stored Procedure | +|-------------------------|----------------------| +| Alt + F1 | [sp_help] | +| Ctrl + F1 | [`sp_WhoIsActive`] | +| Ctrl + 1 | [sp_who] | +| Ctrl + 2 | [sp_lock] | +| Ctrl + 3 | [sp_Blitz] | +| Ctrl + 4 | [sp_BlitzCache] | +| Ctrl + 5 | [sp_BlitzWho] | +| Ctrl + 6 | [sp_BlitzQueryStore] | +| Ctrl + 7 | [sp_BlitzFirst] | +| Ctrl + 8 | [usp_BulkUpload] | +| Ctrl + 9 | [sp_BlitzTrace] | +| Ctrl + 0 | [sp_foreachdb] | Also recommended: - - [sp_BlitzRS] - [sp_DatabaseRestore] - [usp_BulkUpload] [sp_help]:https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-help-transact-sql [sp_who]:https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-who-transact-sql [sp_lock]:https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-lock-transact-sql -[sp_WhoIsActive]:http://whoisactive.com +[`sp_WhoIsActive`]:http://whoisactive.com [sp_Blitz]:https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/blob/dev/sp_Blitz.sql [sp_BlitzBackups]:https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/blob/dev/sp_BlitzBackups.sql [sp_BlitzCache]:https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/blob/dev/sp_BlitzCache.sql @@ -154,42 +198,90 @@ Also recommended: [sp_foreachdb]:https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/blob/dev/sp_foreachdb.sql [usp_BulkUpload]:https://github.com/ktaranov/sqlserver-kit/blob/master/Stored_Procedure/usp_BulkUpload.sql +### Some useful shortcuts for `sp_WhoIsActive` from Kevin Feasel +More details [here](https://36chambers.wordpress.com/2019/04/02/whoisactive-in-ssms/). + +What’s Going On shortcut? +```tsql +EXEC sp_whoisactive + @get_full_inner_text = 1 + , @get_outer_command = 1 + , @find_block_leaders = 1 + , @get_task_info = 2 + , @get_transaction_info = 1 + , @get_plans = 0 + , @output_column_list = '[session_id][login_name][dd%][CPU][reads][writes][wait_info][blocking_session_id][blocked_session_count][sql_text][sql_command][status][tempdb_%][%]' + , @sort_order = '[session_id]'; +``` + +And here it is in a little bit nicer of a format so we can cover it: +```tsql +EXEC sp_whoisactive + @get_full_inner_text = 1 + , @get_outer_command = 1 + , @find_block_leaders = 1 + , @get_task_info = 2 + , @get_transaction_info = 1 + , @get_plans = 0 + , @output_column_list = '[session_id][login_name][dd%][CPU][reads][writes][wait_info][blocking_session_id][blocked_session_count][sql_text][sql_command][status][tempdb_%][%]' + , @sort_order = '[session_id]'; +``` + +When you need to get execution plans, that’s when I break out Ctrl+4. Here is the one-liner: +```tsql +EXEC sp_whoisactive + @get_full_inner_text = 1 + , @get_outer_command = 1 + , @find_block_leaders = 1 + , @get_task_info = 2 + , @get_transaction_info = 1 + , @get_plans = 1 + , @output_column_list = '[session_id][login_name][dd%][CPU][reads][writes][wait_info][blocking_session_id][blocked_session_count][sql_text][sql_command][status][tempdb_%][%]' + , @sort_order = '[session_id]'; +``` -## SSMS Scripting Option +## 4. SSMS Scripting Option ### Script any object with data `Right click on database name > Tasks > Generate Scripts …` ![Script any object with data](/SSMS/SSMS_Tips/ssms_script_objects.gif) + ### The Default Scripting Option In the previous SQL Server Management Studio versions, the generated script will target the latest released SQL Server version. -In SSMS 17.2, the `Match Script Settings to Source` has been added, with the default `True` value means that the generated script will target the source SQL Server instance’s version, edition, and engine type, where the `False` value will force the scripting to behave as the previous SSMS versions. +Starting SSMS 17.2, the `Match Script Settings to Source` has been added, with the default `True` value means that the generated script will target the source SQL Server instance’s version, edition, and engine type, where the `False` value will force the scripting to behave as the previous SSMS versions. `Tools > Options > SQL Server Object Explore > Scripting > Version Options > Match Script Settings to Source` More details here: [What’s new in SQL Server Management Studio 17.2; Authentication methods, scripting options and more] +![Script for SQL Server version](/SSMS/SSMS_Tips/ssms_script_objects_server_version.png) + -## Selecting a block of text using the ALT Key +## 5. Selecting a block of text using the ALT Key By holding down the ALT key as you select a block of text you can control the width of the selection region as well as the number of rows. Also you can activate multi line mode with `Shift + Alt` keys and using keyboard arrows to format multi line code. More info and video about this awesome feature in this article: [My Favorite SSMS Shortcut (After Copy/Paste)](https://bertwagner.com/2017/11/28/multiline-edit-block-selection-alt-highlight-trick/) (by Bert Wagner) +![SSMS Selecting a block of text using the ALT Key](/SSMS/SSMS_Tips/05_ALT+Arrow.gif) + +![SSMS Paste values into a template of commands](/SSMS/SSMS_Tips/05_ALT+PASTE.gif) + -## Script Table and Column Names by Dragging from Object Explorer +## 6. Script Table and Column Names by Dragging from Object Explorer Save keystrokes by dragging Drag the `Columns` folder for a table in to auto-type all column names in the table in a single line. - - Warning: this doesn’t include [brackets] around the column names, so if your columns contain spaces or special characters at the beginning, this shortcut isn’t for you + - Warning: this doesn’t include square [brackets] around the column names for SSMS below 17 version, so if your columns contain spaces or special characters at the beginning, this shortcut isn’t for you - Dragging the table name over will auto-type the schema and table name, with brackets. -## Disable Copy of Empty Text +## 7. Disable Copy of Empty Text - Select a block of text to copy; - Move the cursor the place where you want to paste the code; @@ -202,7 +294,7 @@ This behavior can be disabled in SSMS: go to `Tools > Options > Text Editor > Al -## Client Statistics +## 8. Client Statistics When you enable that option for your session (`Ctrl + Alt + S`), SQL Server Management Studio will give you more information about the client side processing of your query. The Network Statistics shows you the following information: @@ -219,7 +311,7 @@ The Time Statistics additionally shows you the following information: -## Configure Object Explorer to Script Compression and Partition Schemes for Indexes +## 9. Configure Object Explorer to Script Compression and Partition Schemes for Indexes Is this index compressed or partitioned? By default, you wouldn’t know just by scripting out the index from Object Explorer. If you script out indexes this way to check them into source code, or to tweak the definition slightly, this can lead you to make mistakes. @@ -233,7 +325,7 @@ You can make sure you’re aware when indexes have compression or are partitione -## Using GO X to Execute a Batch or Statement Multiple Times +## 10. Using GO X to Execute a Batch or Statement Multiple Times The `GO` command marks the end of a batch of statements that should be sent to SQL Server for processing, and then compiled into a single execution plan. By specifying a number after the `GO` the batch can be run specified number of times. This can be useful if, for instance, you want to create test data by running an insert statement a number of times. Note that this is not a Transact SQL statement and will only work in Management Studio (and also SQLCMD or OSQL). For instance the following SQL can be run in SSMS : @@ -257,7 +349,7 @@ In this case this is a simpler alternative than creating a cursor or while loop. -## SSMS Template Replacement +## 11. SSMS Template Replacement One under-used feature of Management Studio is the template replacement feature. SSMS comes with a library of templates, but you can also make your own templates for reusable scripts. In your saved .sql script, just use the magic incantation to denote the parameters for replacement. The format is simple: `` @@ -266,7 +358,7 @@ Then, when you open the `.sql` script, you hit `CTRL + Shift + M`, and SSMS will -## Color coding of connections +## 12. Color coding of connections SQL Server Management Studio has the capability of coloring the bar at the bottom of each query window, with the color dependent on which server is connected. This can be useful in order to provide a visual check of the server that a query is to be run against, for instance to color code production instances as red, development as green and amber as test. This can also be used in conjunction with Registered Servers and CMS (Central Management Server). @@ -275,25 +367,31 @@ Select the check box towards the bottom of the window and use the ‘Select… -## SQLCMD mode +## 13. SQLCMD mode Switching on SQLCMD mode enables a number of useful extra scripting style commands in SSMS. In particular you can use it to change to the connection credentials within the query window, so that you can run a query against multiple servers from the same query window. There are more details of how to do this here: [Changing the SQL Server connection within an SSMS Query Windows using SQLCMD Mode](http://www.sqlmatters.com/Articles/Changing%20the%20SQL%20Server%20connection%20within%20an%20SSMS%20Query%20Windows%20using%20SQLCMD%20Mode.aspx) +Also some great tips from Louis Davidson article: [Using SQLCMD, End Execution of SQL Commands in a File](https://www.red-gate.com/simple-talk/blogs/using-sqlcmd-end-execution-sql-commands-file/) +1. Making Sure You Don’t Accidentally Execute The Entire File By Mistake using `:EXIT` command in your scripts, details see here [sqlcmd Commands]. +2. Quitting the Statements of a File Based on a Condition using `:On Error[ exit | ignore]` command, details see here [sqlcmd Commands]. + +[sqlcmd Commands]:https://docs.microsoft.com/en-us/sql/tools/sqlcmd-utility?view=sql-server-2017#sqlcmd-commands + -## Script multiple objects using the Object Explorer Details Windows +## 14. Script multiple objects using the Object Explorer Details Windows Individual database objects, such as a table or stored procedure, can be scripted within SSMS by right clicking on the object within Object Explorer and selecting the appropriate item in the drop down menu. However if you have a lot of objects to script that can quickly become time consuming. Fortunately it’s possible to select multiple objects and script them up all together in a single query window. To do this just open the Object Explorer Details window from the View menu (or press the F7 key). If you want to script up multiple (or all) tables, select the Tables item under the relevant database in Object Explorer. A list of all tables appears in the Object Explorer Details window. -Select the tables you want to script (using the Control key if necessary) and then right click and select which script option you want – e.g. to create a table create script for all tables +Select the tables you want to script (using the Control key if necessary) and then right click and select which script option you want – e.g. to create a table create script for all tables. -## Registered Servers / Central Management Server +## 15. Registered Servers / Central Management Server If you have a lot of servers then re-entering the details in Object Explorer every time you start SSMS can be frustrating and time consuming. Fortunately there are two facilities within SSMS that enable these details to be entered just once and "remembered" each time you open up SSMS. These two facilities are **Registered Servers** and **Central Management Servers**. @@ -311,7 +409,7 @@ A significant limitation with CMS is that the CMS server itself can’t be inclu -## Splitting the Query Window and Annotations and Map Mode for Vertical Scroll Bar +## 16. Splitting the Query Window and Annotations and Map Mode for Vertical Scroll Bar The query window in SSMS can be split into two so that you can look at two parts of the same query simultaneously. Both parts of the split window can be scrolled independently. This is especially useful if you have a large query and want to compare different areas of the same query. To split the window simply drag the bar to the top right hand side of the window as shown below. @@ -320,26 +418,28 @@ The splitter bar allows you to view one session with two panes. You can scroll i ![Splitting the Query Window](/SSMS/SSMS_Tips/splitting_the_query_window.gif) -Also you can view some very useful features like annotations and Map mode, detailed instruction here: [SSMS Tip #1: Annotations and Map Mode for Vertical Scroll Bar] +Also you can view some very useful features like annotations and Map mode, detailed instruction: +1. [SSMS Tip #1: Annotations and Map Mode for Vertical Scroll Bar] +2. [SQL Server Management Studio Scroll Bar Enhancements](https://witsociety.wordpress.com/2018/12/13/sql-server-management-studio-scroll-bar-enhancements/) Annotations show the relative position of certain aspects of the script, such as errors, changes, etc. There are four types of annotations, the first three of which are shown in their own columns on the left side of the scroll bar: - - "Changes" are show in yellow (unsaved) and green (saved). These occupy the left column. - - "Marks" are shown in maroon (Breakpoints) and black (Bookmarks). These occupy the left column. - - "Errors" are shown in red. These occupy the right column. - - "Caret Position" is a thin, blue line going horizontally across the scroll bar. This represents the line of the script that the cursor is on. + - **"Changes"** are show in yellow (unsaved) and green (saved). These occupy the left column. + - **"Marks"** are shown in maroon (Breakpoints) and black (Bookmarks). These occupy the left column. + - **"Errors"** are shown in red. These occupy the right column. + - **"Caret Position"** is a thin, blue line going horizontally across the scroll bar. This represents the line of the script that the cursor is on. -## Moving columns in the results pane +## 17. Moving columns in the results pane It may not be immediately obvious but you can switch columns around in the results pane when using the grid view, by dragging the column headers and dropping them next to another column header. This can be useful if you want to rearrange how the results are displayed without amending the query, especially if you have a lot of columns in your result set. This works only for one column. -## Generating Charts and Drawings in SQL Server Management Studio +## 18. Generating Charts and Drawings in SQL Server Management Studio You don't have to settle for T-SQL's monochrome text output. These stored procedures let you quickly and easily turn your SELECT queries' output into colorized charts and even computer-generated art. To turn your own data into a line, column, area, or bar chart using the Chart stored procedure, you need to design a SELECT query that serves as the first parameter in the stored procedure call. @@ -349,8 +449,8 @@ Also you can generate amazing chart using awesome R libraries, detailed article: -## Additional Connection Parameters -One such change SSMS got for free is the connection resiliency logic within the SqlConnection.Open() method. +## 19. Additional Connection Parameters +One such change SSMS got for free is the connection resiliency logic within the `SqlConnection.Open()` method. To improve the default experience for clients which connect to Azure SQL Database, the above method will (in the case of initial connection errors / timeouts) now retry 1 time after sleeping for 10 seconds. These numbers are configurable by properties called ConnectRetryCount (default value 1) and ConnectRetryInterval (default value 10 seconds.) The previous versions of the SqlConnection class would not automatically retry in cases of connection failure. @@ -363,14 +463,14 @@ ConnectRetryCount=0 -## Working with tabs headers +## 20. Working with tabs headers You can view [SPID](https://docs.microsoft.com/en-us/sql/t-sql/functions/spid-transact-sql) in tabs header, quickly open script containing folder or copy script file path. ![Working with tabs headers](/SSMS/SSMS_Tips/working_with_tabs_headers.png) -## Hiding tables in SSMS Object Explorer +## 21. Hiding tables in SSMS Object Explorer 1. You can actually hide an object from object explorer by assigning a specific extended property: ``` EXEC sp_addextendedproperty @@ -403,14 +503,14 @@ In the case of SPs the code, same with Views and in the case of Tables it’s th -## UnDock Tabs and Windows for Multi Monitor Support +## 22. UnDock Tabs and Windows for Multi Monitor Support From SSMS 2012 and onwards, you can easily dock/undock the query tabs as well as different object windows inside SSMS to make better use of the screen real estate and multiple monitors you have. ![UnDock Tabs and Windows for Multi Monitor Support](/SSMS/SSMS_Tips/undock_tabs_and_windows_for_multi_monitor_support.gif) -## RegEx-Based Finding and Replacing of Text in SSMS +## 23. RegEx-Based Finding and Replacing of Text in SSMS So often, one sees developers doing repetitive coding in SSMS or Visual Studio that would be much quicker and easier by using the built-in Regular-Expression-based Find/Replace functionality. It is understandable, since the syntax is odd and some features are missing, but it is still well-worth knowing about. @@ -420,12 +520,12 @@ My favorite regex: replace `\t` on `\n, `. It useful in many cases when you have -## Changing what SSMS opens on startup +## 24. Changing what SSMS opens on startup The more interesting way to look at this shortcut is to check the various options available with SSMS command line parameters. To check them, use the following command: ``` C:\> ssms /? -`` +``` ![SSMS command line parameters](/SSMS/SSMS_Tips/24_SSMS_command-line_parameters.png) @@ -457,7 +557,7 @@ This is the complete text of shortcut properties: -## Modifying New Query Template +## 25. Modifying New Query Template You can modified New Query template for any instance SQL Server: ``` C:\Program Files (x86)\Microsoft SQL Server\[140|130|120|110]\Tools\Binn\ ManagementStudio\SqlWorkbenchProjectItems\Sql\SQLFile.sql @@ -476,7 +576,7 @@ Thanks for this tip Aaron Bertrand: [T-SQL Tuesday #92: Lessons Learned the Hard -## Query Execution Options +## 26. Query Execution Options More detailed article here: [Knowing the Options] The options represent the SET values of the current session. @@ -562,7 +662,7 @@ SELECT 'XACT_ABORT' AS 'Option', CASE @@options & 16384 WHEN 0 THEN -## SQL Server Diagnostics Extension +## 27. SQL Server Diagnostics Extension Analyze Dumps – Customers using this extension will be able to debug and self-resolve memory dump issues from their SQL Server instances and receive recommended Knowledge Base (KB) article(s) from Microsoft, which may be applicable for the fix. The memory dumps are stored in a secured and compliant manner as governed by the [Microsoft Privacy Policy](https://privacy.microsoft.com/en-us/privacystatement). @@ -576,7 +676,7 @@ More details here: [SQL Server Diagnostics Extension for SSMS] and [SQL Server D -## Connect to SQL Servers in another domain using Windows Authentication +## 28. Connect to SQL Servers in another domain using Windows Authentication You may find that you need to connect remotely to a SQL Server that is in another domain. This is a problem when SQL authentication is not an option, because Windows machine is in its own domain; Management Studio cannot directly override the local Windows credentials and pass the credentials for a remote domain user. @@ -612,7 +712,7 @@ More details here: [Connect to SQL Servers in another domain using Windows Authe -## SSMS Default Reports +## 29. SSMS Default Reports By right-clicking on the SQL Server instance and navigating to `Reports > Standard Reports`, you can see the predefined SSMS reports: ![SSMS_Server_Default_Reports](/SSMS/SSMS_Tips/29_SSMS_Server_Default_Reports.png) @@ -626,7 +726,7 @@ Useful another reports information: -## Live Query Statistics +## 30. Live Query Statistics SQL Server Management Studio provides the ability to view the live execution plan of an active query. This live query plan provides real-time insights into the query execution process as the controls flow from one query plan operator to another. The live query plan displays the overall query progress and operator-level run-time execution statistics such as the number of rows produced, elapsed time, operator progress, etc. @@ -641,14 +741,14 @@ This feature can be used with the [Transact-SQL Debugger](https://docs.microsoft -## Searching in Showplan +## 31. Searching in Showplan In SSMS 17.2, appear the ability to search table name, index name or column name and more in graphical showplan. just use `CTRL+F` to start a search in graphical showplan (or right-click on a blank area of the plan, and in the context menu click on Find Node option), and you can quickly see exactly where node id 30 is. More details here: [New in SSMS: Searching in Showplan] -## Object Explore Details +## 32. Object Explore Details To bring up the Object Explorer Details pane, use the `F7` shortcut or it can be accessed from `Toolbar -> View -> Object -> Explorer Details`. ![SSMS_Database_Default_Reports](/SSMS/SSMS_Tips/32_object_explore_details_01.png) @@ -663,19 +763,19 @@ This tells SQL Server Management Studio to display all the objects that have the -## Working with Azure SQL +## 33. Working with Azure SQL For SSMS 17.2 and above you can enable Multi-Factor Authentication in Azure SQL Database, more details here: [Configure Multi-Factor Authentication in Azure SQL Database] -## Using Extended Events and Profiler in SSMS +## 34. Using Extended Events and Profiler in SSMS Full instruction here: [EXTENDED EVENTS AND PROFILER: XE PROFILER] -## Vulnerability Assessment in SSMS +## 35. Vulnerability Assessment in SSMS You will need version 17.4 for the Vulnerability Assessment feature. Right-click to any database to start a scan. ![SSMS_Database_Default_Reports](/SSMS/SSMS_Tips/SQL_Vulnerability_Assessment.gif) @@ -691,10 +791,123 @@ You will need version 17.4 for the Vulnerability Assessment feature. Right-click More info here: [SQL Vulnerability Assessment Available in SSMS] and [Vulnerability Assessment features](https://docs.microsoft.com/en-us/sql/relational-databases/security/sql-vulnerability-assessment) + +## 36. Import Flat File to SQL Wizard +You will need version 17.3 or later. + +Detailed article here: [Import Flat File to SQL Wizard] + +Import Flat File Wizard is a simple way to copy data from a flat file (.csv, .txt) to a destination. + +This wizard was created to improve the current import experience leveraging an intelligent framework known as Program Synthesis using Examples ([PROSE](https://microsoft.github.io/prose/)). +For a user without specialized domain knowledge, importing data can often be a complex, error prone, and tedious task. This wizard streamlines the import process as simple as selecting an input file and unique table name, and the PROSE framework handles the rest. +PROSE analyzes data patterns in your input file to infer column names, types, delimiters, and more. This framework learns the structure of the file and does all of the hard work so our users don't have to. + + + +## 37. AutoRecover in SSMS +With the default settings, you can lose up to 5 minutes of work on a sudden reboot. +The recovered information will be kept for 7 days so there is some time to get your files. +These settings can be modified, changing how often auto recover happens and how long the information is retained. +It depends on the criticality of things that you work on as to how often you would want AutoRecover to save your scripts. +This feature can be turned off but it is not recommended. + +To change the settings, go to: `Tools -> Options -> Environment -> AutoRecover`. + +More details [here](https://witsociety.wordpress.com/2019/04/11/autorecover-in-ssms/). + +![AutoRecover in SSMS](/SSMS/SSMS_Tips/AutoRecover_in_SSMS.png) + + + +## 38. View and query Power BI .pbix files in SSMS +All Power BI files end with `.pbix`. +You can make a copy of the file, (because DBA always like to work from copies vs. the originals) then rename the file from `.pbix` to `.zip`. +You can then unzip the file and see the base components that make up a Power BI report and visuals: + +![Using SSMS with Power BI](/SSMS/SSMS_Tips/38_using_ssms_with_powerbi_01.jpg) + +While the Power BI report is open, you will see what is running using the `netstat -b -n` command from the command prompt as an administrator: + +You will notice that `pbidesktop.exe` is port `54125`, with multiple child threads. +You will also notice there is an executable also sourced from the `pbidesktop.exe` process called `msmdsrv.exe`. +That’s the executable for an Analysis Server. Your data model is being run by trimmed down Analysis Server in Power BI. +If you have an Analysis Server port, you can connect to it with SSMS using the ID for Power BI Desktop. +In our example above, the ID is `54125` and as the desktop is running on your PC, it would be your `localhost` for the server name. +Open up SSMS and update the server type to Analysis Server and type in the following, using my Active Directory login to connect. + +You will connect to the trimmed down Analysis Server behind the PBI Desktop report you have running on your screen and have limited interactive options. + +![Using SSMS with PowerBI](/SSMS/SSMS_Tips/38_using_ssms_with_powerbi_02.jpg) + +More details [here](https://dbakevlar.com/2019/03/using-ssms-with-power-bi/). + + + +## 39. Using SSMS and Profiler to analyze PowerBI with XMLA +SSMS can be used to, for example, view partitions generated by [incremental refresh](https://docs.microsoft.com/power-bi/service-premium-incremental-refresh). Version 18.0 RC1 or above is required. + +SQL Server Profiler can be used for tracing and debugging. SSMS 18.0 RC1 or above is required. + +More details [here](https://powerbi.microsoft.com/en-us/blog/power-bi-open-platform-connectivity-with-xmla-endpoints-public-preview/). + + + +## 40. SSMS shortcut to comment/uncomment a specific part of the query? +You can easily do this with [Code Snippets](https://docs.microsoft.com/en-us/sql/ssms/scripting/add-transact-sql-snippets): + +```xml + + + <_locDefinition xmlns="urn:locstudio"> + <_locDefault _loc="locNone" /> + <_locTag _loc="locData">Title + <_locTag _loc="locData">Description + <_locTag _loc="locData">Author + <_locTag _loc="locData">ToolTip + <_locTag _loc="locData">Default + + +
+ SLASH STAR COMMENT (surrounds) + + Surround selected text with slash star comment block /**/ + wBob + + SurroundsWith + +
+ + + + + + + + + + +
+
+``` + +Save the file with a `.snippet` extension and follow the instructions from [here](https://docs.microsoft.com/en-us/sql/ssms/scripting/add-transact-sql-snippets) to add the snippet to SSMS. + +Instructions for use: + +1. Highlight the text you want to surround with the comment block in the query editor +1. Press `Ctrl+K, Ctrl+S` to summon the 'Surround With' snippets. Note the comma between the two sequences, it means "press Ctrl+K, then press Ctrl+S in quick succession" +1. Select your snippet from the list +1. Your highlighted text is surrounded with the comment block +1. press `Ctrl+Z` to Undo - this is the normal windows undo command. It will remove the comment block as long as you haven't made any other edits. + +More details [here](https://dba.stackexchange.com/a/147182/107045) + + -Reference: +## 40. Reference: - [Free Course: SQL Server Management Studio Shortcuts & Secrets](https://sqlworkbooks.com/course/sql-server-management-studio-shortcuts-secrets/) (by Kendra Little) - - [SSMS Tips: Templates and Control+Shift+M] (by Kendra Little) + - [SSMS Tips: Templates and Control+Shift+M](http://littlekendra.com/2016/08/09/ssms-tips-templates-and-controlshiftm/) (by Kendra Little) - [Fixing Hot-Key issue in SSMS in five steps](http://slavasql.blogspot.ru/2017/02/fixing-hot-key-issue-in-ssms-in-five.html) (by Slava Murygin) - [SSMS Tips and Tricks](http://www.ssmstipsandtricks.com/) (by Latish Sehgal) - [Do you need more than STATISTICS IO for Query Tuning?](https://www.sqlpassion.at/archive/2017/03/27/do-you-need-more-than-statistics-io-for-query-tuning/) (by Klaus Aschenbrenner) @@ -721,16 +934,16 @@ Reference: - [CTRL+R does not hide the Query Result window in SSMS] - [SSMS Tip #1: Annotations and Map Mode for Vertical Scroll Bar] (by Solomon Rutzky) - [SQL Vulnerability Assessment Available in SSMS] (by Thomas LaRock) + - [SSMS Tips and Tricks free ebook](http://ssmsbook.sqldownunder.com) (by SDU Insiders) [Cycle through clipboard ring]:http://www.ssmstipsandtricks.com/blog/2014/05/05/cycle-through-clipboard-ring/ -[SSMS Tips: Templates and Control+Shift+M]:http://littlekendra.com/2016/08/09/ssms-tips-templates-and-controlshiftm/ [Generating Charts and Drawings in SQL Server Management Studio]:http://sqlmag.com/t-sql/generating-charts-and-drawings-sql-server-management-studio [View R Plots from within SQL Server Management Studio]:http://www.sqlservercentral.com/articles/R+Services/156107/ [RegEx-Based Finding and Replacing of Text in SSMS]:https://www.simple-talk.com/sql/sql-training/regex-based-finding-and-replacing-of-text-in-ssms/ [SQL Server Management Studio (SSMS) Tips and Tricks]:http://www.bidn.com/blogs/MMilligan/bidn-blog/3326/sql-server-management-studio-ssms-tips-and-tricks [Knowing the Options]:http://sqlrus.com/2017/05/knowing-the-options/ [SQL Server Diagnostics Extension for SSMS]:https://blogs.msdn.microsoft.com/sql_server_team/sql-server-diagnostics-preview/ -[T-SQL Tuesday #92: Lessons Learned the Hard Way]:https://blogs.sentryone.com/aaronbertrand/t-sql-tuesday-92-lessons-learned-hard-way/ +[T-SQL Tuesday #92: Lessons Learned the Hard Way]:https://www.sentryone.com/blog/aaronbertrand/t-sql-tuesday-92-lessons-learned-hard-way/ [SQL Server Diagnostics: New "Analyze Dumps" feature]:https://sqlworkbooks.com/2017/07/sql-server-diagnostics-new-analyze-dumps-feature/ [Connect to SQL Servers in another domain using Windows Authentication]:https://www.mssqltips.com/sqlservertip/3250/connect-to-sql-servers-in-another-domain-using-windows-authentication/ [New in SSMS: Searching in Showplan]:https://blogs.msdn.microsoft.com/sql_server_team/new-in-ssms-searching-in-showplan/ @@ -742,3 +955,6 @@ Reference: [EXTENDED EVENTS AND PROFILER: XE PROFILER]:https://www.scarydba.com/2017/11/07/extended-events-profiler-xe-profiler/ [New in SSMS – Always On Availability Group Latency Reports]:https://blogs.msdn.microsoft.com/sql_server_team/new-in-ssms-always-on-availability-group-latency-reports/ [SQL Vulnerability Assessment Available in SSMS]:https://thomaslarock.com/2017/12/sql-vulnerability-assessment-available-in-ssms/ +[Import Flat File to SQL Wizard]:https://docs.microsoft.com/en-us/sql/relational-databases/import-export/import-flat-file-wizard +[SSMS Tips by Wayne Sheffield]:http://blog.waynesheffield.com/wayne/archive/tag/ssms-tips/ +[SQL Management Studio, Trusted Connections, and Remote User accounts]:https://weblogs.asp.net/miked/sql-management-studio-trusted-connections-and-remote-user-accounts diff --git a/SSMS/SSMS_Tips/05_ALT+Arrow.gif b/SSMS/SSMS_Tips/05_ALT+Arrow.gif new file mode 100644 index 00000000..a31b990e Binary files /dev/null and b/SSMS/SSMS_Tips/05_ALT+Arrow.gif differ diff --git a/SSMS/SSMS_Tips/05_ALT+PASTE.gif b/SSMS/SSMS_Tips/05_ALT+PASTE.gif new file mode 100644 index 00000000..744efc8b Binary files /dev/null and b/SSMS/SSMS_Tips/05_ALT+PASTE.gif differ diff --git a/SSMS/SSMS_Tips/38_using_ssms_with_powerbi_01.jpg b/SSMS/SSMS_Tips/38_using_ssms_with_powerbi_01.jpg new file mode 100644 index 00000000..3fa320a5 Binary files /dev/null and b/SSMS/SSMS_Tips/38_using_ssms_with_powerbi_01.jpg differ diff --git a/SSMS/SSMS_Tips/38_using_ssms_with_powerbi_02.jpg b/SSMS/SSMS_Tips/38_using_ssms_with_powerbi_02.jpg new file mode 100644 index 00000000..f1c5a890 Binary files /dev/null and b/SSMS/SSMS_Tips/38_using_ssms_with_powerbi_02.jpg differ diff --git a/SSMS/SSMS_Tips/AutoRecover_in_SSMS.png b/SSMS/SSMS_Tips/AutoRecover_in_SSMS.png new file mode 100644 index 00000000..668a88f3 Binary files /dev/null and b/SSMS/SSMS_Tips/AutoRecover_in_SSMS.png differ diff --git a/SSMS/SSMS_Tips/ssms_script_objects_server_version.png b/SSMS/SSMS_Tips/ssms_script_objects_server_version.png new file mode 100644 index 00000000..6442b612 Binary files /dev/null and b/SSMS/SSMS_Tips/ssms_script_objects_server_version.png differ diff --git a/SSMS/SSMS_vssettings/NewSettings_Default_18.7.1(15.0.18358).vssettings b/SSMS/SSMS_vssettings/NewSettings_Default_18.7.1(15.0.18358).vssettings new file mode 100644 index 00000000..89953e17 --- /dev/null +++ b/SSMS/SSMS_vssettings/NewSettings_Default_18.7.1(15.0.18358).vssettings @@ -0,0 +1,995 @@ + + true + false + true + false + true + false + true + true + true + 0 + 0 + + true + true + true + false + + 5 + 0 + 10 + true + true + true + false + false + true + 10 + + false + + %vsspv_settings_directory%\NewSettings.vssettings + + %vsspv_user_appdata%\Documents\SQL Server Management Studio + true + true + true + 4 + 4 + true + %vsspv_visualstudio_dir%\Templates\ItemTemplates + false + true + 1 + 0 + 1 + %vsspv_visualstudio_dir%\Templates\ProjectTemplates + true + 4 + true + + false + + HACK:2 + TODO:2 + UNDONE:2 + UnresolvedMergeConflict:3 + + false + false + + https://docs.microsoft.com/sql/ssms/tutorials/tutorial-sql-server-management-studio + 1 + C:\Windows\system32\notepad.exe + https://www.bing.com + + true + true + 0 + true + true + false + true + false + true + true + + 4 + true + true + true + true + 2 + true + true + true + false + false + true + true + false + false + true + true + 58 + false + false + 4 + true + true + true + true + + 4 + true + true + true + true + 1 + true + true + false + false + false + true + true + true + true + true + true + 58 + false + false + 4 + true + true + true + true + + 4 + true + true + true + true + 1 + true + true + false + false + false + true + true + true + true + true + true + 58 + false + false + 4 + false + true + true + true + + 4 + true + true + true + true + 2 + true + true + false + false + false + true + true + true + true + true + true + 58 + false + false + 4 + false + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + false + true + + true + true + true + false + false + false + true + false + false + false + false + true + true + true + true + false + false + true + true + false + true + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + true + false + + 0 + 0 + + + + True + <ExtensionRepositoryConfigList Capacity="0" xmlns="clr-namespace:Microsoft.VisualStudio.ExtensionManager;assembly=Microsoft.VisualStudio.ExtensionEngine" /> + True + + + + false + true + false + 2 + {B1BA9461-FC54-45B3-A484-CB6DD0B95C94} + 0 + + 2 + + + + + + + + + + + + + + + + + + 15.0.0.0 + + + + + + + + + + + + + + + + + + + + + + + + + + Ctrl+Shift+F + Ctrl+Shift+L + Ctrl+F1 + Ctrl+\, Ctrl+T + Ctrl+\, T + F7 + + Ctrl+T + Ctrl+K, Ctrl+C + Ctrl+Shift+L + Ctrl+Shift+L + Ctrl+Shift+L + Ctrl+Shift+L + Ctrl+Shift+L + Ctrl+Shift+L + Ctrl+Shift+U + Ctrl+Shift+U + Ctrl+Shift+U + Ctrl+Shift+U + Ctrl+Shift+U + Ctrl+Shift+U + Ctrl+K, Ctrl+U + Ctrl+Shift+T + Ctrl+Alt+N + Ctrl+N + Ctrl+F1 + Ctrl+L + F5 + Ctrl+E + F5 + Ctrl+E + Alt+X + F5 + Ctrl+E + F5 + Ctrl+E + F5 + Ctrl+E + Ctrl+M + Shift+Alt+S + Alt+F8 + Ctrl+Shift+F + Ctrl+Shift+F + Ctrl+D + Ctrl+D + Ctrl+T + Ctrl+T + Ctrl+Shift+M + F8 + F7 + F5 + Ctrl+Alt+K + Ctrl+Alt+T + F6 + Shift+F6 + Ctrl+R + Ctrl+R + Ctrl+R + Ctrl+R + Ctrl+R + + + + false + false + + false + false + true + false + false + false + true + false + false + false + false + true + true + true + true + false + false + true + true + false + true + false + {B1BA9461-FC54-45B3-A484-CB6DD0B95C94} + 0 + + false + + 0 + 1 + + true + false + + + + + + + + + + false + true + false + + true + true + + True + False + True + True + True + True + False + False + True + False + + false + 1 + 0 + 0 + 0 + 0 + + MatchCase=0 WholeWord=0 Hidden=0 Up=0 Selection=0 Block=0 KeepCase=0 SubFolders=1 KeepOpen=0 NameOnly=0 Append=0 Plain Files Find + MatchCase=0 WholeWord=0 Hidden=0 Up=0 Selection=0 Block=0 KeepCase=0 SubFolders=1 KeepOpen=0 NameOnly=0 Append=0 Plain Solution Find + MatchCase=0 WholeWord=0 Hidden=0 Up=0 Selection=0 Block=0 KeepCase=0 SubFolders=0 KeepOpen=0 NameOnly=0 Append=0 Plain Document Find + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + Regex + 0 + 0 + + 7 + NoToolWin|Design + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1101011110101111100010000000001001101001000000167577360473600210110111000015001500150010001000100020002000500010000100002501000500125100011001111111111000011100100110000000010120482530001001110000010100110101011132768819211011010000000115010https://referencesource.microsoft.com/symbolshttps://msdl.microsoft.com/download/symbols + True + True + 1048576 + 0 + True + + True + True + True + 8, 8 + SnapLines + True + True + True + True + + None + False + True + True + True + True + True + True + True + True + %VsInstallDir%\xml\Schemas + \ No newline at end of file diff --git a/SSMS/SSMS_vssettings/README.md b/SSMS/SSMS_vssettings/README.md index 326a63c8..dc901533 100644 --- a/SSMS/SSMS_vssettings/README.md +++ b/SSMS/SSMS_vssettings/README.md @@ -1,6 +1,13 @@ # SSMS settings files +In files with `_Default_` you can find defaults SSMS settings for different SSMS version. +For import settings files see **tip 1** in [SSMS tips](https://github.com/ktaranov/sqlserver-kit/blob/master/SSMS/SSMS_Tips.md#1) guide. - - [NewSettings_17.2(14.0.17177).vssettings](/NewSettings_17.2(14.0.17177).vssettings) - - [NewSettings_2014(12.0.5556).vssettings](/NewSettings_2014(12.0.5556).vssettings) - - [NewSettings_Default_17.2(14.0.17177).vssettings](/NewSettings_Default_17.2(14.0.17177).vssettings) - - [NewSettings_Default_2014(12.0.5556).vssettings](/NewSettings_Default_2014(12.0.5556).vssettings) +My awesome settings: [ktaranov_18.7.1.vssettings](.ktaranov_18.7.1.vssettings) + +- [AB.DarkScheme.LargeFonts.vssettings](/AB.DarkScheme.LargeFonts.vssettings) +- [AB.DarkScheme.NormalFonts.vssettings](/AB.DarkScheme.NormalFonts.vssettings) +- [NewSettings_17.2(14.0.17177).vssettings](/NewSettings_17.2(14.0.17177).vssettings) +- [NewSettings_2014(12.0.5556).vssettings](/NewSettings_2014(12.0.5556).vssettings) +- [NewSettings_Default_17.2(14.0.17177).vssettings](/NewSettings_Default_17.2(14.0.17177).vssettings) +- [NewSettings_Default_18.7.1(15.0.18358).vssettings](/NewSettings_Default_18.7.1(15.0.18358).vssettings) +- [NewSettings_Default_2014(12.0.5556).vssettings](/NewSettings_Default_2014(12.0.5556).vssettings) diff --git a/SSMS/SSMS_vssettings/ktaranov_18.7.1.vssettings b/SSMS/SSMS_vssettings/ktaranov_18.7.1.vssettings new file mode 100644 index 00000000..03301c74 --- /dev/null +++ b/SSMS/SSMS_vssettings/ktaranov_18.7.1.vssettings @@ -0,0 +1,124 @@ +truefalsetruefalsetruefalsetruetruetrue10truetruetruefalse56553510truetruetruetruefalsetrue10%vsspv_user_appdata%\Documents\SQL Server Management Studiotruetruetrue44true%vsspv_visualstudio_dir%\Templates\ItemTemplatesfalsetrue101%vsspv_visualstudio_dir%\Templates\ProjectTemplatestrue2truefalseHACK:2TODO:2UNDONE:2UnresolvedMergeConflict:3falsefalse + https://docs.microsoft.com/sql/ssms/tutorials/tutorial-sql-server-management-studio + 1 + C:\Windows\system32\notepad.exe + https://www.bing.com + truetrue0truetruefalsetruefalsetruetrue4truetruetruetrue2truetruetruefalsefalsetruetruefalsefalsetruetrue58truefalse4truetruefalsetrue4truetruetruetrue1truetruetruefalsefalsetruetruefalsetruetruetrue58truefalse4truetruefalsetrue4truetruetruetrue1truetruetruefalsefalsetruetruefalsetruetruetrue58truefalse4truetruefalsetrue4truetruetruetrue2truetruetruefalsefalsetruetruefalsetruetruetrue58truefalse4truetruefalsetrue + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + truefalsetruetruetruetruefalsefalsefalsetruefalsefalsefalsefalsetruetruetruetruefalsefalsetruetruefalsetruefalsefalsetruefalse00True<ExtensionRepositoryConfigList Capacity="0" xmlns="clr-namespace:Microsoft.VisualStudio.ExtensionManager;assembly=Microsoft.VisualStudio.ExtensionEngine" />Truefalsetruefalse2{B1BA9461-FC54-45B3-A484-CB6DD0B95C94}0215.0.0.0Ctrl+Shift+LCtrl+F1Ctrl+\, Ctrl+TCtrl+\, TCtrl+TCtrl+K, Ctrl+CCtrl+Shift+LCtrl+Shift+LCtrl+Shift+LCtrl+Shift+LCtrl+Shift+LCtrl+Shift+LCtrl+Shift+UCtrl+Shift+UCtrl+Shift+UCtrl+Shift+UCtrl+Shift+UCtrl+Shift+UCtrl+K, Ctrl+UCtrl+Shift+TCtrl+Alt+NCtrl+NCtrl+F1Ctrl+LF5Ctrl+EF5Ctrl+EAlt+XF5Ctrl+EF5Ctrl+EF5Ctrl+ECtrl+MShift+Alt+SAlt+F8Ctrl+Shift+FCtrl+Shift+FCtrl+DCtrl+DCtrl+TCtrl+TCtrl+Shift+MF8F7F5Ctrl+Alt+KCtrl+Alt+TF6Shift+F6Ctrl+RCtrl+RCtrl+RCtrl+RCtrl+Rfalsefalsefalsefalsetruefalsefalsefalsetruefalsefalsefalsefalsetruetruetruetruefalsefalsetruetruefalsetruefalse{B1BA9461-FC54-45B3-A484-CB6DD0B95C94}0false01truefalsefalsetruefalsetruetrueTrueFalseTrueTrueTrueTrueFalseFalseTrueTrueTrue + false + 1 + 0 + 0 + 0 + 0 + MatchCase=0 WholeWord=0 Hidden=0 Up=0 Selection=0 Block=0 KeepCase=0 SubFolders=1 KeepOpen=0 NameOnly=0 Append=0 Plain Files FindMatchCase=0 WholeWord=0 Hidden=0 Up=0 Selection=0 Block=0 KeepCase=0 SubFolders=1 KeepOpen=0 NameOnly=0 Append=0 Plain Solution FindMatchCase=0 WholeWord=0 Hidden=0 Up=0 Selection=0 Block=0 KeepCase=0 SubFolders=0 KeepOpen=0 NameOnly=0 Append=0 Plain Document Find1111111111111111Regex007NoToolWin|Design1101011110101111100010000000001001101001000000167577360473600210110111000015001500150010001000100020002000500010000100002501000500125100011001111111111000011100100110000000010120482530001001110000010100110101011132768819211011010000000115010https://referencesource.microsoft.com/symbolshttps://msdl.microsoft.com/download/symbolsTrueTrue10485760True + True + True + True + 8, 8 + SnapLines + True + True + True + True + NoneFalseTrueTrueTrueTrueTrueTrueTrueTrue%VsInstallDir%\xml\Schemas \ No newline at end of file diff --git a/Sample_Databases/Create_Enlarged_Adventureworks_Tables.sql b/Sample_Databases/Create_Enlarged_Adventureworks_Tables.sql new file mode 100644 index 00000000..81347f1e --- /dev/null +++ b/Sample_Databases/Create_Enlarged_Adventureworks_Tables.sql @@ -0,0 +1,224 @@ +/***************************************************************************** +* FileName: Create Enlarged AdventureWorks Tables.sql +* +* Summary: Creates an enlarged version of the AdventureWorks database +* for use in demonstrating SQL Server performance tuning and +* execution plan issues. +* +* Date: November 14, 2011 +* +* SQL Server Versions: +* 2008, 2008R2, 2012 +* +****************************************************************************** +* Copyright (C) 2011 Jonathan M. Kehayias, SQLskills.com +* All rights reserved. +* +* For more scripts and sample code, check out +* https://www.sqlskills.com/blogs/jonathan/enlarging-the-adventureworks-sample-databases/ +* +* You may alter this code for your own *non-commercial* purposes. You may +* republish altered code as long as you include this copyright and give +* due credit. +* +* +* THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF +* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED +* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +* PARTICULAR PURPOSE. +* +******************************************************************************/ + + + +USE AdventureWorks2008R2; +GO + +IF OBJECT_ID('Sales.SalesOrderHeaderEnlarged') IS NOT NULL + DROP TABLE Sales.SalesOrderHeaderEnlarged; +GO + +CREATE TABLE Sales.SalesOrderHeaderEnlarged + ( + SalesOrderID int NOT NULL IDENTITY (1, 1) NOT FOR REPLICATION, + RevisionNumber tinyint NOT NULL, + OrderDate datetime NOT NULL, + DueDate datetime NOT NULL, + ShipDate datetime NULL, + Status tinyint NOT NULL, + OnlineOrderFlag dbo.Flag NOT NULL, + SalesOrderNumber AS (isnull(N'SO'+CONVERT([nvarchar](23),[SalesOrderID],0),N'*** ERROR ***')), + PurchaseOrderNumber dbo.OrderNumber NULL, + AccountNumber dbo.AccountNumber NULL, + CustomerID int NOT NULL, + SalesPersonID int NULL, + TerritoryID int NULL, + BillToAddressID int NOT NULL, + ShipToAddressID int NOT NULL, + ShipMethodID int NOT NULL, + CreditCardID int NULL, + CreditCardApprovalCode varchar(15) NULL, + CurrencyRateID int NULL, + SubTotal money NOT NULL, + TaxAmt money NOT NULL, + Freight money NOT NULL, + TotalDue AS (isnull(([SubTotal]+[TaxAmt])+[Freight],(0))), + Comment nvarchar(128) NULL, + rowguid uniqueidentifier NOT NULL ROWGUIDCOL, + ModifiedDate datetime NOT NULL + ) ON [PRIMARY] +GO + +SET IDENTITY_INSERT Sales.SalesOrderHeaderEnlarged ON +GO +INSERT INTO Sales.SalesOrderHeaderEnlarged (SalesOrderID, RevisionNumber, OrderDate, DueDate, ShipDate, Status, OnlineOrderFlag, PurchaseOrderNumber, AccountNumber, CustomerID, SalesPersonID, TerritoryID, BillToAddressID, ShipToAddressID, ShipMethodID, CreditCardID, CreditCardApprovalCode, CurrencyRateID, SubTotal, TaxAmt, Freight, Comment, rowguid, ModifiedDate) +SELECT SalesOrderID, RevisionNumber, OrderDate, DueDate, ShipDate, Status, OnlineOrderFlag, PurchaseOrderNumber, AccountNumber, CustomerID, SalesPersonID, TerritoryID, BillToAddressID, ShipToAddressID, ShipMethodID, CreditCardID, CreditCardApprovalCode, CurrencyRateID, SubTotal, TaxAmt, Freight, Comment, rowguid, ModifiedDate +FROM Sales.SalesOrderHeader WITH (HOLDLOCK TABLOCKX) +GO +SET IDENTITY_INSERT Sales.SalesOrderHeaderEnlarged OFF + +GO +ALTER TABLE Sales.SalesOrderHeaderEnlarged ADD CONSTRAINT + PK_SalesOrderHeaderEnlarged_SalesOrderID PRIMARY KEY CLUSTERED + ( + SalesOrderID + ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] + +GO + +CREATE UNIQUE NONCLUSTERED INDEX AK_SalesOrderHeaderEnlarged_rowguid ON Sales.SalesOrderHeaderEnlarged + ( + rowguid + ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +GO + +CREATE UNIQUE NONCLUSTERED INDEX AK_SalesOrderHeaderEnlarged_SalesOrderNumber ON Sales.SalesOrderHeaderEnlarged + ( + SalesOrderNumber + ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +GO + +CREATE NONCLUSTERED INDEX IX_SalesOrderHeaderEnlarged_CustomerID ON Sales.SalesOrderHeaderEnlarged + ( + CustomerID + ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +GO + +CREATE NONCLUSTERED INDEX IX_SalesOrderHeaderEnlarged_SalesPersonID ON Sales.SalesOrderHeaderEnlarged + ( + SalesPersonID + ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +GO + +IF OBJECT_ID('Sales.SalesOrderDetailEnlarged') IS NOT NULL + DROP TABLE Sales.SalesOrderDetailEnlarged; +GO +CREATE TABLE Sales.SalesOrderDetailEnlarged + ( + SalesOrderID int NOT NULL, + SalesOrderDetailID int NOT NULL IDENTITY (1, 1), + CarrierTrackingNumber nvarchar(25) NULL, + OrderQty smallint NOT NULL, + ProductID int NOT NULL, + SpecialOfferID int NOT NULL, + UnitPrice money NOT NULL, + UnitPriceDiscount money NOT NULL, + LineTotal AS (isnull(([UnitPrice]*((1.0)-[UnitPriceDiscount]))*[OrderQty],(0.0))), + rowguid uniqueidentifier NOT NULL ROWGUIDCOL, + ModifiedDate datetime NOT NULL + ) ON [PRIMARY] +GO + +SET IDENTITY_INSERT Sales.SalesOrderDetailEnlarged ON +GO +INSERT INTO Sales.SalesOrderDetailEnlarged (SalesOrderID, SalesOrderDetailID, CarrierTrackingNumber, OrderQty, ProductID, SpecialOfferID, UnitPrice, UnitPriceDiscount, rowguid, ModifiedDate) +SELECT SalesOrderID, SalesOrderDetailID, CarrierTrackingNumber, OrderQty, ProductID, SpecialOfferID, UnitPrice, UnitPriceDiscount, rowguid, ModifiedDate +FROM Sales.SalesOrderDetail WITH (HOLDLOCK TABLOCKX) +GO +SET IDENTITY_INSERT Sales.SalesOrderDetailEnlarged OFF +GO +ALTER TABLE Sales.SalesOrderDetailEnlarged ADD CONSTRAINT + PK_SalesOrderDetailEnlarged_SalesOrderID_SalesOrderDetailID PRIMARY KEY CLUSTERED + ( + SalesOrderID, + SalesOrderDetailID + ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] + +GO +CREATE UNIQUE NONCLUSTERED INDEX AK_SalesOrderDetailEnlarged_rowguid ON Sales.SalesOrderDetailEnlarged + ( + rowguid + ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +GO +CREATE NONCLUSTERED INDEX IX_SalesOrderDetailEnlarged_ProductID ON Sales.SalesOrderDetailEnlarged + ( + ProductID + ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +GO + + +BEGIN TRANSACTION + + +DECLARE @TableVar TABLE +(OrigSalesOrderID int, NewSalesOrderID int) + +INSERT INTO Sales.SalesOrderHeaderEnlarged + (RevisionNumber, OrderDate, DueDate, ShipDate, Status, OnlineOrderFlag, + PurchaseOrderNumber, AccountNumber, CustomerID, SalesPersonID, TerritoryID, + BillToAddressID, ShipToAddressID, ShipMethodID, CreditCardID, + CreditCardApprovalCode, CurrencyRateID, SubTotal, TaxAmt, Freight, Comment, + rowguid, ModifiedDate) +OUTPUT inserted.Comment, inserted.SalesOrderID + INTO @TableVar +SELECT RevisionNumber, DATEADD(dd, number, OrderDate) AS OrderDate, + DATEADD(dd, number, DueDate), DATEADD(dd, number, ShipDate), + Status, OnlineOrderFlag, + PurchaseOrderNumber, + AccountNumber, + CustomerID, SalesPersonID, TerritoryID, BillToAddressID, + ShipToAddressID, ShipMethodID, CreditCardID, CreditCardApprovalCode, + CurrencyRateID, SubTotal, TaxAmt, Freight, SalesOrderID, + NEWID(), DATEADD(dd, number, ModifiedDate) +FROM Sales.SalesOrderHeader AS soh WITH (HOLDLOCK TABLOCKX) +CROSS JOIN ( + SELECT number + FROM ( SELECT TOP 10 number + FROM master.dbo.spt_values + WHERE type = N'P' + AND number < 1000 + ORDER BY NEWID() DESC + UNION + SELECT TOP 10 number + FROM master.dbo.spt_values + WHERE type = N'P' + AND number < 1000 + ORDER BY NEWID() DESC + UNION + SELECT TOP 10 number + FROM master.dbo.spt_values + WHERE type = N'P' + AND number < 1000 + ORDER BY NEWID() DESC + UNION + SELECT TOP 10 number + FROM master.dbo.spt_values + WHERE type = N'P' + AND number < 1000 + ORDER BY NEWID() DESC + ) AS tab +) AS Randomizer +ORDER BY OrderDate, number + +INSERT INTO Sales.SalesOrderDetailEnlarged + (SalesOrderID, CarrierTrackingNumber, OrderQty, ProductID, + SpecialOfferID, UnitPrice, UnitPriceDiscount, rowguid, ModifiedDate) +SELECT + tv.NewSalesOrderID, CarrierTrackingNumber, OrderQty, ProductID, + SpecialOfferID, UnitPrice, UnitPriceDiscount, NEWID(), ModifiedDate +FROM Sales.SalesOrderDetail AS sod +JOIN @TableVar AS tv + ON sod.SalesOrderID = tv.OrigSalesOrderID +ORDER BY sod.SalesOrderDetailID + +COMMIT \ No newline at end of file diff --git a/Sample_Databases/Database_script.sql b/Sample_Databases/Database_script.sql new file mode 100644 index 00000000..fc342d1e --- /dev/null +++ b/Sample_Databases/Database_script.sql @@ -0,0 +1,24 @@ +SELECT name [Database Name] + , physical_name [File Location] + , ROUND(size * (8.0 / 1024), 0) [Size in MBs] + , * + FROM sys.master_files + WHERE file_id = 1 AND name NOT IN ('master', 'tempdev', 'modeldev', 'MSDBData') + ORDER BY CASE WHEN physical_name LIKE '%StackOverflow2010.mdf' THEN 1 + WHEN physical_name LIKE '%StackOverflow.mdf' THEN 2 + WHEN physical_name LIKE '%WideWorldImporters.mdf' THEN 3 + WHEN physical_name LIKE '%WideWorldImportersDW.mdf' THEN 4 + WHEN physical_name LIKE '%AdventureWorks2017.mdf' THEN 5 + WHEN physical_name LIKE '%AdventureWorks2016_Data.mdf' THEN 6 + WHEN physical_name LIKE '%AdventureWorks2016_EXT_Data.mdf' THEN 7 + WHEN physical_name LIKE '%AdventureWorks2014_Data.mdf' THEN 8 + WHEN physical_name LIKE '%AdventureWorks2012.mdf' THEN 9 + WHEN physical_name LIKE '%AdventureWorksDW2017.mdf' THEN 10 + WHEN physical_name LIKE '%AdventureWorksDW2016_Data.mdf' THEN 11 + WHEN physical_name LIKE '%AdventureWorksDW2016_EXT_Data.mdf' THEN 12 + WHEN physical_name LIKE '%AdventureWorksDW2014_Data.mdf' THEN 13 + WHEN physical_name LIKE '%AdventureWorksDW2012.mdf' THEN 14 + WHEN physical_name LIKE '%AdventureWorksMultidimensionalModel.mdf' THEN 15 + WHEN physical_name LIKE '%AdventureWorksTabularModel.mdf' THEN 16 + ELSE 100 + END; diff --git a/Sample_Databases/Oracle_Employee_Database.sql b/Sample_Databases/Oracle_Employee_Database.sql new file mode 100644 index 00000000..66723c34 --- /dev/null +++ b/Sample_Databases/Oracle_Employee_Database.sql @@ -0,0 +1,64 @@ +/* +Source link: https://github.com/ktaranov/sqlserver-kit/blob/master/Sample_Databases/Oracle_Employee_Database.sql +Changed data type to more unviversal: varchar2 -> varchar, number -> int +Tested on SQL Server 2019 and Postgres 12.2 +Original link: https://livesql.oracle.com/apex/livesql/file/content_O5AEB2HE08PYEPTGCFLZU9YCV.html +Code style for PostgresSQL - python like. +*/ + +CREATE DATABASE oracle_employee; + +DROP TABLE employee; +DROP TABLE department; + +CREATE TABLE department ( + id int NOT NULL + , name varchar(100) NOT NULL + , CONSTRAINT pk_department PRIMARY KEY (id) +); + +CREATE TABLE employee ( + id int NOT NULL + , department_id INT NOT NULL + , chief_id int NULL + , name varchar(100) NOT NULL + , salary DECIMAL(19,2) NOT NULL + , CONSTRAINT pk_employee PRIMARY KEY (id) +); + +ALTER TABLE employee ADD CONSTRAINT fk_employee__department_id FOREIGN KEY (department_id) REFERENCES department(id); +ALTER TABLE employee ADD CONSTRAINT fk_employee__cheief_id FOREIGN KEY (chief_id) REFERENCES employee(id); + +INSERT INTO department (id, name) VALUES(10, 'ACCOUNTING'); +INSERT INTO department (id, name) VALUES(20, 'RESEARCH'); +INSERT INTO department (id, name) VALUES(30, 'SALES'); +INSERT INTO department (id, name) VALUES(40, 'OPERATIONS'); + +INSERT INTO employee(id, name, chief_id, salary, department_id) +VALUES(7839, 'KING', null, 5000, 10); +INSERT INTO employee(id, name, chief_id, salary, department_id) +VALUES(7698, 'BLAKE', 7839, 2850, 30); +INSERT INTO employee(id, name, chief_id, salary, department_id) +VALUES(7782, 'CLARK', 7839, 2450, 10); +INSERT INTO employee(id, name, chief_id, salary, department_id) +VALUES(7566, 'JONES',7839, 2975, 20); +INSERT INTO employee(id, name, chief_id, salary, department_id) +VALUES(7788, 'SCOTT', 7566, 3000, 20); +INSERT INTO employee(id, name, chief_id, salary, department_id) +VALUES(7902, 'FORD', 7566, 3000, 20); +INSERT INTO employee(id, name, chief_id, salary, department_id) +VALUES(7369, 'SMITH', 7902, 800, 20); +INSERT INTO employee(id, name, chief_id, salary, department_id) +VALUES(7499, 'ALLEN', 7698, 1600, 30); +INSERT INTO employee(id, name, chief_id, salary, department_id) +VALUES(7521, 'WARD', 7698, 1250, 30); +INSERT INTO employee(id, name, chief_id, salary, department_id) +VALUES(7654, 'MARTIN', 7698, 1250, 30); +INSERT INTO employee(id, name, chief_id, salary, department_id) +VALUES(7844, 'TURNER', 7698, 1500, 30); +INSERT INTO employee(id, name, chief_id, salary, department_id) +VALUES(7876, 'ADAMS', 7788, 1100, 20); +INSERT INTO employee(id, name, chief_id, salary, department_id) +VALUES(7900, 'JAMES', 7698, 950, 30 ); +INSERT INTO employee(id, name, chief_id, salary, department_id) +VALUES(7934, 'MILLER', 7782, 1300, 10); diff --git a/Sample_Databases/PerformanceV3.sql b/Sample_Databases/PerformanceV3.sql new file mode 100644 index 00000000..c1912a03 --- /dev/null +++ b/Sample_Databases/PerformanceV3.sql @@ -0,0 +1,220 @@ +--------------------------------------------------------------------- +-- Script that creates the sample database PerformanceV3 +-- +-- Last updated: 20141125 +-- +-- Itzik Ben-Gan +--------------------------------------------------------------------- + +-- creation script for sample database and tables +SET NOCOUNT ON; +USE master; +IF DB_ID(N'PerformanceV3') IS NULL CREATE DATABASE PerformanceV3; +GO +USE PerformanceV3; +GO + +-- drop objects if exist +IF OBJECT_ID(N'dbo.GetNums', N'IF') IS NOT NULL DROP FUNCTION dbo.GetNums; + +IF OBJECT_ID(N'dbo.VEmpOrders', N'V') IS NOT NULL DROP VIEW dbo.VEmpOrders; + +IF OBJECT_ID(N'dbo.Orders' , N'U') IS NOT NULL DROP TABLE dbo.Orders; +IF OBJECT_ID(N'dbo.Customers', N'U') IS NOT NULL DROP TABLE dbo.Customers; +IF OBJECT_ID(N'dbo.Employees', N'U') IS NOT NULL DROP TABLE dbo.Employees; +IF OBJECT_ID(N'dbo.Shippers' , N'U') IS NOT NULL DROP TABLE dbo.Shippers; + +IF OBJECT_ID(N'dbo.Fact' , N'U') IS NOT NULL DROP TABLE dbo.Fact; +IF OBJECT_ID(N'dbo.FactCS', N'U') IS NOT NULL DROP TABLE dbo.FactCS; +IF OBJECT_ID(N'dbo.Dim1' , N'U') IS NOT NULL DROP TABLE dbo.Dim1; +IF OBJECT_ID(N'dbo.Dim2' , N'U') IS NOT NULL DROP TABLE dbo.Dim2; +IF OBJECT_ID(N'dbo.Dim3' , N'U') IS NOT NULL DROP TABLE dbo.Dim3; +GO + +-- definition of GetNums function +CREATE FUNCTION dbo.GetNums(@low AS BIGINT, @high AS BIGINT) RETURNS TABLE +AS +RETURN + WITH + L0 AS (SELECT c FROM (VALUES(1),(1)) AS D(c)), + L1 AS (SELECT 1 AS c FROM L0 AS A CROSS JOIN L0 AS B), + L2 AS (SELECT 1 AS c FROM L1 AS A CROSS JOIN L1 AS B), + L3 AS (SELECT 1 AS c FROM L2 AS A CROSS JOIN L2 AS B), + L4 AS (SELECT 1 AS c FROM L3 AS A CROSS JOIN L3 AS B), + L5 AS (SELECT 1 AS c FROM L4 AS A CROSS JOIN L4 AS B), + Nums AS (SELECT ROW_NUMBER() OVER(ORDER BY (SELECT NULL)) AS rownum + FROM L5) + SELECT TOP(@high - @low + 1) @low + rownum - 1 AS n + FROM Nums + ORDER BY rownum; +GO + +-- data distribution settings for orders +DECLARE + @numorders AS INT = 1000000, + @numcusts AS INT = 20000, + @numemps AS INT = 500, + @numshippers AS INT = 5, + @numyears AS INT = 4, + @startdate AS DATE = '20110101'; + +-- creating and populating the Customers table +CREATE TABLE dbo.Customers +( + custid CHAR(11) NOT NULL, + custname NVARCHAR(50) NOT NULL +); + +INSERT INTO dbo.Customers(custid, custname) + SELECT + 'C' + RIGHT('000000000' + CAST(n AS VARCHAR(10)), 10) AS custid, + N'Cust_' + CAST(n AS VARCHAR(10)) AS custname + FROM dbo.GetNums(1, @numcusts); + +ALTER TABLE dbo.Customers ADD + CONSTRAINT PK_Customers PRIMARY KEY(custid); + +-- creating and populating the Employees table +CREATE TABLE dbo.Employees +( + empid INT NOT NULL, + firstname NVARCHAR(25) NOT NULL, + lastname NVARCHAR(25) NOT NULL +); + +INSERT INTO dbo.Employees(empid, firstname, lastname) + SELECT n AS empid, + N'Fname_' + CAST(n AS NVARCHAR(10)) AS firstname, + N'Lname_' + CAST(n AS NVARCHAR(10)) AS lastname + FROM dbo.GetNums(1, @numemps); + +ALTER TABLE dbo.Employees ADD + CONSTRAINT PK_Employees PRIMARY KEY(empid); + +-- creating and populating the Shippers table +CREATE TABLE dbo.Shippers +( + shipperid VARCHAR(5) NOT NULL, + shippername NVARCHAR(50) NOT NULL +); + +INSERT INTO dbo.Shippers(shipperid, shippername) + SELECT shipperid, N'Shipper_' + shipperid AS shippername + FROM (SELECT CHAR(ASCII('A') - 2 + 2 * n) AS shipperid + FROM dbo.GetNums(1, @numshippers)) AS D; + +ALTER TABLE dbo.Shippers ADD + CONSTRAINT PK_Shippers PRIMARY KEY(shipperid); + +-- creating and populating the Orders table +CREATE TABLE dbo.Orders +( + orderid INT NOT NULL, + custid CHAR(11) NOT NULL, + empid INT NOT NULL, + shipperid VARCHAR(5) NOT NULL, + orderdate DATE NOT NULL, + filler CHAR(160) NOT NULL DEFAULT('a') +); + +INSERT INTO dbo.Orders(orderid, custid, empid, shipperid, orderdate) + SELECT n AS orderid, + 'C' + RIGHT('000000000' + + CAST( + 1 + ABS(CHECKSUM(NEWID())) % @numcusts + AS VARCHAR(10)), 10) AS custid, + 1 + ABS(CHECKSUM(NEWID())) % @numemps AS empid, + CHAR(ASCII('A') - 2 + + 2 * (1 + ABS(CHECKSUM(NEWID())) % @numshippers)) AS shipperid, + DATEADD(day, n / (@numorders / (@numyears * 365.25)) + -- late arrival with earlier date + - CASE WHEN n % 10 = 0 + THEN 1 + ABS(CHECKSUM(NEWID())) % 30 + ELSE 0 + END, @startdate) + AS orderdate + FROM dbo.GetNums(1, @numorders) + ORDER BY CHECKSUM(NEWID()) +OPTION(MAXDOP 1); + +CREATE CLUSTERED INDEX idx_cl_od ON dbo.Orders(orderdate); + +CREATE NONCLUSTERED INDEX idx_nc_sid_od_cid + ON dbo.Orders(shipperid, orderdate, custid); + +CREATE UNIQUE INDEX idx_unc_od_oid_i_cid_eid + ON dbo.Orders(orderdate, orderid) + INCLUDE(custid, empid); + +ALTER TABLE dbo.Orders ADD + CONSTRAINT PK_Orders PRIMARY KEY NONCLUSTERED(orderid), + CONSTRAINT FK_Orders_Customers + FOREIGN KEY(custid) REFERENCES dbo.Customers(custid), + CONSTRAINT FK_Orders_Employees + FOREIGN KEY(empid) REFERENCES dbo.Employees(empid), + CONSTRAINT FK_Orders_Shippers + FOREIGN KEY(shipperid) REFERENCES dbo.Shippers(shipperid); +GO + +-- data distribution settings for dw (2,500,000 rows) +DECLARE + @dim1rows AS INT = 250, + @dim2rows AS INT = 50, + @dim3rows AS INT = 200; + +CREATE TABLE dbo.Dim1 +( + key1 INT NOT NULL CONSTRAINT PK_Dim1 PRIMARY KEY, + attr1 INT NOT NULL, + filler BINARY(100) NOT NULL DEFAULT (0x) +); + +CREATE TABLE dbo.Dim2 +( + key2 INT NOT NULL CONSTRAINT PK_Dim2 PRIMARY KEY, + attr1 INT NOT NULL, + filler BINARY(100) NOT NULL DEFAULT (0x) +); + +CREATE TABLE dbo.Dim3 +( + key3 INT NOT NULL CONSTRAINT PK_Dim3 PRIMARY KEY, + attr1 INT NOT NULL, + filler BINARY(100) NOT NULL DEFAULT (0x) +); + +CREATE TABLE dbo.Fact +( + key1 INT NOT NULL, + key2 INT NOT NULL, + key3 INT NOT NULL, + measure1 INT NOT NULL, + measure2 INT NOT NULL, + measure3 INT NOT NULL, + measure4 NVARCHAR(50) NULL, + filler BINARY(100) NOT NULL DEFAULT (0x), + CONSTRAINT PK_Fact PRIMARY KEY(key1, key2, key3) +); + +INSERT INTO dbo.Dim1(key1, attr1) + SELECT n, ABS(CHECKSUM(NEWID())) % 20 + 1 + FROM dbo.GetNums(1, @dim1rows); + +INSERT INTO dbo.Dim2(key2, attr1) + SELECT n, ABS(CHECKSUM(NEWID())) % 10 + 1 + FROM dbo.GetNums(1, @dim2rows); + +INSERT INTO dbo.Dim3(key3, attr1) + SELECT n, ABS(CHECKSUM(NEWID())) % 40 + 1 + FROM dbo.GetNums(1, @dim3rows); + +INSERT INTO dbo.Fact WITH (TABLOCK) + (key1, key2, key3, measure1, measure2, measure3, measure4) + SELECT D1.key1, D2.key2, D3.key3, + ABS(CHECKSUM(NEWID())) % 10000 + 1, + ABS(CHECKSUM(NEWID())) % 100000 + 1, + ABS(CHECKSUM(NEWID())) % 1000000 + 1, + N'S' + REPLICATE(CAST(ABS(CHECKSUM(NEWID())) % 100000 + 1 AS NVARCHAR(10)), 5) + FROM dbo.Dim1 AS D1 + CROSS JOIN dbo.Dim2 AS D2 + CROSS JOIN dbo.Dim3 AS D3; diff --git a/Sample_Databases/README.md b/Sample_Databases/README.md new file mode 100644 index 00000000..f3e9a3ea --- /dev/null +++ b/Sample_Databases/README.md @@ -0,0 +1,79 @@ +# SQL Server Sample Databases and Datasets +Some databases you can download from this repository: https://rebrand.ly/sample-db + + +## Sample databases information + +| Name / Download links | SQL Server Version | Type | .Bak, MB | .Mdf, MB | Table count | +|-----------------------------------------|--------------------|----------|---------:|---------:|------------:| +| [StackOverflow 2010 Database] | >=2012 | OLTP | 9360 | 9104 | 9 | +| [StackOverflow Database] | >=2012 | OLTP | 137000 | | 9 | +| [StackOverflow Column Store Edition] | >=2017 | OLTP | 160000 | | 9 | +| [WideWorldImporters OLTP] | ? | OLTP | 121 | 1024 | 29 | +| [WideWorldImporters OLTP Legacy] | >=2008 | OLTP | 64 | 391 | 31 | +| [WideWorldImporters DWH] | ? | DWH | 47 | 2048 | 48 | +| [AdventureWorks OLTP 2017] | 2017 | OLTP | 47 | 264 | 71 | +| [AdventureWorks OLTP 2016] | >=2016 | OLTP | 93 | 208 | 96 | +| [AdventureWorks OLTP 2016 Extended] | >=2016 | OLTP | 125 | 386 | 71 | +| [AdventureWorks OLTP 2014] | >=2014 | OLTP | 44 | 205 | 71 | +| [AdventureWorks OLTP 2012] | >=2012 | OLTP | 44 | 192 | 71 | +| [AdventureWorks DWH 2017] | >=2017 | DWH | 22 | 136 | 31 | +| [AdventureWorks DWH 2016] | >=2016 | DWH | 21 | 170 | 31 | +| [AdventureWorks DWH 2016 Extended] | >=2016 | DWH | 883 | 1466 | 33 | +| [AdventureWorks DWH 2014] | >=2014 | DWH | 21 | 170 | 31 | +| [AdventureWorks DWH 2012] | >=2012 | DWH | 21 | 124 | 31 | +| [AdventureWorks Multidimensional Model] | ? | AS | 21 | ? | ? | +| [AdventureWorks Tabular Model] | ? | AS | 21 | ? | ? | +| [Northwind Database][1] | 2000 | OLTP | - | ? | ? | +| [Pub Database][1] | 2000 | OLTP | - | ? | ? | +| [Oracle Employee Database] | 2000 | OLTP | 3 | 4 | 2 | +| [DunderMifflin] | ? | OLTP | - | - | ? | + +[StackOverflow 2010 Database]:https://www.brentozar.com/archive/2015/10/how-to-download-the-stack-overflow-database-via-bittorrent/ +[StackOverflow Database]:https://www.brentozar.com/archive/2015/10/how-to-download-the-stack-overflow-database-via-bittorrent/ +[StackOverflow Column Store Edition]:https://www.erikdarlingdata.com/2019/11/stack-overflow-demo-database-column-store-edition-downloads-and-links/ +[WideWorldImporters OLTP Legacy]:https://www.sentryone.com/blog/aaronbertrand/plan-explorer-3-0-demo-kit +[WideWorldImporters OLTP]:https://github.com/Microsoft/sql-server-samples/releases/tag/wide-world-importers-v1.0 +[WideWorldImporters DWH]:https://github.com/Microsoft/sql-server-samples/releases/tag/wide-world-importers-v1.0 +[AdventureWorks OLTP 2017]:https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorks2017.bak +[AdventureWorks OLTP 2016]:https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorks2016.bak +[AdventureWorks OLTP 2016 Extended]:https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorks2016_EXT.bak +[AdventureWorks OLTP 2014]:https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorks2014.bak +[AdventureWorks OLTP 2012]:https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorks2012.bak +[AdventureWorks DWH 2017]:https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksDW2017.bak +[AdventureWorks DWH 2016]:https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksDW2016.bak +[AdventureWorks DWH 2016 Extended]:https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksDW2016_EXT.bak +[AdventureWorks DWH 2014]:https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksDW2014.bak +[AdventureWorks DWH 2012]:https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksDW2012.bak +[AdventureWorks Multidimensional Model]:https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks-analysis-services/adventure-works-multidimensional-model-full-database-backup.zip +[AdventureWorks Tabular Model]:https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks-analysis-services/adventure-works-tabular-model-1200-full-database-backup.zip +[1]:https://github.com/Microsoft/sql-server-samples/tree/master/samples/databases/northwind-pubs +[Oracle Employee Database]:https://github.com/ktaranov/sqlserver-kit/blob/master/Sample_Databases/Oracle_Employee_Database.sql +[DunderMifflin]:https://github.com/tdmitch/DunderMifflin + +## Datasets + - [Data.gov](https://www.data.gov/) + - [Amazon product data](http://jmcauley.ucsd.edu/data/amazon/) (This dataset contains product reviews and metadata from Amazon, including 142.8 million reviews spanning May 1996 - July 2014) + + +## Useful Links + - [AdventureWorks Sample Databases and Scripts for SQL Server 2017, 2016, 2014 , 2012](https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks) + - [AdventureWorks for Analysis Services](https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks-analysis-services) + - [AdventureWorks Sample Databases and Scripts for SQL Server 2008 R2](https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks2008r2) + - [Microsoft SQL Server 2008 R2 SR1 Sample Databases](https://sqlserversamples.codeplex.com/releases/view/72278) + - [Thinking Big (Adventure)](http://sqlblog.com/blogs/adam_machanic/archive/2011/10/17/thinking-big-adventure.aspx) (by Adam Machanic) + - [WideWorldImporters Sample Database]() (Github Microsoft) + - [IoT Smart Grid sample - demonstrates how SQL Server 2016 memory optimized databases could be used to ingest a very high input data rate](https://github.com/Microsoft/sql-server-samples/releases/tag/iot-smart-grid-v2.0) (Github Microsoft) + - [In-Memory OLTP (WWI Sales Orders)](https://github.com/Microsoft/sql-server-samples/releases/tag/wwi-sales-orders-v0.5) (Github Microsoft) + - [Bigger Fact Table for Wide World Importers](http://www.sqlservercentral.com/blogs/koen-verbeeck/2016/08/12/bigger-fact-table-for-wide-world-importers/) (by Koen Verbeeck) + - [Contoso Retail Data Warehose](https://github.com/Microsoft/sql-server-samples/tree/master/samples/databases/contoso-data-warehouse) (Github) + - [How to Download the Stack Overflow Database via BitTorrent 2016-03](https://www.brentozar.com/archive/2015/10/how-to-download-the-stack-overflow-database-via-bittorrent/) (by Brent Ozar) + - [Stack Overflow Database version 2016-12-15](https://www.brentozar.com/archive/2017/01/updating-stack-overflow-demo-database/) + - [Stackexchange Source files - xml files](https://archive.org/download/stackexchange) + - [Git repo for SQL Server Reporting Services samples and community projects](https://github.com/Microsoft/Reporting-Services) + - [SQLSkills sample databases](https://www.sqlskills.com/sql-server-resources/sql-server-demos/) (also include SAMPLE CORRUPT DATABASES) + - [SQLIndexWorkbook Sample Database](http://www.littlekendra.com/downloads/get-the-sqlindexworkbook-database/) (by Little Kendra) + - [Itzik Ben-Gan Sample Databases](http://tsql.solidq.com/books/source_code/) (by Itzik Ben-Gan) + - [Orders: Open Source Sample Database](https://www.brentozar.com/orders-open-source-sample-database/) (by Brent Ozar) + - [BabbyNames Database](https://github.com/LitKnd/BabbyNames) (by Kendra Little) + - [SQL Server Sakila DB](https://www.jooq.org/sakila) (by jOQO) diff --git a/Sample_Databases/TSQLV4.sql b/Sample_Databases/TSQLV4.sql new file mode 100644 index 00000000..0ccc3960 Binary files /dev/null and b/Sample_Databases/TSQLV4.sql differ diff --git a/Scripts/Adding_Trace_Flags_To_Startup_Parameters.sql b/Scripts/Adding_Trace_Flags_To_Startup_Parameters.sql new file mode 100644 index 00000000..9872dd1a --- /dev/null +++ b/Scripts/Adding_Trace_Flags_To_Startup_Parameters.sql @@ -0,0 +1,109 @@ +/****************************************************************************** +Source link: https://blog.waynesheffield.com/wayne/archive/2017/09/registry-sql-server-startup-parameters/ +Author: Wayne Sheffield + +Description: Globally enable or disable the specified trace flags. +Use DBCC TRACEON/TRACEOFF to enable or disable trace flags globally, +then adjust the SQL Server instance startup parameters for these trace flags. + +SQL Server startup parameters are stored in the registry at: +HKLM\Software\Microsoft\MSSQLSERVER\MSSQLServer\Parameters + +To use the xp_instance_reg... XPs, use: +HKLM\Software\Microsoft\MSSQLSERVER\MSSQLServer\Parameters. + +Usage: +1. Add the Trace Flags that you want modified to the @TraceFlags table variable. +2. Set the @DebugLevel variable to 1 to see what will happen on your system first. +3. When satisfied with the output, set @DebugLevel to 0 to actually execute the statements. +******************************************************************************** +MODIFICATION LOG +******************************************************************************** +2016-08-03 WGS Initial Creation. +*******************************************************************************/ +SET NOCOUNT ON; + +DECLARE @MaxValue INT, + @SQLCMD VARCHAR(MAX), + @RegHive VARCHAR(50) = 'HKEY_LOCAL_MACHINE', + @RegKey VARCHAR(100) = 'Software\Microsoft\MSSQLSERVER\MSSQLServer\Parameters', + @DebugLevel TINYINT = 1; + +DECLARE @TraceFlags TABLE ( + TF INT, + enable BIT, + enable_on_startup BIT, + TF2 AS '-T' + CONVERT(VARCHAR(15), TF) +); +INSERT INTO @TraceFlags (TF, enable, enable_on_startup) +VALUES (1117, 1, 1), + (1118, 1, 1), + (1204, 0, 0), + (1222, 0, 0); + +DECLARE @SQLArgs TABLE ( + Value VARCHAR(50), + Data VARCHAR(500), + ArgNum AS CONVERT(INT, REPLACE(Value, 'SQLArg', '')) +); +INSERT INTO @SQLArgs +EXEC master.sys.xp_instance_regenumvalues @RegHive, @RegKey; + +SELECT @MaxValue = MAX(ArgNum) FROM @SQLArgs; +PRINT 'MaxValue: ' + CAST(@MaxValue AS VARCHAR); + +SELECT @SQLCMD = 'DBCC TRACEOFF(' + + STUFF((SELECT ',' + CONVERT(VARCHAR(15), TF) + FROM @TraceFlags + WHERE enable = 0 + ORDER BY TF + FOR XML PATH(''), TYPE).value('.','varchar(max)'), 1, 1, '') + ', -1);'; +IF @DebugLevel = 0 EXEC (@SQLCMD); +PRINT 'Disable TFs Command: "' + @SQLCMD + '"'; + +SELECT @SQLCMD = 'DBCC TRACEON(' + + STUFF((SELECT ',' + CONVERT(VARCHAR(15), TF) + FROM @TraceFlags + WHERE enable = 1 + ORDER BY TF + FOR XML PATH(''), TYPE).value('.','varchar(max)'), 1, 1, '') + ', -1);'; +IF @DebugLevel = 0 EXEC (@SQLCMD); +PRINT 'Enable TFs Command: "' + @SQLCMD + '"'; + +DECLARE cSQLParams CURSOR LOCAL FAST_FORWARD FOR +WITH cte AS ( + SELECT * , + ROW_NUMBER() OVER (ORDER BY ISNULL(ArgNum, 999999999), TF) - 1 AS RN + FROM @SQLArgs arg + FULL OUTER JOIN @TraceFlags tf ON arg.Data = tf.TF2 +), cte2 AS ( + SELECT ca.Value, ca.Data, + ROW_NUMBER() OVER (ORDER BY RN) - 1 AS RN2 + FROM cte + CROSS APPLY (SELECT ISNULL(Value, 'SQLArg' + CONVERT(VARCHAR(15), RN)), ISNULL(Data, TF2)) ca(Value, Data) + WHERE ISNULL(enable_on_startup, 1) = 1 +) +SELECT 'SQLArg' + CONVERT(VARCHAR(15), RN2) AS Value, Data, MAX(RN2) OVER () AS MaxRN2 +FROM cte2 +WHERE RN2 > 2 +ORDER BY RN2; + +DECLARE @Value VARCHAR(50), @Data VARCHAR(500), @MaxRN2 INT; +OPEN cSQLParams; +FETCH NEXT FROM cSQLParams INTO @Value, @Data, @MaxRN2; +WHILE @@FETCH_STATUS = 0 +BEGIN + IF @DebugLevel = 0 EXEC master.sys.xp_instance_regwrite @RegHive, @RegKey, @Value, 'REG_SZ', @Data; + PRINT 'EXEC master.sys.xp_instance_regwrite ''' + @RegHive + ''', ''' + @RegKey + ''', ''' + @Value + ''', ''REG_SZ'', ''' + @Data + ''''; + FETCH NEXT FROM cSQLParams INTO @Value, @Data, @MaxRN2; +END; +CLOSE cSQLParams; +DEALLOCATE cSQLParams; + +WHILE @MaxValue > @MaxRN2 +BEGIN + SET @Value = 'SQLArg' + CONVERT(VARCHAR(15), @MaxValue); + IF @DebugLevel = 0 EXEC master.sys.xp_instance_regdeletevalue @RegHive, @RegKey, @Value; + PRINT 'EXEC master.sys.xp_instance_regdeletevalue ''' + @RegHive + ''', ''' + @RegKey + ''', ''' + @Value + ''''; + SET @MaxValue = @MaxValue - 1; +END; diff --git a/Scripts/Auto_Generate_Database_Documentation.sql b/Scripts/Auto_Generate_Database_Documentation.sql new file mode 100644 index 00000000..27889cd1 --- /dev/null +++ b/Scripts/Auto_Generate_Database_Documentation.sql @@ -0,0 +1,185 @@ +/* +.EXAMPLE + Connect SSMS to the database in which you wish to create extended properties and hit F5. + +.DESCRIPTION: + This script will not create the extended properties, but auto generate the commands to do so. + The actual value (@value parameter) of the extended property still has to be manually input. + This script will automatically add the user and date to the extended property value. + +.NOTE + Version: 1.1 + Modified: 2018-03-30 23:40:00 UTC+3 Konstantin Taranov + Link: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Auto_Generate_Database_Documentation.sql + Created: 2015-11-25 + Author: (C) Andy Jones mailto:andrew@aejsoftware.co.uk +*/ +DECLARE @Parameter TABLE + ( + [type_desc] sysname NOT NULL, + parameter sysname NOT NULL, + val NVARCHAR(100) NOT NULL, + PRIMARY KEY ( [type_desc], parameter ) + ); + + +/*set up the data for each object type specifying the correct value for each parameter.*/ +INSERT INTO @Parameter + ( [type_desc], parameter, val ) +VALUES ( N'CHECK_CONSTRAINT', N'value', N'_replace_value' ), + ( N'CHECK_CONSTRAINT', N'level0type', N'SCHEMA' ), + ( N'CHECK_CONSTRAINT', N'level0name', N'_replace_schemaname' ), + ( N'CHECK_CONSTRAINT', N'level1type', N'TABLE' ), + ( N'CHECK_CONSTRAINT', N'level1name', N'_replace_parentname' ), + ( N'CHECK_CONSTRAINT', N'level2type', N'CONSTRAINT' ), + ( N'CHECK_CONSTRAINT', N'level2name', N'_replace_name' ), + ( N'FOREIGN_KEY_CONSTRAINT', N'value', N'_replace_value' ), + ( N'FOREIGN_KEY_CONSTRAINT', N'level0type', N'SCHEMA' ), + ( N'FOREIGN_KEY_CONSTRAINT', N'level0name', N'_replace_schemaname' ), + ( N'FOREIGN_KEY_CONSTRAINT', N'level1type', N'TABLE' ), + ( N'FOREIGN_KEY_CONSTRAINT', N'level1name', N'_replace_parentname' ), + ( N'FOREIGN_KEY_CONSTRAINT', N'level2type', N'CONSTRAINT' ), + ( N'FOREIGN_KEY_CONSTRAINT', N'level2name', N'_replace_name' ), + ( N'PRIMARY_KEY_CONSTRAINT', N'value', N'_replace_value' ), + ( N'PRIMARY_KEY_CONSTRAINT', N'level0type', N'SCHEMA' ), + ( N'PRIMARY_KEY_CONSTRAINT', N'level0name', N'_replace_schemaname' ), + ( N'PRIMARY_KEY_CONSTRAINT', N'level1type', N'TABLE' ), + ( N'PRIMARY_KEY_CONSTRAINT', N'level1name', N'_replace_parentname' ), + ( N'PRIMARY_KEY_CONSTRAINT', N'level2type', N'CONSTRAINT' ), + ( N'PRIMARY_KEY_CONSTRAINT', N'level2name', N'_replace_name' ), + ( N'UNIQUE_CONSTRAINT', N'value', N'_replace_value' ), + ( N'UNIQUE_CONSTRAINT', N'level0type', N'SCHEMA' ), + ( N'UNIQUE_CONSTRAINT', N'level0name', N'_replace_schemaname' ), + ( N'UNIQUE_CONSTRAINT', N'level1type', N'TABLE' ), + ( N'UNIQUE_CONSTRAINT', N'level1name', N'_replace_parentname' ), + ( N'UNIQUE_CONSTRAINT', N'level2type', N'CONSTRAINT' ), + ( N'UNIQUE_CONSTRAINT', N'level2name', N'_replace_name' ), + ( N'SQL_STORED_PROCEDURE', N'value', N'_replace_value' ), + ( N'SQL_STORED_PROCEDURE', N'level0type', N'SCHEMA' ), + ( N'SQL_STORED_PROCEDURE', N'level0name', N'_replace_schemaname' ), + ( N'SQL_STORED_PROCEDURE', N'level1type', N'PROCEDURE' ), + ( N'SQL_STORED_PROCEDURE', N'level1name', N'_replace_name' ), + ( N'SQL_STORED_PROCEDURE', N'level2type', N'NULL' ), + ( N'SQL_STORED_PROCEDURE', N'level2name', N'NULL' ), + ( N'SQL_INLINE_TABLE_VALUED_FUNCTION', N'value', N'_replace_value' ), + ( N'SQL_INLINE_TABLE_VALUED_FUNCTION', N'level0type', N'SCHEMA' ), + ( N'SQL_INLINE_TABLE_VALUED_FUNCTION', N'level0name', + N'_replace_schemaname' ), + ( N'SQL_INLINE_TABLE_VALUED_FUNCTION', N'level1type', N'FUNCTION' ), + ( N'SQL_INLINE_TABLE_VALUED_FUNCTION', N'level1name', N'_replace_name' ), + ( N'SQL_INLINE_TABLE_VALUED_FUNCTION', N'level2type', N'NULL' ), + ( N'SQL_INLINE_TABLE_VALUED_FUNCTION', N'level2name', N'NULL' ), + ( N'SQL_SCALAR_FUNCTION', N'value', N'_replace_value' ), + ( N'SQL_SCALAR_FUNCTION', N'level0type', N'SCHEMA' ), + ( N'SQL_SCALAR_FUNCTION', N'level0name', N'_replace_schemaname' ), + ( N'SQL_SCALAR_FUNCTION', N'level1type', N'FUNCTION' ), + ( N'SQL_SCALAR_FUNCTION', N'level1name', N'_replace_name' ), + ( N'SQL_SCALAR_FUNCTION', N'level2type', N'NULL' ), + ( N'SQL_SCALAR_FUNCTION', N'level2name', N'NULL' ), + ( N'USER_TABLE', N'value', N'_replace_value' ), + ( N'USER_TABLE', N'level0type', N'SCHEMA' ), + ( N'USER_TABLE', N'level0name', N'_replace_schemaname' ), + ( N'USER_TABLE', N'level1type', N'TABLE' ), + ( N'USER_TABLE', N'level1name', N'_replace_name' ), + ( N'USER_TABLE', N'level2type', N'NULL' ), + ( N'USER_TABLE', N'level2name', N'NULL' ), + ( N'INDEX', N'value', N'_replace_value' ), + ( N'INDEX', N'level0type', N'SCHEMA' ), + ( N'INDEX', N'level0name', N'_replace_schemaname' ), + ( N'INDEX', N'level1type', N'TABLE' ), + ( N'INDEX', N'level1name', N'_replace_parentname' ), + ( N'INDEX', N'level2type', N'INDEX' ), + ( N'INDEX', N'level2name', N'_replace_name' ), + ( N'COLUMN', N'value', N'_replace_value' ), + ( N'COLUMN', N'level0type', N'SCHEMA' ), + ( N'COLUMN', N'level0name', N'_replace_schemaname' ), + ( N'COLUMN', N'level1type', N'TABLE' ), + ( N'COLUMN', N'level1name', N'_replace_parentname' ), + ( N'COLUMN', N'level2type', N'COLUMN' ), + ( N'COLUMN', N'level2name', N'_replace_name' ); + + +WITH Obj /*union all objects on which to create extended properties. Objects, columns and indexes.*/ + AS ( SELECT parentname = COALESCE(OBJECT_NAME(obj.parent_object_id), + obj.name) , + name = obj.name , + schemaname = SCHEMA_NAME(obj.[schema_id]) , + [type_desc] = obj.[type_desc] , + major_id = obj.[object_id] , + minor_id = 0, +class_desc = N'OBJECT_OR_COLUMN' + FROM sys.objects AS obj + WHERE obj.is_ms_shipped = 0 + UNION ALL + SELECT parentname = OBJECT_NAME(c.[object_id]) , + name = c.name , + schemaname = OBJECT_SCHEMA_NAME(c.[object_id]) , + [type_desc] = N'COLUMN' , + major_id = c.[object_id] , + minor_id = c.column_id, +class_desc = N'OBJECT_OR_COLUMN' + FROM sys.columns AS c + WHERE OBJECTPROPERTYEX(c.[object_id], 'IsMSShipped') = 0 + AND OBJECTPROPERTYEX(c.[object_id], 'IsUserTable') = 1 --only document table columns, not views/functions. Remove predicate if required. + UNION ALL + SELECT parentname = OBJECT_NAME(i.[object_id]) , + name = i.name , + schemaname = OBJECT_SCHEMA_NAME(i.[object_id]) , + [type_desc] = N'INDEX' , + major_id = i.[object_id] , + minor_id = i.index_id, +class_desc = N'INDEX' + FROM sys.indexes AS i + WHERE OBJECTPROPERTYEX(i.[object_id], 'IsMSShipped') = 0 + AND i.is_primary_key = 0 --the constraint is already documented, don't document the index too. Remove predicate if required. + AND i.is_unique_constraint = 0 --the constraint is already documented, don't document the index too. Remove predicate if required. +AND i.[type_desc] <> N'HEAP' --the table is already documented, don't document the heap index row too. + ), +/*Join objects on which to create extended properties to the parameters, performing string replacement where necessary.*/ + Parameter_Value + AS ( SELECT o.major_id , + o.minor_id , +o.class_desc, + p.parameter , +[name] = N'MS_Description', + val = CASE p.val + WHEN N'_replace_schemaname' THEN o.schemaname + WHEN N'_replace_parentname' THEN o.parentname + WHEN N'_replace_name' THEN o.name + WHEN N'_replace_value' + THEN SYSTEM_USER + N' ' + + CONVERT(CHAR(10), CURRENT_TIMESTAMP, 103) + + N': ' + p.val + ELSE p.val + END + FROM @Parameter AS p + INNER JOIN Obj AS o ON o.[type_desc] = p.[type_desc] COLLATE DATABASE_DEFAULT + ) +/*pivot the result set so we have one correctly formatted extended property create statement per object.*/ + SELECT Add_Extended_Property = N'EXECUTE sp_addextendedproperty' + + N' @name = ''' + [name] + N''', @value = ' + [value] + + N', @level0type = ' + [level0type] + N', @level0name = ' + + [level0name] + N', @level1type = ' + [level1type] + + N', @level1name = ' + [level1name] + N', @level2type = ' + + [level2type] + N', @level2name = ' + [level2name] + N';' + FROM ( SELECT pv.major_id , + pv.minor_id , +pv.class_desc, +pv.[name], + pv.parameter , + val = CASE pv.val + WHEN N'NULL' THEN pv.val + ELSE '''' + pv.val + '''' + END + FROM Parameter_Value AS pv + WHERE NOT EXISTS ( SELECT * + FROM sys.extended_properties AS ep + WHERE ep.major_id = pv.major_id + AND ep.minor_id = pv.minor_id +AND ep.class_desc = pv.class_desc +AND ep.[name] = pv.[name] ) + ) AS SourceTable PIVOT +( MIN(val) FOR parameter IN ( [value], [level0type], [level0name], + [level1type], [level1name], [level2type], + [level2name] ) ) AS PivotTable + ORDER BY Add_Extended_Property; diff --git a/Scripts/Azure SQL Database Diagnostic Information Queries.sql b/Scripts/Azure SQL Database Diagnostic Information Queries.sql index 90c9187b..c04f7cd8 100644 --- a/Scripts/Azure SQL Database Diagnostic Information Queries.sql +++ b/Scripts/Azure SQL Database Diagnostic Information Queries.sql @@ -1,24 +1,26 @@ - -- Azure SQL Database Diagnostic Information Queries -- Glenn Berry --- Last Modified: September 26, 2017 --- https://www.sqlskills.com/blogs/glenn/ --- http://sqlserverperformance.wordpress.com/ +-- Last Modified: September 1, 2020 +-- https://glennsqlperformance.com/ +-- https://sqlserverperformance.wordpress.com/ +-- YouTube: https://bit.ly/2PkoAM1 -- Twitter: GlennAlanBerry --- Please listen to my Pluralsight courses --- https://www.pluralsight.com/author/glenn-berry +-- Diagnostic Queries are available here +-- https://glennsqlperformance.com/resources/ + --- If you want to find all of our SQLskills SQL101 blog posts, check out https://www.sqlskills.com/help/sql101/ +-- If you like PowerShell, there is a very useful community solution for running these queries in an automated fashion +-- https://dbatools.io/ +-- Invoke-DbaDiagnosticQuery +-- https://dbatools.io/functions/invoke-dbadiagnosticquery/ --****************************************************************************** ---* Copyright (C) 2017 Glenn Berry, SQLskills.com +--* Copyright (C) 2020 Glenn Berry --* All rights reserved. --* ---* For more scripts and sample code, check out ---* https://www.sqlskills.com/blogs/glenn --* --* You may alter this code for your own *non-commercial* purposes. You may --* republish altered code as long as you include this copyright and give due credit. @@ -34,17 +36,17 @@ -- Make sure you are connected a user database, rather than the master system database --- Instance level queries ******************************* +-- Server level queries ******************************* -- SQL and OS Version information for current instance (Query 1) (Version Info) SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version Info]; ------ --- Azure SQL Database does not expose as much information as on-premise SQL Server does +-- Azure SQL Database does not expose as much information as on-premises SQL Server does --- Get instance-level configuration values for instance (Query 2) (Configuration Values) +-- Get logical instance-level configuration values for instance (Query 2) (Configuration Values) SELECT name, value, value_in_use, minimum, maximum, [description], is_dynamic, is_advanced FROM sys.configurations WITH (NOLOCK) ORDER BY name OPTION (RECOMPILE); @@ -66,27 +68,14 @@ WHERE node_state_desc <> N'ONLINE DAC' OPTION (RECOMPILE); --- Get recent resource usage (Query 4) (Resource Usage) -SELECT avg_cpu_percent, avg_data_io_percent, avg_log_write_percent, avg_memory_usage_percent, xtp_storage_percent, - max_worker_percent, max_session_percent, dtu_limit, avg_login_rate_percent, end_time -FROM sys.dm_db_resource_stats WITH (NOLOCK) -ORDER BY end_time DESC OPTION (RECOMPILE); ------- - --- sys.dm_db_resource_stats (Azure SQL Database) --- https://docs.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-db-resource-stats-azure-sql-database - - - --- Calculates average stalls per read, per write, and per total input/output for each database file (Query 5) (IO Stalls by File) -SELECT DB_NAME(fs.database_id) AS [Database Name], CAST(fs.io_stall_read_ms/(1.0 + fs.num_of_reads) AS NUMERIC(10,1)) AS [avg_read_stall_ms], -CAST(fs.io_stall_write_ms/(1.0 + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_write_stall_ms], -CAST((fs.io_stall_read_ms + fs.io_stall_write_ms)/(1.0 + fs.num_of_reads + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_io_stall_ms], +-- Calculates average stalls per read, per write, and per total input/output for each database file (Query 4) (IO Stalls by File) +SELECT DB_NAME(fs.database_id) AS [Database Name], CAST(fs.io_stall_read_ms/(1.0 + fs.num_of_reads) AS NUMERIC(16,1)) AS [avg_read_stall_ms], +CAST(fs.io_stall_write_ms/(1.0 + fs.num_of_writes) AS NUMERIC(16,1)) AS [avg_write_stall_ms], +CAST((fs.io_stall_read_ms + fs.io_stall_write_ms)/(1.0 + fs.num_of_reads + fs.num_of_writes) AS NUMERIC(16,1)) AS [avg_io_stall_ms], fs.io_stall_read_ms, fs.num_of_reads, fs.io_stall_write_ms, fs.num_of_writes, fs.io_stall_read_ms + fs.io_stall_write_ms AS [io_stalls], fs.num_of_reads + fs.num_of_writes AS [total_io], -io_stall_queued_read_ms AS [Resource Governor Total Read IO Latency (ms)], io_stall_queued_write_ms AS [Resource Governor Total Write IO Latency (ms)] +io_stall_queued_read_ms AS [Resource Governor Total Read IO Latency (ms)], io_stall_queued_write_ms AS [Resource Governor Total Write IO Latency (ms)] FROM sys.dm_io_virtual_file_stats(null,null) AS fs -WHERE database_id NOT IN (4, 5, 32767) ORDER BY avg_io_stall_ms DESC OPTION (RECOMPILE); ------ @@ -98,64 +87,21 @@ ORDER BY avg_io_stall_ms DESC OPTION (RECOMPILE); - --- Important database properties for all databases on instance (Query 6) (Database Properties) -SELECT db.[name] AS [Database Name], db.recovery_model_desc AS [Recovery Model], -db.state_desc, db.containment_desc, db.log_reuse_wait_desc AS [Log Reuse Wait Description], -db.[compatibility_level] AS [DB Compatibility Level], -db.is_mixed_page_allocation_on, db.page_verify_option_desc AS [Page Verify Option], -db.is_auto_create_stats_on, db.is_auto_update_stats_on, db.is_auto_update_stats_async_on, db.is_parameterization_forced, -db.snapshot_isolation_state_desc, db.is_read_committed_snapshot_on, db.is_auto_close_on, db.is_auto_shrink_on, -db.target_recovery_time_in_seconds, db.is_cdc_enabled, db.is_memory_optimized_elevate_to_snapshot_on, -db.delayed_durability_desc, db.is_auto_create_stats_incremental_on, -db.is_query_store_on, db.is_sync_with_backup, db.is_temporal_history_retention_enabled, -db.is_encrypted -FROM sys.databases AS db WITH (NOLOCK) -ORDER BY db.[name] OPTION (RECOMPILE); ------- - --- Things to look at: --- How many databases are on the instance? --- What recovery models are they using? --- What is the log reuse wait description? --- What compatibility level are the databases on? --- What is the Page Verify Option? (should be CHECKSUM) --- Is Auto Update Statistics Asynchronously enabled? --- Is Delayed Durability enabled? --- Make sure auto_shrink and auto_close are not enabled! - - - --- Get VLF Counts for all databases on the instance (Query 7) (VLF Counts) -SELECT[name] AS [Database Name],[VLF Count] -FROMsys.databasesAS db WITH (NOLOCK) -CROSS APPLY(SELECTfile_id, COUNT(*)AS [VLF Count] - FROM sys.dm_db_log_info(db.database_id) - GROUP BYfile_id)AS li -ORDER BY [VLF Count] DESC OPTION (RECOMPILE); ------- - --- High VLF counts can affect write performance to the log file --- and they can make full database restores and crash recovery take much longer --- Try to keep your VLF counts under 200 in most cases (depending on log file size) - --- Important change to VLF creation algorithm in SQL Server 2014 --- https://www.sqlskills.com/blogs/paul/important-change-vlf-creation-algorithm-sql-server-2014/ - - - - --- Get I/O utilization by database (Query 8) (IO Usage By Database) +-- Get I/O utilization by database (Query 5) (IO Usage By Database) WITH Aggregate_IO_Statistics -AS -(SELECT DB_NAME(database_id) AS [Database Name], -CAST(SUM(num_of_bytes_read + num_of_bytes_written)/1048576 AS DECIMAL(12, 2)) AS io_in_mb -FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS [DM_IO_STATS] -WHERE database_id NOT IN (4, 5, 32767) -GROUP BY database_id) -SELECT ROW_NUMBER() OVER(ORDER BY io_in_mb DESC) AS [I/O Rank], [Database Name], - CAST(io_in_mb/ SUM(io_in_mb) OVER() * 100.0 AS DECIMAL(5,2)) AS [I/O Percent], - io_in_mb AS [Total I/O (MB)] +AS (SELECT DB_NAME(database_id) AS [Database Name], + CAST(SUM(num_of_bytes_read + num_of_bytes_written) / 1048576 AS DECIMAL(12, 2)) AS [ioTotalMB], + CAST(SUM(num_of_bytes_read ) / 1048576 AS DECIMAL(12, 2)) AS [ioReadMB], + CAST(SUM(num_of_bytes_written) / 1048576 AS DECIMAL(12, 2)) AS [ioWriteMB] + FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS [DM_IO_STATS] + GROUP BY database_id) +SELECT ROW_NUMBER() OVER (ORDER BY ioTotalMB DESC) AS [I/O Rank], + [Database Name], ioTotalMB AS [Total I/O (MB)], + CAST(ioTotalMB / SUM(ioTotalMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Total I/O %], + ioReadMB AS [Read I/O (MB)], + CAST(ioReadMB / SUM(ioReadMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Read I/O %], + ioWriteMB AS [Write I/O (MB)], + CAST(ioWriteMB / SUM(ioWriteMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Write I/O %] FROM Aggregate_IO_Statistics ORDER BY [I/O Rank] OPTION (RECOMPILE); ------ @@ -163,7 +109,7 @@ ORDER BY [I/O Rank] OPTION (RECOMPILE); -- Helps determine which database is using the most I/O resources on the instance --- Get total buffer usage by database for current instance (Query 9) (Total Buffer Usage by Database) +-- Get total buffer usage by database for current instance (Query 6) (Total Buffer Usage by Database) -- This make take some time to run on a busy instance WITH AggregateBufferPoolUsage AS @@ -171,7 +117,6 @@ AS CAST(COUNT(*) * 8/1024.0 AS DECIMAL (10,2)) AS [CachedSize], AVG(read_microsec) AS [Avg Read Time (microseconds)] FROM sys.dm_os_buffer_descriptors WITH (NOLOCK) -WHERE database_id NOT IN (4, 5, 32767) GROUP BY DB_NAME(database_id)) SELECT ROW_NUMBER() OVER(ORDER BY CachedSize DESC) AS [Buffer Pool Rank], [Database Name], CAST(CachedSize / SUM(CachedSize) OVER() * 100.0 AS DECIMAL(5,2)) AS [Buffer Pool Percent], @@ -185,7 +130,7 @@ ORDER BY [Buffer Pool Rank] OPTION (RECOMPILE); --- Get a count of SQL connections by IP address (Query 10) (Connection Counts by IP Address) +-- Get a count of SQL connections by IP address (Query 7) (Connection Counts by IP Address) SELECT ec.client_net_address, es.[program_name], es.[host_name], es.login_name, COUNT(ec.session_id) AS [connection count] FROM sys.dm_exec_sessions AS es WITH (NOLOCK) @@ -199,11 +144,11 @@ ORDER BY ec.client_net_address, es.[program_name] OPTION (RECOMPILE); -- and verifies connectivity from other machines -- Solving Connectivity errors to SQL Server --- https://support.microsoft.com/en-us/help/4009936/solving-connectivity-errors-to-sql-server +-- https://bit.ly/2EgzoD0 --- Get Average Task Counts (run multiple times) (Query 11) (Avg Task Counts) +-- Get Average Task Counts (run multiple times) (Query 8) (Avg Task Counts) SELECT AVG(current_tasks_count) AS [Avg Task Count], AVG(work_queue_count) AS [Avg Work Queue Count], AVG(runnable_tasks_count) AS [Avg Runnable Task Count], @@ -212,7 +157,7 @@ FROM sys.dm_os_schedulers WITH (NOLOCK) WHERE scheduler_id < 255 OPTION (RECOMPILE); ------ --- Sustained values above 10 suggest further investigation in that area +-- Sustained values above 10 suggest further investigation in that area (depending on your Service Tier) -- Avg Task Counts will be higher with lower service tiers -- High Avg Task Counts are often caused by blocking/deadlocking or other resource contention @@ -222,7 +167,7 @@ WHERE scheduler_id < 255 OPTION (RECOMPILE); --- Detect blocking (run multiple times) (Query 12) (Detect Blocking) +-- Detect blocking (run multiple times) (Query 9) (Detect Blocking) SELECT t1.resource_type AS [lock type], DB_NAME(resource_database_id) AS [database], t1.resource_associated_entity_id AS [blk object],t1.request_mode AS [lock req], -- lock requested t1.request_session_id AS [waiter sid], t2.wait_duration_ms AS [wait time], -- spid of waiter @@ -251,8 +196,9 @@ ON t1.lock_owner_address = t2.resource_address OPTION (RECOMPILE); --- Page Life Expectancy (PLE) value for each NUMA node in current instance (Query 13) (PLE by NUMA Node) -SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], instance_name, cntr_value AS [Page Life Expectancy] +-- Page Life Expectancy (PLE) value for each NUMA node in current instance (Query 10) (PLE by NUMA Node) +SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], + instance_name, cntr_value AS [Page Life Expectancy] FROM sys.dm_os_performance_counters WITH (NOLOCK) WHERE [object_name] LIKE N'%Buffer Node%' -- Handles named instances AND counter_name = N'Page life expectancy' OPTION (RECOMPILE); @@ -262,11 +208,11 @@ AND counter_name = N'Page life expectancy' OPTION (RECOMPILE); -- Higher PLE is better. Watch the trend over time, not the absolute value -- This will only return one row for non-NUMA systems --- Page Life Expectancy isnt what you think --- https://www.sqlskills.com/blogs/paul/page-life-expectancy-isnt-what-you-think/ +-- Page Life Expectancy isn’t what you think… +-- https://bit.ly/2EgynLa --- Memory Grants Pending value for current instance (Query 14) (Memory Grants Pending) +-- Memory Grants Pending value for current instance (Query 11) (Memory Grants Pending) SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], cntr_value AS [Memory Grants Pending] FROM sys.dm_os_performance_counters WITH (NOLOCK) WHERE [object_name] LIKE N'%Memory Manager%' -- Handles named instances @@ -277,7 +223,7 @@ AND counter_name = N'Memory Grants Pending' OPTION (RECOMPILE); -- Memory Grants Pending above zero for a sustained period is a very strong indicator of internal memory pressure --- Memory Clerk Usage for instance (Query 15) (Memory Clerk Usage) +-- Memory Clerk Usage for instance (Query 12) (Memory Clerk Usage) -- Look for high value for CACHESTORE_SQLCP (Ad-hoc query plans) SELECT TOP(10) mc.[type] AS [Memory Clerk Type], CAST((SUM(mc.pages_kb)/1024.0) AS DECIMAL (15,2)) AS [Memory Usage (MB)] @@ -299,21 +245,23 @@ ORDER BY SUM(mc.pages_kb) DESC OPTION (RECOMPILE); --- Find single-use, ad-hoc and prepared queries that are bloating the plan cache (Query 16) (Ad hoc Queries) -SELECT TOP(50) [text] AS [QueryText], cp.cacheobjtype, cp.objtype, cp.size_in_bytes/1024 AS [Plan Size in KB] +-- Find single-use, ad-hoc and prepared queries that are bloating the plan cache (Query 13) (Ad hoc Queries) +SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], t.[text] AS [Query Text], +cp.objtype AS [Object Type], cp.cacheobjtype AS [Cache Object Type], +cp.size_in_bytes/1024 AS [Plan Size in KB] FROM sys.dm_exec_cached_plans AS cp WITH (NOLOCK) -CROSS APPLY sys.dm_exec_sql_text(plan_handle) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t WHERE cp.cacheobjtype = N'Compiled Plan' AND cp.objtype IN (N'Adhoc', N'Prepared') AND cp.usecounts = 1 -ORDER BY cp.size_in_bytes DESC OPTION (RECOMPILE); +ORDER BY cp.size_in_bytes DESC, DB_NAME(t.[dbid]) OPTION (RECOMPILE); ------ -- Gives you the text, type and size of single-use ad-hoc and prepared queries that waste space in the plan cache -- Enabling forced parameterization for the database can help, but test first! -- Plan cache, adhoc workloads and clearing the single-use plan cache bloat --- https://www.sqlskills.com/blogs/kimberly/plan-cache-adhoc-workloads-and-clearing-the-single-use-plan-cache-bloat/ +-- https://bit.ly/2EfYOkl @@ -323,7 +271,7 @@ ORDER BY cp.size_in_bytes DESC OPTION (RECOMPILE); -- Database specific queries ***************************************************************** --- Azure SQL Database size (Query 17) (Azure SQL DB Size) +-- Azure SQL Database size (Query 14) (Azure SQL DB Size) SELECT CAST(SUM(CAST(FILEPROPERTY(name, 'SpaceUsed') AS bigint) * 8192.) / 1024 / 1024 AS DECIMAL(15,2)) AS [Database Size In MB], CAST(SUM(CAST(FILEPROPERTY(name, 'SpaceUsed') AS bigint) * 8192.) / 1024 / 1024 / 1024 AS DECIMAL(15,2)) AS [Database Size In GB] FROM sys.database_files WITH (NOLOCK) @@ -333,11 +281,11 @@ WHERE [type_desc] = N'ROWS' OPTION (RECOMPILE); -- This gives you the actual space usage within the data file only, to match what the Azure portal shows for the database size -- Determining Database Size in Azure SQL Database V12 --- https://blogs.msdn.microsoft.com/sqlcat/2016/09/21/determining-database-size-in-azure-sql-database-v12/ +-- https://bit.ly/2JjrqNh --- Individual File Sizes and space available for current database (Query 18) (File Sizes and Space) +-- Individual File Sizes and space available for current database (Query 15) (File Sizes and Space) SELECT f.name AS [File Name] , f.physical_name AS [Physical Name], CAST((f.size/128.0) AS DECIMAL(15,2)) AS [Total Size in MB], CAST(f.size/128.0 - CAST(FILEPROPERTY(f.name, 'SpaceUsed') AS int)/128.0 AS DECIMAL(15,2)) @@ -351,7 +299,6 @@ ORDER BY f.[file_id] OPTION (RECOMPILE); ------ -- Look at how large and how full the files are and where they are located --- Make sure the transaction log is not full!! -- is_autogrow_all_files was new for SQL Server 2016. Equivalent to TF 1117 for user databases @@ -360,7 +307,7 @@ ORDER BY f.[file_id] OPTION (RECOMPILE); --- Log space usage for current database (Query 19) (Log Space Usage) +-- Log space usage for current database (Query 16) (Log Space Usage) SELECT DB_NAME(lsu.database_id) AS [Database Name], db.recovery_model_desc AS [Recovery Model], CAST(lsu.total_log_size_in_bytes/1048576.0 AS DECIMAL(10, 2)) AS [Total Log Space (MB)], CAST(lsu.used_log_space_in_bytes/1048576.0 AS DECIMAL(10, 2)) AS [Used Log Space (MB)], @@ -376,7 +323,26 @@ OPTION (RECOMPILE); -- Look at log file size and usage, along with the log reuse wait description for the current database --- Status of last VLF for current database (Query 20) (Last VLF Status) +-- Get VLF Count for current database (Query 17) (VLF Counts) +SELECT [name] AS [Database Name], [VLF Count] +FROM sys.databases AS db WITH (NOLOCK) +CROSS APPLY (SELECT file_id, COUNT(*) AS [VLF Count] + FROM sys.dm_db_log_info(db.database_id) + GROUP BY file_id) AS li +WHERE [name] <> N'master' +ORDER BY [VLF Count] DESC OPTION (RECOMPILE); +------ + +-- High VLF counts can affect write performance to the log file +-- and they can make full database restores and crash recovery take much longer +-- Try to keep your VLF counts under 200 in most cases (depending on log file size) + +-- Important change to VLF creation algorithm in SQL Server 2014 +-- https://bit.ly/2Hsjbg4 + + + +-- Status of last VLF for current database (Query 18) (Last VLF Status) SELECT TOP(1) DB_NAME(li.database_id) AS [Database Name], li.[file_id], li.vlf_size_mb, li.vlf_sequence_number, li.vlf_active, li.vlf_status FROM sys.dm_db_log_info(DB_ID()) AS li @@ -391,9 +357,35 @@ ORDER BY vlf_sequence_number DESC OPTION (RECOMPILE); -- 2 is active +-- Important database properties for current database (Query 19) (Database Properties) +SELECT db.[name] AS [Database Name], db.recovery_model_desc AS [Recovery Model], +db.state_desc, db.containment_desc, db.log_reuse_wait_desc AS [Log Reuse Wait Description], +db.[compatibility_level] AS [DB Compatibility Level], +db.is_mixed_page_allocation_on, db.page_verify_option_desc AS [Page Verify Option], +db.is_auto_create_stats_on, db.is_auto_update_stats_on, db.is_auto_update_stats_async_on, db.is_parameterization_forced, +db.snapshot_isolation_state_desc, db.is_read_committed_snapshot_on, db.is_auto_close_on, db.is_auto_shrink_on, +db.target_recovery_time_in_seconds, db.is_cdc_enabled, db.is_memory_optimized_elevate_to_snapshot_on, +db.delayed_durability_desc, db.is_auto_create_stats_incremental_on, +db.is_query_store_on, db.is_sync_with_backup, db.is_temporal_history_retention_enabled, +db.is_encrypted, is_result_set_caching_on, is_accelerated_database_recovery_on, is_tempdb_spill_to_remote_store +FROM sys.databases AS db WITH (NOLOCK) +WHERE db.[name] <> N'master' +ORDER BY db.[name] OPTION (RECOMPILE); +------ --- Get database scoped configuration values for current database (Query 21) (Database-scoped Configurations) -SELECT configuration_id, name, [value] AS [value_for_primary] +-- Things to look at: +-- What recovery model are you using? +-- What is the log reuse wait description? +-- What compatibility level is the database on? +-- What is the Page Verify Option? (should be CHECKSUM) +-- Is Auto Update Statistics Asynchronously enabled? +-- Is Delayed Durability enabled? + + + + +-- Get database scoped configuration values for current database (Query 20) (Database-scoped Configurations) +SELECT configuration_id, [name], [value] AS [value_for_primary] FROM sys.database_scoped_configurations WITH (NOLOCK) OPTION (RECOMPILE); ------ @@ -403,10 +395,10 @@ FROM sys.database_scoped_configurations WITH (NOLOCK) OPTION (RECOMPILE); -- ALTER DATABASE SCOPED CONFIGURATION CLEAR PROCEDURE_CACHE; -- ALTER DATABASE SCOPED CONFIGURATION (Transact-SQL) --- https://msdn.microsoft.com/en-us/library/mt629158.aspx +-- https://bit.ly/2sOH7nb --- I/O Statistics by file for the current database (Query 22) (IO Stats By File) +-- I/O Statistics by file for the current database (Query 21) (IO Stats By File) SELECT DB_NAME(DB_ID()) AS [Database Name], df.name AS [Logical Name], vfs.[file_id], df.type_desc, df.physical_name AS [Physical Name], CAST(vfs.size_on_disk_bytes/1048576.0 AS DECIMAL(10, 2)) AS [Size on Disk (MB)], vfs.num_of_reads, vfs.num_of_writes, vfs.io_stall_read_ms, vfs.io_stall_write_ms, @@ -428,7 +420,37 @@ ON vfs.[file_id]= df.[file_id] OPTION (RECOMPILE); -- It helps you determine whether you has an OLTP or DW/DSS type of workload --- Isolate top waits for this database since last restart or failover (Query 23) (Top DB Waits) +-- Get recent resource usage (Query 22) (Recent Resource Usage) +SELECT end_time, dtu_limit, cpu_limit, avg_cpu_percent, avg_memory_usage_percent, + avg_data_io_percent, avg_log_write_percent, xtp_storage_percent, + max_worker_percent, max_session_percent, avg_login_rate_percent, + avg_instance_cpu_percent, avg_instance_memory_percent +FROM sys.dm_db_resource_stats WITH (NOLOCK) +ORDER BY end_time DESC OPTION (RECOMPILE); +------ + +-- Returns a row of usage metrics every 15 seconds, going back 64 minutes +-- The end_time column is UTC time + +-- sys.dm_db_resource_stats (Azure SQL Database) +-- https://bit.ly/2HaSpKn + + + +-- Get recent resource usage (Query 23) (Avg/Max Resource Usage) +SELECT CAST(AVG(avg_cpu_percent) AS DECIMAL(10,2)) AS [Average CPU Utilization In Percent], + CAST(MAX(avg_cpu_percent) AS DECIMAL(10,2)) AS [Maximum CPU Utilization In Percent], + CAST(AVG(avg_data_io_percent) AS DECIMAL(10,2)) AS [Average Data IO In Percent], + CAST(MAX(avg_data_io_percent) AS DECIMAL(10,2)) AS [Maximum Data IO In Percent], + CAST(AVG(avg_log_write_percent) AS DECIMAL(10,2)) AS [Average Log Write Utilization In Percent], + CAST(MAX(avg_log_write_percent) AS DECIMAL(10,2)) AS [Maximum Log Write Utilization In Percent], + CAST(AVG(avg_memory_usage_percent) AS DECIMAL(10,2)) AS [Average Memory Usage In Percent], + CAST(MAX(avg_memory_usage_percent) AS DECIMAL(10,2)) AS [Maximum Memory Usage In Percent] +FROM sys.dm_db_resource_stats WITH (NOLOCK) OPTION (RECOMPILE); +------ + + +-- Isolate top waits for this database since last restart or failover (Query 24) (Top DB Waits) WITH [Waits] AS (SELECT wait_type, wait_time_ms/ 1000.0 AS [WaitS], (wait_time_ms - signal_wait_time_ms) / 1000.0 AS [ResourceS], @@ -494,31 +516,32 @@ OPTION (RECOMPILE); -- Cumulative wait stats are not as useful on an idle instance that is not under load or performance pressure --- SQL Server Wait Types Library (Paul Randal) --- https://www.sqlskills.com/help/waits/ +-- SQL Server Wait Types Library +-- https://bit.ly/2ePzYO2 -- The SQL Server Wait Type Repository --- http://blogs.msdn.com/b/psssql/archive/2009/11/03/the-sql-server-wait-type-repository.aspx +-- https://bit.ly/1afzfjC -- Wait statistics, or please tell me where it hurts --- https://www.sqlskills.com/blogs/paul/wait-statistics-or-please-tell-me-where-it-hurts/ +-- https://bit.ly/2wsQHQE -- SQL Server 2005 Performance Tuning using the Waits and Queues --- http://technet.microsoft.com/en-us/library/cc966413.aspx +-- https://bit.ly/1o2NFoF --- sys.dm_os_wait_stats (Transact-SQL) --- http://msdn.microsoft.com/en-us/library/ms179984(v=sql.120).aspx +-- sys.dm_db_wait_stats (Azure SQL Database) +-- https://bit.ly/2HoJOoT --- Get most frequently executed queries for this database (Query 24) (Query Execution Counts) +-- Get most frequently executed queries for this database (Query 25) (Query Execution Counts) SELECT TOP(50) LEFT(t.[text], 50) AS [Short Query Text], qs.execution_count AS [Execution Count], qs.total_logical_reads AS [Total Logical Reads], qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], qs.total_worker_time AS [Total Worker Time], qs.total_worker_time/qs.execution_count AS [Avg Worker Time], qs.total_elapsed_time AS [Total Elapsed Time], -qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], qs.creation_time AS [Creation Time] --,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) @@ -528,7 +551,8 @@ WHERE t.dbid = DB_ID() ORDER BY qs.execution_count DESC OPTION (RECOMPILE); ------ --- Get top total worker time queries for this database (Query 25) (Top Worker Time Queries) + +-- Get top total worker time queries for this database (Query 26) (Top Worker Time Queries) SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], REPLACE(REPLACE(LEFT(t.[text], 50), CHAR(10),''), CHAR(13),'') AS [Short Query Text], qs.total_worker_time AS [Total Worker Time], qs.min_worker_time AS [Min Worker Time], @@ -540,7 +564,9 @@ qs.max_elapsed_time AS [Max Elapsed Time], qs.min_logical_reads AS [Min Logical Reads], qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], qs.max_logical_reads AS [Max Logical Reads], -qs.execution_count AS [Execution Count], qs.creation_time AS [Creation Time] +qs.execution_count AS [Execution Count], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] --,t.[text] AS [Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t @@ -553,7 +579,7 @@ ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); -- Can also help track down parameter sniffing issues --- Get top total logical reads queries for this database (Query 26) (Top Logical Reads Queries) +-- Get top total logical reads queries for this database (Query 27) (Top Logical Reads Queries) SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], REPLACE(REPLACE(LEFT(t.[text], 50), CHAR(10),''), CHAR(13),'') AS [Short Query Text], qs.total_logical_reads AS [Total Logical Reads], @@ -566,7 +592,9 @@ qs.max_worker_time AS [Max Worker Time], qs.min_elapsed_time AS [Min Elapsed Time], qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], qs.max_elapsed_time AS [Max Elapsed Time], -qs.execution_count AS [Execution Count], qs.creation_time AS [Creation Time] +qs.execution_count AS [Execution Count], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] --,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t @@ -581,7 +609,7 @@ ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE); --- Get top average elapsed time queries for this database (Query 27) (Top Avg Elapsed Time Queries) +-- Get top average elapsed time queries for this database (Query 28) (Top Avg Elapsed Time Queries) SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], @@ -590,6 +618,7 @@ qs.execution_count AS [Execution Count], qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], qs.total_physical_reads/qs.execution_count AS [Avg Physical Reads], qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], qs.creation_time AS [Creation Time] , qp.query_plan AS [Query Plan] -- comment out this column if copying results to Excel FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) @@ -604,15 +633,20 @@ ORDER BY qs.total_elapsed_time/qs.execution_count DESC OPTION (RECOMPILE); --- Top Cached SPs By Execution Count (Query 28) (SP Execution Counts) -SELECT TOP(100) p.name AS [SP Name], qs.execution_count, +-- Top Cached SPs By Execution Count (Query 29) (SP Execution Counts) +SELECT TOP(100) p.name AS [SP Name], qs.execution_count AS [Execution Count], ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], -qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], qs.total_worker_time AS [TotalWorkerTime], -qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], -qs.cached_time +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 ORDER BY qs.execution_count DESC OPTION (RECOMPILE); @@ -622,15 +656,20 @@ ORDER BY qs.execution_count DESC OPTION (RECOMPILE); -- This helps you characterize and baseline your workload --- Top Cached SPs By Avg Elapsed Time (Query 29) (SP Avg Elapsed Time) +-- Top Cached SPs By Avg Elapsed Time (Query 30) (SP Avg Elapsed Time) SELECT TOP(25) p.name AS [SP Name], qs.min_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], qs.max_elapsed_time, qs.last_elapsed_time, qs.total_elapsed_time, qs.execution_count, ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], -qs.total_worker_time AS [TotalWorkerTime], qs.cached_time +qs.total_worker_time AS [TotalWorkerTime], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 ORDER BY avg_elapsed_time DESC OPTION (RECOMPILE); @@ -641,15 +680,19 @@ ORDER BY avg_elapsed_time DESC OPTION (RECOMPILE); --- Top Cached SPs By Total Worker time. Worker time relates to CPU cost (Query 30) (SP Worker Time) +-- Top Cached SPs By Total Worker time. Worker time relates to CPU cost (Query 31) (SP Worker Time) SELECT TOP(25) p.name AS [SP Name], qs.total_worker_time AS [TotalWorkerTime], qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], qs.execution_count, ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], -qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count -AS [avg_elapsed_time], qs.cached_time +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); @@ -659,15 +702,19 @@ ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); -- You should look at this if you see signs of CPU pressure --- Top Cached SPs By Total Logical Reads. Logical reads relate to memory pressure (Query 31) (SP Logical Reads) +-- Top Cached SPs By Total Logical Reads. Logical reads relate to memory pressure (Query 32) (SP Logical Reads) SELECT TOP(25) p.name AS [SP Name], qs.total_logical_reads AS [TotalLogicalReads], qs.total_logical_reads/qs.execution_count AS [AvgLogicalReads],qs.execution_count, ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], -qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count -AS [avg_elapsed_time], qs.cached_time +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE); @@ -677,14 +724,18 @@ ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE); -- You should look at this if you see signs of memory pressure --- Top Cached SPs By Total Physical Reads. Physical reads relate to disk read I/O pressure (Query 32) (SP Physical Reads) +-- Top Cached SPs By Total Physical Reads. Physical reads relate to disk read I/O pressure (Query 33) (SP Physical Reads) SELECT TOP(25) p.name AS [SP Name],qs.total_physical_reads AS [TotalPhysicalReads], qs.total_physical_reads/qs.execution_count AS [AvgPhysicalReads], qs.execution_count, -qs.total_logical_reads,qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count -AS [avg_elapsed_time], qs.cached_time +qs.total_logical_reads,qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND qs.total_physical_reads > 0 ORDER BY qs.total_physical_reads DESC, qs.total_logical_reads DESC OPTION (RECOMPILE); @@ -695,16 +746,20 @@ ORDER BY qs.total_physical_reads DESC, qs.total_logical_reads DESC OPTION (RECOM --- Top Cached SPs By Total Logical Writes (Query 33) (SP Logical Writes) +-- Top Cached SPs By Total Logical Writes (Query 34) (SP Logical Writes) -- Logical writes relate to both memory and disk I/O pressure SELECT TOP(25) p.name AS [SP Name], qs.total_logical_writes AS [TotalLogicalWrites], qs.total_logical_writes/qs.execution_count AS [AvgLogicalWrites], qs.execution_count, ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], -qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], -qs.cached_time +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND qs.total_logical_writes > 0 AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 @@ -715,7 +770,8 @@ ORDER BY qs.total_logical_writes DESC OPTION (RECOMPILE); -- You should look at this if you see signs of I/O pressure or of memory pressure --- Lists the top statements by average input/output usage for the current database (Query 34) (Top IO Statements) + +-- Lists the top statements by average input/output usage for the current database (Query 35) (Top IO Statements) SELECT TOP(50) OBJECT_NAME(qt.objectid, dbid) AS [SP Name], (qs.total_logical_reads + qs.total_logical_writes) /qs.execution_count AS [Avg IO], qs.execution_count AS [Execution Count], SUBSTRING(qt.[text],qs.statement_start_offset/2, @@ -734,19 +790,24 @@ ORDER BY [Avg IO] DESC OPTION (RECOMPILE); --- Possible Bad NC Indexes (writes > reads) (Query 35) (Bad NC Indexes) -SELECT OBJECT_NAME(s.[object_id]) AS [Table Name], i.name AS [Index Name], i.index_id, +-- Possible Bad NC Indexes (writes > reads) (Query 36) (Bad NC Indexes) +SELECT SCHEMA_NAME(o.[schema_id]) AS [Schema Name], +OBJECT_NAME(s.[object_id]) AS [Table Name], +i.name AS [Index Name], i.index_id, i.is_disabled, i.is_hypothetical, i.has_filter, i.fill_factor, -user_updates AS [Total Writes], user_seeks + user_scans + user_lookups AS [Total Reads], -user_updates - (user_seeks + user_scans + user_lookups) AS [Difference] +s.user_updates AS [Total Writes], s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], +s.user_updates - (s.user_seeks + s.user_scans + s.user_lookups) AS [Difference] FROM sys.dm_db_index_usage_stats AS s WITH (NOLOCK) INNER JOIN sys.indexes AS i WITH (NOLOCK) ON s.[object_id] = i.[object_id] AND i.index_id = s.index_id +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON i.[object_id] = o.[object_id] WHERE OBJECTPROPERTY(s.[object_id],'IsUserTable') = 1 AND s.database_id = DB_ID() -AND user_updates > (user_seeks + user_scans + user_lookups) -AND i.index_id > 1 +AND s.user_updates > (s.user_seeks + s.user_scans + s.user_lookups) +AND i.index_id > 1 AND i.[type_desc] = N'NONCLUSTERED' +AND i.is_primary_key = 0 AND i.is_unique_constraint = 0 AND i.is_unique = 0 ORDER BY [Difference] DESC, [Total Writes] DESC, [Total Reads] ASC OPTION (RECOMPILE); ------ @@ -755,7 +816,7 @@ ORDER BY [Difference] DESC, [Total Writes] DESC, [Total Reads] ASC OPTION (RECOM -- Investigate further before dropping an index! --- Missing Indexes for current database by Index Advantage (Query 36) (Missing Indexes) +-- Missing Indexes for current database by Index Advantage (Query 37) (Missing Indexes) SELECT DISTINCT CONVERT(decimal(18,2), user_seeks * avg_total_user_cost * (avg_user_impact * 0.01)) AS [index_advantage], migs.last_user_seek, mid.[statement] AS [Database.Schema.Table], mid.equality_columns, mid.inequality_columns, mid.included_columns, @@ -777,7 +838,7 @@ ORDER BY index_advantage DESC OPTION (RECOMPILE); -- Do not just blindly add indexes that show up from this query!!! --- Find missing index warnings for cached plans in the current database (Query 37) (Missing Index Warnings) +-- Find missing index warnings for cached plans in the current database (Query 38) (Missing Index Warnings) -- Note: This query could take some time on a busy instance SELECT TOP(25) OBJECT_NAME(objectid) AS [ObjectName], cp.objtype, cp.usecounts, cp.size_in_bytes, query_plan @@ -792,9 +853,10 @@ ORDER BY cp.usecounts DESC OPTION (RECOMPILE); -- This can help you decide whether to add them or not --- Breaks down buffers used by current database by object (table, index) in the buffer cache (Query 38) (Buffer Usage) +-- Breaks down buffers used by current database by object (table, index) in the buffer cache (Query 39) (Buffer Usage) -- Note: This query could take some time on a busy instance -SELECT OBJECT_NAME(p.[object_id]) AS [Object Name], p.index_id, +SELECT SCHEMA_NAME(o.Schema_ID) AS [Schema Name], +OBJECT_NAME(p.[object_id]) AS [Object Name], p.index_id, CAST(COUNT(*)/128.0 AS DECIMAL(10, 2)) AS [Buffer size(MB)], COUNT(*) AS [BufferCount], p.[Rows] AS [Row Count], p.data_compression_desc AS [Compression Type] @@ -803,12 +865,14 @@ INNER JOIN sys.dm_os_buffer_descriptors AS b WITH (NOLOCK) ON a.allocation_unit_id = b.allocation_unit_id INNER JOIN sys.partitions AS p WITH (NOLOCK) ON a.container_id = p.hobt_id +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON p.object_id = o.object_id WHERE b.database_id = CONVERT(int, DB_ID()) AND p.[object_id] > 100 AND OBJECT_NAME(p.[object_id]) NOT LIKE N'plan_%' AND OBJECT_NAME(p.[object_id]) NOT LIKE N'sys%' AND OBJECT_NAME(p.[object_id]) NOT LIKE N'xml_index_nodes%' -GROUP BY p.[object_id], p.index_id, p.data_compression_desc, p.[Rows] +GROUP BY o.Schema_ID, p.[object_id], p.index_id, p.data_compression_desc, p.[Rows] ORDER BY [BufferCount] DESC OPTION (RECOMPILE); ------ @@ -816,33 +880,35 @@ ORDER BY [BufferCount] DESC OPTION (RECOMPILE); -- It can help identify possible candidates for data compression --- Get Table names, row counts, and compression status for clustered index or heap (Query 39) (Table Sizes) -SELECT OBJECT_NAME(object_id) AS [ObjectName], -SUM(Rows) AS [RowCount], data_compression_desc AS [CompressionType] -FROM sys.partitions WITH (NOLOCK) +-- Get Table names, row counts, and compression status for clustered index or heap (Query 40) (Table Sizes) +SELECT SCHEMA_NAME(o.Schema_ID) AS [Schema Name], OBJECT_NAME(p.object_id) AS [ObjectName], +SUM(p.Rows) AS [RowCount], data_compression_desc AS [CompressionType] +FROM sys.partitions AS p WITH (NOLOCK) +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON p.object_id = o.object_id WHERE index_id < 2 --ignore the partitions from the non-clustered index if any -AND OBJECT_NAME(object_id) NOT LIKE N'sys%' -AND OBJECT_NAME(object_id) NOT LIKE N'queue_%' -AND OBJECT_NAME(object_id) NOT LIKE N'filestream_tombstone%' -AND OBJECT_NAME(object_id) NOT LIKE N'fulltext%' -AND OBJECT_NAME(object_id) NOT LIKE N'ifts_comp_fragment%' -AND OBJECT_NAME(object_id) NOT LIKE N'filetable_updates%' -AND OBJECT_NAME(object_id) NOT LIKE N'xml_index_nodes%' -AND OBJECT_NAME(object_id) NOT LIKE N'sqlagent_job%' -AND OBJECT_NAME(object_id) NOT LIKE N'plan_persist%' -GROUP BY object_id, data_compression_desc -ORDER BY SUM(Rows) DESC OPTION (RECOMPILE); +AND OBJECT_NAME(p.object_id) NOT LIKE N'sys%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'spt_%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'queue_%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'filestream_tombstone%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'fulltext%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'ifts_comp_fragment%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'filetable_updates%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'xml_index_nodes%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'sqlagent_job%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'plan_persist%' +GROUP BY SCHEMA_NAME(o.Schema_ID), p.object_id, data_compression_desc +ORDER BY SUM(p.Rows) DESC OPTION (RECOMPILE); ------ -- Gives you an idea of table sizes, and possible data compression opportunities --- Get some key table properties (Query 40) (Table Properties) +-- Get some key table properties (Query 41) (Table Properties) SELECT OBJECT_NAME(t.[object_id]) AS [ObjectName], p.[rows] AS [Table Rows], p.index_id, p.data_compression_desc AS [Index Data Compression], - t.create_date, t.lock_on_bulk_load, - t.is_tracked_by_cdc, t.lock_escalation_desc, t.is_filetable, + t.create_date, t.lock_on_bulk_load, t.lock_escalation_desc, t.is_memory_optimized, t.durability_desc, t.temporal_type_desc FROM sys.tables AS t WITH (NOLOCK) @@ -857,11 +923,11 @@ ORDER BY OBJECT_NAME(t.[object_id]), p.index_id OPTION (RECOMPILE); -- temporal_type_desc, is_remote_data_archive_enabled, is_external are new in SQL Server 2016 -- sys.tables (Transact-SQL) --- https://msdn.microsoft.com/en-us/library/ms187406.aspx +-- https://bit.ly/2Gk7998 --- When were Statistics last updated on all indexes? (Query 41) (Statistics Update) +-- When were Statistics last updated on all indexes? (Query 42) (Statistics Update) SELECT SCHEMA_NAME(o.Schema_ID) + N'.' + o.[NAME] AS [Object Name], o.[type_desc] AS [Object Type], i.[name] AS [Index Name], STATS_DATE(i.[object_id], i.index_id) AS [Statistics Date], s.auto_created, s.no_recompute, s.user_created, s.is_incremental, s.is_temporary, @@ -884,11 +950,11 @@ ORDER BY STATS_DATE(i.[object_id], i.index_id) DESC OPTION (RECOMPILE); -- Also gives you an idea which indexes are the most active -- sys.stats (Transact-SQL) --- https://msdn.microsoft.com/en-us/library/ms177623.aspx +-- https://bit.ly/2GyAxrn --- Look at most frequently modified indexes and statistics (Query 42) (Volatile Indexes) +-- Look at most frequently modified indexes and statistics (Query 43) (Volatile Indexes) SELECT o.[name] AS [Object Name], o.[object_id], o.[type_desc], s.[name] AS [Statistics Name], s.stats_id, s.no_recompute, s.auto_created, s.is_incremental, s.is_temporary, sp.modification_counter, sp.[rows], sp.rows_sampled, sp.last_updated @@ -906,7 +972,7 @@ ORDER BY sp.modification_counter DESC, o.name OPTION (RECOMPILE); --- Get fragmentation info for all indexes above a certain size in the current database (Query 43) (Index Fragmentation) +-- Get fragmentation info for all indexes above a certain size in the current database (Query 44) (Index Fragmentation) -- Note: This query could take some time on a very large database SELECT DB_NAME(ps.database_id) AS [Database Name], SCHEMA_NAME(o.[schema_id]) AS [Schema Name], OBJECT_NAME(ps.OBJECT_ID) AS [Object Name], i.[name] AS [Index Name], ps.index_id, @@ -928,7 +994,7 @@ ORDER BY ps.avg_fragmentation_in_percent DESC OPTION (RECOMPILE); -- and how effective your index maintenance strategy is ---- Index Read/Write stats (all tables in current DB) ordered by Reads (Query 44) (Overall Index Usage - Reads) +--- Index Read/Write stats (all tables in current DB) ordered by Reads (Query 45) (Overall Index Usage - Reads) SELECT OBJECT_NAME(i.[object_id]) AS [ObjectName], i.[name] AS [IndexName], i.index_id, s.user_seeks, s.user_scans, s.user_lookups, s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], @@ -947,7 +1013,7 @@ ORDER BY s.user_seeks + s.user_scans + s.user_lookups DESC OPTION (RECOMPILE); - -- Show which indexes in the current database are most active for Reads ---- Index Read/Write stats (all tables in current DB) ordered by Writes (Query 45) (Overall Index Usage - Writes) +--- Index Read/Write stats (all tables in current DB) ordered by Writes (Query 46) (Overall Index Usage - Writes) SELECT OBJECT_NAME(i.[object_id]) AS [ObjectName], i.[name] AS [IndexName], i.index_id, s.user_updates AS [Writes], s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], i.[type_desc] AS [Index Type], i.fill_factor AS [Fill Factor], i.has_filter, i.filter_definition, @@ -964,7 +1030,7 @@ ORDER BY s.user_updates DESC OPTION (RECOMPILE); -- Order by writes -- Show which indexes in the current database are most active for Writes --- Get in-memory OLTP index usage (Query 46) (XTP Index Usage) +-- Get in-memory OLTP index usage (Query 47) (XTP Index Usage) SELECT OBJECT_NAME(i.[object_id]) AS [Object Name], i.index_id, i.[name] AS [Index Name], i.[type_desc], xis.scans_started, xis.scans_retries, xis.rows_touched, xis.rows_returned @@ -979,11 +1045,11 @@ ORDER BY OBJECT_NAME(i.[object_id]) OPTION (RECOMPILE); -- Returns no data if you are not using in-memory OLTP -- Guidelines for Using Indexes on Memory-Optimized Tables --- https://msdn.microsoft.com/en-us/library/dn133166.aspx +-- https://bit.ly/2GCP8lF --- Look at Columnstore index physical statistics (Query 47) (Columnstore Index Physical Stat) +-- Look at Columnstore index physical statistics (Query 48) (Columnstore Index Physical Stat) SELECT OBJECT_NAME(ps.object_id) AS [TableName], i.[name] AS [IndexName], ps.index_id, ps.partition_number, ps.delta_store_hobt_id, ps.state_desc, ps.total_rows, ps.size_in_bytes, @@ -998,11 +1064,11 @@ ORDER BY ps.object_id, ps.partition_number, ps.row_group_id OPTION (RECOMPILE); ------ -- sys.dm_db_column_store_row_group_physical_stats (Transact-SQL) --- https://msdn.microsoft.com/en-us/library/dn832030.aspx +-- https://bit.ly/2q276XQ --- Get lock waits for current database (Query 48) (Lock Waits) +-- Get lock waits for current database (Query 49) (Lock Waits) SELECT o.name AS [table_name], i.name AS [index_name], ios.index_id, ios.partition_number, SUM(ios.row_lock_wait_count) AS [total_row_lock_waits], SUM(ios.row_lock_wait_in_ms) AS [total_row_lock_wait_in_ms], @@ -1025,7 +1091,7 @@ ORDER BY total_lock_wait_in_ms DESC OPTION (RECOMPILE); --- Look at UDF execution statistics (Query 49) (UDF Statistics) +-- Look at UDF execution statistics (Query 50) (UDF Statistics) SELECT OBJECT_NAME(object_id) AS [Function Name], total_worker_time, execution_count, total_elapsed_time, total_elapsed_time/execution_count AS [avg_elapsed_time], @@ -1039,26 +1105,27 @@ ORDER BY total_worker_time DESC OPTION (RECOMPILE); -- Helps you investigate scalar UDF performance issues -- sys.dm_exec_function_stats (Transact-SQL) --- https://msdn.microsoft.com/en-US/library/mt429371.aspx +-- https://bit.ly/2q1Q6BM --- Get QueryStore Options for this database (Query 50) (QueryStore Options) +-- Get QueryStore Options for this database (Query 51) (QueryStore Options) SELECT actual_state_desc, desired_state_desc, current_storage_size_mb, [max_storage_size_mb], - query_capture_mode_desc, size_based_cleanup_mode_desc + query_capture_mode_desc, size_based_cleanup_mode_desc, + wait_stats_capture_mode_desc, [flush_interval_seconds] FROM sys.database_query_store_options WITH (NOLOCK) OPTION (RECOMPILE); ------ --- New for SQL Server 2016 +-- Added in SQL Server 2016 -- Requires that QueryStore is enabled for this database -- Tuning Workload Performance with Query Store --- http://blogs.technet.com/b/dataplatforminsider/archive/2015/12/16/tuning-workload-performance-with-query-store.aspx +-- https://bit.ly/1kHSl7w --- Get highest aggregate duration queries over last hour (Query 51) (High Aggregate Duration Queries) +-- Get highest aggregate duration queries over last hour (Query 52) (High Aggregate Duration Queries) WITH AggregatedDurationLastHour AS (SELECT q.query_id, SUM(count_executions * avg_duration) AS total_duration, @@ -1101,7 +1168,7 @@ ORDER BY total_duration DESC OPTION (RECOMPILE); -- Requires that QueryStore is enabled for this database --- Get input buffer information for the current database (Query 52) (Input Buffer) +-- Get input buffer information for the current database (Query 53) (Input Buffer) SELECT es.session_id, DB_NAME(es.database_id) AS [Database Name], es.login_time, es.cpu_time, es.logical_reads, es.[status], ib.event_info AS [Input Buffer] @@ -1116,11 +1183,11 @@ AND es.session_id <> @@SPID OPTION (RECOMPILE); -- Replaces DBCC INPUTBUFFER -- New DMF for retrieving input buffer in SQL Server --- https://blogs.msdn.microsoft.com/sql_server_team/new-dmf-for-retrieving-input-buffer-in-sql-server/ +-- https://bit.ly/2uHKMbz --- Get any resumable index rebuild operation information (Query 53) (Resumable Index Rebuild) +-- Get any resumable index rebuild operation information (Query 54) (Resumable Index Rebuild) SELECT OBJECT_NAME(iro.object_id) AS [Object Name], iro.index_id, iro.name AS [Index Name], iro.sql_text, iro.last_max_dop_used, iro.partition_number, iro.state_desc, iro.start_time, iro.percent_complete FROM sys.index_resumable_operations AS iro WITH (NOLOCK) @@ -1128,54 +1195,67 @@ OPTION (RECOMPILE); ------ -- index_resumable_operations (Transact-SQL) --- https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-index-resumable-operations +-- https://bit.ly/2pYSWqq --- Get database automatic tuning options (Query 54) (Automatic Tuning Options) +-- Get database automatic tuning options (Query 55) (Automatic Tuning Options) SELECT [name], desired_state_desc, actual_state_desc, reason_desc FROM sys.database_automatic_tuning_options WITH (NOLOCK) OPTION (RECOMPILE); ------ -- sys.database_automatic_tuning_options (Transact-SQL) --- https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-database-automatic-tuning-options-transact-sql +-- https://bit.ly/2FHhLkL --- Get geo-replication link status for all secondary databases (Query 55) (Geo-Replication Link Status) +-- Get geo-replication link status for all secondary databases (Query 56) (Geo-Replication Link Status) SELECT link_guid, partner_server, partner_database, last_replication, replication_lag_sec, replication_state_desc, role_desc, secondary_allow_connections_desc -FROM sys.dm_geo_replication_link_status; +FROM sys.dm_geo_replication_link_status WITH (NOLOCK) OPTION (RECOMPILE); ------ -- sys.dm_geo_replication_link_status (Azure SQL Database) --- https://docs.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-geo-replication-link-status-azure-sql-database +-- https://bit.ly/2GwIqC2 --- Retrieve some Azure SQL Database properties (Query 56) (Azure SQL DB Properties) +-- Retrieve some Azure SQL Database properties (Query 57) (Azure SQL DB Properties) SELECT DATABASEPROPERTYEX (DB_NAME(DB_ID()), 'Edition') AS [Database Edition], DATABASEPROPERTYEX (DB_NAME(DB_ID()), 'ServiceObjective') AS [Service Objective], DATABASEPROPERTYEX (DB_NAME(DB_ID()), 'MaxSizeInBytes') AS [Max Size In Bytes], - DATABASEPROPERTYEX (DB_NAME(DB_ID()), 'IsXTPSupported') AS [Is XTP Supported]; + DATABASEPROPERTYEX (DB_NAME(DB_ID()), 'IsXTPSupported') AS [Is XTP Supported] + OPTION (RECOMPILE); ------ -- DATABASEPROPERTYEX (Transact-SQL) --- https://docs.microsoft.com/en-us/sql/t-sql/functions/databasepropertyex-transact-sql +-- https://bit.ly/2ItexPg +-- These six Pluralsight Courses go into more detail about how to run these queries and interpret the results +-- Azure SQL Database: Diagnosing Performance Issues with DMVs +-- https://bit.ly/2meDRCN +-- SQL Server 2017: Diagnosing Performance Issues with DMVs +-- https://bit.ly/2FqCeti --- Sign up for Microsoft Visual Studio Dev Essentials and get a free three month pass to Pluralsight +-- SQL Server 2017: Diagnosing Configuration Issues with DMVs +-- https://bit.ly/2MSUDUL --- Microsoft Visual Studio Dev Essentials --- http://bit.ly/1q6xbDL +-- SQL Server 2014 DMV Diagnostic Queries – Part 1 +-- https://bit.ly/2plxCer + +-- SQL Server 2014 DMV Diagnostic Queries – Part 2 +-- https://bit.ly/2IuJpzI +-- SQL Server 2014 DMV Diagnostic Queries – Part 3 +-- https://bit.ly/2FIlCPb --- Sign up for Microsoft IT Pro Cloud Essentials and get lots of free Azure usage credits, MCP exam voucher, three month Pluralsight subscription --- Microsoft IT Pro Cloud Essentials --- http://bit.ly/2443SAd +-- Microsoft Visual Studio Dev Essentials +-- https://bit.ly/2qjNRxi +-- Microsoft Azure Learn +-- https://bit.ly/2O0Hacc \ No newline at end of file diff --git a/Scripts/Bad_Query_Example_13_JOINS.sql b/Scripts/Bad_Query_Example_13_JOINS.sql new file mode 100644 index 00000000..c12aebc0 --- /dev/null +++ b/Scripts/Bad_Query_Example_13_JOINS.sql @@ -0,0 +1,26 @@ +/* + + Generate complex query plan + Reads and writes per database. + 2020-06-23 by Brent Ozar + 2020-07-05 by Konstantin Taranov + 1.1 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Bad_Query_Example_13_JOINS.sql + https://www.brentozar.com/archive/2020/06/bad-idea-jeans-building-big-query-plans/ + +*/ + + +DECLARE @TheRootOfAllEvil TABLE + (Id int PRIMARY KEY CLUSTERED); +WITH CTE1 AS (SELECT * FROM @TheRootOfAllEvil r1), +CTE2 AS (SELECT cA.* FROM CTE1 cA INNER JOIN CTE1 cB ON cA.Id = cB.Id), +CTE3 AS (SELECT cA.* FROM CTE2 cA INNER JOIN CTE2 cB ON cA.Id = cB.Id), +CTE4 AS (SELECT cA.* FROM CTE3 cA INNER JOIN CTE3 cB ON cA.Id = cB.Id), +CTE5 AS (SELECT cA.* FROM CTE4 cA INNER JOIN CTE4 cB ON cA.Id = cB.Id), +CTE6 AS (SELECT cA.* FROM CTE5 cA INNER JOIN CTE5 cB ON cA.Id = cB.Id), +CTE7 AS (SELECT cA.* FROM CTE6 cA INNER JOIN CTE6 cB ON cA.Id = cB.Id), +CTE8 AS (SELECT cA.* FROM CTE7 cA INNER JOIN CTE7 cB ON cA.Id = cB.Id), +CTE9 AS (SELECT cA.* FROM CTE8 cA INNER JOIN CTE8 cB ON cA.Id = cB.Id), +CTE10 AS (SELECT cA.* FROM CTE9 cA INNER JOIN CTE9 cB ON cA.Id = cB.Id) +SELECT * FROM CTE10; diff --git a/Scripts/Benchmark_TSQL.R b/Scripts/Benchmark_TSQL.R new file mode 100644 index 00000000..08dacbaf --- /dev/null +++ b/Scripts/Benchmark_TSQL.R @@ -0,0 +1,296 @@ +#' Benchmarking TSQL statements. +#' +#' @description Run SQL statement specified times, show results, insert execution details into table master.dbo.BenchmarkTSQL (create if not exist). +#' +#' @param tsqlStatement input character vector +#' TSQL statement for benchmarking +#' @param trustedConnection input boolean vector +#' Using trusted connection +#' @param clearCache input boolean vector +#' Clear cached plan for TSQL statement +#' @param calcMedian input boolean vector +#' Calculate pseudo median of execution time +#' @param printStepInfo input boolean vector +#' PRINT detailed step information: step count, start time, end time, duration +#' @param saveResults input boolean vector +#' Save benchmark details to master.dbo.BenchmarkTSQL table if saveResults = 1. +#' @param datetimeFun input character vector +#' Define using datetime function, possible values of functions: SYSDATETIME, SYSUTCDATETIME. +#' See details https://docs.microsoft.com/en-us/sql/t-sql/functions/date-and-time-data-types-and-functions-transact-sql +#' @param durationAccuracy input character vector +#' Duration accuracy calculation, possible values: ns, mcs, ms, ss, mi, hh, wk, dd. +#' See DATEDIFF https://docs.microsoft.com/en-us/sql/t-sql/functions/datediff-transact-sql +#' @param times input integer vector +#' Number of execution TSQL statement. +#' +#' @return print benchmark result +#' +#' @author Konstantin Taranov +#' +#' @examples +#' BenchmarkTSQL("SELECT * FROM sys.databases", trustedConnection=TRUE, clearCache=1, times=10) +#' BenchmarkTSQL("SELECT * FROM sys.databases", trustedConnection=TRUE, clearCache=1, times=3, datetimeFun='SYSUTCDATETIME', calcMedian=TRUE, durationAccuracy='mcs') +#' +#' @export + +BenchmarkTSQL <- function(tsqlStatement, + trustedConnection = TRUE, + clearCache = FALSE, + calcMedian = FALSE, + printStepInfo = TRUE, + saveResults = FALSE, + datetimeFun = 'SYSDATETIME', + durationAccuracy = 'ms', + times = 10L) { + + library("RODBC") + options(digits = 7) + + if (!datetimeFun %in% list('SYSDATETIME', 'SYSUTCDATETIME')){ + stop( + print(paste0( + "For 'datetimeFun' allowed only 'SYSUTCDATETIME' and 'SYSDATETIME'. For details see:", + "https://docs.microsoft.com/en-us/sql/t-sql/functions/date-and-time-data-types-and-functions-transact-sql") + ) + ) + } + + if (!durationAccuracy %in% c('ns' + ,'mcs' + ,'ms' + ,'ss' + ,'mi' + ,'hh' + ,'wk' + ,'dd')){ + stop( + print(paste0( + "For 'durationAccuracy' allowed only ns, mcs, ms, ss, mi, hh, wk, dd. For details see:", + "https://docs.microsoft.com/en-us/sql/t-sql/functions/datediff-transact-sql") + ) + ) + } + + if (trustedConnection <- TRUE) { + connectionString <- + "driver={SQL Server};server=.;database=master;trusted_connection=true;" + } else{ + databaseLogin <- readline(prompt = "Enter a login: ") + databasePassword <- readline(prompt = "Enter a password: ") + connectionString <- + gsub( + "__pwd__", + databasePassword, + "Driver=ODBC Driver 11 for SQL Server;Server=.;Database=master;Uid=__login__;pwd=__pwd__;" + ) + connectionString <- + gsub("__login__", + databaseLogin, + connectionString) + } + + + ch <- odbcDriverConnect(connection = connectionString) + + original_login <- + sqlQuery( + ch, + " + DECLARE @originalLogin SYSNAME = ORIGINAL_LOGIN(); + SELECT ORIGINAL_LOGIN() AS OriginalLogin;", + errors = TRUE + ) + tsqlstatement_guid <- + sqlQuery( + ch, + " + DECLARE @TSQLStatementGUID VARCHAR(36) = NEWID(); + SELECT @TSQLStatementGUID AS TSQLStatementGUID;", + errors = TRUE + ) + + startTime <- Sys.time() + if (datetimeFun == 'SYSUTCDATETIME') + startTime <- as.POSIXlt.POSIXct(Sys.time(), tz='UTC') + print( + paste0( + "Benchmark started at ", startTime, " by ", original_login$OriginalLogin)) + + timetemp <- NULL + for (i in 1L:times) { + if (clearCache) { + tsql <- " + DECLARE @plan_handle VARBINARY(64); + DECLARE @tsqlStatement NVARCHAR(MAX) = N'@tsqlStatementIN'; + + SELECT @plan_handle = plan_handle + FROM sys.dm_exec_cached_plans + CROSS APPLY sys.dm_exec_sql_text(plan_handle) + WHERE [text] LIKE @tsqlStatement; + -- LIKE instead = (equal) because = ignore trailing spaces + + IF @plan_handle IS NOT NULL DBCC FREEPROCCACHE (@plan_handle); + " + + sqlQuery( + ch, + gsub( + "@tsqlStatementIN", + tsqlStatement, + tsql), + errors = TRUE, + as.is = TRUE + ) + } + sqlQuery( + ch, + gsub( + "__datetimeFun__", + datetimeFun, + gsub( + "__durationAccuracy__", + durationAccuracy, + paste0( + " + DECLARE @timestart DATETIME2(7) = __datetimeFun__();\n + IF OBJECT_ID('tempdb..#timetemp', 'U') IS NOT NULL DROP TABLE #timetemp\n", + " + ", tsqlStatement, "\n", + " + SELECT '", tsqlstatement_guid$TSQLStatementGUID,"' AS TSQLSTATEMENTGUID, + ", i," AS STEPROWNUMBER, + CAST('", startTime,"' AS DATETIME2(7)) AS STARTTIMESTAMP, + @timestart AS RUNTIMESTAMP, + CAST(__datetimeFun__() AS DATETIME2(7)) AS FINISHTIMESTAMP, + CAST(DATEDIFF(__durationAccuracy__, @timestart, CAST(__datetimeFun__() AS DATETIME2(7))) AS BIGINT) AS DURATION, + '", tsqlStatement, ";' AS TSQLSTATEMENT, + '", clearCache, "' AS CLEARCACHE, + '", printStepInfo, "' AS PRINTSTEPINFO, + '", durationAccuracy, "' AS DURATIONACCURACY, + '", original_login$OriginalLogin, "' AS ORIGINALLOGIN + INTO #timetemp;" + ) + ) + ), + errors = TRUE, + as.is = TRUE + ) + timetemp <- + rbind( + timetemp, + sqlQuery( + ch, + " + SELECT RUNTIMESTAMP + , FINISHTIMESTAMP + , DURATION + FROM #timetemp", + errors = TRUE + ) + ) + + stepStart <- + strptime(timetemp$RUNTIMESTAMP[nrow(timetemp)], format = "%Y-%m-%d %H:%M:%OS") + stepEnd <- + strptime(timetemp$FINISHTIMESTAMP[nrow(timetemp)], format = "%Y-%m-%d %H:%M:%OS") + duration <- + timetemp$DURATION[nrow(timetemp)] + + if (printStepInfo){ + print( + paste0( + "Run ", + i, + ", start: ", + stepStart, + ", finish: ", + stepEnd, + ", duration: ", + duration, + " ", + durationAccuracy + ) + ) + } + if (saveResults) + sqlQuery( + ch, + "IF OBJECT_ID('master.dbo.BenchmarkTSQL', 'U') IS NULL + BEGIN + CREATE TABLE master.dbo.BenchmarkTSQL( + BenchmarkTSQLID INT IDENTITY NOT NULL + , TSQLStatementGUID VARCHAR(36) NOT NULL + , StepRowNumber INT NOT NULL + , StartTimeStamp DATETIME2(7) NOT NULL + , RunTimeStamp DATETIME2(7) NOT NULL + , FinishTimeStamp DATETIME2(7) NOT NULL + , Duration BIGINT NOT NULL + , TsqlStatement NVARCHAR(MAX) NOT NULL + , ClearCache BIT NOT NULL + , PrintStepInfo BIT NOT NULL + , DurationAccuracy VARCHAR(10) NOT NULL + , OriginalLogin SYSNAME NOT NULL + ); + END + + INSERT INTO master.dbo.BenchmarkTSQL( + TSQLStatementGUID + , StepRowNumber + , StartTimeStamp + , RunTimeStamp + , FinishTimeStamp + , Duration + , TsqlStatement + , ClearCache + , PrintStepInfo + , DurationAccuracy + , OriginalLogin + ) + SELECT TSQLSTATEMENTGUID AS TSQLStatementGUID + , STEPROWNUMBER AS StepRowNumber + , STARTTIMESTAMP AS StartTimeStamp + , RUNTIMESTAMP AS RunTimeStamp + , FINISHTIMESTAMP AS FinishTimeStamp + , DURATION AS Duration + , TSQLSTATEMENT AS TsqlStatement + , CLEARCACHE AS ClearCache + , PRINTSTEPINFO AS PrintStepInfo + , DURATIONACCURACY AS DurationAccuracy + , ORIGINALLOGIN AS OriginalLogin + FROM #timetemp;" + ) + } + + print( + gsub( + "__durationAccuracy__", + durationAccuracy, + paste0( + "Min: ", + min(timetemp$DURATION), + " __durationAccuracy__, average: ", + round(mean(timetemp$DURATION), 7), + " __durationAccuracy__, max: ", + max(timetemp$DURATION), + " __durationAccuracy__", + if (calcMedian) + paste0(", median: ", + round(median(timetemp$DURATION), 7), + ' __durationAccuracy__') + ) + ) + ) + + odbcClose(ch) + + endTime <- Sys.time() + if (datetimeFun == 'SYSUTCDATETIME') + endTime <- as.POSIXlt.POSIXct(Sys.time(), tz='UTC') + + print(paste0( + "Benchmark ended at ", + endTime, + " by ", + original_login$OriginalLogin + )) +} diff --git a/Scripts/Bufer_Cache_Info.sql b/Scripts/Bufer_Cache_Info.sql new file mode 100644 index 00000000..439c17e5 --- /dev/null +++ b/Scripts/Bufer_Cache_Info.sql @@ -0,0 +1,193 @@ +/* +Source: https://www.sqlshack.com/insight-into-the-sql-server-buffer-cache/ +Author: Ed Pollack +*/ +WITH CTE_BUFFER_CACHE AS ( + SELECT + objects.name AS object_name, + objects.type_desc AS object_type_description, + objects.object_id, + COUNT(*) AS buffer_cache_pages, + COUNT(*) * 8 / 1024 AS buffer_cache_used_MB + FROM sys.dm_os_buffer_descriptors + INNER JOIN sys.allocation_units + ON allocation_units.allocation_unit_id = dm_os_buffer_descriptors.allocation_unit_id + INNER JOIN sys.partitions + ON ((allocation_units.container_id = partitions.hobt_id AND type IN (1,3)) + OR (allocation_units.container_id = partitions.partition_id AND type IN (2))) + INNER JOIN sys.objects + ON partitions.object_id = objects.object_id + WHERE allocation_units.type IN (1,2,3) + AND objects.is_ms_shipped = 0 + AND dm_os_buffer_descriptors.database_id = DB_ID() + GROUP BY objects.name, + objects.type_desc, + objects.object_id) +SELECT + PARTITION_STATS.name, + CTE_BUFFER_CACHE.object_type_description, + CTE_BUFFER_CACHE.buffer_cache_pages, + CTE_BUFFER_CACHE.buffer_cache_used_MB, + PARTITION_STATS.total_number_of_used_pages, + PARTITION_STATS.total_number_of_used_pages * 8 / 1024 AS total_mb_used_by_object, + CAST((CAST(CTE_BUFFER_CACHE.buffer_cache_pages AS DECIMAL) / CAST(PARTITION_STATS.total_number_of_used_pages AS DECIMAL) * 100) AS DECIMAL(5,2)) AS percent_of_pages_in_memory +FROM CTE_BUFFER_CACHE +INNER JOIN ( + SELECT + objects.name, + objects.object_id, + SUM(used_page_count) AS total_number_of_used_pages + FROM sys.dm_db_partition_stats + INNER JOIN sys.objects + ON objects.object_id = dm_db_partition_stats.object_id + WHERE objects.is_ms_shipped = 0 + GROUP BY objects.name, objects.object_id) PARTITION_STATS +ON PARTITION_STATS.object_id = CTE_BUFFER_CACHE.object_id +ORDER BY CAST(CTE_BUFFER_CACHE.buffer_cache_pages AS DECIMAL) / CAST(PARTITION_STATS.total_number_of_used_pages AS DECIMAL) DESC; + +SELECT + indexes.name AS index_name, + objects.name AS object_name, + objects.type_desc AS object_type_description, + COUNT(*) AS buffer_cache_pages, + COUNT(*) * 8 / 1024 AS buffer_cache_used_MB, + SUM(allocation_units.used_pages) AS pages_in_index, + SUM(allocation_units.used_pages) * 8 /1024 AS total_index_size_MB, + CAST((CAST(COUNT(*) AS DECIMAL) / CAST(SUM(allocation_units.used_pages) AS DECIMAL) * 100) AS DECIMAL(5,2)) AS percent_of_pages_in_memory +FROM sys.dm_os_buffer_descriptors +INNER JOIN sys.allocation_units +ON allocation_units.allocation_unit_id = dm_os_buffer_descriptors.allocation_unit_id +INNER JOIN sys.partitions +ON ((allocation_units.container_id = partitions.hobt_id AND type IN (1,3)) +OR (allocation_units.container_id = partitions.partition_id AND type IN (2))) +INNER JOIN sys.objects +ON partitions.object_id = objects.object_id +INNER JOIN sys.indexes +ON objects.object_id = indexes.object_id +AND partitions.index_id = indexes.index_id +WHERE allocation_units.type IN (1,2,3) +AND objects.is_ms_shipped = 0 +AND dm_os_buffer_descriptors.database_id = DB_ID() +GROUP BY indexes.name, + objects.name, + objects.type_desc +ORDER BY CAST((CAST(COUNT(*) AS DECIMAL) / CAST(SUM(allocation_units.used_pages) AS DECIMAL) * 100) AS DECIMAL(5,2)) DESC; + +WITH CTE_BUFFER_CACHE AS +( SELECT + databases.name AS database_name, + COUNT(*) AS total_number_of_used_pages, + CAST(COUNT(*) * 8 AS DECIMAL) / 1024 AS buffer_cache_total_MB, + CAST(CAST(SUM(CAST(dm_os_buffer_descriptors.free_space_in_bytes AS BIGINT)) AS DECIMAL) / (1024 * 1024) AS DECIMAL(20,2)) AS buffer_cache_free_space_in_MB + FROM sys.dm_os_buffer_descriptors + INNER JOIN sys.databases + ON databases.database_id = dm_os_buffer_descriptors.database_id + GROUP BY databases.name) +SELECT + *, + CAST((buffer_cache_free_space_in_MB / NULLIF(buffer_cache_total_MB, 0)) * 100 AS DECIMAL(5,2)) AS buffer_cache_percent_free_space +FROM CTE_BUFFER_CACHE +ORDER BY buffer_cache_free_space_in_MB / NULLIF(buffer_cache_total_MB, 0) DESC; + +SELECT + objects.name AS object_name, + objects.type_desc AS object_type_description, + COUNT(*) AS buffer_cache_pages, + CAST(COUNT(*) * 8 AS DECIMAL) / 1024 AS buffer_cache_total_MB, + CAST(SUM(CAST(dm_os_buffer_descriptors.free_space_in_bytes AS BIGINT)) AS DECIMAL) / 1024 / 1024 AS buffer_cache_free_space_in_MB, + CAST((CAST(SUM(CAST(dm_os_buffer_descriptors.free_space_in_bytes AS BIGINT)) AS DECIMAL) / 1024 / 1024) / (CAST(COUNT(*) * 8 AS DECIMAL) / 1024) * 100 AS DECIMAL(5,2)) AS buffer_cache_percent_free_space +FROM sys.dm_os_buffer_descriptors +INNER JOIN sys.allocation_units +ON allocation_units.allocation_unit_id = dm_os_buffer_descriptors.allocation_unit_id +INNER JOIN sys.partitions +ON ((allocation_units.container_id = partitions.hobt_id AND type IN (1,3)) +OR (allocation_units.container_id = partitions.partition_id AND type IN (2))) +INNER JOIN sys.objects +ON partitions.object_id = objects.object_id +WHERE allocation_units.type IN (1,2,3) +AND objects.is_ms_shipped = 0 +AND dm_os_buffer_descriptors.database_id = DB_ID() +GROUP BY objects.name, + objects.type_desc, + objects.object_id +HAVING COUNT(*) > 0 +ORDER BY COUNT(*) DESC; + +SELECT + databases.name AS database_name, + COUNT(*) AS buffer_cache_total_pages, + SUM(CASE WHEN dm_os_buffer_descriptors.is_modified = 1 + THEN 1 + ELSE 0 + END) AS buffer_cache_dirty_pages, + SUM(CASE WHEN dm_os_buffer_descriptors.is_modified = 1 + THEN 0 + ELSE 1 + END) AS buffer_cache_clean_pages, + SUM(CASE WHEN dm_os_buffer_descriptors.is_modified = 1 + THEN 1 + ELSE 0 + END) * 8 / 1024 AS buffer_cache_dirty_page_MB, + SUM(CASE WHEN dm_os_buffer_descriptors.is_modified = 1 + THEN 0 + ELSE 1 + END) * 8 / 1024 AS buffer_cache_clean_page_MB +FROM sys.dm_os_buffer_descriptors +INNER JOIN sys.databases +ON dm_os_buffer_descriptors.database_id = databases.database_id +GROUP BY databases.name; + + +SELECT + indexes.name AS index_name, + objects.name AS object_name, + objects.type_desc AS object_type_description, + COUNT(*) AS buffer_cache_total_pages, + SUM(CASE WHEN dm_os_buffer_descriptors.is_modified = 1 + THEN 1 + ELSE 0 + END) AS buffer_cache_dirty_pages, + SUM(CASE WHEN dm_os_buffer_descriptors.is_modified = 1 + THEN 0 + ELSE 1 + END) AS buffer_cache_clean_pages, + SUM(CASE WHEN dm_os_buffer_descriptors.is_modified = 1 + THEN 1 + ELSE 0 + END) * 8 / 1024 AS buffer_cache_dirty_page_MB, + SUM(CASE WHEN dm_os_buffer_descriptors.is_modified = 1 + THEN 0 + ELSE 1 + END) * 8 / 1024 AS buffer_cache_clean_page_MB +FROM sys.dm_os_buffer_descriptors +INNER JOIN sys.allocation_units +ON allocation_units.allocation_unit_id = dm_os_buffer_descriptors.allocation_unit_id +INNER JOIN sys.partitions +ON ((allocation_units.container_id = partitions.hobt_id AND type IN (1,3)) +OR (allocation_units.container_id = partitions.partition_id AND type IN (2))) +INNER JOIN sys.objects +ON partitions.object_id = objects.object_id +INNER JOIN sys.indexes +ON objects.object_id = indexes.object_id +AND partitions.index_id = indexes.index_id +WHERE allocation_units.type IN (1,2,3) +AND objects.is_ms_shipped = 0 +AND dm_os_buffer_descriptors.database_id = DB_ID() +GROUP BY indexes.name, + objects.name, + objects.type_desc +ORDER BY COUNT(*) DESC; + + +-- Page Life Expectancy +SELECT * +FROM sys.dm_os_performance_counters +WHERE dm_os_performance_counters.object_name LIKE '%Buffer Manager%' +AND dm_os_performance_counters.counter_name = 'Page life expectancy'; + + +-- If your server has a NUMA (non-uniform memory access) architecture +SELECT * +FROM sys.dm_os_performance_counters +WHERE dm_os_performance_counters.object_name LIKE '%Buffer Node%' +AND dm_os_performance_counters.counter_name = 'Page life expectancy'; diff --git a/Scripts/Build_CREATE_TABLE_statement_using_dm_exec_describe_first_result_set.sql b/Scripts/Build_CREATE_TABLE_statement_using_dm_exec_describe_first_result_set.sql new file mode 100644 index 00000000..4cc6aa96 --- /dev/null +++ b/Scripts/Build_CREATE_TABLE_statement_using_dm_exec_describe_first_result_set.sql @@ -0,0 +1,76 @@ +/* + Builds a CREATE TABLE statement to create a temporary table with the required columns + By: Max Vernon +*/ +SET NOCOUNT ON; + +USE tempdb; +IF OBJECT_ID(N'dbo.outputTest', N'P') IS NOT NULL +DROP PROCEDURE dbo.outputTest; +GO +CREATE PROCEDURE dbo.outputTest +( + @column_i int + , @column_j varchar(30) + , @column_k char(6) +) +AS +BEGIN + SET NOCOUNT ON; + SELECT v.i + , v.j + , v.k + FROM (VALUES (@column_i, @column_j, @column_k)) v(i, j, k); +END +GO + +DECLARE @tempTableName sysname; +DECLARE @cmd nvarchar(max) + +SET @tempTableName = N'#someTable'; +SET @cmd = N'EXEC dbo.outputTest @column_i = 1, @column_j = NULL, @column_k = NULL;'; + +DECLARE @createTableStmt nvarchar(max); +DECLARE @maxColumnNameLength int; +DECLARE @maxTypeNameLength int; +SELECT @maxColumnNameLength = MAX(LEN(rs.name)) + , @maxTypeNameLength = MAX(LEN(rs.system_type_name)) +FROM sys.dm_exec_describe_first_result_set(@cmd, NULL, NULL) rs; + +SET @createTableStmt = STUFF( + ( + SELECT N', ' + rs.name + + N' ' + REPLICATE(N' ', @maxColumnNameLength - LEN(rs.name)) + + rs.system_type_name + N' ' + REPLICATE(N' ', @maxTypeNameLength - LEN(rs.system_type_name)) + + CASE WHEN rs.collation_name IS NOT NULL AND rs.collation_name <> DATABASEPROPERTYEX(DB_NAME(), 'Collation') + THEN N'COLLATE ' + rs.collation_name + N' ' ELSE N'' END + + CASE WHEN rs.is_nullable = 1 THEN N'NULL' ELSE N'NOT NULL' END + FROM sys.dm_exec_describe_first_result_set(@cmd, NULL, NULL) rs + ORDER BY rs.column_ordinal + FOR XML PATH('') + ), 1, 2, N''); +SET @createTableStmt = 'IF OBJECT_ID(N''' + @tempTableName + N''', N''U'') IS NOT NULL +BEGIN + DROP TABLE ' + @tempTableName + N'; +END +CREATE TABLE ' + @tempTableName + N' +( + ' + REPLACE(@createTableStmt, N', ', NCHAR(13) + NCHAR(10) + N' , ') + N' +); +'; + +IF LEN(@createTableStmt) > 4000 +BEGIN + DECLARE @CurrentLen int; + SET @CurrentLen = 1; + WHILE @CurrentLen <= LEN(@createTableStmt) + BEGIN + PRINT SUBSTRING(@createTableStmt, @CurrentLen, 4000); + SET @CurrentLen = @CurrentLen + 4000; + END + RAISERROR (N'Output is chunked into 4,000 char pieces - look for errant line endings!', 14, 1); +END +ELSE +BEGIN + PRINT @createTableStmt; +END; diff --git a/Scripts/Cached_Data_Per_Object_in_Memory.sql b/Scripts/Cached_Data_Per_Object_in_Memory.sql new file mode 100644 index 00000000..e98f8d55 --- /dev/null +++ b/Scripts/Cached_Data_Per_Object_in_Memory.sql @@ -0,0 +1,39 @@ +/* + + List Cached Data Per Object in Memory + 1 data set: list Cached Data Per Object in Memory. + No + Pinal Dave + 2021-03-31 + 2021-03-31 by Konstantin Taranov + 1.0 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Cached_Data_Per_Object_in_Memory.sql + https://blog.sqlauthority.com/2021/03/31/sql-server-cached-data-per-object-in-memory/ + +*/ + +SELECT COUNT (1) * 8 / 1024 AS MBUsed, + OBJECT_SCHEMA_NAME(object_id) SchemaName, + name AS TableName, index_id +FROM sys.dm_os_buffer_descriptors AS bd + INNER JOIN + ( + SELECT object_name(object_id) AS name + ,index_id ,allocation_unit_id, object_id + FROM sys.allocation_units AS au + INNER JOIN sys.partitions AS p + ON au.container_id = p.hobt_id + AND (au.type = 1 OR au.type = 3) + UNION ALL + SELECT object_name(object_id) AS name + ,index_id, allocation_unit_id, object_id + FROM sys.allocation_units AS au + INNER JOIN sys.partitions AS p + ON au.container_id = p.partition_id + AND au.type = 2 + ) AS obj + ON bd.allocation_unit_id = obj.allocation_unit_id +WHERE database_id = DB_ID() +GROUP BY OBJECT_SCHEMA_NAME(object_id), name, index_id +ORDER BY COUNT (*) * 8 / 1024 DESC; +GO diff --git a/Scripts/Change_NonDefault_Collation_for_all_tables.sql b/Scripts/Change_NonDefault_Collation_for_all_tables.sql new file mode 100644 index 00000000..b957e74e --- /dev/null +++ b/Scripts/Change_NonDefault_Collation_for_all_tables.sql @@ -0,0 +1,718 @@ +-- SSMS results to text - max length 8192 (change from default!!!) + +/******************************************************************************* +* +* Created 2017-06-16 By Philip C +* +* This script will check individual columns collations and check it against the +* database default collation, where they are different it will create the scripts +* required to drop all the objects dependant on the column, change the collation +* to the database default and then recreate the dependant objects. +* Some of the code has been reused from stuff found online the majority from +* Jayakumaur R who created scripts to drop and recreate constraints +* +* +* Modified 2019-01-11 by Hugo Kornelis +* https://sqlserverfast.com/blog/hugo/2019/01/collation-change-script/ +* +* Removed double checking of recreated constraints +* Modified the order of the output to minimize number of index rebuilds (assuming primary key is most often clsutered index) +* Fixed a bug caused by unique constraints overlapping the primary key constraint +* Fixed a bug in detection of foreign key constraints to drop and recreate +* Fixed bugs with recreating multi-column UNIQUE constraints +* +*********************************************************************************/ + +SET NOCOUNT ON; +SET ANSI_WARNINGS OFF; +GO + +-- Declare variables +DECLARE @SchemaName sysname, + @TableName sysname, + @IndexName sysname, + @ColumnName sysname, + @index_id int, + @is_unique nvarchar(100), + @IndexTypeDesc nvarchar(100), + @FileGroupName sysname, + @is_disabled nvarchar(100), + @IndexOptions nvarchar(MAX), + @IndexColumnId int, + @IsDescendingKey int, + @IsIncludedColumn int, + @TSQLScripCreationIndex nvarchar(MAX), + @TSQLScripDisableIndex nvarchar(MAX), + @object_id int, + @has_key_constraint int, + @has_index int, + @has_foreign_key int, + @has_stats int, + @stats_id int, + @FK_objectid int, + @FK_name sysname, + @UQ_objectid int, + @UQ_name sysname, + @UQ_index_id int, + @has_unique_constraint int, + @DatabaseCollation sysname, + @IndexColumns nvarchar(MAX), + @IncludedColumns nvarchar(MAX); + +-- Temporary table for generated script +CREATE TABLE #tempscriptstore + (ScriptType varchar(20), + script nvarchar(MAX)); + +-- Get dataabse default collation +SELECT @DatabaseCollation = collation_name +FROM sys.databases +WHERE database_id = DB_ID(); + +/************************************************************************************************************************************ +* Iterate over all the tables that have at least one colmun where collation doesn't match the database default. * +* Also checks for PRIMARY KEY, UNIQUE, and (referencing) FOREIGN KEY constraints, indexes, and manually created statistics. * +* (Note that the counts are not accurate counts due to duplication, these should only be tested for zero or non-zero) * +************************************************************************************************************************************/ +DECLARE collationfix CURSOR LOCAL FORWARD_ONLY READ_ONLY STATIC FOR +SELECT t.object_id, + OBJECT_SCHEMA_NAME(t.object_id) AS schemaname, + OBJECT_NAME(t.object_id) AS tablename, + COUNT(kc.object_id) AS has_key_constraint, + COUNT(ic.index_id) AS has_index, + COUNT(fk.constraint_object_id) AS has_foreign_key, + COUNT(st.stats_id) AS has_stats, + COUNT(uq.object_id) AS has_unique_constraint +FROM sys.tables AS t +INNER JOIN sys.columns AS c + ON c.object_id = t.object_id + AND c.collation_name <> @DatabaseCollation -- Table needs to have columns with "wrong" collation +INNER JOIN sys.types AS ty + ON ty.system_type_id = c.system_type_id + AND ty.name <> N'sysname' -- Exclusion retained from Philip C's original script +LEFT JOIN sys.index_columns AS ic -- Find indexes on any of the affected columns + ON ic.object_id = c.object_id + AND ic.column_id = c.column_id +LEFT JOIN sys.key_constraints AS kc -- Find primary key constraints related to an affected index + ON kc.parent_object_id = c.object_id + AND kc.unique_index_id = ic.index_id + AND kc.type = 'PK' +LEFT JOIN sys.key_constraints AS uq -- Find unique constraints related to an affected index + ON uq.parent_object_id = c.object_id + AND uq.unique_index_id = ic.index_id + AND uq.type = 'UQ' +LEFT JOIN sys.foreign_key_columns AS fk -- Find foreign key constraints on any of the affected columns + ON fk.parent_object_id = c.object_id + AND fk.parent_column_id = c.column_id +LEFT JOIN sys.stats_columns AS st -- Find statistics on any of the affected columns + ON st.object_id = c.object_id + AND st.column_id = c.column_id + AND st.stats_column_id <> 1 -- Retained from Philip C's original script, no idea why this is in the query +WHERE t.is_ms_shipped = 0 -- Exclude Microsoft-shipped tables +GROUP BY t.object_id; + +OPEN collationfix; +FETCH NEXT FROM collationfix +INTO @object_id, + @SchemaName, + @TableName, + @has_key_constraint, + @has_index, + @has_foreign_key, + @has_stats, + @has_unique_constraint; + +WHILE (@@FETCH_STATUS = 0) +BEGIN; + + /************************************************************************************************************************************ + * Generates the code to update the colation for all affected columns in the table * + ************************************************************************************************************************************/ + INSERT INTO #tempscriptstore (ScriptType, + script) + SELECT 'AlterCollation', + N'ALTER TABLE ' + QUOTENAME(@SchemaName) + N'.' + QUOTENAME(@TableName) + N' ALTER COLUMN ' + + QUOTENAME(c.name) + ' ' + + CASE WHEN ty.name = N'ntext' + THEN ty.name + N' COLLATE ' + @DatabaseCollation + ' ' + ELSE ty.name + N'(' + CASE WHEN c.max_length = -1 + THEN N'MAX' + ELSE CASE WHEN ty.name = N'nvarchar' + THEN CAST(c.max_length / 2 AS nvarchar(20)) + ELSE CAST(c.max_length AS nvarchar(20)) + END + END + N') COLLATE ' + @DatabaseCollation + END + CASE WHEN c.is_nullable = 1 THEN N' NULL;' ELSE N' NOT NULL;' END + FROM sys.columns AS c + INNER JOIN sys.types AS ty + ON ty.system_type_id = c.system_type_id + AND ty.name <> N'sysname' + WHERE c.object_id = @object_id + AND c.collation_name <> @DatabaseCollation; + + /************************************************************************************************************************************ + * If the table has affected indexes, this creates the drop and recreate index scripts * + ************************************************************************************************************************************/ + IF @has_index > 0 + BEGIN; + -- Process indexes on affected columns, one by one + DECLARE CursorIndex CURSOR LOCAL FORWARD_ONLY READ_ONLY STATIC FOR + SELECT ix.index_id, + ix.name, + CASE WHEN ix.is_unique = 1 THEN N'UNIQUE ' ELSE N'' END, + ix.type_desc, + CASE WHEN ix.is_padded = 1 + THEN N'PAD_INDEX = ON, ' + ELSE N'PAD_INDEX = OFF, ' + END + CASE WHEN ix.allow_page_locks = 1 + THEN N'ALLOW_PAGE_LOCKS = ON, ' + ELSE N'ALLOW_PAGE_LOCKS = OFF, ' + END + CASE WHEN ix.allow_row_locks = 1 + THEN N'ALLOW_ROW_LOCKS = ON, ' + ELSE N'ALLOW_ROW_LOCKS = OFF, ' + END + CASE WHEN INDEXPROPERTY(ix.object_id, ix.name, 'IsStatistics') = 1 + THEN N'STATISTICS_NORECOMPUTE = ON, ' + ELSE N'STATISTICS_NORECOMPUTE = OFF, ' + END + CASE WHEN ix.ignore_dup_key = 1 + THEN N'IGNORE_DUP_KEY = ON, ' + ELSE N'IGNORE_DUP_KEY = OFF, ' + END + N'SORT_IN_TEMPDB = OFF, FILLFACTOR =' + + CASE WHEN ix.fill_factor = 0 + THEN CAST(100 AS nvarchar(3)) + ELSE CAST(ix.fill_factor AS nvarchar(3)) + END AS IndexOptions, + ix.is_disabled, + FILEGROUP_NAME(ix.data_space_id) AS FileGroupName + FROM sys.indexes AS ix + WHERE ix.object_id = @object_id + AND ix.type <> 0 -- Exclude heaps + AND ix.is_primary_key = 0 -- Exclude primary key constraints (handled separately) + AND ix.is_unique_constraint = 0 -- Exclude unique constraints (handled separately) + AND EXISTS (SELECT * -- Has to constrain at least one column with wrong collation + FROM sys.index_columns AS ic + INNER JOIN sys.columns AS c + ON c.object_id = ic.object_id + AND c.column_id = ic.column_id + AND c.collation_name <> @DatabaseCollation + INNER JOIN sys.types AS ty + ON ty.system_type_id = c.system_type_id + AND ty.name <> N'sysname' + WHERE ic.index_id = ix.index_id + AND ic.object_id = ix.object_id); + + OPEN CursorIndex; + FETCH NEXT FROM CursorIndex + INTO @index_id, + @IndexName, + @is_unique, + @IndexTypeDesc, + @IndexOptions, + @is_disabled, + @FileGroupName; + + WHILE (@@FETCH_STATUS = 0) + BEGIN; + -- For each index, use a nested cursor to build lists of indexed and inclued columns + SET @IndexColumns = N''; + SET @IncludedColumns = N''; + + DECLARE CursorIndexColumn CURSOR FOR + SELECT c.name, + ic.is_descending_key, + ic.is_included_column + FROM sys.index_columns AS ic + INNER JOIN sys.columns AS c + ON c.object_id = ic.object_id + AND c.column_id = ic.column_id + WHERE ic.object_id = @object_id + AND ic.index_id = @index_id + ORDER BY ic.index_column_id; + + OPEN CursorIndexColumn; + FETCH NEXT FROM CursorIndexColumn + INTO @ColumnName, + @IsDescendingKey, + @IsIncludedColumn; + + WHILE (@@FETCH_STATUS = 0) + BEGIN; + IF @IsIncludedColumn = 0 + SET @IndexColumns += @ColumnName + + CASE WHEN @IsDescendingKey = 1 THEN N' DESC, ' ELSE N' ASC, ' END; + ELSE + SET @IncludedColumns += @ColumnName + N', '; + + FETCH NEXT FROM CursorIndexColumn + INTO @ColumnName, + @IsDescendingKey, + @IsIncludedColumn; + END; + + CLOSE CursorIndexColumn; + DEALLOCATE CursorIndexColumn; + + -- Remove trailing comma + SET @IndexColumns = SUBSTRING(@IndexColumns, 1, LEN(@IndexColumns) - 1); + IF @IncludedColumns <> N'' + SET @IncludedColumns = SUBSTRING(@IncludedColumns, 1, LEN(@IncludedColumns) - 1); + + -- Generate DROP INDEX statement + INSERT INTO #tempscriptstore (ScriptType, + script) + SELECT 'DropIndex', + N'DROP INDEX ' + QUOTENAME(@SchemaName) + '.' + QUOTENAME(@TableName) + '.' + QUOTENAME(@IndexName) + + N';'; + + -- Generate CREATE INDEX statement + INSERT INTO #tempscriptstore (ScriptType, + script) + SELECT 'CreateIndex', + N'CREATE ' + @is_unique + @IndexTypeDesc + N' INDEX ' + QUOTENAME(@IndexName) + N' ON ' + + QUOTENAME(@SchemaName) + N'.' + QUOTENAME(@TableName) + N'(' + @IndexColumns + N') ' + + CASE WHEN @IncludedColumns <> N'' + THEN N'INCLUDE (' + @IncludedColumns + N')' + ELSE N'' + END + N' WITH (' + @IndexOptions + N') ON ' + QUOTENAME(@FileGroupName) + N';'; + + -- Generate script to (re)disable disabled index after creating it + IF @is_disabled = 1 + INSERT INTO #tempscriptstore (ScriptType, + script) + SELECT 'DisableIndex', + N'ALTER INDEX ' + QUOTENAME(@IndexName) + N' ON ' + QUOTENAME(@SchemaName) + N'.' + + QUOTENAME(@TableName) + N' DISABLE;'; + + FETCH NEXT FROM CursorIndex + INTO @index_id, + @IndexName, + @is_unique, + @IndexTypeDesc, + @IndexOptions, + @is_disabled, + @FileGroupName; + END; + + CLOSE CursorIndex; + DEALLOCATE CursorIndex; + END; + + /************************************************************************************************************************************ + * If the table has an affected primary key constraint, this creates the drop and recreate constraint script * + * this has been taken and adapted from a script found online created by Jayakumaur R * + ************************************************************************************************************************************/ + IF @has_key_constraint > 0 + BEGIN; + -- Find columns and other metadata for primary key + SELECT kc.object_id AS constid, + kc.name AS constraint_name, -- PK name + QUOTENAME(c.name) + CASE WHEN ic.is_descending_key = 1 THEN N' DESC' ELSE N' ASC' END AS pk_col, + ic.key_ordinal, + i.name AS index_name, + i.type_desc AS index_type, + QUOTENAME(fg.name) AS filegroup_name, + N' WITH (PAD_INDEX = ' + CASE WHEN i.is_padded = 0 THEN N'OFF' ELSE N'ON' END + N', IGNORE_DUP_KEY = ' + + CASE WHEN i.ignore_dup_key = 0 THEN N'OFF' ELSE N'ON' END + N', ALLOW_ROW_LOCKS = ' + + CASE WHEN i.allow_row_locks = 0 THEN N'OFF' ELSE N'ON' END + ', ALLOW_PAGE_LOCKS = ' + + CASE WHEN i.allow_page_locks = 0 THEN N'OFF)' ELSE N'ON)' END AS index_property + INTO #temp_pk + FROM sys.key_constraints AS kc + INNER JOIN sys.indexes AS i + ON i.object_id = kc.parent_object_id + AND i.is_primary_key = 1 + INNER JOIN sys.index_columns AS ic + ON ic.object_id = i.object_id + AND ic.index_id = i.index_id + INNER JOIN sys.columns AS c + ON c.object_id = ic.object_id + AND c.column_id = ic.column_id + INNER JOIN sys.filegroups AS fg + ON fg.data_space_id = i.data_space_id + WHERE kc.type = 'PK' + AND kc.parent_object_id = @object_id; + + -- Generate DROP CONSTRAINT statement + INSERT INTO #tempscriptstore (ScriptType, + script) + SELECT TOP (1) -- One DROP statement, even if there are multiple columns + 'DropPrimaryKey', + N'ALTER TABLE ' + QUOTENAME(@SchemaName) + N'.' + QUOTENAME(@TableName) + N' DROP CONSTRAINT ' + + QUOTENAME(constraint_name) + N';' + FROM #temp_pk; + + -- Generate CREATE CONSTRAINT statement + INSERT INTO #tempscriptstore (ScriptType, + script) + SELECT TOP (1) -- One CREATE statement, even if there are multiple columns + 'AddPrimaryKey', + N'ALTER TABLE ' + QUOTENAME(@SchemaName) + N'.' + QUOTENAME(@TableName) + N' ADD CONSTRAINT ' + + QUOTENAME(p.constraint_name) + N' PRIMARY KEY ' + CAST(p.index_type AS nvarchar(100)) + N' (' + + STUFF((SELECT N', ' + pk_col -- This generates a comma-separated list of the columns, in order + FROM #temp_pk + ORDER BY key_ordinal + FOR XML PATH('')), + 1, + 2, + N'') + N')' + p.index_property + N' ON ' + p.filegroup_name + N';' + FROM #temp_pk AS p; + + DROP TABLE #temp_pk; + END; + + /************************************************************************************************************************************ + * If the table has a foreign key constraint on an affected column, this creates the drop and recreate constraint script * + * this has been taken and adapted from a script found online cretaed by Jayakumaur R * + ************************************************************************************************************************************/ + IF @has_foreign_key > 0 + BEGIN; + -- Process foreign key constraints on affected columns, one by one + DECLARE foreignkeycursor CURSOR FOR + SELECT fk.object_id, + fk.name + FROM sys.foreign_keys AS fk + WHERE fk.parent_object_id = @object_id + AND EXISTS (SELECT * -- Has to constrain at least one column with wrong collation + FROM sys.foreign_key_columns AS fkc + INNER JOIN sys.columns AS c + ON c.object_id = fkc.parent_object_id + AND c.column_id = fkc.parent_column_id + AND c.collation_name <> @DatabaseCollation + INNER JOIN sys.types AS ty + ON ty.system_type_id = c.system_type_id + AND ty.name <> N'sysname' + WHERE fkc.parent_object_id = fk.parent_object_id + AND fkc.constraint_object_id = fk.object_id); + + OPEN foreignkeycursor; + FETCH NEXT FROM foreignkeycursor + INTO @FK_objectid, + @FK_name; + + WHILE (@@FETCH_STATUS = 0) + BEGIN; + -- Find columns and other metadata for foreign key + SELECT fk.object_id AS constid, + fk.name AS constraint_name, -- FK name + fkc.constraint_column_id AS column_ordinal, + QUOTENAME(c1.name) AS key_col, + QUOTENAME(OBJECT_SCHEMA_NAME(fk.referenced_object_id)) + N'.' + + QUOTENAME(OBJECT_NAME(fk.referenced_object_id)) AS ref_table, + QUOTENAME(c2.name) AS ref_col, + CASE WHEN fk.delete_referential_action <> 0 -- No action + THEN N' ON DELETE ' + fk.delete_referential_action_desc + ELSE N'' + END AS delete_cascade, + CASE WHEN fk.update_referential_action <> 0 -- No action + THEN N' ON UPDATE ' + fk.update_referential_action_desc + ELSE N'' + END AS update_cascade, + fk.is_not_trusted, + fk.is_disabled + INTO #temp_fk + FROM sys.foreign_keys AS fk + INNER JOIN sys.foreign_key_columns AS fkc + ON fkc.parent_object_id = fk.parent_object_id + AND fkc.constraint_object_id = fk.object_id + INNER JOIN sys.columns AS c1 + ON c1.object_id = fkc.parent_object_id + AND c1.column_id = fkc.parent_column_id + INNER JOIN sys.columns AS c2 + ON c2.object_id = fkc.referenced_object_id + AND c2.column_id = fkc.referenced_column_id + WHERE fk.object_id = @FK_objectid; + + -- Generate DROP CONSTRAINT statement + INSERT INTO #tempscriptstore (ScriptType, + script) + SELECT 'DropForeignKey', + N'ALTER TABLE ' + QUOTENAME(@SchemaName) + N'.' + QUOTENAME(@TableName) + N' DROP CONSTRAINT ' + + QUOTENAME(@FK_name) + N';'; + + -- Generate CREATE CONSTRAINT statement (always as ënabled, "not trusted"; status is changed later in script) + INSERT INTO #tempscriptstore (ScriptType, + script) + SELECT TOP (1) -- One CREATE statement, even if there are multiple columns + 'AddForeignKey', + N'ALTER TABLE ' + QUOTENAME(@SchemaName) + N'.' + QUOTENAME(@TableName) + + N' WITH NOCHECK ADD CONSTRAINT ' + QUOTENAME(constraint_name) + N' FOREIGN KEY (' + + STUFF( + (SELECT N', ' + key_col -- This generates a comma-separated list of the constrained columns, in order + FROM #temp_fk + ORDER BY column_ordinal + FOR XML PATH('')), + 1, + 2, + N'') + N') REFERENCES ' + ref_table + N'(' + + STUFF( + (SELECT N', ' + ref_col -- This generates a comma-separated list of the referencedcolumns, in order + FROM #temp_fk + ORDER BY column_ordinal + FOR XML PATH('')), + 1, + 2, + N'') + N')' + delete_cascade + update_cascade + ';' + FROM #temp_fk; + + -- If constraint was disabled, add code to disable it again + INSERT INTO #tempscriptstore (ScriptType, + script) + SELECT TOP (1) -- One CREATE statement, even if there are multiple columns + 'DisableForeignKey', + N'ALTER TABLE ' + QUOTENAME(@SchemaName) + N'.' + QUOTENAME(@TableName) + N' NOCHECK CONSTRAINT ' + + QUOTENAME(constraint_name) + N';' + FROM #temp_fk + WHERE is_disabled = 1; + + -- If constraint was trusted, add code to force re-check so it's trudsted again + INSERT INTO #tempscriptstore (ScriptType, + script) + SELECT TOP (1) -- One CREATE statement, even if there are multiple columns + 'CheckForeignKey', + N'ALTER TABLE ' + QUOTENAME(@SchemaName) + N'.' + QUOTENAME(@TableName) + + N' WITH CHECK CHECK CONSTRAINT ' + QUOTENAME(constraint_name) + N';' + FROM #temp_fk + WHERE is_not_trusted = 0; + + DROP TABLE #temp_fk; + + FETCH NEXT FROM foreignkeycursor + INTO @FK_objectid, + @FK_name; + END; + CLOSE foreignkeycursor; + DEALLOCATE foreignkeycursor; + END; + + /* +-- DROP and CREATE statistics for manual statistics has been disabled for now + /************************************************************************************************************************************ + * If the column has statistics that aren't part of an index this creates the drop and recreate scripts * + ************************************************************************************************************************************/ + IF @has_stats > 0 + AND @has_index = 0 + BEGIN + DECLARE stats_cursor CURSOR FOR + SELECT sc.stats_id + FROM sys.stats_columns AS sc + JOIN sys.stats AS s + ON s.object_id = sc.object_id + AND s.stats_id = sc.stats_id + AND s.user_created = 1 + WHERE sc.object_id = @object_id + AND sc.column_id = @Collation_columnid; + OPEN stats_cursor; + FETCH NEXT FROM stats_cursor + INTO @stats_id; + WHILE (@@FETCH_STATUS = 0) + BEGIN + --Create DROP Statistics Statement + INSERT INTO #tempscriptstore + (ScriptType, + script) + SELECT 'DropStatistics', + 'DROP STATISTICS ' + QUOTENAME(OBJECT_SCHEMA_NAME(s.object_id)) + '.' + + QUOTENAME(OBJECT_NAME(s.object_id)) + '.' + QUOTENAME(s.name) + FROM sys.stats AS s + WHERE s.object_id = @object_id + AND s.stats_id = @stats_id; + + --Building the CREATE statistics statement + + --Obtaining all the information + SELECT QUOTENAME(OBJECT_SCHEMA_NAME(sc.object_id)) + '.' + QUOTENAME(OBJECT_NAME(sc.object_id)) AS st_table, + QUOTENAME(s.name) AS st_name, + QUOTENAME(c.name) AS st_column, + sc.object_id, + sc.stats_id, + sc.stats_column_id + INTO #temp_stats + FROM sys.stats_columns AS sc + JOIN sys.stats AS s + ON s.stats_id = sc.stats_id + AND s.object_id = sc.object_id + JOIN sys.columns AS c + ON c.object_id = sc.object_id + AND c.column_id = sc.column_id + WHERE sc.object_id = @object_id + AND sc.stats_id = @stats_id; + WITH + cte AS + (SELECT DISTINCT ts.st_table, + ts.st_name, + SUBSTRING((SELECT ',' + st_column + FROM #temp_stats + WHERE stats_id = ts.stats_id + ORDER BY stats_column_id ASC + FOR XML PATH('')), + 2, + 99999) AS st_col_list + FROM #temp_stats AS ts) + --Constructing the statement + INSERT INTO #tempscriptstore + (ScriptType, + script) + SELECT 'AddStatistics', + 'CREATE STATISTICS ' + cte.st_name + ' ON ' + cte.st_table + '(' + cte.st_col_list + ')' + FROM cte; + DROP TABLE #temp_stats; + FETCH NEXT FROM stats_cursor + INTO @stats_id; + END; + CLOSE stats_cursor; + DEALLOCATE stats_cursor; + END; +*/ + + /************************************************************************************************************************************ + * If the table has unique constraints on affected columns, this creates the drop and recreate scripts * + ************************************************************************************************************************************/ + IF @has_unique_constraint > 0 + BEGIN; + -- Process unique constraints on affected columns, one by one + DECLARE uniquecursor CURSOR FOR + SELECT kc.object_id, + kc.name, + kc.unique_index_id + FROM sys.key_constraints AS kc + WHERE kc.parent_object_id = @object_id + AND kc.type = 'UQ' + AND EXISTS (SELECT * -- Has to constrain at least one column with wrong collation + FROM sys.index_columns AS ic + INNER JOIN sys.columns AS c + ON c.object_id = ic.object_id + AND c.column_id = ic.column_id + AND c.collation_name <> @DatabaseCollation + INNER JOIN sys.types AS ty + ON ty.system_type_id = c.system_type_id + AND ty.name <> N'sysname' + WHERE ic.object_id = kc.parent_object_id + AND ic.index_id = kc.unique_index_id); + + OPEN uniquecursor; + FETCH NEXT FROM uniquecursor + INTO @UQ_objectid, + @UQ_name, + @UQ_index_id; + + WHILE (@@FETCH_STATUS = 0) + BEGIN; + -- Find columns and other metadata for unique constraint + SELECT QUOTENAME(c.name) + CASE WHEN ic.is_descending_key = 1 THEN N' DESC' ELSE N' ASC' END AS uq_col, + ic.key_ordinal, + i.name AS index_name, + i.type_desc AS index_type, + QUOTENAME(fg.name) AS filegroup_name, + N' WITH (PAD_INDEX = ' + CASE WHEN i.is_padded = 0 THEN N'OFF' ELSE N'ON' END + + N', IGNORE_DUP_KEY = ' + CASE WHEN i.ignore_dup_key = 0 THEN N'OFF' ELSE N'ON' END + + N', ALLOW_ROW_LOCKS = ' + CASE WHEN i.allow_row_locks = 0 THEN N'OFF' ELSE N'ON' END + + ', ALLOW_PAGE_LOCKS = ' + CASE WHEN i.allow_page_locks = 0 THEN N'OFF)' ELSE N'ON)' END AS index_property + INTO #temp_uq + FROM sys.indexes AS i + INNER JOIN sys.index_columns AS ic + ON ic.object_id = i.object_id + AND ic.index_id = i.index_id + INNER JOIN sys.columns AS c + ON c.object_id = ic.object_id + AND c.column_id = ic.column_id + INNER JOIN sys.filegroups AS fg + ON fg.data_space_id = i.data_space_id + WHERE i.object_id = @object_id + AND i.index_id = @UQ_index_id + AND i.is_unique_constraint = 1; + + -- Generate DROP CONSTRAINT statement + INSERT INTO #tempscriptstore (ScriptType, + script) + SELECT 'DropUniqueKey', + N'ALTER TABLE ' + QUOTENAME(@SchemaName) + N'.' + QUOTENAME(@TableName) + N' DROP CONSTRAINT ' + + QUOTENAME(@UQ_name) + N';'; + + -- Generate CREATE CONSTRAINT statement + INSERT INTO #tempscriptstore (ScriptType, + script) + SELECT TOP (1) -- One CREATE statement, even if there are multiple columns + 'AddUniqueKey', + N'ALTER TABLE ' + QUOTENAME(@SchemaName) + N'.' + QUOTENAME(@TableName) + N' ADD CONSTRAINT ' + + QUOTENAME(@UQ_name) + N' UNIQUE ' + CAST(index_type AS nvarchar(100)) + N' (' + + STUFF((SELECT N', ' + uq_col -- This generates a comma-separated list of the columns, in order + FROM #temp_uq + ORDER BY key_ordinal + FOR XML PATH('')), + 1, + 2, + N'') + N')' + index_property + N' ON ' + filegroup_name + N';' + FROM #temp_uq; + + DROP TABLE #temp_uq; + + FETCH NEXT FROM uniquecursor + INTO @UQ_objectid, + @UQ_name, + @UQ_index_id; + END; + CLOSE uniquecursor; + DEALLOCATE uniquecursor; + END; + + FETCH NEXT FROM collationfix + INTO @object_id, + @SchemaName, + @TableName, + @has_key_constraint, + @has_index, + @has_foreign_key, + @has_stats, + @has_unique_constraint; +END; +CLOSE collationfix; +DEALLOCATE collationfix; + +/************************************************************************************************************************************ +* Returns all the created scripts in the correct order for running * +* Also add GO in between some sections so the entire script can execute at once * +************************************************************************************************************************************/ +WITH ScriptInput + AS (SELECT script, + CASE WHEN ScriptType = 'DropForeignKey' + THEN 1 + WHEN ScriptType = 'DropIndex' + THEN 2 + WHEN ScriptType = 'DropUniqueKey' + THEN 3 + WHEN ScriptType = 'DropPrimaryKey' + THEN 4 + WHEN ScriptType = 'DropStatistics' + THEN 5 + WHEN ScriptType = 'AlterCollation' + THEN 7 + WHEN ScriptType = 'AddPrimaryKey' + THEN 9 + WHEN ScriptType = 'AddUniqueKey' + THEN 10 + WHEN ScriptType = 'CreateIndex' + THEN 11 + WHEN ScriptType = 'AddStatistics' + THEN 12 + WHEN ScriptType = 'AddForeignKey' + THEN 13 + WHEN ScriptType = 'DisableForeignKey' + THEN 15 + WHEN ScriptType = 'CheckForeignKey' + THEN 16 + WHEN ScriptType = 'DisableIndex' + THEN 17 + ELSE 99 + END AS SortOrder + FROM #tempscriptstore + UNION ALL + SELECT 'GO', + n.num + FROM (VALUES (6), -- After dropping objects, before changing collations + (8), -- After chaning collations, before re-creating objects + (14), -- After creating objects, before checking and disabling foreign keys and indexes + (18) -- End of script + ) AS n (num) ) +SELECT ScriptInput.script +FROM ScriptInput +ORDER BY ScriptInput.SortOrder; + +DROP TABLE #tempscriptstore; diff --git a/Scripts/CheckSpectreMeltdownStatus.sql b/Scripts/CheckSpectreMeltdownStatus.sql new file mode 100644 index 00000000..a5ac949c --- /dev/null +++ b/Scripts/CheckSpectreMeltdownStatus.sql @@ -0,0 +1,238 @@ + +-- Check Spectre/Meltdown Status for SQL Server +-- Glenn Berry +-- SQLskills.com +-- Last Modified: January 23, 2018 + +--****************************************************************************** +--* Copyright (C) 2018 Glenn Berry, SQLskills.com +--* All rights reserved. +--* +--* For more scripts and sample code, check out +--* https://www.sqlskills.com/blogs/glenn +--* +--* You may alter this code for your own *non-commercial* purposes. You may +--* republish altered code as long as you include this copyright and give due credit. +--* +--* +--* THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF +--* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED +--* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +--* PARTICULAR PURPOSE. +--* +--****************************************************************************** + +-- Determine if SQL Server has been patched against Meltdown/Spectre +-- This only checks the SQL Server patch status, not the operating system or hardware +-- This works for SQL Server 2008 through SQL Server 2017 + +-- You can use a Microsoft-provided PowerShell script to check your +-- operating system and hardware patch status as decribed in this Microsoft KB + +-- Windows Client Guidance for IT Pros to protect against speculative execution side-channel vulnerabilities +-- https://support.microsoft.com/en-us/help/4073119/protect-against-speculative-execution-side-channel-vulnerabilities-in + +SET NOCOUNT ON; + +-- Declare variables +DECLARE @MachineIdentification varchar(128) = ''; +DECLARE @ProductVersion varchar(20) = ''; +DECLARE @ProductBuild int = 0; +DECLARE @PatchStatus varchar(15) = 'not patched'; +DECLARE @FinalPatchMessage varchar(256) = ''; + +SET @MachineIdentification = 'Server Name = ' + CONVERT(varchar(50), SERVERPROPERTY ('MachineName')) + ', Instance Name = ' + ISNULL(CONVERT(varchar(50), SERVERPROPERTY('InstanceName')), 'None') + ': '; + + +-- Figure out major version number and then get the build number + +-- SQL Server 2008 +IF EXISTS (SELECT * WHERE CONVERT(varchar(20), SERVERPROPERTY('ProductVersion')) LIKE '10.0%') + BEGIN + SET @ProductVersion = CONVERT(varchar(20), SERVERPROPERTY('ProductVersion')); + IF @ProductVersion = '10.0.6556.0' + BEGIN + SET @PatchStatus = 'patched'; + END + SET @FinalPatchMessage = @MachineIdentification + N'SQL Server 2008, Build Number ' + @ProductVersion + '. This SQL Server instance is ' + @PatchStatus + ' against Spectre/Meltdown.'; + PRINT @FinalPatchMessage; + SELECT @FinalPatchMessage AS [SQL Server Patch Status]; + END + +-- Description of the security update for SQL Server 2008 SP4 GDR: January 6, 2018 +-- https://support.microsoft.com/en-us/help/4057114 +-- Build 10.0.6556.0 + + +-- SQL Server 2008 R2 +IF EXISTS (SELECT * WHERE CONVERT(varchar(20), SERVERPROPERTY('ProductVersion')) LIKE '10.5%') + BEGIN + SET @ProductVersion = CONVERT(varchar(20), SERVERPROPERTY('ProductVersion')); + IF @ProductVersion = '10.50.6560.0' + BEGIN + SET @PatchStatus = 'patched'; + END + SET @FinalPatchMessage = @MachineIdentification + N'SQL Server 2008 R2, Build Number ' + @ProductVersion + '. This SQL Server instance is ' + @PatchStatus + ' against Spectre/Meltdown.'; + PRINT @FinalPatchMessage; + SELECT @FinalPatchMessage AS [SQL Server Patch Status]; + END + + +-- Description of the security update for SQL Server 2008 R2 SP3 GDR: January 6, 2018 +-- https://support.microsoft.com/en-us/help/4057113 +-- 10.50.6560.0 + + +-- SQL Server 2012 +-- We have ProductBuild in SQL Server 2012 and newer +IF EXISTS (SELECT * WHERE CONVERT(varchar(20), SERVERPROPERTY('ProductVersion')) LIKE '11%') + BEGIN + SET @ProductVersion = CONVERT(varchar(20), SERVERPROPERTY('ProductVersion')); + SET @ProductBuild = CONVERT(int, SERVERPROPERTY('ProductBuild')); + IF @ProductBuild >= 7462 + BEGIN + SET @PatchStatus = 'patched'; + END + SET @FinalPatchMessage = @MachineIdentification + N'SQL Server 2012, Build Number ' + @ProductVersion + '. This SQL Server instance is ' + @PatchStatus + + ' against Spectre/Meltdown.'; + PRINT @FinalPatchMessage; + SELECT @FinalPatchMessage AS [SQL Server Patch Status]; + END + +-- Description of the security update for SQL Server 2012 SP4 GDR: January 12, 2018 +-- https://support.microsoft.com/en-us/help/4057116 +-- Build 11.0.7462.6 + + +-- SQL Server 2014 +IF EXISTS (SELECT * WHERE CONVERT(varchar(20), SERVERPROPERTY('ProductVersion')) LIKE '12%') + BEGIN + SET @ProductVersion = CONVERT(varchar(20), SERVERPROPERTY('ProductVersion')); + SET @ProductBuild = CONVERT(int, SERVERPROPERTY('ProductBuild')); + IF @ProductBuild >= 5571 -- SP2 CU + BEGIN + SET @PatchStatus = 'patched'; + END + IF @ProductBuild = 5214 -- SP2 GDR + BEGIN + SET @PatchStatus = 'patched'; + END + SET @FinalPatchMessage = @MachineIdentification + N'SQL Server 2014, Build Number ' + @ProductVersion + '. This SQL Server instance is ' + @PatchStatus + + ' against Spectre/Meltdown.'; + PRINT @FinalPatchMessage; + SELECT @FinalPatchMessage AS [SQL Server Patch Status]; + END + +-- Description of the security update for SQL Server 2014 SP2 CU10: January 16, 2018 +-- https://support.microsoft.com/en-us/help/4057117 +-- Build 12.0.5571.0 + +-- Description of the security update for SQL Server 2014 SP2 GDR: January 16, 2018 +-- https://support.microsoft.com/en-us/help/4057120 +-- Build 12.0.5214.6 + + +-- SQL Server 2016 +IF EXISTS (SELECT * WHERE CONVERT(varchar(20), SERVERPROPERTY('ProductVersion')) LIKE '13%') + BEGIN + SET @ProductVersion = CONVERT(varchar(20), SERVERPROPERTY('ProductVersion')); + SET @ProductBuild = CONVERT(int, SERVERPROPERTY('ProductBuild')); + IF @ProductBuild >= 4466 -- SP1 CU7 + BEGIN + SET @PatchStatus = 'patched'; + END + IF @ProductBuild = 4210 -- SP1 GDR + BEGIN + SET @PatchStatus = 'patched'; + END + IF @ProductBuild = 2218 -- RTM CU + BEGIN + SET @PatchStatus = 'patched'; + END + IF @ProductBuild = 1745 -- RTM GDR + BEGIN + SET @PatchStatus = 'patched'; + END + SET @FinalPatchMessage = @MachineIdentification + N'SQL Server 2016, Build Number ' + @ProductVersion + '. This SQL Server instance is ' + @PatchStatus + + ' against Spectre/Meltdown.'; + PRINT @FinalPatchMessage; + SELECT @FinalPatchMessage AS [SQL Server Patch Status]; + END + +-- Description of the security update for SQL Server 2016 CU7 SP1: January 3, 2018 +-- https://support.microsoft.com/en-us/help/4058561 +-- Build 13.0.4466.4 + +-- Description of the security update for SQL Server 2016 GDR SP1: January 3, 2018 +-- https://support.microsoft.com/en-us/help/4057118 +-- Build 13.0.4210.6 + +-- Description of the security update for SQL Server 2016 CU: January 6, 2018 +-- https://support.microsoft.com/en-us/help/4058559 +-- Build 13.0.2218.0 + +-- Description of the security update for SQL Server 2016 GDR: January 6, 2018 +-- https://support.microsoft.com/en-us/help/4058560 +-- Build 13.0.1745.2 + + +-- SQL Server 2017 +IF EXISTS (SELECT * WHERE CONVERT(varchar(20), SERVERPROPERTY('ProductVersion')) LIKE '14%') + BEGIN + SET @ProductVersion = CONVERT(varchar(20), SERVERPROPERTY('ProductVersion')); + SET @ProductBuild = CONVERT(int, SERVERPROPERTY('ProductBuild')); + IF @ProductBuild >= 3015 -- 2017 CU3 + BEGIN + SET @PatchStatus = 'patched'; + END + IF @ProductBuild = 2000 -- 2017 GDR + BEGIN + SET @PatchStatus = 'patched'; + END + SET @FinalPatchMessage = @MachineIdentification + N'SQL Server 2017, Build Number ' + @ProductVersion + '. This SQL Server instance is ' + @PatchStatus + + ' against Spectre/Meltdown.'; + PRINT @FinalPatchMessage; + SELECT @FinalPatchMessage AS [SQL Server Patch Status]; + END + +-- Description of the security update for SQL Server 2017 GDR: January 3, 2018 +-- https://support.microsoft.com/en-us/help/4057122 +-- Build 14.0.2000.63 + +-- Description of the security update for SQL Server 2017 CU3 RTM: January 3, 2018 +-- https://support.microsoft.com/en-us/help/4058562 +-- Build 14.0.3015.40 + + +-- SQL Server Guidance to protect against speculative execution side-channel vulnerabilities +-- https://support.microsoft.com/en-us/help/4073225/guidance-for-sql-server + + + +-- ToDo: Check for clr status, check for R Server, check for linked servers,etc. + +---- Get selected instance-level configuration values that relate to SQL Server extensibility features +SELECT name AS [Configuration Name], value as [Value], + value_in_use AS [Value In Use], description +FROM sys.configurations +WHERE name IN (N'clr enabled', N'clr strict security', + N'external scripts enabled', N'Ole Automation Procedures', + N'xp_cmdshell') +ORDER BY name; + +-- If clr enabled is 1, then strongly consider setting clr strict security to 1 (on new enough builds of SQL Server 2012, 2014, 2016, and 2017) + +-- Update adds the "CLR strict security" feature to SQL Server 2016 +-- https://support.microsoft.com/en-us/help/4018930/update-adds-the-clr-strict-security-feature-to-sql-server-2016 + + +------ Check for Polybase and R Services +--SELECT SERVERPROPERTY('IsPolybaseInstalled') AS [IsPolybaseInstalled], +--SERVERPROPERTY('IsAdvancedAnalyticsInstalled') AS [IsRServicesInstalled]; + +------ Linked servers +--EXEC sp_linkedservers; + + +--SELECT j.[name], s.step_name, s.subsystem +--FROM msdb.dbo.sysjobsteps AS s +--INNER JOIN msdb.dbo.sysjobs AS j +--ON s.job_id = j.job_id +--WHERE s.subsystem = N'ActiveScripting' +--GO diff --git a/Scripts/Check_Reserved_Words_For_Object_Names.sql b/Scripts/Check_Reserved_Words_For_Object_Names.sql new file mode 100644 index 00000000..0cc64b43 --- /dev/null +++ b/Scripts/Check_Reserved_Words_For_Object_Names.sql @@ -0,0 +1,48 @@ +/* +Author: +Original link: https://www.red-gate.com/simple-talk/blogs/sql-naming-conventions/ +*/ + +SELECT o.name + FROM sys.objects AS o + INNER JOIN + ( + VALUES ('ADD'), ('EXTERNAL'), ('PROCEDURE'), ('ALL'), ('FETCH'), + ('PUBLIC'), ('ALTER'), ('FILE'), ('RAISERROR'), ('AND'), + ('FILLFACTOR'), ('READ'), ('ANY'), ('FOR'), ('READTEXT'), ('AS'), + ('FOREIGN'), ('RECONFIGURE'), ('ASC'), ('FREETEXT'), ('REFERENCES'), + ('AUTHORIZATION'), ('FREETEXTTABLE'), ('REPLICATION'), ('BACKUP'), + ('FROM'), ('RESTORE'), ('BEGIN'), ('FULL'), ('RESTRICT'), ('BETWEEN'), + ('FUNCTION'), ('RETURN'), ('BREAK'), ('GOTO'), ('REVERT'), ('BROWSE'), + ('GRANT'), ('REVOKE'), ('BULK'), ('GROUP'), ('RIGHT'), ('BY'), + ('HAVING'), ('ROLLBACK'), ('CASCADE'), ('HOLDLOCK'), ('ROWCOUNT'), + ('CASE'), ('IDENTITY'), ('ROWGUIDCOL'), ('CHECK'), ('IDENTITY_INSERT'), + ('RULE'), ('CHECKPOINT'), ('IDENTITYCOL'), ('SAVE'), ('CLOSE'), ('IF'), + ('SCHEMA'), ('CLUSTERED'), ('IN'), ('SECURITYAUDIT'), ('COALESCE'), + ('INDEX'), ('SELECT'), ('COLLATE'), ('INNER'), + ('SEMANTICKEYPHRASETABLE'), ('COLUMN'), ('INSERT'), + ('SEMANTICSIMILARITYDETAILSTABLE'), ('COMMIT'), ('INTERSECT'), + ('SEMANTICSIMILARITYTABLE'), ('COMPUTE'), ('INTO'), ('SESSION_USER'), + ('CONSTRAINT'), ('IS'), ('SET'), ('CONTAINS'), ('JOIN'), ('SETUSER'), + ('CONTAINSTABLE'), ('KEY'), ('SHUTDOWN'), ('CONTINUE'), ('KILL'), + ('SOME'), ('CONVERT'), ('LEFT'), ('STATISTICS'), ('CREATE'), ('LIKE'), + ('SYSTEM_USER'), ('CROSS'), ('LINENO'), ('TABLE'), ('CURRENT'), + ('LOAD'), ('TABLESAMPLE'), ('CURRENT_DATE'), ('MERGE'), ('TEXTSIZE'), + ('CURRENT_TIME'), ('NATIONAL'), ('THEN'), ('CURRENT_TIMESTAMP'), + ('NOCHECK'), ('TO'), ('CURRENT_USER'), ('NONCLUSTERED'), ('TOP'), + ('CURSOR'), ('NOT'), ('TRAN'), ('DATABASE'), ('NULL'), ('TRANSACTION'), + ('DBCC'), ('NULLIF'), ('TRIGGER'), ('DEALLOCATE'), ('OF'), + ('TRUNCATE'), ('DECLARE'), ('OFF'), ('TRY_CONVERT'), ('DEFAULT'), + ('OFFSETS'), ('TSEQUAL'), ('DELETE'), ('ON'), ('UNION'), ('DENY'), + ('OPEN'), ('UNIQUE'), ('DESC'), ('OPENDATASOURCE'), ('UNPIVOT'), + ('DISK'), ('OPENQUERY'), ('UPDATE'), ('DISTINCT'), ('OPENROWSET'), + ('UPDATETEXT'), ('DISTRIBUTED'), ('OPENXML'), ('USE'), ('DOUBLE'), + ('OPTION'), ('USER'), ('DROP'), ('OR'), ('VALUES'), ('DUMP'), + ('ORDER'), ('VARYING'), ('ELSE'), ('OUTER'), ('VIEW'), ('END'), + ('OVER'), ('WAITFOR'), ('ERRLVL'), ('PERCENT'), ('WHEN'), ('ESCAPE'), + ('PIVOT'), ('WHERE'), ('EXCEPT'), ('PLAN'), ('WHILE'), ('EXEC'), + ('PRECISION'), ('WITH'), ('EXECUTE'), ('PRIMARY'), ('WITHIN GROUP'), + ('EXISTS'), ('PRINT'), ('WRITETEXT'), ('EXIT'), ('PROC') + ) AS reserved (word) + ON reserved.word = o.name; + diff --git a/Scripts/Checkpoint_XE.sql b/Scripts/Checkpoint_XE.sql new file mode 100644 index 00000000..46a4fe4d --- /dev/null +++ b/Scripts/Checkpoint_XE.sql @@ -0,0 +1,50 @@ + + Analyze checkpoint extended events result + 1 data set: checploints info. + No + Aaron Bertrand + 2020-02-17 + 2021-09-30 by Konstantin Taranov + 1.0 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Checkpoint_XE.sql + https://www.mssqltips.com/sqlservertip/6319/sql-server-checkpoint-monitoring-with-extended-events/ + + +DROP TABLE IF EXISTS #xml; +GO +SELECT ev = SUBSTRING([object_name],12,5), ed = CONVERT(xml, event_data) + INTO #xml + FROM sys.fn_xe_file_target_read_file('L:\XE_Out\CheckPoint*.xel', NULL, NULL, NULL); +;WITH Events(ev,ts,db,id) AS +( + SELECT ev, + ed.value(N'(event/@timestamp)[1]', N'datetime'), + ed.value(N'(event/data[@name="database_id"]/value)[1]', N'int'), + ed.value(N'(event/action[@name="attach_activity_id"]/value)[1]', N'uniqueidentifier') + FROM #xml +), +EventPairs AS +( + SELECT db, ev, + checkpoint_ended = ts, + checkpoint_began = LAG(ts, 1) OVER (PARTITION BY id, db ORDER BY ts) + FROM Events +), +Timings AS +( + SELECT + dbname = DB_NAME(db), + checkpoint_began, + checkpoint_ended, + duration_milliseconds = DATEDIFF(MILLISECOND, checkpoint_began, checkpoint_ended) + FROM EventPairs WHERE ev = 'end' AND checkpoint_began IS NOT NULL +) +SELECT + dbname, + checkpoint_count = COUNT(*), + avg_seconds = CONVERT(decimal(18,2),AVG(1.0*duration_milliseconds)/1000), + max_seconds = CONVERT(decimal(18,2),MAX(1.0*duration_milliseconds)/1000), + total_seconds_spent = CONVERT(decimal(18,2),SUM(1.0*duration_milliseconds)/1000) +FROM Timings +GROUP BY dbname +ORDER BY total_seconds_spent DESC; diff --git a/Scripts/Code_Reuse_With_Dynamic_SQL_and_Temp_Procedures_Example.sql b/Scripts/Code_Reuse_With_Dynamic_SQL_and_Temp_Procedures_Example.sql new file mode 100644 index 00000000..8f408abf --- /dev/null +++ b/Scripts/Code_Reuse_With_Dynamic_SQL_and_Temp_Procedures_Example.sql @@ -0,0 +1,74 @@ +/* + + Konstantin Taranov + List All Unicode Code Points. + PRINT variables values getted from temporary stored procedures. + 2019-04-18 + 2019-04-18 + 1.0 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Code_Reuse_With_Dynamic_SQL_and_Temp_Procedures_Example.sql + +*/ + + +BEGIN /* CREATE temporary procedures for reusing TSQL code */ + EXEC sp_executesql N'IF OBJECT_ID(''tempdb..#usp_GetTime'', ''P'') IS NOT NULL DROP PROCEDURE #usp_GetTime;' + EXEC sp_executesql N' + CREATE PROCEDURE #usp_GetTime( + @i VARCHAR(16) + , @o DATETIME2(7) OUTPUT + ) + AS + BEGIN + SET @o = CASE WHEN @i = ''SYSDATETIME'' THEN SYSDATETIME() + WHEN @i = ''SYSUTCDATETIME'' THEN SYSUTCDATETIME() + END; + END;'; + + EXEC sp_executesql N'IF OBJECT_ID(''tempdb..#usp_GetDuration'', ''P'') IS NOT NULL DROP PROCEDURE #usp_GetDuration;' + EXEC sp_executesql N' + CREATE PROCEDURE #usp_GetDuration( + @datepart VARCHAR(5) + , @startdate DATETIME2(7) + , @enddate DATETIME2(7) + , @o INT OUTPUT + ) + AS + BEGIN TRY + SET @o = CASE WHEN @datepart = ''ns'' THEN DATEDIFF(ns, @startdate, @enddate) + WHEN @datepart = ''mcs'' THEN DATEDIFF(mcs, @startdate, @enddate) + WHEN @datepart = ''ms'' THEN DATEDIFF(ms, @startdate, @enddate) + WHEN @datepart = ''ss'' THEN DATEDIFF(ss, @startdate, @enddate) + WHEN @datepart = ''mi'' THEN DATEDIFF(mi, @startdate, @enddate) + WHEN @datepart = ''hh'' THEN DATEDIFF(hh, @startdate, @enddate) + WHEN @datepart = ''dd'' THEN DATEDIFF(dd, @startdate, @enddate) + WHEN @datepart = ''wk'' THEN DATEDIFF(wk, @startdate, @enddate) + ELSE 0 + END; + END TRY + + BEGIN CATCH + PRINT ''Error: '' + CONVERT(varchar(50), ERROR_NUMBER()) + + '', Severity: '' + CONVERT(varchar(5), ERROR_SEVERITY()) + + '', State: '' + CONVERT(varchar(5), ERROR_STATE()) + + '', Procedure: '' + ISNULL(ERROR_PROCEDURE(), ''-'') + + '', Line: '' + CONVERT(varchar(5), ERROR_LINE()) + + '', User name: '' + CONVERT(sysname, ORIGINAL_LOGIN()) + PRINT(ERROR_MESSAGE()); + END CATCH; + '; +END; + +DECLARE @startTime datetime2(7); +DECLARE @dateTimeFunction varchar(16) = 'SYSDATETIME'; +EXEC #usp_GetTime @i = @dateTimeFunction, @o = @startTime OUTPUT; + +DECLARE @runTimeStamp datetime2(7) = SYSDATETIME(); +DECLARE @finishTime datetime2(7) = DATEADD(hour, -1, @runTimeStamp); +DECLARE @duration int; +DECLARE @durationAccuracy varchar(5) = 'ss'; + +EXEC #usp_GetDuration @datepart = @durationAccuracy, @startdate = @runTimeStamp, @enddate = @finishTime, @o = @duration OUTPUT; + +PRINT('@startTime = ' + ISNULL(CAST(@startTime AS varchar(27)), 'IS NULL')); +PRINT('@duration = ' + ISNULL(CAST(@duration AS varchar(27)), 'IS NULL')); diff --git a/Scripts/Compare_Tables_With_Matching_Columns.sql b/Scripts/Compare_Tables_With_Matching_Columns.sql new file mode 100644 index 00000000..0d04af51 --- /dev/null +++ b/Scripts/Compare_Tables_With_Matching_Columns.sql @@ -0,0 +1,129 @@ +/* + + Find all matching column names between tables. Useful for exploring databases with implied relationships but no foreign keys. + 1 data set: temp table #results. + No + Tom Barrett + 2022-08-27 + 2022-08-27 by Tom Barrett + 1.0 + +*/ + +SET NOCOUNT ON; + +/* create staging objects */ +IF object_id('tempdb..#tablesToQuery') IS NOT NULL +BEGIN + DROP TABLE #tablesToQuery +END + +CREATE TABLE #tablesToQuery ( + DatabaseName NVARCHAR(1000) + , SchemaName NVARCHAR(1000) + , TableName NVARCHAR(1000) + , IsProcessed BIT DEFAULT 0 + ) +GO + +IF object_id('tempdb..#results') IS NOT NULL +BEGIN + DROP TABLE #results +END + +CREATE TABLE #results ( + DatabaseName NVARCHAR(1000) + , ColumnName NVARCHAR(1000) + , Table1 NVARCHAR(1000) + , Table2 NVARCHAR(1000) + ) +GO + +/* get list of tables */ +INSERT INTO #tablesToQuery ( + DatabaseName + , SchemaName + , TableName + ) +SELECT TABLE_CATALOG + , TABLE_SCHEMA + , TABLE_NAME +FROM INFORMATION_SCHEMA.TABLES +ORDER BY TABLE_CATALOG + , TABLE_SCHEMA + , TABLE_NAME +GO + +/* loop through tables and get matching columns by name */ +DECLARE @x INT = 1; +DECLARE @table NVARCHAR(1000); + +WHILE @x <= ( + SELECT count('dracula') + FROM #tablesToQuery + WHERE IsProcessed = 0 + ) +BEGIN + /* get next table*/ + SELECT TOP 1 @table = TableName + FROM #tablesToQuery + WHERE IsProcessed = 0; + + /* insert into #results any tables + columns that match */ + WITH cte + AS ( + SELECT TABLE_CATALOG + , TABLE_SCHEMA + , TABLE_NAME + , COLUMN_NAME + FROM INFORMATION_SCHEMA.COLUMNS + ) + INSERT INTO #results + SELECT cte1.TABLE_CATALOG + , cte1.COLUMN_NAME + , CONCAT ( + cte1.TABLE_SCHEMA + , '.' + , cte1.TABLE_NAME + ) + , CONCAT ( + cte2.TABLE_SCHEMA + , '.' + , cte2.TABLE_NAME + ) + FROM cte AS cte1 + JOIN cte AS cte2 ON cte1.TABLE_CATALOG = cte2.TABLE_CATALOG + AND cte1.TABLE_SCHEMA collate Latin1_general_CI_AI = cte2.TABLE_SCHEMA collate Latin1_general_CI_AI /* remove this line to search different schemas*/ + AND cte1.TABLE_NAME collate Latin1_general_CI_AI <> cte2.TABLE_NAME collate Latin1_general_CI_AI + AND cte1.COLUMN_NAME collate Latin1_general_CI_AI = cte2.COLUMN_NAME collate Latin1_general_CI_AI + WHERE cte1.TABLE_NAME = @table + /* add any other irrelevant or metadata columns to exclude */ + AND cte1.COLUMN_NAME collate Latin1_general_CI_AI NOT IN ( + 'ID' + , 'ACTIVE' + , 'CREATEDBY' + , 'ETC.' + ) + + UPDATE #tablesToQuery + SET IsProcessed = 1 + WHERE TableName = @table; +END + +/* return results */ +SELECT * +FROM #results +/* uncomment this line to search results for a specific table */ +/* WHERE Table1 = 'Schema.Table' */ +ORDER BY ColumnName + , Table1 + , Table2 +GO + +/* clean up */ +DROP TABLE #results +GO + +DROP TABLE #tablesToQuery +GO + diff --git a/Scripts/Compress_Tables_And_Indexes.sql b/Scripts/Compress_Tables_And_Indexes.sql new file mode 100644 index 00000000..a6e70b56 --- /dev/null +++ b/Scripts/Compress_Tables_And_Indexes.sql @@ -0,0 +1,205 @@ +/* + + Compress tables and indexes + Temp table #estimated_results and print or exec rebuild index commands + Max Vernon + 2019-08-08 + 2019-09-12 by Konstantin Taranov + 1.1 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Compress_Tables.sql + https://www.sqlserverscience.com/performance/compress-big-tables/ + +*/ + + +/* + Compresses tables and indexes that are consuming more than the specified amount of space. + + By: Max Vernon, 2019-08-08 + + Set the following variables before running the script! + - @DebugOnly - 1 will cause the script to print out the generated commands, 0 will also execute those commands + - @OnlineOnly - 1 causes the script to use ONLINE=ON when performing the compress operation + - @CompressionType - can be "PAGE" or "ROW" + - @MinObjectSizeGB - the minimum current size of a table/index before it will be considered for compression + - @MinCompressionRatio - the minimum estimated compression ratio before a table/index will be compressed, + a lower number indicates a higher level of compression: + 0.25 - the data must compress to 1/4 its uncompressed size + 0.5 - the data must compress to half its uncompressed size + 0.1 - the data must compress to 1/10th its uncompressed size + 1.0 - no compression + Notes: + - Only Heaps, Clustered Indexes, and Non-Clustered Indexes are affected by this script. +*/ + +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +SET NOCOUNT ON; + +DECLARE @DebugOnly bit = 1; --set to zero to actually compress tables +DECLARE @MinObjectSizeGB decimal(38,2) = 0.01; +DECLARE @OnlineOnly bit = 1; +DECLARE @CompressionType nvarchar(60) = N'PAGE'; --can be PAGE or ROW +DECLARE @MinCompressionRatio decimal(38,2) = 10; + +DECLARE @SchemaName sysname; +DECLARE @ObjectName sysname; +DECLARE @IndexID int; +DECLARE @PartitionNumber int; +DECLARE @MaxDOP int; +DECLARE @msg nvarchar(1000); +DECLARE @cmd nvarchar(max); + +SET @MaxDOP = ( --set our MaxDOP to half of the configured value, or 1 if the sysadmin + --hasn't explicity configured the value + SELECT COALESCE(CONVERT(int, c.value), 2) + FROM sys.configurations c + WHERE c.name = N'max degree of parallelism' + ) / 2; + +IF OBJECT_ID(N'tempdb..#estimated_results', N'U') IS NOT NULL +DROP TABLE #estimated_results; +CREATE TABLE #estimated_results +( + [schema_name] sysname NULL + , [object_name] sysname NULL + , [index_id] int NULL + , [partition_number] int NULL + , [size_with_current_compression_setting(KB)] bigint NULL + , [size_with_requested_compression_setting(KB)] bigint NULL + , [sample_size_with_current_compression_setting(KB)] bigint NULL + , [sample_size_with_requested_compression_setting(KB)] bigint NULL +); + +DECLARE cur CURSOR LOCAL FORWARD_ONLY STATIC READ_ONLY +FOR +SELECT SchemaName = s.name + , ObjectName = o.name + , i.index_id + , p.partition_number +FROM sys.schemas s + INNER JOIN sys.objects o ON s.schema_id = o.schema_id + INNER JOIN sys.indexes i ON o.object_id = i.object_id + INNER JOIN sys.partitions p ON i.object_id = p.object_id AND i.index_id = p.index_id + INNER JOIN ( + SELECT v.index_type + FROM (VALUES + (0) --heap + , (1) --clustered index + , (2) --non-clustered index + )v(index_type) + ) index_types ON i.type = index_types.index_type +WHERE i.is_hypothetical = 0 + AND s.name <> N'sys' + AND o.is_ms_shipped = 0 + AND p.data_compression_desc <> @CompressionType + AND ( + ( + @OnlineOnly = 1 + AND NOT EXISTS ( + SELECT 1 + FROM sys.columns c + INNER JOIN sys.types ty ON c.system_type_id = ty.system_type_id + WHERE c.object_id = o.object_id + AND ( + ty.name = N'ntext' --none of these column types can be compressed online + OR ty.name = N'text' + OR ty.name = N'image' + ) + ) + AND p.filestream_filegroup_id = 0 --no filestream table can be compressed online + ) + OR @OnlineOnly = 0 + ) + AND NOT EXISTS ( + --tables with sparse columns cannot be compressed. + --https://docs.microsoft.com/en-us/sql/relational-databases/data-compression/data-compression?view=sql-server-2017#how-compression-affects-other-sql-server-components + SELECT 1 + FROM sys.columns c + WHERE c.object_id = o.object_id + AND c.is_sparse = 1 + ) +ORDER BY s.name + , o.name + , i.index_id + , p.partition_number; + +OPEN cur; +FETCH NEXT FROM cur INTO @SchemaName, @ObjectName, @IndexID, @PartitionNumber; +WHILE @@FETCH_STATUS = 0 +BEGIN + SET @msg = N'EXEC sys.sp_estimate_data_compression_savings @schema_name = N''' + @SchemaName + N''' + , @object_name = N''' + @ObjectName + N''' + , @index_id = ' + CONVERT(nvarchar(1000), @IndexID) + N' + , @partition_number = ' + CONVERT(nvarchar(1000), @PartitionNumber) + N' + , @data_compression = ' + @CompressionType + N';'; + --RAISERROR (@msg, 0, 1) WITH NOWAIT; + + INSERT INTO #estimated_results ( + object_name + , schema_name + , index_id + , partition_number + , [size_with_current_compression_setting(KB)] + , [size_with_requested_compression_setting(KB)] + , [sample_size_with_current_compression_setting(KB)] + , [sample_size_with_requested_compression_setting(KB)] + ) + EXEC sys.sp_estimate_data_compression_savings @schema_name = @SchemaName + , @object_name = @ObjectName + , @index_id = @IndexID + , @partition_number = @PartitionNumber + , @data_compression = @CompressionType; + FETCH NEXT FROM cur INTO @SchemaName, @ObjectName, @IndexID, @PartitionNumber; +END +CLOSE cur; +DEALLOCATE cur; + +DECLARE cur CURSOR LOCAL FORWARD_ONLY STATIC READ_ONLY +FOR +SELECT CASE WHEN er.index_id = 0 THEN + N'ALTER TABLE ' + QUOTENAME(er.schema_name) + N'.' + QUOTENAME(er.object_name) + N' +REBUILD WITH ( + DATA_COMPRESSION = ' + @CompressionType + N' + , ONLINE = ' + CASE WHEN @OnlineOnly = 1 THEN N'ON' ELSE N'OFF' END + N' + , SORT_IN_TEMPDB = OFF + , MAXDOP = ' + CONVERT(nvarchar(10), @MaxDOP) + N' + ); +' +ELSE + N'ALTER INDEX ' + QUOTENAME(i.name) + N' ON ' + QUOTENAME(er.schema_name) + N'.' + QUOTENAME(er.object_name) + N' +REBUILD WITH ( + DATA_COMPRESSION = ' + @CompressionType + N' + , ONLINE = ' + CASE WHEN @OnlineOnly = 1 THEN N'ON' ELSE N'OFF' END + N' + , SORT_IN_TEMPDB = OFF + , MAXDOP = ' + CONVERT(nvarchar(10), @MaxDOP) + N' + ); +' +END +FROM #estimated_results er + LEFT JOIN sys.schemas s ON er.schema_name = s.name + LEFT JOIN sys.objects o ON s.schema_id = o.schema_id AND er.object_name = o.name + LEFT JOIN sys.indexes i ON o.object_id = i.object_id AND er.index_id = i.index_id +WHERE er.[size_with_current_compression_setting(KB)] >= (@MinObjectSizeGB * 1048576) --sizes are reported in KB + AND (CONVERT(decimal(38, 2), er.[size_with_requested_compression_setting(KB)]) / er.[size_with_current_compression_setting(KB)]) <= @MinCompressionRatio +OPEN cur; +FETCH NEXT FROM cur INTO @cmd; +WHILE @@FETCH_STATUS = 0 +BEGIN + if @DebugOnly = 0 + BEGIN + BEGIN TRANSACTION + RAISERROR (@cmd, 0, 1) WITH NOWAIT; + EXEC sys.sp_executesql @cmd; + COMMIT TRANSACTION + CHECKPOINT + END + ELSE + BEGIN + RAISERROR (@cmd, 0, 1) WITH NOWAIT; + END + FETCH NEXT FROM cur INTO @cmd; +END +CLOSE cur; +DEALLOCATE cur; + +SELECT * FROM #estimated_results; diff --git a/Scripts/Configure_SQL_Agent_Alerts.sql b/Scripts/Configure_SQL_Agent_Alerts.sql new file mode 100644 index 00000000..74288e2a --- /dev/null +++ b/Scripts/Configure_SQL_Agent_Alerts.sql @@ -0,0 +1,344 @@ +-- Add important SQL Agent Alerts to your instance + +-- This will work with SQL Server 2008 and newer +-- Glenn Berry +-- SQLskills.com +-- Last Modified: August 11, 2014 +-- http://sqlserverperformance.wordpress.com/ +-- http://sqlskills.com/blogs/glenn/ +-- Twitter: GlennAlanBerry + +-- Listen to my Pluralsight courses +-- http://www.pluralsight.com/author/glenn-berry + +-- Change the @OperatorName as needed + + +USE [msdb]; +GO + +SET NOCOUNT ON; + + +-- Change @OperatorName as needed +DECLARE @OperatorName sysname = N'SQLDBAGroup'; + +-- Change @CategoryName as needed +DECLARE @CategoryName sysname = N'SQL Server Agent Alerts'; + +-- Make sure you have an Agent Operator defined that matches the name you supplied +IF NOT EXISTS(SELECT * FROM msdb.dbo.sysoperators WHERE name = @OperatorName) + BEGIN + RAISERROR ('There is no SQL Operator with a name of %s' , 18 , 16 , @OperatorName); + RETURN; + END + +-- Add Alert Category if it does not exist +IF NOT EXISTS (SELECT * + FROM msdb.dbo.syscategories + WHERE category_class = 2 -- ALERT + AND category_type = 3 + AND name = @CategoryName) + BEGIN + EXEC dbo.sp_add_category @class = N'ALERT', @type = N'NONE', @name = @CategoryName; + END + +-- Get the server name +DECLARE @ServerName sysname = (SELECT @@SERVERNAME); + + +-- Alert Names start with the name of the server +DECLARE @Sev19AlertName sysname = @ServerName + N' Alert - Sev 19 Error: Fatal Error in Resource'; +DECLARE @Sev20AlertName sysname = @ServerName + N' Alert - Sev 20 Error: Fatal Error in Current Process'; +DECLARE @Sev21AlertName sysname = @ServerName + N' Alert - Sev 21 Error: Fatal Error in Database Process'; +DECLARE @Sev22AlertName sysname = @ServerName + N' Alert - Sev 22 Error: Fatal Error: Table Integrity Suspect'; +DECLARE @Sev23AlertName sysname = @ServerName + N' Alert - Sev 23 Error: Fatal Error Database Integrity Suspect'; +DECLARE @Sev24AlertName sysname = @ServerName + N' Alert - Sev 24 Error: Fatal Hardware Error'; +DECLARE @Sev25AlertName sysname = @ServerName + N' Alert - Sev 25 Error: Fatal Error'; +DECLARE @Error823AlertName sysname = @ServerName + N' Alert - Error 823: The operating system returned an error'; +DECLARE @Error824AlertName sysname = @ServerName + N' Alert - Error 824: Logical consistency-based I/O error'; +DECLARE @Error825AlertName sysname = @ServerName + N' Alert - Error 825: Read-Retry Required'; +DECLARE @Error832AlertName sysname = @ServerName + N' Alert - Error 832: Constant page has changed'; +DECLARE @Error855AlertName sysname = @ServerName + N' Alert - Error 855: Uncorrectable hardware memory corruption detected'; +DECLARE @Error856AlertName sysname = @ServerName + N' Alert - Error 856: SQL Server has detected hardware memory corruption, but has recovered the page'; + + + +-- Sev 19 Error: Fatal Error in Resource +IF NOT EXISTS (SELECT name FROM msdb.dbo.sysalerts WHERE name = @Sev19AlertName) + EXEC msdb.dbo.sp_add_alert @name = @Sev19AlertName, + @message_id = 0, @severity = 19, @enabled = 1, + @delay_between_responses = 900, @include_event_description_in = 1, + @category_name = @CategoryName, + @job_id = N'00000000-0000-0000-0000-000000000000'; + +-- Add a notification if it does not exist +IF NOT EXISTS(SELECT * + FROM dbo.sysalerts AS sa + INNER JOIN dbo.sysnotifications AS sn + ON sa.id = sn.alert_id + WHERE sa.name = @Sev19AlertName) + BEGIN + EXEC msdb.dbo.sp_add_notification @alert_name = @Sev19AlertName, @operator_name = @OperatorName, @notification_method = 1; + END + + +-- Sev 20 Error: Fatal Error in Current Process +IF NOT EXISTS (SELECT name FROM msdb.dbo.sysalerts WHERE name = @Sev20AlertName) + EXEC msdb.dbo.sp_add_alert @name = @Sev20AlertName, + @message_id = 0, @severity = 20, @enabled = 1, + @delay_between_responses = 900, @include_event_description_in = 1, + @category_name = @CategoryName, + @job_id = N'00000000-0000-0000-0000-000000000000' + +-- Add a notification if it does not exist +IF NOT EXISTS(SELECT * + FROM dbo.sysalerts AS sa + INNER JOIN dbo.sysnotifications AS sn + ON sa.id = sn.alert_id + WHERE sa.name = @Sev20AlertName) + BEGIN + EXEC msdb.dbo.sp_add_notification @alert_name = @Sev20AlertName, @operator_name = @OperatorName, @notification_method = 1; + END + + +-- Sev 21 Error: Fatal Error in Database Process +IF NOT EXISTS (SELECT name FROM msdb.dbo.sysalerts WHERE name = @Sev21AlertName) + EXEC msdb.dbo.sp_add_alert @name = @Sev21AlertName, + @message_id = 0, @severity = 21, @enabled = 1, + @delay_between_responses = 900, @include_event_description_in = 1, + @category_name = @CategoryName, + @job_id = N'00000000-0000-0000-0000-000000000000'; + +-- Add a notification if it does not exist +IF NOT EXISTS(SELECT * + FROM dbo.sysalerts AS sa + INNER JOIN dbo.sysnotifications AS sn + ON sa.id = sn.alert_id + WHERE sa.name = @Sev21AlertName) + BEGIN + EXEC msdb.dbo.sp_add_notification @alert_name = @Sev21AlertName, @operator_name = @OperatorName, @notification_method = 1; + END + + +-- Sev 22 Error: Fatal Error Table Integrity Suspect +IF NOT EXISTS (SELECT name FROM msdb.dbo.sysalerts WHERE name = @Sev22AlertName) + EXEC msdb.dbo.sp_add_alert @name = @Sev22AlertName, + @message_id = 0, @severity = 22, @enabled = 1, + @delay_between_responses = 900, @include_event_description_in = 1, + @category_name = @CategoryName, + @job_id = N'00000000-0000-0000-0000-000000000000'; + +-- Add a notification if it does not exist +IF NOT EXISTS(SELECT * + FROM dbo.sysalerts AS sa + INNER JOIN dbo.sysnotifications AS sn + ON sa.id = sn.alert_id + WHERE sa.name = @Sev22AlertName) + BEGIN + EXEC msdb.dbo.sp_add_notification @alert_name = @Sev22AlertName, @operator_name = @OperatorName, @notification_method = 1; + END + + +-- Sev 23 Error: Fatal Error Database Integrity Suspect +IF NOT EXISTS (SELECT name FROM msdb.dbo.sysalerts WHERE name = @Sev23AlertName) + EXEC msdb.dbo.sp_add_alert @name = @Sev23AlertName, + @message_id = 0, @severity = 23, @enabled = 1, + @delay_between_responses = 900, @include_event_description_in = 1, + @category_name = @CategoryName, + @job_id = N'00000000-0000-0000-0000-000000000000'; + +-- Add a notification if it does not exist +IF NOT EXISTS(SELECT * + FROM dbo.sysalerts AS sa + INNER JOIN dbo.sysnotifications AS sn + ON sa.id = sn.alert_id + WHERE sa.name = @Sev23AlertName) + BEGIN + EXEC msdb.dbo.sp_add_notification @alert_name = @Sev23AlertName, @operator_name = @OperatorName, @notification_method = 1; + END + + +-- Sev 24 Error: Fatal Hardware Error +IF NOT EXISTS (SELECT name FROM msdb.dbo.sysalerts WHERE name = @Sev24AlertName) + EXEC msdb.dbo.sp_add_alert @name = @Sev24AlertName, + @message_id = 0, @severity = 24, @enabled = 1, + @delay_between_responses = 900, @include_event_description_in = 1, + @category_name = @CategoryName, + @job_id = N'00000000-0000-0000-0000-000000000000'; + +-- Add a notification if it does not exist +IF NOT EXISTS(SELECT * + FROM dbo.sysalerts AS sa + INNER JOIN dbo.sysnotifications AS sn + ON sa.id = sn.alert_id + WHERE sa.name = @Sev24AlertName) + BEGIN + EXEC msdb.dbo.sp_add_notification @alert_name = @Sev24AlertName, @operator_name = @OperatorName, @notification_method = 1; + END + + +-- Sev 25 Error: Fatal Error +IF NOT EXISTS (SELECT name FROM msdb.dbo.sysalerts WHERE name = @Sev25AlertName) + EXEC msdb.dbo.sp_add_alert @name = @Sev25AlertName, + @message_id = 0, @severity = 25, @enabled = 1, + @delay_between_responses = 900, @include_event_description_in = 1, + @category_name = @CategoryName, + @job_id = N'00000000-0000-0000-0000-000000000000'; + +-- Add a notification if it does not exist +IF NOT EXISTS(SELECT * + FROM dbo.sysalerts AS sa + INNER JOIN dbo.sysnotifications AS sn + ON sa.id = sn.alert_id + WHERE sa.name = @Sev25AlertName) + BEGIN + EXEC msdb.dbo.sp_add_notification @alert_name = @Sev25AlertName, @operator_name = @OperatorName, @notification_method = 1; + END + +-- Error 823 Alert added on 8/11/2014 + +-- Error 823: Operating System Error +-- How to troubleshoot a Msg 823 error in SQL Server +-- http://support.microsoft.com/kb/2015755 +IF NOT EXISTS (SELECT name FROM msdb.dbo.sysalerts WHERE name = @Error823AlertName) + EXEC msdb.dbo.sp_add_alert @name = @Error823AlertName, + @message_id = 823, @severity = 0, @enabled = 1, + @delay_between_responses = 900, @include_event_description_in = 1, + @category_name = @CategoryName, + @job_id = N'00000000-0000-0000-0000-000000000000'; + + +-- Add a notification if it does not exist +IF NOT EXISTS(SELECT * + FROM dbo.sysalerts AS sa + INNER JOIN dbo.sysnotifications AS sn + ON sa.id = sn.alert_id + WHERE sa.name = @Error823AlertName) + BEGIN + EXEC msdb.dbo.sp_add_notification @alert_name = @Error823AlertName, @operator_name = @OperatorName, @notification_method = 1; + END + +-- Error 824 Alert added on 8/11/2014 + +-- Error 824: Logical consistency-based I/O error +-- How to troubleshoot Msg 824 in SQL Server +-- http://support.microsoft.com/kb/2015756 +IF NOT EXISTS (SELECT name FROM msdb.dbo.sysalerts WHERE name = @Error824AlertName) + EXEC msdb.dbo.sp_add_alert @name = @Error824AlertName, + @message_id = 824, @severity = 0, @enabled = 1, + @delay_between_responses = 900, @include_event_description_in = 1, + @category_name = @CategoryName, + @job_id = N'00000000-0000-0000-0000-000000000000'; + + +-- Add a notification if it does not exist +IF NOT EXISTS(SELECT * + FROM dbo.sysalerts AS sa + INNER JOIN dbo.sysnotifications AS sn + ON sa.id = sn.alert_id + WHERE sa.name = @Error824AlertName) + BEGIN + EXEC msdb.dbo.sp_add_notification @alert_name = @Error824AlertName, @operator_name = @OperatorName, @notification_method = 1; + END + + +-- Error 825: Read-Retry Required +-- How to troubleshoot Msg 825 (read retry) in SQL Server +-- http://support.microsoft.com/kb/2015757 +IF NOT EXISTS (SELECT name FROM msdb.dbo.sysalerts WHERE name = @Error825AlertName) + EXEC msdb.dbo.sp_add_alert @name = @Error825AlertName, + @message_id = 825, @severity = 0, @enabled = 1, + @delay_between_responses = 900, @include_event_description_in = 1, + @category_name = @CategoryName, + @job_id =N'00000000-0000-0000-0000-000000000000'; + + +-- Add a notification if it does not exist +IF NOT EXISTS(SELECT * + FROM dbo.sysalerts AS sa + INNER JOIN dbo.sysnotifications AS sn + ON sa.id = sn.alert_id + WHERE sa.name = @Error825AlertName) + BEGIN + EXEC msdb.dbo.sp_add_notification @alert_name = @Error825AlertName, @operator_name = @OperatorName, @notification_method = 1; + END + +-- Error 832 Alert added on 10/30/2013 + +-- Error 832: Constant page has changed +-- http://www.sqlskills.com/blogs/paul/dont-confuse-error-823-and-error-832/ +-- http://support.microsoft.com/kb/2015759 +IF NOT EXISTS (SELECT name FROM msdb.dbo.sysalerts WHERE name = @Error832AlertName) + EXEC msdb.dbo.sp_add_alert @name = @Error832AlertName, + @message_id = 832, @severity = 0, @enabled = 1, + @delay_between_responses = 900, @include_event_description_in = 1, + @category_name = @CategoryName, + @job_id = N'00000000-0000-0000-0000-000000000000'; + + +-- Add a notification if it does not exist +IF NOT EXISTS(SELECT * + FROM dbo.sysalerts AS sa + INNER JOIN dbo.sysnotifications AS sn + ON sa.id = sn.alert_id + WHERE sa.name = @Error832AlertName) + BEGIN + EXEC msdb.dbo.sp_add_notification @alert_name = @Error832AlertName, @operator_name = @OperatorName, @notification_method = 1; + END + + +-- Memory Error Correction alerts added on 10/30/2013 + +-- Mitigation of RAM Hardware Errors +-- When SQL Server 2012 Enterprise Edition is installed on a Windows 2012 operating system with hardware that supports bad memory diagnostics, +-- you will notice new error messages like 854, 855, and 856 instead of the 832 errors that LazyWriter usually generates. +-- Error 854 is just informing you that your instance supports memory error correction + +-- Using SQL Server in Windows 8 and Windows Server 2012 environments +-- http://support.microsoft.com/kb/2681562 + + +-- Check for SQL Server 2012 or greater and Enterprise Edition +-- You also need Windows Server 2012 or greater, plus hardware that supports memory error correction +IF LEFT(CONVERT(CHAR(2),SERVERPROPERTY('ProductVersion')), 2) >= '11' AND SERVERPROPERTY('EngineEdition') = 3 + BEGIN + -- Error 855: Uncorrectable hardware memory corruption detected + IF NOT EXISTS (SELECT name FROM msdb.dbo.sysalerts WHERE name = @Error855AlertName) + EXEC msdb.dbo.sp_add_alert @name = @Error855AlertName, + @message_id = 855, @severity = 0, @enabled = 1, + @delay_between_responses = 900, @include_event_description_in = 1, + @category_name = @CategoryName, + @job_id = N'00000000-0000-0000-0000-000000000000'; + + + -- Add a notification if it does not exist + IF NOT EXISTS(SELECT * + FROM dbo.sysalerts AS sa + INNER JOIN dbo.sysnotifications AS sn + ON sa.id = sn.alert_id + WHERE sa.name = @Error855AlertName) + BEGIN + EXEC msdb.dbo.sp_add_notification @alert_name = @Error855AlertName, @operator_name = @OperatorName, @notification_method = 1; + END + + -- Error 856: SQL Server has detected hardware memory corruption, but has recovered the page + IF NOT EXISTS (SELECT name FROM msdb.dbo.sysalerts WHERE name = @Error856AlertName) + EXEC msdb.dbo.sp_add_alert @name = @Error856AlertName, + @message_id = 856, @severity = 0, @enabled = 1, + @delay_between_responses = 900, @include_event_description_in = 1, + @category_name = @CategoryName, + @job_id = N'00000000-0000-0000-0000-000000000000'; + + + -- Add a notification if it does not exist + IF NOT EXISTS(SELECT * + FROM dbo.sysalerts AS sa + INNER JOIN dbo.sysnotifications AS sn + ON sa.id = sn.alert_id + WHERE sa.name = @Error856AlertName) + BEGIN + EXEC msdb.dbo.sp_add_notification @alert_name = @Error856AlertName, @operator_name = @OperatorName, @notification_method = 1; + END + END +GO diff --git a/Scripts/Count_Database_Reads_and_Writes.sql b/Scripts/Count_Database_Reads_and_Writes.sql new file mode 100644 index 00000000..b2fa821e --- /dev/null +++ b/Scripts/Count_Database_Reads_and_Writes.sql @@ -0,0 +1,30 @@ +/* + + Counts reads and writes for databases + Reads and writes per database. + 2020-04-07 by Brent Ozar + 2020-04-15 by Konstantin Taranov + 1.1 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Count_Database_Reads_and_Writes.sql + https://www.brentozar.com/archive/2020/04/how-can-i-measure-if-my-database-does-more-reads-than-writes/ + +*/ + + +WITH reads_and_writes AS ( + SELECT db.name AS database_name, + SUM(user_seeks + user_scans + user_lookups) AS reads, + SUM(user_updates) AS writes, + SUM(user_seeks + user_scans + user_lookups + user_updates) AS all_activity + FROM sys.dm_db_index_usage_stats us + INNER JOIN sys.databases db ON us.database_id = db.database_id + GROUP BY db.name +) +SELECT + database_name + , reads + , ((reads * 1.0) / all_activity) * 100 AS reads_percent + , writes + , ((writes * 1.0) / all_activity) * 100 AS writes_percent + FROM reads_and_writes AS rw + ORDER BY database_name; diff --git a/Scripts/Create_2_Million_Tables.sql b/Scripts/Create_2_Million_Tables.sql new file mode 100644 index 00000000..4863a99e --- /dev/null +++ b/Scripts/Create_2_Million_Tables.sql @@ -0,0 +1,39 @@ +/* +https://docs.microsoft.com/en-us/sql/sql-server/maximum-capacity-specifications-for-sql-server +Database objects include objects such as tables, views, stored procedures, user-defined functions, triggers, rules, defaults, and constraints. +The sum of the number of all objects in a database cannot exceed 2,147,483,647. +*/ +CREATE DATABASE [TwoMillion]; + +ALTER DATABASE [TwoMillion] SET RECOVERY SIMPLE WITH NO_WAIT; +GO + +USE [TwoMillion]; + +SET NOCOUNT ON; + +DECLARE @sql nvarchar(max) = N''; +DECLARE @i int = 1; + +SELECT @i = 2147483647 - COUNT(*) FROM [TwoMillion].sys.objects; +PRINT N'Creating ' + FORMAT(@i,'N0') + N' tables...'; + +WHILE @i > 0 +BEGIN + SET @i -= 1; + + SET @sql = N'CREATE TABLE [TwoMillion].dbo.t' + CONVERT(nvarchar(max),2147483648-@i) + N' (i int);'; + IF (@i % 10000) = 0 RAISERROR(@sql, 0, 1) WITH NOWAIT; + + EXEC sp_executesql @sql; +END; + +/* +ALTER DATABASE [TwoMillion] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; +GO + +USE master; +GO + +DROP DATABASE [TwoMillion]; +*/ diff --git a/Scripts/Create_JOIN_Query_Between_Multiple_Tables_Dynamically.sql b/Scripts/Create_JOIN_Query_Between_Multiple_Tables_Dynamically.sql new file mode 100644 index 00000000..9a53d9da --- /dev/null +++ b/Scripts/Create_JOIN_Query_Between_Multiple_Tables_Dynamically.sql @@ -0,0 +1,73 @@ +/* + + Create JOIN query between multiple tables dynamically. + SELECT statement from input table with INNER JOINS for all tables having foreign consttraints with input table. + Does not properly generate alias for case with multiply foreign keys for one table + Konstantin Taranov + 2019-04-22 + 2019-04-23 by Konstantin Taranov + 1.1 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Create_JOIN_Query_Between_Multiple_Tables_Dynamically.sql + +*/ + +DECLARE @schemaName AS sysname = N'dbo'; +DECLARE @tableName AS sysname = N'TableName'; +DECLARE @tableFullName AS nvarchar(256) = QUOTENAME(@schemaName) + N'.' + QUOTENAME(@tableName) +DECLARE @crlf AS varchar(10) = CHAR(10); +DECLARE @tsql AS nvarchar(max); + +IF LEFT(@tableName, 1) = N'[' OR LEFT(@schemaName, 1) = N'[' +THROW 50001, 'Please do not use quotes in Table or Schema names! In the script it is alredy done with QUOTENAME function.', 1; + +IF OBJECT_ID(@tableFullName) IS NULL +THROW 50002, 'Table is not exist in database. Please check @schemaName and @tableName variables.', 1; + + +WITH AllColumns + AS (SELECT + pObj.name AS ParentTable + ,pCol.COLUMN_NAME AS ParentColumn + ,SCHEMA_NAME(fkObj.schema_id) AS ReferecedTableSchema + ,fkObj.name AS ReferecedTable + ,fkCol.COLUMN_NAME AS ReferencedColumn + FROM sys.foreign_key_columns AS fkc + INNER JOIN sys.objects AS pObj ON pObj.object_id = fkc.parent_object_id + INNER JOIN INFORMATION_SCHEMA.COLUMNS AS pCol ON pCol.TABLE_NAME = pObj.name + AND pCol.ORDINAL_POSITION = fkc.parent_column_id + INNER JOIN sys.objects AS fkObj ON fkObj.object_id = fkc.referenced_object_id + INNER JOIN INFORMATION_SCHEMA.COLUMNS AS fkCol ON fkCol.TABLE_NAME = fkObj.name + AND fkCol.ORDINAL_POSITION = fkc.referenced_column_id + WHERE fkc.constraint_object_id IN + ( + SELECT + object_id + FROM sys.objects AS o + WHERE o.name IN + ( + SELECT + tc.CONSTRAINT_NAME AS CONSTRAINT_NAME + FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS tc + WHERE tc.CONSTRAINT_TYPE = 'FOREIGN KEY' + AND tc.TABLE_NAME = @tableName + AND tc.TABLE_SCHEMA = @schemaName + ) + )) + SELECT + @tsql = + N'SELECT TOP(100) ' + QUOTENAME(@tableName) + N'.*' + @crlf + + N'FROM ' + @tableFullName + + ISNULL( + ( + SELECT + @crlf + N'INNER JOIN ' + QUOTENAME(ac.ReferecedTableSchema) + N'.' + QUOTENAME(ac.ReferecedTable) + N' ON' + @crlf + + N' ' + QUOTENAME(ac.ParentTable) + N'.' + QUOTENAME(ac.ParentColumn) + ' = ' + + QUOTENAME(ac.ReferecedTable) + '.' + QUOTENAME(ac.ReferencedColumn) + FROM AllColumns AS ac FOR + XML PATH('') + ), N'') + N';'; + +IF @tsql IS NULL +PRINT('@tsql is NULL - something went wrong!'); +ELSE +PRINT(@tsql); diff --git a/Scripts/DBCC_CHECKDB_Latest_date.sql b/Scripts/DBCC_CHECKDB_Latest_date.sql new file mode 100644 index 00000000..221eb279 --- /dev/null +++ b/Scripts/DBCC_CHECKDB_Latest_date.sql @@ -0,0 +1,77 @@ +/* +Author: Max Vernon +Original link: https://www.sqlserverscience.com/maintenance/check-dbcc-checkdb/ +Source link: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/DBCC_CHECKDB_Latest_date.sql +Modified: 2018-01-26 18:20 by Konstantin Taranov +*/ + + +SET NOCOUNT ON; + +DECLARE @MaxDaysWithoutCheckDB int = 1; + +IF OBJECT_ID(N'tempdb..#Results') IS NOT NULL +BEGIN + DROP TABLE #Results; +END; + +CREATE TABLE #Results( + DatabaseName SYSNAME NULL + , IsOnline BIT NULL + , ParentObject varchar(100) NULL + , [Object] varchar(100) NULL + , [Field] varchar(100) NULL + , [Value] varchar(100) NULL +); + +DECLARE @cmd NVARCHAR(4000); +DECLARE @dbName SYSNAME; +DECLARE @IsOnline BIT; + +DECLARE cur CURSOR LOCAL FORWARD_ONLY STATIC READ_ONLY +FOR +SELECT DBCCCommand = CAST(N'DBCC DBINFO(N''' + d.name + N''') WITH TABLERESULTS;' AS NVARCHAR(500)) + , DatabaseName = d.name + , IsOnline = CONVERT(BIT, CASE WHEN d.state_desc = 'ONLINE' THEN 1 ELSE 0 END) +FROM sys.databases d +ORDER BY d.name; + +OPEN cur; +FETCH NEXT FROM cur INTO @cmd, @dbName, @IsOnline; + +WHILE @@FETCH_STATUS = 0 +BEGIN + RAISERROR (@dbName, 0, 1) WITH NOWAIT; + IF @IsOnline = 1 + BEGIN + INSERT INTO #Results + (ParentObject, [Object], [Field], [Value]) + EXEC sp_executesql @cmd; + + UPDATE #Results + SET DatabaseName = @dbName + , IsOnline = @IsOnline + WHERE DatabaseName IS NULL; + END + ELSE + BEGIN + INSERT INTO #Results + (DatabaseName, IsOnline) + VALUES + (@dbName, @IsOnline) + END + + FETCH NEXT FROM cur INTO @cmd, @dbName, @IsOnline; +END + +CLOSE cur; +DEALLOCATE cur; + +SELECT ServerName = @@SERVERNAME + , DatabaseName = r.DatabaseName + , LastKnownGoodDate = CONVERT(DATETIME, r.Value, 120) + , AtRisk = CASE WHEN DATEDIFF(day, CONVERT(DATETIME, r.Value, 120), GETDATE()) > @MaxDaysWithoutCheckDB THEN 'X' ELSE '' END + , IsDBOnline = r.IsOnline +FROM #Results r +WHERE r.Field = 'dbi_dbccLastKnownGood' + OR r.Field IS NULL; diff --git a/Scripts/Data_Dictionary_Information.sql b/Scripts/Data_Dictionary_Information.sql new file mode 100644 index 00000000..c9f01596 --- /dev/null +++ b/Scripts/Data_Dictionary_Information.sql @@ -0,0 +1,153 @@ +/*-------------------------------------------------------------------------------------------------- +Name: DataDictionarySelect.sql +Purpose: Display information for every column in every table of a database. +Author: Patrick Slesicki +Created: 3/16/2008 +Notes: Select the database to run against and execute. +http://www.sqlservercentral.com/scripts/Data+Dictionary/167354/ +---------------------------------------------------------------------------------------------------- +PRELIMINAIRES +*/-------------------------------------------------------------------------------------------------- +DECLARE + @InstanceName AS nvarchar(128) = @@SERVERNAME + ,@DatabaseName AS nvarchar(128) = DB_NAME() + +SELECT + InstanceName = @InstanceName + ,DatabaseName = @DatabaseName + ,ObjectType = o.type_desc + ,SchemaName = s.name + ,ObjectName = o.name + ,ColumnID = c.column_id + ,ColumnName = c.name + ,SQLServerDataType = CASE + --Variable length fields + WHEN st.name IN('binary', 'char', 'text', 'varbinary', 'varchar') AND c.max_length > -1 THEN st.name + '(' + CONVERT(varchar(6), c.max_length) + ')' + --Unicode fields require twice the storage as standard variable length fields + WHEN st.name IN('nchar', 'ntext', 'nvarchar') AND c.max_length > -1 THEN st.name + '(' + CONVERT(varchar(6), c.max_length / 2) + ')' + --Scale based lengths for date and time fields + WHEN st.name IN('datetime2', 'datetimeoffset', 'time') THEN st.name + '(' + CONVERT(varchar(3), c.scale) + ')' + --Numeric fields with precision and scale + WHEN st.name IN('decimal', 'numeric') THEN st.name + '(' + CONVERT(varchar(3), c.precision) + ', ' + CONVERT(varchar(3), c.scale) + ')' + --Large Object types (LOB) + WHEN st.name NOT IN('geography', 'geometry', 'xml') AND c.max_length = -1 THEN st.name + '(MAX)' + --Everything else + ELSE st.name + END + ,CustomDataTypeName = CASE ut.name + WHEN st.name THEN '' + ELSE ut.name + END + ,Length = c.max_length + ,Precision = c.precision + ,Scale = c.scale + ,IsNullable = c.is_nullable + ,IsIdentity = c.is_identity + ,PrimaryKeyType = ISNULL + ( + ( + SELECT TOP (1) i.type_desc + FROM sys.indexes AS i + JOIN sys.index_columns AS ic + ON i.object_id = ic.object_id + AND i.index_id = ic.index_id + WHERE + ic.object_id = c.object_id + AND ic.column_id = c.column_id + AND i.is_primary_key = 1 + ) + ,'' + ) + ,ForeignKeySource = ISNULL + ( + ( + SELECT TOP (1) QUOTENAME(ss.name) + '.' + QUOTENAME(so.name) + '.' + QUOTENAME(c.name) + FROM sys.foreign_keys AS fk + JOIN sys.foreign_key_columns AS fkc + ON fk.object_id = fkc.constraint_object_id + JOIN sys.objects AS so + ON fkc.referenced_object_id = so.object_id + JOIN sys.schemas AS ss + ON so.schema_id = ss.schema_id + WHERE + fkc.parent_object_id = c.object_id + AND fkc.parent_column_id = c.column_id + ) + ,'' + ) + ,DependentForeignKeyCount = + ( + SELECT COUNT(*) + FROM sys.foreign_key_columns AS fkc + WHERE + c.object_id = fkc.referenced_object_id + AND c.column_id = fkc.referenced_column_id + ) + ,DefaultValue = ISNULL + ( + ( + SELECT TOP (1) dc.definition + FROM sys.default_constraints AS dc + WHERE + c.object_id = dc.parent_object_id + AND c.column_id = dc.parent_column_id + ) + ,'' + ) + ,UniqueConstraintName = ISNULL + ( + ( + SELECT TOP (1) i.name + FROM sys.indexes AS i + JOIN sys.index_columns AS ic + ON i.object_id = ic.object_id + AND i.index_id = ic.index_id + WHERE + ic.object_id = c.object_id + AND ic.column_id = c.column_id + AND i.is_unique_constraint = 1 + ) + ,'' + ) + ,CheckConstraintDefinition = ISNULL + ( + ( + SELECT TOP (1) dc.definition + FROM sys.check_constraints AS dc + WHERE + c.object_id = dc.parent_object_id + AND c.column_id = dc.parent_column_id + ) + ,'' + ) +FROM sys.schemas AS s +JOIN sys.objects AS o + ON s.schema_id = o.schema_id +JOIN sys.columns AS c + ON o.object_id = c.object_id +JOIN sys.types AS ut + ON c.user_type_id = ut.user_type_id +JOIN sys.types AS st + ON ut.system_type_id = st.user_type_id +WHERE + o.type_desc NOT IN('INTERNAL_TABLE', 'SYSTEM_TABLE') + AND s.name NOT IN('cdc', 'sys') + AND o.name NOT LIKE 'MSp%' + AND o.name NOT LIKE 'sys%' + AND o.name NOT LIKE 'SYNC_%' + +ORDER BY + CASE o.type_desc + WHEN 'USER_TABLE' THEN 1 + WHEN 'VIEW' THEN 2 + WHEN 'SQL_INLINE_TABLE_VALUED_FUNCTION' THEN 3 + WHEN 'SQL_TABLE_VALUED_FUNCTION' THEN 4 + ELSE 5 + END + ,s.name + ,o.name + ,c.column_id + +/*-------------------------------------------------------------------------------------------------- +END +*/-------------------------------------------------------------------------------------------------- diff --git a/Scripts/Database_Mail_Problems.sql b/Scripts/Database_Mail_Problems.sql new file mode 100644 index 00000000..98842d5a --- /dev/null +++ b/Scripts/Database_Mail_Problems.sql @@ -0,0 +1,90 @@ +/* +Author: Kenneth Fisher +Original link: https://sqlstudies.com/2013/07/29/notes-on-debugging-database-mail-problems/ +*/ + +USE msdb; +GO + +-- Check that the service broker is enabled on MSDB. +-- Is_broker_enabled must be 1 to use database mail. +SELECT is_broker_enabled FROM sys.databases WHERE name = 'msdb'; +-- Check that Database mail is turned on. +-- Run_value must be 1 to use database mail. +-- If you need to change it this option does not require +-- a server restart to take effect. +EXEC sp_configure 'show advanced options', 1; +GO +RECONFIGURE; +GO +EXEC sp_configure 'Database Mail XPs'; + +-- Check the Mail queues +-- This system stored procedure lists the two Database Mail queues. +-- The optional @queue_type parameter tells it to only list that queue. +-- The list contains the length of the queue (number of emails waiting), +-- the state of the queue (INACTIVE, NOTIFIED, RECEIVES_OCCURRING, the +-- last time the queue was empty and the last time the queue was active. +EXEC msdb.dbo.sysmail_help_queue_sp -- @queue_type = 'Mail' ; + +-- Check the status (STARTED or STOPPED) of the sysmail database queues +-- EXEC msdb.dbo.sysmail_start_sp -- Start the queue +-- EXEC msdb.dbo.sysmail_stop_sp -- Stop the queue +EXEC msdb.dbo.sysmail_help_status_sp; + +-- Check the different database mail settings. +-- These are system stored procedures that list the general +-- settings, accounts, profiles, links between the accounts +-- and profiles and the link between database principles and +-- database mail profiles. +-- These are generally controlled by the database mail wizard. + +EXEC msdb.dbo.sysmail_help_configure_sp; +EXEC msdb.dbo.sysmail_help_account_sp; +-- Check that your server name and server type are correct in the +-- account you are using. +-- Check that your email_address is correct in the account you are +-- using. +EXEC msdb.dbo.sysmail_help_profile_sp; +-- Check that you are using a valid profile in your dbmail command. +EXEC msdb.dbo.sysmail_help_profileaccount_sp; +-- Check that your account and profile are joined together +-- correctly in sysmail_help_profileaccount_sp. +EXEC msdb.dbo.sysmail_help_principalprofile_sp; + +-- Im doing a TOP 100 on these next several queries as they tend +-- to contain a great deal of data. Obviously if you need to get +-- more than 100 rows this can be changed. +-- Check the database mail event log. +-- Particularly for the event_type of "error". These are where you +-- will find the actual sending error. +SELECT TOP 100 * +FROM msdb.dbo.sysmail_event_log +ORDER BY last_mod_date DESC; + +-- Check the actual emails queued +-- Look at sent_status to see 'failed' or 'unsent' emails. +SELECT TOP 100 * +FROM msdb.dbo.sysmail_allitems +ORDER BY last_mod_date DESC; + +-- Check the emails that actually got sent. +-- This is a view on sysmail_allitems WHERE sent_status = 'sent' +SELECT TOP 100 * +FROM msdb.dbo.sysmail_sentitems +ORDER BY last_mod_date DESC; + +-- Check the emails that failed to be sent. +-- This is a view on sysmail_allitems WHERE sent_status = 'failed' +SELECT TOP 100 * +FROM msdb.dbo.sysmail_faileditems +ORDER BY last_mod_date DESC + +-- Clean out unsent emails +-- Usually I do this before releasing the queue again after fixing the problem. +-- Assuming of course that I don't want to send out potentially thousands of +-- emails that are who knows how old. +-- Obviously can be used to clean out emails of any status. +EXEC msdb.dbo.sysmail_delete_mailitems_sp + @sent_before = GETDATE() - 30, + @sent_status = 'unsent'; diff --git a/Scripts/Databases_Report.sql b/Scripts/Databases_Report.sql new file mode 100644 index 00000000..629890e4 --- /dev/null +++ b/Scripts/Databases_Report.sql @@ -0,0 +1,74 @@ +/* + + Get all databases meta data using dynamic T-SQL + 1 data set: temp table #DatabaseInfo. + No + Konstantin Taranov + 2018-03-01 + 2019-11-14 by Konstantin Taranov + 1.2 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Databases_Report.sql + +*/ + +SET NOCOUNT ON; + +DECLARE @tsql nvarchar(max); +DECLARE @crlf nvarchar(10) = NCHAR(13) + NCHAR(10); +DECLARE @debug bit = 0; + +IF OBJECT_ID('tempdb..#DatabaseInfo', 'U') IS NOT NULL DROP TABLE #DatabaseInfo; + +CREATE TABLE #DatabaseInfo( + DBName sysname NOT NULL + , TableCount int NOT NULL + , TableColumnsCount int NOT NULL + , ViewCount int NOT NULL + , ProcedureCount int NOT NULL + , TriggerCount int NOT NULL + , FullTextCatalog int NOT NULL + , XmlIndexes int NOT NULL + , SpatialIndexes int NOT NULL + , DataTotalSizeMb int NOT NULL + , DataSpaceUtilMb int NOT NULL + , LogTotalSizeMb int NOT NULL + , LogSpaceUtilMb int NOT NULL +); + +SELECT @tsql = COALESCE(@tsql, N'') + @crlf + + N'USE ' + QUOTENAME(name) + N';' + @crlf + + N'INSERT INTO #DatabaseInfo' + @crlf + + N'SELECT' + @crlf + + N' N' + QUOTENAME(name,'''') + N' AS DBName' + @crlf + + N' , (SELECT COUNT(*) AS TableCount FROM ' + QUOTENAME(name) + N'.sys.tables)' + @crlf + + N' , (SELECT ISNULL(SUM(max_column_id_used), 0) AS TableColumnsCount FROM ' + QUOTENAME(name) + N'.sys.tables)' + @crlf + + N' , (SELECT COUNT(*) AS ViewCount FROM ' + QUOTENAME(name) + N'.sys.views)' + @crlf + + N' , (SELECT COUNT(*) AS ProcedureCount FROM ' + QUOTENAME(name) + N'.sys.procedures)' + @crlf + + N' , (SELECT COUNT(*) AS TriggerCount FROM ' + QUOTENAME(name) + N'.sys.triggers)' + @crlf + + N' , (SELECT COUNT(*) AS FullTextCatalog FROM ' + QUOTENAME(name) + N'.sys.fulltext_catalogs)' + @crlf + + N' , (SELECT COUNT(*) AS XmlIndexes FROM ' + QUOTENAME(name) + N'.sys.xml_indexes)' + @crlf + + N' , (SELECT COUNT(*) AS SpatialIndexes FROM ' + QUOTENAME(name) + N'.sys.spatial_indexes)' + @crlf + + N' , (SELECT SUM(size * 8 / 1024) AS DataTotalSizeMb FROM ' + QUOTENAME(name) + N'.sys.master_files WHERE database_id = DB_ID(DB_NAME()) AND type = 0)' + @crlf + + N' , (SELECT SUM(FILEPROPERTY(name, ''SpaceUsed'') * 8 / 1024) AS DataSpaceUtilMb FROM ' + QUOTENAME(name) + N'.sys.master_files WHERE database_id = DB_ID(DB_NAME()) AND type = 0)' + @crlf + + N' , (SELECT SUM(size * 8 / 1024) AS LogTotalSizeMb FROM ' + QUOTENAME(name) + N'.sys.master_files WHERE database_id = DB_ID(DB_NAME()) AND type = 1)' + @crlf + + N' , (SELECT SUM(FILEPROPERTY(name, ''SpaceUsed'') * 8 / 1024) AS LogSpaceUtilMb FROM ' + QUOTENAME(name) + N'.sys.master_files WHERE database_id = DB_ID(DB_NAME()) AND type = 1);' + @crlf +FROM sys.databases +ORDER BY name; + +IF @debug = 1 SELECT @tsql ELSE EXEC sp_executesql @tsql; + +SELECT + DBName + , TableCount + , TableColumnsCount + , ViewCount + , ProcedureCount + , TriggerCount + , FullTextCatalog + , XmlIndexes + , SpatialIndexes + , DataTotalSizeMb + , DataSpaceUtilMb + , LogTotalSizeMb + , LogSpaceUtilMb +FROM #DatabaseInfo; diff --git a/Scripts/Date Calendar Cross-Reference Table.sql b/Scripts/Date Calendar Cross-Reference Table.sql deleted file mode 100644 index f1010c46..00000000 --- a/Scripts/Date Calendar Cross-Reference Table.sql +++ /dev/null @@ -1,527 +0,0 @@ -SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED -SET NOCOUNT ON -SET ANSI_WARNINGS OFF -SET ARITHABORT OFF -SET ARITHIGNORE ON -SET TEXTSIZE 2147483647 - - ------------------------------------------------------------------------------------------------------------------------------ --- Script Details: Listing Of Standard Details Related To The Script ------------------------------------------------------------------------------------------------------------------------------ - --- Purpose: Date Calendar Cross-Reference Table --- Create Date (MM/DD/YYYY): 10/29/2009 --- Developer: Sean Smith (s.smith.sql AT gmail DOT com) --- Additional Notes: N/A - - ------------------------------------------------------------------------------------------------------------------------------ --- Modification History: Listing Of All Modifications Since Original Implementation ------------------------------------------------------------------------------------------------------------------------------ - --- Description: Fixed Bug Affecting "month_weekdays_remaining" And "quarter_weekdays_remaining" Columns --- Date (MM/DD/YYYY): 07/02/2014 --- Developer: Sean Smith (s.smith.sql AT gmail DOT com) --- Additional Notes: N/A - - ------------------------------------------------------------------------------------------------------------------------------ --- Declarations / Sets: Declare And Set Variables ------------------------------------------------------------------------------------------------------------------------------ - -DECLARE - @Date_Start AS DATETIME - ,@Date_End AS DATETIME - - -SET @Date_Start = '20000101' - - -SET @Date_End = '20501231' - - ------------------------------------------------------------------------------------------------------------------------------ --- Error Trapping: Check If Permanent Table(s) Already Exist(s) And Drop If Applicable ------------------------------------------------------------------------------------------------------------------------------ - -IF OBJECT_ID (N'dbo.date_calendar', N'U') IS NOT NULL -BEGIN - - DROP TABLE dbo.date_calendar - -END - - ------------------------------------------------------------------------------------------------------------------------------ --- Permanent Table: Create Date Xref Table ------------------------------------------------------------------------------------------------------------------------------ - -CREATE TABLE dbo.date_calendar - - ( - calendar_date DATETIME NOT NULL CONSTRAINT PK_date_calendar_calendar_date PRIMARY KEY CLUSTERED - ,calendar_year SMALLINT NULL - ,calendar_month TINYINT NULL - ,calendar_day TINYINT NULL - ,calendar_quarter TINYINT NULL - ,first_day_in_week DATETIME NULL - ,last_day_in_week DATETIME NULL - ,is_week_in_same_month INT NULL - ,first_day_in_month DATETIME NULL - ,last_day_in_month DATETIME NULL - ,is_last_day_in_month INT NULL - ,first_day_in_quarter DATETIME NULL - ,last_day_in_quarter DATETIME NULL - ,is_last_day_in_quarter INT NULL - ,day_of_week TINYINT NULL - ,week_of_month TINYINT NULL - ,week_of_quarter TINYINT NULL - ,week_of_year TINYINT NULL - ,days_in_month TINYINT NULL - ,month_days_remaining TINYINT NULL - ,weekdays_in_month TINYINT NULL - ,month_weekdays_remaining TINYINT NULL - ,month_weekdays_completed TINYINT NULL - ,days_in_quarter TINYINT NULL - ,quarter_days_remaining TINYINT NULL - ,quarter_days_completed TINYINT NULL - ,weekdays_in_quarter TINYINT NULL - ,quarter_weekdays_remaining TINYINT NULL - ,quarter_weekdays_completed TINYINT NULL - ,day_of_year SMALLINT NULL - ,year_days_remaining SMALLINT NULL - ,is_weekday INT NULL - ,is_leap_year INT NULL - ,day_name VARCHAR (10) NULL - ,month_day_name_instance TINYINT NULL - ,quarter_day_name_instance TINYINT NULL - ,year_day_name_instance TINYINT NULL - ,month_name VARCHAR (10) NULL - ,year_week CHAR (6) NULL - ,year_month CHAR (6) NULL - ,year_quarter CHAR (6) NULL - ) - - ------------------------------------------------------------------------------------------------------------------------------ --- Table Insert: Populate Base Date Values Into Permanent Table Using Common Table Expression (CTE) ------------------------------------------------------------------------------------------------------------------------------ - -;WITH CTE_Date_Base_Table AS - - ( - SELECT - @Date_Start AS calendar_date - - UNION ALL - - SELECT - DATEADD (DAY, 1, cDBT.calendar_date) - FROM - CTE_Date_Base_Table cDBT - WHERE - DATEADD (DAY, 1, cDBT.calendar_date) <= @Date_End - ) - -INSERT INTO dbo.date_calendar - - ( - calendar_date - ) - -SELECT - cDBT.calendar_date -FROM - CTE_Date_Base_Table cDBT -OPTION - (MAXRECURSION 0) - - ------------------------------------------------------------------------------------------------------------------------------ --- Table Update I: Populate Additional Date Xref Table Fields (Pass I) ------------------------------------------------------------------------------------------------------------------------------ - -UPDATE - dbo.date_calendar -SET - calendar_year = DATEPART (YEAR, calendar_date) - ,calendar_month = DATEPART (MONTH, calendar_date) - ,calendar_day = DATEPART (DAY, calendar_date) - ,calendar_quarter = DATEPART (QUARTER, calendar_date) - ,first_day_in_week = DATEADD (DAY, -DATEPART (WEEKDAY, calendar_date) + 1, calendar_date) - ,first_day_in_month = CONVERT (VARCHAR (6), calendar_date, 112) + '01' - ,day_of_week = DATEPART (WEEKDAY, calendar_date) - ,week_of_year = DATEPART (WEEK, calendar_date) - ,day_of_year = DATEPART (DAYOFYEAR, calendar_date) - ,is_weekday = (CASE - WHEN ((@@DATEFIRST - 1) + (DATEPART (WEEKDAY, calendar_date) - 1)) % 7 NOT IN (5, 6) THEN 1 - ELSE 0 - END) - ,day_name = DATENAME (WEEKDAY, calendar_date) - ,month_name = DATENAME (MONTH, calendar_date) - - -ALTER TABLE dbo.date_calendar ALTER COLUMN calendar_year INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN calendar_month INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN calendar_day INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN calendar_quarter INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN first_day_in_week DATETIME NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN first_day_in_month DATETIME NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN day_of_week INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN week_of_year INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN day_of_year INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN is_weekday INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN day_name VARCHAR (10) NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN month_name VARCHAR (10) NOT NULL - - -CREATE NONCLUSTERED INDEX IX_date_calendar_calendar_year ON dbo.date_calendar (calendar_year) - - -CREATE NONCLUSTERED INDEX IX_date_calendar_calendar_month ON dbo.date_calendar (calendar_month) - - -CREATE NONCLUSTERED INDEX IX_date_calendar_calendar_quarter ON dbo.date_calendar (calendar_quarter) - - -CREATE NONCLUSTERED INDEX IX_date_calendar_first_day_in_week ON dbo.date_calendar (first_day_in_week) - - -CREATE NONCLUSTERED INDEX IX_date_calendar_day_of_week ON dbo.date_calendar (day_of_week) - - -CREATE NONCLUSTERED INDEX IX_date_calendar_is_weekday ON dbo.date_calendar (is_weekday) - - ------------------------------------------------------------------------------------------------------------------------------ --- Table Update II: Populate Additional Date Xref Table Fields (Pass II) ------------------------------------------------------------------------------------------------------------------------------ - -UPDATE - DC -SET - DC.last_day_in_week = DC.first_day_in_week + 6 - ,DC.last_day_in_month = DATEADD (MONTH, 1, DC.first_day_in_month) - 1 - ,DC.first_day_in_quarter = sqDC.first_day_in_quarter - ,DC.last_day_in_quarter = sqDC.last_day_in_quarter - ,DC.week_of_month = DATEDIFF (WEEK, DC.first_day_in_month, DC.calendar_date) + 1 - ,DC.week_of_quarter = (DC.week_of_year - sqDC.min_week_of_year_in_quarter) + 1 - ,DC.is_leap_year = (CASE - WHEN DC.calendar_year % 400 = 0 THEN 1 - WHEN DC.calendar_year % 100 = 0 THEN 0 - WHEN DC.calendar_year % 4 = 0 THEN 1 - ELSE 0 - END) - ,DC.year_week = CONVERT (VARCHAR (4), DC.calendar_year) + RIGHT ('0' + CONVERT (VARCHAR (2), DC.week_of_year), 2) - ,DC.year_month = CONVERT (VARCHAR (4), DC.calendar_year) + RIGHT ('0' + CONVERT (VARCHAR (2), DC.calendar_month), 2) - ,DC.year_quarter = CONVERT (VARCHAR (4), DC.calendar_year) + 'Q' + CONVERT (VARCHAR (1), DC.calendar_quarter) -FROM - dbo.date_calendar DC - INNER JOIN - - ( - SELECT - DC.calendar_year - ,DC.calendar_quarter - ,MIN (DC.calendar_date) AS first_day_in_quarter - ,MAX (DC.calendar_date) AS last_day_in_quarter - ,MIN (DC.week_of_year) AS min_week_of_year_in_quarter - FROM - dbo.date_calendar DC - GROUP BY - DC.calendar_year - ,DC.calendar_quarter - ) sqDC ON sqDC.calendar_year = DC.calendar_year AND sqDC.calendar_quarter = DC.calendar_quarter - - -ALTER TABLE dbo.date_calendar ALTER COLUMN last_day_in_week DATETIME NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN last_day_in_month DATETIME NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN first_day_in_quarter DATETIME NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN last_day_in_quarter DATETIME NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN week_of_month INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN week_of_quarter INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN is_leap_year INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN year_week VARCHAR (6) NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN year_month VARCHAR (6) NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN year_quarter VARCHAR (6) NOT NULL - - -CREATE NONCLUSTERED INDEX IX_date_calendar_last_day_in_week ON dbo.date_calendar (last_day_in_week) - - -CREATE NONCLUSTERED INDEX IX_date_calendar_year_month ON dbo.date_calendar (year_month) - - -CREATE NONCLUSTERED INDEX IX_date_calendar_year_quarter ON dbo.date_calendar (year_quarter) - - ------------------------------------------------------------------------------------------------------------------------------ --- Table Update III: Populate Additional Date Xref Table Fields (Pass III) ------------------------------------------------------------------------------------------------------------------------------ - -UPDATE - DC -SET - DC.is_last_day_in_month = (CASE - WHEN DC.last_day_in_month = DC.calendar_date THEN 1 - ELSE 0 - END) - ,DC.is_last_day_in_quarter = (CASE - WHEN DC.last_day_in_quarter = DC.calendar_date THEN 1 - ELSE 0 - END) - ,DC.days_in_month = DATEPART (DAY, DC.last_day_in_month) - ,DC.weekdays_in_month = sqDC1.weekdays_in_month - ,DC.days_in_quarter = DATEDIFF (DAY, DC.first_day_in_quarter, DC.last_day_in_quarter) + 1 - ,DC.quarter_days_remaining = DATEDIFF (DAY, DC.calendar_date, DC.last_day_in_quarter) - ,DC.weekdays_in_quarter = sqDC2.weekdays_in_quarter - ,DC.year_days_remaining = (365 + DC.is_leap_year) - DC.day_of_year -FROM - dbo.date_calendar DC - INNER JOIN - - ( - SELECT - DC.year_month - ,SUM (DC.is_weekday) AS weekdays_in_month - FROM - dbo.date_calendar DC - GROUP BY - DC.year_month - ) sqDC1 ON sqDC1.year_month = DC.year_month - - INNER JOIN - - ( - SELECT - DC.year_quarter - ,SUM (DC.is_weekday) AS weekdays_in_quarter - FROM - dbo.date_calendar DC - GROUP BY - DC.year_quarter - ) sqDC2 ON sqDC2.year_quarter = DC.year_quarter - - -ALTER TABLE dbo.date_calendar ALTER COLUMN is_last_day_in_month INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN is_last_day_in_quarter INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN days_in_month INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN weekdays_in_month INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN days_in_quarter INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN quarter_days_remaining INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN weekdays_in_quarter INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN year_days_remaining INT NOT NULL - - ------------------------------------------------------------------------------------------------------------------------------ --- Table Update IV: Populate Additional Date Xref Table Fields (Pass IV) ------------------------------------------------------------------------------------------------------------------------------ - -UPDATE - DC -SET - DC.month_weekdays_remaining = DC.weekdays_in_month - sqDC.month_weekdays_remaining_subtraction - ,DC.quarter_weekdays_remaining = DC.weekdays_in_quarter - sqDC.quarter_weekdays_remaining_subtraction -FROM - dbo.date_calendar DC - INNER JOIN - - ( - SELECT - DC.calendar_date - ,ROW_NUMBER () OVER - ( - PARTITION BY - DC.year_month - ORDER BY - DC.calendar_date - ) AS month_weekdays_remaining_subtraction - ,ROW_NUMBER () OVER - ( - PARTITION BY - DC.year_quarter - ORDER BY - DC.calendar_date - ) AS quarter_weekdays_remaining_subtraction - FROM - dbo.date_calendar DC - WHERE - DC.is_weekday = 1 - ) sqDC ON sqDC.calendar_date = DC.calendar_date - - ------------------------------------------------------------------------------------------------------------------------------ --- Table Update V: Populate Additional Date Xref Table Fields (Pass V) ------------------------------------------------------------------------------------------------------------------------------ - -UPDATE - DC -SET - DC.month_weekdays_remaining = (CASE - WHEN DC1.calendar_month = DC.calendar_month AND DC1.month_weekdays_remaining IS NOT NULL THEN DC1.month_weekdays_remaining - WHEN DC2.calendar_month = DC.calendar_month AND DC2.month_weekdays_remaining IS NOT NULL THEN DC2.month_weekdays_remaining - ELSE DC.weekdays_in_month - END) - ,DC.quarter_weekdays_remaining = (CASE - WHEN DC1.calendar_quarter = DC.calendar_quarter AND DC1.quarter_weekdays_remaining IS NOT NULL THEN DC1.quarter_weekdays_remaining - WHEN DC2.calendar_quarter = DC.calendar_quarter AND DC2.quarter_weekdays_remaining IS NOT NULL THEN DC2.quarter_weekdays_remaining - ELSE DC.weekdays_in_quarter - END) -FROM - dbo.date_calendar DC - LEFT JOIN dbo.date_calendar DC1 ON DATEADD (DAY, 1, DC1.calendar_date) = DC.calendar_date - LEFT JOIN dbo.date_calendar DC2 ON DATEADD (DAY, 2, DC2.calendar_date) = DC.calendar_date -WHERE - DC.month_weekdays_remaining IS NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN month_weekdays_remaining INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN quarter_weekdays_remaining INT NOT NULL - - ------------------------------------------------------------------------------------------------------------------------------ --- Table Update VI: Populate Additional Date Xref Table Fields (Pass VI) ------------------------------------------------------------------------------------------------------------------------------ - -UPDATE - DC -SET - DC.is_week_in_same_month = sqDC.is_week_in_same_month - ,DC.month_days_remaining = DC.days_in_month - DC.calendar_day - ,DC.month_weekdays_completed = DC.weekdays_in_month - DC.month_weekdays_remaining - ,DC.quarter_days_completed = DC.days_in_quarter - DC.quarter_days_remaining - ,DC.quarter_weekdays_completed = DC.weekdays_in_quarter - DC.quarter_weekdays_remaining - ,DC.month_day_name_instance = sqDC.month_day_name_instance - ,DC.quarter_day_name_instance = sqDC.quarter_day_name_instance - ,DC.year_day_name_instance = sqDC.year_day_name_instance -FROM - dbo.date_calendar DC - INNER JOIN - - ( - SELECT - DC.calendar_date - ,(CASE - WHEN DATEDIFF (MONTH, DC.first_day_in_week, DC.last_day_in_week) = 0 THEN 1 - ELSE 0 - END) AS is_week_in_same_month - ,ROW_NUMBER () OVER - ( - PARTITION BY - DC.year_month - ,DC.day_name - ORDER BY - DC.calendar_date - ) AS month_day_name_instance - ,ROW_NUMBER () OVER - ( - PARTITION BY - DC.year_quarter - ,DC.day_name - ORDER BY - DC.calendar_date - ) AS quarter_day_name_instance - ,ROW_NUMBER () OVER - ( - PARTITION BY - DC.calendar_year - ,DC.day_name - ORDER BY - DC.calendar_date - ) AS year_day_name_instance - FROM - dbo.date_calendar DC - ) sqDC ON sqDC.calendar_date = DC.calendar_date - - -ALTER TABLE dbo.date_calendar ALTER COLUMN is_week_in_same_month INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN month_days_remaining INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN month_weekdays_completed INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN quarter_days_completed INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN quarter_weekdays_completed INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN month_day_name_instance INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN quarter_day_name_instance INT NOT NULL - - -ALTER TABLE dbo.date_calendar ALTER COLUMN year_day_name_instance INT NOT NULL - - ------------------------------------------------------------------------------------------------------------------------------ --- Main Query: Final Display / Output ------------------------------------------------------------------------------------------------------------------------------ - -SELECT - DC.* -FROM - dbo.date_calendar DC -ORDER BY - DC.calendar_date diff --git a/Scripts/Date_Calendar_Cross-Reference_Table.sql b/Scripts/Date_Calendar_Cross-Reference_Table.sql new file mode 100644 index 00000000..77f17d4d --- /dev/null +++ b/Scripts/Date_Calendar_Cross-Reference_Table.sql @@ -0,0 +1,391 @@ +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SET NOCOUNT ON; +/* +.SYNOPSIS + Calendar Cross-Reference Table + +.DESCRIPTION + Listing Of Standard Details Related To The Script + +.LICENSE MIT +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +.NOTE + Author: Sean Smith (s.smith.sql AT gmail DOT com) + Created date: 2009-10-29 by Sean Smith + Version: 2.0 + Last Modified: 2018-08-28 17:35 UTC+3 by Konstantin Taranov + Main contributors: Sean Smith, Konstantin Taranov + Source: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Date_Calendar_Cross-Reference_Table.sql +*/ + + +----------------------------------------------------------------------------------------------------------------------------- +-- Error Trapping: Check If Permanent Table(s) Already Exist(s) And Drop If Applicable +----------------------------------------------------------------------------------------------------------------------------- +IF OBJECT_ID (N'dbo.date_calendar', N'U') IS NOT NULL +BEGIN + DROP TABLE dbo.date_calendar; +END; +GO + + +----------------------------------------------------------------------------------------------------------------------------- +-- Declarations / Sets: Declare And Set Variables +----------------------------------------------------------------------------------------------------------------------------- +SET DATEFIRST 1; /* https://docs.microsoft.com/en-us/sql/t-sql/statements/set-datefirst-transact-sql */ + +DECLARE @Date_Start AS DATE +DECLARE @Date_End AS DATE; + +SET @Date_Start = '20000101'; +SET @Date_End = '20501231'; + + +----------------------------------------------------------------------------------------------------------------------------- +-- Permanent Table: Create Date Xref Table +----------------------------------------------------------------------------------------------------------------------------- +CREATE TABLE dbo.date_calendar( + calendar_date DATE NOT NULL CONSTRAINT PK_date_calendar_calendar_date PRIMARY KEY CLUSTERED + , calendar_year SMALLINT NULL + , calendar_month TINYINT NULL + , calendar_day TINYINT NULL + , calendar_quarter TINYINT NULL + , first_day_in_week DATETIME NULL + , last_day_in_week DATETIME NULL + , is_week_in_same_month INT NULL + , first_day_in_month DATETIME NULL + , last_day_in_month DATETIME NULL + , is_last_day_in_month INT NULL + , first_day_in_quarter DATETIME NULL + , last_day_in_quarter DATETIME NULL + , is_last_day_in_quarter INT NULL + , day_of_week TINYINT NULL + , week_of_month TINYINT NULL + , week_of_quarter TINYINT NULL + , week_of_year TINYINT NULL + , days_in_month TINYINT NULL + , month_days_remaining TINYINT NULL + , weekdays_in_month TINYINT NULL + , month_weekdays_remaining TINYINT NULL + , month_weekdays_completed TINYINT NULL + , days_in_quarter TINYINT NULL + , quarter_days_remaining TINYINT NULL + , quarter_days_completed TINYINT NULL + , weekdays_in_quarter TINYINT NULL + , quarter_weekdays_remaining TINYINT NULL + , quarter_weekdays_completed TINYINT NULL + , day_of_year SMALLINT NULL + , year_days_remaining SMALLINT NULL + , is_weekday INT NULL + , is_leap_year INT NULL + , day_name VARCHAR (10) NULL + , month_day_name_instance TINYINT NULL + , quarter_day_name_instance TINYINT NULL + , year_day_name_instance TINYINT NULL + , month_name VARCHAR(10) NULL + , year_week CHAR(6) NULL + , year_month CHAR(6) NULL + , year_quarter CHAR(6) NULL + ) + + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Insert: Populate Base Date Values Into Permanent Table Using Common Table Expression (CTE) +----------------------------------------------------------------------------------------------------------------------------- +;WITH CTE_Date_Base_Table AS ( + SELECT + @Date_Start AS calendar_date + UNION ALL + SELECT + DATEADD (DAY, 1, cDBT.calendar_date) + FROM + CTE_Date_Base_Table cDBT + WHERE + DATEADD (DAY, 1, cDBT.calendar_date) <= @Date_End +) +INSERT INTO dbo.date_calendar(calendar_date) +SELECT + cDBT.calendar_date +FROM + CTE_Date_Base_Table cDBT +OPTION + (MAXRECURSION 0); + + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Update I: Populate Additional Date Xref Table Fields (Pass I) +----------------------------------------------------------------------------------------------------------------------------- +UPDATE dbo.date_calendar +SET + calendar_year = DATEPART (YEAR, calendar_date) + ,calendar_month = DATEPART (MONTH, calendar_date) + ,calendar_day = DATEPART (DAY, calendar_date) + ,calendar_quarter = DATEPART (QUARTER, calendar_date) + ,first_day_in_week = DATEADD (DAY, -DATEPART (WEEKDAY, calendar_date) + 1, calendar_date) + ,first_day_in_month = CONVERT (VARCHAR (6), calendar_date, 112) + '01' + ,day_of_week = DATEPART (WEEKDAY, calendar_date) + ,week_of_year = DATEPART (WEEK, calendar_date) + ,day_of_year = DATEPART (DAYOFYEAR, calendar_date) + ,is_weekday = (CASE + WHEN ((@@DATEFIRST - 1) + (DATEPART (WEEKDAY, calendar_date) - 1)) % 7 NOT IN (5, 6) THEN 1 + ELSE 0 + END) + ,day_name = DATENAME (WEEKDAY, calendar_date) + ,month_name = DATENAME (MONTH, calendar_date); + + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Update II: Populate Additional Date Xref Table Fields (Pass II) +----------------------------------------------------------------------------------------------------------------------------- +UPDATE DC +SET + DC.last_day_in_week = DC.first_day_in_week + 6 + ,DC.last_day_in_month = DATEADD (MONTH, 1, DC.first_day_in_month) - 1 + ,DC.first_day_in_quarter = sqDC.first_day_in_quarter + ,DC.last_day_in_quarter = sqDC.last_day_in_quarter + ,DC.week_of_month = DATEDIFF (WEEK, DC.first_day_in_month, DC.calendar_date) + 1 + ,DC.week_of_quarter = (DC.week_of_year - sqDC.min_week_of_year_in_quarter) + 1 + ,DC.is_leap_year = (CASE + WHEN DC.calendar_year % 400 = 0 THEN 1 + WHEN DC.calendar_year % 100 = 0 THEN 0 + WHEN DC.calendar_year % 4 = 0 THEN 1 + ELSE 0 + END) + ,DC.year_week = CONVERT (VARCHAR (4), DC.calendar_year) + RIGHT ('0' + CONVERT (VARCHAR (2), DC.week_of_year), 2) + ,DC.year_month = CONVERT (VARCHAR (4), DC.calendar_year) + RIGHT ('0' + CONVERT (VARCHAR (2), DC.calendar_month), 2) + ,DC.year_quarter = CONVERT (VARCHAR (4), DC.calendar_year) + 'Q' + CONVERT (VARCHAR (1), DC.calendar_quarter) +FROM + dbo.date_calendar DC + INNER JOIN + ( + SELECT + DC.calendar_year + ,DC.calendar_quarter + ,MIN (DC.calendar_date) AS first_day_in_quarter + ,MAX (DC.calendar_date) AS last_day_in_quarter + ,MIN (DC.week_of_year) AS min_week_of_year_in_quarter + FROM + dbo.date_calendar DC + GROUP BY + DC.calendar_year + ,DC.calendar_quarter + ) sqDC ON sqDC.calendar_year = DC.calendar_year AND sqDC.calendar_quarter = DC.calendar_quarter; + + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Update III: Populate Additional Date Xref Table Fields (Pass III) +----------------------------------------------------------------------------------------------------------------------------- +UPDATE DC +SET + DC.is_last_day_in_month = (CASE + WHEN DC.last_day_in_month = DC.calendar_date THEN 1 + ELSE 0 + END) + ,DC.is_last_day_in_quarter = (CASE + WHEN DC.last_day_in_quarter = DC.calendar_date THEN 1 + ELSE 0 + END) + ,DC.days_in_month = DATEPART (DAY, DC.last_day_in_month) + ,DC.weekdays_in_month = sqDC1.weekdays_in_month + ,DC.days_in_quarter = DATEDIFF (DAY, DC.first_day_in_quarter, DC.last_day_in_quarter) + 1 + ,DC.quarter_days_remaining = DATEDIFF (DAY, DC.calendar_date, DC.last_day_in_quarter) + ,DC.weekdays_in_quarter = sqDC2.weekdays_in_quarter + ,DC.year_days_remaining = (365 + DC.is_leap_year) - DC.day_of_year +FROM + dbo.date_calendar DC + INNER JOIN + + ( + SELECT + DC.year_month + ,SUM (DC.is_weekday) AS weekdays_in_month + FROM + dbo.date_calendar DC + GROUP BY + DC.year_month + ) sqDC1 ON sqDC1.year_month = DC.year_month + INNER JOIN + ( + SELECT + DC.year_quarter + ,SUM (DC.is_weekday) AS weekdays_in_quarter + FROM + dbo.date_calendar DC + GROUP BY + DC.year_quarter + ) sqDC2 ON sqDC2.year_quarter = DC.year_quarter; + +ALTER TABLE dbo.date_calendar ALTER COLUMN is_last_day_in_month INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN is_last_day_in_quarter INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN days_in_month INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN weekdays_in_month INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN days_in_quarter INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN quarter_days_remaining INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN weekdays_in_quarter INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN year_days_remaining INT NOT NULL; + + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Update IV: Populate Additional Date Xref Table Fields (Pass IV) +----------------------------------------------------------------------------------------------------------------------------- +UPDATE DC +SET + DC.month_weekdays_remaining = DC.weekdays_in_month - sqDC.month_weekdays_remaining_subtraction + ,DC.quarter_weekdays_remaining = DC.weekdays_in_quarter - sqDC.quarter_weekdays_remaining_subtraction +FROM + dbo.date_calendar DC + INNER JOIN + ( + SELECT + DC.calendar_date + ,ROW_NUMBER () OVER + ( + PARTITION BY + DC.year_month + ORDER BY + DC.calendar_date + ) AS month_weekdays_remaining_subtraction + ,ROW_NUMBER () OVER + ( + PARTITION BY + DC.year_quarter + ORDER BY + DC.calendar_date + ) AS quarter_weekdays_remaining_subtraction + FROM + dbo.date_calendar DC + WHERE + DC.is_weekday = 1 + ) sqDC ON sqDC.calendar_date = DC.calendar_date; + + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Update V: Populate Additional Date Xref Table Fields (Pass V) +----------------------------------------------------------------------------------------------------------------------------- +UPDATE DC +SET + DC.month_weekdays_remaining = (CASE + WHEN DC1.calendar_month = DC.calendar_month AND DC1.month_weekdays_remaining IS NOT NULL THEN DC1.month_weekdays_remaining + WHEN DC2.calendar_month = DC.calendar_month AND DC2.month_weekdays_remaining IS NOT NULL THEN DC2.month_weekdays_remaining + ELSE DC.weekdays_in_month + END) + ,DC.quarter_weekdays_remaining = (CASE + WHEN DC1.calendar_quarter = DC.calendar_quarter AND DC1.quarter_weekdays_remaining IS NOT NULL THEN DC1.quarter_weekdays_remaining + WHEN DC2.calendar_quarter = DC.calendar_quarter AND DC2.quarter_weekdays_remaining IS NOT NULL THEN DC2.quarter_weekdays_remaining + ELSE DC.weekdays_in_quarter + END) +FROM + dbo.date_calendar AS DC + LEFT JOIN dbo.date_calendar DC1 ON DATEADD (DAY, 1, DC1.calendar_date) = DC.calendar_date + LEFT JOIN dbo.date_calendar DC2 ON DATEADD (DAY, 2, DC2.calendar_date) = DC.calendar_date +WHERE + DC.month_weekdays_remaining IS NULL; + +ALTER TABLE dbo.date_calendar ALTER COLUMN month_weekdays_remaining INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN quarter_weekdays_remaining INT NOT NULL; + + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Update VI: Populate Additional Date Xref Table Fields (Pass VI) +----------------------------------------------------------------------------------------------------------------------------- +UPDATE DC +SET + DC.is_week_in_same_month = sqDC.is_week_in_same_month + ,DC.month_days_remaining = DC.days_in_month - DC.calendar_day + ,DC.month_weekdays_completed = DC.weekdays_in_month - DC.month_weekdays_remaining + ,DC.quarter_days_completed = DC.days_in_quarter - DC.quarter_days_remaining + ,DC.quarter_weekdays_completed = DC.weekdays_in_quarter - DC.quarter_weekdays_remaining + ,DC.month_day_name_instance = sqDC.month_day_name_instance + ,DC.quarter_day_name_instance = sqDC.quarter_day_name_instance + ,DC.year_day_name_instance = sqDC.year_day_name_instance +FROM + dbo.date_calendar DC + INNER JOIN + ( + SELECT + DC.calendar_date + ,(CASE + WHEN DATEDIFF (MONTH, DC.first_day_in_week, DC.last_day_in_week) = 0 THEN 1 + ELSE 0 + END) AS is_week_in_same_month + ,ROW_NUMBER () OVER + ( + PARTITION BY + DC.year_month + ,DC.day_name + ORDER BY + DC.calendar_date + ) AS month_day_name_instance + ,ROW_NUMBER () OVER + ( + PARTITION BY + DC.year_quarter + ,DC.day_name + ORDER BY + DC.calendar_date + ) AS quarter_day_name_instance + ,ROW_NUMBER () OVER + ( + PARTITION BY + DC.calendar_year + ,DC.day_name + ORDER BY + DC.calendar_date + ) AS year_day_name_instance + FROM + dbo.date_calendar DC + ) sqDC ON sqDC.calendar_date = DC.calendar_date; + + +ALTER TABLE dbo.date_calendar ALTER COLUMN calendar_year INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN calendar_month INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN calendar_day INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN calendar_quarter INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN first_day_in_week DATE NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN first_day_in_month DATE NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN day_of_week INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN week_of_year INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN day_of_year INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN is_weekday INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN day_name VARCHAR (10) NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN month_name VARCHAR (10) NOT NULL; +CREATE NONCLUSTERED INDEX IX_date_calendar_calendar_year ON dbo.date_calendar (calendar_year); +CREATE NONCLUSTERED INDEX IX_date_calendar_calendar_month ON dbo.date_calendar (calendar_month); +CREATE NONCLUSTERED INDEX IX_date_calendar_calendar_quarter ON dbo.date_calendar (calendar_quarter); +CREATE NONCLUSTERED INDEX IX_date_calendar_first_day_in_week ON dbo.date_calendar (first_day_in_week); +CREATE NONCLUSTERED INDEX IX_date_calendar_day_of_week ON dbo.date_calendar (day_of_week); +CREATE NONCLUSTERED INDEX IX_date_calendar_is_weekday ON dbo.date_calendar (is_weekday); +ALTER TABLE dbo.date_calendar ALTER COLUMN last_day_in_week DATE NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN last_day_in_month DATE NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN first_day_in_quarter DATE NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN last_day_in_quarter DATE NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN week_of_month INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN week_of_quarter INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN is_leap_year INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN year_week VARCHAR (6) NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN year_month VARCHAR (6) NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN year_quarter VARCHAR (6) NOT NULL; +CREATE NONCLUSTERED INDEX IX_date_calendar_last_day_in_week ON dbo.date_calendar (last_day_in_week); +CREATE NONCLUSTERED INDEX IX_date_calendar_year_month ON dbo.date_calendar (year_month); +CREATE NONCLUSTERED INDEX IX_date_calendar_year_quarter ON dbo.date_calendar (year_quarter); +ALTER TABLE dbo.date_calendar ALTER COLUMN is_week_in_same_month INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN month_days_remaining INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN month_weekdays_completed INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN quarter_days_completed INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN quarter_weekdays_completed INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN month_day_name_instance INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN quarter_day_name_instance INT NOT NULL; +ALTER TABLE dbo.date_calendar ALTER COLUMN year_day_name_instance INT NOT NULL; + + +----------------------------------------------------------------------------------------------------------------------------- +-- Main Query: Final Display / Output +----------------------------------------------------------------------------------------------------------------------------- +SELECT DC.* +FROM + dbo.date_calendar DC +ORDER BY + DC.calendar_date; diff --git a/Scripts/Delete_Login_And_All_Users.sql b/Scripts/Delete_Login_And_All_Users.sql new file mode 100644 index 00000000..a91f6887 --- /dev/null +++ b/Scripts/Delete_Login_And_All_Users.sql @@ -0,0 +1,134 @@ +/* + + Delete login and all its users. + Generate script for deleting login and associated users from SQL Server. + No + Max Vernon + 2019-01-31 + 2019-07-01 by Konstantin Taranov + 1.0 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Delete_Login_And_All_Users.sql + https://www.sqlserverscience.com/tools/delete-login-server-database/ + +*/ + +SET NOCOUNT ON; +DECLARE @DebugOnly bit = 1; --switch to 0 to actually drop the login and user(s); 1 displays the generated script. +DECLARE @cmd nvarchar(max); +DECLARE @ServerPrincipalName sysname; +DECLARE @DatabasePrincipalName sysname; + +SET @ServerPrincipalName = N'sa'; --the name of the LOGIN to be dropped from the SERVER. +SET @DatabasePrincipalName = N'DeleteMeUser'; --the name of the USER to be dropped from each DATABASE. + +SET @cmd = ''; + +SELECT @cmd = @cmd + CASE WHEN @cmd = N'' THEN N'' ELSE N' +UNION ALL +' END + N'SELECT ''' + d.name + N''' + , sp.name COLLATE SQL_Latin1_General_CP1_CI_AS + , dp.name COLLATE SQL_Latin1_General_CP1_CI_AS +FROM ' + QUOTENAME(d.name) + N'.sys.database_principals dp + LEFT JOIN master.sys.server_principals sp ON dp.sid = sp.sid +WHERE sp.name = ''' + @ServerPrincipalName + N''' + OR dp.name = ''' + @DatabasePrincipalName + N'''' +FROM sys.databases d +WHERE d.state_desc = N'ONLINE'; + +SET @cmd = @cmd + N';' + +DECLARE @Results TABLE +( + database_name SYSNAME NOT NULL + , server_principal_name SYSNAME NULL + , database_principal_name SYSNAME NULL + , PRIMARY KEY CLUSTERED (database_name) +); + +INSERT INTO @Results (database_name, server_principal_name, database_principal_name) +EXEC (@cmd); + +SET @cmd = N''; + +SELECT @cmd = @cmd + CASE WHEN @cmd = N'' THEN N'' ELSE N' +' END + N' USE ' + QUOTENAME(r.database_name) + N'; + PRINT (N''Dropping user ' + QUOTENAME(r.database_principal_name) + N' in ' + r.database_name + N'''); + + SET @msg = N''''; + + SELECT @msg = @msg + CASE WHEN @msg = N'''' THEN N'''' ELSE CHAR(13) + CHAR(11) END + N''User [' + @DatabasePrincipalName + N'] owns '' + o.type_desc + N'' '' + QUOTENAME(s.name) + N''.'' + QUOTENAME(o.name) + N'' and cannot be dropped'' + FROM sys.objects o + INNER JOIN sys.schemas s ON o.schema_id = s.schema_id + WHERE s.principal_id = (SELECT sp.principal_id FROM sys.database_principals sp WHERE sp.name = N''' + @DatabasePrincipalName + N''') + PRINT (@msg); + + IF @msg <> N'''' + BEGIN + SET @errCount = @errCount + 1; + END + ELSE + BEGIN + IF ( + SELECT (COUNT(1)) + FROM sys.schemas s + WHERE s.principal_id = (SELECT sp.principal_id FROM sys.database_principals sp WHERE sp.name = N''' + r.database_principal_name + N''') + ) > 0 + BEGIN + PRINT (N''User ' + r.database_principal_name + N' owns a schema and cannot be dropped''); + SET @errCount = @errCount + 1; + END + ELSE + BEGIN + DROP USER ' + QUOTENAME(r.database_principal_name) + '; + END; + END; +' +FROM @Results r; + +SET @cmd = N'SET NOCOUNT ON; +DECLARE @msg nvarchar(MAX); +DECLARE @errCount int; +SET @errCount = 0; +BEGIN TRY +' + CASE WHEN @cmd = N'' THEN N' PRINT (N''User ' + @DatabasePrincipalName + N' does not exist in any database.'');' ELSE @cmd END + N' +END TRY +BEGIN CATCH + PRINT (ERROR_MESSAGE()); + SET @errCount = @errCount + 1; +END CATCH + +IF @errCount = 0 +BEGIN +'; + +IF ( + SELECT COUNT(1) + FROM @Results r + WHERE r.server_principal_name IS NOT NULL + ) > 0 +BEGIN + SELECT TOP(1) @cmd = @cmd + N' USE master; + PRINT (N''Dropping LOGIN ' + QUOTENAME(r.database_principal_name) + N'''); + DROP LOGIN ' + QUOTENAME(r.server_principal_name) + N';' + FROM @Results r; +END +ELSE +BEGIN + SET @cmd = @cmd + N' PRINT (N''Login ' + @ServerPrincipalName + N' does not exist.'');'; +END + +SET @cmd = @cmd + N' +END +ELSE +BEGIN + PRINT (N''Errors occurred dropping users; login has NOT been dropped''); +END'; + +IF @DebugOnly = 1 +BEGIN + RAISERROR (@cmd, 0, 1); +END +ELSE +BEGIN + EXEC sys.sp_executesql @cmd; +END; diff --git a/Scripts/Disable_Enable_All_Triggers_In_Database.sql b/Scripts/Disable_Enable_All_Triggers_In_Database.sql new file mode 100644 index 00000000..5801e967 --- /dev/null +++ b/Scripts/Disable_Enable_All_Triggers_In_Database.sql @@ -0,0 +1,44 @@ +/* + + Disable and enable again all triggers in database + nothing. + No + Federico Minca + 2019-08-20 + 2019-08-26 by Konstantin Taranov + 1.0 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Disable_Enable_All_Triggers_In_Database.sql + https://jesspomfret.com/disable-all-triggers/ + +*/ + +-- Select Active Triggers and prepare Disable and Enable T-SQL Statement and put into Temp Table +SELECT 'ALTER TABLE [' + sc.name + '].[' + ta.name + '] DISABLE TRIGGER [' + tr.name + '];' AS DisableTriggerStatement, +'ALTER TABLE [' + sc.name + '].[' + ta.name + '] ENABLE TRIGGER [' + tr.name + '];' AS EnableTriggerStatement +INTO #Triggers +FROM sys.triggers tr +INNER JOIN sys.tables ta ON ta.object_id = tr.parent_id +INNER JOIN sys.schemas sc ON sc.schema_id = ta.schema_id +WHERE tr.is_disabled = 0; + +-- Prepare Variable Script for Execution +DECLARE @Disable_Statement nvarchar(max) = ( + SELECT tmp.DisableTriggerStatement + CHAR(10) AS "data()" + FROM #Triggers tmp + FOR XML PATH('') + ); + +-- Execute SQL +EXEC sys.sp_executesql @Disable_Statement; + +-- Prepare Variable Script for Execution +DECLARE @Enable_Statement nvarchar(max) = ( + SELECT tmp.EnableTriggerStatement + CHAR(10) AS data + FROM #Triggers tmp + FOR XML PATH('') + ); + +-- Execute SQL +EXEC sys.sp_executesql @Enable_Statement; + +DROP TABLE #Triggers; diff --git a/Scripts/Disabling_Jobs_Schedules.sql b/Scripts/Disabling_Jobs_Schedules.sql new file mode 100644 index 00000000..11a6bfca --- /dev/null +++ b/Scripts/Disabling_Jobs_Schedules.sql @@ -0,0 +1,220 @@ +/* + + Disabling Jobs Shedules. + None. + 2018-12-11 by Jon Shaulis + 2020-04-18 by Konstantin Taranov + 1.0 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Disabling_Jobs_Schedules.sql.sql + https://jonshaulis.com/index.php/2018/12/11/how-to-stop-the-sql-scheduler-with-t-sql/ + +*/ + + +USE MSDB; + +/************************************************************* + Checking for history table. Creating it if it doesn't exist. +*************************************************************/ + +IF OBJECT_ID('dbo.JobsEnabledTracker', 'U') IS NULL +BEGIN +CREATE TABLE [dbo].[JobsEnabledTracker]( +[Id] [INT] IDENTITY(1, 1) NOT NULL, +[job_id] [UNIQUEIDENTIFIER] NULL, +[schedule_id] [BIGINT] NULL, +[enabled] [BIT] NULL); +END; +IF EXISTS +( + SELECT + 1 + FROM [dbo].[JobsEnabledTracker] + WHERE [enabled] = 1 +) + OR +( + SELECT + COUNT(*) + FROM [dbo].[JobsEnabledTracker] +) = 0 + BEGIN + PRINT 'There are jobs enabled or there are no jobs yet populated in the history table.'; + +/*********************** + Clear out history table +***********************/ + + PRINT 'Truncating history table: dbo.JobsEnabledTracker'; + TRUNCATE TABLE [dbo].[JobsEnabledTracker]; + + PRINT 'Inserting records into history table: dbo.JobsEnabledTracker'; + +/****************************** + Add in values to history table +******************************/ + + INSERT INTO [dbo].[JobsEnabledTracker] + ( + [job_id], + [schedule_id], + [enabled] + ) + SELECT + [jss].[job_id], + [jss].[schedule_id], + 1 AS 'enabled' + FROM [msdb].[dbo].[sysschedules] AS [ss] + INNER JOIN [msdb].[dbo].[sysjobschedules] AS [jss] ON [jss].[schedule_id] = [ss].[schedule_id] + WHERE [ss].[enabled] = 1; + +/********************************************************************************** + Table variable to hold schedules and jobs enabled. This is important for the loop. +**********************************************************************************/ + + DECLARE @JobsEnabled TABLE + ([Id] INT + PRIMARY KEY IDENTITY(1, 1), + [job_id] UNIQUEIDENTIFIER, + [schedule_id] BIGINT, + [enabled] BIT + ); + +/***************************************** + Insert schedules that we need to disable. +*****************************************/ + + INSERT INTO @JobsEnabled + ( + [job_id], + [schedule_id], + [enabled] + ) + SELECT + [job_id], + [schedule_id], + [enabled] + FROM [dbo].[JobsEnabledTracker]; + +/******************************** + Holds the job id and schedule id +********************************/ + + DECLARE @jobid UNIQUEIDENTIFIER; + DECLARE @scheduleid BIGINT; + +/*********************************** + Holds the ID of the row in the loop +***********************************/ + + DECLARE @ID INT= 0; + +/********************** + Check if records exist +**********************/ + + IF EXISTS + ( + SELECT + [Id] + FROM @JobsEnabled + ) + BEGIN + PRINT 'Loop mode, jobs found enabled.'; + +/********** + Begin loop +**********/ + + WHILE(1 = 1) + BEGIN + +/*************************************** + Grab jobid, scheduleid, and id of rows. +***************************************/ + + SELECT + @jobid = + ( + SELECT TOP 1 + [job_id] + FROM @JobsEnabled + ORDER BY + [job_id] + ); + SELECT + @scheduleid = + ( + SELECT TOP 1 + [schedule_id] + FROM @JobsEnabled + ORDER BY + [job_id] + ); + SELECT + @ID = + ( + SELECT TOP 1 + [Id] + FROM @JobsEnabled + ORDER BY + [job_id] + ); + +/************************************ + Re-enable schedule associated to job +************************************/ + + PRINT 'Disabling schedule_id: '+CAST(@scheduleid AS VARCHAR(255))+' paired to job_id: '+CAST(@jobid AS VARCHAR(255)); + EXEC [sp_update_schedule] + @schedule_id = @scheduleid, + @enabled = 0; + +/********************* + Removes row from loop +*********************/ + + DELETE FROM @JobsEnabled + WHERE + [Id] = @ID; + + UPDATE [dbo].[JobsEnabledTracker] + SET + [enabled] = 0 + WHERE + [job_id] = @jobid + AND [schedule_id] = @scheduleid; + +/**************************** + No more rows, stops deleting +****************************/ + + IF + ( + SELECT + COUNT(*) + FROM @JobsEnabled + ) <= 0 + BEGIN + BREAK + END; + +/******** + End Loop +********/ + END; + PRINT 'Exiting loop, disabling schedules paired to jobs complete.'; + +/********** + End elseif +**********/ + END; + ELSE + BEGIN + PRINT 'All done'; + END; + END; + ELSE + BEGIN + PRINT 'YOU HAVE JOBS STILL DISABLED, EXITING SCRIPT. PLEASE RUN SCRIPT TWO FIRST.'; + END; diff --git a/Scripts/Dynamic_GRANT_Generation.sql b/Scripts/Dynamic_GRANT_Generation.sql new file mode 100644 index 00000000..18277484 --- /dev/null +++ b/Scripts/Dynamic_GRANT_Generation.sql @@ -0,0 +1,35 @@ +/* + + Dynamically generate GRANTs. + PRINT dynamically generated GRANTs for user. + ? + 2020-02-08 by Konstantin Taranov + 1.0 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Dynamic_GRANT_Generation.sql + +*/ + + +SET NOCOUNT ON; +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; + +DECLARE @userName sysname = QUOTENAME(N'user_name'); +DECLARE @tsql nvarchar(max) = N''; + +SELECT @tsql = @tsql + 'GRANT SELECT, INSERT, UPDATE, DELETE ON ' + + QUOTENAME(SCHEMA_NAME("schema_id")) + N'.' + + QUOTENAME("name") + N' TO ' + @userName + N';' + CHAR(13) + CHAR(10) +FROM sys.tables +/* +WHERE "name" NOT IN ('') +--*/ +; + +IF LEN(@tsql) <= 8000 +BEGIN + PRINT(@tsql); +END; +ELSE +BEGIN + SELECT @tsql; +END; diff --git a/Scripts/Enabling_Jobs_Schedules.sql b/Scripts/Enabling_Jobs_Schedules.sql new file mode 100644 index 00000000..05032972 --- /dev/null +++ b/Scripts/Enabling_Jobs_Schedules.sql @@ -0,0 +1,167 @@ +/* + + Enabling Jobs Shedules. + None. + 2018-12-11 by Jon Shaulis + 2020-04-19 by Konstantin Taranov + 1.0 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Enabling_Jobs_Schedules.sql.sql + https://jonshaulis.com/index.php/2018/12/11/how-to-stop-the-sql-scheduler-with-t-sql/ + +*/ + + +USE MSDB; +GO + +/******************************************************************************* + Check for history table. This physical table tells us what jobs we are going to + enable the scheduler for. +*******************************************************************************/ + +IF OBJECT_ID('dbo.JobsEnabledTracker', 'U') IS NOT NULL +BEGIN + IF EXISTS + ( + SELECT 1 + FROM [dbo].[JobsEnabledTracker] + WHERE [enabled] = 0 + ) + BEGIN + PRINT 'Jobs disabled in history table: dbo.JobsEnabledTracker found.'; + +/********************************************************************************** + Table variable to hold schedules and jobs enabled. This is important for the loop. +**********************************************************************************/ + + DECLARE @JobsEnabled TABLE + ( + [Id] int PRIMARY KEY IDENTITY(1, 1) + , [job_id] uniqueidentifier + , [schedule_id] bigint + , [enabled] bit + ); + +/******************************************************************************* + Insert schedules that we had disabled that we need to go back in and re-enable. +*******************************************************************************/ + + INSERT INTO @JobsEnabled( [job_id], [schedule_id], [enabled] ) + SELECT [job_id], [schedule_id], [enabled] + FROM [dbo].[JobsEnabledTracker]; + +/******************************** + Holds the job id and schedule id +********************************/ + + DECLARE @jobid uniqueidentifier; + DECLARE @scheduleid bigint; + +/*********************************** + Holds the ID of the row in the loop +***********************************/ + + DECLARE @ID int= 0; + +/********************** + Check if records exist +**********************/ + + IF EXISTS + ( + SELECT [Id] + FROM @JobsEnabled + ) + BEGIN + PRINT 'Loop mode, jobs found disabled.'; + +/********** + Begin loop +**********/ + + WHILE 1 = 1 + BEGIN + +/*************************************** + Grab jobid, scheduleid, and id of rows. +***************************************/ + + SELECT @jobid = + ( + SELECT TOP 1 [job_id] + FROM @JobsEnabled + ORDER BY [job_id] + ); + SELECT @scheduleid = + ( + SELECT TOP 1 [schedule_id] + FROM @JobsEnabled + ORDER BY [job_id] + ); + SELECT @ID = + ( + SELECT TOP 1 [Id] + FROM @JobsEnabled + ORDER BY [job_id] + ); + +/*************************************** + Re-enable schedule associated to job +***************************************/ + + PRINT 'Enabling schedule_id: '+CAST(@scheduleid AS varchar(255))+' paired to job_id: '+CAST(@jobid AS varchar(255)); + EXEC [sp_update_schedule] @schedule_id = @scheduleid, @enabled = 1; + +/********************* + Removes row from loop +*********************/ + + DELETE FROM @JobsEnabled + WHERE [Id] = @ID; + +/*********************** + Set job back to enabled +***********************/ + + UPDATE [dbo].[JobsEnabledTracker] + SET [enabled] = 1 + WHERE [job_id] = @jobid AND + [schedule_id] = @scheduleid; + +/**************************** + No more rows, stops deleting +****************************/ + + IF + ( + SELECT COUNT(*) + FROM @JobsEnabled + ) <= 0 + BEGIN + BREAK; + END; + +/******** + End Loop +********/ + END; + PRINT 'Exiting loop, enabling schedules paired to jobs complete.'; + +/********** + End elseif +**********/ + END; + ELSE + BEGIN + PRINT 'All done'; + END; + END; + ELSE + BEGIN + PRINT 'dbo.JobsEnabledTracker has no disabled jobs currently.'; + END; +END; +ELSE +BEGIN + PRINT 'dbo.JobsEnabledTracker is NULL, you may need to run the first script to create and populate this table.'; +END; diff --git a/Scripts/Extract_Scale_Part_From_Decimal_Number.sql b/Scripts/Extract_Scale_Part_From_Decimal_Number.sql new file mode 100644 index 00000000..ad5c3915 --- /dev/null +++ b/Scripts/Extract_Scale_Part_From_Decimal_Number.sql @@ -0,0 +1,22 @@ +/* +Author: Pinal Dave +Created Date: 2018-09-12 +Original link: https://blog.sqlauthority.com/2018/09/12/sql-server-simple-method-to-extract-scale-part-from-decimal-number/ +Source link: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Extract_Scale_Part_From_Decimal_Number.sql +Modified: 2018-01-29 by Konstantin Taranov +*/ + +IF OBJECT_ID(N'tempdb..#Numbers', 'U') IS NOT NULL DROP TABLE #Numbers; + +CREATE TABLE #Numbers (DecimalValue DECIMAL(16, 10) NOT NULL); + +INSERT INTO #Numbers(DecimalValue) VALUES (100.0000000001); +INSERT INTO #Numbers(DecimalValue) VALUES (-23.8900000098); +INSERT INTO #Numbers(DecimalValue) VALUES (390.077); +INSERT INTO #Numbers(DecimalValue) VALUES (12.87); +INSERT INTO #Numbers(DecimalValue) VALUES (390.1); + +SELECT DecimalValue + , ABS(DecimalValue)%1 AS DecimalScale + FROM #Numbers; + GO diff --git a/Scripts/Failed_SQL_Server_Agent_Jobs_With_Restart_Command.sql b/Scripts/Failed_SQL_Server_Agent_Jobs_With_Restart_Command.sql new file mode 100644 index 00000000..9282773e --- /dev/null +++ b/Scripts/Failed_SQL_Server_Agent_Jobs_With_Restart_Command.sql @@ -0,0 +1,33 @@ +/* +Author: Max Vernon +Created Date: 2019-02-05 +Original link: https://blog.sqlauthority.com/2018/09/12/sql-server-simple-method-to-extract-scale-part-from-decimal-number/ +Source link: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Failed_SQL_Server_Agent_Jobs_With_Restart_Command.sql +Modified: 2019-02-11 by Konstantin Taranov +*/ + +WITH sys_job_history AS +( + SELECT * + , rn = ROW_NUMBER() OVER (PARTITION BY sjh.job_id ORDER BY msdb.dbo.agent_datetime(sjh.run_date, sjh.run_time) DESC) + FROM msdb.dbo.sysjobhistory sjh + WHERE sjh.step_id > 0 + AND sjh.run_date > CONVERT(int, CONVERT(varchar(8), DATEADD(DAY, -1, GETDATE()), 112)) +) +SELECT sj.name + , sjh.step_name + , sjh.step_id + , sjh.sql_message_id + , sjh.sql_severity + , sjh.message + , sjh.server + , RunDateTime = msdb.dbo.agent_datetime(sjh.run_date, sjh.run_time) + , StartJobCommand = N'EXEC msdb.dbo.sp_start_job @job_name = ''' + sj.name + N''', @step_name = ''' + sjh.step_name + N''';' +FROM sys_job_history sjh + INNER JOIN msdb.dbo.sysjobs sj ON sjh.job_id = sj.job_id + INNER JOIN msdb.dbo.sysjobschedules sjsch ON sj.job_id = sjsch.job_id + INNER JOIN msdb.dbo.sysschedules ss ON sjsch.schedule_id = ss.schedule_id +WHERE sjh.rn = 1 + AND sjh.run_status = 0 --failed + AND ss.enabled = 1 +ORDER BY sj.name; diff --git a/Scripts/Fast_alternative_to_sp_WhoIsActive.sql b/Scripts/Fast_alternative_to_sp_WhoIsActive.sql new file mode 100644 index 00000000..ddc877e5 --- /dev/null +++ b/Scripts/Fast_alternative_to_sp_WhoIsActive.sql @@ -0,0 +1,28 @@ +/* +Author: Arthur Daniels +Created Date: 2019-01-29 +Original link: https://blog.sqlauthority.com/2018/09/12/sql-server-simple-method-to-extract-scale-part-from-decimal-number/ +Source link: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Fast_alternative_to_sp_WhoIsActive.sql +Modified: 2018-01-29 by Konstantin Taranov +*/ + +SELECT s.session_id, + r.start_time, + s.host_name, + s.login_name, + i.event_info, + r.status, + s.program_name, + r.writes, + r.reads, + r.logical_reads, + r.blocking_session_id, + r.wait_type, + r.wait_time, + r.wait_resource +FROM sys.dm_exec_requests AS r + INNER JOIN sys.dm_exec_sessions AS s ON s.session_id = r.session_id +CROSS APPLY sys.dm_exec_input_buffer(s.session_id, r.request_id) as i +WHERE s.session_id <> @@SPID AND + s.is_user_process = 1; +--Remove the line above if you want to see system processes diff --git a/Scripts/Find_Foreign_Key_Chains_For_Tables.sql b/Scripts/Find_Foreign_Key_Chains_For_Tables.sql new file mode 100644 index 00000000..4efe3b70 --- /dev/null +++ b/Scripts/Find_Foreign_Key_Chains_For_Tables.sql @@ -0,0 +1,81 @@ +/* + + Find Foreign Key Chains For Tables + nothing. + No + Konstantin Taranov + 2019-08-20 + 2019-08-24 by Konstantin Taranov + 1.0 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Find_Foreign_Key_Chains_For_Tables.sql + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Find_Foreign_Key_Chains_For_Tables.sql + +*/ + +WITH fk_tables AS + (SELECT s1.name AS from_schema + , o1.name AS from_table + , s2.name AS to_schema + , o2.name AS to_table + FROM sys.foreign_keys AS fk + INNER JOIN sys.objects AS o1 ON fk.parent_object_id = o1.object_id + INNER JOIN sys.schemas AS s1 ON o1.schema_id = s1.schema_id + INNER JOIN sys.objects AS o2 ON fk.referenced_object_id = o2.object_id + INNER JOIN sys.schemas AS s2 ON o2.schema_id = s2.schema_id + INNER JOIN (SELECT object_id, SUM(row_count) AS row_count + FROM sys.dm_db_partition_stats + WHERE index_id < 2 + GROUP BY object_id + ) AS rc ON o1.object_id = rc.object_id + /* For the purposes of finding dependency hierarchy + we're not worried about self-referencing tables */ + WHERE NOT + (s1.name = s2.name + AND o1.name = o2.name + ) + ) + , ordered_tables AS + (SELECT s.name AS SchemaName + , t.name AS TableName + , 0 AS TableLevel + FROM (SELECT name, schema_id FROM sys.tables) AS t + INNER JOIN sys.schemas AS s ON t.schema_id = s.schema_id + LEFT OUTER JOIN fk_tables AS fk ON s.name = fk.from_schema AND t.name = fk.from_table + WHERE fk.from_schema IS NULL + UNION ALL + SELECT fk.from_schema + , fk.from_table + , ot.TableLevel + 1 + FROM fk_tables AS fk + INNER JOIN ordered_tables ot ON fk.to_schema = ot.SchemaName AND fk.to_table = ot.TableName + ) + , final AS + (SELECT DISTINCT ot.SchemaName + , ot.TableName + , ot.TableLevel + FROM ordered_tables ot + INNER JOIN + (SELECT SchemaName + , TableName + , MAX(TableLevel) maxTableLevel + FROM ordered_tables + GROUP BY SchemaName + , TableName + ) mx ON ot.SchemaName = mx.SchemaName AND ot.TableName = mx.TableName AND mx.maxTableLevel = ot.TableLevel + ) +SELECT QUOTENAME(final.SchemaName) + '.' + QUOTENAME(final.TableName) AS TableName + , TableLevel +FROM final +WHERE( + /* exclude some schemes by IN */ + final.SchemaName NOT IN ('dbo') + /* exclude some tables by IN */ + AND final.TableName NOT IN ('Tep1') + /* exclude some tables by mask */ + AND final.TableName NOT LIKE '%Temp' + ) + /* add some tables by mask and with IN */ + OR final.TableName IN ('IPAdmin') + OR final.TableName LIKE 'AspNet%' + OR final.TableName LIKE 'Application%' +ORDER BY TableLevel; diff --git a/Scripts/Find_Maximum_Float_Values.sql b/Scripts/Find_Maximum_Float_Values.sql new file mode 100644 index 00000000..3b2473e4 --- /dev/null +++ b/Scripts/Find_Maximum_Float_Values.sql @@ -0,0 +1,47 @@ +/* +https://docs.microsoft.com/en-us/sql/t-sql/data-types/float-and-real-transact-sql +*/ + +SELECT CAST(-2.22999999999999E-308 AS float(53)) AS "Float(53) Negative Max" + , CAST(-1.797693134862315807E+308 AS float(53)) AS "Float(53) Negative Min" + , CAST(+1.797693134862315807E+308 AS float(53)) AS "Float(53) Positive Max"; + + +SET NOCOUNT ON; + +DROP TABLE IF EXISTS t; +CREATE TABLE t ( + i int IDENTITY(1, 1) NOT NULL + , f float(53) NOT NULL + , s varchar(100) NOT NULL +); +GO + +DECLARE @s varchar(100) = '+1.79'; /* +1.79 -2.22*/ +DECLARE @i int = 1; +DECLARE @j int = 9; + +WHILE (@i < 200 AND LEN(@s) < 22) +BEGIN + BEGIN TRY + SET @i = @i + 1; + + INSERT INTO t(f, s) SELECT CAST((@s + CAST(@j AS varchar) + 'E' + LEFT(@s, 1) + '308') AS float(53)), @s AS s; + SET @s = (@s + CAST(@j AS varchar)); + SET @j = 9; + END TRY + + BEGIN CATCH + SELECT ERROR_NUMBER() AS ErrorNumber + ,ERROR_SEVERITY() AS ErrorSeverity + ,ERROR_STATE() AS ErrorState + ,ERROR_PROCEDURE() AS ErrorProcedure + ,ERROR_LINE() AS ErrorLine + ,ERROR_MESSAGE() AS ErrorMessage; + SET @j = @j - 1; + END CATCH +END; + +SELECT i, f, s +FROM t +WHERE f = (SELECT MAX(f) AS FLOAT_MAX FROM t); diff --git a/Scripts/Find_Not_Used_Legacy_Tables.sql b/Scripts/Find_Not_Used_Legacy_Tables.sql new file mode 100644 index 00000000..f6e3b960 --- /dev/null +++ b/Scripts/Find_Not_Used_Legacy_Tables.sql @@ -0,0 +1,71 @@ +/* +Created: 2019-03-12 by Michael J. Swart +Modified: 2019-03-19 by Konstantin Taranov +Original Link: http://michaeljswart.com/2019/03/lonely-tables-in-sql-server/ +Source link: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Find_Not_Used_Legacy_Tables.sql +*/ + +/* USE [your db name here]; */ + + +IF OBJECT_ID(N'tempdb..#myplans', 'U') IS NOT NULL DROP TABLE #myplans; +IF OBJECT_ID(N'tempdb..#myExecutions', 'U') IS NOT NULL DROP TABLE #myExecutions; + +SELECT qs.query_hash, + qs.plan_handle, + cast(null AS xml) AS query_plan + INTO #myplans + FROM sys.dm_exec_query_stats qs + CROSS APPLY sys.dm_exec_plan_attributes(qs.plan_handle) pa + WHERE pa.attribute = 'dbid' + AND pa.value = DB_ID(); + +WITH duplicate_queries AS ( + SELECT ROW_NUMBER() OVER (PARTITION BY query_hash ORDER BY (SELECT 1)) AS n + FROM #myplans +) +DELETE duplicate_queries + WHERE n > 1; + +UPDATE #myplans + SET query_plan = qp.query_plan + FROM #myplans AS mp + CROSS APPLY sys.dm_exec_query_plan(mp.plan_handle) AS qp; + +WITH XMLNAMESPACES (DEFAULT 'http://schemas.microsoft.com/sqlserver/2004/07/showplan'), +my_cte AS ( + SELECT q.query_hash, + obj.value('(@Schema)[1]', 'sysname') AS [schema_name], + obj.value('(@Table)[1]', 'sysname') AS table_name + FROM #myplans q + CROSS APPLY q.query_plan.nodes('/ShowPlanXML/BatchSequence/Batch/Statements/StmtSimple') as nodes(stmt) + CROSS APPLY stmt.nodes('.//IndexScan/Object') AS index_object(obj) +) +SELECT query_hash, [schema_name], table_name + INTO #myExecutions + FROM my_cte + WHERE [schema_name] IS NOT NULL + AND OBJECT_ID([schema_name] + '.' + table_name) IN (SELECT [object_id] FROM sys.tables) + GROUP BY query_hash, [schema_name], table_name; + +WITH multi_table_queries AS ( + SELECT query_hash + FROM #myExecutions + GROUP BY query_hash + HAVING COUNT(*) > 1 +), +lonely_tables AS ( + SELECT [schema_name], table_name + FROM #myExecutions + EXCEPT + SELECT [schema_name], table_name + FROM #myExecutions WHERE query_hash IN (SELECT query_hash FROM multi_table_queries) +) +SELECT l.[schema_name] + , l.table_name + , ps.row_count + FROM lonely_tables AS l + LEFT JOIN sys.dm_db_partition_stats AS ps + ON OBJECT_ID(l.[schema_name] + '.' + l.table_name) = ps.object_id + WHERE ps.index_id in (0, 1) + ORDER BY ps.row_count DESC; diff --git a/Scripts/Find_Object_Dependecy.sql b/Scripts/Find_Object_Dependecy.sql new file mode 100644 index 00000000..ac65c0f0 --- /dev/null +++ b/Scripts/Find_Object_Dependecy.sql @@ -0,0 +1,2558 @@ + /* +Author: Konstantin Taranov +Source: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Find_Object_Dependecy.sql +*/ +DECLARE @objectName SYSNAME = 'ObjectName'; +DECLARE @schemaName SYSNAME = 'SchemaName'; + +IF Object_id('tempdb..#tempdep', 'U') IS NOT NULL + DROP TABLE #tempdep; + +IF Object_id('tempdb..#t1', 'U') IS NOT NULL + DROP TABLE #t1; + +IF Object_id('tempdb..#t2', 'U') IS NOT NULL + DROP TABLE #t2; + +CREATE TABLE #tempdep + ( + objid INT NOT NULL + ,objname SYSNAME NOT NULL + ,objschema SYSNAME NULL + ,objdb SYSNAME NOT NULL + ,objtype SMALLINT NOT NULL + ); + +EXEC sp_executesql + N'INSERT INTO #tempdep + SELECT tbl.object_id AS [ID], tbl.name AS [Name], SCHEMA_NAME(tbl.schema_id) AS [Schema], db_name(), 3 + FROM sys.tables AS tbl + WHERE (tbl.name=@_msparam_0 and SCHEMA_NAME(tbl.schema_id)=@_msparam_1)', + N'@_msparam_0 nvarchar(4000),@_msparam_1 nvarchar(4000)', + @_msparam_0=@objectName, + @_msparam_1=@schemaName; + +DECLARE @find_referencing_objects INT; + +SET @find_referencing_objects = 1; + +-- parameters: +-- 1. create table #tempdep (objid int NOT NULL, objtype smallint NOT NULL) +-- contains source objects +-- 2. @find_referencing_objects defines ordering +-- 1 order for drop +-- 0 order for script +DECLARE @must_set_nocount_off BIT; + +SET @must_set_nocount_off = 0; + +IF @@OPTIONS & 512 = 0 + SET @must_set_nocount_off = 1; + +SET nocount ON; + +DECLARE @u INT; +DECLARE @udf INT; +DECLARE @v INT; +DECLARE @sp INT; +DECLARE @def INT; +DECLARE @rule INT; +DECLARE @tr INT; +DECLARE @uda INT; +DECLARE @uddt INT; +DECLARE @xml INT; +DECLARE @udt INT; +DECLARE @assm INT; +DECLARE @part_sch INT; +DECLARE @part_func INT; +DECLARE @synonym INT; +DECLARE @sequence INT; +DECLARE @udtt INT; +DECLARE @ddltr INT; +DECLARE @unknown INT; +DECLARE @pg INT; + +SET @u = 3; +SET @udf = 0; +SET @v = 2; +SET @sp = 4; +SET @def = 6; +SET @rule = 7; +SET @tr = 8; +SET @uda = 11; +SET @synonym = 12; +SET @sequence = 13; +-- above 100 -> not in sys.objects +SET @uddt = 101; +SET @xml = 102; +SET @udt = 103; +SET @assm = 1000; +SET @part_sch = 201; +SET @part_func = 202; +SET @udtt = 104; +SET @ddltr = 203; +SET @unknown = 1001; +SET @pg = 204; + +-- variables for referenced type obtained from sys.sql_expression_dependencies +DECLARE @obj INT; + +SET @obj = 20; + +DECLARE @type INT; + +SET @type = 21; + +-- variables for xml and part_func are already there +CREATE TABLE #t1 + ( + object_id INT NULL + ,object_name SYSNAME COLLATE database_default NULL + ,object_schema SYSNAME COLLATE database_default NULL + ,object_db SYSNAME NULL + ,object_svr SYSNAME NULL + ,object_type SMALLINT NOT NULL + ,relative_id INT NOT NULL + ,relative_name SYSNAME COLLATE database_default NOT NULL + ,relative_schema SYSNAME COLLATE database_default NULL + ,relative_db SYSNAME NULL + ,relative_svr SYSNAME NULL + ,relative_type SMALLINT NOT NULL + ,schema_bound BIT NOT NULL + ,rank SMALLINT NULL + ,degree INT NULL + ); + +-- we need to create another temporary table to store the dependencies from sys.sql_expression_dependencies till the updated values are inserted finally into #t1 +CREATE TABLE #t2 + ( + object_id INT NULL + ,object_name SYSNAME COLLATE database_default NULL + ,object_schema SYSNAME COLLATE database_default NULL + ,object_db SYSNAME NULL + ,object_svr SYSNAME NULL + ,object_type SMALLINT NOT NULL + ,relative_id INT NOT NULL + ,relative_name SYSNAME COLLATE database_default NOT NULL + ,relative_schema SYSNAME COLLATE database_default NULL + ,relative_db SYSNAME NULL + ,relative_svr SYSNAME NULL + ,relative_type SMALLINT NOT NULL + ,schema_bound BIT NOT NULL + ,rank SMALLINT NULL + ); + +-- This index will ensure that we have unique parent-child relationship +CREATE UNIQUE CLUSTERED INDEX i1 + ON #t1(object_name, object_schema, object_db, object_svr, object_type, relative_name, relative_schema, relative_type) + WITH ignore_dup_key; + +DECLARE @iter_no INT; +SET @iter_no = 1; + +DECLARE @rows INT; +SET @rows = 1; + +INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) +SELECT l.objid + ,l.objname + ,l.objschema + ,l.objdb + ,l.objtype + ,l.objid + ,l.objname + ,l.objschema + ,l.objdb + ,l.objtype + ,1 + ,@iter_no +FROM #tempdep l; + +-- change the object_id of table types to their user_defined_id +UPDATE #t1 +SET object_id = tt.user_type_id + ,relative_id = tt.user_type_id +FROM sys.table_types AS tt +WHERE tt.type_table_object_id = #t1.object_id + AND object_type = @udtt; + +WHILE @rows > 0 + BEGIN + SET @rows = 0 + + IF ( 1 = @find_referencing_objects ) + BEGIN + -- HARD DEPENDENCIES + -- these dependencies have to be in the same database only + -- tables that reference uddts or udts + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT tbl.object_id + ,tbl.name + ,Schema_name(tbl.schema_id) + ,t.object_db + ,@u + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.columns AS c + ON c.user_type_id = t.object_id + JOIN sys.tables AS tbl + ON tbl.object_id = c.object_id + WHERE @iter_no = t.rank + AND ( t.object_type = @uddt + OR t.object_type = @udt ) + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- udtts that reference uddts or udts + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT tt.user_type_id + ,tt.name + ,Schema_name(tt.schema_id) + ,t.object_db + ,@udtt + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.columns AS c + ON c.user_type_id = t.object_id + JOIN sys.table_types AS tt + ON tt.type_table_object_id = c.object_id + WHERE @iter_no = t.rank + AND ( t.object_type = @uddt + OR t.object_type = @udt ) + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- tables/views that reference triggers + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT o.object_id + ,o.name + ,Schema_name(o.schema_id) + ,t.object_db + ,@tr + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.objects AS o + ON o.parent_object_id = t.object_id + AND o.type = 'TR' + WHERE @iter_no = t.rank + AND ( t.object_type = @u + OR t.object_type = @v ) + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- tables that reference defaults (only default objects) + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT o.object_id + ,o.name + ,Schema_name(o.schema_id) + ,t.object_db + ,@u + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.columns AS clmns + ON clmns.default_object_id = t.object_id + JOIN sys.objects AS o + ON o.object_id = clmns.object_id + AND 0 = ISNULL(o.parent_object_id, 0) + WHERE @iter_no = t.rank + AND t.object_type = @def + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- types that reference defaults (only default objects) + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT tp.user_type_id + ,tp.name + ,Schema_name(tp.schema_id) + ,t.object_db + ,@uddt + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.types AS tp + ON tp.default_object_id = t.object_id + JOIN sys.objects AS o + ON o.object_id = t.object_id + AND 0 = ISNULL(o.parent_object_id, 0) + WHERE @iter_no = t.rank + AND t.object_type = @def + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- tables that reference rules + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT tbl.object_id + ,tbl.name + ,Schema_name(tbl.schema_id) + ,t.object_db + ,@u + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.columns AS clmns + ON clmns.rule_object_id = t.object_id + JOIN sys.tables AS tbl + ON tbl.object_id = clmns.object_id + WHERE @iter_no = t.rank + AND t.relative_type = @rule + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- types that reference rules + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT tp.user_type_id + ,tp.name + ,Schema_name(tp.schema_id) + ,t.object_db + ,@uddt + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.types AS tp + ON tp.rule_object_id = t.object_id + WHERE @iter_no = t.rank + AND t.object_type = @rule + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- tables that reference XmlSchemaCollections + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT tbl.object_id + ,tbl.name + ,Schema_name(tbl.schema_id) + ,t.object_db + ,@u + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.columns AS c + ON c.xml_collection_id = t.object_id + JOIN sys.tables AS tbl + ON tbl.object_id = c.object_id -- eliminate views + WHERE @iter_no = t.rank + AND t.object_type = @xml + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- table types that reference XmlSchemaCollections + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT tt.user_type_id + ,tt.name + ,Schema_name(tt.schema_id) + ,t.object_db + ,@udtt + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.columns AS c + ON c.xml_collection_id = t.object_id + JOIN sys.table_types AS tt + ON tt.type_table_object_id = c.object_id + WHERE @iter_no = t.rank + AND t.object_type = @xml + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- procedures that reference XmlSchemaCollections + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT o.object_id + ,o.name + ,Schema_name(o.schema_id) + ,t.object_db + ,( CASE + WHEN o.type IN ( 'P', 'RF', 'PC' ) THEN @sp + ELSE @udf + END ) + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.parameters AS c + ON c.xml_collection_id = t.object_id + JOIN sys.objects AS o + ON o.object_id = c.object_id + WHERE @iter_no = t.rank + AND t.object_type = @xml + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- udf, sp, uda, trigger all that reference assembly + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT o.object_id + ,o.name + ,Schema_name(o.schema_id) + ,t.object_db + ,( CASE o.type + WHEN 'AF' THEN @uda + WHEN 'PC' THEN @sp + WHEN 'FS' THEN @udf + WHEN 'FT' THEN @udf + WHEN 'TA' THEN @tr + ELSE @udf + END ) + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.assembly_modules AS am + ON ( ( am.assembly_id = t.object_id ) + AND ( am.assembly_id >= 65536 ) ) + JOIN sys.objects AS o + ON am.object_id = o.object_id + WHERE @iter_no = t.rank + AND t.object_type = @assm + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- udt that reference assembly + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT at.user_type_id + ,at.name + ,Schema_name(at.schema_id) + ,t.object_db + ,@udt + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.assembly_types AS at + ON ( ( at.assembly_id = t.object_id ) + AND ( at.is_user_defined = 1 ) ) + WHERE @iter_no = t.rank + AND t.object_type = @assm + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- assembly that reference assembly + INSERT #t1 + (object_id + ,object_name + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT asm.assembly_id + ,asm.name + ,t.object_db + ,@assm + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.assembly_references AS ar + ON ( ( ar.referenced_assembly_id = t.object_id ) + AND ( ar.referenced_assembly_id >= 65536 ) ) + JOIN sys.assemblies AS asm + ON asm.assembly_id = ar.assembly_id + WHERE @iter_no = t.rank + AND t.object_type = @assm + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- table references table + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT tbl.object_id + ,tbl.name + ,Schema_name(tbl.schema_id) + ,t.object_db + ,@u + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.foreign_keys AS fk + ON fk.referenced_object_id = t.object_id + JOIN sys.tables AS tbl + ON tbl.object_id = fk.parent_object_id + WHERE @iter_no = t.rank + AND t.object_type = @u + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- uda references types + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT o.object_id + ,o.name + ,Schema_name(o.schema_id) + ,t.object_db + ,@uda + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.parameters AS p + ON p.user_type_id = t.object_id + JOIN sys.objects AS o + ON o.object_id = p.object_id + AND o.type = 'AF' + WHERE @iter_no = t.rank + AND t.object_type IN ( @udt, @uddt, @udtt ) + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + -- table,view references partition scheme + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT o.object_id + ,o.name + ,Schema_name(o.schema_id) + ,t.object_db + ,( CASE o.type + WHEN 'V' THEN @v + ELSE @u + END ) + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.indexes AS idx + ON idx.data_space_id = t.object_id + JOIN sys.objects AS o + ON o.object_id = idx.object_id + WHERE @iter_no = t.rank + AND t.object_type = @part_sch + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- partition scheme references partition function + INSERT #t1 + (object_id + ,object_name + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT ps.data_space_id + ,ps.name + ,t.object_db + ,@part_sch + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.partition_schemes AS ps + ON ps.function_id = t.object_id + WHERE @iter_no = t.rank + AND t.object_type = @part_func + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- plan guide references sp, udf, triggers + INSERT #t1 + (object_id + ,object_name + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT pg.plan_guide_id + ,pg.name + ,t.object_db + ,@pg + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.plan_guides AS pg + ON pg.scope_object_id = t.object_id + WHERE @iter_no = t.rank + AND t.object_type IN ( @sp, @udf, @tr ) + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- synonym refrences object + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT s.object_id + ,s.name + ,Schema_name(s.schema_id) + ,t.object_db + ,@synonym + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,0 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.synonyms AS s + ON Object_id(s.base_object_name) = t.object_id + WHERE @iter_no = t.rank + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- sequences that reference uddts + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT s.object_id + ,s.name + ,Schema_name(s.schema_id) + ,t.object_db + ,@sequence + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,0 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.sequences AS s + ON s.user_type_id = t.object_id + WHERE @iter_no = t.rank + AND ( t.object_type = @uddt ) + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- SOFT DEPENDENCIES + DECLARE name_cursor CURSOR FOR + SELECT DISTINCT t.object_id + ,t.object_name + ,t.object_schema + ,t.object_type + FROM #t1 AS t + WHERE @iter_no = t.rank + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ) + AND t.object_type NOT IN ( @part_sch, @assm, @tr, @ddltr ); + + OPEN name_cursor; + + DECLARE @objid INT; + DECLARE @objname SYSNAME; + DECLARE @objschema SYSNAME; + DECLARE @objtype SMALLINT; + DECLARE @fullname SYSNAME; + DECLARE @objecttype SYSNAME; + + FETCH next FROM name_cursor INTO @objid, @objname, @objschema, @objtype; + + WHILE ( @@FETCH_STATUS <> -1 ) + BEGIN + SET @fullname = CASE + WHEN @objschema IS NULL THEN + QUOTENAME(@objname) + ELSE QUOTENAME(@objschema) + '.' + QUOTENAME(@objname) + END; + SET @objecttype = CASE + WHEN @objtype IN ( @uddt, @udt, @udtt ) + THEN + 'TYPE' + WHEN @objtype = @xml THEN + 'XML_SCHEMA_COLLECTION' + WHEN @objtype = @part_func THEN + 'PARTITION_FUNCTION' + ELSE 'OBJECT' + END; + + INSERT #t2 + (object_type + ,object_id + ,object_name + ,object_schema + ,object_db + ,object_svr + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT CASE dep.referencing_class + WHEN 1 THEN (SELECT CASE + WHEN obj.type = 'U' THEN @u + WHEN obj.type = 'V' THEN @v + WHEN obj.type = 'TR' THEN @tr + WHEN obj.type IN ( + 'P', 'RF', 'PC' ) + THEN + @sp + WHEN obj.type IN ( 'AF' ) THEN + @uda + WHEN obj.type IN ( + 'TF', 'FN', 'IF', + 'FS', + 'FT' ) + THEN + @udf + WHEN obj.type = 'D' THEN @def + WHEN obj.type = 'SN' THEN + @synonym + WHEN obj.type = 'SO' THEN + @sequence + ELSE @obj + END + FROM sys.objects AS obj + WHERE + obj.object_id = dep.referencing_id) + WHEN 6 THEN (SELECT CASE + WHEN ( tp.is_assembly_type = 1 + ) + THEN + @udt + WHEN ( tp.is_table_type = 1 ) + THEN + @udtt + ELSE @uddt + END + FROM sys.types AS tp + WHERE + tp.user_type_id = dep.referencing_id) + WHEN 7 THEN @u + WHEN 9 THEN @u + WHEN 10 THEN @xml + WHEN 12 THEN @ddltr + WHEN 21 THEN @part_func + END + ,dep.referencing_id + ,dep.referencing_entity_name + ,dep.referencing_schema_name + ,DB_NAME() + ,NULL + ,@objid + ,@objname + ,@objschema + ,DB_NAME() + ,@objtype + ,0 + ,@iter_no + 1 + FROM sys.dm_sql_referencing_entities(@fullname, @objecttype) AS dep; + + FETCH NEXT FROM name_cursor INTO @objid, @objname, @objschema, @objtype; + END + + CLOSE name_cursor; + DEALLOCATE name_cursor; + + UPDATE #t2 + SET object_id = obj.object_id + ,object_name = obj.name + ,object_schema = Schema_name(obj.schema_id) + ,object_type = CASE + WHEN obj.type = 'U' THEN @u + WHEN obj.type = 'V' THEN @v + END + FROM sys.objects AS o + JOIN sys.objects AS obj + ON obj.object_id = o.parent_object_id + WHERE o.object_id = #t2.object_id + AND ( #t2.object_type = @obj + OR o.parent_object_id != 0 ) + AND #t2.rank = @iter_no + 1; + + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_svr + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_svr + ,relative_type + ,schema_bound + ,rank) + SELECT object_id + ,object_name + ,object_schema + ,object_db + ,object_svr + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_svr + ,relative_type + ,schema_bound + ,rank + FROM #t2 + WHERE @iter_no + 1 = rank + AND #t2.object_id != #t2.relative_id; + + SET @rows = @rows + @@rowcount; + END + ELSE + BEGIN + -- SOFT DEPENDENCIES + -- insert all values from sys.sql_expression_dependencies for the corresponding object + -- first insert them in #t2, update them and THEN finally insert them in #t1 + INSERT #t2 + (object_type + ,object_name + ,object_schema + ,object_db + ,object_svr + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT CASE dep.referenced_class + WHEN 1 THEN @obj + WHEN 6 THEN @type + WHEN 7 THEN @u + WHEN 9 THEN @u + WHEN 10 THEN @xml + WHEN 21 THEN @part_func + END + ,dep.referenced_entity_name + ,dep.referenced_schema_name + ,dep.referenced_database_name + ,dep.referenced_server_name + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,dep.is_schema_bound_reference + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.sql_expression_dependencies AS dep + ON dep.referencing_id = t.object_id + WHERE @iter_no = t.rank + AND t.object_svr IS NULL + AND t.object_db = DB_NAME(); + + -- insert all the dependency values in case of a table that references a check + INSERT #t2 + (object_type + ,object_name + ,object_schema + ,object_db + ,object_svr + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT CASE dep.referenced_class + WHEN 1 THEN @obj + WHEN 6 THEN @type + WHEN 7 THEN @u + WHEN 9 THEN @u + WHEN 10 THEN @xml + WHEN 21 THEN @part_func + END + ,dep.referenced_entity_name + ,dep.referenced_schema_name + ,dep.referenced_database_name + ,dep.referenced_server_name + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,dep.is_schema_bound_reference + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.sql_expression_dependencies AS d + ON d.referenced_id = t.object_id + JOIN sys.objects AS o + ON o.object_id = d.referencing_id + AND o.type = 'C' + JOIN sys.sql_expression_dependencies AS dep + ON dep.referencing_id = d.referencing_id + AND dep.referenced_id != t.object_id + WHERE @iter_no = t.rank + AND t.object_svr IS NULL + AND t.object_db = DB_NAME() + AND t.object_type = @u; + + -- insert all the dependency values in case of an object that belongs to another object whose dependencies are being found + INSERT #t2 + (object_type + ,object_name + ,object_schema + ,object_db + ,object_svr + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT CASE dep.referenced_class + WHEN 1 THEN @obj + WHEN 6 THEN @type + WHEN 7 THEN @u + WHEN 9 THEN @u + WHEN 10 THEN @xml + WHEN 21 THEN @part_func + END + ,dep.referenced_entity_name + ,dep.referenced_schema_name + ,dep.referenced_database_name + ,dep.referenced_server_name + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,dep.is_schema_bound_reference + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.objects AS o + ON o.parent_object_id = t.object_id + JOIN sys.sql_expression_dependencies AS dep + ON dep.referencing_id = o.object_id + WHERE @iter_no = t.rank + AND t.object_svr IS NULL + AND t.object_db = DB_NAME(); + + -- queries for objects with object_id null and object_svr null - resolve them + -- we will build the query to resolve the objects + -- increase @rows as we bind the objects + DECLARE db_cursor CURSOR FOR + SELECT DISTINCT ISNULL(object_db, DB_NAME()) + FROM #t2 AS t + WHERE t.rank = ( @iter_no + 1 ) + AND t.object_id IS NULL + AND t.object_svr IS NULL; + + OPEN db_cursor; + + DECLARE @dbname SYSNAME; + DECLARE @quote_quoted_dbname SYSNAME; + DECLARE @bracket_quoted_dbname SYSNAME; + + FETCH next FROM db_cursor INTO @dbname; + + WHILE ( @@FETCH_STATUS <> -1 ) + BEGIN + IF ( DB_ID(@dbname) IS NULL ) + BEGIN + FETCH next FROM db_cursor INTO @dbname; + + CONTINUE; + END + + SET @quote_quoted_dbname = QUOTENAME(@dbname, ''''); + SET @bracket_quoted_dbname = QUOTENAME(@dbname, ']'); + + DECLARE @query NVARCHAR(max); + + -- WHEN schema is not null + -- @obj + SET @query = 'UPDATE #t2 set object_db = N' + + @quote_quoted_dbname + + ', object_id = obj.object_id, object_type = case WHEN obj.type = ''U'' THEN ' + + CAST(@u AS NVARCHAR(8)) + + ' WHEN obj.type = ''V'' THEN ' + + CAST(@v AS NVARCHAR(8)) + + ' WHEN obj.type = ''TR'' THEN ' + + CAST(@tr AS NVARCHAR(8)) + + ' WHEN obj.type in ( ''P'', ''RF'', ''PC'' ) THEN ' + + CAST(@sp AS NVARCHAR(8)) + + ' WHEN obj.type in ( ''AF'' ) THEN ' + + CAST(@uda AS NVARCHAR(8)) + + ' WHEN obj.type in ( ''TF'', ''FN'', ''IF'', ''FS'', ''FT'' ) THEN ' + + CAST(@udf AS NVARCHAR(8)) + + ' WHEN obj.type = ''D'' THEN ' + + CAST(@def AS NVARCHAR(8)) + + ' WHEN obj.type = ''SN'' THEN ' + + CAST(@synonym AS NVARCHAR(8)) + + ' WHEN obj.type = ''SO'' THEN ' + + CAST(@sequence AS NVARCHAR(8)) + ' ELSE ' + + CAST(@unknown AS NVARCHAR(8)) + + ' END FROM ' + + @bracket_quoted_dbname + + '.sys.objects as obj JOIN ' + + @bracket_quoted_dbname + + '.sys.schemas as sch on sch.schema_id = obj.schema_id + WHERE obj.name = #t2.object_name collate database_default AND + sch.name = #t2.object_schema collate database_default AND + #t2.object_type = ' + + CAST(@obj AS NVARCHAR(8)) + + ' AND #t2.object_schema IS NOT NULL AND (#t2.object_db IS NULL or #t2.object_db = N' + + @quote_quoted_dbname + + ') AND #t2.rank = (' + + CAST(@iter_no AS NVARCHAR(8)) + + '+1) AND #t2.object_id IS NULL and #t2.object_svr IS NULL;' + + EXEC sp_executesql @query; + + -- @type + SET @query = 'update #t2 set object_db = N' + + @quote_quoted_dbname + + ', object_id = t.user_type_id, object_type = case WHEN t.is_assembly_type = 1 THEN ' + + CAST(@udt AS NVARCHAR(8)) + + ' WHEN t.is_table_type = 1 THEN ' + + CAST(@udtt AS NVARCHAR(8)) + ' ELSE ' + + CAST(@uddt AS NVARCHAR(8)) + + ' END FROM ' + + @bracket_quoted_dbname + + '.sys.types AS t JOIN ' + + @bracket_quoted_dbname + + '.sys.schemas as sch on sch.schema_id = t.schema_id + WHERE t.name = #t2.object_name collate database_default AND + sch.name = #t2.object_schema collate database_default AND + #t2.object_type = ' + + CAST(@type AS NVARCHAR(8)) + + ' and #t2.object_schema IS NOT NULL AND (#t2.object_db IS NULL or #t2.object_db = N' + + @quote_quoted_dbname + + ') AND #t2.rank = (' + + CAST(@iter_no AS NVARCHAR(8)) + + '+1) AND #t2.object_id IS NULL and #t2.object_svr IS NULL;'; + + EXEC sp_executesql @query; + + -- @xml + SET @query = 'UPDATE #t2 set object_db = N' + + @quote_quoted_dbname + + ', object_id = x.xml_collection_id FROM ' + + @bracket_quoted_dbname + + '.sys.xml_schema_collections AS x JOIN ' + + @bracket_quoted_dbname + + '.sys.schemas as sch on sch.schema_id = x.schema_id + WHERE x.name = #t2.object_name collate database_default AND + sch.name = #t2.object_schema collate database_default AND + #t2.object_type = ' + + CAST(@xml AS NVARCHAR(8)) + + ' AND #t2.object_schema IS NOT NULL AND (#t2.object_db IS NULL OR #t2.object_db = N' + + @quote_quoted_dbname + + ') AND #t2.rank = (' + + CAST(@iter_no AS NVARCHAR(8)) + + '+1) AND #t2.object_id IS NULL and #t2.object_svr IS NULL;'; + + EXEC sp_executesql @query; + + -- @part_func - schema is always null + -- @schema is null + -- consider schema as 'dbo' + -- @obj + SET @query = 'UPDATE #t2 set object_db = N' + + @quote_quoted_dbname + + ', object_id = obj.object_id, object_schema = SCHEMA_NAME(obj.schema_id), object_type = CASE WHEN obj.type = ''U'' THEN ' + + CAST(@u AS NVARCHAR(8)) + + ' WHEN obj.type = ''V'' THEN ' + + CAST(@v AS NVARCHAR(8)) + + ' WHEN obj.type = ''TR'' THEN ' + + CAST(@tr AS NVARCHAR(8)) + + ' WHEN obj.type in ( ''P'', ''RF'', ''PC'' ) THEN ' + + CAST(@sp AS NVARCHAR(8)) + + ' WHEN obj.type in ( ''AF'' ) THEN ' + + CAST(@uda AS NVARCHAR(8)) + + ' WHEN obj.type in ( ''TF'', ''FN'', ''IF'', ''FS'', ''FT'' ) THEN ' + + CAST(@udf AS NVARCHAR(8)) + + ' WHEN obj.type = ''D'' THEN ' + + CAST(@def AS NVARCHAR(8)) + + ' WHEN obj.type = ''SN'' THEN ' + + CAST(@synonym AS NVARCHAR(8)) + + ' WHEN obj.type = ''SO'' THEN ' + + CAST(@sequence AS NVARCHAR(8)) + ' ELSE ' + + CAST(@unknown AS NVARCHAR(8)) + + ' END FROM ' + + @bracket_quoted_dbname + + '.sys.objects as obj + WHERE obj.name = #t2.object_name collate database_default AND + SCHEMA_NAME(obj.schema_id) = ''dbo'' AND + #t2.object_type = ' + + CAST(@obj AS NVARCHAR(8)) + + ' AND #t2.object_schema IS NULL AND (#t2.object_db IS NULL OR #t2.object_db = N' + + @quote_quoted_dbname + + ') AND #t2.rank = (' + + CAST(@iter_no AS NVARCHAR(8)) + + '+1) AND #t2.object_id IS NULL and #t2.object_svr IS NULL;'; + + EXEC sp_executesql @query; + + -- @type + SET @query = 'update #t2 set object_db = N' + + @quote_quoted_dbname + + ', object_id = t.user_type_id, object_schema = SCHEMA_NAME(t.schema_id), object_type = case WHEN t.is_assembly_type = 1 THEN ' + + CAST(@udt AS NVARCHAR(8)) + + ' WHEN t.is_table_type = 1 THEN ' + + CAST(@udtt AS NVARCHAR(8)) + ' else ' + + CAST(@uddt AS NVARCHAR(8)) + + ' end from ' + + @bracket_quoted_dbname + + '.sys.types AS t + where t.name = #t2.object_name collate database_default AND + SCHEMA_NAME(t.schema_id) = ''dbo'' AND + #t2.object_type = ' + + CAST(@type AS NVARCHAR(8)) + + ' and #t2.object_schema IS NULL AND (#t2.object_db IS NULL OR #t2.object_db = N' + + @quote_quoted_dbname + + ') AND #t2.rank = (' + + CAST(@iter_no AS NVARCHAR(8)) + + '+1) AND #t2.object_id IS NULL AND #t2.object_svr IS NULL;'; + + EXEC sp_executesql @query; + + -- @xml + SET @query = 'update #t2 set object_db = N' + + @quote_quoted_dbname + + ', object_id = x.xml_collection_id, object_schema = SCHEMA_NAME(x.schema_id) FROM ' + + @bracket_quoted_dbname + + '.sys.xml_schema_collections as x + WHERE x.name = #t2.object_name collate database_default AND + SCHEMA_NAME(x.schema_id) = ''dbo'' AND + #t2.object_type = ' + + CAST(@xml AS NVARCHAR(8)) + + ' AND #t2.object_schema IS NULL AND (#t2.object_db IS NULL OR #t2.object_db = N' + + @quote_quoted_dbname + + ') and #t2.rank = (' + + CAST(@iter_no AS NVARCHAR(8)) + + '+1) and #t2.object_id IS NULL and #t2.object_svr IS NULL;'; + + EXEC sp_executesql @query; + + -- consider schema as t.relative_schema + -- the parent object will have the default schema of user in case of dynamic schema binding + -- @obj + SET @query = 'UPDATE #t2 set object_db = N' + + @quote_quoted_dbname + + ', object_id = obj.object_id, object_schema = SCHEMA_NAME(obj.schema_id), object_type = CASE WHEN obj.type = ''U'' THEN ' + + CAST(@u AS NVARCHAR(8)) + + ' WHEN obj.type = ''V'' THEN ' + + CAST(@v AS NVARCHAR(8)) + + ' WHEN obj.type = ''TR'' THEN ' + + CAST(@tr AS NVARCHAR(8)) + + ' WHEN obj.type in ( ''P'', ''RF'', ''PC'' ) THEN ' + + CAST(@sp AS NVARCHAR(8)) + + ' WHEN obj.type in ( ''AF'' ) THEN ' + + CAST(@uda AS NVARCHAR(8)) + + ' WHEN obj.type in ( ''TF'', ''FN'', ''IF'', ''FS'', ''FT'' ) THEN ' + + CAST(@udf AS NVARCHAR(8)) + + ' WHEN obj.type = ''D'' THEN ' + + CAST(@def AS NVARCHAR(8)) + + ' WHEN obj.type = ''SN'' THEN ' + + CAST(@synonym AS NVARCHAR(8)) + + ' WHEN obj.type = ''SO'' THEN ' + + CAST(@sequence AS NVARCHAR(8)) + ' else ' + + CAST(@unknown AS NVARCHAR(8)) + + ' end from ' + + @bracket_quoted_dbname + + '.sys.objects as obj JOIN ' + + @bracket_quoted_dbname + + '.sys.schemas as sch on sch.schema_id = obj.schema_id + WHERE obj.name = #t2.object_name collate database_default AND + sch.name = #t2.relative_schema collate database_default AND + #t2.object_type = ' + + CAST(@obj AS NVARCHAR(8)) + + ' AND #t2.object_schema IS NULL AND (#t2.object_db IS NULL or #t2.object_db = N' + + @quote_quoted_dbname + + ') AND #t2.rank = (' + + CAST(@iter_no AS NVARCHAR(8)) + + '+1) AND #t2.object_id IS NULL AND #t2.object_svr IS NULL;'; + + EXEC sp_executesql @query; + + -- @type + SET @query = 'UPDATE #t2 set object_db = N' + + @quote_quoted_dbname + + ', object_id = t.user_type_id, object_schema = SCHEMA_NAME(t.schema_id), object_type = case WHEN t.is_assembly_type = 1 THEN ' + + CAST(@udt AS NVARCHAR(8)) + + ' WHEN t.is_table_type = 1 THEN ' + + CAST(@udtt AS NVARCHAR(8)) + ' else ' + + CAST(@uddt AS NVARCHAR(8)) + + ' END FROM ' + + @bracket_quoted_dbname + + '.sys.types as t JOIN ' + + @bracket_quoted_dbname + + '.sys.schemas as sch on sch.schema_id = t.schema_id + WHERE t.name = #t2.object_name collate database_default AND + sch.name = #t2.relative_schema collate database_default AND + #t2.object_type = ' + + CAST(@type AS NVARCHAR(8)) + + ' and #t2.object_schema IS NULL AND (#t2.object_db IS NULL or #t2.object_db = N' + + @quote_quoted_dbname + + ') AND #t2.rank = (' + + CAST(@iter_no AS NVARCHAR(8)) + + '+1) AND #t2.object_id IS NULL AND #t2.object_svr IS NULL;' + + EXEC sp_executesql @query; + + -- @xml + SET @query = 'UPDATE #t2 set object_db = N' + + @quote_quoted_dbname + + ', object_id = x.xml_collection_id, object_schema = SCHEMA_NAME(x.schema_id) FROM ' + + @bracket_quoted_dbname + + '.sys.xml_schema_collections as x JOIN ' + + @bracket_quoted_dbname + + '.sys.schemas as sch on sch.schema_id = x.schema_id + WHERE x.name = #t2.object_name collate database_default AND + sch.name = #t2.relative_schema collate database_default AND + #t2.object_type = ' + + CAST(@xml AS NVARCHAR(8)) + + ' AND #t2.object_schema IS NULL AND (#t2.object_db IS NULL or #t2.object_db = N' + + @quote_quoted_dbname + + ') AND #t2.rank = (' + + CAST(@iter_no AS NVARCHAR(8)) + + '+1) and #t2.object_id IS NULL AND #t2.object_svr IS NULL;'; + + EXEC sp_executesql @query; + + -- @part_func always have schema as null + SET @query = 'update #t2 set object_db = N' + + @quote_quoted_dbname + + ', object_id = p.function_id FROM ' + + @bracket_quoted_dbname + + '.sys.partition_functions as p + WHERE p.name = #t2.object_name collate database_default AND + #t2.object_type = ' + + CAST(@part_func AS NVARCHAR(8)) + + ' and (#t2.object_db IS NULL or #t2.object_db = N' + + @quote_quoted_dbname + + ') and #t2.rank = (' + + CAST(@iter_no AS NVARCHAR(8)) + + '+1) AND #t2.object_id IS NULL and #t2.object_svr IS NULL'; + + EXEC sp_executesql @query; + + -- update the shared object if any (schema is not null) + UPDATE #t2 + SET object_db = 'master' + ,object_id = o.object_id + ,object_type = @sp + FROM master.sys.objects AS o + JOIN master.sys.schemas AS sch + ON sch.schema_id = o.schema_id + WHERE o.name = #t2.object_name COLLATE database_default + AND sch.name = #t2.object_schema COLLATE database_default + AND o.type IN ( 'P', 'RF', 'PC' ) + AND #t2.object_id IS NULL + AND #t2.object_name LIKE 'sp/_%' ESCAPE '/' + AND #t2.object_db IS NULL + AND #t2.object_svr IS NULL; + + -- update the shared object if any (schema is null) + UPDATE #t2 + SET object_db = 'master' + ,object_id = o.object_id + ,object_schema = Schema_name(o.schema_id) + ,object_type = @sp + FROM master.sys.objects AS o + WHERE o.name = #t2.object_name COLLATE database_default + AND Schema_name(o.schema_id) = 'dbo' COLLATE database_default + AND o.type IN ( 'P', 'RF', 'PC' ) + AND #t2.object_schema IS NULL + AND #t2.object_id IS NULL + AND #t2.object_name LIKE 'sp/_%' ESCAPE '/' + AND #t2.object_db IS NULL + AND #t2.object_svr IS NULL; + + FETCH next FROM db_cursor INTO @dbname; + END; + + CLOSE db_cursor; + DEALLOCATE db_cursor; + + UPDATE #t2 + SET object_type = @unknown + WHERE object_id IS NULL; + + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_svr + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_svr + ,relative_type + ,schema_bound + ,rank) + SELECT object_id + ,object_name + ,object_schema + ,object_db + ,object_svr + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_svr + ,relative_type + ,schema_bound + ,rank + FROM #t2 + WHERE @iter_no + 1 = rank; + + SET @rows = @rows + @@rowcount; + + -- HARD DEPENDENCIES + -- uddt or udt referenced by table + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT tp.user_type_id + ,tp.name + ,Schema_name(tp.schema_id) + ,t.object_db + ,CASE tp.is_assembly_type + WHEN 1 THEN @udt + ELSE @uddt + END + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.columns AS col + ON col.object_id = t.object_id + JOIN sys.types AS tp + ON tp.user_type_id = col.user_type_id + AND tp.schema_id != 4 + WHERE @iter_no = t.rank + AND t.object_type = @u + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- uddt or udt referenced by table type + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT tp.user_type_id + ,tp.name + ,Schema_name(tp.schema_id) + ,t.object_db + ,CASE tp.is_assembly_type + WHEN 1 THEN @udt + ELSE @uddt + END + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.table_types AS tt + ON tt.user_type_id = t.object_id + JOIN sys.columns AS col + ON col.object_id = tt.type_table_object_id + JOIN sys.types AS tp + ON tp.user_type_id = col.user_type_id + AND tp.schema_id != 4 + WHERE @iter_no = t.rank + AND t.object_type = @udtt + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- table or view referenced by trigger + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT o.object_id + ,o.name + ,Schema_name(o.schema_id) + ,t.object_db + ,CASE o.type + WHEN 'V' THEN @v + ELSE @u + END + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.triggers AS tr + ON tr.object_id = t.object_id + JOIN sys.objects AS o + ON o.object_id = tr.parent_id + WHERE @iter_no = t.rank + AND t.object_type = @tr + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- defaults (only default objects) referenced by tables + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT o.object_id + ,o.name + ,Schema_name(o.schema_id) + ,t.object_db + ,@def + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.columns AS clmns + ON clmns.object_id = t.object_id + JOIN sys.objects AS o + ON o.object_id = clmns.default_object_id + AND 0 = ISNULL(o.parent_object_id, 0) + WHERE @iter_no = t.rank + AND t.object_type = @u + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- defaults (only default objects) referenced by types + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT o.object_id + ,o.name + ,Schema_name(o.schema_id) + ,t.object_db + ,@def + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.types AS tp + ON tp.user_type_id = t.object_id + JOIN sys.objects AS o + ON o.object_id = tp.default_object_id + AND 0 = ISNULL(o.parent_object_id, 0) + WHERE @iter_no = t.rank + AND t.object_type = @uddt + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- rules referenced by tables + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT o.object_id + ,o.name + ,Schema_name(o.schema_id) + ,t.object_db + ,@rule + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.columns AS clmns + ON clmns.object_id = t.object_id + JOIN sys.objects AS o + ON o.object_id = clmns.rule_object_id + AND 0 = ISNULL(o.parent_object_id, 0) + WHERE @iter_no = t.rank + AND t.relative_type = @u + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- rules referenced by types + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT o.object_id + ,o.name + ,Schema_name(o.schema_id) + ,t.object_db + ,@rule + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.types AS tp + ON tp.user_type_id = t.object_id + JOIN sys.objects AS o + ON o.object_id = tp.rule_object_id + AND 0 = ISNULL(o.parent_object_id, 0) + WHERE @iter_no = t.rank + AND t.relative_type = @uddt + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- XmlSchemaCollections referenced by tables + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT x.xml_collection_id + ,x.name + ,Schema_name(x.schema_id) + ,t.object_db + ,@xml + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.columns AS c + ON c.object_id = t.object_id + JOIN sys.xml_schema_collections AS x + ON x.xml_collection_id = c.xml_collection_id + AND x.schema_id != 4 + WHERE @iter_no = t.rank + AND t.object_type = @u + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- XmlSchemaCollections referenced by tabletypes + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT x.xml_collection_id + ,x.name + ,Schema_name(x.schema_id) + ,t.object_db + ,@xml + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.table_types AS tt + ON tt.user_type_id = t.object_id + JOIN sys.columns AS c + ON c.object_id = tt.type_table_object_id + JOIN sys.xml_schema_collections AS x + ON x.xml_collection_id = c.xml_collection_id + AND x.schema_id != 4 + WHERE @iter_no = t.rank + AND t.object_type = @udtt + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- XmlSchemaCollections referenced by procedures + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT x.xml_collection_id + ,x.name + ,Schema_name(x.schema_id) + ,t.object_db + ,@xml + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.parameters AS c + ON c.object_id = t.object_id + JOIN sys.xml_schema_collections AS x + ON x.xml_collection_id = c.xml_collection_id + AND x.schema_id != 4 + WHERE @iter_no = t.rank + AND t.object_type IN ( @sp, @udf ) + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- table referenced by table + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT tbl.object_id + ,tbl.name + ,Schema_name(tbl.schema_id) + ,t.object_db + ,@u + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.foreign_keys AS fk + ON fk.parent_object_id = t.object_id + JOIN sys.tables AS tbl + ON tbl.object_id = fk.referenced_object_id + WHERE @iter_no = t.rank + AND t.object_type = @u + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- uddts referenced by uda + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT tp.user_type_id + ,tp.name + ,Schema_name(tp.schema_id) + ,t.object_db + ,CASE + WHEN tp.is_table_type = 1 THEN @udtt + WHEN tp.is_assembly_type = 1 THEN @udt + ELSE @uddt + END + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.parameters AS p + ON p.object_id = t.object_id + JOIN sys.types AS tp + ON tp.user_type_id = p.user_type_id + WHERE @iter_no = t.rank + AND t.object_type = @uda + AND t.object_type = @uda + AND tp.user_type_id > 256; + + SET @rows = @rows + @@rowcount; + + -- assembly referenced by assembly + INSERT #t1 + (object_id + ,object_name + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT asm.assembly_id + ,asm.name + ,t.object_db + ,@assm + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.assembly_references AS ar + ON ( ( ar.assembly_id = t.object_id ) + AND ( ar.referenced_assembly_id >= 65536 ) ) + JOIN sys.assemblies AS asm + ON asm.assembly_id = ar.referenced_assembly_id + WHERE @iter_no = t.rank + AND t.object_type = @assm + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- assembly referenced by udt + INSERT #t1 + (object_id + ,object_name + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT asm.assembly_id + ,asm.name + ,t.object_db + ,@assm + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.assembly_types AS at + ON ( ( at.user_type_id = t.object_id ) + AND ( at.is_user_defined = 1 ) ) + JOIN sys.assemblies AS asm + ON asm.assembly_id = at.assembly_id + WHERE @iter_no = t.rank + AND t.object_type = @udt + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- assembly referenced by udf, sp, uda, trigger + INSERT #t1 + (object_id + ,object_name + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT asm.assembly_id + ,asm.name + ,t.object_db + ,@assm + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.assembly_modules AS am + ON ( ( am.object_id = t.object_id ) + AND ( am.assembly_id >= 65536 ) ) + JOIN sys.assemblies AS asm + ON asm.assembly_id = am.assembly_id + WHERE @iter_no = t.rank + AND t.object_type IN ( @udf, @sp, @uda, @tr ) + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- Partition Schemes referenced by tables/views + INSERT #t1 + (object_id + ,object_name + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT ps.data_space_id + ,ps.name + ,t.object_db + ,@part_sch + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.indexes AS idx + ON idx.object_id = t.object_id + JOIN sys.partition_schemes AS ps + ON ps.data_space_id = idx.data_space_id + WHERE @iter_no = t.rank + AND t.object_type IN ( @u, @v ) + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- Partition Function referenced by Partition Schemes + INSERT #t1 + (object_id + ,object_name + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT pf.function_id + ,pf.name + ,t.object_db + ,@part_func + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.partition_schemes AS ps + ON ps.data_space_id = t.object_id + JOIN sys.partition_functions AS pf + ON pf.function_id = ps.function_id + WHERE @iter_no = t.rank + AND t.object_type = @part_sch + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- sp, udf, triggers referenced by plan guide + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT o.object_id + ,o.name + ,Schema_name(o.schema_id) + ,t.object_db + ,( CASE o.type + WHEN 'P' THEN @sp + WHEN 'TR' THEN @tr + ELSE @udf + END ) + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.plan_guides AS pg + ON pg.plan_guide_id = t.object_id + JOIN sys.objects AS o + ON o.object_id = pg.scope_object_id + WHERE @iter_no = t.rank + AND t.object_type = @pg + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- objects referenced by synonym + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT o.object_id + ,o.name + ,Schema_name(o.schema_id) + ,t.object_db + ,( CASE + WHEN o.type = 'U' THEN @u + WHEN o.type = 'V' THEN @v + WHEN o.type IN ( 'P', 'RF', 'PC' ) THEN @sp + WHEN o.type = 'AF' THEN @uda + ELSE @udf + END ) + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,0 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.synonyms AS s + ON s.object_id = t.object_id + JOIN sys.objects AS o + ON o.object_id = Object_id(s.base_object_name) + AND o.type IN ( 'U', 'V', 'P', 'RF', 'PC', 'AF', 'TF', 'FN', 'IF', 'FS', 'FT' ) + WHERE @iter_no = t.rank + AND t.object_type = @synonym + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; + + -- uddt referenced by sequence. Used to find UDDT that is in sequence dependencies. + INSERT #t1 + (object_id + ,object_name + ,object_schema + ,object_db + ,object_type + ,relative_id + ,relative_name + ,relative_schema + ,relative_db + ,relative_type + ,schema_bound + ,rank) + SELECT tp.user_type_id + ,tp.name + ,Schema_name(tp.schema_id) + ,t.object_db + ,CASE tp.is_assembly_type + WHEN 1 THEN @udt + ELSE @uddt + END + ,t.object_id + ,t.object_name + ,t.object_schema + ,t.object_db + ,t.object_type + ,1 + ,@iter_no + 1 + FROM #t1 AS t + JOIN sys.sequences AS s + ON s.object_id = t.object_id + JOIN sys.types AS tp + ON tp.user_type_id = s.user_type_id + AND tp.schema_id != 4 + WHERE @iter_no = t.rank + AND t.object_type = @sequence + AND ( t.object_svr IS NULL + AND t.object_db = DB_NAME() ); + + SET @rows = @rows + @@rowcount; +END + + SET @iter_no = @iter_no + 1; +END + +UPDATE #t1 +SET rank = 0; + +-- computing the degree of the nodes +UPDATE #t1 +SET degree = (SELECT Count(*) + FROM #t1 t + WHERE t.relative_id = #t1.object_id + AND t.object_id != t.relative_id); + +-- perform the topological sorting +SET @iter_no = 1; + +WHILE 1 = 1 + BEGIN + UPDATE #t1 + SET rank = @iter_no + WHERE degree = 0; + + -- end the loop if no more rows left to process + IF ( @@rowcount = 0 ) + BREAK; + + UPDATE #t1 + SET degree = NULL + WHERE rank = @iter_no + + UPDATE #t1 + SET degree = (SELECT COUNT(*) + FROM #t1 t + WHERE t.relative_id = #t1.object_id + AND t.object_id != t.relative_id + AND t.object_id IN (SELECT tt.object_id + FROM #t1 tt + WHERE tt.rank = 0)) + WHERE degree IS NOT NULL; + + SET @iter_no = @iter_no + 1; + END + +--correcting naming mistakes of objects present in current database +--This part need to be removed once SMO's URN comparision gets fixed +DECLARE @collation SYSNAME; +DECLARE db_cursor CURSOR FOR + SELECT DISTINCT ISNULL(object_db, DB_NAME()) + FROM #t1 AS t + WHERE t.object_id IS NOT NULL + AND t.object_svr IS NULL; + +OPEN db_cursor; + +FETCH next FROM db_cursor INTO @dbname; + +WHILE ( @@FETCH_STATUS <> -1 ) + BEGIN + IF ( DB_ID(@dbname) IS NULL ) + BEGIN + FETCH next FROM db_cursor INTO @dbname; + + CONTINUE; + END + + SET @collation = (SELECT CONVERT(SYSNAME, Databasepropertyex(@dbname, 'Collation'))); + SET @query = + 'UPDATE #t1 set #t1.object_name = o.name,#t1.object_schema = sch.name from #t1 inner join ' + + QUOTENAME(@dbname) + + '.sys.objects as o on #t1.object_id = o.object_id INNER JOIN ' + + QUOTENAME(@dbname) + + '.sys.schemas as sch on sch.schema_id = o.schema_id where o.name = #t1.object_name collate ' + + @collation + + ' AND sch.name = #t1.object_schema collate ' + + @collation; + + EXEC sp_executesql @query; + + FETCH next FROM db_cursor INTO @dbname; +END + +CLOSE db_cursor; + +DEALLOCATE db_cursor; + +--final select +SELECT ISNULL(t.object_id, 0) AS [object_id] + ,t.object_name + ,ISNULL(t.object_schema, '') AS [object_schema] + ,ISNULL(t.object_db, '') AS [object_db] + ,ISNULL(t.object_svr, '') AS [object_svr] + ,t.object_type + ,ISNULL(t.relative_id, 0) AS [relative_id] + ,t.relative_name + ,ISNULL(t.relative_schema, '') AS [relative_schema] + ,relative_db + ,ISNULL(t.relative_svr, '') AS [relative_svr] + ,t.relative_type + ,t.schema_bound + ,ISNULL(CASE + WHEN p.type = 'U' THEN @u + WHEN p.type = 'V' THEN @v + END, 0) AS [ptype] + ,ISNULL(p.name, '') AS [pname] + ,ISNULL(Schema_name(p.schema_id), '') AS [pschema] + ,t.rank +FROM #t1 AS t + LEFT JOIN sys.objects AS o + ON ( t.object_type = @tr + AND o.object_id = t.object_id ) + OR ( t.relative_type = @tr + AND o.object_id = t.relative_id ) + LEFT JOIN sys.objects AS p + ON p.object_id = o.parent_object_id +ORDER BY rank DESC; + +DROP TABLE #t1; +DROP TABLE #t2; +DROP TABLE #tempdep; + +IF @must_set_nocount_off > 0 + SET nocount OFF; diff --git a/Scripts/Find_SQL_Server_Integer_Columns_to_Make_Skinnier.sql b/Scripts/Find_SQL_Server_Integer_Columns_to_Make_Skinnier.sql new file mode 100644 index 00000000..f31640df --- /dev/null +++ b/Scripts/Find_SQL_Server_Integer_Columns_to_Make_Skinnier.sql @@ -0,0 +1,105 @@ +/* + + Find SQL Server Integer Columns to Make Skinnier + 1 data set: temp table #errlog. + No + Konstantin Taranov + 2019-07-25 + 2019-08-15 by Konstantin Taranov + 1.1 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Find_SQL_Server_Integer_Columns_to_Make_Skinnier.sql + https://www.mssqltips.com/sqlservertip/6107/find-sql-server-integer-columns-to-make-skinnier/ + +*/ + +SET NOCOUNT ON; + +IF OBJECT_ID(N'dbo.floob', 'U') IS NOT NULL DROP TABLE dbo.floob; +IF OBJECT_ID(N'dbo.mort', 'U') IS NOT NULL DROP TABLE dbo.mort; + +CREATE TABLE dbo.floob(x bigint, y int, z smallint); +INSERT dbo.floob(x,y,z) VALUES(1,1,1),(32766,32766,254); +CREATE TABLE dbo.mort(a int, b tinyint); +INSERT dbo.mort(a,b) VALUES(1,1),(32768,254); + +IF OBJECT_ID(N'tempdb..#cols', 'U') IS NOT NULL DROP TABLE #cols; + +DECLARE @src bigint = 2; +;WITH types AS +( + SELECT * FROM + (VALUES + (1,0,1, 104, N'bit', 1, 0, 1), + (2,1,1, 48, N'tinyint', 1, 0, 255), + (3,1,1, 52, N'smallint', 2, -(POWER(@src,15)), (POWER(@src,15)-1)), + (4,1,1, 56, N'int', 4, -(POWER(@src,31)), (POWER(@src,31)-1)), + (5,1,0, 127, N'bigint', 8, -(POWER(@src,62)-1)*2-2, (POWER(@src,62)-1)*2+1) + ) AS v(seq,src,trg,type_id,[type],bytes,minval,maxval) +), +cols AS +( + SELECT t.[object_id], + [schema] = s.name, + [table] = t.name, + [column] = QUOTENAME(c.name), + [type] = styp.name + COALESCE(' (alias: ' + utyp.name + ')', ''), + c.is_nullable, + trgtyp.seq, + trgtyp.type_id, + trgtype = trgtyp.[type], + savings = srctyp.bytes - trgtyp.bytes, + trgtyp.minval, + trgtyp.maxval, + [rowcount] = (SELECT SUM([rows]) FROM sys.partitions + WHERE object_id = t.object_id AND index_id IN (0,1)) + FROM sys.tables AS t + INNER JOIN sys.schemas AS s + ON s.[schema_id] = t.[schema_id] + INNER JOIN sys.columns AS c + ON t.[object_id] = c.[object_id] + INNER JOIN sys.types AS styp + ON c.system_type_id = styp.system_type_id + AND c.system_type_id = styp.user_type_id + LEFT OUTER JOIN sys.types AS utyp + ON c.user_type_id = utyp.user_type_id + AND utyp.user_type_id <> utyp.system_type_id + INNER JOIN types AS srctyp + ON srctyp.type_id = c.system_type_id + INNER JOIN types AS trgtyp + ON trgtyp.seq < srctyp.seq + WHERE srctyp.src = 1 + AND trgtyp.trg = 1 +) +SELECT * INTO #cols FROM cols; + +DECLARE @sql nvarchar(max) = N';WITH x([object_id], [column], minval, maxval) +AS (', + @core nvarchar(max) = N' + SELECT $oid, ''$c'', MIN($c), MAX($c) FROM $obj UNION ALL'; +SELECT @sql += REPLACE(REPLACE(REPLACE(@core, '$oid', RTRIM(object_id)), + '$c',[column]),'$obj',QUOTENAME([schema]) + '.' + QUOTENAME([table])) + FROM (SELECT [schema],[table],[column],object_id FROM #cols + GROUP BY [schema],[table],[column],object_id) AS x; +SET @sql += N' + SELECT NULL,NULL,NULL,NULL + ) + SELECT c.[schema], c.[table], c.[column], c.is_nullable, + current_type = c.[type], potential_type = c.trgtype, + space_savings = c.savings * c.[rowcount], x.minval, x.maxval, + range = RTRIM(c.minval) + '' -> '' + RTRIM(c.maxval) + FROM x + INNER JOIN #cols AS c + ON x.[object_id] = c.[object_id] + AND x.[column] = c.[column] + AND x.minval >= c.minval + AND x.maxval <= c.maxval;'; + +--PRINT(@sql); + +DECLARE @xml xml = (SELECT @sql FOR XML path('')); +SET @sql = + REPLACE(REPLACE(REPLACE(REPLACE(CONVERT(nvarchar(MAX), @xml, 1), ' ', CHAR(13)), '>', '>'), '<', '<'), '&', '&'); +/* Enable in SSMS option Tools->Options->Query Results->SQL Server->Results to Grid->Return CR/LF on copy or save */ +SELECT @sql AS SQL_Print; + +EXEC sys.sp_executesql @sql; diff --git a/Scripts/Find_Status_of_SQL_Server_Statistics.sql b/Scripts/Find_Status_of_SQL_Server_Statistics.sql new file mode 100644 index 00000000..8ec49629 --- /dev/null +++ b/Scripts/Find_Status_of_SQL_Server_Statistics.sql @@ -0,0 +1,124 @@ +/* +Author: Taiob Ali +Original link: http://sqlworldwide.com/tsql-to-find-status-of-sql-server-statistics/ + +This code is a modified or extended version of a script from here: +--http://www.sqlskills.com/blogs/erin/new-statistics-dmf-in-sql-server-2008r2-sp2/ + +This script will give all metadata related to statistics for a single database. +You can also uncomment a line and add an object name for a single table. + +Final challenge was to get one row per statistics with all column names. Used the tips from +https://www.mssqltips.com/sqlservertip/2914/rolling-up-multiple-rows-into-a-single-row-and-column-for-sql-server-data/ + +Suneel Mundlapudi who is a Sr. SQL Server Database Consultant at Fresenius Medical Care helped me implementing STUFF function +*/ + +/* Change on your database name */ +USE master; +GO + +IF Object_id('tempdb..#StatsInfo') IS NOT NULL + DROP TABLE #StatsInfo; +GO + +IF Object_id('tempdb..#ColumnList') IS NOT NULL + DROP TABLE #ColumnList; +GO + +DECLARE @object_id INT = NULL; + +--By default you get statistics status for whole database +--Uncomment below line if you are only looking at one table +--SET @object_id = OBJECT_ID(N'Sales.Invoices'); +SELECT ss.[name] AS SchemaName, + obj.[name] AS TableName, + stat.[stats_id], + stat.[name] AS StatisticsName, + CASE + WHEN stat.[auto_created] = 0 + AND stat.[user_created] = 0 THEN 'Index Statistic' + WHEN stat.[auto_created] = 0 + AND stat.[user_created] = 1 THEN 'User Created' + WHEN stat.[auto_created] = 1 + AND stat.[user_created] = 0 THEN 'Auto Created' + WHEN stat.[auto_created] = 1 + AND stat.[user_created] = 1 THEN 'Updated stats available in Secondary' + END AS StatisticType, + CASE + WHEN stat.[is_temporary] = 0 THEN 'Stats in DB' + WHEN stat.[is_temporary] = 1 THEN 'Stats in Tempdb' + END AS IsTemporary, + CASE + WHEN stat.[has_filter] = 1 THEN 'Filtered Index' + WHEN stat.[has_filter] = 0 THEN 'No Filter' + END AS IsFiltered, + c.[name] AS ColumnName, + stat.[filter_definition], + sp.[last_updated], + sp.[rows], + sp.[rows_sampled], + sp.[steps] AS HistorgramSteps, + sp.[unfiltered_rows], + sp.[modification_counter] AS RowsModified +INTO #StatsInfo +FROM sys.[objects] AS obj + INNER JOIN sys.[schemas] ss + ON obj.[schema_id] = ss.[schema_id] + INNER JOIN sys.[stats] stat + ON stat.[object_id] = obj.[object_id] + JOIN sys.[stats_columns] sc + ON sc.[object_id] = stat.[object_id] + AND sc.[stats_id] = stat.[stats_id] + JOIN sys.columns c + ON c.[object_id] = sc.[object_id] + AND c.[column_id] = sc.[column_id] + CROSS apply sys.dm_db_stats_properties(stat.[object_id], stat.stats_id) AS + sp +WHERE ( obj.[is_ms_shipped] = 0 + AND obj.[object_id] = @object_id ) + OR ( obj.[is_ms_shipped] = 0 ) +ORDER BY ss.[name], + obj.[name], + stat.[name]; + +SELECT t.SchemaName, + t.TableName, + t.[stats_id], + STUFF((SELECT ',' + s.ColumnName + FROM #StatsInfo s + WHERE s.SchemaName = t.SchemaName + AND s.TableName = t.TableName + AND s.stats_id = t.stats_id + FOR xml path('')), 1, 1, '') + AS ColumnList +INTO #ColumnList +FROM #StatsInfo AS t +GROUP BY t.SchemaName, + t.TableName, + t.stats_id; + +SELECT DISTINCT SI.SchemaName, + SI.TableName, + SI.stats_id, + SI.StatisticsName, + SI.StatisticType, + SI.IsTemporary, + CL.ColumnList AS ColumnName, + SI.IsFiltered, + SI.filter_definition, + SI.last_updated, + SI.[rows], + SI.rows_sampled, + SI.HistorgramSteps, + SI.unfiltered_rows, + SI.RowsModified +FROM #StatsInfo SI + INNER JOIN #ColumnList CL + ON SI.SchemaName = CL.SchemaName + AND SI.TableName = CL.TableName + AND SI.stats_id = CL.stats_id +ORDER BY SI.SchemaName, + SI.TableName, + SI.StatisticsName; +GO diff --git a/Scripts/Find_Weak_Passwords.sql b/Scripts/Find_Weak_Passwords.sql new file mode 100644 index 00000000..5f45c305 --- /dev/null +++ b/Scripts/Find_Weak_Passwords.sql @@ -0,0 +1,87 @@ +/* + + Find weak passwords in sys.sql_logins + 1 data set: select query. + No + Mitch Wheat + 2019-07-21 + 2019-08-16 by Konstantin Taranov + 1.1 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Find_Weak_Passwords.sql + https://mitchwheat.com/2019/07/21/sql-server-security-find-users-with-weak-passwords/ + +*/ + +SET NOCOUNT ON; + +IF OBJECT_ID('tempdb..#CommonPasswords') IS NOT NULL + DROP TABLE #CommonPasswords; + +CREATE TABLE #CommonPasswords(Password varchar(30) not null primary key); + +INSERT INTO #CommonPasswords(Password) VALUES +(''), +('123'), +('1234'), +('12345'), +('123456'), +('1234567'), +('12345678'), +('123456789'), +('1234567890'), +('qwerty'), +('qwerty123'), +('password'), +('password1'), +('password123'), +('111111'), +('1111111'), +('abc123'), +('666666'), +('7777777'), +('654321'), +('123123'), +('123321'), +('iloveyou'), +('admin'), +('nimda'), +('welcome'), +('!@#$%^&*'), +('aa123456'), +('sunshine'), +('princess' ), +('football'), +('monkey'), +('charlie'), +('donald'), +('dragon'), +('passw0rd'), +('trustno1'), +('letmein'), +('whatever'), +('hello'), +('freedom'), +('master'), +('starwars'), +('qwertyuiop'), +('qazwsx'), +('login'); + +SELECT + name, + create_date, + is_disabled +FROM + sys.sql_logins sl (nolock) + cross apply #CommonPasswords cp +WHERE + PWDCOMPARE(cp.Password, sl.password_hash) = 1 + UNION ALL + SELECT + name, + create_date, + is_disabled +FROM + sys.sql_logins sl (nolock) +WHERE + PWDCOMPARE(sl.name, sl.password_hash) = 1; -- password same as username diff --git a/Scripts/Find_and_fix_that_troublesome_Windows_Power_setting.sql b/Scripts/Find_and_fix_that_troublesome_Windows_Power_setting.sql new file mode 100644 index 00000000..98aae26c --- /dev/null +++ b/Scripts/Find_and_fix_that_troublesome_Windows_Power_setting.sql @@ -0,0 +1,95 @@ +/* + + Fix troublesome Windows Power setting + No. + No + Jeff Iannucci + 2019-04-30 + + 1.0 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Jobs_Find_And_Replace_Text.sql + http://desertdba.com/find-and-fix-that-troublesome-windows-power-setting/ + +*/ + +SET NOCOUNT ON; + + +-- Collect current configuration settings + +DECLARE +@isCmdShellEnabled bit +, @isShowAdvanced bit +, @isGettinFixed bit; + +-- Do you want to Fix this? Then SET this to 1 + +SET @isGettinFixed = 0; + +SELECT @isCmdShellEnabled = CAST(value AS BIT) + +FROM sys.configurations + +WHERE name = 'xp_cmdshell'; + +SELECT @isShowAdvanced = CAST(value AS BIT) + +FROM sys.configurations + +WHERE name = 'show advanced options'; + +IF(@isShowAdvanced = 0) BEGIN + +EXEC sp_configure 'show advanced options', 1; + +RECONFIGURE; + +END; + +IF(@isCmdShellEnabled = 0) BEGIN + +EXEC sp_configure 'xp_cmdshell', 1; + +RECONFIGURE; + +END; + +-- Run xp_cmdshell to get power settings + +IF OBJECT_ID('tempdb..#Power') IS NOT NULL DROP TABLE #Power; + +CREATE TABLE #Power (PowerScheme varchar(1000)); + +INSERT #Power (PowerScheme) + +EXEC xp_cmdshell 'powercfg /list'; + +SELECT PowerScheme FROM #Power WHERE RIGHT(LTRIM(RTRIM(PowerScheme)),1) = '*'; + +-- Set to High Performance + +IF @isGettinFixed = 1 BEGIN + +EXEC xp_cmdshell 'powercfg.exe /setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c'; + +END; + +-- If necessary, turn off 'xp_cmdshell' + +IF(@isCmdShellEnabled = 0) BEGIN + +EXEC sp_configure 'xp_cmdshell', 0; + +RECONFIGURE; + +END; + +-- If necessary, turn off 'show advanced options' + +IF(@isShowAdvanced = 0) BEGIN + +EXEC sp_configure 'show advanced options', 0; + +RECONFIGURE; + +END; diff --git a/Scripts/Finding_Host_Names_for_Failed_login_attempts.sql b/Scripts/Finding_Host_Names_for_Failed_login_attempts.sql new file mode 100644 index 00000000..c2c008d7 --- /dev/null +++ b/Scripts/Finding_Host_Names_for_Failed_login_attempts.sql @@ -0,0 +1,168 @@ +/* + + Inspects the SQL Server Error Log for failed logins, then uses xp_cmdshell to get the machine name by running nslookup against the IP address of the machine that initiated the failed login + 1 data set: temp table #errlog. + No + Konstantin Taranov + 2019-02-01 + 2019-08-09 by Konstantin Taranov + 1.0 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Finding_Host_Names_for_Failed_login_attempts.sql + https://www.sqlserverscience.com/security/finding-host-names-for-failed-login-attempts/ + + + Inspects the SQL Server Error Log for failed logins, then + uses xp_cmdshell to get the machine name by running nslookup against + the IP address of the machine that initiated the failed login. + + By: Max Vernon + https://www.sqlserverscience.com/security/finding-host-names-for-failed-login-attempts/ +*/ + +SET NOCOUNT ON; + +IF ( +SELECT CONVERT(INT, ISNULL(value, value_in_use)) AS config_value +FROM sys.configurations +WHERE name = 'xp_cmdshell') = 0 +RAISERROR (' +Please enable xp_cmdshell for this script using! +-- To allow advanced options to be changed. +EXEC sp_configure ''show advanced options'', 1 +GO +-- To update the currently configured value for advanced options. +RECONFIGURE +GO +-- To enable the feature. +EXEC sp_configure ''xp_cmdshell'', 1 +GO +-- To update the currently configured value for this feature. +RECONFIGURE +GO', 0, 1) WITH NOWAIT; + +IF OBJECT_ID(N'tempdb..#errlog', N'U') IS NULL +CREATE TABLE #errlog +( + ErrorLogFileNum int NULL + , LogDate datetime + , ProcessInfo varchar(255) + , [Text] varchar(4000) +); +TRUNCATE TABLE #errlog; + +DECLARE @ErrorLogCount int; +DECLARE @ErrorLogPath varchar(1000); +DECLARE @cmd varchar(2000); +DECLARE @output TABLE +( + txtID int NOT NULL PRIMARY KEY IDENTITY(1,1) + , txt varchar(1000) NULL +); + +SET @ErrorLogPath = CONVERT(varchar(1000), SERVERPROPERTY(N'errorlogfilename')); +SET @ErrorLogPath = LEFT(@ErrorLogPath, LEN(@ErrorLogPath) - CHARINDEX('\', REVERSE(@ErrorLogPath))); +SET @cmd = 'DIR /b "' + @ErrorLogPath + '\ERRORLOG*"'; + +INSERT INTO @output (txt) +EXEC xp_cmdshell @cmd; + +SELECT @ErrorLogCount = COUNT(*) +FROM @output o +WHERE o.txt IS NOT NULL; + +DECLARE @FileNum int; +SET @FileNum = 0 + +WHILE @FileNum < @ErrorLogCount +BEGIN + INSERT INTO #errlog (LogDate, ProcessInfo, [Text]) + EXEC sys.sp_readerrorlog @FileNum, 1; + + UPDATE #errlog + SET ErrorLogFileNum = @FileNum + WHERE ErrorLogFileNum IS NULL; + + SET @FileNum = @FileNum + 1; +END + +DECLARE @IPs TABLE( + [IP] varchar(15) NOT NULL + , Name varchar(255) +); +DECLARE @IP varchar(15); + +DECLARE cur CURSOR LOCAL FORWARD_ONLY STATIC +FOR +SELECT ClientIP = SUBSTRING(el.[Text] + , CHARINDEX('[', el.[Text]) + 9 + , CHARINDEX(']', el.[Text]) - (CHARINDEX('[', el.[Text]) + 9)) +FROM #errlog el +WHERE el.[Text] LIKE 'Login failed for user %.%' +GROUP BY SUBSTRING(el.[Text] + , CHARINDEX('[', el.[Text]) + 9 + , CHARINDEX(']', el.[Text]) - (CHARINDEX('[', el.[Text]) + 9)); +OPEN cur; +FETCH NEXT FROM cur INTO @IP; +WHILE @@FETCH_STATUS = 0 +BEGIN + DELETE FROM @output; + SET @cmd = 'nslookup ' + @IP; + INSERT INTO @output(txt) + EXEC sys.xp_cmdshell @cmd; + + DELETE + FROM @output + WHERE txt NOT LIKE 'Name: %'; + + UPDATE @output + SET txt = RIGHT(txt, LEN(txt) - 9); + + INSERT INTO @IPs (IP, Name) + SELECT @IP, txt + FROM @output; + FETCH NEXT FROM cur INTO @IP; +END +CLOSE cur; +DEALLOCATE cur; + +DELETE FROM @IPs WHERE Name IS NULL; + +--show only the most recent message for each client +SELECT MostRecentFailedLoginAttempt = MAX(el.LogDate) + , LoginName = SUBSTRING(el.[Text] + , CHARINDEX('''', el.[Text]) + 1 + , CHARINDEX('''', el.[Text], CHARINDEX('''', el.[Text]) + 1) - (CHARINDEX('''', el.[Text]) + 1)) + , FailureReason = SUBSTRING(el.[Text] + , CHARINDEX('.', el.[Text]) + 1 + , CHARINDEX('.', el.[Text], CHARINDEX('.', el.[Text]) + 1) - (CHARINDEX('.', el.[Text]) + 1)) + , ClientIP = SUBSTRING(el.[Text] + , CHARINDEX('[', el.[Text]) + 9 + , CHARINDEX(']', el.[Text]) - (CHARINDEX('[', el.[Text]) + 9)) + , ClientName = ips.Name +FROM #errlog el + LEFT JOIN @IPs ips ON (SUBSTRING(el.[Text] + , CHARINDEX('[', el.[Text]) + 9 + , CHARINDEX(']', el.[Text]) - (CHARINDEX('[', el.[Text]) + 9))) = ips.IP +WHERE el.[Text] LIKE 'Login failed for user %.%' +GROUP BY el.[Text] + , ips.Name +ORDER BY MAX(el.LogDate) DESC; + +--show all messages +SELECT el.LogDate + , LoginName = SUBSTRING(el.[Text] + , CHARINDEX('''', el.[Text]) + 1 + , CHARINDEX('''', el.[Text], CHARINDEX('''', el.[Text]) + 1) - (CHARINDEX('''', el.[Text]) + 1)) + , FailureReason = SUBSTRING(el.[Text] + , CHARINDEX('.', el.[Text]) + 1 + , CHARINDEX('.', el.[Text], CHARINDEX('.', el.[Text]) + 1) - (CHARINDEX('.', el.[Text]) + 1)) + , ClientIP = SUBSTRING(el.[Text] + , CHARINDEX('[', el.[Text]) + 9 + , CHARINDEX(']', el.[Text]) - (CHARINDEX('[', el.[Text]) + 9)) + , ClientName = ips.Name +FROM #errlog el + LEFT JOIN @IPs ips ON (SUBSTRING(el.[Text] + , CHARINDEX('[', el.[Text]) + 9 + , CHARINDEX(']', el.[Text]) - (CHARINDEX('[', el.[Text]) + 9))) = ips.IP +WHERE el.[Text] LIKE 'Login failed for user %.%' +ORDER BY el.LogDate DESC; diff --git a/Scripts/Fix_The_Broken_Dependencies_On_All_Objects.sql b/Scripts/Fix_The_Broken_Dependencies_On_All_Objects.sql new file mode 100644 index 00000000..59fc78c9 --- /dev/null +++ b/Scripts/Fix_The_Broken_Dependencies_On_All_Objects.sql @@ -0,0 +1,185 @@ +/* +Author: Karthick P.K. +Source link: https://mssqlwiki.com/2012/05/04/copy-database-wizard-or-replication-setup-might-fail-due-to-broken-dependency/ +*/ + +--Below script will fix the broken dependencies on all the objects +---------------------------------------------------------------------------- +--List of objects for which referenced objects are missing. +--ex: View created on table XYZ and table XYZ is dropped +---------------------------------------------------------------------------- +SELECT OBJECT_NAME (referencing_id),referenced_database_name, referenced_schema_name, referenced_entity_name +FROM sys.sql_expression_dependencies +WHERE referenced_entity_name not in (select name from sysobjects) + +create table #t_excluded_modules (module_name sysname) +go + +create table #t_modules_refreshed_in_end (module_name sysname) + +go + +------------------------------------------------------------------------------ +-- +-- get the list of modules whose dependencies have to be refreshed +-- +-- Comment: +-- in the list we're not considering procedures or triggers because +-- because they can be created in any order, which means they can be refreshed +-- in any order +-- +------------------------------------------------------------------------------ +create table #t_user_views_or_tables (module_id int) +insert into #t_user_views_or_tables(module_id) + select object_id from sys.objects where + type in ('V', 'FN', 'IF', 'TF') + and name not like 'MSMerge%' + and is_ms_shipped <> 1 + and name not in (select * from #t_modules_refreshed_in_end) + and name not in (select * from #t_excluded_modules) + +insert into #t_user_views_or_tables(module_id) + select object_id from sys.objects where + name in (select * from #t_modules_refreshed_in_end) + +---------------------------------------- +-- +-- get the dependency table +-- |---------------------------------| +-- | referencing_id | referenced_id | +-- | ----------------|---------------| +-- | XXX | XXX | +-- | ----------------|---------------| +-- +---------------------------------------- +Declare @module int, @message varchar(1000), @str nvarchar(1000) +create table #t_dependency_table (referencing_id int, referenced_id int) +DECLARE modules_cursor CURSOR FOR SELECT module_id FROM #t_user_views_or_tables +open modules_cursor +fetch next from modules_cursor into @module + +IF @@FETCH_STATUS <> 0 + PRINT ' <> No module to refresh' + +while @@FETCH_STATUS = 0 + begin + select @str = quotename(schema_name(objectproperty(@module, 'schemaid'))) + '.' + quotename(object_name(@module)) + select @message = ' trying to refresh ' + @str + print @message + exec sys.sp_refreshsqlmodule @str + select @message = ' ' + @str + ' was refreshed' + print @message + + insert into #t_dependency_table (referencing_id, referenced_id) + select distinct object_id as referencing_id, referenced_major_id as referenced_id + from sys.sql_dependencies + where object_id <> referenced_major_id -- to avoid self recursion for functions + and object_id = @module + + fetch next from modules_cursor into @module + end + +close modules_cursor +deallocate modules_cursor + +------------------------------------------------------------------------------------------- +-- +-- get the the bottom of the dependency list i.e. independent modules +-- i.e. +-- get the list of referenced_ids in the dependency table which +-- don't occur in the referencing_ids column +-- +-- Comment: +-- if there are circular dependencies then the few modules which form a circular dependency +-- would be ignored in the independent modules list +-- +------------------------------------------------------------------------------------------- +create table #t_independent_modules (modules int) + +insert into #t_independent_modules (modules) + select #t_dependency_table.referenced_id from + #t_dependency_table left outer join #t_dependency_table t2 + on #t_dependency_table.referenced_id = t2.referencing_id + where + t2.referencing_id is NULL + +------------------------------------------------------------------------------------------- +-- +-- build the ordered list of dependencies starting with the independent modules +-- in the beginning first few rows, ones dependent on it in the following rows and so on... +-- +-- there can be tricky cases of dependencies such as +-- V1 -> V2 -> V3 +-- | ^ +-- +-----------+ +-- +-- in the above example the refresh order would be V3, V1, V2, V1. +-- note that V1 is being refreshed twice, the last refresh of V1 after V2 is important. +-- +------------------------------------------------------------------------------------------- +create table #t_final_dependency_list (id_num int IDENTITY(1,1), modules int) + +while exists (select * from #t_independent_modules) + begin + -- append the set of independent modules into a list + insert into #t_final_dependency_list select * from #t_independent_modules + + -- get the set of dependent modules + select distinct #t_dependency_table.referencing_id into #temp_table + from #t_dependency_table + where #t_dependency_table.referenced_id in (select * from #t_independent_modules) + + -- clear up the list of independent modules + truncate table #t_independent_modules + + -- the dependent modules now become the independent modules + insert into #t_independent_modules select * from #temp_table + + -- delete the dependent modules list + drop table #temp_table + end + +----------------------------------------------------------- +-- +-- refresh the modules once more but in the right order now +-- +----------------------------------------------------------- +declare modules_cursor_final cursor for + select modules from #t_final_dependency_list order by #t_final_dependency_list.id_num + +open modules_cursor_final +fetch next from modules_cursor_final into @module + +IF @@FETCH_STATUS <> 0 + PRINT ' <> No module to refresh' + +while @@FETCH_STATUS = 0 + begin + if (select type from sys.objects where object_id = @module) in ('V', 'FN', 'IF', 'TF') + and (select is_schema_bound from sys.sql_modules where object_id = @module) = 0 + begin + select @str = quotename(schema_name(objectproperty(@module, 'schemaid'))) + '.' + quotename(object_name(@module)) + select @message = ' trying to finally, once more, refresh ' + @str + print @message + exec sys.sp_refreshsqlmodule @str + select @message = ' ' + @str + ' was finally refreshed once again' + print @message + end + + fetch next from modules_cursor_final into @module + end + +close modules_cursor_final +DEALLOCATE modules_cursor_final; + +----------- +-- +-- cleanup +-- +----------- +drop table #t_excluded_modules; +drop table #t_modules_refreshed_in_end; +drop table #t_user_views_or_tables; +drop table #t_dependency_table; +drop table #t_independent_modules; +drop table #t_final_dependency_list; diff --git a/Scripts/Foreign_Keys_With_No_Index.sql b/Scripts/Foreign_Keys_With_No_Index.sql new file mode 100644 index 00000000..20a83b45 --- /dev/null +++ b/Scripts/Foreign_Keys_With_No_Index.sql @@ -0,0 +1,29 @@ +/* +Author: Drupal +Original link: http://sqlworldwide.com/tsql-to-find-status-of-sql-server-statistics/ +*/ + + +WITH fk_cte AS ( + SELECT OBJECT_NAME(fk.referenced_object_id) pk_table + , c2.name pk_column + , kc.name pk_index_name + , OBJECT_NAME(fk.parent_object_id) fk_table + , c.name fk_column + , fk.name fk_name + , CASE WHEN i.object_id IS NOT NULL THEN 1 ELSE 0 END does_fk_has_index + , i.is_primary_key is_fk_a_pk_also + , i.is_unique is_index_on_fk_unique + , fk.* + FROM sys.foreign_keys AS fk + INNER JOIN sys.foreign_key_columns fkc ON fkc.constraint_object_id = fk.object_id + INNER JOIN sys.columns AS c ON c.object_id = fk.parent_object_id AND c.column_id = fkc.parent_column_id + LEFT JOIN sys.columns AS c2 ON c2.object_id = fk.referenced_object_id AND c2.column_id = fkc.referenced_column_id + LEFT JOIN sys.key_constraints AS kc ON kc.parent_object_id = fk.referenced_object_id AND kc.type = 'PK' + LEFT JOIN sys.index_columns AS ic ON ic.object_id = c.object_id AND ic.column_id = c.column_id + LEFT JOIN sys.indexes AS i ON i.object_id = ic.object_id AND i.index_id = ic.index_id + ) +SELECT * FROM fk_cte + LEFT JOIN sys.dm_db_partition_stats ps on ps.object_id = fk_cte.parent_object_id and ps.index_id <= 1 +WHERE does_fk_has_index = 0 -- and fk_table = 'LineItems' +ORDER BY used_page_count DESC; diff --git a/Scripts/Generate_BIML_Script.sql b/Scripts/Generate_BIML_Script.sql new file mode 100644 index 00000000..2114ee35 --- /dev/null +++ b/Scripts/Generate_BIML_Script.sql @@ -0,0 +1,90 @@ +/* +Author: David Stein +Original link: http://www.made2mentor.com/2019/06/generating-biml-scripts-using-t-sql/ +*/ + +DECLARE @SrcQuery nvarchar(4000); +DECLARE @FeedName nvarchar(25); + + +SELECT @SrcQuery = 'SELECT TOP(100) FROM sys.objects;', @FeedName = 'Objects'; + +IF OBJECT_ID('tempdb..#FileFormatMetadata') IS NOT NULL DROP TABLE #FileFormatMetadata; + +SELECT + t.[Column Name] +,t.[SQL DT] +,CASE +WHEN t.[SQL DT] in ('char', 'varchar','text') THEN (t.max_length) +WHEN t.[SQL DT] in ('nchar', 'nvarchar','ntext') THEN (t.max_length/2) +ELSE 0 END [Length] +,CASE +WHEN t.[SQL DT] = 'smallint' THEN 'Int16' +WHEN t.[SQL DT] = 'tinyint' THEN 'Byte' +WHEN t.[SQL DT] = 'int' THEN 'Int32' +WHEN t.[SQL DT] = 'bigint' THEN 'Int64' +WHEN t.[SQL DT] = 'char' THEN 'AnsiStringFixedLength' +WHEN t.[SQL DT] = 'varchar' THEN 'AnsiString' +WHEN t.[SQL DT] = 'nchar' THEN 'StringFixedLength' +WHEN t.[SQL DT] = 'nvarchar' THEN 'String' +WHEN t.[SQL DT] = 'date' THEN 'Date' +WHEN t.[SQL DT] = 'datetime' THEN 'DateTime' +WHEN t.[SQL DT] = 'datetime2' THEN 'DateTime2' +WHEN t.[SQL DT] = 'datetimeoffset' THEN 'DateTimeOffset' +WHEN t.[SQL DT] = 'smalldatetime' THEN 'DateTime' +WHEN t.[SQL DT] = 'time' THEN 'Time' +WHEN t.[SQL DT] = 'decimal' THEN 'Decimal' +WHEN t.[SQL DT] = 'numeric' THEN 'Decimal' +WHEN t.[SQL DT] = 'bit' THEN 'Boolean' +WHEN t.[SQL DT] = 'float' THEN 'Double' +WHEN t.[SQL DT] = 'real' THEN 'Single' +WHEN t.[SQL DT] = 'money' THEN 'Currency' +WHEN t.[SQL DT] = 'smallmoney' THEN 'Currency' +WHEN t.[SQL DT] = 'text' THEN 'AnsiString' +WHEN t.[SQL DT] = 'ntext' THEN 'String' +ELSE NULL END [Biml Data Type] +,t.ColumnOrdinal +,@FeedName FeedName +INTO #FileFormatMetadata +FROM (SELECT name [Column Name] + ,CASE WHEN CHARINDEX('(',system_type_name) = 0 THEN system_type_name + ELSE left(system_type_name, CHARINDEX('(',system_type_name) - 1) + END [SQL DT] + ,max_length + ,column_ordinal ColumnOrdinal + FROM sys.dm_exec_describe_first_result_set(@SrcQuery, NULL, 1) where [name] is not NULL and is_hidden = 0) t + +SELECT CAST(REPLACE(CAST( ( + SELECT + (SELECT 'conn_ff_' + @FeedName "@Name" + ,'C:\FileExport\' + @FeedName + '.csv' "@FilePath" + ,'fff_' + @FeedName "@FileFormat" + FOR XML PATH('FlatFileConnection'), type, root('Connections')) + ,(SELECT 'Export ' + @FeedName "@Name" + , 'Linear' "@ConstraintMode" + ,'DontSaveSensitive' "@ProtectionLevel" + ,(SELECT + 'DFT Load File' "@Name" + ,'OLE_SRC ' + @FeedName "Transformations/OleDbSourceName/@Name" + ,'connNorthwind' "Transformations/OleDbSourceName/@ConnectionName" + ,@SrcQuery "Transformations/OleDbSourceName/DirectInput" + ,'FF_DEST ' + @FeedName "Transformations/FlatFileDestination/@Name" + ,'conn_ff_ ' + @FeedName "Transformations/FlatFileDestination/@ConnectionName" + ,'true' "Transformations/FlatFileDestination/@Overwrite" + ,'false' "Transformations/FlatFileDestination/@ValidateExternalMetadata" + FOR XML PATH('Dataflow'),TYPE, root('Tasks')) + FOR XML PATH('Package'), TYPE,ROOT('Packages')) + ,(SELECT 'fff_' + @FeedName "@Name" + , 'Delmited' "@FlatFileType" + ,'true' "@ColumnNamesInFirstDataRow" + ,'_x0022_' "@TextQualifier" + ,(SELECT [Column Name] "@Name" + ,[Biml Data Type] "@DataType" + ,Length "@Length" + ,CASE WHEN ColumnOrdinal = (SELECT MAX(ColumnOrdinal) FROM #FileFormatMetadata) THEN 'CRLF' + ELSE 'Comma' END "@Delimiter" + from #FileFormatMetadata + FOR XML PATH('Column'), type, root('Columns')) + FOR XML PATH('FlatFileFormat'), type, root('FileFormats')) +FOR XML PATH ('Biml') +) AS nvarchar(MAX)), '', '') AS XML); diff --git a/Scripts/Generate_table_definition_to_match_query.sql b/Scripts/Generate_table_definition_to_match_query.sql index 9f492fd7..dde81a2b 100644 --- a/Scripts/Generate_table_definition_to_match_query.sql +++ b/Scripts/Generate_table_definition_to_match_query.sql @@ -1,20 +1,27 @@ /* -Author: SQL Undercover -Source link: https://sqlundercover.com/2017/08/21/undercover-toolbox-generate-a-temporary-table-definition-to-match-the-resultset-of-a-query/ +Created: 2017-08-21 by SQL Undercover +Modified: 2019-03-26 by Konstantin Taranov +Original link: https://sqlundercover.com/2017/08/21/undercover-toolbox-generate-a-temporary-table-definition-to-match-the-resultset-of-a-query/ +Source link: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Generate_table_definition_to_match_query.sql */ SET NOCOUNT ON; - + DECLARE @Query VARCHAR(MAX) = 'select * from sys.databases;'; DECLARE @TempTableName VARCHAR(128) = '#temptable'; DECLARE @ColumnList VARCHAR(MAX); - -SELECT @ColumnList = STUFF((SELECT ',' + name + ' ' + system_type_name + ' ' + -CASE is_nullable WHEN 0 THEN 'NOT NULL' ELSE 'NULL' END -+ CHAR(10) -FROM sys.dm_exec_describe_first_result_set(@Query, NULL, 0) -FOR XML PATH('')) ,1,1,''); - + +SELECT @ColumnList = STUFF( + (SELECT ' , ' + name + ' ' + system_type_name + ' ' + + CASE is_nullable + WHEN 0 THEN 'NOT NULL' + ELSE 'NULL' + END + CHAR(10) + FROM sys.dm_exec_describe_first_result_set(@Query, NULL, 0) + FOR XML PATH('') + ) + ,1 ,1, ''); + PRINT 'CREATE TABLE ' + @TempTableName + '(' PRINT @ColumnList; -PRINT(')'); \ No newline at end of file +PRINT(');'); diff --git a/Scripts/Get_Amazon_RDS_Instance_Size.sql b/Scripts/Get_Amazon_RDS_Instance_Size.sql new file mode 100644 index 00000000..75cb23b5 --- /dev/null +++ b/Scripts/Get_Amazon_RDS_Instance_Size.sql @@ -0,0 +1,37 @@ +/* + + Get Amazon RDS Instance Size using TSQL + 1 data set: InstanceSize. + No + Mitch Wheat + 2008-07-27 + 2019-07-02 by Konstantin Taranov + 1.0 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Get_Amazon_RDS_Instance_Size.sql + https://mitchwheat.com/2019/07/27/amazon-rds-sql-server-get-instance-size-using-tsql/ + +*/ + +IF OBJECT_ID('tempdb..#AmazonErrorLog') IS NOT NULL + DROP TABLE #AmazonErrorLog; + +CREATE TABLE #AmazonErrorLog +( + LogDate datetime2, + ProcessInfo nvarchar(20), + [Text] nvarchar(1000) +); + +DECLARE @pattern nvarchar(30) = N'System Model:'; + +INSERT INTO #AmazonErrorLog +EXEC rdsadmin.dbo.rds_read_error_log; + +IF @@ROWCOUNT > 0 +BEGIN + SELECT InstanceSize = REPLACE(CAST(SUBSTRING([Text], LEN(@pattern) + 1 + PATINDEX (N'%' + @pattern + N'%', [Text]), 100), '''', '') AS varchar(100)) + FROM #AmazonErrorLog + WHERE PATINDEX (N'%' + @pattern + N'%', [Text]) > 0 +END; + +DROP TABLE #AmazonErrorLog; diff --git a/Scripts/Get_CPU_Usage_Per_Database.sql b/Scripts/Get_CPU_Usage_Per_Database.sql new file mode 100644 index 00000000..c039e63a --- /dev/null +++ b/Scripts/Get_CPU_Usage_Per_Database.sql @@ -0,0 +1,37 @@ +/* + + Get CPU Usage Per Database + 1 data set with 2 columns: database name and CPUTimeAsPercentage. + No + Eli Leiba + 2019-11-05 + 2019-11-05 + 1.0 + https://www.mssqltips.com/sqlservertip/6195/sql-server-function-to-measure-cpu-usage-per-database/ + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Get_CPU_Usage_Per_Database.sql + +*/ + +SELECT + T.[Database] + , T.CPUTimeAsPercentage + FROM + (SELECT + [Database], + CONVERT (DECIMAL (6, 3), [CPUTimeInMiliSeconds] * 1.0 / + SUM ([CPUTimeInMiliSeconds]) OVER () * 100.0) AS [CPUTimeAsPercentage] + FROM + (SELECT + dm_execplanattr.DatabaseID, + DB_Name(dm_execplanattr.DatabaseID) AS [Database], + SUM (dm_execquerystats.total_worker_time) AS CPUTimeInMiliSeconds + FROM sys.dm_exec_query_stats dm_execquerystats + CROSS APPLY + (SELECT + CONVERT (INT, value) AS [DatabaseID] + FROM sys.dm_exec_plan_attributes(dm_execquerystats.plan_handle) + WHERE attribute = N'dbid' + ) dm_execplanattr + GROUP BY dm_execplanattr.DatabaseID + ) AS CPUPerDb + ) AS T; diff --git a/Scripts/Get_Coulmn_Statistics_By_Name.sql b/Scripts/Get_Coulmn_Statistics_By_Name.sql new file mode 100644 index 00000000..cc9c5190 --- /dev/null +++ b/Scripts/Get_Coulmn_Statistics_By_Name.sql @@ -0,0 +1,49 @@ +/* + + Get table column min, max and other parameters + 1 data set + No + Konstantin Taranov + 2019-11-20 + 2019-11-30 by Konstantin Taranov + 1.2 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Get_Coulmn_Statistics_By_Name.sql + +*/ + +DECLARE @columnName sysname = N'ModifiedDate'; +DECLARE @tsql nvarchar(max) = N''; +DECLARE @sep nvarchar(50) = N' UNION ALL '; +DECLARE @crlf nvarchar(10) = CHAR(13) + CHAR(10); +DECLARE @debug bit = 0; +DECLARE @errMsg nvarchar(900) = N'In using database "' + DB_NAME() + + '" no tables with colum name equal "' + @columnName + + '". Choose another database or fix @columnName variable.'; + + +IF NOT EXISTS (SELECT 1 FROM sys.all_columns WHERE "name" = @columnName) +BEGIN + PRINT(@errMsg); +END +ELSE +BEGIN + SELECT -- TOP(2) + @tsql = @tsql + N'SELECT MAX(_C_) AS _C_Max, MIN(_C_) _C_Min, COUNT(_C_) AS _C_Count, ''' + + SCHEMA_NAME(o.schema_id) + ''' AS SchemaName,''' + + OBJECT_NAME(allc.object_id) + ''' AS TableName' + + ' FROM ' + + SCHEMA_NAME(o.schema_id) + '.' + OBJECT_NAME(allc.object_id) + + @crlf + @sep + FROM sys.all_columns AS allc + INNER JOIN sys.objects AS o + ON allc.object_id = o.object_id + WHERE allc."name" = 'ModifiedDate'; + + SET @tsql = REPLACE(@tsql, N'_C_', @columnName); + SET @tsql = LEFT(@tsql, (DATALENGTH(@tsql) - DATALENGTH(@sep)) / 2) + ' ORDER BY 1 DESC'; + + IF @debug = 1 + SELECT @tsql; + ELSE + EXEC sp_executesql @tsql; +END; diff --git a/Scripts/Get_Create_or_Alter_Index_Progress.sql b/Scripts/Get_Create_or_Alter_Index_Progress.sql new file mode 100644 index 00000000..8f812dd5 --- /dev/null +++ b/Scripts/Get_Create_or_Alter_Index_Progress.sql @@ -0,0 +1,47 @@ +/* + + Track progrees CREATE or ALTER Index commands + 1 data set + No + Solomon Rutzky + 2019-12-02 + 2019-12-02 + 1.0 + https://dba.stackexchange.com/a/139225/107045 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Get_Create_or_Alter_Index_Progress.sql + +*/ + +DECLARE @SPID int = 51; + +WITH agg AS +( + SELECT SUM(qp.[row_count]) AS [RowsProcessed], + SUM(qp.[estimate_row_count]) AS [TotalRows], + MAX(qp.last_active_time) - MIN(qp.first_active_time) AS [ElapsedMS], + MAX(IIF(qp.[close_time] = 0 AND qp.[first_row_time] > 0, + [physical_operator_name], + N'')) AS [CurrentStep] + FROM sys.dm_exec_query_profiles qp + WHERE qp.[physical_operator_name] IN (N'Table Scan', N'Clustered Index Scan', + N'Index Scan', N'Sort') + AND qp.[session_id] = @SPID +), comp AS +( + SELECT *, + ([TotalRows] - [RowsProcessed]) AS [RowsLeft], + ([ElapsedMS] / 1000.0) AS [ElapsedSeconds] + FROM agg +) +SELECT [CurrentStep], + [TotalRows], + [RowsProcessed], + [RowsLeft], + CONVERT(DECIMAL(5, 2), + (([RowsProcessed] * 1.0) / [TotalRows]) * 100) AS [PercentComplete], + [ElapsedSeconds], + (([ElapsedSeconds] / [RowsProcessed]) * [RowsLeft]) AS [EstimatedSecondsLeft], + DATEADD(SECOND, + (([ElapsedSeconds] / [RowsProcessed]) * [RowsLeft]), + GETDATE()) AS [EstimatedCompletionTime] +FROM comp; diff --git a/Scripts/Get_Identity_Column_Information.sql b/Scripts/Get_Identity_Column_Information.sql new file mode 100644 index 00000000..ec739483 --- /dev/null +++ b/Scripts/Get_Identity_Column_Information.sql @@ -0,0 +1,88 @@ +/* + + Create JOIN query between multiple tables dynamically. + SELECT statement from input table with INNER JOINS for all tables having foreign consttraints with input table. + Does not properly generate alias for case with multiply foreign keys for one table + Konstantin Taranov + 2019-04-24 + 2019-04-25 by Konstantin Taranov + 1.0 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Get_Identity_Column_Information.sql + +*/ + + +IF OBJECT_ID('tempdb..#IdentityInfo', 'U') IS NOT NULL DROP TABLE #IdentityInfo; +IF OBJECT_ID('tempdb..#IdentityStats', 'U') IS NOT NULL DROP TABLE #IdentityStats; +GO + +DECLARE @tsql nvarchar(max) = N''; + +SELECT IC.object_id AS ObjectID + , SS.name AS SchemaName + , TN.name AS TableName + , IC.name AS ColumnName + , TYPE_NAME(IC.system_type_id) AS ColumnDataType + , DTM.DataTypeMinValue + , DTM.DataTypeMaxValue + , IC.seed_value AS IdentitySeed + , IC.increment_value AS IdentityIncrement + , IC.last_value AS LastIdentityValue + , DPS.NumberOfRows + INTO #IdentityInfo + FROM sys.identity_columns AS IC + INNER JOIN sys.tables AS TN ON IC.object_id = TN.object_id + INNER JOIN sys.schemas AS SS ON TN.schema_id = SS.schema_id + INNER JOIN ( + VALUES + ('tinyint', 0, 255), + ('smallint', -32768, 32767), + ('int', -2147483648, 2147483647), + ('bigint', -9223372036854775808, 9223372036854775807) + ) AS DTM(DataType, DataTypeMinValue, DataTypeMaxValue) ON TYPE_NAME(IC.system_type_id) = DTM.DataType + INNER JOIN ( + SELECT object_id + , SCHEMA_NAME(object_id) AS SchemaName + , OBJECT_NAME(object_id) AS TableName + , SUM(row_count) AS NumberOfRows + FROM sys.dm_db_partition_stats + WHERE index_id < 2 + GROUP BY object_id, SCHEMA_NAME(object_id), OBJECT_NAME(object_id) + ) AS DPS ON IC.object_id = DPS.object_id; + +IF (SELECT COUNT(1) FROM #IdentityInfo) = 0 +THROW 50001, 'You do not have any table with identity column in current database.', 1; + +CREATE TABLE #IdentityStats( + ObjectID bigint + , SchemaName sysname + , TableName sysname + , IdentityColumnMinValue bigint + , IdentityColumnMaxValue bigint + , IdentityColumnAvgValue bigint +); + +SELECT @tsql = @tsql + N'INSERT INTO #IdentityStats SELECT ' + + CAST(t.ObjectID AS nvarchar(30)) + N' AS ObjectID, ''' + + t.SchemaName + N''' AS SchemaName, ''' + t.TableName + N''' AS TableName' + + N', MIN([' + t.ColumnName + N']) AS IdentityColumnMinValue' + + N', MAX([' + t.ColumnName + N']) AS IdentityColumnMaxValue' + + N', AVG(CAST([' + t.ColumnName + N'] AS BIGINT)) AS IdentityColumnAvgValue' + + N' FROM ' + QUOTENAME(t.SchemaName) + N'.' + QUOTENAME(t.TableName) + N' (NOLOCK);' + CHAR(13) +FROM #IdentityInfo AS t; + +/* + // PRINT truncate strings to 4000 char limit, below we using XML trick to solve this issue +*/ +SELECT @tsql FOR XML PATH(''); + +EXEC sp_executesql @tsql; + +SELECT ii.* + , ids.IdentityColumnMaxValue + , ids.IdentityColumnMinValue + , ids.IdentityColumnAvgValue + , (CONVERT(decimal(15,2), CONVERT(bigint, ii.LastIdentityValue) * 100 / ii.DataTypeMaxValue)) AS ReachMaxValuePercent +FROM #IdentityInfo AS ii +INNER JOIN #IdentityStats AS ids ON ii.ObjectID = ids.ObjectID +ORDER BY ReachMaxValuePercent DESC; diff --git a/Scripts/Get_Latest_Success_and_Failure_Login.sql b/Scripts/Get_Latest_Success_and_Failure_Login.sql new file mode 100644 index 00000000..9316bb70 --- /dev/null +++ b/Scripts/Get_Latest_Success_and_Failure_Login.sql @@ -0,0 +1,83 @@ +/* + + Get latest success and failure logins. + Latest success and failure logins. + 2020-04-08 by Kenneth Fisher + 2020-04-17 by Konstantin Taranov + 1.1 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Get_Latest_Success_and_Failure_Login.sql + https://sqlstudies.com/2020/04/08/has-this-login-been-used-recently/ + +*/ + + +IF OBJECT_ID(N'tempdb..#LogInfo', N'U') IS NOT NULL DROP TABLE #LogInfo; + +DECLARE @searchstring1 nvarchar(500) = ''; +DECLARE @searchstring2 nvarchar(500) = ''; +DECLARE @Limit int = 10000; + +---------------------------------------------------------------------- +-- This part of the code was found here: +-- https://ask.sqlservercentral.com/questions/99484/number-of-error-log-files.html + +DECLARE @FileList AS TABLE ( + subdirectory NVARCHAR(4000) NOT NULL + ,DEPTH BIGINT NOT NULL + ,[FILE] BIGINT NOT NULL +); + +DECLARE @ErrorLog NVARCHAR(4000), @ErrorLogPath NVARCHAR(4000); +SELECT @ErrorLog = CAST(SERVERPROPERTY(N'errorlogfilename') AS NVARCHAR(4000)); +SELECT @ErrorLogPath = SUBSTRING(@ErrorLog, 1, LEN(@ErrorLog) - CHARINDEX(N'\', REVERSE(@ErrorLog))) + N'\'; + +INSERT INTO @FileList +EXEC xp_dirtree @ErrorLogPath, 0, 1; + +DECLARE @NumberOfLogfiles INT; +SET @NumberOfLogfiles = (SELECT COUNT(*) FROM @FileList WHERE [@FileList].subdirectory LIKE N'ERRORLOG%'); +-- SELECT @NumberOfLogfiles; +If @Limit IS NOT NULL AND @NumberOfLogfiles > @Limit + SET @NumberOfLogfiles = @Limit; +---------------------------------------------------------------------- + +CREATE TABLE #LogInfo ( + LogDate datetime, + ProcessInfo nvarchar(500), + ErrorText nvarchar(max) +); + +DECLARE @p1 INT = 0; + +WHILE @p1 < @NumberOfLogfiles +BEGIN + -- P1 is the file number starting at 0 + DECLARE + @p2 INT = 1, + -- P2 1 for SQL logs, 2 for SQL Agent logs + @p3 NVARCHAR(255) = @searchstring1, + -- P3 is a value to search on + @p4 NVARCHAR(255) = @searchstring2; + -- P4 is another search value + +BEGIN TRY + INSERT INTO #LogInfo + EXEC sys.xp_readerrorlog @p1, @p2, @p3, @p4; +END TRY +BEGIN CATCH + PRINT 'Error occurred processing file ' + CAST(@p1 as varchar(10)); +END CATCH + +SET @p1 = @p1 + 1; +END; + +SELECT + UserList.UserName + , MAX(CASE WHEN #LogInfo.ErrorText LIKE '%succeeded%' THEN LogDate ELSE NULL END) AS LatestSuccess + , MAX(CASE WHEN #LogInfo.ErrorText LIKE '%failed%' THEN LogDate ELSE NULL END) AS LatestFailure +FROM #LogInfo +CROSS APPLY (SELECT REPLACE(REPLACE(ErrorText,'Login succeeded for user ''',''),'Login failed for user ''','')) RemoveFront(ErrorText) +CROSS APPLY (SELECT SUBSTRING(RemoveFront.ErrorText,1,CHARINDEX('''', RemoveFront.ErrorText)-1)) AS UserList(UserName) +WHERE #LogInfo.ProcessInfo = 'Logon' +and #LogInfo.ErrorText like 'Login%' +GROUP BY UserList.UserName; diff --git a/Scripts/Get_Opened_Transactions_Info.sql b/Scripts/Get_Opened_Transactions_Info.sql new file mode 100644 index 00000000..dacc7a22 --- /dev/null +++ b/Scripts/Get_Opened_Transactions_Info.sql @@ -0,0 +1,46 @@ +/* + + Get opened transactions information + 1 data set with information about opened transactions. + 2017-01-01 by Paul Randal + 2020-11-19 by Konstantin Taranov + 1.1 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Get_Opened_Transactions_Info.sql + https://sqlstudies.com/2013/09/05/a-t-sql-query-to-get-current-job-activity/ + +*/ + +SELECT + s_tst.session_id + , s_es.login_name AS "Login Name" + , DB_NAME (s_tdt.database_id) AS "Database" + , s_tdt.database_transaction_begin_time AS "Begin Time" + , s_tdt.database_transaction_log_bytes_used AS "Log Bytes" + , s_tdt.database_transaction_log_bytes_reserved AS "Log Reserved Bytes" + , s_est.text AS "Last T-SQL Text" + , s_eqp.query_plan AS "Last Plan" +FROM + sys.dm_tran_database_transactions s_tdt +INNER JOIN + sys.dm_tran_session_transactions s_tst +ON + s_tst.transaction_id = s_tdt.transaction_id +INNER JOIN + sys.dm_exec_sessions s_es +ON + s_es.session_id = s_tst.session_id +INNER JOIN + sys.dm_exec_connections s_ec +ON + s_ec.session_id = s_tst.session_id +LEFT OUTER JOIN + sys.dm_exec_requests s_er +ON + s_er.session_id = s_tst.session_id +CROSS APPLY + sys.dm_exec_sql_text (s_ec.most_recent_sql_handle) AS s_est +OUTER APPLY + sys.dm_exec_query_plan (s_er.plan_handle) AS s_eqp +ORDER BY + s_tdt.database_transaction_begin_time ASC; +GO diff --git a/Scripts/Get_SQLServer_Startup_Parameters.sql b/Scripts/Get_SQLServer_Startup_Parameters.sql new file mode 100644 index 00000000..e50f4dbf --- /dev/null +++ b/Scripts/Get_SQLServer_Startup_Parameters.sql @@ -0,0 +1,16 @@ +DECLARE @RegHive VARCHAR(50), + @RegKey VARCHAR(100); + +SET @RegHive = 'HKEY_LOCAL_MACHINE'; +SET @RegKey = 'Software\Microsoft\MSSQLSERVER\MSSQLServer\Parameters'; + +-- Get all of the arguments / parameters when starting up the service. +DECLARE @SQLArgs TABLE ( + Value VARCHAR(50), + Data VARCHAR(500), + ArgNum AS CONVERT(INTEGER, REPLACE(Value, 'SQLArg', ''))); + +INSERT INTO @SQLArgs + EXECUTE master.sys.xp_instance_regenumvalues @RegHive, @RegKey; + +SELECT * FROM @SQLArgs; \ No newline at end of file diff --git a/Scripts/Get_SQL_Server_Agent_Information.sql b/Scripts/Get_SQL_Server_Agent_Information.sql new file mode 100644 index 00000000..5433b1ca --- /dev/null +++ b/Scripts/Get_SQL_Server_Agent_Information.sql @@ -0,0 +1,30 @@ +/* +Author: sqlity.net +Source link: http://sqlity.net/en/1868/identify-sql-server-service-account-in-t-sql/ +*/ + +IF CAST(SERVERPROPERTY('ProductMajorVersion') AS INT) < 10 +BEGIN + DECLARE @sn NVARCHAR(128); + EXEC master.dbo.xp_regread + 'HKEY_LOCAL_MACHINE', + 'SYSTEM\CurrentControlSet\services\SQLSERVERAGENT', + 'ObjectName', + @sn OUTPUT; + SELECT @sn; +END; +ELSE +BEGIN + SELECT DSS.servicename + , DSS.startup_type_desc + , DSS.status_desc + , DSS.last_startup_time + , DSS.service_account + , DSS.is_clustered + , DSS.cluster_nodename + , DSS.filename + , DSS.startup_type + , DSS.status + , DSS.process_id + FROM sys.dm_server_services AS DSS; +END; diff --git a/Scripts/Get_SQL_Server_Backup_Directory.sql b/Scripts/Get_SQL_Server_Backup_Directory.sql new file mode 100644 index 00000000..0b501fab --- /dev/null +++ b/Scripts/Get_SQL_Server_Backup_Directory.sql @@ -0,0 +1,11 @@ +DECLARE @HkeyLocal nvarchar(18) = N'HKEY_LOCAL_MACHINE'; +DECLARE @MSSqlServerRegPath nvarchar(31) = N'SOFTWARE\Microsoft\MSSQLServer'; +DECLARE @InstanceRegPath sysname = @MSSqlServerRegPath + N'\MSSQLServer'; + +DECLARE @BackupDirectory nvarchar(512) +if 1=isnull(cast(SERVERPROPERTY('IsLocalDB') as bit), 0) +SET @BackupDirectory=cast(SERVERPROPERTY('instancedefaultdatapath') as nvarchar(512)) +else +EXEC master.dbo.xp_instance_regread @HkeyLocal, @InstanceRegPath, N'BackupDirectory', @BackupDirectory OUTPUT; + +SELECT @BackupDirectory AS SQLServerBackupDirectory; diff --git a/Scripts/Get_SQL_Server_NUMA_Memory.sql b/Scripts/Get_SQL_Server_NUMA_Memory.sql new file mode 100644 index 00000000..9645c6ae --- /dev/null +++ b/Scripts/Get_SQL_Server_NUMA_Memory.sql @@ -0,0 +1,54 @@ +/* +https://sql-sasquatch.blogspot.com/2019/09/placeholder.html +*/ + +WITH tgt AS (SELECT instance_name, cntr_value + FROM sys.dm_os_performance_counters + WHERE counter_name = 'Target Node Memory (KB)' + UNION ALL + SELECT 'TOTAL', cntr_value + FROM sys.dm_os_performance_counters + WHERE counter_name = 'Target Server Memory (KB)'), +tot AS (SELECT instance_name, cntr_value + FROM sys.dm_os_performance_counters + WHERE counter_name = 'Total Node Memory (KB)' + UNION ALL + SELECT 'TOTAL', cntr_value + FROM sys.dm_os_performance_counters + WHERE counter_name = 'Total Server Memory (KB)'), +dbc AS (SELECT instance_name, cntr_value + FROM sys.dm_os_performance_counters + WHERE counter_name = 'Database Node Memory (KB)' + UNION ALL + SELECT 'TOTAL', cntr_value + FROM sys.dm_os_performance_counters + WHERE counter_name = 'Database Cache Memory (KB)'), +stl AS (SELECT instance_name, cntr_value + FROM sys.dm_os_performance_counters + WHERE counter_name = 'Stolen Node Memory (KB)' + UNION ALL + SELECT 'TOTAL', cntr_value + FROM sys.dm_os_performance_counters + WHERE counter_name = 'Stolen Server Memory (KB)'), +fre AS (SELECT instance_name, cntr_value + FROM sys.dm_os_performance_counters + WHERE counter_name = 'Free Node Memory (KB)' + UNION ALL + SELECT 'TOTAL', cntr_value + FROM sys.dm_os_performance_counters + WHERE counter_name = 'Free Memory (KB)'), +frn AS (SELECT instance_name, cntr_value + FROM sys.dm_os_performance_counters + WHERE counter_name = 'Foreign Node Memory (KB)' + UNION ALL + SELECT 'TOTAL', cntr_value = CONVERT(INT, NULL)) +SELECT tgt.instance_name, target_kb = tgt.cntr_value, + total_kb = tot.cntr_value, dbCache_kb = dbc.cntr_value, + stolen_kb = stl.cntr_value, free_kb = fre.cntr_value, + foreign_kb = frn.cntr_value +FROM tgt +INNER JOIN tot ON tgt.instance_name = tot.instance_name +INNER JOIN frn ON tgt.instance_name = frn.instance_name +INNER JOIN dbc ON tgt.instance_name = dbc.instance_name +INNER JOIN stl ON tgt.instance_name = stl.instance_name +INNER JOIN fre ON tgt.instance_name = fre.instance_name; diff --git a/Scripts/Get_Table_and_Index_Storage_Size.sql b/Scripts/Get_Table_and_Index_Storage_Size.sql new file mode 100644 index 00000000..f87985fa --- /dev/null +++ b/Scripts/Get_Table_and_Index_Storage_Size.sql @@ -0,0 +1,56 @@ +/* + + Count tables and indexes sizes in database. + 1 query set with table and index sizes/returns> + Muhmud + 2019-03-26 + 2019-10-24 by Konstantin Taranov + 1.2 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Get_Table_and_Index_Storage_Size.sql + + If you divide the DataKb and IndexAllKb values by 1024.0, you will get the numbers you see in the SSMS. Takes into account internal tables, such as those used for XML storage. + +*/ + + +WITH TablePages AS ( + SELECT s.[object_id] + , SUM(s.reserved_page_count) AS reserved_pages + , SUM(s.used_page_count) AS used_pages + , SUM(CASE WHEN index_id < 2 THEN in_row_data_page_count + lob_used_page_count + row_overflow_used_page_count + ELSE lob_used_page_count + row_overflow_used_page_count + END) AS pages + , (SELECT COUNT(i.[object_id]) FROM sys.indexes AS i WHERE s.[object_id] = i.[object_id] AND i.[type] <> 0) AS IndexCount + , SUM(row_count) AS NumberOfRows + FROM sys.dm_db_partition_stats AS s + GROUP BY [object_id] +) +, ExtraData AS ( + SELECT p.[object_id] + , COUNT(*) AS IndexCount + , SUM(reserved_page_count) AS reserved_pages + , SUM(used_page_count) AS used_pages + FROM sys.dm_db_partition_stats AS p + LEFT JOIN sys.internal_tables AS it ON p.[object_id] = it.[object_id] + WHERE it.internal_type IN (202, 204, 211, 212, 213, 214, 215, 216) + GROUP BY p.[object_id] +) +SELECT p.[object_id] + , OBJECT_SCHEMA_NAME(p.[object_id]) AS ShemaName + , OBJECT_NAME(p.[object_id]) AS TableName + , p.NumberOfRows + , (p.reserved_pages + ISNULL(e.reserved_pages, 0)) * 8 AS ReservedKb + , p.pages * 8 AS DataKb + , p.IndexCount + , CASE WHEN p.IndexCount <> 0 AND p.used_pages + ISNULL(e.used_pages, 0) >= p.pages + THEN p.used_pages + ISNULL(e.used_pages, 0) - p.pages + ELSE 0 + END * 8 AS IndexAllKb + , CASE WHEN p.reserved_pages + ISNULL(e.reserved_pages, 0) > p.used_pages + ISNULL(e.used_pages, 0) + THEN p.reserved_pages + ISNULL(e.reserved_pages, 0) - p.used_pages + ISNULL(e.used_pages, 0) + ELSE 0 + END * 8 AS UnusedKb +FROM TablePages AS p +LEFT JOIN ExtraData AS e ON p.[object_id] = e.[object_id] +WHERE OBJECT_SCHEMA_NAME(p.[object_id]) <> 'sys' AND p.pages > 0 +ORDER BY DataKb ASC; diff --git a/Scripts/Get_latches_Objects.sql b/Scripts/Get_latches_Objects.sql new file mode 100644 index 00000000..e4d3f3ab --- /dev/null +++ b/Scripts/Get_latches_Objects.sql @@ -0,0 +1,83 @@ +IF OBJECT_ID('tempdb..#owt', 'U') IS NOT NULL DROP TABLE #owt; + +CREATE TABLE #owt + ( + session_id INT NOT NULL, + wait_type NVARCHAR(100) NOT NULL, + wait_duration_ms BIGINT NOT NULL, + rd NVARCHAR(100) NOT NULL, + database_num INT NOT NULL, + file_num INT NOT NULL, + page_num INT NOT NULL, + resource_type NVARCHAR(100) NOT NULL + ); + +INSERT INTO #owt + (session_id, + wait_type, + wait_duration_ms, + owt.rd, + database_num, + file_num, + page_num, + resource_type) +SELECT session_id, + owt.wait_type, + owt.wait_duration_ms, + owt.rd, + LEFT(owt.rd, owt.pos1 - 1) AS + database_num, + Substring(owt.rd, owt.pos1 + 1, Len(owt.rd) - ( owt.pos1 + owt.pos2 )) AS + file_num, + RIGHT(owt.rd, owt.pos2 - 1) AS + page_num, + CASE + WHEN RIGHT(owt.rd, owt.pos2 - 1) - 1 % 8088 = 0 THEN 'Is PFS Page' + WHEN RIGHT(owt.rd, owt.pos2 - 1) - 2 % 511232 = 0 THEN 'Is GAM Page' + WHEN RIGHT(owt.rd, owt.pos2 - 1) - 3 % 511232 = 0 THEN 'Is SGAM Page' + ELSE 'Is Not PFS, GAM, or SGAM page' + END AS + resource_type +FROM (SELECT owt.session_id, + owt.wait_type, + owt.wait_duration_ms, + owt.blocking_session_id, + owt.resource_description AS rd, + Charindex(':', owt.resource_description) AS pos1, + Charindex(':', Reverse(owt.resource_description)) AS pos2, + Len(owt.resource_description) AS ln + FROM sys.dm_os_waiting_tasks owt + WHERE owt.wait_type LIKE 'PAGELATCH%') owt + +SELECT * +FROM #owt + +IF EXISTS(SELECT 1 FROM #owt) + BEGIN + SELECT owt.session_id, + owt.wait_type, + owt.wait_duration_ms, + owt.rd, + owt.resource_type, + s.NAME + '.' + o.NAME AS table_name, + i.NAME AS index_name, + obd.page_level, + obd.row_count + FROM sys.dm_os_buffer_descriptors obd + INNER JOIN #owt owt + ON obd.database_id = owt.database_num + AND obd.[file_id] = owt.file_num + AND obd.page_id = owt.page_num + INNER JOIN sys.allocation_units au + ON obd.allocation_unit_id = au.allocation_unit_id + INNER JOIN sys.partitions p + ON au.container_id = p.[partition_id] + INNER JOIN sys.indexes i + ON p.index_id = i.index_id + AND p.[object_id] = i.[object_id] + INNER JOIN sys.objects o + ON i.[object_id] = o.[object_id] + INNER JOIN sys.schemas s + ON o.[schema_id] = s.[schema_id] + OPTION(force ORDER) + END; diff --git a/Scripts/How_much_will_it_cost_or_save_to_rebuild_that_index.sql b/Scripts/How_much_will_it_cost_or_save_to_rebuild_that_index.sql new file mode 100644 index 00000000..ed160dd1 --- /dev/null +++ b/Scripts/How_much_will_it_cost_or_save_to_rebuild_that_index.sql @@ -0,0 +1,69 @@ +/* + + Detail Job History + 1 result set with detailed jobs information. + No + Max Vernon + 2019-07-21 + + 1.0 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/How_much_will_it_cost_or_save_to_rebuild_that_index.sql + https://www.sqlservercentral.com/articles/rebuild-index + +*/ + +/************************************************************************************************** + Purpose: + Display some things about indexes that wed normally like to know plus it calculates how much + extra space would be saved or used after a REBUILD for the current Fill Factor and for the 70, 80, + 90, and 100% Fill Factors. + Progammers Notes: + + 1. Keep in mind that these are all based on averages and so should be considered as approximations. + Also, indexes with very wide rows where there are less than 20 or so rows per page can cause + less accurate approximations. + 2. It would be quite easy to turn this into a system stored procedure that could be executed from + any database. + 3. Note that this has only been tested for non-partitioned rowstore indexes. + Revision History: + Rev 00 - 21 Jul 2019 - Jeff Moden + - Borrow parts of a much larger stored procedure that I use. +**************************************************************************************************/ + WITH cteStats AS +(--===== This CTE is used mostly to rename some of the very long names in the DMF. + SELECT DBName = DB_NAME() + ,ObjectID = ips.object_id + ,IndexID = ips.index_id + ,FragPct = CONVERT(INT,ips.avg_fragmentation_in_percent) + ,AvgFragSize = avg_fragment_size_in_pages + ,PageDensity = ips.avg_page_space_used_in_percent + ,PageCnt = ips.page_count + ,RowCnt = ips.record_count + ,CurSizeMB = ips.page_count/128 --Integer math produces whole numbers here. + FROM sys.dm_db_index_physical_stats (DB_ID(),NULL,NULL,NULL,'SAMPLED') ips + WHERE ips.index_id > 0 --NOT a HEAP + AND ips.page_count > 128 --This is 1 MB or 16 Extents and could be parameterized. +) + SELECT stats.DBName + ,SchemaName = OBJECT_SCHEMA_NAME(stats.ObjectID) + ,ObjectName = OBJECT_NAME(stats.ObjectID) + ,stats.ObjectID + ,IndexName = idx.name + ,stats.IndexID + ,CurFillFactor = idx.fill_factor + ,stats.FragPct + ,stats.AvgFragSize + ,stats.PageDensity + ,stats.PageCnt + ,stats.RowCnt + ,stats.CurSizeMB + ,SavingsMBCur = CONVERT(INT,(stats.PageCnt-(stats.PageDensity/ISNULL(NULLIF(idx.fill_factor,0),100)*stats.PageCnt))/128.0) + ,SavingsMB070 = CONVERT(INT,(stats.PageCnt-(stats.PageDensity/ 70*stats.PageCnt))/128.0) + ,SavingsMB080 = CONVERT(INT,(stats.PageCnt-(stats.PageDensity/ 80*stats.PageCnt))/128.0) + ,SavingsMB090 = CONVERT(INT,(stats.PageCnt-(stats.PageDensity/ 90*stats.PageCnt))/128.0) + ,SavingsMB100 = CONVERT(INT,(stats.PageCnt-(stats.PageDensity/100*stats.PageCnt))/128.0) + FROM cteStats stats + JOIN sys.indexes idx + ON stats.ObjectID = idx.object_id + AND stats.IndexID = idx.index_id +; \ No newline at end of file diff --git a/Scripts/How_to_obtain_the_deadlocks_on_Azure.sql b/Scripts/How_to_obtain_the_deadlocks_on_Azure.sql new file mode 100644 index 00000000..b42f653a --- /dev/null +++ b/Scripts/How_to_obtain_the_deadlocks_on_Azure.sql @@ -0,0 +1,19 @@ +/* +Author: Jose M Jurado +Created Date: 2017-01-21 +Original link: https://blogs.msdn.microsoft.com/azuresqldbsupport/2017/01/21/lesson-learned-19-how-to-obtain-the-deadlocks-of-your-azure-sql-database/ +Source link: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/How_to_obtain_the_deadlocks_on_Azure.sql +Modified: 2019-03-18 by Konstantin Taranov +*/ + +USE master; +GO + +WITH CTE AS ( + SELECT CAST(event_data AS XML) AS [target_data_XML] + FROM sys.fn_xe_telemetry_blob_target_read_file('dl', null, null, null) +) +SELECT target_data_XML.value('(/event/@timestamp)[1]', 'DateTime2') AS [Timestamp] + , target_data_XML.query('/event/data[@name=''xml_report'']/value/deadlock') AS deadlock_xml + , target_data_XML.query('/event/data[@name=''database_name'']/value').value('(/value)[1]', 'nvarchar(100)') AS [db_name] +FROM CTE; diff --git a/Scripts/IN_Memory_Example_2014.sql b/Scripts/IN_Memory_Example_2014.sql index 14adf060..c453a2d2 100644 --- a/Scripts/IN_Memory_Example_2014.sql +++ b/Scripts/IN_Memory_Example_2014.sql @@ -1,8 +1,14 @@ --- https://docs.microsoft.com/en-us/sql/relational-databases/in-memory-oltp/overview-and-usage-scenarios +/* +Author: Konstantin Taranov +Link: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/IN_Memory_Example_2014.sql +*/ USE master; GO -DECLARE @databaseFilePath NVARCHAR(1000) = N'C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\'; +DECLARE @databaseFilePath NVARCHAR(1000) = N''; +SELECT @databaseFilePath = SUBSTRING(physical_name, 1, CHARINDEX(N'master.mdf', LOWER(physical_name)) - 1) + FROM master.sys.master_files + WHERE database_id = 1 AND file_id = 1; DECLARE @databaseName SYSNAME = N'ಠ ಠ 14 Test'; DECLARE @tsqlStatement NVARCHAR(4000) = N''; DECLARE @debug BIT = 0; @@ -66,7 +72,7 @@ WITH (MEMORY_OPTIMIZED=ON); CREATE TABLE dbo.InMemTable1( keyColumn INT IDENTITY PRIMARY KEY NONCLUSTERED - , description CHAR(100) NOT NULL + , description NCHAR(100) NOT NULL ) WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_AND_DATA); diff --git a/Scripts/IN_Memory_Example_2017.sql b/Scripts/IN_Memory_Example_2017.sql index e77ed7d6..284c0ff1 100644 --- a/Scripts/IN_Memory_Example_2017.sql +++ b/Scripts/IN_Memory_Example_2017.sql @@ -1,15 +1,27 @@ --- https://docs.microsoft.com/en-us/sql/relational-databases/in-memory-oltp/overview-and-usage-scenarios +/* +Author: Konstantin Taranov +Link: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/IN_Memory_Example_2017.sql +*/ USE master; GO +DECLARE @databaseFilePath NVARCHAR(1000) = N''; +SELECT @databaseFilePath = SUBSTRING(physical_name, 1, CHARINDEX(N'master.mdf', LOWER(physical_name)) - 1) + FROM master.sys.master_files + WHERE database_id = 1 AND file_id = 1; -DECLARE @databaseFilePath NVARCHAR(1000) = N'C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\'; -DECLARE @databaseName SYSNAME = N'ಠ ಠ 17 Test'; +DECLARE @databaseName SYSNAME = N'1ಠಠಠ 16+ 错误的名字! Wrong Name! गलत नाम! Неправильное название! Nombre incorrecto! Falscher Name! 間違った名前! שם שגוי! Mauvais Nom!1'; +/* To prevent Msg 5135, שםשגוי cannot be used for FILESTREAM files */ +DECLARE @dbFileName_mod SYSNAME = SUBSTRING(@databaseName, 1, 80) + N'_mod'; +DECLARE @databaseFileName NVARCHAR(1000) = REPLACE(@databaseName, N' ', N''); DECLARE @tsqlStatement NVARCHAR(4000) = N''; -DECLARE @debug BIT = 0; +DECLARE @crlf VARCHAR(10) = CHAR(10) + CHAR(13); +DECLARE @debug BIT = 1; -SET @tsqlStatement = ' -IF DB_ID(N''@databaseName'') IS NOT NULL +SET @tsqlStatement = N' +USE master;' + +CASE WHEN @debug = 1 THEN @crlf + N'GO' + @crlf ELSE N'' END + +N'IF DB_ID(N''@databaseName'') IS NOT NULL BEGIN ALTER DATABASE [@databaseName] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DROP DATABASE [@databaseName]; @@ -18,16 +30,22 @@ END; CREATE DATABASE [@databaseName] CONTAINMENT = NONE ON PRIMARY -(NAME = N''@databaseName'', FILENAME = N''@databaseFilePath@databaseName.mdf'', SIZE = 64MB, MAXSIZE = UNLIMITED, FILEGROWTH = 64MB), +(NAME = N''@databaseName'', +FILENAME = N''@databaseFilePath@databaseFileName.mdf'', SIZE = 32MB, MAXSIZE = 2048MB, FILEGROWTH = 64MB), FILEGROUP [@databaseName] CONTAINS MEMORY_OPTIMIZED_DATA DEFAULT -( NAME = N''@databaseName_mod'', FILENAME = N''@databaseFilePath@databaseName_mod'', MAXSIZE = UNLIMITED) +( NAME = N''@databaseName_mod'', FILENAME = N''@databaseFilePath@dbFileName_mod'', MAXSIZE = 2048MB) LOG ON -( NAME = N''@databaseName_log'', FILENAME = N''@databaseFilePath@databaseName_log.ldf'', SIZE = 64MB, MAXSIZE = 2048MB, FILEGROWTH = 64MB); - +( NAME = N''@databaseName_log'', FILENAME = N''@databaseFilePath@databaseFileName_log.ldf'', SIZE = 32MB, MAXSIZE = 2048MB, FILEGROWTH = 64MB); +' + CASE WHEN @debug = 1 THEN @crlf + N'GO' + @crlf ELSE N'' END + +N'IF CAST(SERVERPROPERTY(''ProductMajorVersion'') AS INT) = 14 ALTER DATABASE [@databaseName] SET COMPATIBILITY_LEVEL = 140; -'; + +IF CAST(SERVERPROPERTY(''ProductMajorVersion'') AS INT) = 13 +ALTER DATABASE [@databaseName] SET COMPATIBILITY_LEVEL = 130;'; SET @tsqlStatement = REPLACE(@tsqlStatement, '@databaseName', @databaseName); +SET @tsqlStatement = REPLACE(@tsqlStatement, '@dbFileName_mod', @dbFileName_mod); +SET @tsqlStatement = REPLACE(@tsqlStatement, '@databaseFileName', @databaseFileName); SET @tsqlStatement = REPLACE(@tsqlStatement, '@databaseFilePath', @databaseFilePath); IF @debug = 1 PRINT(@tsqlStatement) @@ -35,28 +53,25 @@ ELSE EXEC sp_executesql @tsqlStatement; -SET @tsqlStatement = ' -USE [@databaseName]; ---UNCOMMENT GO Statement if you want to execute statements after printing in debug mode!!! ---GO - --- configure recommended DB option +SET @tsqlStatement = N'USE [@databaseName];' + +CASE WHEN @debug = 1 THEN @crlf + N'GO' + @crlf ELSE N'' END + +N'/* configure recommended DB option */ ALTER DATABASE CURRENT SET MEMORY_OPTIMIZED_ELEVATE_TO_SNAPSHOT=ON; --- memory-optimized table -CREATE TABLE dbo.table1 +/* memory-optimized table */ +CREATE TABLE dbo.[¯\_(ツ)_/¯ 😁__間違った名前 In Memory Table Я не советую так называть__👻 ¯\_(ツ)_/¯] ( c1 INT IDENTITY PRIMARY KEY NONCLUSTERED, c2 NVARCHAR(MAX)) WITH (MEMORY_OPTIMIZED=ON); --- non-durable table +/* non-durable table */ CREATE TABLE dbo.temp_table1 ( c1 INT IDENTITY PRIMARY KEY NONCLUSTERED, c2 NVARCHAR(MAX)) WITH (MEMORY_OPTIMIZED=ON, DURABILITY=SCHEMA_ONLY); --- memory-optimized table type +/* memory-optimized table type */ CREATE TYPE dbo.tt_table1 AS TABLE ( c1 INT IDENTITY, c2 NVARCHAR(MAX), @@ -64,13 +79,13 @@ CREATE TYPE dbo.tt_table1 AS TABLE INDEX ix_c1 HASH (c1) WITH (BUCKET_COUNT=1024)) WITH (MEMORY_OPTIMIZED=ON); -CREATE TABLE dbo.InMemTable1( +CREATE TABLE dbo.[¯\_(ツ)_/¯ 😁__間違った名前 In Memory Table Я не советую так называть__👻 ¯\_(ツ)_/¯]( keyColumn INT IDENTITY PRIMARY KEY NONCLUSTERED , description CHAR(100) NOT NULL ) WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_AND_DATA); -INSERT dbo.InMemTable1 +INSERT dbo.[¯\_(ツ)_/¯ 😁__間違った名前 In Memory Table Я не советую так называть__👻 ¯\_(ツ)_/¯] ( description ) @@ -90,12 +105,12 @@ ELSE EXEC sp_executesql @tsqlStatement; --- https://stackoverflow.com/a/793362/2298061 +/* https://stackoverflow.com/a/793362/2298061 */ DECLARE @UseAndExecStatment NVARCHAR(4000); SET @UseAndExecStatment = N'USE [' + @databaseName + N']; EXEC sp_executesql @tsqlStatement'; -SET @tsqlStatement = N' --- natively compiled stored procedure +SET @tsqlStatement = CASE WHEN @debug = 1 THEN @crlf + N'GO' + @crlf ELSE N'' END + +N'/* natively compiled stored procedure */ CREATE PROCEDURE dbo.usp_ingest_table1 @table1 dbo.tt_table1 READONLY WITH NATIVE_COMPILATION, SCHEMABINDING @@ -139,15 +154,16 @@ END; SET @UseAndExecStatment = N'USE [' + @databaseName + N']; EXEC sp_executesql @tsqlStatement'; -SET @tsqlStatement = N' +SET @tsqlStatement = CASE WHEN @debug = 1 THEN @crlf + N'GO' + @crlf ELSE N'' END + +N' CREATE OR ALTER PROCEDURE dbo.native_sp WITH NATIVE_COMPILATION, SCHEMABINDING, EXECUTE AS OWNER AS BEGIN ATOMIC WITH (TRANSACTION ISOLATION LEVEL = SNAPSHOT, LANGUAGE = N''us_english'') SELECT keyColumn ,description -FROM dbo.InMemTable1; -END;'; +FROM dbo.[¯\_(ツ)_/¯ 😁__間違った名前 In Memory Table Я не советую так называть__👻 ¯\_(ツ)_/¯]; +END;' + CASE WHEN @debug = 1 THEN @crlf + N'GO' + @crlf ELSE N'' END; IF @debug = 1 PRINT(@tsqlStatement) ELSE @@ -159,7 +175,7 @@ END; SET @UseAndExecStatment = N'USE [' + @databaseName + N']; EXEC sp_executesql @tsqlStatement'; SET @tsqlStatement = ' --- sample execution of the proc +/* sample execution of the proc */ DECLARE @table1 dbo.tt_table1; INSERT @table1 (c2, is_transient) VALUES (N''sample durable'', 0); INSERT @table1 (c2, is_transient) VALUES (N''sample non-durable'', 1); diff --git a/Scripts/Index_Creating_Info.sql b/Scripts/Index_Creating_Info.sql new file mode 100644 index 00000000..5bebae2d --- /dev/null +++ b/Scripts/Index_Creating_Info.sql @@ -0,0 +1,45 @@ +/* + + Track index creating progress + 1 data set: index creation info. + No + Solomon Rutzky + 2020-09-03 + 2021-08-12 by Konstantin Taranov + 1.0 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Index_Creating_Info.sql + https://dba.stackexchange.com/a/139225/107045 + +*/ + +WITH agg AS +( + SELECT SUM(qp.row_count) AS RowsProcessed, + SUM(qp.estimate_row_count) AS TotalRows, + MAX(qp.last_active_time) - MIN(qp.first_active_time) AS ElapsedMS, + MAX(IIF(qp.close_time = 0 AND qp.first_row_time > 0, + physical_operator_name, + N'')) AS CurrentStep + FROM sys.dm_exec_query_profiles qp + WHERE qp.[physical_operator_name] IN (N'Table Scan', N'Clustered Index Scan', + N'Index Scan', N'Sort') + AND qp.[session_id] IN (SELECT session_id from sys.dm_exec_requests where command IN ( 'CREATE INDEX','ALTER INDEX','ALTER TABLE') ) +), comp AS +( + SELECT *, + (TotalRows - RowsProcessed) AS RowsLeft, + (ElapsedMS / 1000.0) AS ElapsedSeconds + FROM agg +) +SELECT CurrentStep, + TotalRows, + RowsProcessed, + RowsLeft, + CONVERT(DECIMAL(5, 2), + ((RowsProcessed * 1.0) / TotalRows) * 100) AS PercentComplete, + ElapsedSeconds, + ((ElapsedSeconds / RowsProcessed) * RowsLeft) AS EstimatedSecondsLeft, + DATEADD(SECOND, + ((ElapsedSeconds / RowsProcessed) * RowsLeft), + GETDATE()) AS EstimatedCompletionTime +FROM comp; diff --git a/Scripts/Job_AG_Failover_Detected.sql b/Scripts/Job_AG_Failover_Detected.sql new file mode 100644 index 00000000..b674343d --- /dev/null +++ b/Scripts/Job_AG_Failover_Detected.sql @@ -0,0 +1,39 @@ +/* + + Use this event to run a job when the replica becomes primary + Create job to resume AG database data movement for suspended databases. + 2020-08-06 by Wayne Sheffield + 1.0 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Job_AG_Failover_Detected.sql + https://blog.waynesheffield.com/wayne/archive/2020/08/availability-group-issues-fixed-with-alerts/ + +*/ + +/* +Use this event to run a job when the replica becomes primary +*/ +USE msdb; +GO +EXEC msdb.dbo.sp_add_alert @name=N'AG Failover Detected - Now Primary', +@message_id=1480, +@severity=0, +@enabled=1, +@delay_between_responses=0, +@include_event_description_in=0, +@event_description_keyword=N'"RESOLVING" to "PRIMARY"', +@job_id=N'00000000-0000-0000-0000-000000000000'; +GO +/* +Use this event to run a job when the replica becomes secondary +*/ +USE msdb; +GO +EXEC msdb.dbo.sp_add_alert @name=N'AG Failover Detected - Now Secondary', +@message_id=1480, +@severity=0, +@enabled=1, +@delay_between_responses=0, +@include_event_description_in=0, +@event_description_keyword=N'"RESOLVING" to "SECONDARY"', +@job_id=N'00000000-0000-0000-0000-000000000000'; +GO diff --git a/Scripts/Job_AG_Resume_Data_Movement.sql b/Scripts/Job_AG_Resume_Data_Movement.sql new file mode 100644 index 00000000..310ce020 --- /dev/null +++ b/Scripts/Job_AG_Resume_Data_Movement.sql @@ -0,0 +1,129 @@ +/* + + Create job to resume AG database data movement for suspended databases. + Create alert to catch when data movement has been suspended, and run the job + + Create job to resume AG database data movement for suspended databases. + 2020-08-06 by Wayne Sheffield + 1.0 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Job_AG_Resume_Data_Movement.sql + https://blog.waynesheffield.com/wayne/archive/2020/08/availability-group-issues-fixed-with-alerts/ + +*/ + +USE msdb; +GO + +BEGIN TRANSACTION; +DECLARE @ReturnCode INT; +SELECT @ReturnCode = 0;DECLARE @jobname sysname = N'AG - Resume Data Movement'; +DECLARE @categoryname sysname = 'HADR-Availability Group'; + +IF EXISTS (SELECT name FROM dbo.sysjobs where name = @jobname) +BEGIN +EXECUTE msdb.dbo.sp_delete_job @job_name = @jobname; +END; + +IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=@categoryname AND category_class=1) +BEGIN +EXECUTE @ReturnCode = msdb.dbo.sp_add_category @class=N'JOB', @type=N'LOCAL', @name=@categoryname; +IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback; +END; + + +EXECUTE @ReturnCode = msdb.dbo.sp_add_job +@job_name=@jobname, +@enabled=1, +@notify_level_eventlog=0, +@notify_level_email=2, +@notify_level_netsend=2, +@notify_level_page=2, +@delete_level=0, +@description=N'Resume data movement on suspended Availability Group databases. + +This job can be run manually, or from an alert', +@category_name=N'HADR-Availability Group', +@owner_login_name=N'sa'; +IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback; + +EXECUTE @ReturnCode = msdb.dbo.sp_add_jobserver @job_name=@jobname, @server_name = N'(local)' +IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback; + +EXECUTE @ReturnCode = msdb.dbo.sp_add_jobstep +@job_name=@jobname, +@step_name=N'Resume data movement in AG databases', +@step_id=1, +@cmdexec_success_code=0, +@on_success_action=1, +@on_fail_action=2, +@retry_attempts=0, +@retry_interval=0, +@os_run_priority=0, +@subsystem=N'TSQL', +@command=N'DECLARE @SQLCMD VARCHAR(1000); +DECLARE cDBSuspended CURSOR FOR +SELECT ''ALTER DATABASE ['' + DB_NAME(database_id) + ''] SET HADR RESUME;'' +FROM sys.dm_hadr_database_replica_states drs +JOIN sys.availability_replicas ar ON ar.replica_id = drs.replica_id +WHERE ar.replica_server_name = @@SERVERNAME +AND drs.is_suspended = 1; + +OPEN cDBSuspended; +FETCH NEXT FROM cDBSuspended INTO @SQLCMD; +WHILE @@FETCH_STATUS = 0 +BEGIN +EXECUTE (@SQLCMD); +FETCH NEXT FROM cDBSuspended INTO @SQLCMD; +END; +CLOSE cDBSuspended; +DEALLOCATE cDBSuspended; +', +@database_name=N'master', +@flags=0; +IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback; + + +EXECUTE @ReturnCode = msdb.dbo.sp_update_job +@job_name=@jobname, +@enabled=1, +@start_step_id=1, +@notify_level_eventlog=0, +@notify_level_email=2, +@notify_level_netsend=2, +@notify_level_page=2, +@delete_level=0, +@description=N'Resume data movement on suspended Availability Group databases.', +@category_name=N'HADR-Availability Group', +@owner_login_name=N'sa', +@notify_email_operator_name=N'', +@notify_netsend_operator_name=N'', +@notify_page_operator_name=N''; +IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback; + +DECLARE @alertname sysname = N'AG Data Movement suspended'; +IF EXISTS (SELECT * FROM msdb.dbo.sysalerts WHERE name = @alertname) +BEGIN +EXECUTE @ReturnCode = msdb.dbo.sp_delete_alert @alertname; +IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback; +END; + +/* +Alert text: +AlwaysOn Availability Groups data movement for database '%.*ls' has been suspended for the following reason: "%S_MSG" (Source ID %d; Source string: '%.*ls'). To resume data movement on the database, you will need to resume the database manually. For information about how to resume an availability database, see SQL Server Books Online. +*/ +EXECUTE @ReturnCode = msdb.dbo.sp_add_alert +@name=@alertname, +@message_id=35264, +@severity=0, +@enabled=1, +@delay_between_responses=0, +@include_event_description_in=0, +@job_name = @jobname; +IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback; + +COMMIT TRANSACTION; +GOTO EndSave +QuitWithRollback: +IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION; +EndSave: +GO diff --git a/Scripts/Jobs_Detailed_History.sql b/Scripts/Jobs_Detailed_History.sql new file mode 100644 index 00000000..42165088 --- /dev/null +++ b/Scripts/Jobs_Detailed_History.sql @@ -0,0 +1,118 @@ +/* + + Detail Job History + 1 result set with detailed jobs information. + No + Konstantin Taranov + 2019-08-16 + 2019-08-27 by Konstantin Taranov + 1.1 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Read_Errorlog.sql + https://jasonbrimhall.info/2019/06/27/detail-job-history-back-to-basics/ + +*/ + +WITH jobhist +AS (SELECT jh.job_id, + jh.run_date, + jh.run_status, + jh.step_id, + ROW_NUMBER() OVER (PARTITION BY jh.job_id, jh.run_status ORDER BY jh.run_date DESC) AS rownum + FROM dbo.sysjobhistory jh + WHERE jh.step_id = 0), + agglastsixty +AS (SELECT sjh.job_id, + sjh.run_status, + COUNT(*) AS RunCount + FROM dbo.sysjobhistory AS sjh + INNER JOIN jobhist AS jh + ON jh.job_id = sjh.job_id + AND jh.run_status = sjh.run_status + AND jh.step_id = sjh.step_id + WHERE CONVERT(DATE, CONVERT(varchar(30), sjh.run_date)) > DATEADD(d, -60, CONVERT(DATE, CONVERT(varchar(30), jh.run_date))) + AND jh.rownum = 1 + GROUP BY sjh.job_id, + sjh.run_status), + aggtotal +AS (SELECT sjh.job_id, + sjh.run_status, + COUNT(*) AS RunCount + FROM dbo.sysjobhistory sjh + INNER JOIN jobhist jh + ON jh.job_id = sjh.job_id + AND jh.run_status = sjh.run_status + AND jh.step_id = sjh.step_id + WHERE jh.rownum = 1 + GROUP BY sjh.job_id, + sjh.run_status) +SELECT j.name AS JobName, + sc.name AS CategoryName, + j.date_created, + j.enabled, + CONVERT(DATE, CONVERT(VARCHAR(30), oa.run_date)) AS RunDate, + CASE oa.run_status + WHEN 0 THEN + 'Failed' + WHEN 1 THEN + 'Succeeded' + WHEN 2 THEN + 'Retry' + WHEN 3 THEN + 'Canceled' + WHEN 4 THEN + 'In Progress' + END AS run_status, + als.RunCount AS Last60StatusCount, + agt.RunCount AS TotalStatusCount, + js.subsystem AS JobStepSubsystem, + js.command, + CASE + WHEN js.subsystem = 'SSIS' + AND js.command LIKE '%DECRYPT%' THEN + LTRIM(RTRIM(SUBSTRING( + js.command, + CHARINDEX('/DECRYPT', js.command, 1) + 9, + CHARINDEX('/', js.command, CHARINDEX('/DECRYPT', js.command, 1) + 1) + - CHARINDEX('/DECRYPT', js.command, 1) - 9 + ) + ) + ) + ELSE + 'N/A' + END AS PkgPassword, + CASE + WHEN js.subsystem = 'SSIS' + AND js.command LIKE '%FILE%' THEN + LTRIM(RTRIM(SUBSTRING( + js.command, + CHARINDEX('/FILE', js.command, 1) + 9, + CHARINDEX('\""', js.command, CHARINDEX('/FILE', js.command, 1) + 1) + - CHARINDEX('/FILE', js.command, 1) - 9 + ) + ) + ) + ELSE + 'N/A' + END AS PkgPath, + spr.name AS ProxyName, + spr.credential_id +FROM dbo.sysjobs j + LEFT JOIN jobhist oa + ON oa.job_id = j.job_id + LEFT OUTER JOIN agglastsixty als + ON als.job_id = oa.job_id + AND als.run_status = oa.run_status + LEFT OUTER JOIN aggtotal agt + ON agt.job_id = oa.job_id + AND agt.run_status = oa.run_status + INNER JOIN sys.server_principals sp + ON j.owner_sid = sp.sid + INNER JOIN dbo.syscategories sc + ON j.category_id = sc.category_id + INNER JOIN dbo.sysjobsteps js + ON js.job_id = j.job_id + LEFT JOIN dbo.sysproxies spr + ON js.proxy_id = spr.proxy_id +WHERE oa.rownum = 1 +--AND oa.run_status = 0 +ORDER BY RunDate DESC; diff --git a/Scripts/Jobs_Find_And_Replace_Text.sql b/Scripts/Jobs_Find_And_Replace_Text.sql new file mode 100644 index 00000000..80bd077d --- /dev/null +++ b/Scripts/Jobs_Find_And_Replace_Text.sql @@ -0,0 +1,117 @@ +/* + + Replace text in jobs + No. + No + Max Vernon + 2019-04-30 + 2019-09-06 by Konstantin Taranov + 1.1 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Jobs_Find_And_Replace_Text.sql + https://www.sqlserverscience.com/tools/find-and-replace-sql-server-agent-jobs/ + +*/ + +USE msdb; +GO + +DECLARE @Find nvarchar(max); +DECLARE @Replace nvarchar(max); +DECLARE @DebugOnly bit; +SET @Find = N'\\SERVERA\Backups'; +SET @Replace = N'\\SERVERB\Backups'; +SET @DebugOnly = 1; + +IF OBJECT_ID(N'tempdb..#excludeJobs', N'U') IS NOT NULL +BEGIN + DROP TABLE #excludeJobs; +END +CREATE TABLE #excludeJobs +( + JobName sysname NOT NULL + PRIMARY KEY CLUSTERED +); + +INSERT INTO #excludeJobs (JobName) +VALUES ('The Name of a job you want to skip'); + +IF OBJECT_ID(N'tempdb..#deets', N'U') IS NOT NULL +DROP TABLE #deets; + +CREATE TABLE #deets +( + JobName sysname NOT NULL + , StepName sysname NOT NULL + , OldCommand nvarchar(max) NOT NULL + , NewCommand nvarchar(max) NOT NULL + , PRIMARY KEY (JobName, StepName) +); +DECLARE @JobName sysname; +DECLARE @StepName sysname; +DECLARE @StepID int; +DECLARE @Command nvarchar(max); +DECLARE @NewCommand nvarchar(max); + +BEGIN TRY + BEGIN TRANSACTION; + + DECLARE cur CURSOR LOCAL FORWARD_ONLY STATIC READ_ONLY + FOR + SELECT sj.name + , sjs.step_name + , sjs.step_id + , sjs.command + FROM dbo.sysjobsteps sjs + INNER JOIN dbo.sysjobs sj ON sjs.job_id = sj.job_id + WHERE sjs.command LIKE N'%' + @Find + N'%' ESCAPE N'|' COLLATE SQL_Latin1_General_CP1_CI_AS + AND sj.enabled = 1 + AND NOT EXISTS ( + SELECT 1 + FROM #excludeJobs ej + WHERE ej.JobName = sj.name + ) + ORDER BY sj.name + , sjs.step_name; + + OPEN cur; + FETCH NEXT FROM cur INTO @JobName + , @StepName + , @StepID + , @Command; + WHILE @@FETCH_STATUS = 0 + BEGIN + SET @NewCommand = REPLACE(@Command, @Find, @Replace) COLLATE SQL_Latin1_General_CP1_CI_AS; + INSERT INTO #deets (JobName, StepName, OldCommand, NewCommand) + SELECT JobName = @JobName + , StepName = @StepName + , PriorCommand = @Command + , NewCommand = @NewCommand; + + IF @DebugOnly = 0 + BEGIN + EXEC dbo.sp_update_jobstep @job_name = @JobName, @step_id = @StepID, @command = @NewCommand; + PRINT N'Updated ' + @JobName; + END + + FETCH NEXT FROM cur INTO @JobName + , @StepName + , @StepID + , @Command; + END + CLOSE cur; + DEALLOCATE cur; + + SELECT * + FROM #deets; + + COMMIT TRANSACTION; +END TRY +BEGIN CATCH + IF @@TRANCOUNT > 0 + BEGIN + ROLLBACK TRANSACTION; + PRINT N'Transaction rolled back'; + END + PRINT ERROR_MESSAGE(); + PRINT ERROR_LINE(); +END CATCH diff --git a/Scripts/Jobs_Get_Runing_info.sql b/Scripts/Jobs_Get_Runing_info.sql new file mode 100644 index 00000000..517abcf3 --- /dev/null +++ b/Scripts/Jobs_Get_Runing_info.sql @@ -0,0 +1,39 @@ +/* + + Return active jobs info. + 1 data set with information about current runnig jobs. + 2017-01-07 by Brenda + 2020-08-10 by Konstantin Taranov + 1.1 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Jobs_Get_runing_info.sql + https://sqlstudies.com/2013/09/05/a-t-sql-query-to-get-current-job-activity/ + +*/ + +SELECT + DISTINCT j.name as JobName + , CASE WHEN ja.last_executed_step_id IS NULL THEN js.step_name ELSE js2.step_name END AS StepName + , ja.start_execution_date AS StartDateTime + , 'Running' AS RunStatus + , RIGHT('0' + CONVERT(VARCHAR(2), DATEDIFF(second, ja.start_execution_date, GetDate())/3600), 2) + ':' + + RIGHT('0' + CONVERT(VARCHAR(2), DATEDIFF(second, ja.start_execution_date, GetDate())%3600/60), 2) + ':' + + RIGHT('0' + CONVERT(VARCHAR(2), DATEDIFF(second, ja.start_execution_date, GetDate())%60), 2) AS Duration + , '' AS message +FROM msdb.dbo.sysjobactivity ja + JOIN msdb.dbo.sysjobs j + ON ja.job_id = j.job_id + LEFT JOIN msdb.dbo.sysjobsteps js + ON j.job_id = js.job_id + AND CASE WHEN ja.last_executed_step_id IS NULL THEN j.start_step_id + ELSE ja.last_executed_step_id + END = js.step_id + LEFT JOIN msdb.dbo.sysjobsteps js2 + ON js.job_id = js2.job_id + AND js.on_success_step_id = js2.step_id +WHERE ja.session_id = ( + SELECT TOP(1) session_id + FROM msdb.dbo.syssessions + ORDER BY agent_start_date DESC + ) +AND ja.start_execution_date IS NOT NULL +AND ja.stop_execution_date IS NULL; diff --git a/Scripts/Line_Of_Codes_In_database.sql b/Scripts/Line_Of_Codes_In_database.sql new file mode 100644 index 00000000..4b0bcf74 --- /dev/null +++ b/Scripts/Line_Of_Codes_In_database.sql @@ -0,0 +1,19 @@ +/* +Author: Pinal Dave +Source link: https://blog.sqlauthority.com/2015/06/12/sql-server-how-many-line-of-code-do-you-have-in-database/ +*/ + +SELECT DB_NAME(DB_ID()) AS DBName, + ObjectType, + COUNT(*) AS Object_Count, + SUM(LinesOfCode) AS LinesOfCode +FROM (SELECT s.type AS ObjectType, + LEN(definition)- LEN(REPLACE(definition,CHAR(10),'')) AS LinesOfCode, + OBJECT_NAME(a.object_id) AS NameOfObject + FROM sys.all_sql_modules AS a + INNER JOIN sysobjects AS s + ON a.object_id = s.id + -- AND xtype IN('TR', 'P', 'FN', 'IF', 'TF', 'V') + WHERE OBJECTPROPERTY(a.object_id,'IsMSShipped') = 0 +) SubQuery +GROUP BY ObjectType; diff --git a/Scripts/MAXDOP_recommendation.sql b/Scripts/MAXDOP_recommendation.sql index cfc6cb52..7fc9f14e 100644 --- a/Scripts/MAXDOP_recommendation.sql +++ b/Scripts/MAXDOP_recommendation.sql @@ -1,4 +1,6 @@ -/* Use coreinfo (utility by sysinternals) as this will give you +/* +Link: https://dba.stackexchange.com/a/36578/107045 +Use coreinfo (utility by sysinternals) as this will give you a. Logical to Physical Processor Map b. Logical Processor to Socket Map c. Logical Processor to NUMA Node Map as below : @@ -29,66 +31,67 @@ Considering all above factors, the max degree of Parallelism should be set to 6 So the answer is -- "it depends" on your processor footprint and the NUMA configuration and below table will summarize what I explained above: 8 or less processors ===> 0 to N (where N= no. of processors) More than 8 processors ===> 8 -NUMA configured ===> MAXDOP should not exceed no of CPU’s assigned to each +NUMA configured ===> MAXDOP should not exceed no of CPU’s assigned to each NUMA node with max value capped to 8 Hyper threading Enabled ===> Should not exceed the number of physical processors. Below is a quick and dirty TSQL script to generate Recommendation for MAXDOP setting Author : Kin Shah Purpose : Recommend MaxDop settings for the server instance -Tested RDBMS : SQL Server 2008R2 */ +Tested RDBMS : SQL Server 2008R2, 2014, 2016, 2017 */ -declare @hyperthreadingRatio bit -declare @logicalCPUs int -declare @HTEnabled int -declare @physicalCPU int -declare @SOCKET int -declare @logicalCPUPerNuma int -declare @NoOfNUMA int +DECLARE @hyperthreadingRatio BIT; +DECLARE @logicalCPUs INT; +DECLARE @HTEnabled INT; +DECLARE @physicalCPU INT; +DECLARE @SOCKET INT; +DECLARE @logicalCPUPerNuma INT; +DECLARE @NoOfNUMA INT; -select @logicalCPUs = cpu_count -- [Logical CPU Count] - ,@hyperthreadingRatio = hyperthread_ratio -- [Hyperthread Ratio] - ,@physicalCPU = cpu_count / hyperthread_ratio -- [Physical CPU Count] - ,@HTEnabled = case - when cpu_count > hyperthread_ratio - then 1 - else 0 - end -- HTEnabled -from sys.dm_os_sys_info -option (recompile); +SELECT @logicalCPUs = cpu_count -- [Logical CPU Count] + , @hyperthreadingRatio = hyperthread_ratio -- [Hyperthread Ratio] + , @physicalCPU = cpu_count / hyperthread_ratio -- [Physical CPU Count] + , @HTEnabled = CASE + WHEN cpu_count > hyperthread_ratio THEN 1 + ELSE 0 + END -- HTEnabled +FROM sys.dm_os_sys_info +OPTION (recompile); -select @logicalCPUPerNuma = COUNT(parent_node_id) -- [NumberOfLogicalProcessorsPerNuma] -from sys.dm_os_schedulers -where [status] = 'VISIBLE ONLINE' - and parent_node_id < 64 -group by parent_node_id -option (recompile); +SELECT @logicalCPUPerNuma = Count(parent_node_id) +-- [NumberOfLogicalProcessorsPerNuma] +FROM sys.dm_os_schedulers +WHERE [status] = 'VISIBLE ONLINE' + AND parent_node_id < 64 +GROUP BY parent_node_id +OPTION (recompile); -select @NoOfNUMA = count(distinct parent_node_id) -from sys.dm_os_schedulers -- find NO OF NUMA Nodes -where [status] = 'VISIBLE ONLINE' - and parent_node_id < 64 +SELECT @NoOfNUMA = Count(DISTINCT parent_node_id) +FROM sys.dm_os_schedulers -- find NO OF NUMA Nodes +WHERE [status] = 'VISIBLE ONLINE' + AND parent_node_id < 64 -- Report the recommendations .... -select - --- 8 or less processors and NO HT enabled - case - when @logicalCPUs < 8 - and @HTEnabled = 0 - then 'MAXDOP setting should be : ' + CAST(@logicalCPUs as varchar(3)) - --- 8 or more processors and NO HT enabled - when @logicalCPUs >= 8 - and @HTEnabled = 0 - then 'MAXDOP setting should be : 8' - --- 8 or more processors and HT enabled and NO NUMA - when @logicalCPUs >= 8 - and @HTEnabled = 1 - and @NoofNUMA = 1 - then 'MaxDop setting should be : ' + CAST(@logicalCPUPerNuma / @physicalCPU as varchar(3)) - --- 8 or more processors and HT enabled and NUMA - when @logicalCPUs >= 8 - and @HTEnabled = 1 - and @NoofNUMA > 1 - then 'MaxDop setting should be : ' + CAST(@logicalCPUPerNuma / @physicalCPU as varchar(3)) - else '' - end as Recommendations \ No newline at end of file +SELECT +--- 8 or less processors and NO HT enabled +CASE + WHEN @logicalCPUs < 8 + AND @HTEnabled = 0 THEN 'MAXDOP setting should be : ' + + Cast(@logicalCPUs AS VARCHAR(3)) + --- 8 or more processors and NO HT enabled + WHEN @logicalCPUs >= 8 + AND @HTEnabled = 0 THEN 'MAXDOP setting should be : 8' + --- 8 or more processors and HT enabled and NO NUMA + WHEN @logicalCPUs >= 8 + AND @HTEnabled = 1 + AND @NoOfNUMA = 1 THEN 'MaxDop setting should be : ' + + Cast(@logicalCPUPerNuma / @physicalCPU AS + VARCHAR(3)) + --- 8 or more processors and HT enabled and NUMA + WHEN @logicalCPUs >= 8 + AND @HTEnabled = 1 + AND @NoOfNUMA > 1 THEN 'MaxDop setting should be : ' + + Cast(@logicalCPUPerNuma / @physicalCPU AS + VARCHAR(3)) + ELSE '' +END AS Recommendations; diff --git a/Scripts/MaxDop_2016_and_higher.sql b/Scripts/MaxDop_2016_and_higher.sql new file mode 100644 index 00000000..00570a01 --- /dev/null +++ b/Scripts/MaxDop_2016_and_higher.sql @@ -0,0 +1,116 @@ +/* + + Calculate recommended MAXDOP value for your server. + 1 data set with information about current runnig jobs. + 2020-02-18 by John Welch + 2020-09-07 by Konstantin Taranov + 1.1 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/MaxDop_2016_and_higher.sql + https://www.sentryone.com/blog/is-maxdop-configured-correctly + +*/ + + +DECLARE @ProductVersion NVARCHAR(50); +DECLARE @Major INT; +DECLARE @NumaNodeCount INT; +DECLARE @LogicalProcessorPerNumaNodeCount INT; +DECLARE @EffectiveMaxDop INT; +DECLARE @LogicalProcessorThreshold INT; +DECLARE @ResultMessage NVARCHAR(255); + +SET @ProductVersion = CAST(SERVERPROPERTY('ProductVersion') AS NVARCHAR(50)); +SET @Major = CAST(LEFT(@ProductVersion, CHARINDEX('.', @ProductVersion)-1) AS INT); + +IF @Major < 13 +BEGIN + RAISERROR('This script is intended for SQL Server 2016 or higher. It will not work on version [%s].', 11, 1, @ProductVersion); +END + +/* Get the MAXDOP setting */ +SELECT + @EffectiveMaxDop = CAST(value_in_use AS INT) +FROM + sys.configurations +WHERE + [name] = N'max degree of parallelism'; + +IF @EffectiveMaxDop = 0 +BEGIN + SELECT + @EffectiveMaxDop = COUNT(*) + FROM + sys.dm_os_schedulers + WHERE + scheduler_id <= 1048575 + AND is_online = 1; +END + +-- Get the NUMA node count +-- Get the logical processors per numa node +SELECT + @NumaNodeCount = COUNT(*), @LogicalProcessorPerNumaNodeCount = MAX(online_scheduler_count) +FROM + sys.dm_os_nodes +WHERE node_id <> 64; --Excluded DAC node + +IF @NumaNodeCount < 1 OR @LogicalProcessorPerNumaNodeCount < 1 +BEGIN + RAISERROR('Could not capture NUMA node or logical processor count. Reported values - NUMA: [%d], Logical Processor: [%d]', + 11,1, @NumaNodeCount, @LogicalProcessorPerNumaNodeCount); +END + +SET @LogicalProcessorThreshold = IIF(@NumaNodeCount = 1, 8, 16); + +--If NUMA = 1 and LogiProcs <= 8 THEN ASSERT(MaxDop <= LogiProcs) +--If NUMA > 1 and LogiProcs <= 16 THEN ASSERT(MaxDop <= LogiProcs) +IF @LogicalProcessorPerNumaNodeCount <= @LogicalProcessorThreshold + AND @EffectiveMaxDop > @LogicalProcessorPerNumaNodeCount +BEGIN + SET @ResultMessage = N'MAXDOP should be less than or equal to the Logical Processor count per NUMA node.'; +END +ELSE +BEGIN + -- If NUMA = 1 and LogiProcs > 8 THEN ASSERT(MaxDop == 8) + IF @NumaNodeCount = 1 + AND @LogicalProcessorPerNumaNodeCount > @LogicalProcessorThreshold + AND @EffectiveMaxDop <> @LogicalProcessorThreshold + BEGIN + SET @ResultMessage = N'MAXDOP should be equal to 8.'; + END + -- If NUMA > 1 and LogiProcs > 16 THEN ASSERT(MaxDop <= 16 & MaxDop <= (LogiProcs / 2)) + ELSE + BEGIN + IF @LogicalProcessorPerNumaNodeCount > @LogicalProcessorThreshold + AND @EffectiveMaxDop > @LogicalProcessorThreshold + BEGIN + SET @ResultMessage = N'MAXDOP should not exceed a value of 16.'; + --RAISERROR('MAXDOP is not set based on recommendations in KB2806535. MAXDOP should not exceed a value of 16 . Reported values - NUMA: [%d], Logical Processor: [%d], MAXDOP: [%d]', + -- 15,1, @NumaNodeCount, @LogicalProcessorPerNumaNodeCount, @EffectiveMaxDop); + END + ELSE IF @LogicalProcessorPerNumaNodeCount > @LogicalProcessorThreshold + AND (@LogicalProcessorPerNumaNodeCount / 2) <= @LogicalProcessorThreshold + AND @EffectiveMaxDop <> (@LogicalProcessorPerNumaNodeCount / 2) + BEGIN + SET @ResultMessage = N'MAXDOP should be set at half the number of logical processors per NUMA node with a MAX value of 16.'; + --RAISERROR('MAXDOP is not set based on recommendations in KB2806535. MAXDOP should be set at half the number of logical processors per NUMA node with a MAX value of 16 . Reported values - NUMA: [%d], Logical Processor: [%d], MAXDOP: [%d]', + -- 15,1, @NumaNodeCount, @LogicalProcessorPerNumaNodeCount, @EffectiveMaxDop); + END + END +END +IF @EffectiveMaxDop = 1 +BEGIN + RAISERROR('MAXDOP is set to 1, which supresses parallel plan generation.', 0, 1); +END + +IF @ResultMessage IS NULL +BEGIN + RAISERROR('MAXDOP setting is in the recommended range. Reported values - NUMA: [%d], Logical Processor: [%d], MAXDOP: [%d]', + 0, 1, @NumaNodeCount, @LogicalProcessorPerNumaNodeCount, @EffectiveMaxDop); +END +ELSE +BEGIN + RAISERROR('MAXDOP is not set based on recommendations in KB2806535. %s Reported values - NUMA: [%d], Logical Processor: [%d], MAXDOP: [%d]', + 11, 1, @ResultMessage, @NumaNodeCount, @LogicalProcessorPerNumaNodeCount, @EffectiveMaxDop); +END +GO diff --git a/Scripts/Memory_Consumption_By_Object.sql b/Scripts/Memory_Consumption_By_Object.sql new file mode 100644 index 00000000..9cd0ed08 --- /dev/null +++ b/Scripts/Memory_Consumption_By_Object.sql @@ -0,0 +1,122 @@ +/* + + Get memory for all objects in all databases + Temp table #obd with memory consumption by objects + 2019-08-02 by Max Vernon + 2020-02-05 by Konstantin Taranov + 1.2 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Memory_Consumption_By_Object.sql + https://www.sqlserverscience.com/performance/memory-consumption-by-object/ + +*/ + +SET NOCOUNT ON; +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; + +IF OBJECT_ID(N'tempdb..#obd', N'U') IS NOT NULL +BEGIN + DROP TABLE #obd; +END +CREATE TABLE #obd +( + database_id int NULL + , file_id int NULL + , page_id int NULL + , page_level int NULL + , allocation_unit_id bigint NULL + , page_type nvarchar(60) NULL + , row_count int NULL + , free_space_in_bytes int NULL + , is_modified bit NULL + , numa_node int NULL + , read_microsec bigint NULL +); + + +INSERT INTO #obd +( + database_id + , file_id + , page_id + , page_level + , allocation_unit_id + , page_type + , row_count + , free_space_in_bytes + , is_modified + , numa_node + , read_microsec +) +SELECT + obd.database_id + , obd.file_id + , obd.page_id + , obd.page_level + , obd.allocation_unit_id + , obd.page_type + , obd.row_count + , obd.free_space_in_bytes + , obd.is_modified + , obd.numa_node + , obd.read_microsec +FROM sys.dm_os_buffer_descriptors obd; + +SELECT d.name AS DatabaseName + , obd.page_type + , (COUNT(1) * 8192 / 1048576.0) AS MB_in_memory +FROM #obd obd + INNER JOIN sys.databases d ON obd.database_id = d.database_id +WHERE d.state_desc = N'ONLINE' +GROUP BY d.name + , obd.page_type +ORDER BY d.name + , obd.page_type; + +IF OBJECT_ID(N'tempdb..#allocunits', N'U') IS NOT NULL +BEGIN + DROP TABLE #allocunits; +END +CREATE TABLE #allocunits +( + allocation_unit_id bigint NOT NULL + , ObjectName nvarchar(128) NOT NULL + , database_id smallint NULL +); + +DECLARE @cmd nvarchar(max); +SET @cmd = N''; +DECLARE @serverCollation nvarchar(200) = CAST(SERVERPROPERTY('Collation') AS nvarchar(100)); + +SELECT @cmd = @cmd + CASE WHEN @cmd = N'' THEN N'' ELSE N' +UNION ALL +' END + N'SELECT au.allocation_unit_id + , o.name COLLATE ' + @serverCollation + N' AS ObjectName' + + N', ' + CONVERT(nvarchar(10), d.database_id) + N' AS database_id +FROM ' + QUOTENAME(d.name) + N'.sys.allocation_units au + INNER JOIN ' + QUOTENAME(d.name) + N'.sys.partitions p ON ((au.type = 1 OR au.type = 3) AND (au.container_id = p.hobt_id)) + OR (au.type = 2 AND au.container_id = p.partition_id) + INNER JOIN ' + QUOTENAME(d.name) + N'.sys.objects o ON p.object_id = o.object_id +WHERE o.is_ms_shipped = 0' +FROM sys.databases d +WHERE d.state_desc = N'ONLINE'; + +PRINT(@cmd); + +INSERT INTO #allocunits (allocation_unit_id, ObjectName, database_id) +EXEC sys.sp_executesql @cmd; + +SELECT d.name AS DatabaseName + , au.ObjectName + , obd.page_type + , (COUNT(1) * 8192 / 1048576.0) AS MB_in_memory +FROM #obd obd + INNER JOIN sys.databases d ON obd.database_id = d.database_id + INNER JOIN #allocunits au ON obd.database_id = au.database_id + AND obd.allocation_unit_id = au.allocation_unit_id +GROUP BY d.name + , au.ObjectName + , obd.page_type +ORDER BY d.name + , MB_in_memory DESC + , au.ObjectName + , obd.page_type; diff --git a/Scripts/Move_tempdb.sql b/Scripts/Move_tempdb.sql index 06930a0c..af5e8871 100644 --- a/Scripts/Move_tempdb.sql +++ b/Scripts/Move_tempdb.sql @@ -1,11 +1,61 @@ /* -Author: Brent Ozar -Original link: https://www.brentozar.com/archive/2017/11/move-tempdb-another-drive-folder/ +Author: Michael Petri +Original link: https://gist.github.com/FlogDonkey/3b9851f1c13b94f3f2d26b4ab5b49de0 */ -SELECT 'ALTER DATABASE tempdb MODIFY FILE (NAME = [' + f.name + '],' - + ' FILENAME = ''Z:\MSSQL\DATA\' + f.name - + CASE WHEN f.type = 1 THEN '.ldf' ELSE '.mdf' END - + ''');' -FROM sys.master_files f -WHERE f.database_id = DB_ID(N'tempdb'); +/* + Snippet is nuts and bolts for creating/moving to an isolated tempdb drive. + After you run this, SQL Server must be restarted for it to take effect +*/ +DECLARE @debug BIT = 1; +DECLARE @DriveSizeGB int = 40; +DECLARE @FileCount int = 9; +DECLARE @RowID int; +DECLARE @FileSize varchar(10); +DECLARE @DrivePath nvarchar(512) = N'T:\' + @@SERVICENAME + '\'; + +/* Converts GB to MB */ +SELECT @DriveSizeGB = @DriveSizeGB * 1000; + +/* Splits size by the nine files */ +SELECT @FileSize = @DriveSizeGB / @FileCount; + +/* Table to house requisite SQL statements that will modify the files to the standardized name, and size */ +DECLARE @Command TABLE( + RowID int IDENTITY(1, 1) + ,Command nvarchar(max) +); +INSERT INTO @Command (Command) +SELECT N'ALTER DATABASE tempdb MODIFY FILE (NAME = [' + f.name + N'],' + N' FILENAME = ''' + @DrivePath + f.name + + CASE + WHEN f.type = 1 THEN N'.ldf' + ELSE N'.mdf' + END + N''', SIZE = ' + @FileSize + ');' +FROM sys.master_files AS f +WHERE f.database_id = DB_ID(N'tempdb'); +SET @RowID = @@ROWCOUNT + +/* If there are less files than indicated in @FileCount, add missing lines as ADD FILE commands */ +WHILE @RowID < @FileCount +BEGIN + INSERT INTO @Command (Command) + SELECT N'ALTER DATABASE tempdb ADD FILE (NAME = [temp' + CAST(@RowID AS VARCHAR) + N'],' + N' FILENAME = ''' + @DrivePath + N'temp'+ CAST(@RowID AS varchar(70)) + N'.mdf''' + N', SIZE=' + @FileSize + N');'; + SET @RowID = @RowID + 1; +END + +/* Execute each line to process */ +WHILE @RowID > 0 +BEGIN + DECLARE @WorkingSQL nvarchar(max); + + SELECT @WorkingSQL = Command + FROM @Command + WHERE RowID = @RowID; + + IF @debug = 1 + PRINT(@WorkingSQL) + ELSE + EXEC (@WorkingSQL); + + SET @RowID = @RowID - 1; +END; diff --git a/Scripts/Numbers_DATALENGTH.sql b/Scripts/Numbers_DATALENGTH.sql new file mode 100644 index 00000000..f3d37075 --- /dev/null +++ b/Scripts/Numbers_DATALENGTH.sql @@ -0,0 +1,17 @@ +SELECT DATALENGTH(CAST(99999999999999999999999999999999999999 AS decimal(38, 0))) AS DECIMAL38 + , DATALENGTH(CAST( 9999999999999999999999999999 AS decimal(28, 0))) AS DECIMAL28 + , DATALENGTH(CAST( 9999999999999999999 AS decimal(19, 0))) AS DECIMAL19 + , DATALENGTH(CAST( 999999999 AS decimal( 9, 0))) AS DECIMAL9 + , DATALENGTH(CAST( 9 AS decimal( 1, 0))) AS DECIMAL1 + , DATALENGTH(CAST( 1.797693134862315807E+308 AS float(53))) AS FLOAT53 + , DATALENGTH(CAST( 9999999999999999999999999 AS float(25))) AS FLOAT25 + , DATALENGTH(CAST( 999999999999999999999999 AS float(24))) AS FLOAT24 + , DATALENGTH(CAST( 9 AS float( 1))) AS FLOAT1 + , DATALENGTH(CAST( 999999999999999999999999 AS real)) AS "REAL" + , DATALENGTH(CAST( 9223372036854775807 AS bigint )) AS "BIGINT" + , DATALENGTH(CAST( 2147483647 AS int )) AS "INT" + , DATALENGTH(CAST( 32600 AS smallint )) AS "SMALLINT" + , DATALENGTH(CAST( 255 AS tinyint )) AS "TINYINT" + , DATALENGTH(CAST( 0 AS bit )) AS BIT0 + , DATALENGTH(CAST( 1.797693134862315807E+308 AS bit )) AS BIT1 + , DATALENGTH(POWER(10.0, 37)) AS "Power10^37"; diff --git a/Scripts/ObjectSizes.sql b/Scripts/ObjectSizes.sql deleted file mode 100644 index a1b980cf..00000000 --- a/Scripts/ObjectSizes.sql +++ /dev/null @@ -1,36 +0,0 @@ -/* -Author: @DBA_ANDY -Original link: http://nebraskasql.blogspot.ru/2017/07/toolbox-which-tables-are-using-all-of.html -Desctiption: Which Tables are Using All of My Space? -*/ - -/* -Object Sizes -Modified from http://stackoverflow.com/questions/15896564/get-table-and-index-storage-size-in-sql-server -*/ -SELECT TOP 50 - @@SERVERNAME as InstanceName - , DB_NAME() as DatabaseName - , s.NAME AS SchemaName - , t.NAME AS TableName - , SUM(p.rows) AS RowCounts - --, SUM(a.total_pages) * 8 AS TotalSpaceKB - , SUM(a.total_pages) * 8/1024.0 AS TotalSpaceMB - , SUM(a.total_pages) * 8/1024.0/1024.0 AS TotalSpaceGB - , SUM(a.used_pages) * 8/1024.0 AS UsedSpaceMB - , (SUM(a.total_pages) - SUM(a.used_pages)) * 8/1024.0 AS UnusedSpaceMB -FROM sys.tables t -INNER JOIN sys.schemas s -ON s.schema_id = t.schema_id -INNER JOIN sys.indexes i -ON t.OBJECT_ID = i.object_id -INNER JOIN sys.partitions p -ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id -INNER JOIN sys.allocation_units a -ON p.partition_id = a.container_id -WHERE t.NAME NOT LIKE 'dt%' -- filter out system tables for diagramming -AND t.is_ms_shipped = 0 -AND i.OBJECT_ID > 255 -GROUP BY t.Name -, s.Name -ORDER BY TotalSpaceMB DESC diff --git a/Scripts/Objects_Size_In_Database.sql b/Scripts/Objects_Size_In_Database.sql new file mode 100644 index 00000000..4b131069 --- /dev/null +++ b/Scripts/Objects_Size_In_Database.sql @@ -0,0 +1,31 @@ +/* + + Count size in bytes veiws, triggers, procedures and function in database. + 1 data set: RoutinType, SUM LENGTH of objects, SUM DATALENGTH. + No + Cade Roux + 2008-10-20 + 2019-06-26 by Konstantin Taranov + 1.0 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Objects_Size_In_Database.sql + https://stackoverflow.com/a/219740/2298061 + +*/ + +SET NOCOUNT ON; +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; + +WITH CTE_Routine AS ( + /* Can not use INFORMATION_SCHEMA.ROUTINES because of 4000 character limit */ + SELECT o.type_desc AS RoutineType + , o.[name] AS RoutineName + , m.[definition] AS RoutineDefinition + FROM sys.sql_modules AS m + INNER JOIN sys.objects AS o ON m.object_id = o.object_id +) +SELECT RoutineType + , SUM(LEN(RoutineDefinition)) AS RoutineLen + /* DATALENGTH for counting trailing space in the end of objects definitions */ + , SUM(DATALENGTH(RoutineDefinition)) / 2 AS RoutineDatalength +FROM CTE_Routine +GROUP BY RoutineType; diff --git a/Scripts/Overview_HADR_AlwaysOn_Local_Replica_Server.sql b/Scripts/Overview_HADR_AlwaysOn_Local_Replica_Server.sql new file mode 100644 index 00000000..1187f4e4 --- /dev/null +++ b/Scripts/Overview_HADR_AlwaysOn_Local_Replica_Server.sql @@ -0,0 +1,62 @@ +/*================================================================== +Script: HADR Local Replica Overview.sql +Description: This script will display a utilisation overview +of the local Availability Group Replica Server. +The overview will contain amount of databases as +well as total size of databases (DATA, LOG, FILESTREAM) +and is group by ... +1) ... Replica role (PRIMARY / SECONDARY) +2) ... Availability Group +Сreated вфеу: 2018-09-05 +Author: Dominic Wirth +Original link: https://blog.sqlauthority.com/2018/09/11/sql-server-scripts-to-overview-hadr-alwayson-local-replica-server/ +Source link: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Overview_HADR_AlwaysOn_Local_Replica_Server.sql +Modified: 2019-01-29 by Konstantin Taranov +Script Version: 1.1 +SQL Version: SQL Server 2014 or higher +====================================================================*/ + + +-- Load size of databases which are part of an Availability Group +DECLARE @dbSizes TABLE (DatabaseId INT, + DbTotalSizeMB INT, + DbTotalSizeGB DECIMAL(10,2)); +DECLARE @dbId INT, @stmt NVARCHAR(MAX); + +SELECT @dbId = MIN(database_id) +FROM sys.databases +WHERE group_database_id IS NOT NULL; + +WHILE @dbId IS NOT NULL +BEGIN + SELECT @stmt = 'USE [' + DB_NAME(@dbId) + ']; SELECT ' + CAST(@dbId AS NVARCHAR) + ', (SUM([size]) / 128.0), (SUM([size]) / 128.0 / 1024.0) FROM sys.database_files;'; + INSERT INTO @dbSizes + (DatabaseId, DbTotalSizeMB, DbTotalSizeGB) + EXEC (@stmt); + SELECT @dbId = MIN(database_id) + FROM sys.databases + WHERE group_database_id IS NOT NULL AND database_id > @dbId; +END; + +-- Show utilisation overview grouped by replica role +SELECT AR.replica_server_name, DRS.is_primary_replica AS IsPrimaryReplica, COUNT(DB.database_id) AS [Databases] +, SUM(DBS.DbTotalSizeMB) AS SizeOfAllDatabasesMB, SUM(DBS.DbTotalSizeGB) AS SizeOfAllDatabasesGB +FROM sys.dm_hadr_database_replica_states AS DRS + INNER JOIN sys.availability_replicas AS AR ON DRS.replica_id = AR.replica_id + LEFT JOIN sys.databases AS DB ON DRS.group_database_id = DB.group_database_id + LEFT JOIN @dbSizes AS DBS ON DB.database_id = DBS.DatabaseId +WHERE DRS.is_local = 1 +GROUP BY DRS.is_primary_replica, AR.replica_server_name +ORDER BY AR.replica_server_name ASC, DRS.is_primary_replica DESC; + +-- Show utilisation overview grouped by Availability Group +SELECT AR.replica_server_name, DRS.is_primary_replica AS IsPrimaryReplica, AG.[name] AS AvailabilityGroup, COUNT(DB.database_id) AS [Databases] +, SUM(DBS.DbTotalSizeMB) AS SizeOfAllDatabasesMB, SUM(DBS.DbTotalSizeGB) AS SizeOfAllDatabasesGB +FROM sys.dm_hadr_database_replica_states AS DRS + INNER JOIN sys.availability_groups AS AG ON DRS.group_id = AG.group_id + INNER JOIN sys.availability_replicas AS AR ON DRS.replica_id = AR.replica_id + LEFT JOIN sys.databases AS DB ON DRS.group_database_id = DB.group_database_id + LEFT JOIN @dbSizes AS DBS ON DB.database_id = DBS.DatabaseId +WHERE DRS.is_local = 1 +GROUP BY AG.[name], DRS.is_primary_replica, AR.replica_server_name +ORDER BY AG.[name] ASC, AR.replica_server_name ASC; diff --git a/Scripts/PIVOT_Columns_generator.sql b/Scripts/PIVOT_Columns_generator.sql new file mode 100644 index 00000000..5af63b2c --- /dev/null +++ b/Scripts/PIVOT_Columns_generator.sql @@ -0,0 +1,22 @@ +/* + + Generate numeric columns for PIVOT statement + 1 column + No + 2020-01-23 by Konstantin Taranov + 1.0 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/PIVOT_Columns_generator.sql + +*/ + +DECLARE @i int = 1990; +DECLARE @s varchar(max) = ''; +DECLARE @sep varchar(10) = ', '; + +WHILE @i <= 2020 +BEGIN + SET @s = @s + '[' + CAST(@i AS varchar) + ']' + @sep; + SET @i = @i + 1; +END; + +SELECT LEFT(@s, DATALENGTH(@s) - DATALENGTH(@sep)) AS y; diff --git a/Scripts/Partial_Restore_Demo.sql b/Scripts/Partial_Restore_Demo.sql new file mode 100644 index 00000000..78512e0c --- /dev/null +++ b/Scripts/Partial_Restore_Demo.sql @@ -0,0 +1,147 @@ +use master +GO +CREATE DATABASE AdventureWorks2012 +GO +-- Make sure, the db is in full recovery mode +ALTER DATABASE AdventureWorks2012 SET RECOVERY FULL; +GO +BACKUP DATABASE AdventureWorks2012 TO DISK = 'NUL' +GO +USE AdventureWorks2012; +GO +-- Adds four new filegroups to the AdventureWorks2012 database +ALTER DATABASE AdventureWorks2012 +ADD FILEGROUP test1fg; +GO +ALTER DATABASE AdventureWorks2012 +ADD FILEGROUP test2fg; +GO +ALTER DATABASE AdventureWorks2012 +ADD FILEGROUP test3fg; +GO +ALTER DATABASE AdventureWorks2012 +ADD FILEGROUP test4fg; + +-- Adds one file for each filegroup. +ALTER DATABASE AdventureWorks2012 +ADD FILE +( + NAME = test1dat1, + FILENAME = 'X:\MSSQL\DATA\t1dat1.ndf', + SIZE = 5MB, + MAXSIZE = 100MB, + FILEGROWTH = 5MB +) +TO FILEGROUP test1fg; +ALTER DATABASE AdventureWorks2012 +ADD FILE +( + NAME = test2dat2, + FILENAME = 'X:\MSSQL\DATA\t2dat2.ndf', + SIZE = 5MB, + MAXSIZE = 100MB, + FILEGROWTH = 5MB +) +TO FILEGROUP test2fg; +GO +ALTER DATABASE AdventureWorks2012 +ADD FILE +( + NAME = test3dat3, + FILENAME = 'X:\MSSQL\DATA\t3dat3.ndf', + SIZE = 5MB, + MAXSIZE = 100MB, + FILEGROWTH = 5MB +) +TO FILEGROUP test3fg; +GO +ALTER DATABASE AdventureWorks2012 +ADD FILE +( + NAME = test4dat4, + FILENAME = 'X:\MSSQL\DATA\t4dat4.ndf', + SIZE = 5MB, + MAXSIZE = 100MB, + FILEGROWTH = 5MB +) +TO FILEGROUP test4fg; +GO +-- Creates a partition function called myRangePF1 that will partition a table into four partitions +CREATE PARTITION FUNCTION myRangePF1 (int) + AS RANGE LEFT FOR VALUES (1, 100, 1000) ; +GO +-- Creates a partition scheme called myRangePS1 that applies myRangePF1 to the four filegroups created above +CREATE PARTITION SCHEME myRangePS1 + AS PARTITION myRangePF1 + TO (test1fg, test2fg, test3fg, test4fg) ; +GO +-- Creates a partitioned table called PartitionTable that uses myRangePS1 to partition col1 +CREATE TABLE PartitionTable (col1 int PRIMARY KEY, col2 char(10)) + ON myRangePS1 (col1) ; +GO + +-- Insert some values into each partition +insert into PartitionTable +values (0, 'ska'),(50, 'pop'),(150, 'rap'),(1050, 'rock') +GO + +--Backup of Primary filegroup +BACKUP DATABASE [AdventureWorks2012] FILEGROUP = N'PRIMARY' +TO DISK = N'X:\MSSQL\backup\primary.bak' WITH NOFORMAT, NOINIT, +NAME = N'PrimaryFG Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10 +GO + +--Backup of FG1 filegroup +BACKUP DATABASE [AdventureWorks2012] FILEGROUP = N'test1fg' +TO DISK = N'X:\MSSQL\backup\test1fg.bak' WITH NOFORMAT, NOINIT, +NAME = N'FG1 Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10 +GO + +--Backup of FG2 filegroup +BACKUP DATABASE [AdventureWorks2012] FILEGROUP = N'test2fg' +TO DISK = N'X:\MSSQL\backup\test2fg.bak' WITH NOFORMAT, NOINIT, +NAME = N'FG2 Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10 +GO + +--Backup of FG3 filegroup +BACKUP DATABASE [AdventureWorks2012] FILEGROUP = N'test3fg' +TO DISK = N'X:\MSSQL\backup\test3fg.bak' WITH NOFORMAT, NOINIT, +NAME = N'FG3 Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10 +GO + +--Backup of FG4 filegroup +BACKUP DATABASE [AdventureWorks2012] FILEGROUP = N'test4fg' +TO DISK = N'X:\MSSQL\backup\test4fg.bak' WITH NOFORMAT, NOINIT, +NAME = N'FG4 Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10 +GO + +-- We have to take log backup, or else we will not be able to finish restore +BACKUP LOG [AdventureWorks2012] TO DISK = N'X:\MSSQL\backup\aw2012_log.trn' WITH NOFORMAT, NOINIT, NAME = N'AdventureWorks2012-Transaction Log Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10 +GO + +-- Restore our backups of only primary FG into new database with NORECOVERY +RESTORE DATABASE TestDB FILEGROUP='Primary' FROM DISK = N'X:\MSSQL\backup\primary.bak' +WITH +MOVE 'AdventureWorks2012' TO 'X:\MSSQL\DATA\AdventureWorks2012Copy_Data.mdf', +MOVE 'AdventureWorks2012_Log' TO 'X:\MSSQL\DATA\AdventureWorks2012Copy_Log.ldf', NORECOVERY, +PARTIAL +GO + +-- Restore additional FG with NORECOVERY +RESTORE DATABASE TestDB FILEGROUP='test1fg' FROM DISK = N'X:\MSSQL\backup\test1fg.bak' +WITH +MOVE 'test1dat1' TO 'X:\MSSQL\DATA\test1dat1_copy.ndf', NORECOVERY +GO + +-- After restoring all required FGs, restore the log backup WITH RECOVERY +restore log TestDB FROM DISK = 'X:\MSSQL\backup\aw2012_log.trn' +GO + + +-- Lets have a look at the cintents of partially restored table. It gives an error, but still shows the rows from range residing in FG we have restored. +use TestDB +GO +select * from PartitionTable + +-- This select doesn't cause any errors, because we have limited output to the boundary of our partition. +select * from PartitionTable where col1 <= 1 \ No newline at end of file diff --git a/Scripts/Pattern_Match.sql b/Scripts/Pattern_Match.sql new file mode 100644 index 00000000..0427bf1f --- /dev/null +++ b/Scripts/Pattern_Match.sql @@ -0,0 +1,63 @@ +/* +https://sqlserverfast.com/blog/hugo/2019/04/removing-multiple-patterns-from-a-string/ +*/ + +IF OBJECT_ID('Number', N'U') IS NULL +BEGIN + CREATE TABLE Number ( + N INT CONSTRAINT Number_PK PRIMARY KEY CLUSTERED(N) + ); + + WITH + L0 AS(SELECT 1 AS C UNION ALL SELECT 1 AS O), -- 2 rows + L1 AS(SELECT 1 AS C FROM L0 AS A CROSS JOIN L0 AS B), -- 4 rows + L2 AS(SELECT 1 AS C FROM L1 AS A CROSS JOIN L1 AS B), -- 16 rows + L3 AS(SELECT 1 AS C FROM L2 AS A CROSS JOIN L2 AS B), -- 256 rows + L4 AS(SELECT 1 AS C FROM L3 AS A CROSS JOIN L3 AS B), -- 65,536 rows + L5 AS(SELECT 1 AS C FROM L4 AS A CROSS JOIN L4 AS B), -- 4,294,967,296 rows + Nums AS(SELECT ROW_NUMBER() OVER(ORDER BY (SELECT NULL)) AS N FROM L5) + + INSERT INTO Number SELECT TOP 10000 N FROM Nums ORDER BY N; +END + +DECLARE @test table + (PartNo varchar(50) NOT NULL PRIMARY KEY); +INSERT @test +VALUES ('ABC-12%D^^^E3T'), + ('AB345%6%-44%^^^^No.XXXNo.W8RNo.8R8D'); + + +WITH Patterns + AS (SELECT Pattern, + Length + FROM (VALUES ('%-[0-9][0-9][%]%', 4), -- -@@% + ('%[0-9][0-9][%]%', 3), -- @@% + ('%-[0-9][%]%', 3), -- -@% + ('%[0-9][%]%', 2), -- @% + ('%No.[A-Z][A-Z0-9][A-Z]%', 6), -- No.X#X + ('%^^^%', 3), -- ^^^ + ('%[0-9][A-Z]', 2) -- @X (end of string) + ) AS Patterns (Pattern, Length) ) +SELECT t.PartNo, + (SELECT SUBSTRING(t.PartNo, n.N, 1) + FROM dbo.Number AS n + WHERE n.N BETWEEN 1 + AND LEN(t.PartNo) + AND NOT EXISTS (SELECT * + FROM Patterns AS p + WHERE PATINDEX( + p.Pattern, + STUFF(t.PartNo, + 1, + CASE WHEN n.N > p.Length + THEN n.N - p.Length + ELSE 0 + END, + '')) BETWEEN 1 + AND CASE WHEN n.N > p.Length + THEN p.Length + ELSE n.N + END) + ORDER BY n.N + FOR XML PATH('')) +FROM @test AS t; diff --git a/Scripts/Queries_with_parallelism.sql b/Scripts/Queries_with_parallelism.sql new file mode 100644 index 00000000..6f723b41 --- /dev/null +++ b/Scripts/Queries_with_parallelism.sql @@ -0,0 +1,41 @@ +/* +Author: Eitan Blumin +Source link: http://www.madeiradata.com/cost-threshold-for-parallelism-and-how-to-increase-it-properly/ +*/ + +DECLARE + @MinUseCount INT = 50 -- Set minimum usecount to ignore rarely-used plans + , @CurrentCostThreshold FLOAT = 5 -- Serves as minimum sub-tree cost + , @MaxSubTreeCost FLOAT = 30 -- Set the maximum sub-tree cost, plans with higher cost than this wouldn't normally interest us + +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; + +SELECT @CurrentCostThreshold = CONVERT(FLOAT, value_in_use) +FROM sys.configurations +WHERE [name] = 'cost threshold for parallelism'; + +WITH XMLNAMESPACES +(DEFAULT 'http://schemas.microsoft.com/sqlserver/2004/07/showplan') +SELECT * +FROM +( +SELECT + ecp.plan_handle, + CompleteQueryPlan = query_plan, + StatementText = n.value('(@StatementText)[1]', 'VARCHAR(4000)'), + StatementSubTreeCost = n.value('(@StatementSubTreeCost)[1]', 'VARCHAR(128)'), + ParallelSubTreeXML = n.query('.'), + ecp.usecounts, + ecp.size_in_bytes, + RankPerText = ROW_NUMBER() OVER (PARTITION BY n.value('(@StatementText)[1]', 'VARCHAR(4000)') ORDER BY ecp.usecounts DESC) +FROM sys.dm_exec_cached_plans AS ecp +CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS eqp +CROSS APPLY query_plan.nodes('/ShowPlanXML/BatchSequence/Batch/Statements/StmtSimple') AS qn(n) +WHERE n.query('.').exist('//RelOp[@PhysicalOp="Parallelism"]') = 1 +AND ecp.usecounts > @MinUseCount +AND n.value('(@StatementSubTreeCost)[1]', 'float') BETWEEN @CurrentCostThreshold AND @MaxSubTreeCost +) AS Q +WHERE + RankPerText = 1 -- This would filter out duplicate statements, returning only those with the highest usecount +ORDER BY + usecounts DESC; diff --git a/Scripts/Query_Store_Export.sql b/Scripts/Query_Store_Export.sql new file mode 100644 index 00000000..a4591945 --- /dev/null +++ b/Scripts/Query_Store_Export.sql @@ -0,0 +1,163 @@ +/* + + dump the previous 8 hours of data from Query Store + 1 query set + No + 2020-01-24 by Greg Gonzalez + 1.0 + https://sqlperformance.com/2020/01/sql-performance/why-waits-alone-are-not-enough + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Query_Store_Export.sql + +*/ + +DECLARE @HoursBack smallint = 8; +DECLARE @StartDate datetime2 = DATEADD(hour, -@HoursBack, GETUTCDATE()); + +WITH QueryRuntimeStats AS ( + SELECT + p.plan_id + ,q.query_id + ,q.query_hash + ,SUM(rs.count_executions) AS total_executions + ,SUM(rs.count_executions * rs.avg_duration) / 1000 AS total_duration_ms + ,SUM(rs.count_executions * rs.avg_cpu_time) / 1000 AS total_cpu_ms + ,SUM(rs.count_executions * rs.avg_clr_time) / 1000 AS total_clr_time_ms + ,SUM(rs.count_executions * rs.avg_query_max_used_memory) AS total_query_max_used_memory + ,SUM(rs.count_executions * rs.avg_logical_io_reads) AS total_logi_reads + ,SUM(rs.count_executions * rs.avg_logical_io_writes) AS total_logi_writes + ,SUM(rs.count_executions * rs.avg_physical_io_reads) AS total_phys_reads + ,SUM(rs.count_executions * rs.avg_rowcount) AS total_rowcount + ,SUM(rs.count_executions * rs.avg_log_bytes_used) AS total_log_bytes_used + ,SUM(rs.count_executions * rs.avg_tempdb_space_used) AS total_tempdb_space_used + from sys.query_store_plan p + join sys.query_store_query q + on q.query_id = p.query_id + join sys.query_store_runtime_stats rs + on rs.plan_id = p.plan_id + join sys.query_store_runtime_stats_interval rsi + on rsi.runtime_stats_interval_id = rs.runtime_stats_interval_id + where rsi.start_time > @StartDate + group by + p.plan_id + ,q.query_id + ,q.query_hash +) +,QueryWaitStats AS ( + SELECT + p.plan_id + ,q.query_id + ,q.query_hash + ,ws.wait_category_desc + ,SUM(ws.total_query_wait_time_ms) AS total_wait_time_ms + FROM sys.query_store_plan p + JOIN sys.query_store_query q + ON q.query_id = p.query_id + JOIN sys.query_store_wait_stats ws + ON ws.plan_id = p.plan_id + JOIN sys.query_store_runtime_stats_interval rsi + ON rsi.runtime_stats_interval_id = ws.runtime_stats_interval_id + WHERE rsi.start_time > @StartDate + GROUP BY + p.plan_id + ,q.query_id + ,q.query_hash + ,ws.wait_category_desc +) +,QueryWaitStatsByCategory +AS +( + SELECT * + FROM QueryWaitStats + PIVOT + ( + SUM(total_wait_time_ms) + FOR wait_category_desc IN + ( + [Unknown] + ,[CPU] + ,[Worker Thread] + ,[Lock] + ,[Latch] + ,[Buffer Latch] + ,[Buffer IO] + ,[Compilation] + ,[SQL CLR] + ,[Mirroring] + ,[Transaction] + ,[Idle] + ,[Preemptive] + ,[Service Broker] + ,[Tran Log IO] + ,[Network IO] + ,[Parallelism] + ,[Memory] + ,[User Wait] + ,[Tracing] + ,[Full Text Search] + ,[Other Disk IO] + ,[Replication] + ,[Log Rate Governor] + ) + ) AS pvt +) +,QueryWaitStatsTotals +AS +( + SELECT + plan_id + ,query_id + ,query_hash + ,SUM(total_wait_time_ms) AS total_wait_time_ms + FROM QueryWaitStats + GROUP BY + plan_id + ,query_id + ,query_hash +) +SELECT + rs.plan_id + , rs.query_id + , rs.query_hash + , rs.total_executions + , rs.total_duration_ms + , rs.total_cpu_ms + , rs.total_clr_time_ms + , rs.total_query_max_used_memory + , rs.total_logi_reads + , rs.total_logi_writes + , rs.total_phys_reads + , rs.total_rowcount + , rs.total_log_bytes_used + , rs.total_tempdb_space_used + , ws.total_wait_time_ms + , wsc.[CPU] + , wsc.[Lock] + , wsc.[Latch] + , wsc.[Buffer Latch] + , wsc.[Buffer IO] + , wsc.[Memory] + , wsc.[Tran Log IO] + , wsc.[Network IO] + , wsc.[Worker Thread] + , wsc.[Unknown] + , wsc.[Compilation] + , wsc.[SQL CLR] + , wsc.[Mirroring] + , wsc.[Transaction] + , wsc.[Idle] + , wsc.[Preemptive] + , wsc.[Service Broker] + , wsc.[Parallelism] + , wsc.[User Wait] + , wsc.[Tracing] + , wsc.[Full Text Search] + , wsc.[Other Disk IO] + , wsc.[Replication] + , wsc.[Log Rate Governor] +FROM QueryRuntimeStats rs +LEFT JOIN QueryWaitStatsTotals AS ws + ON rs.plan_id = ws.plan_id + AND rs.query_id = ws.query_id +LEFT JOIN QueryWaitStatsByCategory AS wsc + ON rs.plan_id = wsc.plan_id + AND rs.query_id = wsc.query_id; diff --git a/Scripts/README.md b/Scripts/README.md index 22ef6d99..32eea1bf 100644 --- a/Scripts/README.md +++ b/Scripts/README.md @@ -1,103 +1,3 @@ # Usefull SQL Server Scripts - -## [SQL Server 2016 Diagnostic Information Queries](SQL Server 2016 Diagnostic Information Queries.sql) -Author: Glenn Alan Berry
-Original link: http://www.sqlskills.com/blogs/glenn/sql-server-diagnostic-information-queries-for-june-2016/
-Tested on SQL Server version: 2016 - - -## [SQL Server 2012 Diagnostic Information Queries](SQL Server 2012 Diagnostic Information Queries.sql) -Author: Glenn Alan Berry
-Original link: http://www.sqlskills.com/blogs/glenn/sql-server-diagnostic-information-queries-for-june-2016/
-Tested on SQL Server version: 2012 - - -## [SQL Server 2008 R2 Diagnostic Information Queries](SQL Server 2008 R2 Diagnostic Information Queries.sql) -Author: Glenn Alan Berry
-Original link: http://www.sqlskills.com/blogs/glenn/sql-server-diagnostic-information-queries-for-june-2016/
-Tested on SQL Server version: 2008 - - -## [SQL Server 2008 Diagnostic Information Queries](SQL Server 2008 Diagnostic Information Queries.sql) -Author: Glenn Alan Berry
-Original link: http://www.sqlskills.com/blogs/glenn/sql-server-diagnostic-information-queries-for-june-2016/
-Tested on SQL Server version: 2008 - - -## [SQL Server 2014 Diagnostic Information Queries](SQL Server 2014 Diagnostic Information Queries.sql) -Author: Glenn Alan Berry
-Original link: http://www.sqlskills.com/blogs/glenn/sql-server-diagnostic-information-queries-for-june-2016/
-Tested on SQL Server version: 2014 - - -## [SQL Server 2005 Diagnostic Information Queries](SQL Server 2005 Diagnostic Information Queries.sql) -Author: Glenn Alan Berry
-Original link: http://www.sqlskills.com/blogs/glenn/sql-server-diagnostic-information-queries-for-june-2016/
-Tested on SQL Server version: 2005 - - -## [Auto generate SQL Server restore script from backup files in a directory](Generate_Restore_Script_From_Backup_Folder.sql) -Author: Greg Robidoux
-Original link: https://www.mssqltips.com/sqlservertip/1584/auto-generate-sql-server-restore-script-from-backup-files-in-a-directory/ -Tested on SQL Server version: 2008/2012/2014/2016 - - -## [CPU Utilization Graphical form](CPU_Utilization_Graphical_form.sql) -Author: Slava Murygin
-Original link: http://slavasql.blogspot.ru/2016/03/sql-server-cpu-utilization-in-graphical.html
-Tested on SQL Server version: 2012/2014 - - -## [CPU Utilization](CPU_Utilization.sql) -Author: Benjamin Nevarez
-Original link: http://sqlblog.com/blogs/ben_nevarez/archive/2009/07/26/getting-cpu-utilization-data-from-sql-server.aspx
-Tested on SQL Server version: 2014 - - -## [Restore script for Ola Hallengren backup](Restore_script_for_Ola_Hallengren_backup.sql) -Author: Joe O'Connor
-Original link: http://www.sqlservercentral.com/scripts/Restore/140540/
-Tested on SQL Server version: 2014 - - -## [Search Script](Search_Script.sql) -Author: Ed Pollack
-Original link: http://www.sqlshack.com/searching-sql-server-made-easy-building-the-perfect-search-script/
-Tested on SQL Server version: 2014 - - -## [Table count alternative](Table Count alternative.sql) -Author: Jes Schultz Borland
-Original link: http://www.brentozar.com/archive/2014/02/count-number-rows-table-sql-server/
-Tested on SQL Server version: 2008/2012/2014/2016 - - -## [Foreign Key batch rename](Foreign Key batch rename.sql) -Author: Wes Henriksen
-Original link: http://www.brentozar.com/archive/2014/02/count-number-rows-table-sql-server/
-Tested on SQL Server version: 2008/2012/2014 - - -## [Count character matches](Count character matches.sql) -Author: Sean Smith
-Original link: http://www.sqlservercentral.com/scripts/Date/68389/
-Tested on SQL Server version: 2008/2012/2014 - - -## [Index Breakdown](Index Breakdown.sql) -Author: Sean Smith
-Original link: http://www.sqlservercentral.com/scripts/Indexing/104395/
-Tested on SQL Server version: 2014 - - -## [Indexes Script Out](Indexes_Script_Out.sql) -Author: Kendra Little
-Original link: http://www.littlekendra.com/2016/05/05/how-to-script-out-indexes-from-sql-server/
-Tested on SQL Server version: 2012/2014 - - -## [Query Active Directory](QueryActiveDirectory.sql) -Author: Ryan Adams
-Original link: http://www.ryanjadams.com/2016/03/query-active-directory-sql-server/
-Tested on SQL Server version: 2014 +More than 100 useful scripts for SQL Server diff --git a/Scripts/Read_Default_Trace.sql b/Scripts/Read_Default_Trace.sql new file mode 100644 index 00000000..ce80a853 --- /dev/null +++ b/Scripts/Read_Default_Trace.sql @@ -0,0 +1,69 @@ +/* + + Dynamically generate GRANTs. + PRINT dynamically generated GRANTs for user. + 2020-03-02 by Aaron Bertrand + 2020-03-05 by Konstantin Taranov + 1.1 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Read_Default_Trace.sql + https://sqlperformance.com/2020/03/extended-events/removing-default-trace-1 + +*/ + + +IF OBJECT_ID('tempdb..#t','U') IS NOT NULL DROP TABLE #t; +GO + +WITH filesrc ([path]) AS +( + SELECT REVERSE(SUBSTRING(p, CHARINDEX(N'\', p), 260)) + N'log.trc' + FROM (SELECT REVERSE([path]) FROM sys.traces WHERE is_default = 1) s(p) +), +tracedata AS +( + SELECT Context = CASE + WHEN DDL = 1 THEN + CASE WHEN LEFT(ObjectName,8) = N'_WA_SYS_' + THEN 'AutoStat: ' + DBType + WHEN LEFT(ObjectName,2) IN (N'PK', N'UQ', N'IX') AND ObjectName LIKE N'%[_#]%' + THEN UPPER(LEFT(ObjectName,2)) + ': tempdb' + WHEN ObjectType = 17747 AND ObjectName LIKE N'TELEMETRY%' + THEN 'Telemetry' + ELSE 'Other DDL in ' + DBType END + WHEN EventClass = 116 THEN + CASE WHEN TextData LIKE N'%checkdb%' THEN 'DBCC CHECKDB' + -- several more of these ... + ELSE UPPER(CONVERT(nchar(32), TextData)) END + ELSE DBType END, + EventName = CASE WHEN DDL = 1 THEN 'DDL' ELSE EventName END, + EventSubClass, + EventClass, + StartTime + FROM + ( + SELECT DDL = CASE WHEN t.EventClass IN (46,47,164) THEN 1 ELSE 0 END, + TextData = LOWER(CONVERT(nvarchar(512), t.TextData)), + EventName = e.[name], + t.EventClass, + t.EventSubClass, + ObjectName = UPPER(t.ObjectName), + t.ObjectType, + t.StartTime, + DBType = CASE WHEN t.DatabaseID = 2 OR t.ObjectName LIKE N'#%' THEN 'tempdb' + WHEN t.DatabaseID IN (1,3,4) THEN 'System database' + WHEN t.DatabaseID IS NOT NULL THEN 'User database' ELSE '?' END + FROM filesrc CROSS APPLY sys.fn_trace_gettable(filesrc.[path], DEFAULT) AS t + LEFT OUTER JOIN sys.trace_events AS e ON t.EventClass = e.trace_event_id + ) AS src WHERE (EventSubClass IS NULL) + OR (EventSubClass = CASE WHEN DDL = 1 THEN 1 ELSE EventSubClass END) -- ddl_phase +) +SELECT @@SERVERNAME AS "Instance", + EventName, + Context, + EventCount = COUNT(*), + FirstSeen = MIN(StartTime), + LastSeen = MAX(StartTime) +INTO #t FROM tracedata +GROUP BY GROUPING SETS ((), (EventName, Context)); + +SELECT * FROM #t ORDER BY EventCount DESC; diff --git a/Scripts/Read_Error_Log_File.sql b/Scripts/Read_Error_Log_File.sql new file mode 100644 index 00000000..284220bb --- /dev/null +++ b/Scripts/Read_Error_Log_File.sql @@ -0,0 +1,125 @@ +/* +Created: 2019-03-05 by Max Vernon +Modified: 2019-03-26 by Konstantin Taranov +Original link: https://www.sqlserverscience.com/tools/error-log-analysis-script/ +Source link: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Read_Error_Log_File.sql +Note: Shows the contents of the SQL Server Error Log files, up to a maximum of the most recent 9 files. +Certain "noisy" log messages are filtered out via the #exclusions temp table. +*/ + +SET NOCOUNT ON; + +DECLARE @ErrorLogType tinyint; +SET @ErrorLogType = 1; --1 for SQL Server Error log, 2 for SQL Server Agent Log + +IF OBJECT_ID(N'tempdb..#exclusions', N'U') IS NOT NULL DROP TABLE #exclusions; + +CREATE TABLE #exclusions +( + LogTextToExclude VARCHAR(4000)-- COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL + -- PRIMARY KEY CLUSTERED + , LogType tinyint NOT NULL +); + +-- the pipe symbol, "|", should be used as the escape character +INSERT INTO #exclusions (LogTextToExclude, LogType) +VALUES ('%Using ''dbghelp.dll'' version ''4.0.5''%', 1) + , ('%informational message%no user action is required%', 1) + , ('Log was backed up%', 1) + , ('Database backed up%', 1) + , ('BACKUP DATABASE %', 1) + , ('DBCC %', 1) + , ('Setting database option RECOVERY to %', 1) + , ('This instance of SQL Server has been using a process ID of %', 1) + , ('Starting up database%', 1) + , ('Software Usage Metrics is enabled.', 1) + , ('|[184|] Job completion for % is being logged to sysjobhistory%', 2) + , ('|[177|] Job % has been requested to run by Schedule %', 2) + , ('|[248|] Saving NextRunDate/Times for all updated job schedules...%', 2) + , ('|[249|] % job schedule|(s|) saved%', 2) + , ('|[182|] Job completion for % is being logged to the eventlog%', 2) + , ('|[171|] There are % alert|(s|) in the alert cache%', 2) + , ('|[168|] There are 21 job(s) |[0 disabled|] in the job cache%', 2) + , ('|[170|] Populating alert cache...%', 2) + , ('|[473|] Database Mail profile DBA refreshed.%', 2) + , ('|[353|] Mail session started%', 2) + , ('|[273|] Mail dispatcher started%', 2) + , ('|[174|] Job scheduler engine started |(maximum user worker threads: 200, maximum system worker threads: 100|)%', 2) + , ('|[193|] Alert engine started |(using Eventlog Events|)%', 2) + , ('|[146|] Request servicer engine started%', 2) + , ('|[167|] Populating job cache...%', 2) + , ('|[133|] Support engine started%', 2) + , ('|[271|] Idle processor poller started%', 2) + + +IF OBJECT_ID(N'tempdb..#mverrlog', N'U') IS NOT NULL +DROP TABLE #mverrlog; +CREATE TABLE #mverrlog +( + RowNum INT PRIMARY KEY CLUSTERED IDENTITY(1,1) + , ErrorLogFileNum INT NULL + , LogDate DATETIME NOT NULL + , ProcessInfo NVARCHAR(255) NOT NULL + , [Text] NVARCHAR(4000) NOT NULL +); + +DECLARE @ErrorLogCount int; +DECLARE @cmd varchar(2000); +DECLARE @msg varchar(1000); + +DECLARE @ErrorlogEnum TABLE( + [Archive #] varchar(3) NOT NULL PRIMARY KEY CLUSTERED + , [Date] datetime NOT NULL + , [Log File Size (Byte)] int NOT NULL +); + +INSERT INTO @ErrorlogEnum ([Archive #], [Date], [Log File Size (Byte)]) +EXEC sys.sp_enumerrorlogs; + +SET @ErrorLogCount = COALESCE(( + SELECT COUNT(1) + FROM @ErrorlogEnum eln + WHERE eln.[Log File Size (Byte)] > 0 + ), 0); + +IF @ErrorLogCount > 9 SET @ErrorLogCount = 9; + +DECLARE @FileNum INT; +SET @FileNum = 0 + +WHILE @FileNum < @ErrorLogCount +BEGIN TRY + SET @msg = 'Retreiving log ' + CONVERT(varchar(100), @FileNum); + RAISERROR (@msg, 0, 1) WITH NOWAIT; --send progress to the "Messages" tab + + INSERT INTO #mverrlog (LogDate, ProcessInfo, [Text]) + EXEC sys.xp_readerrorlog @FileNum, @ErrorLogType; + + UPDATE #mverrlog + SET ErrorLogFileNum = @FileNum + WHERE ErrorLogFileNum IS NULL; + + SET @FileNum = @FileNum + 1; +END TRY +BEGIN CATCH + PRINT 'Error: ' + CONVERT(varchar(50), ERROR_NUMBER()) + + ', Severity: ' + CONVERT(varchar(5), ERROR_SEVERITY()) + + ', State: ' + CONVERT(varchar(5), ERROR_STATE()) + + ', Procedure: ' + ISNULL(ERROR_PROCEDURE(), '-') + + ', Line: ' + CONVERT(varchar(5), ERROR_LINE()) + + ', User name: ' + CONVERT(sysname, ORIGINAL_LOGIN()); + PRINT(ERROR_MESSAGE()); + PRINT('Change @FileNum to smaller value!'); +END CATCH + +SELECT FileNumber = el.ErrorLogFileNum + , el.LogDate + , el.Text +FROM #mverrlog el +WHERE NOT EXISTS ( + SELECT 1 + FROM #exclusions e + WHERE (el.Text LIKE e.LogTextToExclude ESCAPE '|') + AND e.LogType = @ErrorLogType + ) +ORDER BY el.ErrorLogFileNum, el.RowNum DESC; diff --git a/Scripts/Read_errorlog.sql b/Scripts/Read_errorlog.sql new file mode 100644 index 00000000..818a1eb7 --- /dev/null +++ b/Scripts/Read_errorlog.sql @@ -0,0 +1,108 @@ +/* + + Read error log with filters + 2 result sets with detailed info from error log. + No + Konstantin Taranov + 2019-06-27 + 2019-08-27 by Konstantin Taranov + 1.1 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Jobs_Detailed_History.sql + https://thelonedba.wordpress.com/2019/08/16/reading-sql-server-error-logs/ + +*/ + +DECLARE @daysback INT = 0; -- number of days to go back in the logs. 0 = today only + +-- table variable for holding the details of the error logs. +-- Yes, I know, table variables are evil. This one is unlikely to hold more than a few dozen rather narrow lines +DECLARE @ErrorLogs TABLE +( + Archive INT NOT NULL, + LogDate DATETIME NOT NULL, + LogFileSizeBytes BIGINT NOT NULL, + ReadThis TINYINT NULL +); + +-- useful trick if you don't know it: INSERT INTO a table the results of EXECing a SP. +INSERT INTO @ErrorLogs +( + Archive, + LogDate, + LogFileSizeBytes +) +EXEC sys.sp_enumerrorlogs; + +DECLARE @lognum INT = 0; +DECLARE @logdate DATETIME; + +--figure out which logfiles we need. +WITH NextLog +AS (SELECT Archive, + LogDate, + LogFileSizeBytes, + ReadThis, + ISNULL(LAG(LogDate) OVER (ORDER BY Archive), LogDate) AS nextlogdate + FROM @ErrorLogs) +UPDATE @ErrorLogs +SET ReadThis = CASE + WHEN e.Archive = 1 THEN + 1 -- always read the first file; doesn't always get identified by the next line + WHEN n.nextlogdate >= DATEADD(DAY, DATEDIFF(DAY, '20100101', GETDATE()) - ABS(@daysback), '20100101') THEN + 1 + ELSE + 0 + END +FROM NextLog AS n + INNER JOIN @ErrorLogs AS e + ON e.Archive = n.Archive; + +--just checking which files we're looking at... Probably comment this line out for production use +SELECT * +FROM @ErrorLogs +ORDER BY Archive; + +IF OBJECT_ID('tempdb.dbo.#spErrorLog', 'U') IS NOT NULL +BEGIN + DROP TABLE #spErrorLog; +END; + +CREATE TABLE #spErrorLog +( + logdate DATETIME NOT NULL, + ProcessInfo VARCHAR(20) NULL, + Text NVARCHAR(MAX) NOT NULL +); + +WHILE @lognum <= (SELECT MAX(Archive) FROM @ErrorLogs WHERE ReadThis = 1) +BEGIN + INSERT INTO #spErrorLog + EXEC sys.sp_readerrorlog @p1 = @lognum; + + SELECT @lognum = @lognum + 1; + + SELECT @logdate = LogDate + FROM @ErrorLogs + WHERE Archive = @lognum; +END; + +SELECT * +FROM #spErrorLog +WHERE 1 = 1 + AND + ( + ProcessInfo = 'Server' -- we like server-related boot messages. + OR + ( -- filter out noisy messages that we don't really need to see here + Text NOT LIKE '%Backup Log%' + AND Text NOT LIKE 'Log was backed up%' + AND Text NOT LIKE 'CHECKDB for database % finished without errors on %This is an informational message only; no user action is required.' + AND Text NOT LIKE 'DBCC CHECKDB % WITH all_errormsgs, no_infomsgs, data_purity executed by % found 0 errors and repaired 0 errors.%' + AND Text NOT LIKE 'BACKUP DATABASE WITH DIFFERENTIAL successfully processed % pages%' + AND Text NOT LIKE 'Database differential changes were backed up. Database: % This is an informational message. No user action is required.' + AND Text NOT LIKE 'BACKUP DATABASE successfully processed % pages %' + AND Text NOT LIKE 'Database backed up. Database: % This is an informational message only. No user action is required.' + AND logdate >= DATEADD(DAY, DATEDIFF(DAY, '20100101', GETDATE()) - ABS(@daysback), '20100101') + ) + ) +ORDER BY logdate; diff --git a/Scripts/Remove_Leading_and_Trailing_Backward_and_Forward_Slashes.sql b/Scripts/Remove_Leading_and_Trailing_Backward_and_Forward_Slashes.sql new file mode 100644 index 00000000..fb625d8d --- /dev/null +++ b/Scripts/Remove_Leading_and_Trailing_Backward_and_Forward_Slashes.sql @@ -0,0 +1,15 @@ +/* +https://sqlperformance.com/2019/10/t-sql-queries/overlooked-t-sql-gems +*/ + +SELECT string, leading_slash_count, trailing_slash_count, + STUFF(STUFF(string, LEN(string) - trailing_slash_count + 1, +trailing_slash_count, ''), 1, leading_slash_count, '') AS new_string +FROM ( VALUES + (CAST('//\\ remove leading and trailing backward (\) and forward (/) slashes \\//' AS varchar(200))), + ('//\\**remove leading and trailing backward (\) and forward (/) slashes**\\//') +) AS test_data(string) +CROSS APPLY ( +SELECT PATINDEX('%[^/\]%', string) - 1 AS leading_slash_count, + PATINDEX('%[^/\]%', REVERSE(string)) - 1 AS trailing_slash_count +) AS ca1; diff --git a/Scripts/Reseed_Identity_Column_Value_To_Last_Value.sql b/Scripts/Reseed_Identity_Column_Value_To_Last_Value.sql new file mode 100644 index 00000000..85db377c --- /dev/null +++ b/Scripts/Reseed_Identity_Column_Value_To_Last_Value.sql @@ -0,0 +1,36 @@ +/* +https://eitanblumin.com/2018/11/06/re-align-identity-last-value-to-actual-max-value/ +*/ + +DECLARE @CurrTable SYSNAME, @CurrCol SYSNAME, @LastValue BIGINT +DECLARE @CMD NVARCHAR(MAX), @Result NVARCHAR(MAX) + +DECLARE Cur CURSOR +LOCAL FAST_FORWARD +FOR +SELECT QUOTENAME(OBJECT_SCHEMA_NAME(t.object_id)) + '.' + QUOTENAME(OBJECT_NAME(t.object_id)), c.name, CONVERT(int, c.last_value) +FROM sys.identity_columns AS c +INNER JOIN sys.tables AS t +ON c.object_id = t.object_id +WHERE c.last_value > c.seed_value + +OPEN Cur +FETCH NEXT FROM Cur INTO @CurrTable, @CurrCol, @LastValue + +WHILE @@FETCH_STATUS = 0 +BEGIN + SET @CMD = N' + SELECT @pResult = N''DBCC CHECKIDENT(''''' + @CurrTable + N''''', RESEED, '' + CONVERT(nvarchar(max), MAX(' + QUOTENAME(@CurrCol) + N')) + N'') -- ' + CONVERT(nvarchar(max), @LastValue) + N''' + FROM ' + @CurrTable + N' + HAVING MAX(' + QUOTENAME(@CurrCol) + N') <> @LastValue' + + EXEC sp_executesql @CMD, N'@pResult NVARCHAR(MAX) OUTPUT, @LastValue BIGINT', @Result OUTPUT, @LastValue; + + IF @Result IS NOT NULL + PRINT @Result; + + FETCH NEXT FROM Cur INTO @CurrTable, @CurrCol, @LastValue +END + +CLOSE Cur +DEALLOCATE Cur \ No newline at end of file diff --git a/Scripts/Restore_Database_Dynamic_SQL.sql b/Scripts/Restore_Database_Dynamic_SQL.sql new file mode 100644 index 00000000..e936d5b6 --- /dev/null +++ b/Scripts/Restore_Database_Dynamic_SQL.sql @@ -0,0 +1,21 @@ +USE master; +GO + +DECLARE @restoreStatement NVARCHAR(4000) = N''; +DECLARE @databaseName SYSNAME = N'AdventureWorks2014'; +DECLARE @backupFilePath NVARCHAR(2000) = N'G:\YaDisk\Backup\Distrib\SQL Server\Sample_Database\AdventureWorks\' + @databaseName + N'.bak'; +DECLARE @serverPath NVARCHAR(2000) = N'K:\MSSQL\MSSQL14.MSSQLSERVER\MSSQL\DATA\'; +DECLARE @debug BIT = 1; + +SET @restoreStatement = N' +RESTORE DATABASE [@databaseName] FROM DISK = N''@backupFilePath'' +WITH FILE = 1, MOVE N''@databaseName_Data'' TO N''@serverPath@databaseName_Data.mdf'', +MOVE N''@databaseName_Log'' TO N''@serverPath@databaseName_Log.ldf'', NOUNLOAD, STATS = 5'; +SET @restoreStatement = REPLACE(@restoreStatement, '@databaseName', @databaseName); +SET @restoreStatement = REPLACE(@restoreStatement, '@backupFilePath', @backupFilePath); +SET @restoreStatement = REPLACE(@restoreStatement, '@serverPath', @serverPath); + +IF @debug = 1 PRINT(@restoreStatement) +ELSE +EXEC sp_executesql @restoreStatement; +GO diff --git a/Scripts/SQL Managed Instance Diagnostic Information Queries.sql b/Scripts/SQL Managed Instance Diagnostic Information Queries.sql new file mode 100644 index 00000000..9c6f6ca1 --- /dev/null +++ b/Scripts/SQL Managed Instance Diagnostic Information Queries.sql @@ -0,0 +1,1675 @@ + +-- SQL Managed Instance Diagnostic Information Queries +-- Glenn Berry +-- Last Modified: December 3, 2020 +-- https://glennsqlperformance.com/ +-- https://sqlserverperformance.wordpress.com/ +-- YouTube: https://bit.ly/2PkoAM1 +-- Twitter: GlennAlanBerry + +-- Diagnostic Queries are available here +-- https://glennsqlperformance.com/resources/ + + +-- If you like PowerShell, there is a very useful community solution for running these queries in an automated fashion +-- https://dbatools.io/ + +-- Invoke-DbaDiagnosticQuery +-- https://dbatools.io/functions/invoke-dbadiagnosticquery/ + + +--****************************************************************************** +--* Copyright (C) 2020 Glenn Berry +--* All rights reserved. +--* +--* +--* You may alter this code for your own *non-commercial* purposes. You may +--* republish altered code as long as you include this copyright and give due credit. +--* +--* +--* THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF +--* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED +--* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +--* PARTICULAR PURPOSE. +--* +--****************************************************************************** + +-- Check the major product version to see if it is SQL Managed Instance +IF NOT EXISTS (SELECT * WHERE CONVERT(varchar(128), SERVERPROPERTY('EngineEdition')) = 8) + BEGIN + DECLARE @ProductVersion varchar(128) = CONVERT(varchar(128), SERVERPROPERTY('EngineEdition')); + RAISERROR ('Script does not match the EngineEdition [%s] of this instance. Many of these queries may not work on this version.' , 18 , 16 , @ProductVersion); + END + ELSE + PRINT N'You are using SQL Managed Instance for this diagnostic information script'; + + +-- Instance level queries ******************************* + +-- SQL and OS Version information for current instance (Query 1) (Version Info) +SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version Info]; +------ + +-- The version number from @@VERSION will not match what is in the SQL Server error log + +-- How to determine the version, edition and update level of SQL Server and its components +-- https://bit.ly/2oAjKgW + +-- Download SQL Server Management Studio (SSMS) +-- https://bit.ly/1OcupT9 + +-- Download and install Azure Data Studio +-- https://bit.ly/2vgke1A + + + +-- Get selected server properties (Query 2) (Server Properties) +SELECT SERVERPROPERTY('ServerName') AS [ServerName], +SERVERPROPERTY('EngineEdition') AS [Engine Edition], -- Engine Edition 8 is Managed Instance +SERVERPROPERTY('Edition') AS [Edition], +SERVERPROPERTY('ProductLevel') AS [ProductLevel], -- What servicing branch (RTM/SP/CU) +SERVERPROPERTY('ProductVersion') AS [ProductVersion], +SERVERPROPERTY('ProductMajorVersion') AS [ProductMajorVersion], +SERVERPROPERTY('ProductMinorVersion') AS [ProductMinorVersion], +SERVERPROPERTY('ProductBuild') AS [ProductBuild], +SERVERPROPERTY('Collation') AS [Collation], +SERVERPROPERTY('IsFullTextInstalled') AS [IsFullTextInstalled], +SERVERPROPERTY('IsIntegratedSecurityOnly') AS [IsIntegratedSecurityOnly], +SERVERPROPERTY('FilestreamConfiguredLevel') AS [FilestreamConfiguredLevel], +SERVERPROPERTY('IsHadrEnabled') AS [IsHadrEnabled], +SERVERPROPERTY('HadrManagerStatus') AS [HadrManagerStatus], +SERVERPROPERTY('InstanceDefaultDataPath') AS [InstanceDefaultDataPath], +SERVERPROPERTY('InstanceDefaultLogPath') AS [InstanceDefaultLogPath], +SERVERPROPERTY('BuildClrVersion') AS [Build CLR Version], +SERVERPROPERTY('IsXTPSupported') AS [IsXTPSupported], +SERVERPROPERTY('IsPolybaseInstalled') AS [IsPolybaseInstalled], +SERVERPROPERTY('IsAdvancedAnalyticsInstalled') AS [IsRServicesInstalled]; +------ + +-- This gives you a lot of useful information about your "instance" of SQL Managed Instance + + +-- SERVERPROPERTY (Transact-SQL) +-- https://bit.ly/2eeaXeI + + + +-- Get instance-level configuration values for instance (Query 3) (Configuration Values) +SELECT name, value, value_in_use, minimum, maximum, [description], is_dynamic, is_advanced +FROM sys.configurations WITH (NOLOCK) +ORDER BY name OPTION (RECOMPILE); +------ + +-- Focus on these settings: +-- automatic soft-NUMA disabled (should be 0 in most cases) +-- backup checksum default (should be 1) +-- backup compression default (should be 1 in most cases) +-- clr enabled (only enable if it is needed) +-- cost threshold for parallelism (depends on your workload) +-- lightweight pooling (should be zero) +-- max degree of parallelism (depends on your workload and hardware) +-- max server memory (MB) (set to an appropriate value, not the default) +-- optimize for ad hoc workloads (should be 1) +-- priority boost (should be zero) +-- remote admin connections (should be 1) + +-- sys.configurations (Transact-SQL) +-- https://bit.ly/2HsyDZI + + + + +-- SQL Server Process Address space info (Query 4) (Process Memory) +-- (shows whether locked pages is enabled, among other things) +SELECT physical_memory_in_use_kb/1024 AS [SQL Server Memory Usage (MB)], + locked_page_allocations_kb/1024 AS [SQL Server Locked Pages Allocation (MB)], + large_page_allocations_kb/1024 AS [SQL Server Large Pages Allocation (MB)], + page_fault_count, memory_utilization_percentage, available_commit_limit_kb, + process_physical_memory_low, process_virtual_memory_low +FROM sys.dm_os_process_memory WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- You want to see 0 for process_physical_memory_low +-- You want to see 0 for process_virtual_memory_low +-- This indicates that you are not under internal memory pressure +-- If locked_page_allocations_kb > 0, then LPIM is enabled + +-- How to enable the "locked pages" feature in SQL Server 2012 +-- https://bit.ly/2F5UjOA + +-- Memory Management Architecture Guide +-- https://bit.ly/2JKkadC + + + +-- Get SQL Server Agent jobs and Category information (Query 5) (SQL Server Agent Jobs) +SELECT sj.name AS [Job Name], sj.[description] AS [Job Description], SUSER_SNAME(sj.owner_sid) AS [Job Owner], +sj.date_created AS [Date Created], sj.[enabled] AS [Job Enabled], +sj.notify_email_operator_id, sj.notify_level_email, sc.name AS [CategoryName], +s.[enabled] AS [Sched Enabled], js.next_run_date, js.next_run_time +FROM msdb.dbo.sysjobs AS sj WITH (NOLOCK) +INNER JOIN msdb.dbo.syscategories AS sc WITH (NOLOCK) +ON sj.category_id = sc.category_id +LEFT OUTER JOIN msdb.dbo.sysjobschedules AS js WITH (NOLOCK) +ON sj.job_id = js.job_id +LEFT OUTER JOIN msdb.dbo.sysschedules AS s WITH (NOLOCK) +ON js.schedule_id = s.schedule_id +ORDER BY sj.name OPTION (RECOMPILE); +------ + +-- Gives you some basic information about your SQL Server Agent jobs, who owns them and how they are configured +-- Look for Agent jobs that are not owned by sa +-- Look for jobs that have a notify_email_operator_id set to 0 (meaning no operator) +-- Look for jobs that have a notify_level_email set to 0 (meaning no e-mail is ever sent) +-- +-- MSDN sysjobs documentation +-- https://bit.ly/2paDEOP + + + +-- SQL Server NUMA Node information (Query 6) (SQL Server NUMA Info) +SELECT node_id, node_state_desc, memory_node_id, processor_group, cpu_count, online_scheduler_count, + idle_scheduler_count, active_worker_count, avg_load_balance, resource_monitor_state +FROM sys.dm_os_nodes WITH (NOLOCK) +WHERE node_state_desc <> N'ONLINE DAC' OPTION (RECOMPILE); +------ + +-- Gives you some useful information about the composition and relative load on your NUMA nodes +-- You want to see an equal number of schedulers on each NUMA node + + +-- sys.dm_os_nodes (Transact-SQL) +-- https://bit.ly/2pn5Mw8 + +-- Balancing Your Available SQL Server Core Licenses Evenly Across NUMA Nodes +-- https://bit.ly/2vfC4Rq + + + +-- Server Resource Statistics (Query 7) (Server Resource Stats) +SELECT TOP(250) resource_type, resource_name, sku, hardware_generation, +virtual_core_count, avg_cpu_percent, io_requests, +CONVERT(DECIMAL(18,2), io_bytes_read/1048576.0) AS [MB Read], +CONVERT(DECIMAL(18,2), io_bytes_read * 1./(io_bytes_read + io_bytes_written) * 100.) AS [Read Percentage], +CONVERT(DECIMAL(18,2), io_bytes_written/1048576.0) AS [MB Written], +CONVERT(DECIMAL(18,2), io_bytes_written * 1./(io_bytes_read + io_bytes_written) * 100.) AS [Write Percentage], +CONVERT(DECIMAL(18,2), (io_bytes_read + io_bytes_written)/1048576.0) AS [MB Total IO], +start_time, end_time +FROM master.sys.server_resource_stats WITH (NOLOCK) +WHERE io_bytes_read > 0 AND io_bytes_written > 0 +ORDER BY end_time DESC OPTION (RECOMPILE); +------ + +-- Shows recent resource usage, in 15-second slices + +-- SQL Managed Instance Pricing +-- https://bit.ly/2XlEE2u + + + + +-- Hardware information from SQL Managed Instance (Query 8) (Hardware Info) +SELECT cpu_count AS [Logical CPU Count], scheduler_count, + numa_node_count, max_workers_count AS [Max Workers Count], + affinity_type_desc AS [Affinity Type], + sqlserver_start_time AS [SQL Server Start Time], + DATEDIFF(hour, sqlserver_start_time, GETDATE()) AS [SQL Server Up Time (hrs)], + virtual_machine_type_desc AS [Virtual Machine Type], + softnuma_configuration_desc AS [Soft NUMA Configuration], + sql_memory_model_desc +FROM sys.dm_os_sys_info WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- Gives you some good basic hardware information about your database server +-- Note: virtual_machine_type_desc of HYPERVISOR does not automatically mean you are running SQL Server inside of a VM +-- It merely indicates that you have a hypervisor running on your host + +-- sys.dm_os_sys_info (Transact-SQL) +-- https://bit.ly/2pczOYs + +-- Soft NUMA configuration was a new column for SQL Server 2016 +-- OFF = Soft-NUMA feature is OFF +-- ON = SQL Server automatically determines the NUMA node sizes for Soft-NUMA +-- MANUAL = Manually configured soft-NUMA + +-- Configure SQL Server to Use Soft-NUMA (SQL Server) +-- https://bit.ly/2HTpKJt + +-- sql_memory_model_desc values (Added in SQL Server 2016 SP1) +-- CONVENTIONAL +-- LOCK_PAGES +-- LARGE_PAGES + + +-- Get System Manufacturer and model number from SQL Server Error log (Query 9) (System Manufacturer) +EXEC sys.xp_readerrorlog 0, 1, N'Manufacturer'; +------ + +-- This can help you determine the capabilities and capacities of your database server +-- Can also be used to confirm if you are running in a VM +-- This query might take a few seconds if you have not recycled your error log recently +-- This query will return no results if your error log has been recycled since the instance was started + + + + +-- Get information on location, time and size of any memory dumps from SQL Server (Query 10) (Memory Dump Info) +SELECT [filename], creation_time, size_in_bytes/1048576.0 AS [Size (MB)] +FROM sys.dm_server_memory_dumps WITH (NOLOCK) +ORDER BY creation_time DESC OPTION (RECOMPILE); +------ + +-- This will not return any rows if you have +-- not had any memory dumps (which is a good thing) + +-- sys.dm_server_memory_dumps (Transact-SQL) +-- https://bit.ly/2elwWll + + + +-- Look at Suspect Pages table (Query 11) (Suspect Pages) +SELECT DB_NAME(database_id) AS [Database Name], [file_id], page_id, + event_type, error_count, last_update_date +FROM msdb.dbo.suspect_pages WITH (NOLOCK) +ORDER BY database_id OPTION (RECOMPILE); +------ + +-- event_type value descriptions +-- 1 = 823 error caused by an operating system CRC error +-- or 824 error other than a bad checksum or a torn page (for example, a bad page ID) +-- 2 = Bad checksum +-- 3 = Torn page +-- 4 = Restored (The page was restored after it was marked bad) +-- 5 = Repaired (DBCC repaired the page) +-- 7 = Deallocated by DBCC + +-- Ideally, this query returns no results. The table is limited to 1000 rows. +-- If you do get results here, you should do further investigation to determine the root cause + +-- Manage the suspect_pages Table +-- https://bit.ly/2Fvr1c9 + + + +-- File names and paths for all user and system databases on instance (Query 12) (Database Filenames and Paths) +SELECT DB_NAME([database_id]) AS [Database Name], + [file_id], [name], physical_name, [type_desc], state_desc, + is_percent_growth, growth, + CONVERT(bigint, growth/128.0) AS [Growth in MB], + CONVERT(bigint, size/128.0) AS [Total Size in MB], max_size +FROM sys.master_files WITH (NOLOCK) +ORDER BY DB_NAME([database_id]), [file_id] OPTION (RECOMPILE); +------ + +-- Things to look at: +-- Are data files and log files on different drives? +-- Is everything on the C: drive? +-- Is tempdb on dedicated drives? +-- Is there only one tempdb data file? +-- Are all of the tempdb data files the same size? +-- Are there multiple data files for user databases? +-- Is percent growth enabled for any files (which is bad)? + + + + +-- Volume info for all LUNS that have database files on the current instance (Query 13) (Volume Info) +SELECT DISTINCT vs.volume_mount_point, vs.file_system_type, vs.logical_volume_name, +CONVERT(DECIMAL(18,2), vs.total_bytes/1073741824.0) AS [Total Size (GB)], +CONVERT(DECIMAL(18,2), vs.available_bytes/1073741824.0) AS [Available Size (GB)], +CONVERT(DECIMAL(18,2), vs.available_bytes * 1. / vs.total_bytes * 100.) AS [Space Free %], +vs.supports_compression, vs.is_compressed, +vs.supports_sparse_files, vs.supports_alternate_streams +FROM sys.master_files AS f WITH (NOLOCK) +CROSS APPLY sys.dm_os_volume_stats(f.database_id, f.[file_id]) AS vs +ORDER BY vs.volume_mount_point OPTION (RECOMPILE); +------ + +-- Shows you the total and free space on the LUNs where you have database files +-- Being low on free space can negatively affect performance + +-- sys.dm_os_volume_stats (Transact-SQL) +-- https://bit.ly/2oBPNNr + + + +-- Drive level latency information (Query 14) (Drive Level Latency) +SELECT tab.[Drive], tab.volume_mount_point AS [Volume Mount Point], + CASE + WHEN num_of_reads = 0 THEN 0 + ELSE (io_stall_read_ms/num_of_reads) + END AS [Read Latency], + CASE + WHEN num_of_writes = 0 THEN 0 + ELSE (io_stall_write_ms/num_of_writes) + END AS [Write Latency], + CASE + WHEN (num_of_reads = 0 AND num_of_writes = 0) THEN 0 + ELSE (io_stall/(num_of_reads + num_of_writes)) + END AS [Overall Latency], + CASE + WHEN num_of_reads = 0 THEN 0 + ELSE (num_of_bytes_read/num_of_reads) + END AS [Avg Bytes/Read], + CASE + WHEN num_of_writes = 0 THEN 0 + ELSE (num_of_bytes_written/num_of_writes) + END AS [Avg Bytes/Write], + CASE + WHEN (num_of_reads = 0 AND num_of_writes = 0) THEN 0 + ELSE ((num_of_bytes_read + num_of_bytes_written)/(num_of_reads + num_of_writes)) + END AS [Avg Bytes/Transfer] +FROM (SELECT LEFT(UPPER(mf.physical_name), 2) AS Drive, SUM(num_of_reads) AS num_of_reads, + SUM(io_stall_read_ms) AS io_stall_read_ms, SUM(num_of_writes) AS num_of_writes, + SUM(io_stall_write_ms) AS io_stall_write_ms, SUM(num_of_bytes_read) AS num_of_bytes_read, + SUM(num_of_bytes_written) AS num_of_bytes_written, SUM(io_stall) AS io_stall, vs.volume_mount_point + FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS vfs + INNER JOIN sys.master_files AS mf WITH (NOLOCK) + ON vfs.database_id = mf.database_id AND vfs.file_id = mf.file_id + CROSS APPLY sys.dm_os_volume_stats(mf.database_id, mf.[file_id]) AS vs + GROUP BY LEFT(UPPER(mf.physical_name), 2), vs.volume_mount_point) AS tab +ORDER BY [Overall Latency] OPTION (RECOMPILE); +------ + +-- Shows you the drive-level latency for reads and writes, in milliseconds +-- Latency above 30-40ms is usually a problem +-- These latency numbers include all file activity against all SQL Server +-- database files on each drive since SQL Server was last started + + +-- Calculates average latency per read, per write, and per total input/output for each database file (Query 15) (IO Latency by File) +SELECT DB_NAME(fs.database_id) AS [Database Name], CAST(fs.io_stall_read_ms/(1.0 + fs.num_of_reads) AS NUMERIC(10,1)) AS [avg_read_latency_ms], +CAST(fs.io_stall_write_ms/(1.0 + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_write_latency_ms], +CAST((fs.io_stall_read_ms + fs.io_stall_write_ms)/(1.0 + fs.num_of_reads + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_io_latency_ms], +CONVERT(DECIMAL(18,2), mf.size/128.0) AS [File Size (MB)], mf.physical_name, mf.type_desc, fs.io_stall_read_ms, fs.num_of_reads, +fs.io_stall_write_ms, fs.num_of_writes, fs.io_stall_read_ms + fs.io_stall_write_ms AS [io_stalls], fs.num_of_reads + fs.num_of_writes AS [total_io], +io_stall_queued_read_ms AS [Resource Governor Total Read IO Latency (ms)], io_stall_queued_write_ms AS [Resource Governor Total Write IO Latency (ms)] +FROM sys.dm_io_virtual_file_stats(null,null) AS fs +INNER JOIN sys.master_files AS mf WITH (NOLOCK) +ON fs.database_id = mf.database_id +AND fs.[file_id] = mf.[file_id] +ORDER BY avg_io_latency_ms DESC OPTION (RECOMPILE); +------ + +-- Helps determine which database files on the entire instance have the most I/O bottlenecks +-- This can help you decide whether certain LUNs are overloaded and whether you might +-- want to move some files to a different location or perhaps improve your I/O performance +-- These latency numbers include all file activity against each SQL Server +-- database file since SQL Server was last started + + +-- Look for I/O requests taking longer than 15 seconds in the six most recent SQL Server Error Logs (Query 16) (IO Warnings) +CREATE TABLE #IOWarningResults(LogDate datetime, ProcessInfo sysname, LogText nvarchar(1000)); + + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 0, 1, N'taking longer than 15 seconds'; + + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 1, 1, N'taking longer than 15 seconds'; + + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 2, 1, N'taking longer than 15 seconds'; + + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 3, 1, N'taking longer than 15 seconds'; + + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 4, 1, N'taking longer than 15 seconds'; + + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 5, 1, N'taking longer than 15 seconds'; + +SELECT LogDate, ProcessInfo, LogText +FROM #IOWarningResults +ORDER BY LogDate DESC; + +DROP TABLE #IOWarningResults; +------ + +-- Finding 15 second I/O warnings in the SQL Server Error Log is useful evidence of +-- poor I/O performance (which might have many different causes) +-- Look to see if you see any patterns in the results (same files, same drives, same time of day, etc.) + +-- Diagnostics in SQL Server help detect stalled and stuck I/O operations +-- https://bit.ly/2qtaw73 + + + +-- Recovery model, log reuse wait description (Query 17) (Database Properties) +-- and compatibility level for all databases on instance +SELECT db.[name] AS [Database Name], SUSER_SNAME(db.owner_sid) AS [Database Owner], db.recovery_model_desc AS [Recovery Model], +db.state_desc, db.containment_desc, db.log_reuse_wait_desc AS [Log Reuse Wait Description], +db.[compatibility_level] AS [DB Compatibility Level], +db.is_mixed_page_allocation_on, db.page_verify_option_desc AS [Page Verify Option], +db.is_auto_create_stats_on, db.is_auto_update_stats_on, db.is_auto_update_stats_async_on, db.is_parameterization_forced, +db.snapshot_isolation_state_desc, db.is_read_committed_snapshot_on, db.is_auto_close_on, db.is_auto_shrink_on, +db.target_recovery_time_in_seconds, db.is_cdc_enabled, db.delayed_durability_desc, +db.is_query_store_on, db.is_sync_with_backup, db.is_temporal_history_retention_enabled, +db.is_encrypted, de.encryption_state, de.percent_complete, de.key_algorithm, de.key_length, +db.is_accelerated_database_recovery_on +FROM sys.databases AS db WITH (NOLOCK) +LEFT OUTER JOIN sys.dm_database_encryption_keys AS de WITH (NOLOCK) +ON db.database_id = de.database_id +ORDER BY db.[name] OPTION (RECOMPILE); +------ + +-- sys.databases (Transact-SQL) +-- https://bit.ly/2G5wqaX + +-- sys.dm_os_performance_counters (Transact-SQL) +-- https://bit.ly/3kEO2JR + +-- sys.dm_database_encryption_keys (Transact-SQL) +-- https://bit.ly/3mE7kkx + +-- Things to look at: +-- How many databases are on the instance? +-- What recovery models are they using? +-- What is the log reuse wait description? +-- What compatibility level are the databases on? +-- Is Auto Update Statistics Asynchronously enabled? +-- Is Delayed Durability enabled +-- Make sure auto_shrink is not enabled! + +-- is_mixed_page_allocation_on is a new property for SQL Server 2016. Equivalent to TF 1118 for a user database +-- SQL Server 2016: Changes in default behavior for autogrow and allocations for tempdb and user databases +-- https://bit.ly/2evRZSR + +-- A non-zero value for target_recovery_time_in_seconds means that indirect checkpoint is enabled +-- If the setting has a zero value it indicates that automatic checkpoint is enabled + + +-- https://docs.microsoft.com/en-us/azure/sql-database/sql-database-managed-instance-transact-sql-information + + +-- Missing Indexes for all databases by Index Advantage (Query 18) (Missing Indexes All Databases) +SELECT CONVERT(decimal(18,2), user_seeks * avg_total_user_cost * (avg_user_impact * 0.01)) AS [index_advantage], +FORMAT(migs.last_user_seek, 'yyyy-MM-dd HH:mm:ss') AS [last_user_seek], +mid.[statement] AS [Database.Schema.Table], +COUNT(1) OVER(PARTITION BY mid.[statement]) AS [missing_indexes_for_table], +COUNT(1) OVER(PARTITION BY mid.[statement], equality_columns) AS [similar_missing_indexes_for_table], +mid.equality_columns, mid.inequality_columns, mid.included_columns, +migs.unique_compiles, migs.user_seeks, +CONVERT(decimal(18,2), migs.avg_total_user_cost) AS [avg_total_user_cost], migs.avg_user_impact +FROM sys.dm_db_missing_index_group_stats AS migs WITH (NOLOCK) +INNER JOIN sys.dm_db_missing_index_groups AS mig WITH (NOLOCK) +ON migs.group_handle = mig.index_group_handle +INNER JOIN sys.dm_db_missing_index_details AS mid WITH (NOLOCK) +ON mig.index_handle = mid.index_handle +ORDER BY index_advantage DESC OPTION (RECOMPILE); +------ + +-- Getting missing index information for all of the databases on the instance is very useful +-- Look at last user seek time, number of user seeks to help determine source and importance +-- Also look at avg_user_impact and avg_total_user_cost to help determine importance +-- SQL Server is overly eager to add included columns, so beware +-- Do not just blindly add indexes that show up from this query!!! + +-- SQL Server Index Design Guide +-- https://bit.ly/2qtZr4N + + + +-- Get VLF Counts for all databases on the instance (Query 19) (VLF Counts) +SELECT [name] AS [Database Name], [VLF Count] +FROM sys.databases AS db WITH (NOLOCK) +CROSS APPLY (SELECT file_id, COUNT(*) AS [VLF Count] + FROM sys.dm_db_log_info(db.database_id) + GROUP BY file_id) AS li +ORDER BY [VLF Count] DESC OPTION (RECOMPILE); +------ + +-- High VLF counts can affect write performance to the log file +-- and they can make full database restores and crash recovery take much longer +-- Try to keep your VLF counts under 200 in most cases (depending on log file size) + +-- Important change to VLF creation algorithm in SQL Server 2014 +-- https://bit.ly/2Hsjbg4 + +-- SQL Server Transaction Log Architecture and Management Guide +-- https://bit.ly/2JjmQRZ + + +-- Get CPU utilization by database (Query 20) (CPU Usage by Database) +WITH DB_CPU_Stats +AS +(SELECT pa.DatabaseID, DB_Name(pa.DatabaseID) AS [Database Name], + SUM(qs.total_worker_time/1000) AS [CPU_Time_Ms] + FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) + CROSS APPLY (SELECT CONVERT(int, value) AS [DatabaseID] + FROM sys.dm_exec_plan_attributes(qs.plan_handle) + WHERE attribute = N'dbid') AS pa + GROUP BY DatabaseID) +SELECT ROW_NUMBER() OVER(ORDER BY [CPU_Time_Ms] DESC) AS [CPU Rank], + [Database Name], DatabaseID, [CPU_Time_Ms] AS [CPU Time (ms)], + CAST([CPU_Time_Ms] * 1.0 / SUM([CPU_Time_Ms]) OVER() * 100.0 AS DECIMAL(5, 2)) AS [CPU Percent] +FROM DB_CPU_Stats +WHERE DatabaseID <> 32767 -- ResourceDB +ORDER BY [CPU Rank] OPTION (RECOMPILE); +------ + +-- Helps determine which database is using the most CPU resources on the instance +-- There are two copies on the master database. The low DatabaseID is the physical master, +-- and the high DatabaseID is the replicated master +-- Note: This only reflects CPU usage from the currently cached query plans + + +-- Get I/O utilization by database (Query 21) (IO Usage By Database) +WITH Aggregate_IO_Statistics +AS (SELECT DB_NAME(database_id) AS [Database Name], + CAST(SUM(num_of_bytes_read + num_of_bytes_written) / 1048576 AS DECIMAL(12, 2)) AS [ioTotalMB], + CAST(SUM(num_of_bytes_read ) / 1048576 AS DECIMAL(12, 2)) AS [ioReadMB], + CAST(SUM(num_of_bytes_written) / 1048576 AS DECIMAL(12, 2)) AS [ioWriteMB], database_id + FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS [DM_IO_STATS] + GROUP BY database_id) +SELECT ROW_NUMBER() OVER (ORDER BY ioTotalMB DESC) AS [I/O Rank], + [Database Name], database_id, ioTotalMB AS [Total I/O (MB)], + CAST(ioTotalMB / SUM(ioTotalMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Total I/O %], + ioReadMB AS [Read I/O (MB)], + CAST(ioReadMB / SUM(ioReadMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Read I/O %], + ioWriteMB AS [Write I/O (MB)], + CAST(ioWriteMB / SUM(ioWriteMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Write I/O %] +FROM Aggregate_IO_Statistics +ORDER BY [I/O Rank] OPTION (RECOMPILE); +------ + +-- Helps determine which database is using the most I/O resources on the instance +-- These numbers are cumulative since the last service restart +-- They include all I/O activity, not just the nominal I/O workload + + +-- Get total buffer usage by database for current instance (Query 22) (Total Buffer Usage by Database) +-- This make take some time to run on a busy instance +WITH AggregateBufferPoolUsage +AS +(SELECT DB_NAME(database_id) AS [Database Name], database_id, +CAST(COUNT(*) * 8/1024.0 AS DECIMAL (10,2)) AS [CachedSize] +FROM sys.dm_os_buffer_descriptors WITH (NOLOCK) +WHERE database_id <> 32767 -- ResourceDB +GROUP BY DB_NAME(database_id), database_id) + SELECT ROW_NUMBER() OVER(ORDER BY CachedSize DESC) AS [Buffer Pool Rank], + [Database Name], database_id, CachedSize AS [Cached Size (MB)], + CAST(CachedSize / SUM(CachedSize) OVER() * 100.0 AS DECIMAL(5,2)) AS [Buffer Pool Percent] +FROM AggregateBufferPoolUsage +ORDER BY [Buffer Pool Rank] OPTION (RECOMPILE); +------ + +-- Tells you how much memory (in the buffer pool) +-- is being used by each database on the instance + + +-- Get tempdb version store space usage by database (Query 23) (Version Store Space Usage) +SELECT DB_NAME(database_id) AS [Database Name], + reserved_page_count AS [Version Store Reserved Page Count], + reserved_space_kb/1024 AS [Version Store Reserved Space (MB)] +FROM sys.dm_tran_version_store_space_usage WITH (NOLOCK) +ORDER BY reserved_space_kb/1024 DESC OPTION (RECOMPILE); +------ + +-- sys.dm_tran_version_store_space_usage (Transact-SQL) +-- https://bit.ly/2vh3Bmk + + + + +-- Clear Wait Stats with this command +-- DBCC SQLPERF('sys.dm_os_wait_stats', CLEAR); + +-- Isolate top waits for server instance since last restart or wait statistics clear (Query 24) (Top Waits) +WITH [Waits] +AS (SELECT wait_type, wait_time_ms/ 1000.0 AS [WaitS], + (wait_time_ms - signal_wait_time_ms) / 1000.0 AS [ResourceS], + signal_wait_time_ms / 1000.0 AS [SignalS], + waiting_tasks_count AS [WaitCount], + 100.0 * wait_time_ms / SUM (wait_time_ms) OVER() AS [Percentage], + ROW_NUMBER() OVER(ORDER BY wait_time_ms DESC) AS [RowNum] + FROM sys.dm_os_wait_stats WITH (NOLOCK) + WHERE [wait_type] NOT IN ( + N'BROKER_EVENTHANDLER', N'BROKER_RECEIVE_WAITFOR', N'BROKER_TASK_STOP', + N'BROKER_TO_FLUSH', N'BROKER_TRANSMITTER', N'CHECKPOINT_QUEUE', + N'CHKPT', N'CLR_AUTO_EVENT', N'CLR_MANUAL_EVENT', N'CLR_SEMAPHORE', N'CXCONSUMER', + N'DBMIRROR_DBM_EVENT', N'DBMIRROR_EVENTS_QUEUE', N'DBMIRROR_WORKER_QUEUE', + N'DBMIRRORING_CMD', N'DIRTY_PAGE_POLL', N'DISPATCHER_QUEUE_SEMAPHORE', + N'EXECSYNC', N'FSAGENT', N'FT_IFTS_SCHEDULER_IDLE_WAIT', N'FT_IFTSHC_MUTEX', + N'HADR_CLUSAPI_CALL', N'HADR_FABRIC_CALLBACK', N'HADR_FILESTREAM_IOMGR_IOCOMPLETION', N'HADR_LOGCAPTURE_WAIT', + N'HADR_NOTIFICATION_DEQUEUE', N'HADR_TIMER_TASK', N'HADR_WORK_QUEUE', + N'KSOURCE_WAKEUP', N'LAZYWRITER_SLEEP', N'LOGMGR_QUEUE', + N'MEMORY_ALLOCATION_EXT', N'ONDEMAND_TASK_QUEUE', + N'PARALLEL_REDO_DRAIN_WORKER', N'PARALLEL_REDO_LOG_CACHE', N'PARALLEL_REDO_TRAN_LIST', + N'PARALLEL_REDO_WORKER_SYNC', N'PARALLEL_REDO_WORKER_WAIT_WORK', + N'PREEMPTIVE_HADR_LEASE_MECHANISM', N'PREEMPTIVE_SP_SERVER_DIAGNOSTICS', + N'PREEMPTIVE_OS_LIBRARYOPS', N'PREEMPTIVE_OS_COMOPS', N'PREEMPTIVE_OS_CRYPTOPS', + N'PREEMPTIVE_OS_PIPEOPS', N'PREEMPTIVE_OS_AUTHENTICATIONOPS', + N'PREEMPTIVE_OS_GENERICOPS', N'PREEMPTIVE_OS_VERIFYTRUST', + N'PREEMPTIVE_OS_FILEOPS', N'PREEMPTIVE_OS_DEVICEOPS', N'PREEMPTIVE_OS_QUERYREGISTRY', + N'PREEMPTIVE_OS_WRITEFILE', + N'PREEMPTIVE_XE_CALLBACKEXECUTE', N'PREEMPTIVE_XE_DISPATCHER', + N'PREEMPTIVE_XE_GETTARGETSTATE', N'PREEMPTIVE_XE_SESSIONCOMMIT', + N'PREEMPTIVE_XE_TARGETINIT', N'PREEMPTIVE_XE_TARGETFINALIZE', + N'PWAIT_ALL_COMPONENTS_INITIALIZED', N'PWAIT_DIRECTLOGCONSUMER_GETNEXT', + N'PWAIT_EXTENSIBILITY_CLEANUP_TASK', + N'QDS_PERSIST_TASK_MAIN_LOOP_SLEEP', N'QDS_ASYNC_QUEUE', + N'QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEP', N'REQUEST_FOR_DEADLOCK_SEARCH', + N'RESOURCE_QUEUE', N'SERVER_IDLE_CHECK', N'SLEEP_BPOOL_FLUSH', N'SLEEP_DBSTARTUP', + N'SLEEP_DCOMSTARTUP', N'SLEEP_MASTERDBREADY', N'SLEEP_MASTERMDREADY', + N'SLEEP_MASTERUPGRADED', N'SLEEP_MSDBSTARTUP', N'SLEEP_SYSTEMTASK', N'SLEEP_TASK', + N'SLEEP_TEMPDBSTARTUP', N'SNI_HTTP_ACCEPT', N'SOS_WORK_DISPATCHER', + N'SP_SERVER_DIAGNOSTICS_SLEEP', + N'SQLTRACE_BUFFER_FLUSH', N'SQLTRACE_INCREMENTAL_FLUSH_SLEEP', N'SQLTRACE_WAIT_ENTRIES', + N'STARTUP_DEPENDENCY_MANAGER', + N'WAIT_FOR_RESULTS', N'WAITFOR', N'WAITFOR_TASKSHUTDOWN', N'WAIT_XTP_HOST_WAIT', + N'WAIT_XTP_OFFLINE_CKPT_NEW_LOG', N'WAIT_XTP_CKPT_CLOSE', N'WAIT_XTP_RECOVERY', + N'XE_BUFFERMGR_ALLPROCESSED_EVENT', N'XE_DISPATCHER_JOIN', + N'XE_DISPATCHER_WAIT', N'XE_LIVE_TARGET_TVF', N'XE_TIMER_EVENT') + AND waiting_tasks_count > 0) +SELECT + MAX (W1.wait_type) AS [WaitType], + CAST (MAX (W1.Percentage) AS DECIMAL (5,2)) AS [Wait Percentage], + CAST ((MAX (W1.WaitS) / MAX (W1.WaitCount)) AS DECIMAL (16,4)) AS [AvgWait_Sec], + CAST ((MAX (W1.ResourceS) / MAX (W1.WaitCount)) AS DECIMAL (16,4)) AS [AvgRes_Sec], + CAST ((MAX (W1.SignalS) / MAX (W1.WaitCount)) AS DECIMAL (16,4)) AS [AvgSig_Sec], + CAST (MAX (W1.WaitS) AS DECIMAL (16,2)) AS [Wait_Sec], + CAST (MAX (W1.ResourceS) AS DECIMAL (16,2)) AS [Resource_Sec], + CAST (MAX (W1.SignalS) AS DECIMAL (16,2)) AS [Signal_Sec], + MAX (W1.WaitCount) AS [Wait Count], + CAST (N'https://www.sqlskills.com/help/waits/' + W1.wait_type AS XML) AS [Help/Info URL] +FROM Waits AS W1 +INNER JOIN Waits AS W2 +ON W2.RowNum <= W1.RowNum +GROUP BY W1.RowNum, W1.wait_type +HAVING SUM (W2.Percentage) - MAX (W1.Percentage) < 99 -- percentage threshold +OPTION (RECOMPILE); +------ + +-- Cumulative wait stats are not as useful on an idle instance that is not under load or performance pressure + +-- SQL Server Wait Types Library +-- https://bit.ly/2ePzYO2 + +-- The SQL Server Wait Type Repository +-- https://bit.ly/1afzfjC + +-- Wait statistics, or please tell me where it hurts +-- https://bit.ly/2wsQHQE + +-- SQL Server 2005 Performance Tuning using the Waits and Queues +-- https://bit.ly/1o2NFoF + +-- sys.dm_os_wait_stats (Transact-SQL) +-- https://bit.ly/2Hjq9Yl + + + +-- Get a count of SQL connections by IP address (Query 25) (Connection Counts by IP Address) +SELECT ec.client_net_address, es.[program_name], es.[host_name], es.login_name, +COUNT(ec.session_id) AS [connection count] +FROM sys.dm_exec_sessions AS es WITH (NOLOCK) +INNER JOIN sys.dm_exec_connections AS ec WITH (NOLOCK) +ON es.session_id = ec.session_id +GROUP BY ec.client_net_address, es.[program_name], es.[host_name], es.login_name +ORDER BY ec.client_net_address, es.[program_name] OPTION (RECOMPILE); +------ + +-- This helps you figure where your database load is coming from +-- and verifies connectivity from other machines + +-- Solving Connectivity errors to SQL Server +-- https://bit.ly/2EgzoD0 + + + +-- Get Average Task Counts (run multiple times) (Query 26) (Avg Task Counts) +SELECT AVG(current_tasks_count) AS [Avg Task Count], +AVG(work_queue_count) AS [Avg Work Queue Count], +AVG(runnable_tasks_count) AS [Avg Runnable Task Count], +AVG(pending_disk_io_count) AS [Avg Pending DiskIO Count] +FROM sys.dm_os_schedulers WITH (NOLOCK) +WHERE scheduler_id < 255 OPTION (RECOMPILE); +------ + +-- Sustained values above 10 suggest further investigation in that area +-- High Avg Task Counts are often caused by blocking/deadlocking or other resource contention + +-- Sustained values above 1 suggest further investigation in that area +-- High Avg Runnable Task Counts are a good sign of CPU pressure +-- High Avg Pending DiskIO Counts are a sign of disk pressure + +-- How to Do Some Very Basic SQL Server Monitoring +-- https://bit.ly/2q3Btgt + + + +-- Detect blocking (run multiple times) (Query 27) (Detect Blocking) +SELECT t1.resource_type AS [lock type], DB_NAME(resource_database_id) AS [database], +t1.resource_associated_entity_id AS [blk object],t1.request_mode AS [lock req], -- lock requested +t1.request_session_id AS [waiter sid], t2.wait_duration_ms AS [wait time], -- spid of waiter +(SELECT [text] FROM sys.dm_exec_requests AS r WITH (NOLOCK) -- get sql for waiter +CROSS APPLY sys.dm_exec_sql_text(r.[sql_handle]) +WHERE r.session_id = t1.request_session_id) AS [waiter_batch], +(SELECT SUBSTRING(qt.[text],r.statement_start_offset/2, + (CASE WHEN r.statement_end_offset = -1 + THEN LEN(CONVERT(nvarchar(max), qt.[text])) * 2 + ELSE r.statement_end_offset END - r.statement_start_offset)/2) +FROM sys.dm_exec_requests AS r WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(r.[sql_handle]) AS qt +WHERE r.session_id = t1.request_session_id) AS [waiter_stmt], -- statement blocked +t2.blocking_session_id AS [blocker sid], -- spid of blocker +(SELECT [text] FROM sys.sysprocesses AS p -- get sql for blocker +CROSS APPLY sys.dm_exec_sql_text(p.[sql_handle]) +WHERE p.spid = t2.blocking_session_id) AS [blocker_batch] +FROM sys.dm_tran_locks AS t1 WITH (NOLOCK) +INNER JOIN sys.dm_os_waiting_tasks AS t2 WITH (NOLOCK) +ON t1.lock_owner_address = t2.resource_address OPTION (RECOMPILE); +------ + +-- Helps troubleshoot blocking and deadlocking issues +-- The results will change from second to second on a busy system +-- You should run this query multiple times when you see signs of blocking + + + +-- Get CPU Utilization History for last 256 minutes (in one minute intervals) (Query 28) (CPU Utilization History) +DECLARE @ts_now bigint = (SELECT cpu_ticks/(cpu_ticks/ms_ticks) FROM sys.dm_os_sys_info WITH (NOLOCK)); + +SELECT TOP(256) SQLProcessUtilization AS [SQL Server Process CPU Utilization], + SystemIdle AS [System Idle Process], + 100 - SystemIdle - SQLProcessUtilization AS [Other Process CPU Utilization], + DATEADD(ms, -1 * (@ts_now - [timestamp]), GETDATE()) AS [Event Time] +FROM (SELECT record.value('(./Record/@id)[1]', 'int') AS record_id, + record.value('(./Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int') + AS [SystemIdle], + record.value('(./Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]', 'int') + AS [SQLProcessUtilization], [timestamp] + FROM (SELECT [timestamp], CONVERT(xml, record) AS [record] + FROM sys.dm_os_ring_buffers WITH (NOLOCK) + WHERE ring_buffer_type = N'RING_BUFFER_SCHEDULER_MONITOR' + AND record LIKE N'%%') AS x) AS y +ORDER BY record_id DESC OPTION (RECOMPILE); +------ + +-- Look at the trend over the entire period +-- Also look at high sustained 'Other Process' CPU Utilization values +-- Note: This query sometimes gives inaccurate results (negative values) +-- on high core count (> 64 cores) systems + + +-- Get top total worker time queries for entire instance (Query 29) (Top Worker Time Queries) +SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], +REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], +qs.total_worker_time AS [Total Worker Time], qs.min_worker_time AS [Min Worker Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.max_worker_time AS [Max Worker Time], +qs.min_elapsed_time AS [Min Elapsed Time], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.max_elapsed_time AS [Max Elapsed Time], +qs.min_logical_reads AS [Min Logical Reads], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +qs.max_logical_reads AS [Max Logical Reads], +qs.execution_count AS [Execution Count], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] +--,t.[text] AS [Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel +FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t +CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp +ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); +------ + + +-- Helps you find the most expensive queries from a CPU perspective across the entire instance +-- Can also help track down parameter sniffing issues + + + +-- Page Life Expectancy (PLE) value for each NUMA node in current instance (Query 30) (PLE by NUMA Node) +SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], + instance_name, cntr_value AS [Page Life Expectancy] +FROM sys.dm_os_performance_counters WITH (NOLOCK) +WHERE [object_name] LIKE N'%Buffer Node%' -- Handles named instances +AND counter_name = N'Page life expectancy' OPTION (RECOMPILE); +------ + +-- PLE is a good measurement of internal memory pressure +-- Higher PLE is better. Watch the trend over time, not the absolute value +-- This will only return one row for non-NUMA systems + +-- Page Life Expectancy isnt what you think +-- https://bit.ly/2EgynLa + + +-- Memory Grants Pending value for current instance (Query 31) (Memory Grants Pending) +SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], cntr_value AS [Memory Grants Pending] +FROM sys.dm_os_performance_counters WITH (NOLOCK) +WHERE [object_name] LIKE N'%Memory Manager%' -- Handles named instances +AND counter_name = N'Memory Grants Pending' OPTION (RECOMPILE); +------ + +-- Run multiple times, and run periodically if you suspect you are under memory pressure +-- Memory Grants Pending above zero for a sustained period is a very strong indicator of internal memory pressure + + +-- Memory Clerk Usage for instance (Query 32) (Memory Clerk Usage) +-- Look for high value for CACHESTORE_SQLCP (Ad-hoc query plans) +SELECT TOP(10) mc.[type] AS [Memory Clerk Type], + CAST((SUM(mc.pages_kb)/1024.0) AS DECIMAL (15,2)) AS [Memory Usage (MB)] +FROM sys.dm_os_memory_clerks AS mc WITH (NOLOCK) +GROUP BY mc.[type] +ORDER BY SUM(mc.pages_kb) DESC OPTION (RECOMPILE); +------ + +-- MEMORYCLERK_SQLBUFFERPOOL was new for SQL Server 2012. It should be your highest consumer of memory + +-- CACHESTORE_SQLCP SQL Plans +-- These are cached SQL statements or batches that aren't in stored procedures, functions and triggers +-- Watch out for high values for CACHESTORE_SQLCP +-- Enabling 'optimize for ad hoc workloads' at the instance level can help reduce this +-- Running DBCC FREESYSTEMCACHE ('SQL Plans') periodically may be required to better control this + +-- CACHESTORE_OBJCP Object Plans +-- These are compiled plans for stored procedures, functions and triggers + +-- sys.dm_os_memory_clerks (Transact-SQL) +-- https://bit.ly/2H31xDR + + + +-- Find single-use, ad-hoc and prepared queries that are bloating the plan cache (Query 33) (Ad hoc Queries) +SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], t.[text] AS [Query Text], +cp.objtype AS [Object Type], cp.cacheobjtype AS [Cache Object Type], +cp.size_in_bytes/1024 AS [Plan Size in KB] +FROM sys.dm_exec_cached_plans AS cp WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t +WHERE cp.cacheobjtype = N'Compiled Plan' +AND cp.objtype IN (N'Adhoc', N'Prepared') +AND cp.usecounts = 1 +ORDER BY cp.size_in_bytes DESC, DB_NAME(t.[dbid]) OPTION (RECOMPILE); +------ + +-- Gives you the text, type and size of single-use ad-hoc and prepared queries that waste space in the plan cache +-- Enabling 'optimize for ad hoc workloads' for the instance can help (SQL Server 2008 and above only) +-- Running DBCC FREESYSTEMCACHE ('SQL Plans') periodically may be required to better control this +-- Enabling forced parameterization for the database can help, but test first! + +-- Plan cache, adhoc workloads and clearing the single-use plan cache bloat +-- https://bit.ly/2EfYOkl + + +-- Get top total logical reads queries for entire instance (Query 34) (Top Logical Reads Queries) +SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], +REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], +qs.total_logical_reads AS [Total Logical Reads], +qs.min_logical_reads AS [Min Logical Reads], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +qs.max_logical_reads AS [Max Logical Reads], +qs.min_worker_time AS [Min Worker Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.max_worker_time AS [Max Worker Time], +qs.min_elapsed_time AS [Min Elapsed Time], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.max_elapsed_time AS [Max Elapsed Time], +qs.execution_count AS [Execution Count], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] +--,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel +FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t +CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp +ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE); +------ + + +-- Helps you find the most expensive queries from a memory perspective across the entire instance +-- Can also help track down parameter sniffing issues + + +-- Get top average elapsed time queries for entire instance (Query 35) (Top Avg Elapsed Time Queries) +SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], +REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.min_elapsed_time, qs.max_elapsed_time, qs.last_elapsed_time, +qs.execution_count AS [Execution Count], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +qs.total_physical_reads/qs.execution_count AS [Avg Physical Reads], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] +--,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel +FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t +CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp +ORDER BY qs.total_elapsed_time/qs.execution_count DESC OPTION (RECOMPILE); +------ + +-- Helps you find the highest average elapsed time queries across the entire instance +-- Can also help track down parameter sniffing issues + + +-- Look at UDF execution statistics (Query 36) (UDF Stats by DB) +SELECT TOP (25) DB_NAME(database_id) AS [Database Name], + OBJECT_NAME(object_id, database_id) AS [Function Name], + total_worker_time, execution_count, total_elapsed_time, + total_elapsed_time/execution_count AS [avg_elapsed_time], + last_elapsed_time, last_execution_time, cached_time, [type_desc] +FROM sys.dm_exec_function_stats WITH (NOLOCK) +ORDER BY total_worker_time DESC OPTION (RECOMPILE); +------ + +-- sys.dm_exec_function_stats (Transact-SQL) +-- https://bit.ly/2q1Q6BM + +-- Showplan Enhancements for UDFs +-- https://bit.ly/2LVqiQ1 + + +-- Database specific queries ***************************************************************** + +-- **** Please switch to a user database that you are interested in! ***** +--USE YourDatabaseName; -- make sure to change to an actual database on your instance, not the master system database +--GO + +-- Individual File Sizes and space available for current database (Query 37) (File Sizes and Space) +SELECT f.name AS [File Name] , f.physical_name AS [Physical Name], +CAST((f.size/128.0) AS DECIMAL(15,2)) AS [Total Size in MB], +CAST(f.size/128.0 - CAST(FILEPROPERTY(f.name, 'SpaceUsed') AS int)/128.0 AS DECIMAL(15,2)) +AS [Available Space In MB], f.[file_id], fg.name AS [Filegroup Name], +f.is_percent_growth, f.growth, fg.is_default, fg.is_read_only, +fg.is_autogrow_all_files +FROM sys.database_files AS f WITH (NOLOCK) +LEFT OUTER JOIN sys.filegroups AS fg WITH (NOLOCK) +ON f.data_space_id = fg.data_space_id +ORDER BY f.[file_id] OPTION (RECOMPILE); +------ + +-- Look at how large and how full the files are and where they are located +-- Make sure the transaction log is not full!! + +-- is_autogrow_all_files was new for SQL Server 2016. Equivalent to TF 1117 for user databases + +-- SQL Server 2016: Changes in default behavior for autogrow and allocations for tempdb and user databases +-- https://bit.ly/2evRZSR + + +-- Log space usage for current database (Query 38) (Log Space Usage) +SELECT DB_NAME(lsu.database_id) AS [Database Name], db.recovery_model_desc AS [Recovery Model], + CAST(lsu.total_log_size_in_bytes/1048576.0 AS DECIMAL(10, 2)) AS [Total Log Space (MB)], + CAST(lsu.used_log_space_in_bytes/1048576.0 AS DECIMAL(10, 2)) AS [Used Log Space (MB)], + CAST(lsu.used_log_space_in_percent AS DECIMAL(10, 2)) AS [Used Log Space %], + CAST(lsu.log_space_in_bytes_since_last_backup/1048576.0 AS DECIMAL(10, 2)) AS [Used Log Space Since Last Backup (MB)], + db.log_reuse_wait_desc +FROM sys.dm_db_log_space_usage AS lsu WITH (NOLOCK) +INNER JOIN sys.databases AS db WITH (NOLOCK) +ON lsu.database_id = db.database_id +OPTION (RECOMPILE); +------ + +-- Look at log file size and usage, along with the log reuse wait description for the current database + +-- sys.dm_db_log_space_usage (Transact-SQL) +-- https://bit.ly/2H4MQw9 + + +-- Status of last VLF for current database (Query 39) (Last VLF Status) +SELECT TOP(1) DB_NAME(li.database_id) AS [Database Name], li.[file_id], + li.vlf_size_mb, li.vlf_sequence_number, li.vlf_active, li.vlf_status +FROM sys.dm_db_log_info(DB_ID()) AS li +ORDER BY vlf_sequence_number DESC OPTION (RECOMPILE); +------ + +-- Determine whether you will be able to shrink the transaction log file + +-- vlf_status Values +-- 0 is inactive +-- 1 is initialized but unused +-- 2 is active + +-- sys.dm_db_log_info (Transact-SQL) +-- https://bit.ly/2EQUU1v + + + +-- Get database scoped configuration values for current database (Query 40) (Database-scoped Configurations) +SELECT configuration_id, name, [value] AS [value_for_primary] +FROM sys.database_scoped_configurations WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- This lets you see the value of these new properties for the current database + +-- Clear plan cache for current database +-- ALTER DATABASE SCOPED CONFIGURATION CLEAR PROCEDURE_CACHE; + +-- ALTER DATABASE SCOPED CONFIGURATION (Transact-SQL) +-- https://bit.ly/2sOH7nb + + +-- I/O Statistics by file for the current database (Query 41) (IO Stats By File) +SELECT DB_NAME(DB_ID()) AS [Database Name], df.name AS [Logical Name], vfs.[file_id], df.type_desc, +df.physical_name AS [Physical Name], CAST(vfs.size_on_disk_bytes/1048576.0 AS DECIMAL(10, 2)) AS [Size on Disk (MB)], +vfs.num_of_reads, vfs.num_of_writes, vfs.io_stall_read_ms, vfs.io_stall_write_ms, +CAST(100. * vfs.io_stall_read_ms/(vfs.io_stall_read_ms + vfs.io_stall_write_ms) AS DECIMAL(10,1)) AS [IO Stall Reads Pct], +CAST(100. * vfs.io_stall_write_ms/(vfs.io_stall_write_ms + vfs.io_stall_read_ms) AS DECIMAL(10,1)) AS [IO Stall Writes Pct], +(vfs.num_of_reads + vfs.num_of_writes) AS [Writes + Reads], +CAST(vfs.num_of_bytes_read/1048576.0 AS DECIMAL(10, 2)) AS [MB Read], +CAST(vfs.num_of_bytes_written/1048576.0 AS DECIMAL(10, 2)) AS [MB Written], +CAST(100. * vfs.num_of_reads/(vfs.num_of_reads + vfs.num_of_writes) AS DECIMAL(10,1)) AS [# Reads Pct], +CAST(100. * vfs.num_of_writes/(vfs.num_of_reads + vfs.num_of_writes) AS DECIMAL(10,1)) AS [# Write Pct], +CAST(100. * vfs.num_of_bytes_read/(vfs.num_of_bytes_read + vfs.num_of_bytes_written) AS DECIMAL(10,1)) AS [Read Bytes Pct], +CAST(100. * vfs.num_of_bytes_written/(vfs.num_of_bytes_read + vfs.num_of_bytes_written) AS DECIMAL(10,1)) AS [Written Bytes Pct] +FROM sys.dm_io_virtual_file_stats(DB_ID(), NULL) AS vfs +INNER JOIN sys.database_files AS df WITH (NOLOCK) +ON vfs.[file_id]= df.[file_id] OPTION (RECOMPILE); +------ + +-- This helps you characterize your workload better from an I/O perspective for this database +-- It helps you determine whether you has an OLTP or DW/DSS type of workload + + + +-- Get most frequently executed queries for this database (Query 42) (Query Execution Counts) +SELECT TOP(50) LEFT(t.[text], 50) AS [Short Query Text], qs.execution_count AS [Execution Count], +qs.total_logical_reads AS [Total Logical Reads], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +qs.total_worker_time AS [Total Worker Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.total_elapsed_time AS [Total Elapsed Time], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] +--,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel +FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t +CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp +WHERE t.dbid = DB_ID() +ORDER BY qs.execution_count DESC OPTION (RECOMPILE); +------ + + +-- Queries 48 through 53 are the "Bad Man List" for stored procedures + +-- Top Cached SPs By Execution Count (Query 43) (SP Execution Counts) +SELECT TOP(100) p.name AS [SP Name], qs.execution_count AS [Execution Count], +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +ORDER BY qs.execution_count DESC OPTION (RECOMPILE); +------ + +-- Tells you which cached stored procedures are called the most often +-- This helps you characterize and baseline your workload + + +-- Top Cached SPs By Avg Elapsed Time (Query 44) (SP Avg Elapsed Time) +SELECT TOP(25) p.name AS [SP Name], qs.min_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +qs.max_elapsed_time, qs.last_elapsed_time, qs.total_elapsed_time, qs.execution_count, +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], +qs.total_worker_time AS [TotalWorkerTime], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +ORDER BY avg_elapsed_time DESC OPTION (RECOMPILE); +------ + +-- This helps you find high average elapsed time cached stored procedures that +-- may be easy to optimize with standard query tuning techniques + + + +-- Top Cached SPs By Total Worker time. Worker time relates to CPU cost (Query 45) (SP Worker Time) +SELECT TOP(25) p.name AS [SP Name], qs.total_worker_time AS [TotalWorkerTime], +qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], qs.execution_count, +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +--,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); +------ + +-- This helps you find the most expensive cached stored procedures from a CPU perspective +-- You should look at this if you see signs of CPU pressure + + +-- Top Cached SPs By Total Logical Reads. Logical reads relate to memory pressure (Query 46) (SP Logical Reads) +SELECT TOP(25) p.name AS [SP Name], qs.total_logical_reads AS [TotalLogicalReads], +qs.total_logical_reads/qs.execution_count AS [AvgLogicalReads],qs.execution_count, +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE); +------ + +-- This helps you find the most expensive cached stored procedures from a memory perspective +-- You should look at this if you see signs of memory pressure + + +-- Top Cached SPs By Total Physical Reads. Physical reads relate to disk read I/O pressure (Query 47) (SP Physical Reads) +SELECT TOP(25) p.name AS [SP Name],qs.total_physical_reads AS [TotalPhysicalReads], +qs.total_physical_reads/qs.execution_count AS [AvgPhysicalReads], qs.execution_count, +qs.total_logical_reads,qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND qs.total_physical_reads > 0 +ORDER BY qs.total_physical_reads DESC, qs.total_logical_reads DESC OPTION (RECOMPILE); +------ + +-- This helps you find the most expensive cached stored procedures from a read I/O perspective +-- You should look at this if you see signs of I/O pressure or of memory pressure + + + +-- Top Cached SPs By Total Logical Writes (Query 48) (SP Logical Writes) +-- Logical writes relate to both memory and disk I/O pressure +SELECT TOP(25) p.name AS [SP Name], qs.total_logical_writes AS [TotalLogicalWrites], +qs.total_logical_writes/qs.execution_count AS [AvgLogicalWrites], qs.execution_count, +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND qs.total_logical_writes > 0 +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +ORDER BY qs.total_logical_writes DESC OPTION (RECOMPILE); +------ + +-- This helps you find the most expensive cached stored procedures from a write I/O perspective +-- You should look at this if you see signs of I/O pressure or of memory pressure + + +-- Lists the top statements by average input/output usage for the current database (Query 49) (Top IO Statements) +SELECT TOP(50) OBJECT_NAME(qt.objectid, dbid) AS [SP Name], +(qs.total_logical_reads + qs.total_logical_writes) /qs.execution_count AS [Avg IO], qs.execution_count AS [Execution Count], +SUBSTRING(qt.[text],qs.statement_start_offset/2, + (CASE + WHEN qs.statement_end_offset = -1 + THEN LEN(CONVERT(nvarchar(max), qt.[text])) * 2 + ELSE qs.statement_end_offset + END - qs.statement_start_offset)/2) AS [Query Text] +FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS qt +WHERE qt.[dbid] = DB_ID() +ORDER BY [Avg IO] DESC OPTION (RECOMPILE); +------ + +-- Helps you find the most expensive statements for I/O by SP + + + +-- Possible Bad NC Indexes (writes > reads) (Query 50) (Bad NC Indexes) +SELECT SCHEMA_NAME(o.[schema_id]) AS [Schema Name], +OBJECT_NAME(s.[object_id]) AS [Table Name], +i.name AS [Index Name], i.index_id, +i.is_disabled, i.is_hypothetical, i.has_filter, i.fill_factor, +s.user_updates AS [Total Writes], s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], +s.user_updates - (s.user_seeks + s.user_scans + s.user_lookups) AS [Difference] +FROM sys.dm_db_index_usage_stats AS s WITH (NOLOCK) +INNER JOIN sys.indexes AS i WITH (NOLOCK) +ON s.[object_id] = i.[object_id] +AND i.index_id = s.index_id +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON i.[object_id] = o.[object_id] +WHERE OBJECTPROPERTY(s.[object_id],'IsUserTable') = 1 +AND s.database_id = DB_ID() +AND s.user_updates > (s.user_seeks + s.user_scans + s.user_lookups) +AND i.index_id > 1 AND i.[type_desc] = N'NONCLUSTERED' +AND i.is_primary_key = 0 AND i.is_unique_constraint = 0 AND i.is_unique = 0 +ORDER BY [Difference] DESC, [Total Writes] DESC, [Total Reads] ASC OPTION (RECOMPILE); +------ + +-- Look for indexes with high numbers of writes and zero or very low numbers of reads +-- Consider your complete workload, and how long your instance has been running +-- Investigate further before dropping an index! + + +-- Missing Indexes for current database by Index Advantage (Query 51) (Missing Indexes) +SELECT DISTINCT CONVERT(decimal(18,2), user_seeks * avg_total_user_cost * (avg_user_impact * 0.01)) AS [index_advantage], +migs.last_user_seek, mid.[statement] AS [Database.Schema.Table], +mid.equality_columns, mid.inequality_columns, mid.included_columns, +migs.unique_compiles, migs.user_seeks, migs.avg_total_user_cost, migs.avg_user_impact, +OBJECT_NAME(mid.[object_id]) AS [Table Name], p.rows AS [Table Rows] +FROM sys.dm_db_missing_index_group_stats AS migs WITH (NOLOCK) +INNER JOIN sys.dm_db_missing_index_groups AS mig WITH (NOLOCK) +ON migs.group_handle = mig.index_group_handle +INNER JOIN sys.dm_db_missing_index_details AS mid WITH (NOLOCK) +ON mig.index_handle = mid.index_handle +INNER JOIN sys.partitions AS p WITH (NOLOCK) +ON p.[object_id] = mid.[object_id] +WHERE mid.database_id = DB_ID() +AND p.index_id < 2 +ORDER BY index_advantage DESC OPTION (RECOMPILE); +------ + +-- Look at index advantage, last user seek time, number of user seeks to help determine source and importance +-- SQL Server is overly eager to add included columns, so beware +-- Do not just blindly add indexes that show up from this query!!! + + +-- Find missing index warnings for cached plans in the current database (Query 52) (Missing Index Warnings) +-- Note: This query could take some time on a busy instance +SELECT TOP(25) OBJECT_NAME(objectid) AS [ObjectName], + cp.objtype, cp.usecounts, cp.size_in_bytes, query_plan +FROM sys.dm_exec_cached_plans AS cp WITH (NOLOCK) +CROSS APPLY sys.dm_exec_query_plan(cp.plan_handle) AS qp +WHERE CAST(query_plan AS NVARCHAR(MAX)) LIKE N'%MissingIndex%' +AND dbid = DB_ID() +ORDER BY cp.usecounts DESC OPTION (RECOMPILE); +------ + +-- Helps you connect missing indexes to specific stored procedures or queries +-- This can help you decide whether to add them or not + + +-- Breaks down buffers used by current database by object (table, index) in the buffer cache (Query 53) (Buffer Usage) +-- Note: This query could take some time on a busy instance +SELECT fg.name AS [Filegroup Name], SCHEMA_NAME(o.Schema_ID) AS [Schema Name], +OBJECT_NAME(p.[object_id]) AS [Object Name], p.index_id, +CAST(COUNT(*)/128.0 AS DECIMAL(10, 2)) AS [Buffer size(MB)], +COUNT(*) AS [BufferCount], p.[Rows] AS [Row Count], +p.data_compression_desc AS [Compression Type] +FROM sys.allocation_units AS a WITH (NOLOCK) +INNER JOIN sys.dm_os_buffer_descriptors AS b WITH (NOLOCK) +ON a.allocation_unit_id = b.allocation_unit_id +INNER JOIN sys.partitions AS p WITH (NOLOCK) +ON a.container_id = p.hobt_id +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON p.object_id = o.object_id +INNER JOIN sys.database_files AS f WITH (NOLOCK) +ON b.file_id = f.file_id +INNER JOIN sys.filegroups AS fg WITH (NOLOCK) +ON f.data_space_id = fg.data_space_id +WHERE b.database_id = CONVERT(int, DB_ID()) +AND p.[object_id] > 100 +AND OBJECT_NAME(p.[object_id]) NOT LIKE N'plan_%' +AND OBJECT_NAME(p.[object_id]) NOT LIKE N'sys%' +AND OBJECT_NAME(p.[object_id]) NOT LIKE N'xml_index_nodes%' +GROUP BY fg.name, o.Schema_ID, p.[object_id], p.index_id, + p.data_compression_desc, p.[Rows] +ORDER BY [BufferCount] DESC OPTION (RECOMPILE); +------ + +-- Tells you what tables and indexes are using the most memory in the buffer cache +-- It can help identify possible candidates for data compression + + +-- Get Table names, row counts, and compression status for clustered index or heap (Query 54) (Table Sizes) +SELECT SCHEMA_NAME(o.Schema_ID) AS [Schema Name], OBJECT_NAME(p.object_id) AS [ObjectName], +SUM(p.Rows) AS [RowCount], data_compression_desc AS [CompressionType] +FROM sys.partitions AS p WITH (NOLOCK) +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON p.object_id = o.object_id +WHERE index_id < 2 --ignore the partitions from the non-clustered index if any +AND OBJECT_NAME(p.object_id) NOT LIKE N'sys%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'spt_%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'queue_%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'filestream_tombstone%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'fulltext%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'ifts_comp_fragment%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'filetable_updates%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'xml_index_nodes%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'sqlagent_job%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'plan_persist%' +GROUP BY SCHEMA_NAME(o.Schema_ID), p.object_id, data_compression_desc +ORDER BY SUM(p.Rows) DESC OPTION (RECOMPILE); +------ + +-- Gives you an idea of table sizes, and possible data compression opportunities + + + +-- Get some key table properties (Query 55) (Table Properties) +SELECT OBJECT_NAME(t.[object_id]) AS [ObjectName], p.[rows] AS [Table Rows], p.index_id, + p.data_compression_desc AS [Index Data Compression], + t.create_date, t.lock_on_bulk_load, t.is_replicated, t.has_replication_filter, + t.is_tracked_by_cdc, t.lock_escalation_desc, t.is_filetable, + t.is_memory_optimized, t.durability_desc, + t.temporal_type_desc, t.is_remote_data_archive_enabled, t.is_external -- new for SQL Server 2016 +FROM sys.tables AS t WITH (NOLOCK) +INNER JOIN sys.partitions AS p WITH (NOLOCK) +ON t.[object_id] = p.[object_id] +WHERE OBJECT_NAME(t.[object_id]) NOT LIKE N'sys%' +ORDER BY OBJECT_NAME(t.[object_id]), p.index_id OPTION (RECOMPILE); +------ + +-- Gives you some good information about your tables +-- is_memory_optimized and durability_desc were new in SQL Server 2014 +-- temporal_type_desc, is_remote_data_archive_enabled, is_external were new in SQL Server 2016 + +-- sys.tables (Transact-SQL) +-- https://bit.ly/2Gk7998 + + + +-- When were Statistics last updated on all indexes? (Query 56) (Statistics Update) +SELECT SCHEMA_NAME(o.Schema_ID) + N'.' + o.[NAME] AS [Object Name], o.[type_desc] AS [Object Type], + i.[name] AS [Index Name], STATS_DATE(i.[object_id], i.index_id) AS [Statistics Date], + s.auto_created, s.no_recompute, s.user_created, s.is_incremental, s.is_temporary, + st.row_count, st.used_page_count +FROM sys.objects AS o WITH (NOLOCK) +INNER JOIN sys.indexes AS i WITH (NOLOCK) +ON o.[object_id] = i.[object_id] +INNER JOIN sys.stats AS s WITH (NOLOCK) +ON i.[object_id] = s.[object_id] +AND i.index_id = s.stats_id +INNER JOIN sys.dm_db_partition_stats AS st WITH (NOLOCK) +ON o.[object_id] = st.[object_id] +AND i.[index_id] = st.[index_id] +WHERE o.[type] IN ('U', 'V') +AND st.row_count > 0 +ORDER BY STATS_DATE(i.[object_id], i.index_id) DESC OPTION (RECOMPILE); +------ + +-- Helps discover possible problems with out-of-date statistics +-- Also gives you an idea which indexes are the most active + +-- sys.stats (Transact-SQL) +-- https://bit.ly/2GyAxrn + +-- UPDATEs to Statistics (Erin Stellato) +-- https://bit.ly/2vhrYQy + + + + +-- Look at most frequently modified indexes and statistics (Query 57) (Volatile Indexes) +SELECT o.[name] AS [Object Name], o.[object_id], o.[type_desc], s.[name] AS [Statistics Name], + s.stats_id, s.no_recompute, s.auto_created, s.is_incremental, s.is_temporary, + sp.modification_counter, sp.[rows], sp.rows_sampled, sp.last_updated +FROM sys.objects AS o WITH (NOLOCK) +INNER JOIN sys.stats AS s WITH (NOLOCK) +ON s.object_id = o.object_id +CROSS APPLY sys.dm_db_stats_properties(s.object_id, s.stats_id) AS sp +WHERE o.[type_desc] NOT IN (N'SYSTEM_TABLE', N'INTERNAL_TABLE') +AND sp.modification_counter > 0 +ORDER BY sp.modification_counter DESC, o.name OPTION (RECOMPILE); +------ + +-- This helps you understand your workload and make better decisions about +-- things like data compression and adding new indexes to a table + + + +-- Get fragmentation info for all indexes above a certain size in the current database (Query 58) (Index Fragmentation) +-- Note: This query could take some time on a very large database +SELECT DB_NAME(ps.database_id) AS [Database Name], SCHEMA_NAME(o.[schema_id]) AS [Schema Name], +OBJECT_NAME(ps.OBJECT_ID) AS [Object Name], i.[name] AS [Index Name], ps.index_id, +ps.index_type_desc, ps.avg_fragmentation_in_percent, +ps.fragment_count, ps.page_count, i.fill_factor, i.has_filter, +i.filter_definition, i.[allow_page_locks] +FROM sys.dm_db_index_physical_stats(DB_ID(),NULL, NULL, NULL , N'LIMITED') AS ps +INNER JOIN sys.indexes AS i WITH (NOLOCK) +ON ps.[object_id] = i.[object_id] +AND ps.index_id = i.index_id +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON i.[object_id] = o.[object_id] +WHERE ps.database_id = DB_ID() +AND ps.page_count > 2500 +ORDER BY ps.avg_fragmentation_in_percent DESC OPTION (RECOMPILE); +------ + +-- Helps determine whether you have framentation in your relational indexes +-- and how effective your index maintenance strategy is + + +--- Index Read/Write stats (all tables in current DB) ordered by Reads (Query 59) (Overall Index Usage - Reads) +SELECT SCHEMA_NAME(t.[schema_id]) AS [SchemaName], OBJECT_NAME(i.[object_id]) AS [ObjectName], + i.[name] AS [IndexName], i.index_id, + s.user_seeks, s.user_scans, s.user_lookups, + s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], + s.user_updates AS [Writes], + i.[type_desc] AS [Index Type], i.fill_factor AS [Fill Factor], i.has_filter, i.filter_definition, + s.last_user_scan, s.last_user_lookup, s.last_user_seek +FROM sys.indexes AS i WITH (NOLOCK) +LEFT OUTER JOIN sys.dm_db_index_usage_stats AS s WITH (NOLOCK) +ON i.[object_id] = s.[object_id] +AND i.index_id = s.index_id +AND s.database_id = DB_ID() +LEFT OUTER JOIN sys.tables AS t WITH (NOLOCK) +ON t.[object_id] = i.[object_id] +WHERE OBJECTPROPERTY(i.[object_id],'IsUserTable') = 1 +ORDER BY s.user_seeks + s.user_scans + s.user_lookups DESC OPTION (RECOMPILE); -- Order by reads +------ + +-- Show which indexes in the current database are most active for Reads + + +--- Index Read/Write stats (all tables in current DB) ordered by Writes (Query 60) (Overall Index Usage - Writes) +SELECT SCHEMA_NAME(t.[schema_id]) AS [SchemaName],OBJECT_NAME(i.[object_id]) AS [ObjectName], + i.[name] AS [IndexName], i.index_id, + s.user_updates AS [Writes], s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], + i.[type_desc] AS [Index Type], i.fill_factor AS [Fill Factor], i.has_filter, i.filter_definition, + s.last_system_update, s.last_user_update +FROM sys.indexes AS i WITH (NOLOCK) +LEFT OUTER JOIN sys.dm_db_index_usage_stats AS s WITH (NOLOCK) +ON i.[object_id] = s.[object_id] +AND i.index_id = s.index_id +AND s.database_id = DB_ID() +LEFT OUTER JOIN sys.tables AS t WITH (NOLOCK) +ON t.[object_id] = i.[object_id] +WHERE OBJECTPROPERTY(i.[object_id],'IsUserTable') = 1 +ORDER BY s.user_updates DESC OPTION (RECOMPILE); -- Order by writes + +-- Show which indexes in the current database are most active for Writes + + + +-- Look at Columnstore index physical statistics (Query 61) (Columnstore Index Physical Stat) +SELECT OBJECT_NAME(ps.object_id) AS [TableName], + i.[name] AS [IndexName], ps.index_id, ps.partition_number, + ps.delta_store_hobt_id, ps.state_desc, ps.total_rows, ps.size_in_bytes, + ps.trim_reason_desc, ps.generation, ps.transition_to_compressed_state_desc, + ps.has_vertipaq_optimization, ps.deleted_rows, + 100 * (ISNULL(ps.deleted_rows, 0))/ps.total_rows AS [Fragmentation] +FROM sys.dm_db_column_store_row_group_physical_stats AS ps WITH (NOLOCK) +INNER JOIN sys.indexes AS i WITH (NOLOCK) +ON ps.object_id = i.object_id +AND ps.index_id = i.index_id +ORDER BY ps.object_id, ps.partition_number, ps.row_group_id OPTION (RECOMPILE); +------ + +-- sys.dm_db_column_store_row_group_physical_stats (Transact-SQL) +-- https://bit.ly/2q276XQ + + + +-- Get lock waits for current database (Query 62) (Lock Waits) +SELECT o.name AS [table_name], i.name AS [index_name], ios.index_id, ios.partition_number, + SUM(ios.row_lock_wait_count) AS [total_row_lock_waits], + SUM(ios.row_lock_wait_in_ms) AS [total_row_lock_wait_in_ms], + SUM(ios.page_lock_wait_count) AS [total_page_lock_waits], + SUM(ios.page_lock_wait_in_ms) AS [total_page_lock_wait_in_ms], + SUM(ios.page_lock_wait_in_ms)+ SUM(row_lock_wait_in_ms) AS [total_lock_wait_in_ms] +FROM sys.dm_db_index_operational_stats(DB_ID(), NULL, NULL, NULL) AS ios +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON ios.[object_id] = o.[object_id] +INNER JOIN sys.indexes AS i WITH (NOLOCK) +ON ios.[object_id] = i.[object_id] +AND ios.index_id = i.index_id +WHERE o.[object_id] > 100 +GROUP BY o.name, i.name, ios.index_id, ios.partition_number +HAVING SUM(ios.page_lock_wait_in_ms)+ SUM(row_lock_wait_in_ms) > 0 +ORDER BY total_lock_wait_in_ms DESC OPTION (RECOMPILE); +------ + +-- This query is helpful for troubleshooting blocking and deadlocking issues + + + +-- Look at UDF execution statistics (Query 63) (UDF Statistics) +SELECT OBJECT_NAME(object_id) AS [Function Name], execution_count, + total_worker_time, total_logical_reads, total_physical_reads, total_elapsed_time, + total_elapsed_time/execution_count AS [avg_elapsed_time], + FORMAT(cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +FROM sys.dm_exec_function_stats WITH (NOLOCK) +WHERE database_id = DB_ID() +ORDER BY total_worker_time DESC OPTION (RECOMPILE); +------ + +-- New for SQL Server 2016 +-- Helps you investigate scalar UDF performance issues +-- Does not return information for table valued functions + +-- sys.dm_exec_function_stats (Transact-SQL) +-- https://bit.ly/2q1Q6BM + + +-- Determine which scalar UDFs are in-lineable (Query 64) (Inlineable UDFs) +SELECT OBJECT_NAME(m.object_id) AS [Function Name], m.is_inlineable, m.inline_type, m.definition +FROM sys.sql_modules AS m WITH (NOLOCK) +LEFT OUTER JOIN sys.dm_exec_function_stats AS efs WITH (NOLOCK) +ON m.object_id = efs.object_id +WHERE efs.type_desc = N'SQL_SCALAR_FUNCTION' +OPTION (RECOMPILE); +------ + +-- Scalar UDF Inlining +-- https://bit.ly/2JU971M + +-- sys.sql_modules (Transact-SQL) +-- https://bit.ly/2Qt216S + + +-- Get QueryStore Options for this database (Query 65) (QueryStore Options) +SELECT actual_state_desc, desired_state_desc, [interval_length_minutes], + current_storage_size_mb, [max_storage_size_mb], + query_capture_mode_desc, size_based_cleanup_mode_desc +FROM sys.database_query_store_options WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- New for SQL Server 2016 +-- Requires that Query Store is enabled for this database + +-- Make sure that the actual_state_desc is the same as desired_state_desc +-- Make sure that the current_storage_size_mb is less than the max_storage_size_mb + +-- Tuning Workload Performance with Query Store +-- https://bit.ly/1kHSl7w + + + +-- Get input buffer information for the current database (Query 66) (Input Buffer) +SELECT es.session_id, DB_NAME(es.database_id) AS [Database Name], + es.login_time, es.cpu_time, es.logical_reads, es.memory_usage, + es.[status], ib.event_info AS [Input Buffer] +FROM sys.dm_exec_sessions AS es WITH (NOLOCK) +CROSS APPLY sys.dm_exec_input_buffer(es.session_id, NULL) AS ib +WHERE es.database_id = DB_ID() +AND es.session_id > 50 +AND es.session_id <> @@SPID OPTION (RECOMPILE); +------ + +-- Gives you input buffer information from all non-system sessions for the current database +-- Replaces DBCC INPUTBUFFER + +-- New DMF for retrieving input buffer in SQL Server +-- https://bit.ly/2uHKMbz + +-- sys.dm_exec_input_buffer (Transact-SQL) +-- https://bit.ly/2J5Hf9q + + + +-- Get any resumable index rebuild operation information (Query 67) (Resumable Index Rebuild) +SELECT OBJECT_NAME(iro.object_id) AS [Object Name], iro.index_id, iro.name AS [Index Name], + iro.sql_text, iro.last_max_dop_used, iro.partition_number, iro.state_desc, iro.start_time, iro.percent_complete +FROM sys.index_resumable_operations AS iro WITH (NOLOCK) +OPTION (RECOMPILE); +------ + +-- index_resumable_operations (Transact-SQL) +-- https://bit.ly/2pYSWqq + + +-- Get database automatic tuning options (Query 68) (Automatic Tuning Options) +SELECT [name], desired_state_desc, actual_state_desc, reason_desc +FROM sys.database_automatic_tuning_options WITH (NOLOCK) +OPTION (RECOMPILE); +------ + +-- sys.database_automatic_tuning_options (Transact-SQL) +-- https://bit.ly/2FHhLkL + + + +-- Look at recent Full backups for the current database (Query 69) (Recent Full Backups) +SELECT TOP (30) bs.machine_name, bs.server_name, bs.database_name AS [Database Name], bs.recovery_model, +CONVERT (BIGINT, bs.backup_size / 1048576 ) AS [Uncompressed Backup Size (MB)], +CONVERT (BIGINT, bs.compressed_backup_size / 1048576 ) AS [Compressed Backup Size (MB)], +CONVERT (NUMERIC (20,2), (CONVERT (FLOAT, bs.backup_size) / +CONVERT (FLOAT, bs.compressed_backup_size))) AS [Compression Ratio], bs.has_backup_checksums, bs.is_copy_only, bs.encryptor_type, +DATEDIFF (SECOND, bs.backup_start_date, bs.backup_finish_date) AS [Backup Elapsed Time (sec)], +bs.backup_finish_date AS [Backup Finish Date], bmf.physical_device_name AS [Backup Location], bmf.physical_block_size +FROM msdb.dbo.backupset AS bs WITH (NOLOCK) +INNER JOIN msdb.dbo.backupmediafamily AS bmf WITH (NOLOCK) +ON bs.media_set_id = bmf.media_set_id +WHERE bs.database_name = DB_NAME(DB_ID()) +AND bs.[type] = 'D' +ORDER BY bs.backup_finish_date DESC OPTION (RECOMPILE); +------ + +-- Automatic database backups by the MI Service will not appear in this list + +-- Are your backup sizes and times changing over time? +-- Are you using backup compression? +-- Are you using backup checksums? +-- Are you doing copy_only backups? +-- Are you doing encrypted backups? +-- Have you done any backup tuning with striped backups, or changing the parameters of the backup command? + +-- In SQL Server 2016, native SQL Server backup compression actually works +-- much better with databases that are using TDE than in previous versions +-- https://bit.ly/28Rpb2x + + +-- Microsoft Visual Studio Dev Essentials +-- https://bit.ly/2qjNRxi + +-- Microsoft Azure Learn +-- https://bit.ly/2O0Hacc + + diff --git a/Scripts/SQL Server 2005 Diagnostic Information Queries.sql b/Scripts/SQL Server 2005 Diagnostic Information Queries.sql index 0d68f85b..da495695 100644 --- a/Scripts/SQL Server 2005 Diagnostic Information Queries.sql +++ b/Scripts/SQL Server 2005 Diagnostic Information Queries.sql @@ -1,26 +1,22 @@ -- SQL Server 2005 Diagnostic Information Queries -- Glenn Berry --- CY 2017 --- Last Modified: December 6, 2017 --- https://www.sqlserverperformance.wordpress.com/ --- https://www.sqlskills.com/blogs/glenn/ +-- Last Modified: December 3, 2020 +-- https://glennsqlperformance.com/ +-- https://sqlserverperformance.wordpress.com/ +-- YouTube: https://bit.ly/2PkoAM1 -- Twitter: GlennAlanBerry --- Please listen to my Pluralsight courses --- https://www.pluralsight.com/author/glenn-berry - --- If you want to find all of our SQLskills SQL101 blog posts, check out https://www.sqlskills.com/help/sql101/ +-- Diagnostic Queries are available here +-- https://glennsqlperformance.com/resources/ -- Many of these queries will not work if you have databases in 80 compatibility mode -- Please make sure you are using the correct version of these diagnostic queries for your version of SQL Server --****************************************************************************** ---* Copyright (C) 2017 Glenn Berry, SQLskills.com +--* Copyright (C) 2020 Glenn Berry --* All rights reserved. --* ---* For more scripts and sample code, check out ---* https://www.sqlskills.com/blogs/glenn --* --* You may alter this code for your own *non-commercial* purposes. You may --* republish altered code as long as you include this copyright and give due credit. @@ -151,7 +147,7 @@ ORDER BY name OPTION (RECOMPILE); ------ -- Gives you some basic information about your SQL Server Agent Alerts (which are different from SQL Server Agent jobs) --- Read more about Agent Alerts here: https://www.sqlskills.com/blogs/glenn/creating-sql-server-agent-alerts-for-critical-errors/ +-- Read more about Agent Alerts here: https://bit.ly/2v5YR37 -- Returns a list of all global trace flags that are enabled (Query 6) (Global Trace Flags) @@ -163,15 +159,15 @@ DBCC TRACESTATUS (-1); -- Common trace flags that should be enabled in most cases -- TF 1117 - When growing a data file, grow all files at the same time so they remain the same size, reducing allocation contention points --- http://support2.microsoft.com/kb/2154845 +-- https://bit.ly/2GY1kOl -- -- TF 1118 - Helps alleviate allocation contention in tempdb, SQL Server allocates full extents to each database object, -- thereby eliminating the contention on SGAM pages (more important with older versions of SQL Server) -- Recommendations to reduce allocation contention in SQL Server tempdb database --- http://support2.microsoft.com/kb/2154845 +-- https://bit.ly/2GY1kOl -- TF 3226 - Supresses logging of successful database backup messages to the SQL Server Error Log --- https://www.sqlskills.com/blogs/paul/fed-up-with-backup-success-messages-bloating-your-error-logs/ +-- https://bit.ly/38zDNAK -- Hardware Information from SQL Server 2005 (Query 7) (Hardware Info) @@ -232,9 +228,9 @@ ORDER BY name OPTION (RECOMPILE); -- File names and paths for all user and system databases on instance (Query 11) (Database Filenames and Paths) SELECT DB_NAME([database_id]) AS [Database Name], [file_id], [name], physical_name, [type_desc], state_desc, - is_percent_growth, growth, + is_percent_growth, growth, CONVERT(bigint, growth/128.0) AS [Growth in MB], - CONVERT(bigint, size/128.0) AS [Total Size in MB] + CONVERT(bigint, size/128.0) AS [Total Size in MB], max_size FROM sys.master_files WITH (NOLOCK) ORDER BY DB_NAME([database_id]), [file_id] OPTION (RECOMPILE); ------ @@ -284,7 +280,7 @@ DROP TABLE #IOWarningResults; -- Drive level latency information (Query 13) (Drive Level Latency) -- Based on code from Jimmy May -SELECT tab.[Drive], tab.volume_mount_point AS [Volume Mount Point], +SELECT tab.[Drive], CASE WHEN num_of_reads = 0 THEN 0 ELSE (io_stall_read_ms/num_of_reads) @@ -312,12 +308,11 @@ SELECT tab.[Drive], tab.volume_mount_point AS [Volume Mount Point], FROM (SELECT LEFT(UPPER(mf.physical_name), 2) AS Drive, SUM(num_of_reads) AS num_of_reads, SUM(io_stall_read_ms) AS io_stall_read_ms, SUM(num_of_writes) AS num_of_writes, SUM(io_stall_write_ms) AS io_stall_write_ms, SUM(num_of_bytes_read) AS num_of_bytes_read, - SUM(num_of_bytes_written) AS num_of_bytes_written, SUM(io_stall) AS io_stall, vs.volume_mount_point + SUM(num_of_bytes_written) AS num_of_bytes_written, SUM(io_stall) AS io_stall FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS vfs INNER JOIN sys.master_files AS mf WITH (NOLOCK) ON vfs.database_id = mf.database_id AND vfs.file_id = mf.file_id - CROSS APPLY sys.dm_os_volume_stats(mf.database_id, mf.[file_id]) AS vs - GROUP BY LEFT(UPPER(mf.physical_name), 2), vs.volume_mount_point) AS tab + GROUP BY LEFT(UPPER(mf.physical_name), 2)) AS tab ORDER BY [Overall Latency] OPTION (RECOMPILE); ------ @@ -326,9 +321,9 @@ ORDER BY [Overall Latency] OPTION (RECOMPILE); -- Calculates average stalls per read, per write, and per total input/output for each database file (Query 14) (IO Stalls by File) -SELECT DB_NAME(fs.database_id) AS [Database Name], CAST(fs.io_stall_read_ms/(1.0 + fs.num_of_reads) AS NUMERIC(10,1)) AS [avg_read_stall_ms], -CAST(fs.io_stall_write_ms/(1.0 + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_write_stall_ms], -CAST((fs.io_stall_read_ms + fs.io_stall_write_ms)/(1.0 + fs.num_of_reads + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_io_stall_ms], +SELECT DB_NAME(fs.database_id) AS [Database Name], CAST(fs.io_stall_read_ms/(1.0 + fs.num_of_reads) AS NUMERIC(16,1)) AS [avg_read_stall_ms], +CAST(fs.io_stall_write_ms/(1.0 + fs.num_of_writes) AS NUMERIC(16,1)) AS [avg_write_stall_ms], +CAST((fs.io_stall_read_ms + fs.io_stall_write_ms)/(1.0 + fs.num_of_reads + fs.num_of_writes) AS NUMERIC(16,1)) AS [avg_io_stall_ms], CONVERT(DECIMAL(18,2), mf.size/128.0) AS [File Size (MB)], mf.physical_name, mf.type_desc, fs.io_stall_read_ms, fs.num_of_reads, fs.io_stall_write_ms, fs.num_of_writes, fs.io_stall_read_ms + fs.io_stall_write_ms AS [io_stalls], fs.num_of_reads + fs.num_of_writes AS [total_io] FROM sys.dm_io_virtual_file_stats(null,null) AS fs @@ -364,6 +359,15 @@ AND ls.counter_name LIKE N'Log File(s) Size (KB)%' AND ls.cntr_value > 0 OPTION (RECOMPILE); ------ +-- sys.databases (Transact-SQL) +-- https://bit.ly/2G5wqaX + +-- sys.dm_os_performance_counters (Transact-SQL) +-- https://bit.ly/3kEO2JR + +-- sys.dm_database_encryption_keys (Transact-SQL) +-- https://bit.ly/3mE7kkx + -- Things to look at: -- How many databases are on the instance? -- What recovery models are they using? @@ -449,6 +453,7 @@ ORDER BY [CPU Rank] OPTION (RECOMPILE); ------ -- Helps determine which database is using the most CPU resources on the instance +-- Note: This only reflects CPU usage from the currently cached query plans -- Get I/O utilization by database (Query 19) (IO Usage By Database) @@ -533,27 +538,27 @@ SELECT FROM Waits AS W1 INNER JOIN Waits AS W2 ON W2.RowNum <= W1.RowNum -GROUP BY W1.RowNum +GROUP BY W1.RowNum, W1.wait_type HAVING SUM (W2.Percentage) - MAX (W1.Percentage) < 99 -- percentage threshold OPTION (RECOMPILE); ------ -- Cumulative wait stats are not as useful on an idle instance that is not under load or performance pressure --- SQL Server Wait Types Library (Paul Randal) --- https://www.sqlskills.com/help/waits/ +-- SQL Server Wait Types Library +-- https://bit.ly/2ePzYO2 -- The SQL Server Wait Type Repository --- http://blogs.msdn.com/b/psssql/archive/2009/11/03/the-sql-server-wait-type-repository.aspx +-- https://bit.ly/1afzfjC -- Wait statistics, or please tell me where it hurts --- https://www.sqlskills.com/blogs/paul/wait-statistics-or-please-tell-me-where-it-hurts/ +-- https://bit.ly/2wsQHQE -- SQL Server 2005 Performance Tuning using the Waits and Queues --- http://technet.microsoft.com/en-us/library/cc966413.aspx +-- https://bit.ly/1o2NFoF -- sys.dm_os_wait_stats (Transact-SQL) --- http://msdn.microsoft.com/en-us/library/ms179984(v=sql.105).aspx +-- https://bit.ly/2Hjq9Yl @@ -706,13 +711,15 @@ ORDER BY SUM(single_pages_kb) DESC OPTION (RECOMPILE); -- Find single-use, ad-hoc queries that are bloating the plan cache (Query 30) (Ad hoc Queries) -SELECT TOP(50) [text] AS [QueryText], cp.cacheobjtype, cp.objtype, cp.size_in_bytes/1024 AS [Plan Size in KB] +SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], t.[text] AS [Query Text], +cp.objtype AS [Object Type], cp.cacheobjtype AS [Cache Object Type], +cp.size_in_bytes/1024 AS [Plan Size in KB] FROM sys.dm_exec_cached_plans AS cp WITH (NOLOCK) -CROSS APPLY sys.dm_exec_sql_text(plan_handle) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t WHERE cp.cacheobjtype = N'Compiled Plan' AND cp.objtype IN (N'Adhoc', N'Prepared') AND cp.usecounts = 1 -ORDER BY cp.size_in_bytes DESC OPTION (RECOMPILE); +ORDER BY cp.size_in_bytes DESC, DB_NAME(t.[dbid]) OPTION (RECOMPILE); ------ -- Gives you the text and size of single-use ad-hoc queries that waste space in plan cache @@ -904,20 +911,19 @@ ORDER BY [Avg IO] DESC OPTION (RECOMPILE); -- Possible Bad NC Indexes (writes > reads) (Query 40) (Bad NC Indexes) -SELECT OBJECT_NAME(s.[object_id]) AS [Table Name], i.name AS [Index Name], -o.[type_desc], o.create_date, i.index_id, i.is_disabled, +SELECT OBJECT_NAME(s.[object_id]) AS [Table Name], i.name AS [Index Name], i.index_id, +i.is_disabled, i.is_hypothetical, i.has_filter, i.fill_factor, user_updates AS [Total Writes], user_seeks + user_scans + user_lookups AS [Total Reads], user_updates - (user_seeks + user_scans + user_lookups) AS [Difference] FROM sys.dm_db_index_usage_stats AS s WITH (NOLOCK) INNER JOIN sys.indexes AS i WITH (NOLOCK) ON s.[object_id] = i.[object_id] AND i.index_id = s.index_id -INNER JOIN sys.objects AS o WITH (NOLOCK) -ON i.[object_id] = o.[object_id] WHERE OBJECTPROPERTY(s.[object_id],'IsUserTable') = 1 AND s.database_id = DB_ID() -AND user_updates > (user_seeks + user_scans + user_lookups) -AND i.index_id > 1 +AND s.user_updates > (s.user_seeks + s.user_scans + s.user_lookups) +AND i.index_id > 1 AND i.[type_desc] = N'NONCLUSTERED' +AND i.is_primary_key = 0 AND i.is_unique_constraint = 0 ORDER BY [Difference] DESC, [Total Writes] DESC, [Total Reads] ASC OPTION (RECOMPILE); ------ @@ -983,15 +989,24 @@ ORDER BY buffer_count DESC OPTION (RECOMPILE); -- Get Table names, row counts (Query 44) (Table Sizes) -SELECT OBJECT_NAME(object_id) AS [ObjectName], SUM(Rows) AS [RowCount] -FROM sys.partitions WITH (NOLOCK) +SELECT SCHEMA_NAME(o.Schema_ID) AS [Schema Name], OBJECT_NAME(p.object_id) AS [ObjectName], +SUM(p.Rows) AS [RowCount] +FROM sys.partitions AS p WITH (NOLOCK) +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON p.object_id = o.object_id WHERE index_id < 2 --ignore the partitions from the non-clustered index if any -AND OBJECT_NAME(object_id) NOT LIKE N'sys%' -AND OBJECT_NAME(object_id) NOT LIKE N'queue_%' -AND OBJECT_NAME(object_id) NOT LIKE N'filestream_tombstone%' -AND OBJECT_NAME(object_id) NOT LIKE N'fulltext%' -GROUP BY [object_id] -ORDER BY SUM(Rows) DESC OPTION (RECOMPILE); +AND OBJECT_NAME(p.object_id) NOT LIKE N'sys%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'spt_%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'queue_%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'filestream_tombstone%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'fulltext%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'ifts_comp_fragment%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'filetable_updates%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'xml_index_nodes%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'sqlagent_job%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'plan_persist%' +GROUP BY SCHEMA_NAME(o.Schema_ID), p.object_id +ORDER BY SUM(p.Rows) DESC OPTION (RECOMPILE); ------ -- Gives you an idea of table sizes @@ -1067,32 +1082,41 @@ ORDER BY ps.avg_fragmentation_in_percent DESC OPTION (RECOMPILE); --- Index Read/Write stats (all tables in current DB) ordered by Reads (Query 48) (Overall Index Usage - Reads) -SELECT OBJECT_NAME(s.[object_id]) AS [ObjectName], i.name AS [IndexName], i.index_id, - user_seeks + user_scans + user_lookups AS [Reads], s.user_updates AS [Writes], - i.type_desc AS [IndexType], i.fill_factor AS [FillFactor] -FROM sys.dm_db_index_usage_stats AS s WITH (NOLOCK) -INNER JOIN sys.indexes AS i WITH (NOLOCK) -ON s.[object_id] = i.[object_id] -WHERE OBJECTPROPERTY(s.[object_id],'IsUserTable') = 1 +SELECT SCHEMA_NAME(t.[schema_id]) AS [SchemaName], OBJECT_NAME(i.[object_id]) AS [ObjectName], + i.[name] AS [IndexName], i.index_id, + s.user_seeks, s.user_scans, s.user_lookups, + s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], + s.user_updates AS [Writes], + i.[type_desc] AS [Index Type], i.fill_factor AS [Fill Factor], i.has_filter, i.filter_definition, + s.last_user_scan, s.last_user_lookup, s.last_user_seek +FROM sys.indexes AS i WITH (NOLOCK) +LEFT OUTER JOIN sys.dm_db_index_usage_stats AS s WITH (NOLOCK) +ON i.[object_id] = s.[object_id] AND i.index_id = s.index_id AND s.database_id = DB_ID() -ORDER BY user_seeks + user_scans + user_lookups DESC OPTION (RECOMPILE); -- Order by reads +LEFT OUTER JOIN sys.tables AS t WITH (NOLOCK) +ON t.[object_id] = i.[object_id] +WHERE OBJECTPROPERTY(i.[object_id],'IsUserTable') = 1 +ORDER BY s.user_seeks + s.user_scans + s.user_lookups DESC OPTION (RECOMPILE); -- Order by reads ------ -- Show which indexes in the current database are most active for Reads --- Index Read/Write stats (all tables in current DB) ordered by Writes (Query 49) (Overall Index Usage - Writes) -SELECT OBJECT_NAME(s.[object_id]) AS [ObjectName], i.name AS [IndexName], i.index_id, - s.user_updates AS [Writes], user_seeks + user_scans + user_lookups AS [Reads], - i.type_desc AS [IndexType], i.fill_factor AS [FillFactor], +SELECT SCHEMA_NAME(t.[schema_id]) AS [SchemaName],OBJECT_NAME(i.[object_id]) AS [ObjectName], + i.[name] AS [IndexName], i.index_id, + s.user_updates AS [Writes], s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], + i.[type_desc] AS [Index Type], i.fill_factor AS [Fill Factor], i.has_filter, i.filter_definition, s.last_system_update, s.last_user_update -FROM sys.dm_db_index_usage_stats AS s WITH (NOLOCK) -INNER JOIN sys.indexes AS i WITH (NOLOCK) -ON s.[object_id] = i.[object_id] -WHERE OBJECTPROPERTY(s.[object_id],'IsUserTable') = 1 +FROM sys.indexes AS i WITH (NOLOCK) +LEFT OUTER JOIN sys.dm_db_index_usage_stats AS s WITH (NOLOCK) +ON i.[object_id] = s.[object_id] AND i.index_id = s.index_id AND s.database_id = DB_ID() +LEFT OUTER JOIN sys.tables AS t WITH (NOLOCK) +ON t.[object_id] = i.[object_id] +WHERE OBJECTPROPERTY(i.[object_id],'IsUserTable') = 1 ORDER BY s.user_updates DESC OPTION (RECOMPILE); -- Order by writes ------ @@ -1137,34 +1161,19 @@ ORDER BY bs.backup_finish_date DESC OPTION (RECOMPILE); ------ -- Are your backup sizes and times changing over time? +-- Are you using backup compression? +-- Are you using backup checksums? +-- Are you doing copy_only backups? +-- Have you done any backup tuning with striped backups, or changing the parameters of the backup command? --- These three Pluralsight Courses go into more detail about how to run these queries and interpret the results - --- SQL Server 2014 DMV Diagnostic Queries Part 1 --- https://www.pluralsight.com/courses/sql-server-2014-dmv-diagnostic-queries-part1 - --- SQL Server 2014 DMV Diagnostic Queries Part 2 --- https://www.pluralsight.com/courses/sql-server-2014-dmv-diagnostic-queries-part2 - --- SQL Server 2014 DMV Diagnostic Queries Part 3 --- https://www.pluralsight.com/courses/sql-server-2014-dmv-diagnostic-queries-part3 - - --- Sign up for Microsoft Visual Studio Dev Essentials and get a free three month pass to Pluralsight - -- Microsoft Visual Studio Dev Essentials --- http://bit.ly/1q6xbDL - - --- Sign up for Microsoft IT Pro Cloud Essentials and get lots of free Azure usage credits, MCP exam voucher, three month Pluralsight subscription +-- https://bit.ly/2qjNRxi --- Microsoft IT Pro Cloud Essentials --- http://bit.ly/2443SAd +-- Microsoft Azure Learn +-- https://bit.ly/2O0Hacc --- August 2017 blog series about upgrading and migrating SQL Server --- https://www.sqlskills.com/blogs/glenn/category/upgrading-sql-server/ diff --git a/Scripts/SQL Server 2008 Diagnostic Information Queries.sql b/Scripts/SQL Server 2008 Diagnostic Information Queries.sql index d8792a7b..1c5cb165 100644 --- a/Scripts/SQL Server 2008 Diagnostic Information Queries.sql +++ b/Scripts/SQL Server 2008 Diagnostic Information Queries.sql @@ -1,26 +1,22 @@ -- SQL Server 2008 Diagnostic Information Queries -- Glenn Berry --- CY 2017 --- Last Modified: December 6, 2017 +-- Last Modified: December 3, 2020 +-- https://glennsqlperformance.com/ -- https://sqlserverperformance.wordpress.com/ --- https://www.sqlskills.com/blogs/glenn/ +-- YouTube: https://bit.ly/2PkoAM1 -- Twitter: GlennAlanBerry --- Please listen to my Pluralsight courses --- https://www.pluralsight.com/author/glenn-berry - --- If you want to find all of our SQLskills SQL101 blog posts, check out https://www.sqlskills.com/help/sql101/ +-- Diagnostic Queries are available here +-- https://glennsqlperformance.com/resources/ -- Many of these queries will not work if you have databases in 80 compatibility mode -- Please make sure you are using the correct version of these diagnostic queries for your version of SQL Server --****************************************************************************** ---* Copyright (C) 2017 Glenn Berry, SQLskills.com +--* Copyright (C) 2020 Glenn Berry --* All rights reserved. --* ---* For more scripts and sample code, check out ---* https://www.sqlskills.com/blogs/glenn --* --* You may alter this code for your own *non-commercial* purposes. You may --* republish altered code as long as you include this copyright and give due credit. @@ -90,7 +86,7 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In -- 10.0.5861 SP3 CU17 5/19/2014 -- 10.0.5867 SP3 CU17+ 10.0.6000 SP4 RTM 9/30/2014 -- 10.0.6526 SP4 + HF 2/9/2015 --- http://support.microsoft.com/kb/3034373 +-- Security Update for SQL Server 2008 SP4 (KB4057114) https://www.microsoft.com/en-us/download/details.aspx?id=56418 10.0.6556 SP4 + HF 1/5/2018 -- -- SQL Server 2008 RTM is considered an "unsupported service pack" as of April 13, 2010 -- SQL Server 2008 SP1 is considered an "unsupported service pack" as of September 19, 2011 @@ -114,6 +110,7 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In -- Download SQL Server Management Studio (SSMS) -- https://msdn.microsoft.com/en-us/library/mt238290.aspx +-- SQL Server 2008 Configuration Manager is SQLServerManager10.msc -- When was SQL Server installed (Query 2) (SQL Server Install Date) @@ -173,7 +170,7 @@ ORDER BY name OPTION (RECOMPILE); ------ -- Gives you some basic information about your SQL Server Agent Alerts (which are different from SQL Server Agent jobs) --- Read more about Agent Alerts here: https://www.sqlskills.com/blogs/glenn/creating-sql-server-agent-alerts-for-critical-errors/ +-- Read more about Agent Alerts here: https://bit.ly/2v5YR37 -- Returns a list of all global trace flags that are enabled (Query 6) (Global Trace Flags) @@ -185,18 +182,18 @@ DBCC TRACESTATUS (-1); -- Common trace flags that should be enabled in most cases -- TF 1117 - When growing a data file, grow all files at the same time so they remain the same size, reducing allocation contention points --- http://support2.microsoft.com/kb/2154845 +-- https://bit.ly/2GY1kOl -- -- TF 1118 - Helps alleviate allocation contention in tempdb, SQL Server allocates full extents to each database object, -- thereby eliminating the contention on SGAM pages (more important with older versions of SQL Server) -- Recommendations to reduce allocation contention in SQL Server tempdb database --- http://support2.microsoft.com/kb/2154845 +-- https://bit.ly/2GY1kOl -- TF 2371 - Lowers auto update statistics threshold for large tables --- http://blogs.msdn.com/b/saponsqlserver/archive/2011/09/07/changes-to-automatic-update-statistics-in-sql-server-traceflag-2371.aspx +-- https://bit.ly/30KO4Hh -- TF 3226 - Supresses logging of successful database backup messages to the SQL Server Error Log --- https://www.sqlskills.com/blogs/paul/fed-up-with-backup-success-messages-bloating-your-error-logs/ +-- https://bit.ly/38zDNAK -- SQL Server NUMA Node information (Query 7) (SQL Server NUMA Info) @@ -214,7 +211,9 @@ WHERE node_state_desc <> N'ONLINE DAC' OPTION (RECOMPILE); -- (Cannot distinguish between HT and multi-core) SELECT cpu_count AS [Logical CPU Count], hyperthread_ratio AS [Hyperthread Ratio], cpu_count/hyperthread_ratio AS [Physical CPU Count], -physical_memory_in_bytes/1048576 AS [Physical Memory (MB)], sqlserver_start_time +physical_memory_in_bytes/1048576 AS [Physical Memory (MB)], +sqlserver_start_time, +DATEDIFF(hour, sqlserver_start_time, GETDATE()) AS [SQL Server Up Time (hrs)] FROM sys.dm_os_sys_info WITH (NOLOCK) OPTION (RECOMPILE); ------ @@ -282,9 +281,9 @@ ORDER BY name OPTION (RECOMPILE); -- File names and paths for all user and system databases on instance (Query 13) (Database Filenames and Paths) SELECT DB_NAME([database_id]) AS [Database Name], [file_id], [name], physical_name, [type_desc], state_desc, - is_percent_growth, growth, + is_percent_growth, growth, CONVERT(bigint, growth/128.0) AS [Growth in MB], - CONVERT(bigint, size/128.0) AS [Total Size in MB] + CONVERT(bigint, size/128.0) AS [Total Size in MB], max_size FROM sys.master_files WITH (NOLOCK) ORDER BY DB_NAME([database_id]), [file_id] OPTION (RECOMPILE); ------ @@ -334,7 +333,7 @@ DROP TABLE #IOWarningResults; -- Drive level latency information (Query 15) (Drive Level Latency) -- Based on code from Jimmy May -SELECT tab.[Drive], tab.volume_mount_point AS [Volume Mount Point], +SELECT tab.[Drive], CASE WHEN num_of_reads = 0 THEN 0 ELSE (io_stall_read_ms/num_of_reads) @@ -362,12 +361,11 @@ SELECT tab.[Drive], tab.volume_mount_point AS [Volume Mount Point], FROM (SELECT LEFT(UPPER(mf.physical_name), 2) AS Drive, SUM(num_of_reads) AS num_of_reads, SUM(io_stall_read_ms) AS io_stall_read_ms, SUM(num_of_writes) AS num_of_writes, SUM(io_stall_write_ms) AS io_stall_write_ms, SUM(num_of_bytes_read) AS num_of_bytes_read, - SUM(num_of_bytes_written) AS num_of_bytes_written, SUM(io_stall) AS io_stall, vs.volume_mount_point + SUM(num_of_bytes_written) AS num_of_bytes_written, SUM(io_stall) AS io_stall FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS vfs INNER JOIN sys.master_files AS mf WITH (NOLOCK) ON vfs.database_id = mf.database_id AND vfs.file_id = mf.file_id - CROSS APPLY sys.dm_os_volume_stats(mf.database_id, mf.[file_id]) AS vs - GROUP BY LEFT(UPPER(mf.physical_name), 2), vs.volume_mount_point) AS tab + GROUP BY LEFT(UPPER(mf.physical_name), 2)) AS tab ORDER BY [Overall Latency] OPTION (RECOMPILE); ------ @@ -376,9 +374,9 @@ ORDER BY [Overall Latency] OPTION (RECOMPILE); -- Calculates average stalls per read, per write, and per total input/output for each database file (Query 16) (IO Stalls by File) -SELECT DB_NAME(fs.database_id) AS [Database Name], CAST(fs.io_stall_read_ms/(1.0 + fs.num_of_reads) AS NUMERIC(10,1)) AS [avg_read_stall_ms], -CAST(fs.io_stall_write_ms/(1.0 + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_write_stall_ms], -CAST((fs.io_stall_read_ms + fs.io_stall_write_ms)/(1.0 + fs.num_of_reads + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_io_stall_ms], +SELECT DB_NAME(fs.database_id) AS [Database Name], CAST(fs.io_stall_read_ms/(1.0 + fs.num_of_reads) AS NUMERIC(16,1)) AS [avg_read_stall_ms], +CAST(fs.io_stall_write_ms/(1.0 + fs.num_of_writes) AS NUMERIC(16,1)) AS [avg_write_stall_ms], +CAST((fs.io_stall_read_ms + fs.io_stall_write_ms)/(1.0 + fs.num_of_reads + fs.num_of_writes) AS NUMERIC(16,1)) AS [avg_io_stall_ms], CONVERT(DECIMAL(18,2), mf.size/128.0) AS [File Size (MB)], mf.physical_name, mf.type_desc, fs.io_stall_read_ms, fs.num_of_reads, fs.io_stall_write_ms, fs.num_of_writes, fs.io_stall_read_ms + fs.io_stall_write_ms AS [io_stalls], fs.num_of_reads + fs.num_of_writes AS [total_io] FROM sys.dm_io_virtual_file_stats(null,null) AS fs @@ -414,6 +412,15 @@ AND ls.counter_name LIKE N'Log File(s) Size (KB)%' AND ls.cntr_value > 0 OPTION (RECOMPILE); ------ +-- sys.databases (Transact-SQL) +-- https://bit.ly/2G5wqaX + +-- sys.dm_os_performance_counters (Transact-SQL) +-- https://bit.ly/3kEO2JR + +-- sys.dm_database_encryption_keys (Transact-SQL) +-- https://bit.ly/3mE7kkx + -- Things to look at: -- How many databases are on the instance? -- What recovery models are they using? @@ -499,6 +506,7 @@ ORDER BY [CPU Rank] OPTION (RECOMPILE); ------ -- Helps determine which database is using the most CPU resources on the instance +-- Note: This only reflects CPU usage from the currently cached query plans -- Get I/O utilization by database (Query 21) (IO Usage By Database) @@ -583,27 +591,27 @@ SELECT FROM Waits AS W1 INNER JOIN Waits AS W2 ON W2.RowNum <= W1.RowNum -GROUP BY W1.RowNum +GROUP BY W1.RowNum, W1.wait_type HAVING SUM (W2.Percentage) - MAX (W1.Percentage) < 99 -- percentage threshold OPTION (RECOMPILE); ------ -- Cumulative wait stats are not as useful on an idle instance that is not under load or performance pressure --- SQL Server Wait Types Library (Paul Randal) --- https://www.sqlskills.com/help/waits/ +-- SQL Server Wait Types Library +-- https://bit.ly/2ePzYO2 -- The SQL Server Wait Type Repository --- http://blogs.msdn.com/b/psssql/archive/2009/11/03/the-sql-server-wait-type-repository.aspx +-- https://bit.ly/1afzfjC -- Wait statistics, or please tell me where it hurts --- https://www.sqlskills.com/blogs/paul/wait-statistics-or-please-tell-me-where-it-hurts/ +-- https://bit.ly/2wsQHQE -- SQL Server 2005 Performance Tuning using the Waits and Queues --- http://technet.microsoft.com/en-us/library/cc966413.aspx +-- https://bit.ly/1o2NFoF -- sys.dm_os_wait_stats (Transact-SQL) --- http://msdn.microsoft.com/en-us/library/ms179984(v=sql.105).aspx +-- https://bit.ly/2Hjq9Ylx @@ -680,7 +688,7 @@ WHERE scheduler_id < 255 OPTION (RECOMPILE); -- High Avg Pending DiskIO Counts are a sign of disk pressure -- How to Do Some Very Basic SQL Server Monitoring --- https://www.sqlskills.com/blogs/glenn/how-to-do-some-very-basic-sql-server-monitoring/ +-- https://bit.ly/30IRla0 @@ -735,7 +743,8 @@ ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); -- Good basic information about OS memory amounts and state (Query 30) (System Memory) SELECT total_physical_memory_kb/1024 AS [Physical Memory (MB)], available_physical_memory_kb/1024 AS [Available Memory (MB)], - total_page_file_kb/1024 AS [Total Page File (MB)], + total_page_file_kb/1024 AS [Page File Commit Limit (MB)], + total_page_file_kb/1024 - total_physical_memory_kb/1024 AS [Physical Page File Size (MB)], available_page_file_kb/1024 AS [Available Page File (MB)], system_cache_kb/1024 AS [System Cache (MB)], system_memory_state_desc AS [System Memory State] @@ -804,13 +813,15 @@ ORDER BY SUM(single_pages_kb) DESC OPTION (RECOMPILE); -- Find single-use, ad-hoc and prepared queries that are bloating the plan cache (Query 35) (Ad hoc Queries) -SELECT TOP(50) [text] AS [QueryText], cp.cacheobjtype, cp.objtype, cp.size_in_bytes/1024 AS [Plan Size in KB] +SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], t.[text] AS [Query Text], +cp.objtype AS [Object Type], cp.cacheobjtype AS [Cache Object Type], +cp.size_in_bytes/1024 AS [Plan Size in KB] FROM sys.dm_exec_cached_plans AS cp WITH (NOLOCK) -CROSS APPLY sys.dm_exec_sql_text(plan_handle) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t WHERE cp.cacheobjtype = N'Compiled Plan' AND cp.objtype IN (N'Adhoc', N'Prepared') AND cp.usecounts = 1 -ORDER BY cp.size_in_bytes DESC OPTION (RECOMPILE); +ORDER BY cp.size_in_bytes DESC, DB_NAME(t.[dbid]) OPTION (RECOMPILE); ------ -- Gives you the text, type and size of single-use ad-hoc and prepared queries that waste space in the plan cache @@ -1028,8 +1039,9 @@ ON s.[object_id] = i.[object_id] AND i.index_id = s.index_id WHERE OBJECTPROPERTY(s.[object_id],'IsUserTable') = 1 AND s.database_id = DB_ID() -AND user_updates > (user_seeks + user_scans + user_lookups) -AND i.index_id > 1 +AND s.user_updates > (s.user_seeks + s.user_scans + s.user_lookups) +AND i.index_id > 1 AND i.[type_desc] = N'NONCLUSTERED' +AND i.is_primary_key = 0 AND i.is_unique_constraint = 0 ORDER BY [Difference] DESC, [Total Writes] DESC, [Total Reads] ASC OPTION (RECOMPILE); ------ @@ -1078,18 +1090,24 @@ ORDER BY cp.usecounts DESC OPTION (RECOMPILE); -- Breaks down buffers used by current database by object (table, index) in the buffer cache (Query 50) (Buffer Usage) -- Note: This query could take some time on a busy instance -SELECT OBJECT_NAME(p.[object_id]) AS [Object Name], p.index_id, +SELECT SCHEMA_NAME(o.Schema_ID) AS [Schema Name], +OBJECT_NAME(p.[object_id]) AS [Object Name], p.index_id, CAST(COUNT(*)/128.0 AS DECIMAL(10, 2)) AS [Buffer size(MB)], -COUNT(*) AS [BufferCount], p.Rows AS [Row Count], +COUNT(*) AS [BufferCount], p.[Rows] AS [Row Count], p.data_compression_desc AS [Compression Type] FROM sys.allocation_units AS a WITH (NOLOCK) INNER JOIN sys.dm_os_buffer_descriptors AS b WITH (NOLOCK) ON a.allocation_unit_id = b.allocation_unit_id INNER JOIN sys.partitions AS p WITH (NOLOCK) ON a.container_id = p.hobt_id -WHERE b.database_id = CONVERT(int,DB_ID()) +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON p.object_id = o.object_id +WHERE b.database_id = CONVERT(int, DB_ID()) AND p.[object_id] > 100 -GROUP BY p.[object_id], p.index_id, p.data_compression_desc, p.[Rows] +AND OBJECT_NAME(p.[object_id]) NOT LIKE N'plan_%' +AND OBJECT_NAME(p.[object_id]) NOT LIKE N'sys%' +AND OBJECT_NAME(p.[object_id]) NOT LIKE N'xml_index_nodes%' +GROUP BY o.Schema_ID, p.[object_id], p.index_id, p.data_compression_desc, p.[Rows] ORDER BY [BufferCount] DESC OPTION (RECOMPILE); ------ @@ -1098,18 +1116,24 @@ ORDER BY [BufferCount] DESC OPTION (RECOMPILE); -- Get Table names, row counts, and compression status for clustered index or heap (Query 51) (Table Sizes) -SELECT OBJECT_NAME(object_id) AS [ObjectName], -SUM(Rows) AS [RowCount], data_compression_desc AS [CompressionType] -FROM sys.partitions WITH (NOLOCK) +SELECT SCHEMA_NAME(o.Schema_ID) AS [Schema Name], OBJECT_NAME(p.object_id) AS [ObjectName], +SUM(p.Rows) AS [RowCount], data_compression_desc AS [CompressionType] +FROM sys.partitions AS p WITH (NOLOCK) +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON p.object_id = o.object_id WHERE index_id < 2 --ignore the partitions from the non-clustered index if any -AND OBJECT_NAME(object_id) NOT LIKE N'sys%' -AND OBJECT_NAME(object_id) NOT LIKE N'queue_%' -AND OBJECT_NAME(object_id) NOT LIKE N'filestream_tombstone%' -AND OBJECT_NAME(object_id) NOT LIKE N'fulltext%' -AND OBJECT_NAME(object_id) NOT LIKE N'ifts_comp_fragment%' -AND OBJECT_NAME(object_id) NOT LIKE N'xml_index_nodes%' -GROUP BY object_id, data_compression_desc -ORDER BY SUM(Rows) DESC OPTION (RECOMPILE); +AND OBJECT_NAME(p.object_id) NOT LIKE N'sys%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'spt_%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'queue_%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'filestream_tombstone%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'fulltext%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'ifts_comp_fragment%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'filetable_updates%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'xml_index_nodes%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'sqlagent_job%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'plan_persist%' +GROUP BY SCHEMA_NAME(o.Schema_ID), p.object_id, data_compression_desc +ORDER BY SUM(p.Rows) DESC OPTION (RECOMPILE); ------ -- Gives you an idea of table sizes, and possible data compression opportunities @@ -1195,17 +1219,22 @@ ORDER BY ps.avg_fragmentation_in_percent DESC OPTION (RECOMPILE); --- Index Read/Write stats (all tables in current DB) ordered by Reads (Query 56) (Overall Index Usage - Reads) -SELECT OBJECT_NAME(s.[object_id]) AS [ObjectName], i.name AS [IndexName], i.index_id, - user_seeks + user_scans + user_lookups AS [Reads], s.user_updates AS [Writes], - i.type_desc AS [IndexType], i.fill_factor AS [FillFactor], i.has_filter, i.filter_definition, +SELECT SCHEMA_NAME(t.[schema_id]) AS [SchemaName], OBJECT_NAME(i.[object_id]) AS [ObjectName], + i.[name] AS [IndexName], i.index_id, + s.user_seeks, s.user_scans, s.user_lookups, + s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], + s.user_updates AS [Writes], + i.[type_desc] AS [Index Type], i.fill_factor AS [Fill Factor], i.has_filter, i.filter_definition, s.last_user_scan, s.last_user_lookup, s.last_user_seek -FROM sys.dm_db_index_usage_stats AS s WITH (NOLOCK) -INNER JOIN sys.indexes AS i WITH (NOLOCK) -ON s.[object_id] = i.[object_id] -WHERE OBJECTPROPERTY(s.[object_id],'IsUserTable') = 1 +FROM sys.indexes AS i WITH (NOLOCK) +LEFT OUTER JOIN sys.dm_db_index_usage_stats AS s WITH (NOLOCK) +ON i.[object_id] = s.[object_id] AND i.index_id = s.index_id AND s.database_id = DB_ID() -ORDER BY user_seeks + user_scans + user_lookups DESC OPTION (RECOMPILE); -- Order by reads +LEFT OUTER JOIN sys.tables AS t WITH (NOLOCK) +ON t.[object_id] = i.[object_id] +WHERE OBJECTPROPERTY(i.[object_id],'IsUserTable') = 1 +ORDER BY s.user_seeks + s.user_scans + s.user_lookups DESC OPTION (RECOMPILE); -- Order by reads ------ @@ -1213,16 +1242,19 @@ ORDER BY user_seeks + user_scans + user_lookups DESC OPTION (RECOMPILE); -- Orde --- Index Read/Write stats (all tables in current DB) ordered by Writes (Query 57) (Overall Index Usage - Writes) -SELECT OBJECT_NAME(s.[object_id]) AS [ObjectName], i.name AS [IndexName], i.index_id, - s.user_updates AS [Writes], user_seeks + user_scans + user_lookups AS [Reads], - i.type_desc AS [IndexType], i.fill_factor AS [FillFactor], i.has_filter, i.filter_definition, +SELECT SCHEMA_NAME(t.[schema_id]) AS [SchemaName],OBJECT_NAME(i.[object_id]) AS [ObjectName], + i.[name] AS [IndexName], i.index_id, + s.user_updates AS [Writes], s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], + i.[type_desc] AS [Index Type], i.fill_factor AS [Fill Factor], i.has_filter, i.filter_definition, s.last_system_update, s.last_user_update -FROM sys.dm_db_index_usage_stats AS s WITH (NOLOCK) -INNER JOIN sys.indexes AS i WITH (NOLOCK) -ON s.[object_id] = i.[object_id] -WHERE OBJECTPROPERTY(s.[object_id],'IsUserTable') = 1 +FROM sys.indexes AS i WITH (NOLOCK) +LEFT OUTER JOIN sys.dm_db_index_usage_stats AS s WITH (NOLOCK) +ON i.[object_id] = s.[object_id] AND i.index_id = s.index_id AND s.database_id = DB_ID() +LEFT OUTER JOIN sys.tables AS t WITH (NOLOCK) +ON t.[object_id] = i.[object_id] +WHERE OBJECTPROPERTY(i.[object_id],'IsUserTable') = 1 ORDER BY s.user_updates DESC OPTION (RECOMPILE); -- Order by writes ------ @@ -1271,31 +1303,14 @@ ORDER BY bs.backup_finish_date DESC OPTION (RECOMPILE); -- Are your backup sizes and times changing over time? -- Are you using backup compression? +-- Are you using backup checksums? +-- Are you doing copy_only backups? +-- Have you done any backup tuning with striped backups, or changing the parameters of the backup command? --- These three Pluralsight Courses go into more detail about how to run these queries and interpret the results - --- SQL Server 2014 DMV Diagnostic Queries Part 1 --- https://www.pluralsight.com/courses/sql-server-2014-dmv-diagnostic-queries-part1 - --- SQL Server 2014 DMV Diagnostic Queries Part 2 --- https://www.pluralsight.com/courses/sql-server-2014-dmv-diagnostic-queries-part2 - --- SQL Server 2014 DMV Diagnostic Queries Part 3 --- https://www.pluralsight.com/courses/sql-server-2014-dmv-diagnostic-queries-part3 - - --- Sign up for Microsoft Visual Studio Dev Essentials and get a free three month pass to Pluralsight - -- Microsoft Visual Studio Dev Essentials --- http://bit.ly/1q6xbDL - - --- Sign up for Microsoft IT Pro Cloud Essentials and get lots of free Azure usage credits, MCP exam voucher, three month Pluralsight subscription - --- Microsoft IT Pro Cloud Essentials --- http://bit.ly/2443SAd +-- https://bit.ly/2qjNRxi +-- Microsoft Azure Learn +-- https://bit.ly/2O0Hacc --- August 2017 blog series about upgrading and migrating SQL Server --- https://www.sqlskills.com/blogs/glenn/category/upgrading-sql-server/ diff --git a/Scripts/SQL Server 2008 R2 Diagnostic Information Queries.sql b/Scripts/SQL Server 2008 R2 Diagnostic Information Queries.sql index 5bd6c536..7b9c0840 100644 --- a/Scripts/SQL Server 2008 R2 Diagnostic Information Queries.sql +++ b/Scripts/SQL Server 2008 R2 Diagnostic Information Queries.sql @@ -1,26 +1,22 @@ -- SQL Server 2008 R2 Diagnostic Information Queries -- Glenn Berry --- CY 2017 --- Last Modified: December 6, 2017 --- https://www.sqlserverperformance.wordpress.com/ --- https://www.sqlskills.com/blogs/glenn/ +-- Last Modified: December 3, 2020 +-- https://glennsqlperformance.com/ +-- https://sqlserverperformance.wordpress.com/ +-- YouTube: https://bit.ly/2PkoAM1 -- Twitter: GlennAlanBerry --- Please listen to my Pluralsight courses --- https://www.pluralsight.com/author/glenn-berry - --- If you want to find all of our SQLskills SQL101 blog posts, check out https://www.sqlskills.com/help/sql101/ +-- Diagnostic Queries are available here +-- https://glennsqlperformance.com/resources/ -- Many of these queries will not work if you have databases in 80 compatibility mode -- Please make sure you are using the correct version of these diagnostic queries for your version of SQL Server --****************************************************************************** ---* Copyright (C) 2017 Glenn Berry, SQLskills.com +--* Copyright (C) 2020 Glenn Berry --* All rights reserved. --* ---* For more scripts and sample code, check out ---* https://www.sqlskills.com/blogs/glenn --* --* You may alter this code for your own *non-commercial* purposes. You may --* republish altered code as long as you include this copyright and give due credit. @@ -87,6 +83,7 @@ SELECT SERVERPROPERTY ('MachineName') AS [Server Name], @@VERSION AS [SQL Server -- 10.50.4319 SP2 CU13 6/30/2014 -- 10.50.6000 SP3 RTM 9/26/2014 -- 10.50.6525 SP3 + HF 2/9/2015 http://support.microsoft.com/kb/3033860 +-- Security Update for SQL Server 2008 R2 SP3 (KB4057113) https://www.microsoft.com/en-us/download/details.aspx?id=56415 10.50.6560 SP3 + HF 1/5/2018 Hot fix for Spectre/Meltdown -- SQL Server 2008 R2 SP3 RTM plus an on-demand hotfix (Build 10.50.6525) is the final public build of SQL Server 2008 R2, barring any later security fixes. @@ -111,6 +108,7 @@ SELECT SERVERPROPERTY ('MachineName') AS [Server Name], @@VERSION AS [SQL Server -- Download SQL Server Management Studio (SSMS) -- https://msdn.microsoft.com/en-us/library/mt238290.aspx +-- SQL Server 2008 R2 Configuration Manager is SQLServerManager10.msc -- When was SQL Server installed (Query 2) (SQL Server Install Date) @@ -170,7 +168,7 @@ ORDER BY name OPTION (RECOMPILE); ------ -- Gives you some basic information about your SQL Server Agent Alerts (which are different from SQL Server Agent jobs) --- Read more about Agent Alerts here: https://www.sqlskills.com/blogs/glenn/creating-sql-server-agent-alerts-for-critical-errors/ +-- Read more about Agent Alerts here: https://bit.ly/2v5YR37 -- Returns a list of all global trace flags that are enabled (Query 6) (Global Trace Flags) @@ -182,18 +180,18 @@ DBCC TRACESTATUS (-1); -- Common trace flags that should be enabled in most cases -- TF 1117 - When growing a data file, grow all files at the same time so they remain the same size, reducing allocation contention points --- http://support2.microsoft.com/kb/2154845 +-- https://bit.ly/2GY1kOl5 -- -- TF 1118 - Helps alleviate allocation contention in tempdb, SQL Server allocates full extents to each database object, -- thereby eliminating the contention on SGAM pages (more important with older versions of SQL Server) -- Recommendations to reduce allocation contention in SQL Server tempdb database --- http://support2.microsoft.com/kb/2154845 +-- https://bit.ly/2GY1kOl -- TF 2371 - Lowers auto update statistics threshold for large tables --- http://blogs.msdn.com/b/saponsqlserver/archive/2011/09/07/changes-to-automatic-update-statistics-in-sql-server-traceflag-2371.aspx +-- https://bit.ly/30KO4Hh -- TF 3226 - Supresses logging of successful database backup messages to the SQL Server Error Log --- https://www.sqlskills.com/blogs/paul/fed-up-with-backup-success-messages-bloating-your-error-logs/ +-- https://bit.ly/38zDNAK -- Windows information (SQL Server 2008 R2 SP1 or greater) (Query 7) (Windows Info) @@ -252,7 +250,9 @@ WHERE node_state_desc <> N'ONLINE DAC' OPTION (RECOMPILE); SELECT cpu_count AS [Logical CPU Count], hyperthread_ratio AS [Hyperthread Ratio], cpu_count/hyperthread_ratio AS [Physical CPU Count], physical_memory_in_bytes/1048576 AS [Physical Memory (MB)], -sqlserver_start_time, affinity_type_desc +sqlserver_start_time, +DATEDIFF(hour, sqlserver_start_time, GETDATE()) AS [SQL Server Up Time (hrs)], +affinity_type_desc FROM sys.dm_os_sys_info WITH (NOLOCK) OPTION (RECOMPILE); ------ @@ -329,9 +329,9 @@ ORDER BY creation_time DESC OPTION (RECOMPILE); -- File names and paths for all user and system databases on instance (Query 16) (Database Filenames and Paths) SELECT DB_NAME([database_id]) AS [Database Name], [file_id], [name], physical_name, [type_desc], state_desc, - is_percent_growth, growth, + is_percent_growth, growth, CONVERT(bigint, growth/128.0) AS [Growth in MB], - CONVERT(bigint, size/128.0) AS [Total Size in MB] + CONVERT(bigint, size/128.0) AS [Total Size in MB], max_size FROM sys.master_files WITH (NOLOCK) ORDER BY DB_NAME([database_id]), [file_id] OPTION (RECOMPILE); ------ @@ -436,9 +436,9 @@ ORDER BY [Overall Latency] OPTION (RECOMPILE); -- Calculates average stalls per read, per write, and per total input/output for each database file (Query 20) (IO Stalls by File) -SELECT DB_NAME(fs.database_id) AS [Database Name], CAST(fs.io_stall_read_ms/(1.0 + fs.num_of_reads) AS NUMERIC(10,1)) AS [avg_read_stall_ms], -CAST(fs.io_stall_write_ms/(1.0 + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_write_stall_ms], -CAST((fs.io_stall_read_ms + fs.io_stall_write_ms)/(1.0 + fs.num_of_reads + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_io_stall_ms], +SELECT DB_NAME(fs.database_id) AS [Database Name], CAST(fs.io_stall_read_ms/(1.0 + fs.num_of_reads) AS NUMERIC(16,1)) AS [avg_read_stall_ms], +CAST(fs.io_stall_write_ms/(1.0 + fs.num_of_writes) AS NUMERIC(16,1)) AS [avg_write_stall_ms], +CAST((fs.io_stall_read_ms + fs.io_stall_write_ms)/(1.0 + fs.num_of_reads + fs.num_of_writes) AS NUMERIC(16,1)) AS [avg_io_stall_ms], CONVERT(DECIMAL(18,2), mf.size/128.0) AS [File Size (MB)], mf.physical_name, mf.type_desc, fs.io_stall_read_ms, fs.num_of_reads, fs.io_stall_write_ms, fs.num_of_writes, fs.io_stall_read_ms + fs.io_stall_write_ms AS [io_stalls], fs.num_of_reads + fs.num_of_writes AS [total_io] FROM sys.dm_io_virtual_file_stats(null,null) AS fs @@ -455,7 +455,7 @@ ORDER BY avg_io_stall_ms DESC OPTION (RECOMPILE); -- Recovery model, log reuse wait description, log file size, log usage size (Query 21) (Database Properties) -- and compatibility level for all databases on instance -SELECT db.[name] AS [Database Name], db.recovery_model_desc AS [Recovery Model], +SELECT db.[name] AS [Database Name], SUSER_SNAME(db.owner_sid) AS [Database Owner], db.recovery_model_desc AS [Recovery Model], db.log_reuse_wait_desc AS [Log Reuse Wait Description], ls.cntr_value AS [Log Size (KB)], lu.cntr_value AS [Log Used (KB)], CAST(CAST(lu.cntr_value AS FLOAT) / CAST(ls.cntr_value AS FLOAT)AS DECIMAL(18,2)) * 100 AS [Log Used %], @@ -475,6 +475,15 @@ AND ls.cntr_value > 0 ORDER BY db.[name] OPTION (RECOMPILE); ------ +-- sys.databases (Transact-SQL) +-- https://bit.ly/2G5wqaX + +-- sys.dm_os_performance_counters (Transact-SQL) +-- https://bit.ly/3kEO2JR + +-- sys.dm_database_encryption_keys (Transact-SQL) +-- https://bit.ly/3mE7kkx + -- Things to look at: -- How many databases are on the instance? -- What recovery models are they using? @@ -560,6 +569,7 @@ ORDER BY [CPU Rank] OPTION (RECOMPILE); ------ -- Helps determine which database is using the most CPU resources on the instance +-- Note: This only reflects CPU usage from the currently cached query plans -- Get I/O utilization by database (Query 25) (IO Usage By Database) @@ -644,27 +654,27 @@ SELECT FROM Waits AS W1 INNER JOIN Waits AS W2 ON W2.RowNum <= W1.RowNum -GROUP BY W1.RowNum +GROUP BY W1.RowNum, W1.wait_type HAVING SUM (W2.Percentage) - MAX (W1.Percentage) < 99 -- percentage threshold OPTION (RECOMPILE); ------ -- Cumulative wait stats are not as useful on an idle instance that is not under load or performance pressure --- SQL Server Wait Types Library (Paul Randal) --- https://www.sqlskills.com/help/waits/ +-- SQL Server Wait Types Library +-- https://bit.ly/2ePzYO2 -- The SQL Server Wait Type Repository --- http://blogs.msdn.com/b/psssql/archive/2009/11/03/the-sql-server-wait-type-repository.aspx +-- https://bit.ly/1afzfjC -- Wait statistics, or please tell me where it hurts --- https://www.sqlskills.com/blogs/paul/wait-statistics-or-please-tell-me-where-it-hurts/ +-- https://bit.ly/2wsQHQE -- SQL Server 2005 Performance Tuning using the Waits and Queues --- http://technet.microsoft.com/en-us/library/cc966413.aspx +-- https://bit.ly/1o2NFoF -- sys.dm_os_wait_stats (Transact-SQL) --- http://msdn.microsoft.com/en-us/library/ms179984(v=sql.105).aspx +-- https://bit.ly/2Hjq9Yl @@ -741,7 +751,7 @@ WHERE scheduler_id < 255 OPTION (RECOMPILE); -- High Avg Pending DiskIO Counts are a sign of disk pressure -- How to Do Some Very Basic SQL Server Monitoring --- https://www.sqlskills.com/blogs/glenn/how-to-do-some-very-basic-sql-server-monitoring/ +-- https://bit.ly/30IRla0 @@ -796,7 +806,8 @@ ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); -- Good basic information about OS memory amounts and state (Query 34) (System Memory) SELECT total_physical_memory_kb/1024 AS [Physical Memory (MB)], available_physical_memory_kb/1024 AS [Available Memory (MB)], - total_page_file_kb/1024 AS [Total Page File (MB)], + total_page_file_kb/1024 AS [Page File Commit Limit (MB)], + total_page_file_kb/1024 - total_physical_memory_kb/1024 AS [Physical Page File Size (MB)], available_page_file_kb/1024 AS [Available Page File (MB)], system_cache_kb/1024 AS [System Cache (MB)], system_memory_state_desc AS [System Memory State] @@ -865,13 +876,15 @@ ORDER BY SUM(single_pages_kb) DESC OPTION (RECOMPILE); -- Find single-use, ad-hoc and prepared queries that are bloating the plan cache (Query 39) (Ad hoc Queries) -SELECT TOP(50) [text] AS [QueryText], cp.cacheobjtype, cp.objtype, cp.size_in_bytes/1024 AS [Plan Size in KB] +SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], t.[text] AS [Query Text], +cp.objtype AS [Object Type], cp.cacheobjtype AS [Cache Object Type], +cp.size_in_bytes/1024 AS [Plan Size in KB] FROM sys.dm_exec_cached_plans AS cp WITH (NOLOCK) -CROSS APPLY sys.dm_exec_sql_text(plan_handle) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t WHERE cp.cacheobjtype = N'Compiled Plan' AND cp.objtype IN (N'Adhoc', N'Prepared') AND cp.usecounts = 1 -ORDER BY cp.size_in_bytes DESC OPTION (RECOMPILE); +ORDER BY cp.size_in_bytes DESC, DB_NAME(t.[dbid]) OPTION (RECOMPILE); ------ -- Gives you the text, type and size of single-use ad-hoc and prepared queries that waste space in the plan cache @@ -1090,8 +1103,9 @@ ON s.[object_id] = i.[object_id] AND i.index_id = s.index_id WHERE OBJECTPROPERTY(s.[object_id],'IsUserTable') = 1 AND s.database_id = DB_ID() -AND user_updates > (user_seeks + user_scans + user_lookups) -AND i.index_id > 1 +AND s.user_updates > (s.user_seeks + s.user_scans + s.user_lookups) +AND i.index_id > 1 AND i.[type_desc] = N'NONCLUSTERED' +AND i.is_primary_key = 0 AND i.is_unique_constraint = 0 ORDER BY [Difference] DESC, [Total Writes] DESC, [Total Reads] ASC OPTION (RECOMPILE); ------ @@ -1140,21 +1154,29 @@ ORDER BY cp.usecounts DESC OPTION (RECOMPILE); -- Breaks down buffers used by current database by object (table, index) in the buffer cache (Query 54) (Buffer Usage) -- Note: This query could take some time on a busy instance -SELECT OBJECT_NAME(p.[object_id]) AS [Object Name], p.index_id, +SELECT fg.name AS [Filegroup Name], SCHEMA_NAME(o.Schema_ID) AS [Schema Name], +OBJECT_NAME(p.[object_id]) AS [Object Name], p.index_id, CAST(COUNT(*)/128.0 AS DECIMAL(10, 2)) AS [Buffer size(MB)], -COUNT(*) AS [BufferCount], p.Rows AS [Row Count], +COUNT(*) AS [BufferCount], p.[Rows] AS [Row Count], p.data_compression_desc AS [Compression Type] FROM sys.allocation_units AS a WITH (NOLOCK) INNER JOIN sys.dm_os_buffer_descriptors AS b WITH (NOLOCK) ON a.allocation_unit_id = b.allocation_unit_id INNER JOIN sys.partitions AS p WITH (NOLOCK) ON a.container_id = p.hobt_id -WHERE b.database_id = CONVERT(int,DB_ID()) +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON p.object_id = o.object_id +INNER JOIN sys.database_files AS f WITH (NOLOCK) +ON b.file_id = f.file_id +INNER JOIN sys.filegroups AS fg WITH (NOLOCK) +ON f.data_space_id = fg.data_space_id +WHERE b.database_id = CONVERT(int, DB_ID()) AND p.[object_id] > 100 AND OBJECT_NAME(p.[object_id]) NOT LIKE N'plan_%' AND OBJECT_NAME(p.[object_id]) NOT LIKE N'sys%' AND OBJECT_NAME(p.[object_id]) NOT LIKE N'xml_index_nodes%' -GROUP BY p.[object_id], p.index_id, p.data_compression_desc, p.[Rows] +GROUP BY fg.name, o.Schema_ID, p.[object_id], p.index_id, + p.data_compression_desc, p.[Rows] ORDER BY [BufferCount] DESC OPTION (RECOMPILE); ------ @@ -1163,18 +1185,24 @@ ORDER BY [BufferCount] DESC OPTION (RECOMPILE); -- Get Table names, row counts, and compression status for clustered index or heap (Query 55) (Table Sizes) -SELECT OBJECT_NAME(object_id) AS [ObjectName], -SUM(Rows) AS [RowCount], data_compression_desc AS [CompressionType] -FROM sys.partitions WITH (NOLOCK) +SELECT SCHEMA_NAME(o.Schema_ID) AS [Schema Name], OBJECT_NAME(p.object_id) AS [ObjectName], +SUM(p.Rows) AS [RowCount], data_compression_desc AS [CompressionType] +FROM sys.partitions AS p WITH (NOLOCK) +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON p.object_id = o.object_id WHERE index_id < 2 --ignore the partitions from the non-clustered index if any -AND OBJECT_NAME(object_id) NOT LIKE N'sys%' -AND OBJECT_NAME(object_id) NOT LIKE N'queue_%' -AND OBJECT_NAME(object_id) NOT LIKE N'filestream_tombstone%' -AND OBJECT_NAME(object_id) NOT LIKE N'fulltext%' -AND OBJECT_NAME(object_id) NOT LIKE N'ifts_comp_fragment%' -AND OBJECT_NAME(object_id) NOT LIKE N'xml_index_nodes%' -GROUP BY object_id, data_compression_desc -ORDER BY SUM(Rows) DESC OPTION (RECOMPILE); +AND OBJECT_NAME(p.object_id) NOT LIKE N'sys%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'spt_%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'queue_%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'filestream_tombstone%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'fulltext%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'ifts_comp_fragment%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'filetable_updates%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'xml_index_nodes%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'sqlagent_job%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'plan_persist%' +GROUP BY SCHEMA_NAME(o.Schema_ID), p.object_id, data_compression_desc +ORDER BY SUM(p.Rows) DESC OPTION (RECOMPILE); ------ -- Gives you an idea of table sizes, and possible data compression opportunities @@ -1279,17 +1307,22 @@ ORDER BY ps.avg_fragmentation_in_percent DESC OPTION (RECOMPILE); --- Index Read/Write stats (all tables in current DB) ordered by Reads (Query 61) (Overall Index Usage - Reads) -SELECT OBJECT_NAME(s.[object_id]) AS [ObjectName], i.name AS [IndexName], i.index_id, - user_seeks + user_scans + user_lookups AS [Reads], s.user_updates AS [Writes], - i.type_desc AS [IndexType], i.fill_factor AS [FillFactor], i.has_filter, i.filter_definition, +SELECT SCHEMA_NAME(t.[schema_id]) AS [SchemaName], OBJECT_NAME(i.[object_id]) AS [ObjectName], + i.[name] AS [IndexName], i.index_id, + s.user_seeks, s.user_scans, s.user_lookups, + s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], + s.user_updates AS [Writes], + i.[type_desc] AS [Index Type], i.fill_factor AS [Fill Factor], i.has_filter, i.filter_definition, s.last_user_scan, s.last_user_lookup, s.last_user_seek -FROM sys.dm_db_index_usage_stats AS s WITH (NOLOCK) -INNER JOIN sys.indexes AS i WITH (NOLOCK) -ON s.[object_id] = i.[object_id] -WHERE OBJECTPROPERTY(s.[object_id],'IsUserTable') = 1 +FROM sys.indexes AS i WITH (NOLOCK) +LEFT OUTER JOIN sys.dm_db_index_usage_stats AS s WITH (NOLOCK) +ON i.[object_id] = s.[object_id] AND i.index_id = s.index_id AND s.database_id = DB_ID() -ORDER BY user_seeks + user_scans + user_lookups DESC OPTION (RECOMPILE); -- Order by reads +LEFT OUTER JOIN sys.tables AS t WITH (NOLOCK) +ON t.[object_id] = i.[object_id] +WHERE OBJECTPROPERTY(i.[object_id],'IsUserTable') = 1 +ORDER BY s.user_seeks + s.user_scans + s.user_lookups DESC OPTION (RECOMPILE); -- Order by reads ------ @@ -1297,16 +1330,19 @@ ORDER BY user_seeks + user_scans + user_lookups DESC OPTION (RECOMPILE); -- Orde --- Index Read/Write stats (all tables in current DB) ordered by Writes (Query 62) (Overall Index Usage - Writes) -SELECT OBJECT_NAME(s.[object_id]) AS [ObjectName], i.name AS [IndexName], i.index_id, - s.user_updates AS [Writes], user_seeks + user_scans + user_lookups AS [Reads], - i.type_desc AS [IndexType], i.fill_factor AS [FillFactor], i.has_filter, i.filter_definition, +SELECT SCHEMA_NAME(t.[schema_id]) AS [SchemaName],OBJECT_NAME(i.[object_id]) AS [ObjectName], + i.[name] AS [IndexName], i.index_id, + s.user_updates AS [Writes], s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], + i.[type_desc] AS [Index Type], i.fill_factor AS [Fill Factor], i.has_filter, i.filter_definition, s.last_system_update, s.last_user_update -FROM sys.dm_db_index_usage_stats AS s WITH (NOLOCK) -INNER JOIN sys.indexes AS i WITH (NOLOCK) -ON s.[object_id] = i.[object_id] -WHERE OBJECTPROPERTY(s.[object_id],'IsUserTable') = 1 +FROM sys.indexes AS i WITH (NOLOCK) +LEFT OUTER JOIN sys.dm_db_index_usage_stats AS s WITH (NOLOCK) +ON i.[object_id] = s.[object_id] AND i.index_id = s.index_id AND s.database_id = DB_ID() +LEFT OUTER JOIN sys.tables AS t WITH (NOLOCK) +ON t.[object_id] = i.[object_id] +WHERE OBJECTPROPERTY(i.[object_id],'IsUserTable') = 1 ORDER BY s.user_updates DESC OPTION (RECOMPILE); -- Order by writes ------ @@ -1354,35 +1390,14 @@ ORDER BY bs.backup_finish_date DESC OPTION (RECOMPILE); ------ -- Are your backup sizes and times changing over time? --- Are you using backup compression? -- Are you using backup checksums? -- Are you doing copy_only backups? -- Have you done any backup tuning with striped backups, or changing the parameters of the backup command? --- These three Pluralsight Courses go into more detail about how to run these queries and interpret the results - --- SQL Server 2014 DMV Diagnostic Queries Part 1 --- https://www.pluralsight.com/courses/sql-server-2014-dmv-diagnostic-queries-part1 - --- SQL Server 2014 DMV Diagnostic Queries Part 2 --- https://www.pluralsight.com/courses/sql-server-2014-dmv-diagnostic-queries-part2 - --- SQL Server 2014 DMV Diagnostic Queries Part 3 --- https://www.pluralsight.com/courses/sql-server-2014-dmv-diagnostic-queries-part3 - - --- Sign up for Microsoft Visual Studio Dev Essentials and get a free three month pass to Pluralsight - -- Microsoft Visual Studio Dev Essentials --- http://bit.ly/1q6xbDL - - --- Sign up for Microsoft IT Pro Cloud Essentials and get lots of free Azure usage credits, MCP exam voucher, three month Pluralsight subscription - --- Microsoft IT Pro Cloud Essentials --- http://bit.ly/2443SAd +-- https://bit.ly/2qjNRxi +-- Microsoft Azure Learn +-- https://bit.ly/2O0Hacc --- August 2017 blog series about upgrading and migrating SQL Server --- https://www.sqlskills.com/blogs/glenn/category/upgrading-sql-server/ diff --git a/Scripts/SQL Server 2012 Diagnostic Information Queries.sql b/Scripts/SQL Server 2012 Diagnostic Information Queries.sql index 4a146685..a54e603a 100644 --- a/Scripts/SQL Server 2012 Diagnostic Information Queries.sql +++ b/Scripts/SQL Server 2012 Diagnostic Information Queries.sql @@ -1,26 +1,30 @@ -- SQL Server 2012 Diagnostic Information Queries -- Glenn Berry --- Last Modified: December 5, 2017 --- https://www.sqlskills.com/blogs/glenn/ --- http://sqlserverperformance.wordpress.com/ +-- Last Modified: December 3, 2020 +-- https://glennsqlperformance.com/ +-- https://sqlserverperformance.wordpress.com/ +-- YouTube: https://bit.ly/2PkoAM1 -- Twitter: GlennAlanBerry --- Please listen to my Pluralsight courses --- https://www.pluralsight.com/author/glenn-berry - --- If you want to find all of our SQLskills SQL101 blog posts, check out https://www.sqlskills.com/help/sql101/ +-- Diagnostic Queries are available here +-- https://glennsqlperformance.com/resources/ -- Please make sure you are using the correct version of these diagnostic queries for your version of SQL Server --- Many of these queries will not work if you have databases in 80 compatibility mode + + +-- If you like PowerShell, there is a very useful community solution for running these queries in an automated fashion +-- https://dbatools.io/ + +-- Invoke-DbaDiagnosticQuery +-- https://dbatools.io/functions/invoke-dbadiagnosticquery/ + --****************************************************************************** ---* Copyright (C) 2017 Glenn Berry, SQLskills.com +--* Copyright (C) 2020 Glenn Berry --* All rights reserved. --* ---* For more scripts and sample code, check out ---* https://www.sqlskills.com/blogs/glenn --* --* You may alter this code for your own *non-commercial* purposes. You may --* republish altered code as long as you include this copyright and give due credit. @@ -86,55 +90,62 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In -- 11.0.6594 SP3 CU8 3/20/2017 -- 11.0.6598 SP3 CU9 5/15/2017 -- 11.0.6607 SP3 CU10 8/8/2017 --- 11.0.7001 SP4 RTM 10/3/2017 +-- 11.0.7001 SP4 RTM 10/3/2017 +-- +-- +-- Security Update for SQL Server 2012 SP4 (KB4532098) +-- https://support.microsoft.com/en-us/help/4532098/security-update-for-sql-server-2012-sp4-gdr +-- Security Update for SQL Server 2012 SP4 (KB4057116) +-- https://bit.ly/2F33Sc4 +-- 11.0.7462 Security Update 1/12/2018 (Security Update for SQL Server 2012 SP4 (KB4057116)) +-- 11.0.7493.4 Security Update 2/11/2020 (Security Update for SQL Server 2012 SP4 (KB4532098)) -- SQL Server 2012 Service Pack 4 (SP4) Released! --- https://blogs.msdn.microsoft.com/sqlreleaseservices/sql-server-2012-service-pack-4-sp4-released/ +-- https://bit.ly/2qN8kr3 -- How to determine the version, edition and update level of SQL Server and its components --- https://support.microsoft.com/en-us/kb/321185 +-- https://bit.ly/2oAjKgW -- SQL Server 2012 SP3 build versions --- https://support.microsoft.com/en-us/kb/3133750 +-- https://bit.ly/2HFjAzA -- SQL Server 2012 SP2 build versions --- https://support.microsoft.com/kb/2983249 +-- https://bit.ly/2qLqqcS -- The SQL Server 2012 builds that were released after SQL Server 2012 Service Pack 1 was released --- https://support.microsoft.com/kb/2772858 +-- https://bit.ly/2HG21za -- The SQL Server 2012 builds that were released after SQL Server 2012 was released --- https://support.microsoft.com/kb/2692828 +-- https://bit.ly/2K1xZnX -- Where to find information about the latest SQL Server builds --- https://support.microsoft.com/en-us/help/957826/where-to-find-information-about-the-latest-sql-server-builds +-- https://bit.ly/2IGHbfY -- Recommended updates and configuration options for SQL Server 2012 and SQL Server 2014 used with high-performance workloads --- https://support.microsoft.com/kb/2964518/EN-US +-- https://bit.ly/2Hy3zIZ -- Performance and Stability Related Fixes in Post-SQL Server 2012 SP3 Builds --- https://www.sqlskills.com/blogs/glenn/performance-and-stability-related-fixes-in-post-sql-server-2012-sp3-builds/ +-- https://bit.ly/2woDJ4Z -- Performance and Stability Related Fixes in Post-SQL Server 2012 SP2 Builds --- https://www.sqlskills.com/blogs/glenn/performance-and-stability-related-fixes-in-post-sql-server-2012-sp2-builds/ +-- https://bit.ly/2vuKZzp -- Performance and Stability Related Fixes in Post-SQL Server 2012 SP1 Builds --- https://www.sqlskills.com/blogs/glenn/performance-and-stability-related-fixes-in-post-sql-server-2012-sp1-builds-2/ +-- https://bit.ly/2vBt1LC -- Performance Related Fixes in Post-SQL Server 2012 RTM Builds --- https://www.sqlskills.com/blogs/glenn/performance-related-fixes-in-post-sql-server-2012-rtm-builds/ - --- Announcing updates to the SQL Server Incremental Servicing Model (ISM) --- https://blogs.msdn.microsoft.com/sqlreleaseservices/announcing-updates-to-the-sql-server-incremental-servicing-model-ism/ +-- https://bit.ly/2vuIQn4 -- Update Center for Microsoft SQL Server --- http://bit.ly/2pZptuQ +-- https://bit.ly/2pZptuQ -- Download SQL Server Management Studio (SSMS) --- https://msdn.microsoft.com/en-us/library/mt238290.aspx +-- https://bit.ly/1OcupT9 + +-- Download and install Azure Data Studio +-- https://bit.ly/2vgke1A --- Download and install Microsoft SQL Operations Studio --- https://docs.microsoft.com/en-us/sql/sql-operations-studio/download +-- SQL Server 2012 Configuration Manager is SQLServerManager11.msc -- Get socket, physical core and logical core count from the SQL Server Error log. (Query 2) (Core Counts) @@ -142,13 +153,12 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In EXEC sys.xp_readerrorlog 0, 1, N'detected', N'socket'; ------ --- New in SQL Server 2012 SP4 -- This can help you determine the exact core counts used by SQL Server and whether HT is enabled or not -- It can also help you confirm your SQL Server licensing model -- Be on the lookout for this message "using 40 logical processors based on SQL Server licensing" -- (when you have more than 40 logical cores) which means grandfathered Server/CAL licensing -- This query will return no results if your error log has been recycled since the instance was last started - +-- New in SQL Server 2012 SP4 -- Get selected server properties (Query 3) (Server Properties) @@ -175,6 +185,7 @@ SERVERPROPERTY('IsHadrEnabled') AS [IsHadrEnabled], SERVERPROPERTY('HadrManagerStatus') AS [HadrManagerStatus], SERVERPROPERTY('InstanceDefaultDataPath') AS [InstanceDefaultDataPath], SERVERPROPERTY('InstanceDefaultLogPath') AS [InstanceDefaultLogPath], +SERVERPROPERTY('ErrorLogFileName') AS [ErrorLogFileName], SERVERPROPERTY('BuildClrVersion') AS [Build CLR Version]; ------ @@ -183,7 +194,7 @@ SERVERPROPERTY('BuildClrVersion') AS [Build CLR Version]; -- Note: Some columns will be NULL on older SQL Server builds -- SERVERPROPERTY (Transact-SQL) --- http://bit.ly/2eeaXeI +-- https://bit.ly/2eeaXeI -- Get instance-level configuration values for instance (Query 4) (Configuration Values) @@ -213,44 +224,57 @@ DBCC TRACESTATUS (-1); -- Common trace flags that should be enabled in most cases -- TF 1117 - When growing a data file, grow all files at the same time so they remain the same size, reducing allocation contention points --- https://support2.microsoft.com/kb/2154845 +-- https://bit.ly/2GY1kOl -- -- TF 1118 - Helps alleviate allocation contention in tempdb, SQL Server allocates full extents to each database object, -- thereby eliminating the contention on SGAM pages (more important with older versions of SQL Server) -- Recommendations to reduce allocation contention in SQL Server tempdb database --- https://support2.microsoft.com/kb/2154845 +-- https://bit.ly/2GY1kOl -- TF 2371 - Lowers auto update statistics threshold for large tables (on tables with more than 25,000 rows) --- https://blogs.msdn.com/b/saponsqlserver/archive/2011/09/07/changes-to-automatic-update-statistics-in-sql-server-traceflag-2371.aspx +-- https://bit.ly/30KO4Hh -- TF 3023 - Enables backup checksum default --- https://support.microsoft.com/en-us/help/2656988/how-to-enable-the-checksum-option-if-backup-utilities-do-not-expose-th +-- https://bit.ly/2vtjqqc -- TF 3226 - Supresses logging of successful database backup messages to the SQL Server Error Log --- https://www.sqlskills.com/blogs/paul/fed-up-with-backup-success-messages-bloating-your-error-logs/ +-- https://bit.ly/38zDNAK -- TF 3449 - Enables use of dirty page manager (SQL Server 2012 SP3 CU3 and later) --- https://blogs.msdn.microsoft.com/psssql/2017/06/29/sql-server-large-ram-and-db-checkpointing/ +-- https://bit.ly/2uj0h5M -- TF 6533 - Spatial performance improvements in SQL Server 2012 and 2014 --- https://support.microsoft.com/en-us/kb/3107399 +-- https://bit.ly/2v7C7ze -- TF 6534 - Enables use of native code to improve performance with spatial data --- https://blogs.msdn.microsoft.com/bobsql/2016/06/03/sql-2016-it-just-runs-faster-native-spatial-implementations/ +-- https://bit.ly/2HrQUpU -- TF 8079 - Enables automatic soft-NUMA on systems with eight or more physical cores per NUMA node (with SQL Server 2012 SP4) --- https://blogs.msdn.microsoft.com/sqlreleaseservices/sql-server-2012-service-pack-4-sp4-released/ +-- https://bit.ly/2qN8kr3 + +-- DBCC TRACEON - Trace Flags (Transact-SQL) +-- https://bit.ly/2FuSvPg + + +-- Returns status of instant file initialization (Query 6) (IFI Status) +EXEC sys.xp_readerrorlog 0, 1, N'Database Instant File Initialization'; +------ ---- DBCC TRACEON - Trace Flags (Transact-SQL) --- https://docs.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-traceon-trace-flags-transact-sql +-- Lets you determine whether Instant File Initialization (IFI) is enabled for the instance +-- This should be enabled in the vast majority of cases +-- Note: This query won't return any results if the SQL Server error log has been recycled +-- (Added in SQL Server 2012 SP4) +-- Database Instant File Initialization +-- https://bit.ly/2nTX74y --- SQL Server Process Address space info (Query 6) (Process Memory) +-- SQL Server Process Address space info (Query 7) (Process Memory) -- (shows whether locked pages is enabled, among other things) SELECT physical_memory_in_use_kb/1024 AS [SQL Server Memory Usage (MB)], - large_page_allocations_kb, locked_page_allocations_kb, page_fault_count, - memory_utilization_percentage, available_commit_limit_kb, + locked_page_allocations_kb/1024 AS [SQL Server Locked Pages Allocation (MB)], + large_page_allocations_kb/1024 AS [SQL Server Large Pages Allocation (MB)], + page_fault_count, memory_utilization_percentage, available_commit_limit_kb, process_physical_memory_low, process_virtual_memory_low FROM sys.dm_os_process_memory WITH (NOLOCK) OPTION (RECOMPILE); ------ @@ -261,11 +285,14 @@ FROM sys.dm_os_process_memory WITH (NOLOCK) OPTION (RECOMPILE); -- If locked_page_allocations_kb > 0, then LPIM is enabled -- How to enable the "locked pages" feature in SQL Server 2012 --- https://support.microsoft.com/en-us/kb/2659143 +-- https://bit.ly/2F5UjOA +-- Memory Management Architecture Guide +-- https://bit.ly/2JKkadC --- SQL Server Services information (Query 7) (SQL Server Services Info) + +-- SQL Server Services information (Query 8) (SQL Server Services Info) SELECT servicename, process_id, startup_type_desc, status_desc, last_startup_time, service_account, is_clustered, cluster_nodename, [filename] FROM sys.dm_server_services WITH (NOLOCK) OPTION (RECOMPILE); @@ -275,26 +302,34 @@ FROM sys.dm_server_services WITH (NOLOCK) OPTION (RECOMPILE); -- Shows the process_id, when they were last started, and their current status -- Also shows whether you are running on a failover cluster instance, and what node you are running on +-- sys.dm_server_services (Transact-SQL) +-- https://bit.ly/2oKa1Un --- Last backup information by database (Query 8) (Last Backup By Database) +-- Last backup information by database (Query 9) (Last Backup By Database) SELECT ISNULL(d.[name], bs.[database_name]) AS [Database], d.recovery_model_desc AS [Recovery Model], d.log_reuse_wait_desc AS [Log Reuse Wait Desc], MAX(CASE WHEN [type] = 'D' THEN bs.backup_finish_date ELSE NULL END) AS [Last Full Backup], + MAX(CASE WHEN [type] = 'D' THEN bmf.physical_device_name ELSE NULL END) AS [Last Full Backup Location], MAX(CASE WHEN [type] = 'I' THEN bs.backup_finish_date ELSE NULL END) AS [Last Differential Backup], - MAX(CASE WHEN [type] = 'L' THEN bs.backup_finish_date ELSE NULL END) AS [Last Log Backup] + MAX(CASE WHEN [type] = 'I' THEN bmf.physical_device_name ELSE NULL END) AS [Last Differential Backup Location], + MAX(CASE WHEN [type] = 'L' THEN bs.backup_finish_date ELSE NULL END) AS [Last Log Backup], + MAX(CASE WHEN [type] = 'L' THEN bmf.physical_device_name ELSE NULL END) AS [Last Log Backup Location] FROM sys.databases AS d WITH (NOLOCK) LEFT OUTER JOIN msdb.dbo.backupset AS bs WITH (NOLOCK) -ON bs.[database_name] = d.[name] +ON bs.[database_name] = d.[name] +LEFT OUTER JOIN msdb.dbo.backupmediafamily AS bmf WITH (NOLOCK) +ON bs.media_set_id = bmf.media_set_id AND bs.backup_finish_date > GETDATE()- 30 -GROUP BY ISNULL(d.[name], bs.[database_name]), d.recovery_model_desc, d.log_reuse_wait_desc -ORDER BY d.recovery_model_desc OPTION (RECOMPILE); +WHERE d.name <> N'tempdb' +GROUP BY ISNULL(d.[name], bs.[database_name]), d.recovery_model_desc, d.log_reuse_wait_desc, d.[name] +ORDER BY d.recovery_model_desc, d.[name] OPTION (RECOMPILE); ------ -- This helps you spot runaway transaction logs and other issues with your backup schedule --- Get SQL Server Agent jobs and Category information (Query 9) (SQL Server Agent Jobs) +-- Get SQL Server Agent jobs and Category information (Query 10) (SQL Server Agent Jobs) SELECT sj.name AS [Job Name], sj.[description] AS [Job Description], SUSER_SNAME(sj.owner_sid) AS [Job Owner], sj.date_created AS [Date Created], sj.[enabled] AS [Job Enabled], sj.notify_email_operator_id, sj.notify_level_email, sc.name AS [CategoryName], @@ -315,32 +350,37 @@ ORDER BY sj.name OPTION (RECOMPILE); -- Look for jobs that have a notify_level_email set to 0 (meaning no e-mail is ever sent) -- -- MSDN sysjobs documentation --- https://msdn.microsoft.com/en-us/library/ms189817.aspx +-- https://bit.ly/2paDEOP -- SQL Server Maintenance Solution --- https://ola.hallengren.com/ +-- https://bit.ly/1pgchQu + +-- You can use this script to add default schedules to the standard Ola Hallengren Maintenance Solution jobs +-- https://bit.ly/3ane0gN --- Get SQL Server Agent Alert Information (Query 10) (SQL Server Agent Alerts) +-- Get SQL Server Agent Alert Information (Query 11) (SQL Server Agent Alerts) SELECT name, event_source, message_id, severity, [enabled], has_notification, delay_between_responses, occurrence_count, last_occurrence_date, last_occurrence_time FROM msdb.dbo.sysalerts WITH (NOLOCK) ORDER BY name OPTION (RECOMPILE); ------ --- Gives you some basic information about your SQL Server Agent Alerts (which are different from SQL Server Agent jobs) --- Read more about Agent Alerts here: https://www.sqlskills.com/blogs/glenn/creating-sql-server-agent-alerts-for-critical-errors/ +-- Gives you some basic information about your SQL Server Agent Alerts +-- (which are different from SQL Server Agent jobs) +-- Read more about Agent Alerts here: https://bit.ly/2v5YR37 --- Windows information (Query 11) (Windows Info) +-- Windows information (Query 12) (Windows Info) SELECT windows_release, windows_service_pack_level, windows_sku, os_language_version FROM sys.dm_os_windows_info WITH (NOLOCK) OPTION (RECOMPILE); ------ -- Gives you major OS version, Service Pack, Edition, and language info for the operating system --- 6.3 is either Windows 8.1, Windows 10 or Windows Server 2012 R2, Windows Server 2016 +-- 10.0 is either Windows 10 or Windows Server 2016 +-- 6.3 is either Windows 8.1, or Windows Server 2012 R2 -- 6.2 is either Windows 8 or Windows Server 2012 -- 6.1 is either Windows 7 or Windows Server 2008 R2 -- 6.0 is either Windows Vista or Windows Server 2008 @@ -351,20 +391,21 @@ FROM sys.dm_os_windows_info WITH (NOLOCK) OPTION (RECOMPILE); -- 8 is Datacenter Server Edition -- 10 is Enterprise Server Edition -- 48 is Professional Edition +-- 161 is Pro for Workstations -- 1033 for os_language_version is US-English -- SQL Server 2012 requires Windows Server 2008 SP2 or newer -- Hardware and Software Requirements for Installing SQL Server 2012 --- https://msdn.microsoft.com/en-us/library/ms143506.aspx +-- https://bit.ly/1yRYXkQ -- Using SQL Server in Windows 8 and later versions of Windows operating system --- https://support.microsoft.com/en-us/kb/2681562 +-- https://bit.ly/2F7Ax0P --- SQL Server NUMA Node information (Query 12) (SQL Server NUMA Info) +-- SQL Server NUMA Node information (Query 13) (SQL Server NUMA Info) SELECT node_id, node_state_desc, memory_node_id, processor_group, online_scheduler_count, idle_scheduler_count, active_worker_count, avg_load_balance, resource_monitor_state FROM sys.dm_os_nodes WITH (NOLOCK) @@ -373,18 +414,22 @@ WHERE node_state_desc <> N'ONLINE DAC' OPTION (RECOMPILE); -- Gives you some useful information about the composition and relative load on your NUMA nodes -- You want to see an equal number of schedulers on each NUMA node --- Watch out if SQL Server 2012 Standard Edition has been installed on a machine with more than 16 physical cores --- Watch out if you have a VM with more than 4 NUMA nodes with SQL Server Standard Edition, since there is a four-socket license limit +-- Watch out if SQL Server 2012 Standard Edition has been installed +-- on a physical or virtual machine with more than four sockets or more than 16 physical cores + +-- sys.dm_os_nodes (Transact-SQL) +-- https://bit.ly/2pn5Mw8 --- Balancing Your Available SQL Server Core Licenses Evenly Across NUMA Nodes --- https://www.sqlskills.com/blogs/glenn/balancing-your-available-sql-server-core-licenses-evenly-across-numa-nodes/ +-- How to Balance SQL Server Core Licenses Across NUMA Nodes +-- https://bit.ly/3i4TyVR --- Good basic information about OS memory amounts and state (Query 13) (System Memory) +-- Good basic information about OS memory amounts and state (Query 14) (System Memory) SELECT total_physical_memory_kb/1024 AS [Physical Memory (MB)], available_physical_memory_kb/1024 AS [Available Memory (MB)], - total_page_file_kb/1024 AS [Total Page File (MB)], + total_page_file_kb/1024 AS [Page File Commit Limit (MB)], + total_page_file_kb/1024 - total_physical_memory_kb/1024 AS [Physical Page File Size (MB)], available_page_file_kb/1024 AS [Available Page File (MB)], system_cache_kb/1024 AS [System Cache (MB)], system_memory_state_desc AS [System Memory State] @@ -398,13 +443,18 @@ FROM sys.dm_os_sys_memory WITH (NOLOCK) OPTION (RECOMPILE); -- Available physical memory is high -- Physical memory usage is steady -- Available physical memory is low +-- Available physical memory is running low -- Physical memory state is transitioning +-- sys.dm_os_sys_memory (Transact-SQL) +-- https://bit.ly/2pcV0xq + + -- You can skip the next two queries if you know you don't have a clustered instance --- Get information about your cluster nodes and their status (Query 14) (Cluster Node Properties) +-- Get information about your cluster nodes and their status (Query 15) (Cluster Node Properties) -- (if your database server is in a failover cluster) SELECT NodeName, status_description, is_current_owner FROM sys.dm_os_cluster_nodes WITH (NOLOCK) OPTION (RECOMPILE); @@ -415,10 +465,10 @@ FROM sys.dm_os_cluster_nodes WITH (NOLOCK) OPTION (RECOMPILE); -- You will see no results if your instance is not clustered -- Recommended hotfixes and updates for Windows Server 2012 R2-based failover clusters --- http://support.microsoft.com/kb/2920151 +-- https://bit.ly/1z5BfCw --- Get information about any AlwaysOn AG cluster this instance is a part of (Query 15) (AlwaysOn AG Cluster) +-- Get information about any AlwaysOn AG cluster this instance is a part of (Query 16) (AlwaysOn AG Cluster) SELECT cluster_name, quorum_type_desc, quorum_state_desc FROM sys.dm_hadr_cluster WITH (NOLOCK) OPTION (RECOMPILE); ------ @@ -426,14 +476,40 @@ FROM sys.dm_hadr_cluster WITH (NOLOCK) OPTION (RECOMPILE); -- You will see no results if your instance is not using AlwaysOn AGs +-- Good overview of AG health and status (Query 17) (AG Status) +SELECT ag.name AS [AG Name], ar.replica_server_name, ar.availability_mode_desc, adc.[database_name], + drs.is_local, drs.is_primary_replica, drs.synchronization_state_desc, drs.is_commit_participant, + drs.synchronization_health_desc, drs.recovery_lsn, drs.truncation_lsn, drs.last_sent_lsn, + drs.last_sent_time, drs.last_received_lsn, drs.last_received_time, drs.last_hardened_lsn, + drs.last_hardened_time, drs.last_redone_lsn, drs.last_redone_time, drs.log_send_queue_size, + drs.log_send_rate, drs.redo_queue_size, drs.redo_rate, drs.filestream_send_rate, + drs.end_of_log_lsn, drs.last_commit_lsn, drs.last_commit_time, drs.database_state_desc +FROM sys.dm_hadr_database_replica_states AS drs WITH (NOLOCK) +INNER JOIN sys.availability_databases_cluster AS adc WITH (NOLOCK) +ON drs.group_id = adc.group_id +AND drs.group_database_id = adc.group_database_id +INNER JOIN sys.availability_groups AS ag WITH (NOLOCK) +ON ag.group_id = drs.group_id +INNER JOIN sys.availability_replicas AS ar WITH (NOLOCK) +ON drs.group_id = ar.group_id +AND drs.replica_id = ar.replica_id +ORDER BY ag.name, ar.replica_server_name, adc.[database_name] OPTION (RECOMPILE); --- Hardware information from SQL Server 2012 (Query 16) (Hardware Info) -SELECT cpu_count AS [Logical CPU Count], scheduler_count, hyperthread_ratio AS [Hyperthread Ratio], -cpu_count/hyperthread_ratio AS [Physical CPU Count], -physical_memory_kb/1024 AS [Physical Memory (MB)], committed_kb/1024 AS [Committed Memory (MB)], -committed_target_kb/1024 AS [Committed Target Memory (MB)], -max_workers_count AS [Max Workers Count], affinity_type_desc AS [Affinity Type], -sqlserver_start_time AS [SQL Server Start Time], virtual_machine_type_desc AS [Virtual Machine Type] +-- You will see no results if your instance is not using AlwaysOn AGs + + +-- Hardware information from SQL Server 2012 (Query 18) (Hardware Info) +SELECT cpu_count AS [Logical CPU Count], scheduler_count, + hyperthread_ratio AS [Hyperthread Ratio], + cpu_count/hyperthread_ratio AS [Physical CPU Count], + physical_memory_kb/1024 AS [Physical Memory (MB)], + committed_kb/1024 AS [Committed Memory (MB)], + committed_target_kb/1024 AS [Committed Target Memory (MB)], + max_workers_count AS [Max Workers Count], + affinity_type_desc AS [Affinity Type], + sqlserver_start_time AS [SQL Server Start Time], + DATEDIFF(hour, sqlserver_start_time, GETDATE()) AS [SQL Server Up Time (hrs)], + virtual_machine_type_desc AS [Virtual Machine Type] FROM sys.dm_os_sys_info WITH (NOLOCK) OPTION (RECOMPILE); ------ @@ -442,8 +518,11 @@ FROM sys.dm_os_sys_info WITH (NOLOCK) OPTION (RECOMPILE); -- Note: virtual_machine_type_desc of HYPERVISOR does not automatically mean you are running SQL Server inside of a VM -- It merely indicates that you have a hypervisor running on your host +-- sys.dm_os_sys_info (Transact-SQL) +-- https://bit.ly/2pczOYs --- Get System Manufacturer and model number from SQL Server Error log (Query 17) (System Manufacturer) + +-- Get System Manufacturer and model number from SQL Server Error log (Query 19) (System Manufacturer) EXEC sys.xp_readerrorlog 0, 1, N'Manufacturer'; ------ @@ -453,7 +532,7 @@ EXEC sys.xp_readerrorlog 0, 1, N'Manufacturer'; -- This query will return no results if your error log has been recycled since the instance was started --- Get BIOS date from Windows Registry (Query 18) (BIOS Date) +-- Get BIOS date from Windows Registry (Query 20) (BIOS Date) EXEC sys.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'HARDWARE\DESCRIPTION\System\BIOS', N'BiosReleaseDate'; ------ @@ -461,7 +540,7 @@ EXEC sys.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'HARDWARE\DESCRIPTION\Syste -- Not as useful for virtualization --- Get processor description from Windows Registry (Query 19) (Processor Description) +-- Get processor description from Windows Registry (Query 21) (Processor Description) EXEC sys.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'HARDWARE\DESCRIPTION\System\CentralProcessor\0', N'ProcessorNameString'; ------ @@ -470,14 +549,15 @@ EXEC sys.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'HARDWARE\DESCRIPTION\Syste -- to the Windows Power Plan or hardware power management -- You can use CPU-Z to get your actual CPU core speed and a lot of other useful information --- http://www.cpuid.com/softwares/cpu-z.html +-- https://bit.ly/QhR6xF -- You can learn more about processor selection for SQL Server by following this link --- https://www.sqlskills.com/blogs/glenn/processor-selection-for-sql-server/ +-- https://bit.ly/2F3aVlP + --- Get information on location, time and size of any memory dumps from SQL Server (Query 20) (Memory Dump Info) +-- Get information on location, time and size of any memory dumps from SQL Server (Query 22) (Memory Dump Info) SELECT [filename], creation_time, size_in_bytes/1048576.0 AS [Size (MB)] FROM sys.dm_server_memory_dumps WITH (NOLOCK) ORDER BY creation_time DESC OPTION (RECOMPILE); @@ -487,10 +567,11 @@ ORDER BY creation_time DESC OPTION (RECOMPILE); -- not had any memory dumps (which is a good thing) -- sys.dm_server_memory_dumps (Transact-SQL) --- http://bit.ly/2elwWll +-- https://bit.ly/2elwWll + --- Look at Suspect Pages table (Query 21) (Suspect Pages) +-- Look at Suspect Pages table (Query 23) (Suspect Pages) SELECT DB_NAME(database_id) AS [Database Name], [file_id], page_id, event_type, error_count, last_update_date FROM msdb.dbo.suspect_pages WITH (NOLOCK) @@ -498,27 +579,37 @@ ORDER BY database_id OPTION (RECOMPILE); ------ -- event_type value descriptions --- 1 = 823 error caused by an operating system CRC error or 824 error other than a bad checksum or a torn page (for example, a bad page ID) +-- 1 = 823 error caused by an operating system CRC error +-- or 824 error other than a bad checksum or a torn page (for example, a bad page ID) -- 2 = Bad checksum -- 3 = Torn page -- 4 = Restored (The page was restored after it was marked bad) -- 5 = Repaired (DBCC repaired the page) -- 7 = Deallocated by DBCC --- Manage the suspect_pages Table --- https://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/manage-the-suspect-pages-table-sql-server - -- Ideally, this query returns no results. The table is limited to 1000 rows. -- If you do get results here, you should do further investigation to determine the root cause +-- Manage the suspect_pages Table +-- https://bit.ly/2Fvr1c9 --- File names and paths for all user and system databases on instance (Query 22) (Database Filenames and Paths) +-- Get number of data files in tempdb database (Query 24) (Tempdb Data Files) +EXEC sys.xp_readerrorlog 0, 1, N'The tempdb database has'; +------ + +-- Get the number of data files in the tempdb database +-- 4-8 data files that are all the same size is a good starting point +-- This query will return no results if your error log has been recycled since the instance was last started +-- This will be blank unless you have Service Pack 4 or later + + +-- File names and paths for all user and system databases on instance (Query 25) (Database Filenames and Paths) SELECT DB_NAME([database_id]) AS [Database Name], [file_id], [name], physical_name, [type_desc], state_desc, - is_percent_growth, growth, + is_percent_growth, growth, CONVERT(bigint, growth/128.0) AS [Growth in MB], - CONVERT(bigint, size/128.0) AS [Total Size in MB] + CONVERT(bigint, size/128.0) AS [Total Size in MB], max_size FROM sys.master_files WITH (NOLOCK) ORDER BY DB_NAME([database_id]), [file_id] OPTION (RECOMPILE); ------ @@ -533,11 +624,13 @@ ORDER BY DB_NAME([database_id]), [file_id] OPTION (RECOMPILE); -- Is percent growth enabled for any files (which is bad)? --- Volume info for all LUNS that have database files on the current instance (Query 23) (Volume Info) -SELECT DISTINCT vs.volume_mount_point, vs.file_system_type, -vs.logical_volume_name, CONVERT(DECIMAL(18,2),vs.total_bytes/1073741824.0) AS [Total Size (GB)], +-- Volume info for all LUNS that have database files on the current instance (Query 26) (Volume Info) +SELECT DISTINCT vs.volume_mount_point, vs.file_system_type, vs.logical_volume_name, +CONVERT(DECIMAL(18,2), vs.total_bytes/1073741824.0) AS [Total Size (GB)], CONVERT(DECIMAL(18,2), vs.available_bytes/1073741824.0) AS [Available Size (GB)], -CONVERT(DECIMAL(18,2), vs.available_bytes * 1. / vs.total_bytes * 100.) AS [Space Free %] +CONVERT(DECIMAL(18,2), vs.available_bytes * 1. / vs.total_bytes * 100.) AS [Space Free %], +vs.supports_compression, vs.is_compressed, +vs.supports_sparse_files, vs.supports_alternate_streams FROM sys.master_files AS f WITH (NOLOCK) CROSS APPLY sys.dm_os_volume_stats(f.database_id, f.[file_id]) AS vs ORDER BY vs.volume_mount_point OPTION (RECOMPILE); @@ -546,10 +639,12 @@ ORDER BY vs.volume_mount_point OPTION (RECOMPILE); -- Shows you the total and free space on the LUNs where you have database files -- Being low on free space can negatively affect performance +-- sys.dm_os_volume_stats (Transact-SQL) +-- https://bit.ly/2oBPNNr --- Drive level latency information (Query 24) (Drive Level Latency) --- Based on code from Jimmy May + +-- Drive level latency information (Query 27) (Drive Level Latency) SELECT tab.[Drive], tab.volume_mount_point AS [Volume Mount Point], CASE WHEN num_of_reads = 0 THEN 0 @@ -592,18 +687,25 @@ ORDER BY [Overall Latency] OPTION (RECOMPILE); -- These latency numbers include all file activity against all SQL Server -- database files on each drive since SQL Server was last started +-- sys.dm_io_virtual_file_stats (Transact-SQL) +-- https://bit.ly/3bRWUc0 + +-- sys.dm_os_volume_stats (Transact-SQL) +-- https://bit.ly/33thz2j --- Calculates average stalls per read, per write, and per total input/output for each database file (Query 25) (IO Stalls by File) -SELECT DB_NAME(fs.database_id) AS [Database Name], CAST(fs.io_stall_read_ms/(1.0 + fs.num_of_reads) AS NUMERIC(10,1)) AS [avg_read_stall_ms], -CAST(fs.io_stall_write_ms/(1.0 + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_write_stall_ms], -CAST((fs.io_stall_read_ms + fs.io_stall_write_ms)/(1.0 + fs.num_of_reads + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_io_stall_ms], + + +-- Calculates average stalls per read, per write, and per total input/output for each database file (Query 28) (IO Latency by File) +SELECT DB_NAME(fs.database_id) AS [Database Name], CAST(fs.io_stall_read_ms/(1.0 + fs.num_of_reads) AS NUMERIC(10,1)) AS [avg_read_latency_ms], +CAST(fs.io_stall_write_ms/(1.0 + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_write_latency_ms], +CAST((fs.io_stall_read_ms + fs.io_stall_write_ms)/(1.0 + fs.num_of_reads + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_io_latency_ms], CONVERT(DECIMAL(18,2), mf.size/128.0) AS [File Size (MB)], mf.physical_name, mf.type_desc, fs.io_stall_read_ms, fs.num_of_reads, fs.io_stall_write_ms, fs.num_of_writes, fs.io_stall_read_ms + fs.io_stall_write_ms AS [io_stalls], fs.num_of_reads + fs.num_of_writes AS [total_io] FROM sys.dm_io_virtual_file_stats(null,null) AS fs INNER JOIN sys.master_files AS mf WITH (NOLOCK) ON fs.database_id = mf.database_id AND fs.[file_id] = mf.[file_id] -ORDER BY avg_io_stall_ms DESC OPTION (RECOMPILE); +ORDER BY avg_io_latency_ms DESC OPTION (RECOMPILE); ------ -- Helps determine which database files on the entire instance have the most I/O bottlenecks @@ -612,8 +714,12 @@ ORDER BY avg_io_stall_ms DESC OPTION (RECOMPILE); -- These latency numbers include all file activity against each SQL Server -- database file since SQL Server was last started +-- sys.dm_io_virtual_file_stats (Transact-SQL) +-- https://bit.ly/3bRWUc0 + --- Look for I/O requests taking longer than 15 seconds in the five most recent SQL Server Error Logs (Query 26) (IO Warnings) + +-- Look for I/O requests taking longer than 15 seconds in the six most recent SQL Server Error Logs (Query 29) (IO Warnings) CREATE TABLE #IOWarningResults(LogDate datetime, ProcessInfo sysname, LogText nvarchar(1000)); INSERT INTO #IOWarningResults @@ -631,6 +737,9 @@ CREATE TABLE #IOWarningResults(LogDate datetime, ProcessInfo sysname, LogText nv INSERT INTO #IOWarningResults EXEC xp_readerrorlog 4, 1, N'taking longer than 15 seconds'; + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 5, 1, N'taking longer than 15 seconds'; + SELECT LogDate, ProcessInfo, LogText FROM #IOWarningResults ORDER BY LogDate DESC; @@ -643,11 +752,25 @@ DROP TABLE #IOWarningResults; -- Look to see if you see any patterns in the results (same files, same drives, same time of day, etc.) -- Diagnostics in SQL Server help detect stalled and stuck I/O operations --- https://support.microsoft.com/en-us/kb/897284 +-- https://bit.ly/2qtaw73 + + +-- Resource Governor Resource Pool information (Query 30) (RG Resource Pools) +SELECT pool_id, [Name], statistics_start_time, + min_memory_percent, max_memory_percent, + max_memory_kb/1024 AS [max_memory_mb], + used_memory_kb/1024 AS [used_memory_mb], + target_memory_kb/1024 AS [target_memory_mb] +FROM sys.dm_resource_governor_resource_pools WITH (NOLOCK) +OPTION (RECOMPILE); +------ + +-- sys.dm_resource_governor_resource_pools (Transact-SQL) +-- https://bit.ly/2MVU0Vy --- Recovery model, log reuse wait description, log file size, log usage size (Query 27) (Database Properties) +-- Recovery model, log reuse wait description, log file size, log usage size (Query 31) (Database Properties) -- and compatibility level for all databases on instance SELECT db.[name] AS [Database Name], SUSER_SNAME(db.owner_sid) AS [Database Owner], db.recovery_model_desc AS [Recovery Model], db.state_desc, db.containment_desc, db.log_reuse_wait_desc AS [Log Reuse Wait Description], @@ -671,6 +794,15 @@ AND ls.cntr_value > 0 ORDER BY db.[name] OPTION (RECOMPILE); ------ +-- sys.databases (Transact-SQL) +-- https://bit.ly/2G5wqaX + +-- sys.dm_os_performance_counters (Transact-SQL) +-- https://bit.ly/3kEO2JR + +-- sys.dm_database_encryption_keys (Transact-SQL) +-- https://bit.ly/3mE7kkx + -- Things to look at: -- How many databases are on the instance? -- What recovery models are they using? @@ -683,11 +815,13 @@ ORDER BY db.[name] OPTION (RECOMPILE); --- Missing Indexes for all databases by Index Advantage (Query 28) (Missing Indexes All Databases) -SELECT CONVERT(decimal(18,2), user_seeks * avg_total_user_cost * (avg_user_impact * 0.01)) AS [index_advantage], -migs.last_user_seek, mid.[statement] AS [Database.Schema.Table], -mid.equality_columns, mid.inequality_columns, mid.included_columns, -migs.unique_compiles, migs.user_seeks, migs.avg_total_user_cost, migs.avg_user_impact +-- Missing Indexes for all databases by Index Advantage (Query 32) (Missing Indexes All Databases) +SELECT CONVERT(decimal(18,2), migs.user_seeks * migs.avg_total_user_cost * (migs.avg_user_impact * 0.01)) AS [index_advantage], +FORMAT(migs.last_user_seek, 'yyyy-MM-dd HH:mm:ss') AS [last_user_seek], mid.[statement] AS [Database.Schema.Table], +COUNT(1) OVER(PARTITION BY mid.[statement]) AS [missing_indexes_for_table], +COUNT(1) OVER(PARTITION BY mid.[statement], equality_columns) AS [similar_missing_indexes_for_table], +mid.equality_columns, mid.inequality_columns, mid.included_columns, migs.user_seeks, +CONVERT(decimal(18,2), migs.avg_total_user_cost) AS [avg_total_user_cost], migs.avg_user_impact FROM sys.dm_db_missing_index_group_stats AS migs WITH (NOLOCK) INNER JOIN sys.dm_db_missing_index_groups AS mig WITH (NOLOCK) ON migs.group_handle = mig.index_group_handle @@ -701,10 +835,14 @@ ORDER BY index_advantage DESC OPTION (RECOMPILE); -- Also look at avg_user_impact and avg_total_user_cost to help determine importance -- SQL Server is overly eager to add included columns, so beware -- Do not just blindly add indexes that show up from this query!!! +-- Hkan Winther has given me some great suggestions for this query +-- SQL Server Index Design Guide +-- https://bit.ly/2qtZr4N --- Get VLF Counts for all databases on the instance (Query 29) (VLF Counts) + +-- Get VLF Counts for all databases on the instance (Query 33) (VLF Counts) -- (adapted from Michelle Ufford) CREATE TABLE #VLFInfo (RecoveryUnitID int, FileID int, FileSize bigint, StartOffset bigint, @@ -736,9 +874,11 @@ DROP TABLE #VLFCountResults; -- and they can make full database restores and crash recovery take much longer -- Try to keep your VLF counts under 200 in most cases (depending on log file size) +-- SQL Server Transaction Log Architecture and Management Guide +-- https://bit.ly/2JjmQRZ --- Get CPU utilization by database (Query 30) (CPU Usage by Database) +-- Get CPU utilization by database (Query 34) (CPU Usage by Database) WITH DB_CPU_Stats AS (SELECT pa.DatabaseID, DB_Name(pa.DatabaseID) AS [Database Name], SUM(qs.total_worker_time/1000) AS [CPU_Time_Ms] @@ -756,25 +896,34 @@ ORDER BY [CPU Rank] OPTION (RECOMPILE); ------ -- Helps determine which database is using the most CPU resources on the instance +-- Note: This only reflects CPU usage from the currently cached query plans --- Get I/O utilization by database (Query 31) (IO Usage By Database) +-- Get I/O utilization by database (Query 35) (IO Usage By Database) WITH Aggregate_IO_Statistics -AS -(SELECT DB_NAME(database_id) AS [Database Name], -CAST(SUM(num_of_bytes_read + num_of_bytes_written)/1048576 AS DECIMAL(12, 2)) AS io_in_mb -FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS [DM_IO_STATS] -GROUP BY database_id) -SELECT ROW_NUMBER() OVER(ORDER BY io_in_mb DESC) AS [I/O Rank], [Database Name], io_in_mb AS [Total I/O (MB)], - CAST(io_in_mb/ SUM(io_in_mb) OVER() * 100.0 AS DECIMAL(5,2)) AS [I/O Percent] +AS (SELECT DB_NAME(database_id) AS [Database Name], + CAST(SUM(num_of_bytes_read + num_of_bytes_written) / 1048576 AS DECIMAL(12, 2)) AS [ioTotalMB], + CAST(SUM(num_of_bytes_read ) / 1048576 AS DECIMAL(12, 2)) AS [ioReadMB], + CAST(SUM(num_of_bytes_written) / 1048576 AS DECIMAL(12, 2)) AS [ioWriteMB] + FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS [DM_IO_STATS] + GROUP BY database_id) +SELECT ROW_NUMBER() OVER (ORDER BY ioTotalMB DESC) AS [I/O Rank], + [Database Name], ioTotalMB AS [Total I/O (MB)], + CAST(ioTotalMB / SUM(ioTotalMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Total I/O %], + ioReadMB AS [Read I/O (MB)], + CAST(ioReadMB / SUM(ioReadMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Read I/O %], + ioWriteMB AS [Write I/O (MB)], + CAST(ioWriteMB / SUM(ioWriteMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Write I/O %] FROM Aggregate_IO_Statistics ORDER BY [I/O Rank] OPTION (RECOMPILE); ------ -- Helps determine which database is using the most I/O resources on the instance +-- These numbers are cumulative since the last service restart +-- They include all I/O activity, not just the nominal I/O workload --- Get total buffer usage by database for current instance (Query 32) (Total Buffer Usage by Database) +-- Get total buffer usage by database for current instance (Query 36) (Total Buffer Usage by Database) -- This make take some time to run on a busy instance WITH AggregateBufferPoolUsage AS @@ -796,7 +945,7 @@ ORDER BY [Buffer Pool Rank] OPTION (RECOMPILE); -- Clear Wait Stats with this command -- DBCC SQLPERF('sys.dm_os_wait_stats', CLEAR); --- Isolate top waits for server instance since last restart or wait statistics clear (Query 33) (Top Waits) +-- Isolate top waits for server instance since last restart or wait statistics clear (Query 37) (Top Waits) WITH [Waits] AS (SELECT wait_type, wait_time_ms/ 1000.0 AS [WaitS], (wait_time_ms - signal_wait_time_ms) / 1000.0 AS [ResourceS], @@ -850,24 +999,24 @@ OPTION (RECOMPILE); -- Cumulative wait stats are not as useful on an idle instance that is not under load or performance pressure --- SQL Server Wait Types Library (Paul Randal) --- https://www.sqlskills.com/help/waits/ +-- SQL Server Wait Types Library +-- https://bit.ly/2ePzYO2 -- The SQL Server Wait Type Repository --- http://blogs.msdn.com/b/psssql/archive/2009/11/03/the-sql-server-wait-type-repository.aspx +-- https://bit.ly/1afzfjC -- Wait statistics, or please tell me where it hurts --- http://www.sqlskills.com/blogs/paul/wait-statistics-or-please-tell-me-where-it-hurts/ +-- https://bit.ly/2wsQHQE -- SQL Server 2005 Performance Tuning using the Waits and Queues --- http://technet.microsoft.com/en-us/library/cc966413.aspx +-- https://bit.ly/1o2NFoF -- sys.dm_os_wait_stats (Transact-SQL) --- http://msdn.microsoft.com/en-us/library/ms179984(v=sql.120).aspx +-- https://bit.ly/2Hjq9Yl --- Get a count of SQL connections by IP address (Query 34) (Connection Counts by IP Address) +-- Get a count of SQL connections by IP address (Query 38) (Connection Counts by IP Address) SELECT ec.client_net_address, es.[program_name], es.[host_name], es.login_name, COUNT(ec.session_id) AS [connection count] FROM sys.dm_exec_sessions AS es WITH (NOLOCK) @@ -881,11 +1030,11 @@ ORDER BY ec.client_net_address, es.[program_name] OPTION (RECOMPILE); -- and verifies connectivity from other machines -- Solving Connectivity errors to SQL Server --- https://support.microsoft.com/en-us/help/4009936/solving-connectivity-errors-to-sql-server +-- https://bit.ly/2EgzoD0 --- Get Average Task Counts (run multiple times) (Query 35) (Avg Task Counts) +-- Get Average Task Counts (run multiple times) (Query 39) (Avg Task Counts) SELECT AVG(current_tasks_count) AS [Avg Task Count], AVG(work_queue_count) AS [Avg Work Queue Count], AVG(runnable_tasks_count) AS [Avg Runnable Task Count], @@ -902,11 +1051,11 @@ WHERE scheduler_id < 255 OPTION (RECOMPILE); -- High Avg Pending DiskIO Counts are a sign of disk pressure -- How to Do Some Very Basic SQL Server Monitoring --- https://www.sqlskills.com/blogs/glenn/how-to-do-some-very-basic-sql-server-monitoring/ +-- https://bit.ly/30IRla0 --- Detect blocking (run multiple times) (Query 36) (Detect Blocking) +-- Detect blocking (run multiple times) (Query 40) (Detect Blocking) SELECT t1.resource_type AS [lock type], DB_NAME(resource_database_id) AS [database], t1.resource_associated_entity_id AS [blk object],t1.request_mode AS [lock req], -- lock requested t1.request_session_id AS [waiter sid], t2.wait_duration_ms AS [wait time], -- spid of waiter @@ -935,7 +1084,7 @@ ON t1.lock_owner_address = t2.resource_address OPTION (RECOMPILE); --- Get CPU Utilization History for last 256 minutes (in one minute intervals) (Query 37) (CPU Utilization History) +-- Get CPU Utilization History for last 256 minutes (in one minute intervals) (Query 41) (CPU Utilization History) DECLARE @ts_now bigint = (SELECT cpu_ticks/(cpu_ticks/ms_ticks) FROM sys.dm_os_sys_info WITH (NOLOCK)); SELECT TOP(256) SQLProcessUtilization AS [SQL Server Process CPU Utilization], @@ -956,10 +1105,11 @@ ORDER BY record_id DESC OPTION (RECOMPILE); -- Look at the trend over the entire period -- Also look at high sustained 'Other Process' CPU Utilization values +-- Note: This query sometimes gives inaccurate results (negative values) +-- on high core count (> 64 cores) systems - --- Get top total worker time queries for entire instance (Query 38) (Top Worker Time Queries) +-- Get top total worker time queries for entire instance (Query 42) (Top Worker Time Queries) SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], qs.total_worker_time AS [Total Worker Time], qs.min_worker_time AS [Min Worker Time], @@ -971,7 +1121,9 @@ qs.max_elapsed_time AS [Max Elapsed Time], qs.min_logical_reads AS [Min Logical Reads], qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], qs.max_logical_reads AS [Max Logical Reads], -qs.execution_count AS [Execution Count], qs.creation_time AS [Creation Time] +qs.execution_count AS [Execution Count], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] --,t.[text] AS [Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t @@ -985,8 +1137,9 @@ ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); --- Page Life Expectancy (PLE) value for each NUMA node in current instance (Query 39) (PLE by NUMA Node) -SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], instance_name, cntr_value AS [Page Life Expectancy] +-- Page Life Expectancy (PLE) value for each NUMA node in current instance (Query 43) (PLE by NUMA Node) +SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], + instance_name, cntr_value AS [Page Life Expectancy] FROM sys.dm_os_performance_counters WITH (NOLOCK) WHERE [object_name] LIKE N'%Buffer Node%' -- Handles named instances AND counter_name = N'Page life expectancy' OPTION (RECOMPILE); @@ -997,10 +1150,10 @@ AND counter_name = N'Page life expectancy' OPTION (RECOMPILE); -- This will only return one row for non-NUMA systems -- Page Life Expectancy isnt what you think --- https://www.sqlskills.com/blogs/paul/page-life-expectancy-isnt-what-you-think/ +-- https://bit.ly/2EgynLa --- Memory Grants Pending value for current instance (Query 40) (Memory Grants Pending) +-- Memory Grants Pending value for current instance (Query 44) (Memory Grants Pending) SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], cntr_value AS [Memory Grants Pending] FROM sys.dm_os_performance_counters WITH (NOLOCK) WHERE [object_name] LIKE N'%Memory Manager%' -- Handles named instances @@ -1011,7 +1164,7 @@ AND counter_name = N'Memory Grants Pending' OPTION (RECOMPILE); -- Memory Grants Pending above zero for a sustained period is a very strong indicator of internal memory pressure --- Memory Clerk Usage for instance (Query 41) (Memory Clerk Usage) +-- Memory Clerk Usage for instance (Query 45) (Memory Clerk Usage) -- Look for high value for CACHESTORE_SQLCP (Ad-hoc query plans) SELECT TOP(10) mc.[type] AS [Memory Clerk Type], CAST((SUM(mc.pages_kb)/1024.0) AS DECIMAL (15,2)) AS [Memory Usage (MB)] @@ -1033,14 +1186,16 @@ ORDER BY SUM(mc.pages_kb) DESC OPTION (RECOMPILE); --- Find single-use, ad-hoc and prepared queries that are bloating the plan cache (Query 42) (Ad hoc Queries) -SELECT TOP(50) [text] AS [QueryText], cp.cacheobjtype, cp.objtype, cp.size_in_bytes/1024 AS [Plan Size in KB] +-- Find single-use, ad-hoc and prepared queries that are bloating the plan cache (Query 46) (Ad hoc Queries) +SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], t.[text] AS [Query Text], +cp.objtype AS [Object Type], cp.cacheobjtype AS [Cache Object Type], +cp.size_in_bytes/1024 AS [Plan Size in KB] FROM sys.dm_exec_cached_plans AS cp WITH (NOLOCK) -CROSS APPLY sys.dm_exec_sql_text(plan_handle) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t WHERE cp.cacheobjtype = N'Compiled Plan' AND cp.objtype IN (N'Adhoc', N'Prepared') AND cp.usecounts = 1 -ORDER BY cp.size_in_bytes DESC OPTION (RECOMPILE); +ORDER BY cp.size_in_bytes DESC, DB_NAME(t.[dbid]) OPTION (RECOMPILE); ------ -- Gives you the text, type and size of single-use ad-hoc and prepared queries that waste space in the plan cache @@ -1049,10 +1204,10 @@ ORDER BY cp.size_in_bytes DESC OPTION (RECOMPILE); -- Enabling forced parameterization for the database can help, but test first! -- Plan cache, adhoc workloads and clearing the single-use plan cache bloat --- https://www.sqlskills.com/blogs/kimberly/plan-cache-adhoc-workloads-and-clearing-the-single-use-plan-cache-bloat/ +-- https://bit.ly/2EfYOkl --- Get top total logical reads queries for entire instance (Query 43) (Top Logical Reads Queries) +-- Get top total logical reads queries for entire instance (Query 47) (Top Logical Reads Queries) SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], qs.total_logical_reads AS [Total Logical Reads], @@ -1065,7 +1220,9 @@ qs.max_worker_time AS [Max Worker Time], qs.min_elapsed_time AS [Min Elapsed Time], qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], qs.max_elapsed_time AS [Max Elapsed Time], -qs.execution_count AS [Execution Count], qs.creation_time AS [Creation Time] +qs.execution_count AS [Execution Count], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] --,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t @@ -1078,7 +1235,7 @@ ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE); -- Can also help track down parameter sniffing issues --- Get top average elapsed time queries for entire instance (Query 44) (Top Avg Elapsed Time Queries) +-- Get top average elapsed time queries for entire instance (Query 48) (Top Avg Elapsed Time Queries) SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], @@ -1087,8 +1244,9 @@ qs.execution_count AS [Execution Count], qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], qs.total_physical_reads/qs.execution_count AS [Avg Physical Reads], qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], qs.creation_time AS [Creation Time] -, qp.query_plan AS [Query Plan] -- comment out this column if copying results to Excel +--,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp @@ -1107,11 +1265,14 @@ ORDER BY qs.total_elapsed_time/qs.execution_count DESC OPTION (RECOMPILE); --USE YourDatabaseName; -- make sure to change to an actual database on your instance, not the master system database --GO --- Individual File Sizes and space available for current database (Query 45) (File Sizes and Space) +-- Individual File Sizes and space available for current database (Query 49) (File Sizes and Space) SELECT f.name AS [File Name] , f.physical_name AS [Physical Name], CAST((f.size/128.0) AS DECIMAL(15,2)) AS [Total Size in MB], CAST(f.size/128.0 - CAST(FILEPROPERTY(f.name, 'SpaceUsed') AS int)/128.0 AS DECIMAL(15,2)) -AS [Available Space In MB], f.[file_id], fg.name AS [Filegroup Name], +AS [Available Space In MB], +CAST((f.size/128.0) AS DECIMAL(15,2)) - +CAST(f.size/128.0 - CAST(FILEPROPERTY(f.name, 'SpaceUsed') AS int)/128.0 AS DECIMAL(15,2)) AS [Used Space in MB], +f.[file_id], fg.name AS [Filegroup Name], f.is_percent_growth, f.growth, fg.is_default, fg.is_read_only FROM sys.database_files AS f WITH (NOLOCK) LEFT OUTER JOIN sys.filegroups AS fg WITH (NOLOCK) @@ -1123,19 +1284,19 @@ ORDER BY f.[file_id] OPTION (RECOMPILE); -- Make sure the transaction log is not full!! --- I/O Statistics by file for the current database (Query 46) (IO Stats By File) +-- I/O Statistics by file for the current database (Query 50) (IO Stats By File) SELECT DB_NAME(DB_ID()) AS [Database Name], df.name AS [Logical Name], vfs.[file_id], df.type_desc, -df.physical_name AS [Physical Name], CAST(vfs.size_on_disk_bytes/1048576.0 AS DECIMAL(10, 2)) AS [Size on Disk (MB)], +df.physical_name AS [Physical Name], CAST(vfs.size_on_disk_bytes/1048576.0 AS DECIMAL(16, 2)) AS [Size on Disk (MB)], vfs.num_of_reads, vfs.num_of_writes, vfs.io_stall_read_ms, vfs.io_stall_write_ms, -CAST(100. * vfs.io_stall_read_ms/(vfs.io_stall_read_ms + vfs.io_stall_write_ms) AS DECIMAL(10,1)) AS [IO Stall Reads Pct], -CAST(100. * vfs.io_stall_write_ms/(vfs.io_stall_write_ms + vfs.io_stall_read_ms) AS DECIMAL(10,1)) AS [IO Stall Writes Pct], +CAST(100. * vfs.io_stall_read_ms/(vfs.io_stall_read_ms + vfs.io_stall_write_ms) AS DECIMAL(16,1)) AS [IO Stall Reads Pct], +CAST(100. * vfs.io_stall_write_ms/(vfs.io_stall_write_ms + vfs.io_stall_read_ms) AS DECIMAL(16,1)) AS [IO Stall Writes Pct], (vfs.num_of_reads + vfs.num_of_writes) AS [Writes + Reads], -CAST(vfs.num_of_bytes_read/1048576.0 AS DECIMAL(10, 2)) AS [MB Read], -CAST(vfs.num_of_bytes_written/1048576.0 AS DECIMAL(10, 2)) AS [MB Written], -CAST(100. * vfs.num_of_reads/(vfs.num_of_reads + vfs.num_of_writes) AS DECIMAL(10,1)) AS [# Reads Pct], -CAST(100. * vfs.num_of_writes/(vfs.num_of_reads + vfs.num_of_writes) AS DECIMAL(10,1)) AS [# Write Pct], -CAST(100. * vfs.num_of_bytes_read/(vfs.num_of_bytes_read + vfs.num_of_bytes_written) AS DECIMAL(10,1)) AS [Read Bytes Pct], -CAST(100. * vfs.num_of_bytes_written/(vfs.num_of_bytes_read + vfs.num_of_bytes_written) AS DECIMAL(10,1)) AS [Written Bytes Pct] +CAST(vfs.num_of_bytes_read/1048576.0 AS DECIMAL(16, 2)) AS [MB Read], +CAST(vfs.num_of_bytes_written/1048576.0 AS DECIMAL(16, 2)) AS [MB Written], +CAST(100. * vfs.num_of_reads/(vfs.num_of_reads + vfs.num_of_writes) AS DECIMAL(16,1)) AS [# Reads Pct], +CAST(100. * vfs.num_of_writes/(vfs.num_of_reads + vfs.num_of_writes) AS DECIMAL(16,1)) AS [# Write Pct], +CAST(100. * vfs.num_of_bytes_read/(vfs.num_of_bytes_read + vfs.num_of_bytes_written) AS DECIMAL(16,1)) AS [Read Bytes Pct], +CAST(100. * vfs.num_of_bytes_written/(vfs.num_of_bytes_read + vfs.num_of_bytes_written) AS DECIMAL(16,1)) AS [Written Bytes Pct] FROM sys.dm_io_virtual_file_stats(DB_ID(), NULL) AS vfs INNER JOIN sys.database_files AS df WITH (NOLOCK) ON vfs.[file_id]= df.[file_id] OPTION (RECOMPILE); @@ -1146,14 +1307,15 @@ ON vfs.[file_id]= df.[file_id] OPTION (RECOMPILE); --- Get most frequently executed queries for this database (Query 47) (Query Execution Counts) +-- Get most frequently executed queries for this database (Query 51) (Query Execution Counts) SELECT TOP(50) LEFT(t.[text], 50) AS [Short Query Text], qs.execution_count AS [Execution Count], qs.total_logical_reads AS [Total Logical Reads], qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], qs.total_worker_time AS [Total Worker Time], qs.total_worker_time/qs.execution_count AS [Avg Worker Time], qs.total_elapsed_time AS [Total Elapsed Time], -qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], qs.creation_time AS [Creation Time] --,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) @@ -1164,16 +1326,22 @@ ORDER BY qs.execution_count DESC OPTION (RECOMPILE); ------ --- Queries 47 through 52 are the "Bad Man List" for stored procedures --- Top Cached SPs By Execution Count (Query 48) (SP Execution Counts) -SELECT TOP(100) p.name AS [SP Name], qs.execution_count, +-- Queries 52 through 57 are the "Bad Man List" for stored procedures + +-- Top Cached SPs By Execution Count (Query 52) (SP Execution Counts) +SELECT TOP(100) p.name AS [SP Name], qs.execution_count AS [Execution Count], ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], -qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], qs.total_worker_time AS [TotalWorkerTime], -qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], -qs.cached_time +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 ORDER BY qs.execution_count DESC OPTION (RECOMPILE); @@ -1181,17 +1349,23 @@ ORDER BY qs.execution_count DESC OPTION (RECOMPILE); -- Tells you which cached stored procedures are called the most often -- This helps you characterize and baseline your workload +-- It also helps you find possible caching opportunities --- Top Cached SPs By Avg Elapsed Time (Query 49) (SP Avg Elapsed Time) +-- Top Cached SPs By Avg Elapsed Time (Query 53) (SP Avg Elapsed Time) SELECT TOP(25) p.name AS [SP Name], qs.min_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], qs.max_elapsed_time, qs.last_elapsed_time, qs.total_elapsed_time, qs.execution_count, ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], -qs.total_worker_time AS [TotalWorkerTime], qs.cached_time +qs.total_worker_time AS [TotalWorkerTime], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 ORDER BY avg_elapsed_time DESC OPTION (RECOMPILE); @@ -1202,15 +1376,19 @@ ORDER BY avg_elapsed_time DESC OPTION (RECOMPILE); --- Top Cached SPs By Total Worker time. Worker time relates to CPU cost (Query 50) (SP Worker Time) +-- Top Cached SPs By Total Worker time. Worker time relates to CPU cost (Query 54) (SP Worker Time) SELECT TOP(25) p.name AS [SP Name], qs.total_worker_time AS [TotalWorkerTime], qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], qs.execution_count, ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], -qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count -AS [avg_elapsed_time], qs.cached_time +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); @@ -1220,15 +1398,19 @@ ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); -- You should look at this if you see signs of CPU pressure --- Top Cached SPs By Total Logical Reads. Logical reads relate to memory pressure (Query 51) (SP Logical Reads) +-- Top Cached SPs By Total Logical Reads. Logical reads relate to memory pressure (Query 55) (SP Logical Reads) SELECT TOP(25) p.name AS [SP Name], qs.total_logical_reads AS [TotalLogicalReads], qs.total_logical_reads/qs.execution_count AS [AvgLogicalReads],qs.execution_count, ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], -qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count -AS [avg_elapsed_time], qs.cached_time +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE); @@ -1238,14 +1420,18 @@ ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE); -- You should look at this if you see signs of memory pressure --- Top Cached SPs By Total Physical Reads. Physical reads relate to disk read I/O pressure (Query 52) (SP Physical Reads) +-- Top Cached SPs By Total Physical Reads. Physical reads relate to disk read I/O pressure (Query 56) (SP Physical Reads) SELECT TOP(25) p.name AS [SP Name],qs.total_physical_reads AS [TotalPhysicalReads], qs.total_physical_reads/qs.execution_count AS [AvgPhysicalReads], qs.execution_count, -qs.total_logical_reads,qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count -AS [avg_elapsed_time], qs.cached_time +qs.total_logical_reads,qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND qs.total_physical_reads > 0 ORDER BY qs.total_physical_reads DESC, qs.total_logical_reads DESC OPTION (RECOMPILE); @@ -1256,16 +1442,20 @@ ORDER BY qs.total_physical_reads DESC, qs.total_logical_reads DESC OPTION (RECOM --- Top Cached SPs By Total Logical Writes (Query 53) (SP Logical Writes) +-- Top Cached SPs By Total Logical Writes (Query 57) (SP Logical Writes) -- Logical writes relate to both memory and disk I/O pressure SELECT TOP(25) p.name AS [SP Name], qs.total_logical_writes AS [TotalLogicalWrites], qs.total_logical_writes/qs.execution_count AS [AvgLogicalWrites], qs.execution_count, ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], -qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], -qs.cached_time +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND qs.total_logical_writes > 0 AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 @@ -1276,7 +1466,7 @@ ORDER BY qs.total_logical_writes DESC OPTION (RECOMPILE); -- You should look at this if you see signs of I/O pressure or of memory pressure --- Lists the top statements by average input/output usage for the current database (Query 54) (Top IO Statements) +-- Lists the top statements by average input/output usage for the current database (Query 58) (Top IO Statements) SELECT TOP(50) OBJECT_NAME(qt.objectid, dbid) AS [SP Name], (qs.total_logical_reads + qs.total_logical_writes) /qs.execution_count AS [Avg IO], qs.execution_count AS [Execution Count], SUBSTRING(qt.[text],qs.statement_start_offset/2, @@ -1295,19 +1485,24 @@ ORDER BY [Avg IO] DESC OPTION (RECOMPILE); --- Possible Bad NC Indexes (writes > reads) (Query 55) (Bad NC Indexes) -SELECT OBJECT_NAME(s.[object_id]) AS [Table Name], i.name AS [Index Name], i.index_id, +-- Possible Bad NC Indexes (writes > reads) (Query 59) (Bad NC Indexes) +SELECT SCHEMA_NAME(o.[schema_id]) AS [Schema Name], +OBJECT_NAME(s.[object_id]) AS [Table Name], +i.name AS [Index Name], i.index_id, i.is_disabled, i.is_hypothetical, i.has_filter, i.fill_factor, -user_updates AS [Total Writes], user_seeks + user_scans + user_lookups AS [Total Reads], -user_updates - (user_seeks + user_scans + user_lookups) AS [Difference] +s.user_updates AS [Total Writes], s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], +s.user_updates - (s.user_seeks + s.user_scans + s.user_lookups) AS [Difference] FROM sys.dm_db_index_usage_stats AS s WITH (NOLOCK) INNER JOIN sys.indexes AS i WITH (NOLOCK) ON s.[object_id] = i.[object_id] AND i.index_id = s.index_id +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON i.[object_id] = o.[object_id] WHERE OBJECTPROPERTY(s.[object_id],'IsUserTable') = 1 AND s.database_id = DB_ID() -AND user_updates > (user_seeks + user_scans + user_lookups) -AND i.index_id > 1 +AND s.user_updates > (s.user_seeks + s.user_scans + s.user_lookups) +AND i.index_id > 1 AND i.[type_desc] = N'NONCLUSTERED' +AND i.is_primary_key = 0 AND i.is_unique_constraint = 0 AND i.is_unique = 0 ORDER BY [Difference] DESC, [Total Writes] DESC, [Total Reads] ASC OPTION (RECOMPILE); ------ @@ -1316,11 +1511,11 @@ ORDER BY [Difference] DESC, [Total Writes] DESC, [Total Reads] ASC OPTION (RECOM -- Investigate further before dropping an index! --- Missing Indexes for current database by Index Advantage (Query 56) (Missing Indexes) -SELECT DISTINCT CONVERT(decimal(18,2), user_seeks * avg_total_user_cost * (avg_user_impact * 0.01)) AS [index_advantage], +-- Missing Indexes for current database by Index Advantage (Query 60) (Missing Indexes) +SELECT DISTINCT CONVERT(decimal(18,2), migs.user_seeks * migs.avg_total_user_cost * (migs.avg_user_impact * 0.01)) AS [index_advantage], migs.last_user_seek, mid.[statement] AS [Database.Schema.Table], mid.equality_columns, mid.inequality_columns, mid.included_columns, -migs.unique_compiles, migs.user_seeks, migs.avg_total_user_cost, migs.avg_user_impact, +migs.user_seeks, migs.avg_total_user_cost, migs.avg_user_impact, OBJECT_NAME(mid.[object_id]) AS [Table Name], p.rows AS [Table Rows] FROM sys.dm_db_missing_index_group_stats AS migs WITH (NOLOCK) INNER JOIN sys.dm_db_missing_index_groups AS mig WITH (NOLOCK) @@ -1337,12 +1532,13 @@ ORDER BY index_advantage DESC OPTION (RECOMPILE); -- Look at index advantage, last user seek time, number of user seeks to help determine source and importance -- SQL Server is overly eager to add included columns, so beware -- Do not just blindly add indexes that show up from this query!!! +-- Hkan Winther has given me some great suggestions for this query --- Find missing index warnings for cached plans in the current database (Query 57) (Missing Index Warnings) +-- Find missing index warnings for cached plans in the current database (Query 61) (Missing Index Warnings) -- Note: This query could take some time on a busy instance SELECT TOP(25) OBJECT_NAME(objectid) AS [ObjectName], - cp.objtype, cp.usecounts, cp.size_in_bytes, query_plan + cp.objtype, cp.usecounts, cp.size_in_bytes, qp.query_plan FROM sys.dm_exec_cached_plans AS cp WITH (NOLOCK) CROSS APPLY sys.dm_exec_query_plan(cp.plan_handle) AS qp WHERE CAST(query_plan AS NVARCHAR(MAX)) LIKE N'%MissingIndex%' @@ -1354,9 +1550,10 @@ ORDER BY cp.usecounts DESC OPTION (RECOMPILE); -- This can help you decide whether to add them or not --- Breaks down buffers used by current database by object (table, index) in the buffer cache (Query 58) (Buffer Usage) +-- Breaks down buffers used by current database by object (table, index) in the buffer cache (Query 62) (Buffer Usage) -- Note: This query could take some time on a busy instance -SELECT OBJECT_NAME(p.[object_id]) AS [Object Name], p.index_id, +SELECT fg.name AS [Filegroup Name], SCHEMA_NAME(o.Schema_ID) AS [Schema Name], +OBJECT_NAME(p.[object_id]) AS [Object Name], p.index_id, CAST(COUNT(*)/128.0 AS DECIMAL(10, 2)) AS [Buffer size(MB)], COUNT(*) AS [BufferCount], p.[Rows] AS [Row Count], p.data_compression_desc AS [Compression Type] @@ -1365,12 +1562,19 @@ INNER JOIN sys.dm_os_buffer_descriptors AS b WITH (NOLOCK) ON a.allocation_unit_id = b.allocation_unit_id INNER JOIN sys.partitions AS p WITH (NOLOCK) ON a.container_id = p.hobt_id +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON p.object_id = o.object_id +INNER JOIN sys.database_files AS f WITH (NOLOCK) +ON b.file_id = f.file_id +INNER JOIN sys.filegroups AS fg WITH (NOLOCK) +ON f.data_space_id = fg.data_space_id WHERE b.database_id = CONVERT(int, DB_ID()) AND p.[object_id] > 100 AND OBJECT_NAME(p.[object_id]) NOT LIKE N'plan_%' AND OBJECT_NAME(p.[object_id]) NOT LIKE N'sys%' AND OBJECT_NAME(p.[object_id]) NOT LIKE N'xml_index_nodes%' -GROUP BY p.[object_id], p.index_id, p.data_compression_desc, p.[Rows] +GROUP BY fg.name, o.Schema_ID, p.[object_id], p.index_id, + p.data_compression_desc, p.[Rows] ORDER BY [BufferCount] DESC OPTION (RECOMPILE); ------ @@ -1378,29 +1582,32 @@ ORDER BY [BufferCount] DESC OPTION (RECOMPILE); -- It can help identify possible candidates for data compression --- Get Table names, row counts, and compression status for clustered index or heap (Query 59) (Table Sizes) -SELECT OBJECT_NAME(object_id) AS [ObjectName], -SUM(Rows) AS [RowCount], data_compression_desc AS [CompressionType] -FROM sys.partitions WITH (NOLOCK) +-- Get Table names, row counts, and compression status for clustered index or heap (Query 63) (Table Sizes) +SELECT SCHEMA_NAME(o.Schema_ID) AS [Schema Name], OBJECT_NAME(p.object_id) AS [ObjectName], +SUM(p.Rows) AS [RowCount], p.data_compression_desc AS [Compression Type] +FROM sys.partitions AS p WITH (NOLOCK) +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON p.object_id = o.object_id WHERE index_id < 2 --ignore the partitions from the non-clustered index if any -AND OBJECT_NAME(object_id) NOT LIKE N'sys%' -AND OBJECT_NAME(object_id) NOT LIKE N'queue_%' -AND OBJECT_NAME(object_id) NOT LIKE N'filestream_tombstone%' -AND OBJECT_NAME(object_id) NOT LIKE N'fulltext%' -AND OBJECT_NAME(object_id) NOT LIKE N'ifts_comp_fragment%' -AND OBJECT_NAME(object_id) NOT LIKE N'filetable_updates%' -AND OBJECT_NAME(object_id) NOT LIKE N'xml_index_nodes%' -AND OBJECT_NAME(object_id) NOT LIKE N'sqlagent_job%' -AND OBJECT_NAME(object_id) NOT LIKE N'plan_persist%' -GROUP BY object_id, data_compression_desc -ORDER BY SUM(Rows) DESC OPTION (RECOMPILE); +AND OBJECT_NAME(p.object_id) NOT LIKE N'sys%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'spt_%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'queue_%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'filestream_tombstone%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'fulltext%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'ifts_comp_fragment%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'filetable_updates%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'xml_index_nodes%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'sqlagent_job%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'plan_persist%' +GROUP BY SCHEMA_NAME(o.Schema_ID), p.object_id, data_compression_desc +ORDER BY SUM(p.Rows) DESC OPTION (RECOMPILE); ------ -- Gives you an idea of table sizes, and possible data compression opportunities --- Get some key table properties (Query 60) (Table Properties) +-- Get some key table properties (Query 64) (Table Properties) SELECT OBJECT_NAME(t.[object_id]) AS [ObjectName], p.[rows] AS [Table Rows], p.index_id, p.data_compression_desc AS [Index Data Compression], t.create_date, t.lock_on_bulk_load, t.is_replicated, t.has_replication_filter, @@ -1416,9 +1623,9 @@ ORDER BY OBJECT_NAME(t.[object_id]), p.index_id OPTION (RECOMPILE); --- When were Statistics last updated on all indexes? (Query 61) (Statistics Update) -SELECT SCHEMA_NAME(o.Schema_ID) + N'.' + o.NAME AS [Object Name], o.type_desc AS [Object Type], - i.name AS [Index Name], STATS_DATE(i.[object_id], i.index_id) AS [Statistics Date], +-- When were Statistics last updated on all indexes? (Query 65) (Statistics Update) +SELECT SCHEMA_NAME(o.Schema_ID) + N'.' + o.[NAME] AS [Object Name], o.[type_desc] AS [Object Type], + i.[name] AS [Index Name], STATS_DATE(i.[object_id], i.index_id) AS [Statistics Date], s.auto_created, s.no_recompute, s.user_created, s.is_temporary, st.row_count, st.used_page_count FROM sys.objects AS o WITH (NOLOCK) @@ -1441,9 +1648,13 @@ ORDER BY STATS_DATE(i.[object_id], i.index_id) DESC OPTION (RECOMPILE); -- sys.stats (Transact-SQL) -- https://msdn.microsoft.com/en-us/library/ms177623.aspx +-- UPDATEs to Statistics (Erin Stellato) +-- https://bit.ly/2vhrYQy --- Look at most frequently modified indexes and statistics (Query 62) (Volatile Indexes) + + +-- Look at most frequently modified indexes and statistics (Query 66) (Volatile Indexes) SELECT o.[name] AS [Object Name], o.[object_id], o.[type_desc], s.[name] AS [Statistics Name], s.stats_id, s.no_recompute, s.auto_created, s.is_temporary, sp.modification_counter, sp.[rows], sp.rows_sampled, sp.last_updated @@ -1461,7 +1672,7 @@ ORDER BY sp.modification_counter DESC, o.name OPTION (RECOMPILE); --- Get fragmentation info for all indexes above a certain size in the current database (Query 63) (Index Fragmentation) +-- Get fragmentation info for all indexes above a certain size in the current database (Query 67) (Index Fragmentation) -- Note: This query could take some time on a very large database SELECT DB_NAME(ps.database_id) AS [Database Name], SCHEMA_NAME(o.[schema_id]) AS [Schema Name], OBJECT_NAME(ps.OBJECT_ID) AS [Object Name], i.[name] AS [Index Name], ps.index_id, @@ -1483,8 +1694,9 @@ ORDER BY ps.avg_fragmentation_in_percent DESC OPTION (RECOMPILE); -- and how effective your index maintenance strategy is ---- Index Read/Write stats (all tables in current DB) ordered by Reads (Query 64) (Overall Index Usage - Reads) -SELECT OBJECT_NAME(i.[object_id]) AS [ObjectName], i.[name] AS [IndexName], i.index_id, +--- Index Read/Write stats (all tables in current DB) ordered by Reads (Query 68) (Overall Index Usage - Reads) +SELECT SCHEMA_NAME(t.[schema_id]) AS [SchemaName], OBJECT_NAME(i.[object_id]) AS [ObjectName], + i.[name] AS [IndexName], i.index_id, s.user_seeks, s.user_scans, s.user_lookups, s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], s.user_updates AS [Writes], @@ -1495,6 +1707,8 @@ LEFT OUTER JOIN sys.dm_db_index_usage_stats AS s WITH (NOLOCK) ON i.[object_id] = s.[object_id] AND i.index_id = s.index_id AND s.database_id = DB_ID() +LEFT OUTER JOIN sys.tables AS t WITH (NOLOCK) +ON t.[object_id] = i.[object_id] WHERE OBJECTPROPERTY(i.[object_id],'IsUserTable') = 1 ORDER BY s.user_seeks + s.user_scans + s.user_lookups DESC OPTION (RECOMPILE); -- Order by reads ------ @@ -1502,8 +1716,9 @@ ORDER BY s.user_seeks + s.user_scans + s.user_lookups DESC OPTION (RECOMPILE); - -- Show which indexes in the current database are most active for Reads ---- Index Read/Write stats (all tables in current DB) ordered by Writes (Query 65) (Overall Index Usage - Writes) -SELECT OBJECT_NAME(i.[object_id]) AS [ObjectName], i.[name] AS [IndexName], i.index_id, +--- Index Read/Write stats (all tables in current DB) ordered by Writes (Query 69) (Overall Index Usage - Writes) +SELECT SCHEMA_NAME(t.[schema_id]) AS [SchemaName],OBJECT_NAME(i.[object_id]) AS [ObjectName], + i.[name] AS [IndexName], i.index_id, s.user_updates AS [Writes], s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], i.[type_desc] AS [Index Type], i.fill_factor AS [Fill Factor], i.has_filter, i.filter_definition, s.last_system_update, s.last_user_update @@ -1512,6 +1727,8 @@ LEFT OUTER JOIN sys.dm_db_index_usage_stats AS s WITH (NOLOCK) ON i.[object_id] = s.[object_id] AND i.index_id = s.index_id AND s.database_id = DB_ID() +LEFT OUTER JOIN sys.tables AS t WITH (NOLOCK) +ON t.[object_id] = i.[object_id] WHERE OBJECTPROPERTY(i.[object_id],'IsUserTable') = 1 ORDER BY s.user_updates DESC OPTION (RECOMPILE); -- Order by writes ------ @@ -1519,7 +1736,7 @@ ORDER BY s.user_updates DESC OPTION (RECOMPILE); -- Order by writes -- Show which indexes in the current database are most active for Writes --- Get lock waits for current database (Query 66) (Lock Waits) +-- Get lock waits for current database (Query 70) (Lock Waits) SELECT o.name AS [table_name], i.name AS [index_name], ios.index_id, ios.partition_number, SUM(ios.row_lock_wait_count) AS [total_row_lock_waits], SUM(ios.row_lock_wait_in_ms) AS [total_row_lock_wait_in_ms], @@ -1541,7 +1758,7 @@ ORDER BY total_lock_wait_in_ms DESC OPTION (RECOMPILE); -- This query is helpful for troubleshooting blocking and deadlocking issues --- Look at recent Full backups for the current database (Query 67) (Recent Full Backups) +-- Look at recent Full backups for the current database (Query 71) (Recent Full Backups) SELECT TOP (30) bs.machine_name, bs.server_name, bs.database_name AS [Database Name], bs.recovery_model, CONVERT (BIGINT, bs.backup_size / 1048576 ) AS [Uncompressed Backup Size (MB)], CONVERT (BIGINT, bs.compressed_backup_size / 1048576 ) AS [Compressed Backup Size (MB)], @@ -1564,29 +1781,10 @@ ORDER BY bs.backup_finish_date DESC OPTION (RECOMPILE); -- Have you done any backup tuning with striped backups, or changing the parameters of the backup command? --- These three Pluralsight Courses go into more detail about how to run these queries and interpret the results - --- SQL Server 2014 DMV Diagnostic Queries Part 1 --- https://www.pluralsight.com/courses/sql-server-2014-dmv-diagnostic-queries-part1 - --- SQL Server 2014 DMV Diagnostic Queries Part 2 --- https://www.pluralsight.com/courses/sql-server-2014-dmv-diagnostic-queries-part2 - --- SQL Server 2014 DMV Diagnostic Queries Part 3 --- https://www.pluralsight.com/courses/sql-server-2014-dmv-diagnostic-queries-part3 - - --- Sign up for Microsoft Visual Studio Dev Essentials and get a free three month pass to Pluralsight - -- Microsoft Visual Studio Dev Essentials --- http://bit.ly/1q6xbDL - - --- Sign up for Microsoft IT Pro Cloud Essentials and get lots of free Azure usage credits, MCP exam voucher, three month Pluralsight subscription +-- https://bit.ly/2qjNRxi --- Microsoft IT Pro Cloud Essentials --- http://bit.ly/2443SAd +-- Microsoft Azure Learn +-- https://bit.ly/2O0Hacc --- August 2017 blog series about upgrading and migrating SQL Server --- https://www.sqlskills.com/blogs/glenn/category/upgrading-sql-server/ diff --git a/Scripts/SQL Server 2014 Diagnostic Information Queries.sql b/Scripts/SQL Server 2014 Diagnostic Information Queries.sql index 366472c3..59bb822e 100644 --- a/Scripts/SQL Server 2014 Diagnostic Information Queries.sql +++ b/Scripts/SQL Server 2014 Diagnostic Information Queries.sql @@ -1,26 +1,30 @@ -- SQL Server 2014 Diagnostic Information Queries -- Glenn Berry --- Last Modified: December 5, 2017 --- https://www.sqlskills.com/blogs/glenn/ --- http://sqlserverperformance.wordpress.com/ +-- Last Modified: December 3, 2020 +-- https://glennsqlperformance.com/ +-- https://sqlserverperformance.wordpress.com/ +-- YouTube: https://bit.ly/2PkoAM1 -- Twitter: GlennAlanBerry --- Please listen to my Pluralsight courses --- https://www.pluralsight.com/author/glenn-berry - --- If you want to find all of our SQLskills SQL101 blog posts, check out https://www.sqlskills.com/help/sql101/ +-- Diagnostic Queries are available here +-- https://glennsqlperformance.com/resources/ -- Please make sure you are using the correct version of these diagnostic queries for your version of SQL Server! +-- If you like PowerShell, there is a very useful community solution for running these queries in an automated fashion +-- https://dbatools.io/ + +-- Invoke-DbaDiagnosticQuery +-- https://dbatools.io/functions/invoke-dbadiagnosticquery/ + + --****************************************************************************** ---* Copyright (C) 2017 Glenn Berry, SQLskills.com +--* Copyright (C) 2020 Glenn Berry --* All rights reserved. --* ---* For more scripts and sample code, check out ---* https://www.sqlskills.com/blogs/glenn --* --* You may alter this code for your own *non-commercial* purposes. You may --* republish altered code as long as you include this copyright and give due credit. @@ -49,8 +53,8 @@ IF NOT EXISTS (SELECT * WHERE CONVERT(varchar(128), SERVERPROPERTY('ProductVersi SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version Info]; ------ --- SQL Server 2014 RTM Branch Builds SQL Server 2014 SP1 Branch Builds SQL Server 2014 SP2 Branch Builds --- Build Description Release Date Build Description Release Date Build Description Release Date +-- SQL Server 2014 RTM Branch Builds SQL Server 2014 SP1 Branch Builds SQL Server 2014 SP2 Branch Builds SQL Server 2014 SP23 Branch Builds +-- Build Description Release Date Build Description Release Date Build Description Release Date Build Description Release Date -- 11.0.9120 CTP1 6/2/2013 -- 12.0.1524 CTP2 10/15/2013 -- 12.0.2000 RTM 4/1/2014 @@ -69,52 +73,63 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In -- 12.0.2564 CU12 2/22/2016 12.0.4439 SP1 CU5 2/22/2016 -- 12.0.2568 CU13 4/18/2016 12.0.4449 SP1 CU6 4/18/2016 (Deprecated) -- 12.0.4457 SP1 CU6 5/30/2016 (Re-release) --- 12.0.2569 CU14 6/20/2016 12.0.4459 SP1 CU7 6/20/2016 -----------> 12.0.5000 SP2 RTM 7/11/2016 --- 12.0.4468 SP1 CU8 8/15/2016 12.0.5511 SP2 CU1 8/25/2016 +-- 12.0.2569 CU14 6/20/2016 12.0.4459 SP1 CU7 6/20/2016 -----------> 12.0.5000 SP2 RTM 7/11/2016 +-- 12.0.4468 SP1 CU8 8/15/2016 12.0.5511 SP2 CU1 8/25/2016 -- 12.0.4474 SP1 CU9 10/17/2016 12.0.5522 SP2 CU2 10/17/2016 --- 12.0.4487 SP1 CU9 + HF 11/8/2016 12.0.5532 SP2 CU2 + HF 11/8/2016 https://technet.microsoft.com/library/security/MS16-136 +-- 12.0.4487 SP1 CU9 + HF 11/8/2016 12.0.5532 SP2 CU2 + HF 11/8/2016 -- 12.0.4491 SP1 CU10 12/28/2016 12.0.5537 SP2 CU3 12/28/2016 --- 12.0.4502 SP1 CU11 2/21/2017 12.0.5540 SP2 CU4 2/21/2017 --- 12.0.4511 SP1 CU12 4/17/2017 12.0.5546 SP2 CU5 4/17/2017 --- 12.0.4522 SP1 CU13 7/17/2017 12.0.5552 SP2 CU6 7/17/2017 --- 12.0.5556 SP2 CU7 8/28/2017 +-- 12.0.4502 SP1 CU11 2/21/2017 12.0.5540 SP2 CU4 2/21/2017 +-- 12.0.4511 SP1 CU12 4/17/2017 12.0.5546 SP2 CU5 4/17/2017 +-- 12.0.4522 SP1 CU13 7/17/2017 12.0.5552 SP2 CU6 7/17/2017 +-- 12.0.5556 SP2 CU7 8/28/2017 -- 12.0.5557 SP2 CU8 10/16/2017 - - - +-- 12.0.5563 SP2 CU9 12/18/2017 +-- 12.0.5571 SP2 CU10 1/16/2018 +-- 12.0.5579 SP2 CU11 3/19/2018 +-- 12.0.5589 SP2 CU12 6/18/2018 +-- 12.0.5590 SP2 CU13 8/27/2018 +-- 12.0.5600 SP2 CU14 10/15/2018 +-- 12.0.6024 SP3 RTM 10/30/2018 +-- 12.0.5605 SP2 CU15 12/12/2018 ----> 12.0.6205 SP3 CU1 12/12/2018 +-- 12.0.5626 SP2 CU16 2/19/2019 ----> 12.0.6214 SP3 CU2 2/19/2019 +-- 12.0.5632 SP2 CU17 4/16/2019 ----> 12.0.6259 SP3 CU3 4/16/2019 +-- 12.0.5687 SP2 CU18 7/29/2019 ----> 12.0.6329 SP3 CU4 7/29/2019 + + +-- 12.0.6372.1 Security Update for SQL Server 2016 SP3 CU4 February 11, 2020 +-- https://support.microsoft.com/en-us/help/4535288/description-of-the-security-update-for-sql-server-2014-sp3-cu4-feb -- How to determine the version, edition and update level of SQL Server and its components --- https://support.microsoft.com/en-us/kb/321185 +-- https://bit.ly/2oAjKgW -- SQL Server 2014 build versions --- http://support.microsoft.com/kb/2936603 - --- Where to find information about the latest SQL Server builds --- https://support.microsoft.com/en-us/help/957826/where-to-find-information-about-the-latest-sql-server-builds +-- https://bit.ly/2HpmYOG -- Recommended updates and configuration options for SQL Server 2012 and SQL Server 2014 used with high-performance workloads --- http://support.microsoft.com/kb/2964518/EN-US +-- https://bit.ly/2Hy3zIZ -- Performance and Stability Related Fixes in Post-SQL Server 2014 RTM Builds --- https://www.sqlskills.com/blogs/glenn/performance-and-stability-related-fixes-in-post-sql-server-2014-rtm-builds/ +-- https://bit.ly/2Hx50HU -- Performance and Stability Related Fixes in Post-SQL Server 2014 SP1 Builds --- https://www.sqlskills.com/blogs/glenn/performance-and-stability-related-fixes-in-post-sql-server-2014-sp1-builds/ +-- https://bit.ly/2GWLx6a -- Performance and Stability Related Fixes in Post-SQL Server 2014 SP2 Builds --- https://www.sqlskills.com/blogs/glenn/performance-and-stability-related-fixes-in-post-sql-server-2014-sp2-builds/ +-- https://bit.ly/2iJ9G4N --- Announcing updates to the SQL Server Incremental Servicing Model (ISM) --- https://blogs.msdn.microsoft.com/sqlreleaseservices/announcing-updates-to-the-sql-server-incremental-servicing-model-ism/ +-- Performance and Stability Related Fixes in Post-SQL Server 2014 SP3 Builds +-- https://bit.ly/2PRGTWS -- Update Center for Microsoft SQL Server --- http://bit.ly/2pZptuQ +-- https://bit.ly/2pZptuQ -- Download SQL Server Management Studio (SSMS) --- https://msdn.microsoft.com/en-us/library/mt238290.aspx +-- https://bit.ly/1OcupT9 + +-- Download and install Azure Data Studio +-- https://bit.ly/2vgke1A --- Download and install Microsoft SQL Operations Studio --- https://docs.microsoft.com/en-us/sql/sql-operations-studio/download +-- SQL Server 2014 Configuration Manager is SQLServerManager12.msc -- Get socket, physical core and logical core count from the SQL Server Error log. (Query 2) (Core Counts) @@ -154,6 +169,7 @@ SERVERPROPERTY('IsHadrEnabled') AS [IsHadrEnabled], SERVERPROPERTY('HadrManagerStatus') AS [HadrManagerStatus], SERVERPROPERTY('InstanceDefaultDataPath') AS [InstanceDefaultDataPath], SERVERPROPERTY('InstanceDefaultLogPath') AS [InstanceDefaultLogPath], +SERVERPROPERTY('ErrorLogFileName') AS [ErrorLogFileName], SERVERPROPERTY('BuildClrVersion') AS [Build CLR Version], SERVERPROPERTY('IsXTPSupported') AS [IsXTPSupported]; ------ @@ -163,7 +179,7 @@ SERVERPROPERTY('IsXTPSupported') AS [IsXTPSupported]; -- Note: Some columns will be NULL on older SQL Server builds -- SERVERPROPERTY (Transact-SQL) --- http://bit.ly/2eeaXeI +-- https://bit.ly/2eeaXeI -- Get instance-level configuration values for instance (Query 4) (Configuration Values) @@ -194,33 +210,33 @@ DBCC TRACESTATUS (-1); -- Common trace flags that should be enabled in most cases -- TF 1117 - When growing a data file, grow all files at the same time so they remain the same size, reducing allocation contention points --- https://support2.microsoft.com/kb/2154845 +-- https://bit.ly/2GY1kOl -- -- TF 1118 - Helps alleviate allocation contention in tempdb, SQL Server allocates full extents to each database object, -- thereby eliminating the contention on SGAM pages (more important with older versions of SQL Server) -- Recommendations to reduce allocation contention in SQL Server tempdb database --- https://support2.microsoft.com/kb/2154845 +-- https://bit.ly/2GY1kOl -- TF 2371 - Lowers auto update statistics threshold for large tables (on tables with more than 25,000 rows) --- https://blogs.msdn.com/b/saponsqlserver/archive/2011/09/07/changes-to-automatic-update-statistics-in-sql-server-traceflag-2371.aspx +-- https://bit.ly/30KO4Hh -- TF 3226 - Supresses logging of successful database backup messages to the SQL Server Error Log --- https://www.sqlskills.com/blogs/paul/fed-up-with-backup-success-messages-bloating-your-error-logs/ +-- https://bit.ly/38zDNAK -- TF 3449 - Enables use of dirty page manager (SQL Server 2014 SP1 CU7 and later) --- https://blogs.msdn.microsoft.com/psssql/2017/06/29/sql-server-large-ram-and-db-checkpointing/ +-- https://bit.ly/2uj0h5M -- TF 6533 - Spatial performance improvements in SQL Server 2012 and 2014 --- https://support.microsoft.com/en-us/kb/3107399 +-- https://bit.ly/2v7C7ze -- TF 6534 - Enables use of native code to improve performance with spatial data --- https://blogs.msdn.microsoft.com/bobsql/2016/06/03/sql-2016-it-just-runs-faster-native-spatial-implementations/ +-- https://bit.ly/2HrQUpU -- TF 8079 - Enables automatic soft-NUMA on systems with eight or more physical cores per NUMA node (with SQL Server 2014 SP2) --- https://blogs.msdn.microsoft.com/sqlreleaseservices/sql-2014-service-pack-2-is-now-available/ +-- https://bit.ly/29B7oR8 -- DBCC TRACEON - Trace Flags (Transact-SQL) --- https://docs.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-traceon-trace-flags-transact-sql +-- https://bit.ly/2FuSvPg @@ -230,20 +246,19 @@ EXEC sys.xp_readerrorlog 0, 1, N'Database Instant File Initialization'; -- Lets you determine whether Instant File Initialization (IFI) is enabled for the instance -- This should be enabled in the vast majority of cases --- SQL Server 2016 lets you enable this during the SQL server installation process +-- Note: This query won't return any results if the SQL Server error log has been recycled --- Database Instant File Initialization --- https://docs.microsoft.com/en-us/sql/relational-databases/databases/database-instant-file-initialization --- Misconceptions around instant file initialization --- https://www.sqlskills.com/blogs/paul/misconceptions-around-instant-file-initialization/ +-- Database Instant File Initialization +-- https://bit.ly/2nTX74y -- SQL Server Process Address space info (Query 7) (Process Memory) -- (shows whether locked pages is enabled, among other things) SELECT physical_memory_in_use_kb/1024 AS [SQL Server Memory Usage (MB)], - large_page_allocations_kb, locked_page_allocations_kb, page_fault_count, - memory_utilization_percentage, available_commit_limit_kb, + locked_page_allocations_kb/1024 AS [SQL Server Locked Pages Allocation (MB)], + large_page_allocations_kb/1024 AS [SQL Server Large Pages Allocation (MB)], + page_fault_count, memory_utilization_percentage, available_commit_limit_kb, process_physical_memory_low, process_virtual_memory_low FROM sys.dm_os_process_memory WITH (NOLOCK) OPTION (RECOMPILE); ------ @@ -254,7 +269,10 @@ FROM sys.dm_os_process_memory WITH (NOLOCK) OPTION (RECOMPILE); -- If locked_page_allocations_kb > 0, then LPIM is enabled -- How to enable the "locked pages" feature in SQL Server 2012 --- https://support.microsoft.com/en-us/kb/2659143 +-- https://bit.ly/2F5UjOA + +-- Memory Management Architecture Guide +-- https://bit.ly/2JKkadC @@ -268,20 +286,28 @@ FROM sys.dm_server_services WITH (NOLOCK) OPTION (RECOMPILE); -- Shows the process_id, when they were last started, and their current status -- Also shows whether you are running on a failover cluster instance, and what node you are running on +-- sys.dm_server_services (Transact-SQL) +-- https://bit.ly/2oKa1Un -- Last backup information by database (Query 9) (Last Backup By Database) SELECT ISNULL(d.[name], bs.[database_name]) AS [Database], d.recovery_model_desc AS [Recovery Model], d.log_reuse_wait_desc AS [Log Reuse Wait Desc], MAX(CASE WHEN [type] = 'D' THEN bs.backup_finish_date ELSE NULL END) AS [Last Full Backup], + MAX(CASE WHEN [type] = 'D' THEN bmf.physical_device_name ELSE NULL END) AS [Last Full Backup Location], MAX(CASE WHEN [type] = 'I' THEN bs.backup_finish_date ELSE NULL END) AS [Last Differential Backup], - MAX(CASE WHEN [type] = 'L' THEN bs.backup_finish_date ELSE NULL END) AS [Last Log Backup] + MAX(CASE WHEN [type] = 'I' THEN bmf.physical_device_name ELSE NULL END) AS [Last Differential Backup Location], + MAX(CASE WHEN [type] = 'L' THEN bs.backup_finish_date ELSE NULL END) AS [Last Log Backup], + MAX(CASE WHEN [type] = 'L' THEN bmf.physical_device_name ELSE NULL END) AS [Last Log Backup Location] FROM sys.databases AS d WITH (NOLOCK) LEFT OUTER JOIN msdb.dbo.backupset AS bs WITH (NOLOCK) -ON bs.[database_name] = d.[name] +ON bs.[database_name] = d.[name] +LEFT OUTER JOIN msdb.dbo.backupmediafamily AS bmf WITH (NOLOCK) +ON bs.media_set_id = bmf.media_set_id AND bs.backup_finish_date > GETDATE()- 30 -GROUP BY ISNULL(d.[name], bs.[database_name]), d.recovery_model_desc, d.log_reuse_wait_desc -ORDER BY d.recovery_model_desc OPTION (RECOMPILE); +WHERE d.name <> N'tempdb' +GROUP BY ISNULL(d.[name], bs.[database_name]), d.recovery_model_desc, d.log_reuse_wait_desc, d.[name] +ORDER BY d.recovery_model_desc, d.[name] OPTION (RECOMPILE); ------ -- This helps you spot runaway transaction logs and other issues with your backup schedule @@ -308,10 +334,13 @@ ORDER BY sj.name OPTION (RECOMPILE); -- Look for jobs that have a notify_level_email set to 0 (meaning no e-mail is ever sent) -- -- MSDN sysjobs documentation --- https://msdn.microsoft.com/en-us/library/ms189817.aspx +-- https://bit.ly/2paDEOP -- SQL Server Maintenance Solution --- https://ola.hallengren.com/ +-- https://bit.ly/1pgchQu + +-- You can use this script to add default schedules to the standard Ola Hallengren Maintenance Solution jobs +-- https://bit.ly/3ane0gN -- Get SQL Server Agent Alert Information (Query 11) (SQL Server Agent Alerts) @@ -321,8 +350,9 @@ FROM msdb.dbo.sysalerts WITH (NOLOCK) ORDER BY name OPTION (RECOMPILE); ------ --- Gives you some basic information about your SQL Server Agent Alerts (which are different from SQL Server Agent jobs) --- Read more about Agent Alerts here: https://www.sqlskills.com/blogs/glenn/creating-sql-server-agent-alerts-for-critical-errors/ +-- Gives you some basic information about your SQL Server Agent Alerts +-- (which are different from SQL Server Agent jobs) +-- Read more about Agent Alerts here: https://bit.ly/2v5YR37 @@ -333,7 +363,8 @@ FROM sys.dm_os_windows_info WITH (NOLOCK) OPTION (RECOMPILE); ------ -- Gives you major OS version, Service Pack, Edition, and language info for the operating system --- 6.3 is either Windows 8.1, Windows 10 or Windows Server 2012 R2, Windows Server 2016 +-- 10.0 is either Windows 10 or Windows Server 2016 +-- 6.3 is either Windows 8.1, or Windows Server 2012 R2 -- 6.2 is either Windows 8 or Windows Server 2012 -- 6.1 is either Windows 7 or Windows Server 2008 R2 -- 6.0 is either Windows Vista or Windows Server 2008 @@ -344,16 +375,17 @@ FROM sys.dm_os_windows_info WITH (NOLOCK) OPTION (RECOMPILE); -- 8 is Datacenter Server Edition -- 10 is Enterprise Server Edition -- 48 is Professional Edition +-- 161 is Pro for Workstations -- 1033 for os_language_version is US-English -- SQL Server 2014 requires Windows Server 2008 SP2 or newer -- Hardware and Software Requirements for Installing SQL Server 2014 --- https://msdn.microsoft.com/en-us/library/ms143506.aspx +-- https://bit.ly/1yRYXkQ -- Using SQL Server in Windows 8 and later versions of Windows operating system --- https://support.microsoft.com/en-us/kb/2681562 +-- https://bit.ly/2F7Ax0P @@ -366,18 +398,22 @@ WHERE node_state_desc <> N'ONLINE DAC' OPTION (RECOMPILE); -- Gives you some useful information about the composition and relative load on your NUMA nodes -- You want to see an equal number of schedulers on each NUMA node --- Watch out if SQL Server 2014 Standard Edition has been installed on a machine with more than 16 physical cores --- Watch out if you have a VM with more than 4 NUMA nodes with SQL Server Standard Edition, since there is a four-socket license limit +-- Watch out if SQL Server 2014 Standard Edition has been installed +-- on a physical or virtual machine with more than four sockets or more than 16 physical cores --- Balancing Your Available SQL Server Core Licenses Evenly Across NUMA Nodes --- https://www.sqlskills.com/blogs/glenn/balancing-your-available-sql-server-core-licenses-evenly-across-numa-nodes/ +-- sys.dm_os_nodes (Transact-SQL) +-- https://bit.ly/2pn5Mw8 + +-- How to Balance SQL Server Core Licenses Across NUMA Nodes +-- https://bit.ly/3i4TyVR -- Good basic information about OS memory amounts and state (Query 14) (System Memory) SELECT total_physical_memory_kb/1024 AS [Physical Memory (MB)], available_physical_memory_kb/1024 AS [Available Memory (MB)], - total_page_file_kb/1024 AS [Total Page File (MB)], + total_page_file_kb/1024 AS [Page File Commit Limit (MB)], + total_page_file_kb/1024 - total_physical_memory_kb/1024 AS [Physical Page File Size (MB)], available_page_file_kb/1024 AS [Available Page File (MB)], system_cache_kb/1024 AS [System Cache (MB)], system_memory_state_desc AS [System Memory State] @@ -391,8 +427,13 @@ FROM sys.dm_os_sys_memory WITH (NOLOCK) OPTION (RECOMPILE); -- Available physical memory is high -- Physical memory usage is steady -- Available physical memory is low +-- Available physical memory is running low -- Physical memory state is transitioning +-- sys.dm_os_sys_memory (Transact-SQL) +-- https://bit.ly/2pcV0xq + + -- You can skip the next two queries if you know you don't have a clustered instance @@ -408,7 +449,7 @@ FROM sys.dm_os_cluster_nodes WITH (NOLOCK) OPTION (RECOMPILE); -- You will see no results if your instance is not clustered -- Recommended hotfixes and updates for Windows Server 2012 R2-based failover clusters --- http://support.microsoft.com/kb/2920151 +-- https://bit.ly/1z5BfCw -- Get information about any AlwaysOn AG cluster this instance is a part of (Query 16) (AlwaysOn AG Cluster) @@ -419,7 +460,7 @@ FROM sys.dm_hadr_cluster WITH (NOLOCK) OPTION (RECOMPILE); -- You will see no results if your instance is not using AlwaysOn AGs --- Good overview of AG health and status (Query 17) (AlwaysOn AG Status) +-- Good overview of AG health and status (Query 17) (AG Status) SELECT ag.name AS [AG Name], ar.replica_server_name, ar.availability_mode_desc, adc.[database_name], drs.is_local, drs.is_primary_replica, drs.synchronization_state_desc, drs.is_commit_participant, drs.synchronization_health_desc, drs.recovery_lsn, drs.truncation_lsn, drs.last_sent_lsn, @@ -442,12 +483,17 @@ ORDER BY ag.name, ar.replica_server_name, adc.[database_name] OPTION (RECOMPILE) -- Hardware information from SQL Server 2014 (Query 18) (Hardware Info) -SELECT cpu_count AS [Logical CPU Count], scheduler_count, hyperthread_ratio AS [Hyperthread Ratio], -cpu_count/hyperthread_ratio AS [Physical CPU Count], -physical_memory_kb/1024 AS [Physical Memory (MB)], committed_kb/1024 AS [Committed Memory (MB)], -committed_target_kb/1024 AS [Committed Target Memory (MB)], -max_workers_count AS [Max Workers Count], affinity_type_desc AS [Affinity Type], -sqlserver_start_time AS [SQL Server Start Time], virtual_machine_type_desc AS [Virtual Machine Type] +SELECT cpu_count AS [Logical CPU Count], scheduler_count, + hyperthread_ratio AS [Hyperthread Ratio], + cpu_count/hyperthread_ratio AS [Physical CPU Count], + physical_memory_kb/1024 AS [Physical Memory (MB)], + committed_kb/1024 AS [Committed Memory (MB)], + committed_target_kb/1024 AS [Committed Target Memory (MB)], + max_workers_count AS [Max Workers Count], + affinity_type_desc AS [Affinity Type], + sqlserver_start_time AS [SQL Server Start Time], + DATEDIFF(hour, sqlserver_start_time, GETDATE()) AS [SQL Server Up Time (hrs)], + virtual_machine_type_desc AS [Virtual Machine Type] FROM sys.dm_os_sys_info WITH (NOLOCK) OPTION (RECOMPILE); ------ @@ -456,6 +502,9 @@ FROM sys.dm_os_sys_info WITH (NOLOCK) OPTION (RECOMPILE); -- Note: virtual_machine_type_desc of HYPERVISOR does not automatically mean you are running SQL Server inside of a VM -- It merely indicates that you have a hypervisor running on your host +-- sys.dm_os_sys_info (Transact-SQL) +-- https://bit.ly/2pczOYs + -- Get System Manufacturer and model number from SQL Server Error log (Query 19) (System Manufacturer) EXEC sys.xp_readerrorlog 0, 1, N'Manufacturer'; @@ -484,45 +533,15 @@ EXEC sys.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'HARDWARE\DESCRIPTION\Syste -- to the Windows Power Plan or hardware power management -- You can use CPU-Z to get your actual CPU core speed and a lot of other useful information --- http://www.cpuid.com/softwares/cpu-z.html +-- https://bit.ly/QhR6xF -- You can learn more about processor selection for SQL Server by following this link --- https://www.sqlskills.com/blogs/glenn/processor-selection-for-sql-server/ - - - --- See if buffer pool extensions (BPE) is enabled (Query 22) (BPE Configuration) -SELECT [path], state_description, current_size_in_kb, -CAST(current_size_in_kb/1048576.0 AS DECIMAL(10,2)) AS [Size (GB)] -FROM sys.dm_os_buffer_pool_extension_configuration WITH (NOLOCK) OPTION (RECOMPILE); ------- - --- BPE is available in both Standard Edition and Enterprise Edition --- It is a more interesting feature for Standard Edition - --- Buffer Pool Extension to SSDs in SQL Server 2014 --- http://blogs.technet.com/b/dataplatforminsider/archive/2013/07/25/buffer-pool-extension-to-ssds-in-sql-server-2014.aspx - --- Buffer Pool Extension --- https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/buffer-pool-extension - +-- https://bit.ly/2F3aVlP --- Look at buffer descriptors to see BPE usage by database (Query 23) (BPE Usage) -SELECT DB_NAME(database_id) AS [Database Name], COUNT(page_id) AS [Page Count], -CAST(COUNT(*)/128.0 AS DECIMAL(10, 2)) AS [Buffer size(MB)], -AVG(read_microsec) AS [Avg Read Time (microseconds)] -FROM sys.dm_os_buffer_descriptors WITH (NOLOCK) -WHERE database_id <> 32767 -AND is_in_bpool_extension = 1 -GROUP BY DB_NAME(database_id) -ORDER BY [Buffer size(MB)] DESC OPTION (RECOMPILE); ------- --- You will see no results if BPE is not enabled or if there is no BPE usage - --- Get information on location, time and size of any memory dumps from SQL Server (Query 24) (Memory Dump Info) +-- Get information on location, time and size of any memory dumps from SQL Server (Query 22) (Memory Dump Info) SELECT [filename], creation_time, size_in_bytes/1048576.0 AS [Size (MB)] FROM sys.dm_server_memory_dumps WITH (NOLOCK) ORDER BY creation_time DESC OPTION (RECOMPILE); @@ -532,10 +551,11 @@ ORDER BY creation_time DESC OPTION (RECOMPILE); -- not had any memory dumps (which is a good thing) -- sys.dm_server_memory_dumps (Transact-SQL) --- http://bit.ly/2elwWll +-- https://bit.ly/2elwWll + --- Look at Suspect Pages table (Query 25) (Suspect Pages) +-- Look at Suspect Pages table (Query 23) (Suspect Pages) SELECT DB_NAME(database_id) AS [Database Name], [file_id], page_id, event_type, error_count, last_update_date FROM msdb.dbo.suspect_pages WITH (NOLOCK) @@ -543,35 +563,37 @@ ORDER BY database_id OPTION (RECOMPILE); ------ -- event_type value descriptions --- 1 = 823 error caused by an operating system CRC error or 824 error other than a bad checksum or a torn page (for example, a bad page ID) +-- 1 = 823 error caused by an operating system CRC error +-- or 824 error other than a bad checksum or a torn page (for example, a bad page ID) -- 2 = Bad checksum -- 3 = Torn page -- 4 = Restored (The page was restored after it was marked bad) -- 5 = Repaired (DBCC repaired the page) -- 7 = Deallocated by DBCC --- Manage the suspect_pages Table --- https://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/manage-the-suspect-pages-table-sql-server - -- Ideally, this query returns no results. The table is limited to 1000 rows. -- If you do get results here, you should do further investigation to determine the root cause +-- Manage the suspect_pages Table +-- https://bit.ly/2Fvr1c9 --- Get number of data files in tempdb database (Query 26) (Tempdb Data Files) + +-- Get number of data files in tempdb database (Query 24) (Tempdb Data Files) EXEC sys.xp_readerrorlog 0, 1, N'The tempdb database has'; ------ -- Get the number of data files in the tempdb database -- 4-8 data files that are all the same size is a good starting point +-- This query will return no results if your error log has been recycled since the instance was last started -- This will be blank unless you have Service Pack 2 or later --- File names and paths for all user and system databases on instance (Query 27) (Database Filenames and Paths) +-- File names and paths for all user and system databases on instance (Query 25) (Database Filenames and Paths) SELECT DB_NAME([database_id]) AS [Database Name], [file_id], [name], physical_name, [type_desc], state_desc, - is_percent_growth, growth, + is_percent_growth, growth, CONVERT(bigint, growth/128.0) AS [Growth in MB], - CONVERT(bigint, size/128.0) AS [Total Size in MB] + CONVERT(bigint, size/128.0) AS [Total Size in MB], max_size FROM sys.master_files WITH (NOLOCK) ORDER BY DB_NAME([database_id]), [file_id] OPTION (RECOMPILE); ------ @@ -586,11 +608,13 @@ ORDER BY DB_NAME([database_id]), [file_id] OPTION (RECOMPILE); -- Is percent growth enabled for any files (which is bad)? --- Volume info for all LUNS that have database files on the current instance (Query 28) (Volume Info) -SELECT DISTINCT vs.volume_mount_point, vs.file_system_type, -vs.logical_volume_name, CONVERT(DECIMAL(18,2),vs.total_bytes/1073741824.0) AS [Total Size (GB)], +-- Volume info for all LUNS that have database files on the current instance (Query 26) (Volume Info) +SELECT DISTINCT vs.volume_mount_point, vs.file_system_type, vs.logical_volume_name, +CONVERT(DECIMAL(18,2), vs.total_bytes/1073741824.0) AS [Total Size (GB)], CONVERT(DECIMAL(18,2), vs.available_bytes/1073741824.0) AS [Available Size (GB)], -CONVERT(DECIMAL(18,2), vs.available_bytes * 1. / vs.total_bytes * 100.) AS [Space Free %] +CONVERT(DECIMAL(18,2), vs.available_bytes * 1. / vs.total_bytes * 100.) AS [Space Free %], +vs.supports_compression, vs.is_compressed, +vs.supports_sparse_files, vs.supports_alternate_streams FROM sys.master_files AS f WITH (NOLOCK) CROSS APPLY sys.dm_os_volume_stats(f.database_id, f.[file_id]) AS vs ORDER BY vs.volume_mount_point OPTION (RECOMPILE); @@ -599,10 +623,12 @@ ORDER BY vs.volume_mount_point OPTION (RECOMPILE); -- Shows you the total and free space on the LUNs where you have database files -- Being low on free space can negatively affect performance +-- sys.dm_os_volume_stats (Transact-SQL) +-- https://bit.ly/2oBPNNr + --- Drive level latency information (Query 29) (Drive Level Latency) --- Based on code from Jimmy May +-- Drive level latency information (Query 27) (Drive Level Latency) SELECT tab.[Drive], tab.volume_mount_point AS [Volume Mount Point], CASE WHEN num_of_reads = 0 THEN 0 @@ -645,11 +671,18 @@ ORDER BY [Overall Latency] OPTION (RECOMPILE); -- These latency numbers include all file activity against all SQL Server -- database files on each drive since SQL Server was last started +-- sys.dm_io_virtual_file_stats (Transact-SQL) +-- https://bit.ly/3bRWUc0 + +-- sys.dm_os_volume_stats (Transact-SQL) +-- https://bit.ly/33thz2j + + --- Calculates average stalls per read, per write, and per total input/output for each database file (Query 30) (IO Stalls by File) -SELECT DB_NAME(fs.database_id) AS [Database Name], CAST(fs.io_stall_read_ms/(1.0 + fs.num_of_reads) AS NUMERIC(10,1)) AS [avg_read_stall_ms], -CAST(fs.io_stall_write_ms/(1.0 + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_write_stall_ms], -CAST((fs.io_stall_read_ms + fs.io_stall_write_ms)/(1.0 + fs.num_of_reads + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_io_stall_ms], +-- Calculates average stalls per read, per write, and per total input/output for each database file (Query 28) (IO Latency by File) +SELECT DB_NAME(fs.database_id) AS [Database Name], CAST(fs.io_stall_read_ms/(1.0 + fs.num_of_reads) AS NUMERIC(10,1)) AS [avg_read_latency_ms], +CAST(fs.io_stall_write_ms/(1.0 + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_write_latency_ms], +CAST((fs.io_stall_read_ms + fs.io_stall_write_ms)/(1.0 + fs.num_of_reads + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_io_latency_ms], CONVERT(DECIMAL(18,2), mf.size/128.0) AS [File Size (MB)], mf.physical_name, mf.type_desc, fs.io_stall_read_ms, fs.num_of_reads, fs.io_stall_write_ms, fs.num_of_writes, fs.io_stall_read_ms + fs.io_stall_write_ms AS [io_stalls], fs.num_of_reads + fs.num_of_writes AS [total_io], io_stall_queued_read_ms AS [Resource Governor Total Read IO Latency (ms)], io_stall_queued_write_ms AS [Resource Governor Total Write IO Latency (ms)] @@ -657,7 +690,7 @@ FROM sys.dm_io_virtual_file_stats(null,null) AS fs INNER JOIN sys.master_files AS mf WITH (NOLOCK) ON fs.database_id = mf.database_id AND fs.[file_id] = mf.[file_id] -ORDER BY avg_io_stall_ms DESC OPTION (RECOMPILE); +ORDER BY avg_io_latency_ms DESC OPTION (RECOMPILE); ------ -- Helps determine which database files on the entire instance have the most I/O bottlenecks @@ -666,8 +699,11 @@ ORDER BY avg_io_stall_ms DESC OPTION (RECOMPILE); -- These latency numbers include all file activity against each SQL Server -- database file since SQL Server was last started +-- sys.dm_io_virtual_file_stats (Transact-SQL) +-- https://bit.ly/3bRWUc0 --- Look for I/O requests taking longer than 15 seconds in the five most recent SQL Server Error Logs (Query 31) (IO Warnings) + +-- Look for I/O requests taking longer than 15 seconds in the six most recent SQL Server Error Logs (Query 29) (IO Warnings) CREATE TABLE #IOWarningResults(LogDate datetime, ProcessInfo sysname, LogText nvarchar(1000)); INSERT INTO #IOWarningResults @@ -685,6 +721,9 @@ CREATE TABLE #IOWarningResults(LogDate datetime, ProcessInfo sysname, LogText nv INSERT INTO #IOWarningResults EXEC xp_readerrorlog 4, 1, N'taking longer than 15 seconds'; + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 5, 1, N'taking longer than 15 seconds'; + SELECT LogDate, ProcessInfo, LogText FROM #IOWarningResults ORDER BY LogDate DESC; @@ -697,11 +736,26 @@ DROP TABLE #IOWarningResults; -- Look to see if you see any patterns in the results (same files, same drives, same time of day, etc.) -- Diagnostics in SQL Server help detect stalled and stuck I/O operations --- https://support.microsoft.com/en-us/kb/897284 +-- https://bit.ly/2qtaw73 + + +-- Resource Governor Resource Pool information (Query 30) (RG Resource Pools) +SELECT pool_id, [Name], statistics_start_time, + min_memory_percent, max_memory_percent, + max_memory_kb/1024 AS [max_memory_mb], + used_memory_kb/1024 AS [used_memory_mb], + target_memory_kb/1024 AS [target_memory_mb], + min_iops_per_volume, max_iops_per_volume +FROM sys.dm_resource_governor_resource_pools WITH (NOLOCK) +OPTION (RECOMPILE); +------ + +-- sys.dm_resource_governor_resource_pools (Transact-SQL) +-- https://bit.ly/2MVU0Vy --- Recovery model, log reuse wait description, log file size, log usage size (Query 32) (Database Properties) +-- Recovery model, log reuse wait description, log file size, log usage size (Query 31) (Database Properties) -- and compatibility level for all databases on instance SELECT db.[name] AS [Database Name], SUSER_SNAME(db.owner_sid) AS [Database Owner], db.recovery_model_desc AS [Recovery Model], db.state_desc, db.containment_desc, db.log_reuse_wait_desc AS [Log Reuse Wait Description], @@ -710,9 +764,8 @@ CAST(CAST(lu.cntr_value AS FLOAT) / CAST(ls.cntr_value AS FLOAT)AS DECIMAL(18,2) db.[compatibility_level] AS [DB Compatibility Level], db.page_verify_option_desc AS [Page Verify Option], db.is_auto_create_stats_on, db.is_auto_update_stats_on, db.is_auto_update_stats_async_on, db.is_parameterization_forced, db.snapshot_isolation_state_desc, db.is_read_committed_snapshot_on, db.is_auto_close_on, db.is_auto_shrink_on, -db.target_recovery_time_in_seconds, db.is_cdc_enabled, db.is_published, db.is_distributor, db.is_encrypted, -db.group_database_id, db.replica_id,db.is_memory_optimized_elevate_to_snapshot_on, -db.delayed_durability_desc, db.is_auto_create_stats_incremental_on, +db.target_recovery_time_in_seconds, db.is_cdc_enabled, db.is_published, db.is_distributor, +db.group_database_id, db.replica_id,db.is_memory_optimized_elevate_to_snapshot_on, db.delayed_durability_desc, db.is_encrypted, de.encryption_state, de.percent_complete, de.key_algorithm, de.key_length FROM sys.databases AS db WITH (NOLOCK) INNER JOIN sys.dm_os_performance_counters AS lu WITH (NOLOCK) @@ -727,6 +780,15 @@ AND ls.cntr_value > 0 ORDER BY db.[name] OPTION (RECOMPILE); ------ +-- sys.databases (Transact-SQL) +-- https://bit.ly/2G5wqaX + +-- sys.dm_os_performance_counters (Transact-SQL) +-- https://bit.ly/3kEO2JR + +-- sys.dm_database_encryption_keys (Transact-SQL) +-- https://bit.ly/3mE7kkx + -- Things to look at: -- How many databases are on the instance? -- What recovery models are they using? @@ -739,11 +801,13 @@ ORDER BY db.[name] OPTION (RECOMPILE); --- Missing Indexes for all databases by Index Advantage (Query 33) (Missing Indexes All Databases) -SELECT CONVERT(decimal(18,2), user_seeks * avg_total_user_cost * (avg_user_impact * 0.01)) AS [index_advantage], -migs.last_user_seek, mid.[statement] AS [Database.Schema.Table], -mid.equality_columns, mid.inequality_columns, mid.included_columns, -migs.unique_compiles, migs.user_seeks, migs.avg_total_user_cost, migs.avg_user_impact +-- Missing Indexes for all databases by Index Advantage (Query 32) (Missing Indexes All Databases) +SELECT CONVERT(decimal(18,2), migs.user_seeks * migs.avg_total_user_cost * (migs.avg_user_impact * 0.01)) AS [index_advantage], +FORMAT(migs.last_user_seek, 'yyyy-MM-dd HH:mm:ss') AS [last_user_seek], mid.[statement] AS [Database.Schema.Table], +COUNT(1) OVER(PARTITION BY mid.[statement]) AS [missing_indexes_for_table], +COUNT(1) OVER(PARTITION BY mid.[statement], equality_columns) AS [similar_missing_indexes_for_table], +mid.equality_columns, mid.inequality_columns, mid.included_columns, migs.user_seeks, +CONVERT(decimal(18,2), migs.avg_total_user_cost) AS [avg_total_user_cost], migs.avg_user_impact FROM sys.dm_db_missing_index_group_stats AS migs WITH (NOLOCK) INNER JOIN sys.dm_db_missing_index_groups AS mig WITH (NOLOCK) ON migs.group_handle = mig.index_group_handle @@ -757,10 +821,14 @@ ORDER BY index_advantage DESC OPTION (RECOMPILE); -- Also look at avg_user_impact and avg_total_user_cost to help determine importance -- SQL Server is overly eager to add included columns, so beware -- Do not just blindly add indexes that show up from this query!!! +-- Hkan Winther has given me some great suggestions for this query + +-- SQL Server Index Design Guide +-- https://bit.ly/2qtZr4N --- Get VLF Counts for all databases on the instance (Query 34) (VLF Counts) +-- Get VLF Counts for all databases on the instance (Query 33) (VLF Counts) -- (adapted from Michelle Ufford) CREATE TABLE #VLFInfo (RecoveryUnitID int, FileID int, FileSize bigint, StartOffset bigint, @@ -793,11 +861,15 @@ DROP TABLE #VLFCountResults; -- Try to keep your VLF counts under 200 in most cases (depending on log file size) -- Important change to VLF creation algorithm in SQL Server 2014 --- https://www.sqlskills.com/blogs/paul/important-change-vlf-creation-algorithm-sql-server-2014/ +-- https://bit.ly/2Hsjbg4 + +-- SQL Server Transaction Log Architecture and Management Guide +-- https://bit.ly/2JjmQRZ + --- Get CPU utilization by database (Query 35) (CPU Usage by Database) +-- Get CPU utilization by database (Query 34) (CPU Usage by Database) WITH DB_CPU_Stats AS (SELECT pa.DatabaseID, DB_Name(pa.DatabaseID) AS [Database Name], SUM(qs.total_worker_time/1000) AS [CPU_Time_Ms] @@ -815,25 +887,34 @@ ORDER BY [CPU Rank] OPTION (RECOMPILE); ------ -- Helps determine which database is using the most CPU resources on the instance +-- Note: This only reflects CPU usage from the currently cached query plans --- Get I/O utilization by database (Query 36) (IO Usage By Database) +-- Get I/O utilization by database (Query 35) (IO Usage By Database) WITH Aggregate_IO_Statistics -AS -(SELECT DB_NAME(database_id) AS [Database Name], -CAST(SUM(num_of_bytes_read + num_of_bytes_written)/1048576 AS DECIMAL(12, 2)) AS io_in_mb -FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS [DM_IO_STATS] -GROUP BY database_id) -SELECT ROW_NUMBER() OVER(ORDER BY io_in_mb DESC) AS [I/O Rank], [Database Name], io_in_mb AS [Total I/O (MB)], - CAST(io_in_mb/ SUM(io_in_mb) OVER() * 100.0 AS DECIMAL(5,2)) AS [I/O Percent] +AS (SELECT DB_NAME(database_id) AS [Database Name], + CAST(SUM(num_of_bytes_read + num_of_bytes_written) / 1048576 AS DECIMAL(12, 2)) AS [ioTotalMB], + CAST(SUM(num_of_bytes_read ) / 1048576 AS DECIMAL(12, 2)) AS [ioReadMB], + CAST(SUM(num_of_bytes_written) / 1048576 AS DECIMAL(12, 2)) AS [ioWriteMB] + FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS [DM_IO_STATS] + GROUP BY database_id) +SELECT ROW_NUMBER() OVER (ORDER BY ioTotalMB DESC) AS [I/O Rank], + [Database Name], ioTotalMB AS [Total I/O (MB)], + CAST(ioTotalMB / SUM(ioTotalMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Total I/O %], + ioReadMB AS [Read I/O (MB)], + CAST(ioReadMB / SUM(ioReadMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Read I/O %], + ioWriteMB AS [Write I/O (MB)], + CAST(ioWriteMB / SUM(ioWriteMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Write I/O %] FROM Aggregate_IO_Statistics ORDER BY [I/O Rank] OPTION (RECOMPILE); ------ -- Helps determine which database is using the most I/O resources on the instance +-- These numbers are cumulative since the last service restart +-- They include all I/O activity, not just the nominal I/O workload --- Get total buffer usage by database for current instance (Query 37) (Total Buffer Usage by Database) +-- Get total buffer usage by database for current instance (Query 36) (Total Buffer Usage by Database) -- This make take some time to run on a busy instance WITH AggregateBufferPoolUsage AS @@ -855,7 +936,7 @@ ORDER BY [Buffer Pool Rank] OPTION (RECOMPILE); -- Clear Wait Stats with this command -- DBCC SQLPERF('sys.dm_os_wait_stats', CLEAR); --- Isolate top waits for server instance since last restart or wait statistics clear (Query 38) (Top Waits) +-- Isolate top waits for server instance since last restart or wait statistics clear (Query 37) (Top Waits) WITH [Waits] AS (SELECT wait_type, wait_time_ms/ 1000.0 AS [WaitS], (wait_time_ms - signal_wait_time_ms) / 1000.0 AS [ResourceS], @@ -910,24 +991,24 @@ OPTION (RECOMPILE); -- Cumulative wait stats are not as useful on an idle instance that is not under load or performance pressure --- SQL Server Wait Types Library (Paul Randal) --- https://www.sqlskills.com/help/waits/ +-- SQL Server Wait Types Library +-- https://bit.ly/2ePzYO2 -- The SQL Server Wait Type Repository --- http://blogs.msdn.com/b/psssql/archive/2009/11/03/the-sql-server-wait-type-repository.aspx +-- https://bit.ly/1afzfjC -- Wait statistics, or please tell me where it hurts --- https://www.sqlskills.com/blogs/paul/wait-statistics-or-please-tell-me-where-it-hurts/ +-- https://bit.ly/2wsQHQE -- SQL Server 2005 Performance Tuning using the Waits and Queues --- http://technet.microsoft.com/en-us/library/cc966413.aspx +-- https://bit.ly/1o2NFoF -- sys.dm_os_wait_stats (Transact-SQL) --- http://msdn.microsoft.com/en-us/library/ms179984(v=sql.120).aspx +-- https://bit.ly/2Hjq9Yl --- Get a count of SQL connections by IP address (Query 39) (Connection Counts by IP Address) +-- Get a count of SQL connections by IP address (Query 38) (Connection Counts by IP Address) SELECT ec.client_net_address, es.[program_name], es.[host_name], es.login_name, COUNT(ec.session_id) AS [connection count] FROM sys.dm_exec_sessions AS es WITH (NOLOCK) @@ -941,11 +1022,11 @@ ORDER BY ec.client_net_address, es.[program_name] OPTION (RECOMPILE); -- and verifies connectivity from other machines -- Solving Connectivity errors to SQL Server --- https://support.microsoft.com/en-us/help/4009936/solving-connectivity-errors-to-sql-server +-- https://bit.ly/2EgzoD0 --- Get Average Task Counts (run multiple times) (Query 40) (Avg Task Counts) +-- Get Average Task Counts (run multiple times) (Query 39) (Avg Task Counts) SELECT AVG(current_tasks_count) AS [Avg Task Count], AVG(work_queue_count) AS [Avg Work Queue Count], AVG(runnable_tasks_count) AS [Avg Runnable Task Count], @@ -962,11 +1043,11 @@ WHERE scheduler_id < 255 OPTION (RECOMPILE); -- High Avg Pending DiskIO Counts are a sign of disk pressure -- How to Do Some Very Basic SQL Server Monitoring --- https://www.sqlskills.com/blogs/glenn/how-to-do-some-very-basic-sql-server-monitoring/ +-- https://bit.ly/30IRla0 --- Detect blocking (run multiple times) (Query 41) (Detect Blocking) +-- Detect blocking (run multiple times) (Query 40) (Detect Blocking) SELECT t1.resource_type AS [lock type], DB_NAME(resource_database_id) AS [database], t1.resource_associated_entity_id AS [blk object],t1.request_mode AS [lock req], -- lock requested t1.request_session_id AS [waiter sid], t2.wait_duration_ms AS [wait time], -- spid of waiter @@ -995,7 +1076,7 @@ ON t1.lock_owner_address = t2.resource_address OPTION (RECOMPILE); --- Get CPU Utilization History for last 256 minutes (in one minute intervals) (Query 42) (CPU Utilization History) +-- Get CPU Utilization History for last 256 minutes (in one minute intervals) (Query 41) (CPU Utilization History) DECLARE @ts_now bigint = (SELECT cpu_ticks/(cpu_ticks/ms_ticks) FROM sys.dm_os_sys_info WITH (NOLOCK)); SELECT TOP(256) SQLProcessUtilization AS [SQL Server Process CPU Utilization], @@ -1016,10 +1097,11 @@ ORDER BY record_id DESC OPTION (RECOMPILE); -- Look at the trend over the entire period -- Also look at high sustained 'Other Process' CPU Utilization values +-- Note: This query sometimes gives inaccurate results (negative values) +-- on high core count (> 64 cores) systems - --- Get top total worker time queries for entire instance (Query 43) (Top Worker Time Queries) +-- Get top total worker time queries for entire instance (Query 42) (Top Worker Time Queries) SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], qs.total_worker_time AS [Total Worker Time], qs.min_worker_time AS [Min Worker Time], @@ -1031,7 +1113,9 @@ qs.max_elapsed_time AS [Max Elapsed Time], qs.min_logical_reads AS [Min Logical Reads], qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], qs.max_logical_reads AS [Max Logical Reads], -qs.execution_count AS [Execution Count], qs.creation_time AS [Creation Time] +qs.execution_count AS [Execution Count], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] --,t.[text] AS [Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t @@ -1045,8 +1129,9 @@ ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); --- Page Life Expectancy (PLE) value for each NUMA node in current instance (Query 44) (PLE by NUMA Node) -SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], instance_name, cntr_value AS [Page Life Expectancy] +-- Page Life Expectancy (PLE) value for each NUMA node in current instance (Query 43) (PLE by NUMA Node) +SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], + instance_name, cntr_value AS [Page Life Expectancy] FROM sys.dm_os_performance_counters WITH (NOLOCK) WHERE [object_name] LIKE N'%Buffer Node%' -- Handles named instances AND counter_name = N'Page life expectancy' OPTION (RECOMPILE); @@ -1057,10 +1142,10 @@ AND counter_name = N'Page life expectancy' OPTION (RECOMPILE); -- This will only return one row for non-NUMA systems -- Page Life Expectancy isnt what you think --- https://www.sqlskills.com/blogs/paul/page-life-expectancy-isnt-what-you-think/ +-- https://bit.ly/2EgynLa --- Memory Grants Pending value for current instance (Query 45) (Memory Grants Pending) +-- Memory Grants Pending value for current instance (Query 44) (Memory Grants Pending) SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], cntr_value AS [Memory Grants Pending] FROM sys.dm_os_performance_counters WITH (NOLOCK) WHERE [object_name] LIKE N'%Memory Manager%' -- Handles named instances @@ -1071,7 +1156,7 @@ AND counter_name = N'Memory Grants Pending' OPTION (RECOMPILE); -- Memory Grants Pending above zero for a sustained period is a very strong indicator of internal memory pressure --- Memory Clerk Usage for instance (Query 46) (Memory Clerk Usage) +-- Memory Clerk Usage for instance (Query 45) (Memory Clerk Usage) -- Look for high value for CACHESTORE_SQLCP (Ad-hoc query plans) SELECT TOP(10) mc.[type] AS [Memory Clerk Type], CAST((SUM(mc.pages_kb)/1024.0) AS DECIMAL (15,2)) AS [Memory Usage (MB)] @@ -1093,14 +1178,16 @@ ORDER BY SUM(mc.pages_kb) DESC OPTION (RECOMPILE); --- Find single-use, ad-hoc and prepared queries that are bloating the plan cache (Query 47) (Ad hoc Queries) -SELECT TOP(50) [text] AS [QueryText], cp.cacheobjtype, cp.objtype, cp.size_in_bytes/1024 AS [Plan Size in KB] +-- Find single-use, ad-hoc and prepared queries that are bloating the plan cache (Query 46) (Ad hoc Queries) +SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], t.[text] AS [Query Text], +cp.objtype AS [Object Type], cp.cacheobjtype AS [Cache Object Type], +cp.size_in_bytes/1024 AS [Plan Size in KB] FROM sys.dm_exec_cached_plans AS cp WITH (NOLOCK) -CROSS APPLY sys.dm_exec_sql_text(plan_handle) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t WHERE cp.cacheobjtype = N'Compiled Plan' AND cp.objtype IN (N'Adhoc', N'Prepared') AND cp.usecounts = 1 -ORDER BY cp.size_in_bytes DESC OPTION (RECOMPILE); +ORDER BY cp.size_in_bytes DESC, DB_NAME(t.[dbid]) OPTION (RECOMPILE); ------ -- Gives you the text, type and size of single-use ad-hoc and prepared queries that waste space in the plan cache @@ -1109,10 +1196,10 @@ ORDER BY cp.size_in_bytes DESC OPTION (RECOMPILE); -- Enabling forced parameterization for the database can help, but test first! -- Plan cache, adhoc workloads and clearing the single-use plan cache bloat --- https://www.sqlskills.com/blogs/kimberly/plan-cache-adhoc-workloads-and-clearing-the-single-use-plan-cache-bloat/ +-- https://bit.ly/2EfYOkl --- Get top total logical reads queries for entire instance (Query 48) (Top Logical Reads Queries) +-- Get top total logical reads queries for entire instance (Query 47) (Top Logical Reads Queries) SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], qs.total_logical_reads AS [Total Logical Reads], @@ -1125,7 +1212,9 @@ qs.max_worker_time AS [Max Worker Time], qs.min_elapsed_time AS [Min Elapsed Time], qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], qs.max_elapsed_time AS [Max Elapsed Time], -qs.execution_count AS [Execution Count], qs.creation_time AS [Creation Time] +qs.execution_count AS [Execution Count], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] --,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t @@ -1138,7 +1227,7 @@ ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE); -- Can also help track down parameter sniffing issues --- Get top average elapsed time queries for entire instance (Query 49) (Top Avg Elapsed Time Queries) +-- Get top average elapsed time queries for entire instance (Query 48) (Top Avg Elapsed Time Queries) SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], @@ -1147,8 +1236,9 @@ qs.execution_count AS [Execution Count], qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], qs.total_physical_reads/qs.execution_count AS [Avg Physical Reads], qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], qs.creation_time AS [Creation Time] -, qp.query_plan AS [Query Plan] -- comment out this column if copying results to Excel +--,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp @@ -1167,11 +1257,14 @@ ORDER BY qs.total_elapsed_time/qs.execution_count DESC OPTION (RECOMPILE); --USE YourDatabaseName; -- make sure to change to an actual database on your instance, not the master system database --GO --- Individual File Sizes and space available for current database (Query 50) (File Sizes and Space) +-- Individual File Sizes and space available for current database (Query 49) (File Sizes and Space) SELECT f.name AS [File Name] , f.physical_name AS [Physical Name], CAST((f.size/128.0) AS DECIMAL(15,2)) AS [Total Size in MB], CAST(f.size/128.0 - CAST(FILEPROPERTY(f.name, 'SpaceUsed') AS int)/128.0 AS DECIMAL(15,2)) -AS [Available Space In MB], f.[file_id], fg.name AS [Filegroup Name], +AS [Available Space In MB], +CAST((f.size/128.0) AS DECIMAL(15,2)) - +CAST(f.size/128.0 - CAST(FILEPROPERTY(f.name, 'SpaceUsed') AS int)/128.0 AS DECIMAL(15,2)) AS [Used Space in MB], +f.[file_id], fg.name AS [Filegroup Name], f.is_percent_growth, f.growth, fg.is_default, fg.is_read_only FROM sys.database_files AS f WITH (NOLOCK) LEFT OUTER JOIN sys.filegroups AS fg WITH (NOLOCK) @@ -1183,7 +1276,7 @@ ORDER BY f.[file_id] OPTION (RECOMPILE); -- Make sure the transaction log is not full!! --- Log space usage for current database (Query 51) (Log Space Usage) +-- Log space usage for current database (Query 50) (Log Space Usage) SELECT DB_NAME(lsu.database_id) AS [Database Name], db.recovery_model_desc AS [Recovery Model], CAST(lsu.total_log_size_in_bytes/1048576.0 AS DECIMAL(10, 2)) AS [Total Log Space (MB)], CAST(lsu.used_log_space_in_bytes/1048576.0 AS DECIMAL(10, 2)) AS [Used Log Space (MB)], @@ -1198,20 +1291,23 @@ OPTION (RECOMPILE); -- Look at log file size and usage, along with the log reuse wait description for the current database +-- sys.dm_db_log_space_usage (Transact-SQL) +-- https://bit.ly/2H4MQw9 --- I/O Statistics by file for the current database (Query 52) (IO Stats By File) + +-- I/O Statistics by file for the current database (Query 51) (IO Stats By File) SELECT DB_NAME(DB_ID()) AS [Database Name], df.name AS [Logical Name], vfs.[file_id], df.type_desc, -df.physical_name AS [Physical Name], CAST(vfs.size_on_disk_bytes/1048576.0 AS DECIMAL(10, 2)) AS [Size on Disk (MB)], +df.physical_name AS [Physical Name], CAST(vfs.size_on_disk_bytes/1048576.0 AS DECIMAL(16, 2)) AS [Size on Disk (MB)], vfs.num_of_reads, vfs.num_of_writes, vfs.io_stall_read_ms, vfs.io_stall_write_ms, -CAST(100. * vfs.io_stall_read_ms/(vfs.io_stall_read_ms + vfs.io_stall_write_ms) AS DECIMAL(10,1)) AS [IO Stall Reads Pct], -CAST(100. * vfs.io_stall_write_ms/(vfs.io_stall_write_ms + vfs.io_stall_read_ms) AS DECIMAL(10,1)) AS [IO Stall Writes Pct], +CAST(100. * vfs.io_stall_read_ms/(vfs.io_stall_read_ms + vfs.io_stall_write_ms) AS DECIMAL(16,1)) AS [IO Stall Reads Pct], +CAST(100. * vfs.io_stall_write_ms/(vfs.io_stall_write_ms + vfs.io_stall_read_ms) AS DECIMAL(16,1)) AS [IO Stall Writes Pct], (vfs.num_of_reads + vfs.num_of_writes) AS [Writes + Reads], -CAST(vfs.num_of_bytes_read/1048576.0 AS DECIMAL(10, 2)) AS [MB Read], -CAST(vfs.num_of_bytes_written/1048576.0 AS DECIMAL(10, 2)) AS [MB Written], -CAST(100. * vfs.num_of_reads/(vfs.num_of_reads + vfs.num_of_writes) AS DECIMAL(10,1)) AS [# Reads Pct], -CAST(100. * vfs.num_of_writes/(vfs.num_of_reads + vfs.num_of_writes) AS DECIMAL(10,1)) AS [# Write Pct], -CAST(100. * vfs.num_of_bytes_read/(vfs.num_of_bytes_read + vfs.num_of_bytes_written) AS DECIMAL(10,1)) AS [Read Bytes Pct], -CAST(100. * vfs.num_of_bytes_written/(vfs.num_of_bytes_read + vfs.num_of_bytes_written) AS DECIMAL(10,1)) AS [Written Bytes Pct] +CAST(vfs.num_of_bytes_read/1048576.0 AS DECIMAL(16, 2)) AS [MB Read], +CAST(vfs.num_of_bytes_written/1048576.0 AS DECIMAL(16, 2)) AS [MB Written], +CAST(100. * vfs.num_of_reads/(vfs.num_of_reads + vfs.num_of_writes) AS DECIMAL(16,1)) AS [# Reads Pct], +CAST(100. * vfs.num_of_writes/(vfs.num_of_reads + vfs.num_of_writes) AS DECIMAL(16,1)) AS [# Write Pct], +CAST(100. * vfs.num_of_bytes_read/(vfs.num_of_bytes_read + vfs.num_of_bytes_written) AS DECIMAL(16,1)) AS [Read Bytes Pct], +CAST(100. * vfs.num_of_bytes_written/(vfs.num_of_bytes_read + vfs.num_of_bytes_written) AS DECIMAL(16,1)) AS [Written Bytes Pct] FROM sys.dm_io_virtual_file_stats(DB_ID(), NULL) AS vfs INNER JOIN sys.database_files AS df WITH (NOLOCK) ON vfs.[file_id]= df.[file_id] OPTION (RECOMPILE); @@ -1222,14 +1318,15 @@ ON vfs.[file_id]= df.[file_id] OPTION (RECOMPILE); --- Get most frequently executed queries for this database (Query 53) (Query Execution Counts) +-- Get most frequently executed queries for this database (Query 52) (Query Execution Counts) SELECT TOP(50) LEFT(t.[text], 50) AS [Short Query Text], qs.execution_count AS [Execution Count], qs.total_logical_reads AS [Total Logical Reads], qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], qs.total_worker_time AS [Total Worker Time], qs.total_worker_time/qs.execution_count AS [Avg Worker Time], qs.total_elapsed_time AS [Total Elapsed Time], -qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], qs.creation_time AS [Creation Time] --,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) @@ -1240,16 +1337,22 @@ ORDER BY qs.execution_count DESC OPTION (RECOMPILE); ------ --- Queries 53 through 57 are the "Bad Man List" for stored procedures --- Top Cached SPs By Execution Count (Query 54) (SP Execution Counts) -SELECT TOP(100) p.name AS [SP Name], qs.execution_count, +-- Queries 53 through 59 are the "Bad Man List" for stored procedures + +-- Top Cached SPs By Execution Count (Query 53) (SP Execution Counts) +SELECT TOP(100) p.name AS [SP Name], qs.execution_count AS [Execution Count], ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], -qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], qs.total_worker_time AS [TotalWorkerTime], -qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], -qs.cached_time +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 ORDER BY qs.execution_count DESC OPTION (RECOMPILE); @@ -1257,17 +1360,23 @@ ORDER BY qs.execution_count DESC OPTION (RECOMPILE); -- Tells you which cached stored procedures are called the most often -- This helps you characterize and baseline your workload +-- It also helps you find possible caching opportunities --- Top Cached SPs By Avg Elapsed Time (Query 55) (SP Avg Elapsed Time) +-- Top Cached SPs By Avg Elapsed Time (Query 54) (SP Avg Elapsed Time) SELECT TOP(25) p.name AS [SP Name], qs.min_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], qs.max_elapsed_time, qs.last_elapsed_time, qs.total_elapsed_time, qs.execution_count, ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], -qs.total_worker_time AS [TotalWorkerTime], qs.cached_time +qs.total_worker_time AS [TotalWorkerTime], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 ORDER BY avg_elapsed_time DESC OPTION (RECOMPILE); @@ -1278,15 +1387,19 @@ ORDER BY avg_elapsed_time DESC OPTION (RECOMPILE); --- Top Cached SPs By Total Worker time. Worker time relates to CPU cost (Query 56) (SP Worker Time) +-- Top Cached SPs By Total Worker time. Worker time relates to CPU cost (Query 55) (SP Worker Time) SELECT TOP(25) p.name AS [SP Name], qs.total_worker_time AS [TotalWorkerTime], qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], qs.execution_count, ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], -qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count -AS [avg_elapsed_time], qs.cached_time +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); @@ -1296,15 +1409,19 @@ ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); -- You should look at this if you see signs of CPU pressure --- Top Cached SPs By Total Logical Reads. Logical reads relate to memory pressure (Query 57) (SP Logical Reads) +-- Top Cached SPs By Total Logical Reads. Logical reads relate to memory pressure (Query 56) (SP Logical Reads) SELECT TOP(25) p.name AS [SP Name], qs.total_logical_reads AS [TotalLogicalReads], qs.total_logical_reads/qs.execution_count AS [AvgLogicalReads],qs.execution_count, ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], -qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count -AS [avg_elapsed_time], qs.cached_time +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE); @@ -1314,14 +1431,18 @@ ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE); -- You should look at this if you see signs of memory pressure --- Top Cached SPs By Total Physical Reads. Physical reads relate to disk read I/O pressure (Query 58) (SP Physical Reads) +-- Top Cached SPs By Total Physical Reads. Physical reads relate to disk read I/O pressure (Query 57) (SP Physical Reads) SELECT TOP(25) p.name AS [SP Name],qs.total_physical_reads AS [TotalPhysicalReads], qs.total_physical_reads/qs.execution_count AS [AvgPhysicalReads], qs.execution_count, -qs.total_logical_reads,qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count -AS [avg_elapsed_time], qs.cached_time +qs.total_logical_reads,qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND qs.total_physical_reads > 0 ORDER BY qs.total_physical_reads DESC, qs.total_logical_reads DESC OPTION (RECOMPILE); @@ -1332,16 +1453,20 @@ ORDER BY qs.total_physical_reads DESC, qs.total_logical_reads DESC OPTION (RECOM --- Top Cached SPs By Total Logical Writes (Query 59) (SP Logical Writes) +-- Top Cached SPs By Total Logical Writes (Query 58) (SP Logical Writes) -- Logical writes relate to both memory and disk I/O pressure SELECT TOP(25) p.name AS [SP Name], qs.total_logical_writes AS [TotalLogicalWrites], qs.total_logical_writes/qs.execution_count AS [AvgLogicalWrites], qs.execution_count, ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], -qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], -qs.cached_time +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND qs.total_logical_writes > 0 AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 @@ -1352,6 +1477,31 @@ ORDER BY qs.total_logical_writes DESC OPTION (RECOMPILE); -- You should look at this if you see signs of I/O pressure or of memory pressure + +-- Cached SPs Missing Indexes by Execution Count (Query 59) (SP Missing Index) +SELECT TOP(25) p.name AS [SP Name], qs.execution_count AS [Execution Count], +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +AND CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' +ORDER BY qs.execution_count DESC OPTION (RECOMPILE); +------ + +-- This helps you find the most frequently executed cached stored procedures that have missing index warnings +-- This can often help you find index tuning candidates + + + -- Lists the top statements by average input/output usage for the current database (Query 60) (Top IO Statements) SELECT TOP(50) OBJECT_NAME(qt.objectid, dbid) AS [SP Name], (qs.total_logical_reads + qs.total_logical_writes) /qs.execution_count AS [Avg IO], qs.execution_count AS [Execution Count], @@ -1372,18 +1522,23 @@ ORDER BY [Avg IO] DESC OPTION (RECOMPILE); -- Possible Bad NC Indexes (writes > reads) (Query 61) (Bad NC Indexes) -SELECT OBJECT_NAME(s.[object_id]) AS [Table Name], i.name AS [Index Name], i.index_id, +SELECT SCHEMA_NAME(o.[schema_id]) AS [Schema Name], +OBJECT_NAME(s.[object_id]) AS [Table Name], +i.name AS [Index Name], i.index_id, i.is_disabled, i.is_hypothetical, i.has_filter, i.fill_factor, -user_updates AS [Total Writes], user_seeks + user_scans + user_lookups AS [Total Reads], -user_updates - (user_seeks + user_scans + user_lookups) AS [Difference] +s.user_updates AS [Total Writes], s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], +s.user_updates - (s.user_seeks + s.user_scans + s.user_lookups) AS [Difference] FROM sys.dm_db_index_usage_stats AS s WITH (NOLOCK) INNER JOIN sys.indexes AS i WITH (NOLOCK) ON s.[object_id] = i.[object_id] AND i.index_id = s.index_id +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON i.[object_id] = o.[object_id] WHERE OBJECTPROPERTY(s.[object_id],'IsUserTable') = 1 AND s.database_id = DB_ID() -AND user_updates > (user_seeks + user_scans + user_lookups) -AND i.index_id > 1 +AND s.user_updates > (s.user_seeks + s.user_scans + s.user_lookups) +AND i.index_id > 1 AND i.[type_desc] = N'NONCLUSTERED' +AND i.is_primary_key = 0 AND i.is_unique_constraint = 0 AND i.is_unique = 0 ORDER BY [Difference] DESC, [Total Writes] DESC, [Total Reads] ASC OPTION (RECOMPILE); ------ @@ -1393,10 +1548,10 @@ ORDER BY [Difference] DESC, [Total Writes] DESC, [Total Reads] ASC OPTION (RECOM -- Missing Indexes for current database by Index Advantage (Query 62) (Missing Indexes) -SELECT DISTINCT CONVERT(decimal(18,2), user_seeks * avg_total_user_cost * (avg_user_impact * 0.01)) AS [index_advantage], +SELECT DISTINCT CONVERT(decimal(18,2), migs.user_seeks * migs.avg_total_user_cost * (migs.avg_user_impact * 0.01)) AS [index_advantage], migs.last_user_seek, mid.[statement] AS [Database.Schema.Table], mid.equality_columns, mid.inequality_columns, mid.included_columns, -migs.unique_compiles, migs.user_seeks, migs.avg_total_user_cost, migs.avg_user_impact, +migs.user_seeks, migs.avg_total_user_cost, migs.avg_user_impact, OBJECT_NAME(mid.[object_id]) AS [Table Name], p.rows AS [Table Rows] FROM sys.dm_db_missing_index_group_stats AS migs WITH (NOLOCK) INNER JOIN sys.dm_db_missing_index_groups AS mig WITH (NOLOCK) @@ -1413,12 +1568,13 @@ ORDER BY index_advantage DESC OPTION (RECOMPILE); -- Look at index advantage, last user seek time, number of user seeks to help determine source and importance -- SQL Server is overly eager to add included columns, so beware -- Do not just blindly add indexes that show up from this query!!! +-- Hkan Winther has given me some great suggestions for this query -- Find missing index warnings for cached plans in the current database (Query 63) (Missing Index Warnings) -- Note: This query could take some time on a busy instance SELECT TOP(25) OBJECT_NAME(objectid) AS [ObjectName], - cp.objtype, cp.usecounts, cp.size_in_bytes, query_plan + cp.objtype, cp.usecounts, cp.size_in_bytes, qp.query_plan FROM sys.dm_exec_cached_plans AS cp WITH (NOLOCK) CROSS APPLY sys.dm_exec_query_plan(cp.plan_handle) AS qp WHERE CAST(query_plan AS NVARCHAR(MAX)) LIKE N'%MissingIndex%' @@ -1432,7 +1588,8 @@ ORDER BY cp.usecounts DESC OPTION (RECOMPILE); -- Breaks down buffers used by current database by object (table, index) in the buffer cache (Query 64) (Buffer Usage) -- Note: This query could take some time on a busy instance -SELECT OBJECT_NAME(p.[object_id]) AS [Object Name], p.index_id, +SELECT fg.name AS [Filegroup Name], SCHEMA_NAME(o.Schema_ID) AS [Schema Name], +OBJECT_NAME(p.[object_id]) AS [Object Name], p.index_id, CAST(COUNT(*)/128.0 AS DECIMAL(10, 2)) AS [Buffer size(MB)], COUNT(*) AS [BufferCount], p.[Rows] AS [Row Count], p.data_compression_desc AS [Compression Type] @@ -1441,12 +1598,19 @@ INNER JOIN sys.dm_os_buffer_descriptors AS b WITH (NOLOCK) ON a.allocation_unit_id = b.allocation_unit_id INNER JOIN sys.partitions AS p WITH (NOLOCK) ON a.container_id = p.hobt_id +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON p.object_id = o.object_id +INNER JOIN sys.database_files AS f WITH (NOLOCK) +ON b.file_id = f.file_id +INNER JOIN sys.filegroups AS fg WITH (NOLOCK) +ON f.data_space_id = fg.data_space_id WHERE b.database_id = CONVERT(int, DB_ID()) AND p.[object_id] > 100 AND OBJECT_NAME(p.[object_id]) NOT LIKE N'plan_%' AND OBJECT_NAME(p.[object_id]) NOT LIKE N'sys%' AND OBJECT_NAME(p.[object_id]) NOT LIKE N'xml_index_nodes%' -GROUP BY p.[object_id], p.index_id, p.data_compression_desc, p.[Rows] +GROUP BY fg.name, o.Schema_ID, p.[object_id], p.index_id, + p.data_compression_desc, p.[Rows] ORDER BY [BufferCount] DESC OPTION (RECOMPILE); ------ @@ -1455,21 +1619,24 @@ ORDER BY [BufferCount] DESC OPTION (RECOMPILE); -- Get Table names, row counts, and compression status for clustered index or heap (Query 65) (Table Sizes) -SELECT OBJECT_NAME(object_id) AS [ObjectName], -SUM(Rows) AS [RowCount], data_compression_desc AS [CompressionType] -FROM sys.partitions WITH (NOLOCK) +SELECT SCHEMA_NAME(o.Schema_ID) AS [Schema Name], OBJECT_NAME(p.object_id) AS [ObjectName], +SUM(p.Rows) AS [RowCount], p.data_compression_desc AS [Compression Type] +FROM sys.partitions AS p WITH (NOLOCK) +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON p.object_id = o.object_id WHERE index_id < 2 --ignore the partitions from the non-clustered index if any -AND OBJECT_NAME(object_id) NOT LIKE N'sys%' -AND OBJECT_NAME(object_id) NOT LIKE N'queue_%' -AND OBJECT_NAME(object_id) NOT LIKE N'filestream_tombstone%' -AND OBJECT_NAME(object_id) NOT LIKE N'fulltext%' -AND OBJECT_NAME(object_id) NOT LIKE N'ifts_comp_fragment%' -AND OBJECT_NAME(object_id) NOT LIKE N'filetable_updates%' -AND OBJECT_NAME(object_id) NOT LIKE N'xml_index_nodes%' -AND OBJECT_NAME(object_id) NOT LIKE N'sqlagent_job%' -AND OBJECT_NAME(object_id) NOT LIKE N'plan_persist%' -GROUP BY object_id, data_compression_desc -ORDER BY SUM(Rows) DESC OPTION (RECOMPILE); +AND OBJECT_NAME(p.object_id) NOT LIKE N'sys%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'spt_%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'queue_%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'filestream_tombstone%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'fulltext%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'ifts_comp_fragment%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'filetable_updates%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'xml_index_nodes%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'sqlagent_job%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'plan_persist%' +GROUP BY SCHEMA_NAME(o.Schema_ID), p.object_id, data_compression_desc +ORDER BY SUM(p.Rows) DESC OPTION (RECOMPILE); ------ -- Gives you an idea of table sizes, and possible data compression opportunities @@ -1517,7 +1684,11 @@ ORDER BY STATS_DATE(i.[object_id], i.index_id) DESC OPTION (RECOMPILE); -- Also gives you an idea which indexes are the most active -- sys.stats (Transact-SQL) --- https://msdn.microsoft.com/en-us/library/ms177623.aspx +-- https://bit.ly/2GyAxrn + +-- UPDATEs to Statistics (Erin Stellato) +-- https://bit.ly/2vhrYQy + @@ -1562,7 +1733,8 @@ ORDER BY ps.avg_fragmentation_in_percent DESC OPTION (RECOMPILE); --- Index Read/Write stats (all tables in current DB) ordered by Reads (Query 70) (Overall Index Usage - Reads) -SELECT OBJECT_NAME(i.[object_id]) AS [ObjectName], i.[name] AS [IndexName], i.index_id, +SELECT SCHEMA_NAME(t.[schema_id]) AS [SchemaName], OBJECT_NAME(i.[object_id]) AS [ObjectName], + i.[name] AS [IndexName], i.index_id, s.user_seeks, s.user_scans, s.user_lookups, s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], s.user_updates AS [Writes], @@ -1573,6 +1745,8 @@ LEFT OUTER JOIN sys.dm_db_index_usage_stats AS s WITH (NOLOCK) ON i.[object_id] = s.[object_id] AND i.index_id = s.index_id AND s.database_id = DB_ID() +LEFT OUTER JOIN sys.tables AS t WITH (NOLOCK) +ON t.[object_id] = i.[object_id] WHERE OBJECTPROPERTY(i.[object_id],'IsUserTable') = 1 ORDER BY s.user_seeks + s.user_scans + s.user_lookups DESC OPTION (RECOMPILE); -- Order by reads ------ @@ -1581,7 +1755,8 @@ ORDER BY s.user_seeks + s.user_scans + s.user_lookups DESC OPTION (RECOMPILE); - --- Index Read/Write stats (all tables in current DB) ordered by Writes (Query 71) (Overall Index Usage - Writes) -SELECT OBJECT_NAME(i.[object_id]) AS [ObjectName], i.[name] AS [IndexName], i.index_id, +SELECT SCHEMA_NAME(t.[schema_id]) AS [SchemaName],OBJECT_NAME(i.[object_id]) AS [ObjectName], + i.[name] AS [IndexName], i.index_id, s.user_updates AS [Writes], s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], i.[type_desc] AS [Index Type], i.fill_factor AS [Fill Factor], i.has_filter, i.filter_definition, s.last_system_update, s.last_user_update @@ -1590,6 +1765,8 @@ LEFT OUTER JOIN sys.dm_db_index_usage_stats AS s WITH (NOLOCK) ON i.[object_id] = s.[object_id] AND i.index_id = s.index_id AND s.database_id = DB_ID() +LEFT OUTER JOIN sys.tables AS t WITH (NOLOCK) +ON t.[object_id] = i.[object_id] WHERE OBJECTPROPERTY(i.[object_id],'IsUserTable') = 1 ORDER BY s.user_updates DESC OPTION (RECOMPILE); -- Order by writes ------ @@ -1612,7 +1789,7 @@ ORDER BY OBJECT_NAME(i.[object_id]) OPTION (RECOMPILE); -- Returns no data if you are not using in-memory OLTP -- Guidelines for Using Indexes on Memory-Optimized Tables --- https://msdn.microsoft.com/en-us/library/dn133166.aspx +-- https://bit.ly/2GCP8lF -- Get lock waits for current database (Query 73) (Lock Waits) @@ -1652,7 +1829,7 @@ AND es.session_id <> @@SPID OPTION (RECOMPILE); -- Requires SQL Server 2014 SP2 or later -- New DMF for retrieving input buffer in SQL Server --- https://blogs.msdn.microsoft.com/sql_server_team/new-dmf-for-retrieving-input-buffer-in-sql-server/ +-- https://bit.ly/2uHKMbz -- Look at recent Full backups for the current database (Query 75) (Recent Full Backups) @@ -1679,29 +1856,10 @@ ORDER BY bs.backup_finish_date DESC OPTION (RECOMPILE); -- Have you done any backup tuning with striped backups, or changing the parameters of the backup command? --- These three Pluralsight Courses go into more detail about how to run these queries and interpret the results - --- SQL Server 2014 DMV Diagnostic Queries Part 1 --- https://www.pluralsight.com/courses/sql-server-2014-dmv-diagnostic-queries-part1 - --- SQL Server 2014 DMV Diagnostic Queries Part 2 --- https://www.pluralsight.com/courses/sql-server-2014-dmv-diagnostic-queries-part2 - --- SQL Server 2014 DMV Diagnostic Queries Part 3 --- https://www.pluralsight.com/courses/sql-server-2014-dmv-diagnostic-queries-part3 - - --- Sign up for Microsoft Visual Studio Dev Essentials and get a free three month pass to Pluralsight - -- Microsoft Visual Studio Dev Essentials --- http://bit.ly/1q6xbDL - - --- Sign up for Microsoft IT Pro Cloud Essentials and get lots of free Azure usage credits, MCP exam voucher, three month Pluralsight subscription +-- https://bit.ly/2qjNRxi --- Microsoft IT Pro Cloud Essentials --- http://bit.ly/2443SAd +-- Microsoft Azure Learn +-- https://bit.ly/2O0Hacc --- August 2017 blog series about upgrading and migrating SQL Server --- https://www.sqlskills.com/blogs/glenn/category/upgrading-sql-server/ diff --git a/Scripts/SQL Server 2016 Diagnostic Information Queries.sql b/Scripts/SQL Server 2016 Diagnostic Information Queries.sql index 21c934ab..0d8bc109 100644 --- a/Scripts/SQL Server 2016 Diagnostic Information Queries.sql +++ b/Scripts/SQL Server 2016 Diagnostic Information Queries.sql @@ -1,7 +1,7 @@ -- SQL Server 2016 Diagnostic Information Queries -- Glenn Berry --- Last Modified: December 7, 2017 +-- Last Modified: December 4, 2019 -- https://www.sqlskills.com/blogs/glenn/ -- http://sqlserverperformance.wordpress.com/ -- Twitter: GlennAlanBerry @@ -15,8 +15,15 @@ -- Please make sure you are using the correct version of these diagnostic queries for your version of SQL Server +-- If you like PowerShell, there is a very useful community solution for running these queries in an automated fashion +-- https://dbatools.io/ + +-- Invoke-DbaDiagnosticQuery +-- https://dbatools.io/functions/invoke-dbadiagnosticquery/ + + --****************************************************************************** ---* Copyright (C) 2017 Glenn Berry, SQLskills.com +--* Copyright (C) 2019 Glenn Berry, SQLskills.com --* All rights reserved. --* --* For more scripts and sample code, check out @@ -49,8 +56,8 @@ IF NOT EXISTS (SELECT * WHERE CONVERT(varchar(128), SERVERPROPERTY('ProductVersi SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version Info]; ------ --- SQL Server 2016 RTM Branch Builds -- SQL Server 2016 SP1 Branch Builds --- Build Description Release Date Build Description Release Date +-- SQL Server 2016 RTM Branch Builds -- SQL Server 2016 SP1 Branch Builds -- SQL Server 2016 SP2 Branch Builds +-- Build Description Release Date Build Description Release Date Build Description Release Date -- 13.0.200.172 CTP 2.0 5/26/2015 -- 13.0.300.44 CTP 2.1 6/14/2015 -- 13.0.407.1 CTP 2.2 7/28/2015 @@ -71,41 +78,51 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In -- 13.0.2193.0 RTM CU4 1/18/2017 ----> 13.0.4411.0 SP1 CU1 1/18/2017 -- 13.0.2197.0 RTM CU5 3/20/2017 ----> 13.0.4422.0 SP1 CU2 3/20/2017 -- 13.0.2204.0 RTM CU6 5/15/2017 ----> 13.0.4435.0 SP1 CU3 5/15/2017 --- 13.0.2210.0 RTM CU7 8/8/2017 ----> 13.0.4446.0 SP1 CU4 8/8/2017 +-- 13.0.2210.0 RTM CU7 8/8/2017 ----> 13.0.4446.0 SP1 CU4 8/8/2017 -- 13.0.2213.0 RTM CU8 9/18/2017 ----> 13.0.4451.0 SP1 CU5 9/18/2017 -- 13.0.2216.0 RTM CU9 11/21/2017 ----> 13.0.4457.0 SP1 CU6 11/21/2017 +-- 13.0.4466.4 SP1 CU7 1/4/2018 +-- 13.0.4474.0 SP1 CU8 3/20/2018 ----> 13.0.5026.0 SP2 RTM 4/24/2018 +-- 13.0.4502.0 SP1 CU9 5/30/2018 ----> 13.0.5149.0 SP2 CU1 5/30/2018 +-- 13.0.4514.0 SP1 CU10 7/16/2018 ----> 13.0.5153.0 SP2 CU2 7/16/2018 +-- 13.0.4528.0 SP1 CU11 9/17/2018 ----> 13.0.5216.0 SP2 CU3 9/20/2018 +-- 13.0.4541.0 SP1 CU12 11/13/2018 ----> 13.0.5233.0 SP2 CU4 11/13/2018 +-- 13.0.4550.1 SP1 CU13 1/23/2019 ----> 13.0.5264.1 SP2 CU5 1/23/2019 +-- 13.0.4560.0 SP1 CU14 3/19/2019 ----> 13.0.5292.0 SP2 CU6 3/19/2019 +-- 13.0.4574.0 SP1 CU15 5/16/2019 ----> 13.0.5337.0 SP2 CU7 5/22/2019 +-- 13.0.5426.0 SP2 CU8 7/31/2019 +-- 13.0.5470.0 SP2 CU9 9/30/2019 +-- 13.0.5492.2 SP2 CU10 10/8/2019 -- How to determine the version, edition and update level of SQL Server and its components --- https://support.microsoft.com/en-us/kb/321185 +-- https://bit.ly/2oAjKgW -- How to obtain the latest Service Pack for SQL Server 2016 --- https://support.microsoft.com/en-us/kb/3177534 - --- Microsoft SQL Server 2016 SP1 Latest Cumulative Update --- https://www.microsoft.com/en-us/download/details.aspx?id=54613 +-- https://bit.ly/2egtfzK -- SQL Server 2016 build versions --- https://support.microsoft.com/en-us/kb/3177312 +-- https://bit.ly/2epkTDT --- Where to find information about the latest SQL Server builds --- https://support.microsoft.com/en-us/help/957826/where-to-find-information-about-the-latest-sql-server-builds +-- Recommended updates and configuration options for SQL Server 2017 and 2016 with high-performance workloads +-- https://bit.ly/2JsReue -- Performance and Stability Related Fixes in Post-SQL Server 2016 SP1 Builds --- https://www.sqlskills.com/blogs/glenn/performance-and-stability-related-fixes-in-post-sql-server-2016-sp1-builds/ +-- https://bit.ly/2gr7k9L --- Announcing updates to the SQL Server Incremental Servicing Model (ISM) --- https://blogs.msdn.microsoft.com/sqlreleaseservices/announcing-updates-to-the-sql-server-incremental-servicing-model-ism/ +-- Performance and Stability Related Fixes in Post-SQL Server 2016 SP2 Builds +-- https://bit.ly/2K3LoPf -- Update Center for Microsoft SQL Server --- http://bit.ly/2pZptuQ +-- https://bit.ly/2pZptuQ -- Download SQL Server Management Studio (SSMS) --- https://msdn.microsoft.com/en-us/library/mt238290.aspx +-- https://bit.ly/1OcupT9 --- Download and install Microsoft SQL Operations Studio --- https://docs.microsoft.com/en-us/sql/sql-operations-studio/download +-- Download and install Azure Data Studio +-- https://bit.ly/2vgke1A +-- SQL Server 2016 Configuration Manager is SQLServerManager13.msc -- Get socket, physical core and logical core count from the SQL Server Error log. (Query 2) (Core Counts) @@ -156,7 +173,7 @@ SERVERPROPERTY('IsAdvancedAnalyticsInstalled') AS [IsRServicesInstalled]; -- New -- Note: Some columns will be NULL on older SQL Server builds -- SERVERPROPERTY (Transact-SQL) --- http://bit.ly/2eeaXeI +-- https://bit.ly/2eeaXeI @@ -188,7 +205,7 @@ ORDER BY name OPTION (RECOMPILE); -- remote data archive (Allow the use of the REMOTE_DATA_ARCHIVE data access for Stretch databases) -- SQLSweet16!, Episode 1: Backup Compression for TDE-enabled Databases --- https://blogs.msdn.microsoft.com/sqlcat/2016/06/20/sqlsweet16-episode-1-backup-compression-for-tde-enabled-databases/ +-- https://bit.ly/28Rpb2x @@ -200,44 +217,42 @@ DBCC TRACESTATUS (-1); -- It is very useful to know what global trace flags are currently enabled as part of the diagnostic process. -- Common trace flags that should be enabled in most cases +-- TF 460 - Improvement: Optional replacement for "String or binary data would be truncated" message with extended information in SQL Server 2017 +-- https://bit.ly/2sboMli (added in SP2 CU6) + -- TF 3226 - Supresses logging of successful database backup messages to the SQL Server Error Log --- https://www.sqlskills.com/blogs/paul/fed-up-with-backup-success-messages-bloating-your-error-logs/ +-- https://bit.ly/2p6MTjS -- TF 6534 - Enables use of native code to improve performance with spatial data --- https://blogs.msdn.microsoft.com/bobsql/2016/06/03/sql-2016-it-just-runs-faster-native-spatial-implementations/ +-- https://bit.ly/2HrQUpU + +-- TF 7745 - Prevents Query Store data from being written to disk in case of a failover or shutdown command +-- https://bit.ly/2GU69Km + +-- TF 7752 - Enables asynchronous load of Query Store +-- This allows a database to become online and queries to be executed before the Query Store has been fully recovered -- The behavior of TF 1117, 1118 are enabled for tempdb in SQL Server 2016 by default -- SQL 2016 It Just Runs Faster: -T1117 and -T1118 changes for TEMPDB and user databases --- https://blogs.msdn.microsoft.com/psssql/2016/03/15/sql-2016-it-just-runs-faster-t1117-and-t1118-changes-for-tempdb-and-user-databases/ +-- https://bit.ly/2lbNWxK --- The behavior of TF 2371 is enabled by default in SQL Server 2016 (in compat level 130) +-- The behavior of TF 2371 is enabled by default in SQL Server 2016 and newer (in compat level 130 and higher) -- DBCC TRACEON - Trace Flags (Transact-SQL) --- https://docs.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-traceon-trace-flags-transact-sql - - - --- Returns status of instant file initialization (Query 6) (IFI Status) -EXEC sys.xp_readerrorlog 0, 1, N'Database Instant File Initialization'; ------- +-- https://bit.ly/2FuSvPg --- Lets you determine whether Instant File Initialization (IFI) is enabled for the instance --- This should be enabled in the vast majority of cases --- SQL Server 2016 lets you enable this during the SQL server installation process +-- Recommended updates and configuration options for SQL Server 2017 and 2016 with high-performance workloads +-- https://bit.ly/2VVRGTY --- Database Instant File Initialization --- https://docs.microsoft.com/en-us/sql/relational-databases/databases/database-instant-file-initialization --- Misconceptions around instant file initialization --- https://www.sqlskills.com/blogs/paul/misconceptions-around-instant-file-initialization/ - --- SQL Server Process Address space info (Query 7) (Process Memory) +-- SQL Server Process Address space info (Query 6) (Process Memory) -- (shows whether locked pages is enabled, among other things) SELECT physical_memory_in_use_kb/1024 AS [SQL Server Memory Usage (MB)], - large_page_allocations_kb, locked_page_allocations_kb, page_fault_count, - memory_utilization_percentage, available_commit_limit_kb, + locked_page_allocations_kb/1024 AS [SQL Server Locked Pages Allocation (MB)], + large_page_allocations_kb/1024 AS [SQL Server Large Pages Allocation (MB)], + page_fault_count, memory_utilization_percentage, available_commit_limit_kb, process_physical_memory_low, process_virtual_memory_low FROM sys.dm_os_process_memory WITH (NOLOCK) OPTION (RECOMPILE); ------ @@ -248,11 +263,14 @@ FROM sys.dm_os_process_memory WITH (NOLOCK) OPTION (RECOMPILE); -- If locked_page_allocations_kb > 0, then LPIM is enabled -- How to enable the "locked pages" feature in SQL Server 2012 --- https://support.microsoft.com/en-us/kb/2659143 +-- https://bit.ly/2F5UjOA + +-- Memory Management Architecture Guide +-- https://bit.ly/2JKkadC --- SQL Server Services information (Query 8) (SQL Server Services Info) +-- SQL Server Services information (Query 7) (SQL Server Services Info) SELECT servicename, process_id, startup_type_desc, status_desc, last_startup_time, service_account, is_clustered, cluster_nodename, [filename], instant_file_initialization_enabled -- New in SQL Server 2016 SP1 @@ -264,8 +282,11 @@ FROM sys.dm_server_services WITH (NOLOCK) OPTION (RECOMPILE); -- Also shows whether you are running on a failover cluster instance, and what node you are running on -- Also shows whether IFI is enabled +-- sys.dm_server_services (Transact-SQL) +-- https://bit.ly/2oKa1Un + --- Last backup information by database (Query 9) (Last Backup By Database) +-- Last backup information by database (Query 8) (Last Backup By Database) SELECT ISNULL(d.[name], bs.[database_name]) AS [Database], d.recovery_model_desc AS [Recovery Model], d.log_reuse_wait_desc AS [Log Reuse Wait Desc], MAX(CASE WHEN [type] = 'D' THEN bs.backup_finish_date ELSE NULL END) AS [Last Full Backup], @@ -275,14 +296,15 @@ FROM sys.databases AS d WITH (NOLOCK) LEFT OUTER JOIN msdb.dbo.backupset AS bs WITH (NOLOCK) ON bs.[database_name] = d.[name] AND bs.backup_finish_date > GETDATE()- 30 -GROUP BY ISNULL(d.[name], bs.[database_name]), d.recovery_model_desc, d.log_reuse_wait_desc -ORDER BY d.recovery_model_desc OPTION (RECOMPILE); +WHERE d.name <> N'tempdb' +GROUP BY ISNULL(d.[name], bs.[database_name]), d.recovery_model_desc, d.log_reuse_wait_desc, d.[name] +ORDER BY d.recovery_model_desc, d.[name] OPTION (RECOMPILE); ------ -- This helps you spot runaway transaction logs and other issues with your backup schedule --- Get SQL Server Agent jobs and Category information (Query 10) (SQL Server Agent Jobs) +-- Get SQL Server Agent jobs and Category information (Query 9) (SQL Server Agent Jobs) SELECT sj.name AS [Job Name], sj.[description] AS [Job Description], SUSER_SNAME(sj.owner_sid) AS [Job Owner], sj.date_created AS [Date Created], sj.[enabled] AS [Job Enabled], sj.notify_email_operator_id, sj.notify_level_email, sc.name AS [CategoryName], @@ -303,35 +325,36 @@ ORDER BY sj.name OPTION (RECOMPILE); -- Look for jobs that have a notify_level_email set to 0 (meaning no e-mail is ever sent) -- -- MSDN sysjobs documentation --- https://msdn.microsoft.com/en-us/library/ms189817.aspx +-- https://bit.ly/2paDEOP -- SQL Server Maintenance Solution --- https://ola.hallengren.com/ +-- https://bit.ly/1pgchQu --- Get SQL Server Agent Alert Information (Query 11) (SQL Server Agent Alerts) +-- Get SQL Server Agent Alert Information (Query 10) (SQL Server Agent Alerts) SELECT name, event_source, message_id, severity, [enabled], has_notification, delay_between_responses, occurrence_count, last_occurrence_date, last_occurrence_time FROM msdb.dbo.sysalerts WITH (NOLOCK) ORDER BY name OPTION (RECOMPILE); ------ --- Gives you some basic information about your SQL Server Agent Alerts (which are different from SQL Server Agent jobs) --- Read more about Agent Alerts here: https://www.sqlskills.com/blogs/glenn/creating-sql-server-agent-alerts-for-critical-errors/ +-- Gives you some basic information about your SQL Server Agent Alerts +-- (which are different from SQL Server Agent jobs) +-- Read more about Agent Alerts here: https://bit.ly/2Giz0Xf --- Windows information (Query 12) (Windows Info) +-- Windows information (Query 11) (Windows Info) SELECT windows_release, windows_service_pack_level, windows_sku, os_language_version FROM sys.dm_os_windows_info WITH (NOLOCK) OPTION (RECOMPILE); ------ -- Gives you major OS version, Service Pack, Edition, and language info for the operating system --- 6.3 is either Windows 8.1, Windows 10 or Windows Server 2012 R2, Windows Server 2016 +-- 10.0 is either Windows 10 or Windows Server 2016 +-- 6.3 is either Windows 8.1 or Windows Server 2012 R2 -- 6.2 is either Windows 8 or Windows Server 2012 --- 6.1 is either Windows 7 or Windows Server 2008 R2 --- 6.0 is either Windows Vista or Windows Server 2008 + -- Windows SKU codes -- 4 is Enterprise Edition @@ -339,22 +362,23 @@ FROM sys.dm_os_windows_info WITH (NOLOCK) OPTION (RECOMPILE); -- 8 is Datacenter Server Edition -- 10 is Enterprise Server Edition -- 48 is Professional Edition +-- 161 is Pro for Workstations -- 1033 for os_language_version is US-English -- SQL Server 2016 requires Windows Server 2012 or newer -- Quick-Start Installation of SQL Server 2016 --- https://msdn.microsoft.com/en-us/library/bb500433(v=sql.130).aspx +-- https://bit.ly/2qtxQ3G -- Hardware and Software Requirements for Installing SQL Server 2016 --- https://msdn.microsoft.com/en-us/library/ms143506(v=sql.130).aspx +-- https://bit.ly/2JJIUTl -- Using SQL Server in Windows 8 and later versions of Windows operating system --- https://support.microsoft.com/en-us/kb/2681562 +-- https://bit.ly/2F7Ax0P --- SQL Server NUMA Node information (Query 13) (SQL Server NUMA Info) +-- SQL Server NUMA Node information (Query 12) (SQL Server NUMA Info) SELECT node_id, node_state_desc, memory_node_id, processor_group, online_scheduler_count, idle_scheduler_count, active_worker_count, avg_load_balance, resource_monitor_state FROM sys.dm_os_nodes WITH (NOLOCK) @@ -363,15 +387,18 @@ WHERE node_state_desc <> N'ONLINE DAC' OPTION (RECOMPILE); -- Gives you some useful information about the composition and relative load on your NUMA nodes -- You want to see an equal number of schedulers on each NUMA node --- Watch out if SQL Server 2016 Standard Edition has been installed on a machine with more than 24 physical cores --- Watch out if you have a VM with more than 4 NUMA nodes with SQL Server Standard Edition, since there is a four-socket license limit +-- Watch out if SQL Server 2016 Standard Edition has been installed +-- on a physical or virtual machine with more than four sockets or more than 24 physical cores + +-- sys.dm_os_nodes (Transact-SQL) +-- https://bit.ly/2pn5Mw8 -- Balancing Your Available SQL Server Core Licenses Evenly Across NUMA Nodes --- https://www.sqlskills.com/blogs/glenn/balancing-your-available-sql-server-core-licenses-evenly-across-numa-nodes/ +-- https://bit.ly/2vfC4Rq --- Good basic information about OS memory amounts and state (Query 14) (System Memory) +-- Good basic information about OS memory amounts and state (Query 13) (System Memory) SELECT total_physical_memory_kb/1024 AS [Physical Memory (MB)], available_physical_memory_kb/1024 AS [Available Memory (MB)], total_page_file_kb/1024 AS [Total Page File (MB)], @@ -388,13 +415,18 @@ FROM sys.dm_os_sys_memory WITH (NOLOCK) OPTION (RECOMPILE); -- Available physical memory is high -- Physical memory usage is steady -- Available physical memory is low +-- Available physical memory is running low -- Physical memory state is transitioning +-- sys.dm_os_sys_memory (Transact-SQL) +-- https://bit.ly/2pcV0xq + + -- You can skip the next two queries if you know you don't have a clustered instance --- Get information about your cluster nodes and their status (Query 15) (Cluster Node Properties) +-- Get information about your cluster nodes and their status (Query 14) (Cluster Node Properties) -- (if your database server is in a failover cluster) SELECT NodeName, status_description, is_current_owner FROM sys.dm_os_cluster_nodes WITH (NOLOCK) OPTION (RECOMPILE); @@ -405,10 +437,10 @@ FROM sys.dm_os_cluster_nodes WITH (NOLOCK) OPTION (RECOMPILE); -- You will see no results if your instance is not clustered -- Recommended hotfixes and updates for Windows Server 2012 R2-based failover clusters --- http://support.microsoft.com/kb/2920151 +-- https://bit.ly/1z5BfCw --- Get information about any AlwaysOn AG cluster this instance is a part of (Query 16) (AlwaysOn AG Cluster) +-- Get information about any AlwaysOn AG cluster this instance is a part of (Query 15) (AlwaysOn AG Cluster) SELECT cluster_name, quorum_type_desc, quorum_state_desc FROM sys.dm_hadr_cluster WITH (NOLOCK) OPTION (RECOMPILE); ------ @@ -416,7 +448,7 @@ FROM sys.dm_hadr_cluster WITH (NOLOCK) OPTION (RECOMPILE); -- You will see no results if your instance is not using AlwaysOn AGs --- Good overview of AG health and status (Query 17) (AlwaysOn AG Status) +-- Good overview of AG health and status (Query 16) (AlwaysOn AG Status) SELECT ag.name AS [AG Name], ar.replica_server_name, ar.availability_mode_desc, adc.[database_name], drs.is_local, drs.is_primary_replica, drs.synchronization_state_desc, drs.is_commit_participant, drs.synchronization_health_desc, drs.recovery_lsn, drs.truncation_lsn, drs.last_sent_lsn, @@ -438,41 +470,48 @@ ORDER BY ag.name, ar.replica_server_name, adc.[database_name] OPTION (RECOMPILE) -- You will see no results if your instance is not using AlwaysOn AGs -- SQL Server 2016 It Just Runs Faster: Always On Availability Groups Turbocharged --- https://blogs.msdn.microsoft.com/bobsql/2016/09/26/sql-server-2016-it-just-runs-faster-always-on-availability-groups-turbocharged/ - - --- Hardware information from SQL Server 2016 (Query 18) (Hardware Info) -SELECT cpu_count AS [Logical CPU Count], scheduler_count, hyperthread_ratio AS [Hyperthread Ratio], -cpu_count/hyperthread_ratio AS [Physical CPU Count], -physical_memory_kb/1024 AS [Physical Memory (MB)], committed_kb/1024 AS [Committed Memory (MB)], -committed_target_kb/1024 AS [Committed Target Memory (MB)], -max_workers_count AS [Max Workers Count], affinity_type_desc AS [Affinity Type], -sqlserver_start_time AS [SQL Server Start Time], virtual_machine_type_desc AS [Virtual Machine Type], -softnuma_configuration_desc AS [Soft NUMA Configuration], -sql_memory_model_desc -- New in SQL Server 2016 SP1 +-- https://bit.ly/2dn1H6r + + +-- Hardware information from SQL Server 2016 (Query 17) (Hardware Info) +SELECT cpu_count AS [Logical CPU Count], scheduler_count, + hyperthread_ratio AS [Hyperthread Ratio], + cpu_count/hyperthread_ratio AS [Physical CPU Count], + physical_memory_kb/1024 AS [Physical Memory (MB)], + committed_kb/1024 AS [Committed Memory (MB)], + committed_target_kb/1024 AS [Committed Target Memory (MB)], + max_workers_count AS [Max Workers Count], + affinity_type_desc AS [Affinity Type], + sqlserver_start_time AS [SQL Server Start Time], + DATEDIFF(hour, sqlserver_start_time, GETDATE()) AS [SQL Server Up Time (hrs)], + virtual_machine_type_desc AS [Virtual Machine Type], + softnuma_configuration_desc AS [Soft NUMA Configuration], + sql_memory_model_desc -- New in SQL Server 2016 FROM sys.dm_os_sys_info WITH (NOLOCK) OPTION (RECOMPILE); ------ -- Gives you some good basic hardware information about your database server --- Cannot distinguish between HT and multi-core -- Note: virtual_machine_type_desc of HYPERVISOR does not automatically mean you are running SQL Server inside of a VM -- It merely indicates that you have a hypervisor running on your host --- Soft NUMA configuration is a new column for SQL Server 2016 +-- sys.dm_os_sys_info (Transact-SQL) +-- https://bit.ly/2pczOYs + +-- Soft NUMA configuration was a new column for SQL Server 2016 -- OFF = Soft-NUMA feature is OFF -- ON = SQL Server automatically determines the NUMA node sizes for Soft-NUMA -- MANUAL = Manually configured soft-NUMA -- Configure SQL Server to Use Soft-NUMA (SQL Server) --- https://msdn.microsoft.com/en-us/library/ms345357(v=sql.130).aspx +-- https://bit.ly/2HTpKJt --- sql_memory_model_desc values (New in SQL Server 2016 SP1) +-- sql_memory_model_desc values (Added in SQL Server 2016 SP1) -- CONVENTIONAL -- LOCK_PAGES -- LARGE_PAGES --- Get System Manufacturer and model number from SQL Server Error log (Query 19) (System Manufacturer) +-- Get System Manufacturer and model number from SQL Server Error log (Query 18) (System Manufacturer) EXEC sys.xp_readerrorlog 0, 1, N'Manufacturer'; ------ @@ -482,6 +521,16 @@ EXEC sys.xp_readerrorlog 0, 1, N'Manufacturer'; -- This query will return no results if your error log has been recycled since the instance was started +-- Get pvscsi info from Windows Registry (Query 19) (PVSCSI Driver Parameters) +EXEC sys.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'SYSTEM\CurrentControlSet\services\pvscsi\Parameters\Device', N'DriverParameter'; +------ + +-- This is valid for VMware VMs +-- Recommended value for intensive I/O patterns from VMware is: RequestRingPages=32,MaxQueueDepth=254 +-- https://kb.vmware.com/s/article/2053145 + + + -- Get BIOS date from Windows Registry (Query 20) (BIOS Date) EXEC sys.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'HARDWARE\DESCRIPTION\System\BIOS', N'BiosReleaseDate'; ------ @@ -499,44 +548,15 @@ EXEC sys.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'HARDWARE\DESCRIPTION\Syste -- to the Windows Power Plan or hardware power management -- You can use CPU-Z to get your actual CPU core speed and a lot of other useful information --- http://www.cpuid.com/softwares/cpu-z.html +-- https://bit.ly/QhR6xF -- You can learn more about processor selection for SQL Server by following this link --- https://www.sqlskills.com/blogs/glenn/processor-selection-for-sql-server/ - - - --- See if buffer pool extensions (BPE) is enabled (Query 22) (BPE Configuration) -SELECT [path], state_description, current_size_in_kb, -CAST(current_size_in_kb/1048576.0 AS DECIMAL(10,2)) AS [Size (GB)] -FROM sys.dm_os_buffer_pool_extension_configuration WITH (NOLOCK) OPTION (RECOMPILE); ------- +-- https://bit.ly/2F3aVlP --- BPE is available in both Standard Edition and Enterprise Edition --- It is a more interesting feature for Standard Edition --- Buffer Pool Extension to SSDs in SQL Server 2014 --- http://blogs.technet.com/b/dataplatforminsider/archive/2013/07/25/buffer-pool-extension-to-ssds-in-sql-server-2014.aspx - --- Buffer Pool Extension --- https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/buffer-pool-extension - - --- Look at buffer descriptors to see BPE usage by database (Query 23) (BPE Usage) -SELECT DB_NAME(database_id) AS [Database Name], COUNT(page_id) AS [Page Count], -CAST(COUNT(*)/128.0 AS DECIMAL(10, 2)) AS [Buffer size(MB)], -AVG(read_microsec) AS [Avg Read Time (microseconds)] -FROM sys.dm_os_buffer_descriptors WITH (NOLOCK) -WHERE database_id <> 32767 -AND is_in_bpool_extension = 1 -GROUP BY DB_NAME(database_id) -ORDER BY [Buffer size(MB)] DESC OPTION (RECOMPILE); ------- --- You will see no results if BPE is not enabled or if there is no BPE usage - --- Get information on location, time and size of any memory dumps from SQL Server (Query 24) (Memory Dump Info) +-- Get information on location, time and size of any memory dumps from SQL Server (Query 22) (Memory Dump Info) SELECT [filename], creation_time, size_in_bytes/1048576.0 AS [Size (MB)] FROM sys.dm_server_memory_dumps WITH (NOLOCK) ORDER BY creation_time DESC OPTION (RECOMPILE); @@ -546,10 +566,11 @@ ORDER BY creation_time DESC OPTION (RECOMPILE); -- not had any memory dumps (which is a good thing) -- sys.dm_server_memory_dumps (Transact-SQL) --- http://bit.ly/2elwWll +-- https://bit.ly/2elwWll + --- Look at Suspect Pages table (Query 25) (Suspect Pages) +-- Look at Suspect Pages table (Query 23) (Suspect Pages) SELECT DB_NAME(database_id) AS [Database Name], [file_id], page_id, event_type, error_count, last_update_date FROM msdb.dbo.suspect_pages WITH (NOLOCK) @@ -557,34 +578,36 @@ ORDER BY database_id OPTION (RECOMPILE); ------ -- event_type value descriptions --- 1 = 823 error caused by an operating system CRC error or 824 error other than a bad checksum or a torn page (for example, a bad page ID) +-- 1 = 823 error caused by an operating system CRC error +-- or 824 error other than a bad checksum or a torn page (for example, a bad page ID) -- 2 = Bad checksum -- 3 = Torn page -- 4 = Restored (The page was restored after it was marked bad) -- 5 = Repaired (DBCC repaired the page) -- 7 = Deallocated by DBCC --- Manage the suspect_pages Table --- https://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/manage-the-suspect-pages-table-sql-server - -- Ideally, this query returns no results. The table is limited to 1000 rows. -- If you do get results here, you should do further investigation to determine the root cause +-- Manage the suspect_pages Table +-- https://bit.ly/2Fvr1c9 + --- Get number of data files in tempdb database (Query 26) (TempDB Data Files) +-- Get number of data files in tempdb database (Query 24) (TempDB Data Files) EXEC sys.xp_readerrorlog 0, 1, N'The tempdb database has'; ------ -- Get the number of data files in the tempdb database -- 4-8 data files that are all the same size is a good starting point +-- This query will return no results if your error log has been recycled since the instance was last started --- File names and paths for all user and system databases on instance (Query 27) (Database Filenames and Paths) +-- File names and paths for all user and system databases on instance (Query 25) (Database Filenames and Paths) SELECT DB_NAME([database_id]) AS [Database Name], [file_id], [name], physical_name, [type_desc], state_desc, - is_percent_growth, growth, + is_percent_growth, growth, CONVERT(bigint, growth/128.0) AS [Growth in MB], - CONVERT(bigint, size/128.0) AS [Total Size in MB] + CONVERT(bigint, size/128.0) AS [Total Size in MB], max_size FROM sys.master_files WITH (NOLOCK) ORDER BY DB_NAME([database_id]), [file_id] OPTION (RECOMPILE); ------ @@ -599,11 +622,13 @@ ORDER BY DB_NAME([database_id]), [file_id] OPTION (RECOMPILE); -- Is percent growth enabled for any files (which is bad)? --- Volume info for all LUNS that have database files on the current instance (Query 28) (Volume Info) -SELECT DISTINCT vs.volume_mount_point, vs.file_system_type, -vs.logical_volume_name, CONVERT(DECIMAL(18,2),vs.total_bytes/1073741824.0) AS [Total Size (GB)], +-- Volume info for all LUNS that have database files on the current instance (Query 26) (Volume Info) +SELECT DISTINCT vs.volume_mount_point, vs.file_system_type, vs.logical_volume_name, +CONVERT(DECIMAL(18,2), vs.total_bytes/1073741824.0) AS [Total Size (GB)], CONVERT(DECIMAL(18,2), vs.available_bytes/1073741824.0) AS [Available Size (GB)], -CONVERT(DECIMAL(18,2), vs.available_bytes * 1. / vs.total_bytes * 100.) AS [Space Free %] +CONVERT(DECIMAL(18,2), vs.available_bytes * 1. / vs.total_bytes * 100.) AS [Space Free %], +vs.supports_compression, vs.is_compressed, +vs.supports_sparse_files, vs.supports_alternate_streams FROM sys.master_files AS f WITH (NOLOCK) CROSS APPLY sys.dm_os_volume_stats(f.database_id, f.[file_id]) AS vs ORDER BY vs.volume_mount_point OPTION (RECOMPILE); @@ -612,9 +637,12 @@ ORDER BY vs.volume_mount_point OPTION (RECOMPILE); -- Shows you the total and free space on the LUNs where you have database files -- Being low on free space can negatively affect performance +-- sys.dm_os_volume_stats (Transact-SQL) +-- https://bit.ly/2oBPNNr + --- Drive level latency information (Query 29) (Drive Level Latency) +-- Drive level latency information (Query 27) (Drive Level Latency) -- Based on code from Jimmy May SELECT tab.[Drive], tab.volume_mount_point AS [Volume Mount Point], CASE @@ -659,10 +687,10 @@ ORDER BY [Overall Latency] OPTION (RECOMPILE); -- database files on each drive since SQL Server was last started --- Calculates average stalls per read, per write, and per total input/output for each database file (Query 30) (IO Stalls by File) -SELECT DB_NAME(fs.database_id) AS [Database Name], CAST(fs.io_stall_read_ms/(1.0 + fs.num_of_reads) AS NUMERIC(10,1)) AS [avg_read_stall_ms], -CAST(fs.io_stall_write_ms/(1.0 + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_write_stall_ms], -CAST((fs.io_stall_read_ms + fs.io_stall_write_ms)/(1.0 + fs.num_of_reads + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_io_stall_ms], +-- Calculates average stalls per read, per write, and per total input/output for each database file (Query 28) (IO Latency by File) +SELECT DB_NAME(fs.database_id) AS [Database Name], CAST(fs.io_stall_read_ms/(1.0 + fs.num_of_reads) AS NUMERIC(10,1)) AS [avg_read_latency_ms], +CAST(fs.io_stall_write_ms/(1.0 + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_write_latency_ms], +CAST((fs.io_stall_read_ms + fs.io_stall_write_ms)/(1.0 + fs.num_of_reads + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_io_latency_ms], CONVERT(DECIMAL(18,2), mf.size/128.0) AS [File Size (MB)], mf.physical_name, mf.type_desc, fs.io_stall_read_ms, fs.num_of_reads, fs.io_stall_write_ms, fs.num_of_writes, fs.io_stall_read_ms + fs.io_stall_write_ms AS [io_stalls], fs.num_of_reads + fs.num_of_writes AS [total_io], io_stall_queued_read_ms AS [Resource Governor Total Read IO Latency (ms)], io_stall_queued_write_ms AS [Resource Governor Total Write IO Latency (ms)] @@ -670,7 +698,7 @@ FROM sys.dm_io_virtual_file_stats(null,null) AS fs INNER JOIN sys.master_files AS mf WITH (NOLOCK) ON fs.database_id = mf.database_id AND fs.[file_id] = mf.[file_id] -ORDER BY avg_io_stall_ms DESC OPTION (RECOMPILE); +ORDER BY avg_io_latency_ms DESC OPTION (RECOMPILE); ------ -- Helps determine which database files on the entire instance have the most I/O bottlenecks @@ -680,7 +708,7 @@ ORDER BY avg_io_stall_ms DESC OPTION (RECOMPILE); -- database file since SQL Server was last started --- Look for I/O requests taking longer than 15 seconds in the five most recent SQL Server Error Logs (Query 31) (IO Warnings) +-- Look for I/O requests taking longer than 15 seconds in the six most recent SQL Server Error Logs (Query 29) (IO Warnings) CREATE TABLE #IOWarningResults(LogDate datetime, ProcessInfo sysname, LogText nvarchar(1000)); INSERT INTO #IOWarningResults @@ -698,6 +726,9 @@ CREATE TABLE #IOWarningResults(LogDate datetime, ProcessInfo sysname, LogText nv INSERT INTO #IOWarningResults EXEC xp_readerrorlog 4, 1, N'taking longer than 15 seconds'; + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 5, 1, N'taking longer than 15 seconds'; + SELECT LogDate, ProcessInfo, LogText FROM #IOWarningResults ORDER BY LogDate DESC; @@ -710,11 +741,26 @@ DROP TABLE #IOWarningResults; -- Look to see if you see any patterns in the results (same files, same drives, same time of day, etc.) -- Diagnostics in SQL Server help detect stalled and stuck I/O operations --- https://support.microsoft.com/en-us/kb/897284 +-- https://bit.ly/2qtaw73 +-- Resource Governor Resource Pool information (Query 30) (RG Resource Pools) +SELECT pool_id, [Name], statistics_start_time, + min_memory_percent, max_memory_percent, + max_memory_kb/1024 AS [max_memory_mb], + used_memory_kb/1024 AS [used_memory_mb], + target_memory_kb/1024 AS [target_memory_mb], + min_iops_per_volume, max_iops_per_volume +FROM sys.dm_resource_governor_resource_pools WITH (NOLOCK) +OPTION (RECOMPILE); +------ + +-- sys.dm_resource_governor_resource_pools (Transact-SQL) +-- https://bit.ly/2MVU0Vy --- Recovery model, log reuse wait description, log file size, log usage size (Query 32) (Database Properties) + + +-- Recovery model, log reuse wait description, log file size, log usage size (Query 31) (Database Properties) -- and compatibility level for all databases on instance SELECT db.[name] AS [Database Name], SUSER_SNAME(db.owner_sid) AS [Database Owner], db.recovery_model_desc AS [Recovery Model], db.state_desc, db.containment_desc, db.log_reuse_wait_desc AS [Log Reuse Wait Description], @@ -756,20 +802,23 @@ ORDER BY db.[name] OPTION (RECOMPILE); -- is_mixed_page_allocation_on is a new property for SQL Server 2016. Equivalent to TF 1118 for a user database -- SQL Server 2016: Changes in default behavior for autogrow and allocations for tempdb and user databases --- https://blogs.msdn.microsoft.com/sql_server_team/sql-server-2016-changes-in-default-behavior-for-autogrow-and-allocations-for-tempdb-and-user-databases/ +-- https://bit.ly/2evRZSR -- A non-zero value for target_recovery_time_in_seconds means that indirect checkpoint is enabled -- If the setting has a zero value it indicates that automatic checkpoint is enabled -- Changes in SQL Server 2016 Checkpoint Behavior --- https://blogs.msdn.microsoft.com/sqlcat/2016/08/03/changes-in-sql-server-2016-checkpoint-behavior/ +-- https://bit.ly/2pdggk3 --- Missing Indexes for all databases by Index Advantage (Query 33) (Missing Indexes All Databases) -SELECT CONVERT(decimal(18,2), user_seeks * avg_total_user_cost * (avg_user_impact * 0.01)) AS [index_advantage], -migs.last_user_seek, mid.[statement] AS [Database.Schema.Table], -mid.equality_columns, mid.inequality_columns, mid.included_columns, -migs.unique_compiles, migs.user_seeks, migs.avg_total_user_cost, migs.avg_user_impact +-- Missing Indexes for all databases by Index Advantage (Query 32) (Missing Indexes All Databases) +SELECT CONVERT(decimal(18,2), migs.user_seeks * migs.avg_total_user_cost * (migs.avg_user_impact * 0.01)) AS [index_advantage], +FORMAT(migs.last_user_seek, 'yyyy-MM-dd HH:mm:ss') AS [last_user_seek], +mid.[statement] AS [Database.Schema.Table], +COUNT(1) OVER(PARTITION BY mid.[statement]) AS [missing_indexes_for_table], +COUNT(1) OVER(PARTITION BY mid.[statement], equality_columns) AS [similar_missing_indexes_for_table], +mid.equality_columns, mid.inequality_columns, mid.included_columns, migs.user_seeks, +CONVERT(decimal(18,2), migs.avg_total_user_cost) AS [avg_total_user_cost], migs.avg_user_impact FROM sys.dm_db_missing_index_group_stats AS migs WITH (NOLOCK) INNER JOIN sys.dm_db_missing_index_groups AS mig WITH (NOLOCK) ON migs.group_handle = mig.index_group_handle @@ -783,10 +832,14 @@ ORDER BY index_advantage DESC OPTION (RECOMPILE); -- Also look at avg_user_impact and avg_total_user_cost to help determine importance -- SQL Server is overly eager to add included columns, so beware -- Do not just blindly add indexes that show up from this query!!! +-- Hkan Winther has given me some great suggestions for this query + +-- SQL Server Index Design Guide +-- https://bit.ly/2qtZr4N --- Get VLF Counts for all databases on the instance (Query 34) (VLF Counts) +-- Get VLF Counts for all databases on the instance (Query 33) (VLF Counts) -- (adapted from Michelle Ufford) CREATE TABLE #VLFInfo (RecoveryUnitID int, FileID int, FileSize bigint, StartOffset bigint, @@ -819,11 +872,15 @@ DROP TABLE #VLFCountResults; -- Try to keep your VLF counts under 200 in most cases (depending on log file size) -- Important change to VLF creation algorithm in SQL Server 2014 --- https://www.sqlskills.com/blogs/paul/important-change-vlf-creation-algorithm-sql-server-2014/ +-- https://bit.ly/2Hsjbg4 + +-- SQL Server Transaction Log Architecture and Management Guide +-- https://bit.ly/2JjmQRZ --- Get CPU utilization by database (Query 35) (CPU Usage by Database) + +-- Get CPU utilization by database (Query 34) (CPU Usage by Database) WITH DB_CPU_Stats AS (SELECT pa.DatabaseID, DB_Name(pa.DatabaseID) AS [Database Name], SUM(qs.total_worker_time/1000) AS [CPU_Time_Ms] @@ -841,25 +898,34 @@ ORDER BY [CPU Rank] OPTION (RECOMPILE); ------ -- Helps determine which database is using the most CPU resources on the instance +-- Note: This only reflects CPU usage from the currently cached query plans --- Get I/O utilization by database (Query 36) (IO Usage By Database) +-- Get I/O utilization by database (Query 35) (IO Usage By Database) WITH Aggregate_IO_Statistics -AS -(SELECT DB_NAME(database_id) AS [Database Name], -CAST(SUM(num_of_bytes_read + num_of_bytes_written)/1048576 AS DECIMAL(12, 2)) AS io_in_mb -FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS [DM_IO_STATS] -GROUP BY database_id) -SELECT ROW_NUMBER() OVER(ORDER BY io_in_mb DESC) AS [I/O Rank], [Database Name], io_in_mb AS [Total I/O (MB)], - CAST(io_in_mb/ SUM(io_in_mb) OVER() * 100.0 AS DECIMAL(5,2)) AS [I/O Percent] +AS (SELECT DB_NAME(database_id) AS [Database Name], + CAST(SUM(num_of_bytes_read + num_of_bytes_written) / 1048576 AS DECIMAL(12, 2)) AS [ioTotalMB], + CAST(SUM(num_of_bytes_read ) / 1048576 AS DECIMAL(12, 2)) AS [ioReadMB], + CAST(SUM(num_of_bytes_written) / 1048576 AS DECIMAL(12, 2)) AS [ioWriteMB] + FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS [DM_IO_STATS] + GROUP BY database_id) +SELECT ROW_NUMBER() OVER (ORDER BY ioTotalMB DESC) AS [I/O Rank], + [Database Name], ioTotalMB AS [Total I/O (MB)], + CAST(ioTotalMB / SUM(ioTotalMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Total I/O %], + ioReadMB AS [Read I/O (MB)], + CAST(ioReadMB / SUM(ioReadMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Read I/O %], + ioWriteMB AS [Write I/O (MB)], + CAST(ioWriteMB / SUM(ioWriteMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Write I/O %] FROM Aggregate_IO_Statistics ORDER BY [I/O Rank] OPTION (RECOMPILE); ------ -- Helps determine which database is using the most I/O resources on the instance +-- These numbers are cumulative since the last service restart +-- They include all I/O activity, not just the nominal I/O workload --- Get total buffer usage by database for current instance (Query 37) (Total Buffer Usage by Database) +-- Get total buffer usage by database for current instance (Query 36) (Total Buffer Usage by Database) -- This make take some time to run on a busy instance WITH AggregateBufferPoolUsage AS @@ -881,7 +947,7 @@ ORDER BY [Buffer Pool Rank] OPTION (RECOMPILE); -- Clear Wait Stats with this command -- DBCC SQLPERF('sys.dm_os_wait_stats', CLEAR); --- Isolate top waits for server instance since last restart or wait statistics clear (Query 38) (Top Waits) +-- Isolate top waits for server instance since last restart or wait statistics clear (Query 37) (Top Waits) WITH [Waits] AS (SELECT wait_type, wait_time_ms/ 1000.0 AS [WaitS], (wait_time_ms - signal_wait_time_ms) / 1000.0 AS [ResourceS], @@ -901,6 +967,8 @@ AS (SELECT wait_type, wait_time_ms/ 1000.0 AS [WaitS], N'HADR_NOTIFICATION_DEQUEUE', N'HADR_TIMER_TASK', N'HADR_WORK_QUEUE', N'KSOURCE_WAKEUP', N'LAZYWRITER_SLEEP', N'LOGMGR_QUEUE', N'MEMORY_ALLOCATION_EXT', N'ONDEMAND_TASK_QUEUE', + N'PARALLEL_REDO_DRAIN_WORKER', N'PARALLEL_REDO_LOG_CACHE', N'PARALLEL_REDO_TRAN_LIST', + N'PARALLEL_REDO_WORKER_SYNC', N'PARALLEL_REDO_WORKER_WAIT_WORK', N'PREEMPTIVE_HADR_LEASE_MECHANISM', N'PREEMPTIVE_SP_SERVER_DIAGNOSTICS', N'PREEMPTIVE_OS_LIBRARYOPS', N'PREEMPTIVE_OS_COMOPS', N'PREEMPTIVE_OS_CRYPTOPS', N'PREEMPTIVE_OS_PIPEOPS', N'PREEMPTIVE_OS_AUTHENTICATIONOPS', @@ -946,23 +1014,23 @@ OPTION (RECOMPILE); -- Cumulative wait stats are not as useful on an idle instance that is not under load or performance pressure -- SQL Server Wait Types Library (Paul Randal) --- https://www.sqlskills.com/help/waits/ +-- https://bit.ly/2ePzYO2 -- The SQL Server Wait Type Repository --- http://blogs.msdn.com/b/psssql/archive/2009/11/03/the-sql-server-wait-type-repository.aspx +-- https://bit.ly/1afzfjC -- Wait statistics, or please tell me where it hurts --- https://www.sqlskills.com/blogs/paul/wait-statistics-or-please-tell-me-where-it-hurts/ +-- https://bit.ly/2wsQHQE -- SQL Server 2005 Performance Tuning using the Waits and Queues --- http://technet.microsoft.com/en-us/library/cc966413.aspx +-- https://bit.ly/1o2NFoF -- sys.dm_os_wait_stats (Transact-SQL) --- http://msdn.microsoft.com/en-us/library/ms179984(v=sql.120).aspx +-- https://bit.ly/2Hjq9Yl --- Get a count of SQL connections by IP address (Query 39) (Connection Counts by IP Address) +-- Get a count of SQL connections by IP address (Query 38) (Connection Counts by IP Address) SELECT ec.client_net_address, es.[program_name], es.[host_name], es.login_name, COUNT(ec.session_id) AS [connection count] FROM sys.dm_exec_sessions AS es WITH (NOLOCK) @@ -976,11 +1044,11 @@ ORDER BY ec.client_net_address, es.[program_name] OPTION (RECOMPILE); -- and verifies connectivity from other machines -- Solving Connectivity errors to SQL Server --- https://support.microsoft.com/en-us/help/4009936/solving-connectivity-errors-to-sql-server +-- https://bit.ly/2EgzoD0 --- Get Average Task Counts (run multiple times) (Query 40) (Avg Task Counts) +-- Get Average Task Counts (run multiple times) (Query 39) (Avg Task Counts) SELECT AVG(current_tasks_count) AS [Avg Task Count], AVG(work_queue_count) AS [Avg Work Queue Count], AVG(runnable_tasks_count) AS [Avg Runnable Task Count], @@ -997,11 +1065,11 @@ WHERE scheduler_id < 255 OPTION (RECOMPILE); -- High Avg Pending DiskIO Counts are a sign of disk pressure -- How to Do Some Very Basic SQL Server Monitoring --- https://www.sqlskills.com/blogs/glenn/how-to-do-some-very-basic-sql-server-monitoring/ +-- https://bit.ly/2q3Btgt --- Detect blocking (run multiple times) (Query 41) (Detect Blocking) +-- Detect blocking (run multiple times) (Query 40) (Detect Blocking) SELECT t1.resource_type AS [lock type], DB_NAME(resource_database_id) AS [database], t1.resource_associated_entity_id AS [blk object],t1.request_mode AS [lock req], -- lock requested t1.request_session_id AS [waiter sid], t2.wait_duration_ms AS [wait time], -- spid of waiter @@ -1030,7 +1098,7 @@ ON t1.lock_owner_address = t2.resource_address OPTION (RECOMPILE); --- Get CPU Utilization History for last 256 minutes (in one minute intervals) (Query 42) (CPU Utilization History) +-- Get CPU Utilization History for last 256 minutes (in one minute intervals) (Query 41) (CPU Utilization History) DECLARE @ts_now bigint = (SELECT cpu_ticks/(cpu_ticks/ms_ticks) FROM sys.dm_os_sys_info WITH (NOLOCK)); SELECT TOP(256) SQLProcessUtilization AS [SQL Server Process CPU Utilization], @@ -1051,10 +1119,11 @@ ORDER BY record_id DESC OPTION (RECOMPILE); -- Look at the trend over the entire period -- Also look at high sustained 'Other Process' CPU Utilization values +-- Note: This query sometimes gives inaccurate results (negative values) +-- on high core count (> 64 cores) systems - --- Get top total worker time queries for entire instance (Query 43) (Top Worker Time Queries) +-- Get top total worker time queries for entire instance (Query 42) (Top Worker Time Queries) SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], qs.total_worker_time AS [Total Worker Time], qs.min_worker_time AS [Min Worker Time], @@ -1066,7 +1135,9 @@ qs.max_elapsed_time AS [Max Elapsed Time], qs.min_logical_reads AS [Min Logical Reads], qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], qs.max_logical_reads AS [Max Logical Reads], -qs.execution_count AS [Execution Count], qs.creation_time AS [Creation Time] +qs.execution_count AS [Execution Count], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] --,t.[text] AS [Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t @@ -1080,8 +1151,9 @@ ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); --- Page Life Expectancy (PLE) value for each NUMA node in current instance (Query 44) (PLE by NUMA Node) -SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], instance_name, cntr_value AS [Page Life Expectancy] +-- Page Life Expectancy (PLE) value for each NUMA node in current instance (Query 43) (PLE by NUMA Node) +SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], + instance_name, cntr_value AS [Page Life Expectancy] FROM sys.dm_os_performance_counters WITH (NOLOCK) WHERE [object_name] LIKE N'%Buffer Node%' -- Handles named instances AND counter_name = N'Page life expectancy' OPTION (RECOMPILE); @@ -1092,10 +1164,10 @@ AND counter_name = N'Page life expectancy' OPTION (RECOMPILE); -- This will only return one row for non-NUMA systems -- Page Life Expectancy isnt what you think --- https://www.sqlskills.com/blogs/paul/page-life-expectancy-isnt-what-you-think/ +-- https://bit.ly/2EgynLa --- Memory Grants Pending value for current instance (Query 45) (Memory Grants Pending) +-- Memory Grants Pending value for current instance (Query 44) (Memory Grants Pending) SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], cntr_value AS [Memory Grants Pending] FROM sys.dm_os_performance_counters WITH (NOLOCK) WHERE [object_name] LIKE N'%Memory Manager%' -- Handles named instances @@ -1106,7 +1178,7 @@ AND counter_name = N'Memory Grants Pending' OPTION (RECOMPILE); -- Memory Grants Pending above zero for a sustained period is a very strong indicator of internal memory pressure --- Memory Clerk Usage for instance (Query 46) (Memory Clerk Usage) +-- Memory Clerk Usage for instance (Query 45) (Memory Clerk Usage) -- Look for high value for CACHESTORE_SQLCP (Ad-hoc query plans) SELECT TOP(10) mc.[type] AS [Memory Clerk Type], CAST((SUM(mc.pages_kb)/1024.0) AS DECIMAL (15,2)) AS [Memory Usage (MB)] @@ -1128,14 +1200,16 @@ ORDER BY SUM(mc.pages_kb) DESC OPTION (RECOMPILE); --- Find single-use, ad-hoc and prepared queries that are bloating the plan cache (Query 47) (Ad hoc Queries) -SELECT TOP(50) [text] AS [QueryText], cp.cacheobjtype, cp.objtype, cp.size_in_bytes/1024 AS [Plan Size in KB] +-- Find single-use, ad-hoc and prepared queries that are bloating the plan cache (Query 46) (Ad hoc Queries) +SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], t.[text] AS [Query Text], +cp.objtype AS [Object Type], cp.cacheobjtype AS [Cache Object Type], +cp.size_in_bytes/1024 AS [Plan Size in KB] FROM sys.dm_exec_cached_plans AS cp WITH (NOLOCK) -CROSS APPLY sys.dm_exec_sql_text(plan_handle) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t WHERE cp.cacheobjtype = N'Compiled Plan' AND cp.objtype IN (N'Adhoc', N'Prepared') AND cp.usecounts = 1 -ORDER BY cp.size_in_bytes DESC OPTION (RECOMPILE); +ORDER BY cp.size_in_bytes DESC, DB_NAME(t.[dbid]) OPTION (RECOMPILE); ------ -- Gives you the text, type and size of single-use ad-hoc and prepared queries that waste space in the plan cache @@ -1144,10 +1218,10 @@ ORDER BY cp.size_in_bytes DESC OPTION (RECOMPILE); -- Enabling forced parameterization for the database can help, but test first! -- Plan cache, adhoc workloads and clearing the single-use plan cache bloat --- https://www.sqlskills.com/blogs/kimberly/plan-cache-adhoc-workloads-and-clearing-the-single-use-plan-cache-bloat/ +-- https://bit.ly/2EfYOkl --- Get top total logical reads queries for entire instance (Query 48) (Top Logical Reads Queries) +-- Get top total logical reads queries for entire instance (Query 47) (Top Logical Reads Queries) SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], qs.total_logical_reads AS [Total Logical Reads], @@ -1160,7 +1234,9 @@ qs.max_worker_time AS [Max Worker Time], qs.min_elapsed_time AS [Min Elapsed Time], qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], qs.max_elapsed_time AS [Max Elapsed Time], -qs.execution_count AS [Execution Count], qs.creation_time AS [Creation Time] +qs.execution_count AS [Execution Count], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] --,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t @@ -1173,7 +1249,7 @@ ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE); -- Can also help track down parameter sniffing issues --- Get top average elapsed time queries for entire instance (Query 49) (Top Avg Elapsed Time Queries) +-- Get top average elapsed time queries for entire instance (Query 48) (Top Avg Elapsed Time Queries) SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], @@ -1182,8 +1258,9 @@ qs.execution_count AS [Execution Count], qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], qs.total_physical_reads/qs.execution_count AS [Avg Physical Reads], qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], qs.creation_time AS [Creation Time] -, qp.query_plan AS [Query Plan] -- comment out this column if copying results to Excel +--,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp @@ -1194,7 +1271,7 @@ ORDER BY qs.total_elapsed_time/qs.execution_count DESC OPTION (RECOMPILE); -- Can also help track down parameter sniffing issues --- Look at UDF execution statistics (Query 50) (UDF Stats by DB) +-- Look at UDF execution statistics (Query 49) (UDF Stats by DB) SELECT TOP (25) DB_NAME(database_id) AS [Database Name], OBJECT_NAME(object_id, database_id) AS [Function Name], total_worker_time, execution_count, total_elapsed_time, @@ -1205,8 +1282,10 @@ ORDER BY total_worker_time DESC OPTION (RECOMPILE); ------ -- sys.dm_exec_function_stats (Transact-SQL) --- https://msdn.microsoft.com/en-US/library/mt429371.aspx +-- https://bit.ly/2q1Q6BM +-- Showplan Enhancements for UDFs +-- https://bit.ly/2LVqiQ1 -- Database specific queries ***************************************************************** @@ -1215,7 +1294,7 @@ ORDER BY total_worker_time DESC OPTION (RECOMPILE); --USE YourDatabaseName; -- make sure to change to an actual database on your instance, not the master system database --GO --- Individual File Sizes and space available for current database (Query 51) (File Sizes and Space) +-- Individual File Sizes and space available for current database (Query 50) (File Sizes and Space) SELECT f.name AS [File Name] , f.physical_name AS [Physical Name], CAST((f.size/128.0) AS DECIMAL(15,2)) AS [Total Size in MB], CAST(f.size/128.0 - CAST(FILEPROPERTY(f.name, 'SpaceUsed') AS int)/128.0 AS DECIMAL(15,2)) @@ -1234,10 +1313,10 @@ ORDER BY f.[file_id] OPTION (RECOMPILE); -- is_autogrow_all_files is new for SQL Server 2016. Equivalent to TF 1117 for user databases -- SQL Server 2016: Changes in default behavior for autogrow and allocations for tempdb and user databases --- http://bit.ly/2evRZSR +-- https://bit.ly/2evRZSR --- Log space usage for current database (Query 52) (Log Space Usage) +-- Log space usage for current database (Query 51) (Log Space Usage) SELECT DB_NAME(lsu.database_id) AS [Database Name], db.recovery_model_desc AS [Recovery Model], CAST(lsu.total_log_size_in_bytes/1048576.0 AS DECIMAL(10, 2)) AS [Total Log Space (MB)], CAST(lsu.used_log_space_in_bytes/1048576.0 AS DECIMAL(10, 2)) AS [Used Log Space (MB)], @@ -1254,7 +1333,7 @@ OPTION (RECOMPILE); --- Get database scoped configuration values for current database (Query 53) (Database-scoped Configurations) +-- Get database scoped configuration values for current database (Query 52) (Database-scoped Configurations) SELECT configuration_id, name, [value] AS [value_for_primary], value_for_secondary FROM sys.database_scoped_configurations WITH (NOLOCK) OPTION (RECOMPILE); ------ @@ -1265,22 +1344,22 @@ FROM sys.database_scoped_configurations WITH (NOLOCK) OPTION (RECOMPILE); -- ALTER DATABASE SCOPED CONFIGURATION CLEAR PROCEDURE_CACHE; -- ALTER DATABASE SCOPED CONFIGURATION (Transact-SQL) --- https://msdn.microsoft.com/en-us/library/mt629158.aspx +-- https://bit.ly/2sOH7nb --- I/O Statistics by file for the current database (Query 54) (IO Stats By File) +-- I/O Statistics by file for the current database (Query 53) (IO Stats By File) SELECT DB_NAME(DB_ID()) AS [Database Name], df.name AS [Logical Name], vfs.[file_id], df.type_desc, -df.physical_name AS [Physical Name], CAST(vfs.size_on_disk_bytes/1048576.0 AS DECIMAL(10, 2)) AS [Size on Disk (MB)], +df.physical_name AS [Physical Name], CAST(vfs.size_on_disk_bytes/1048576.0 AS DECIMAL(16, 2)) AS [Size on Disk (MB)], vfs.num_of_reads, vfs.num_of_writes, vfs.io_stall_read_ms, vfs.io_stall_write_ms, -CAST(100. * vfs.io_stall_read_ms/(vfs.io_stall_read_ms + vfs.io_stall_write_ms) AS DECIMAL(10,1)) AS [IO Stall Reads Pct], -CAST(100. * vfs.io_stall_write_ms/(vfs.io_stall_write_ms + vfs.io_stall_read_ms) AS DECIMAL(10,1)) AS [IO Stall Writes Pct], +CAST(100. * vfs.io_stall_read_ms/(vfs.io_stall_read_ms + vfs.io_stall_write_ms) AS DECIMAL(16,1)) AS [IO Stall Reads Pct], +CAST(100. * vfs.io_stall_write_ms/(vfs.io_stall_write_ms + vfs.io_stall_read_ms) AS DECIMAL(16,1)) AS [IO Stall Writes Pct], (vfs.num_of_reads + vfs.num_of_writes) AS [Writes + Reads], -CAST(vfs.num_of_bytes_read/1048576.0 AS DECIMAL(10, 2)) AS [MB Read], -CAST(vfs.num_of_bytes_written/1048576.0 AS DECIMAL(10, 2)) AS [MB Written], -CAST(100. * vfs.num_of_reads/(vfs.num_of_reads + vfs.num_of_writes) AS DECIMAL(10,1)) AS [# Reads Pct], -CAST(100. * vfs.num_of_writes/(vfs.num_of_reads + vfs.num_of_writes) AS DECIMAL(10,1)) AS [# Write Pct], -CAST(100. * vfs.num_of_bytes_read/(vfs.num_of_bytes_read + vfs.num_of_bytes_written) AS DECIMAL(10,1)) AS [Read Bytes Pct], -CAST(100. * vfs.num_of_bytes_written/(vfs.num_of_bytes_read + vfs.num_of_bytes_written) AS DECIMAL(10,1)) AS [Written Bytes Pct] +CAST(vfs.num_of_bytes_read/1048576.0 AS DECIMAL(16, 2)) AS [MB Read], +CAST(vfs.num_of_bytes_written/1048576.0 AS DECIMAL(16, 2)) AS [MB Written], +CAST(100. * vfs.num_of_reads/(vfs.num_of_reads + vfs.num_of_writes) AS DECIMAL(16,1)) AS [# Reads Pct], +CAST(100. * vfs.num_of_writes/(vfs.num_of_reads + vfs.num_of_writes) AS DECIMAL(16,1)) AS [# Write Pct], +CAST(100. * vfs.num_of_bytes_read/(vfs.num_of_bytes_read + vfs.num_of_bytes_written) AS DECIMAL(16,1)) AS [Read Bytes Pct], +CAST(100. * vfs.num_of_bytes_written/(vfs.num_of_bytes_read + vfs.num_of_bytes_written) AS DECIMAL(16,1)) AS [Written Bytes Pct] FROM sys.dm_io_virtual_file_stats(DB_ID(), NULL) AS vfs INNER JOIN sys.database_files AS df WITH (NOLOCK) ON vfs.[file_id]= df.[file_id] OPTION (RECOMPILE); @@ -1291,14 +1370,15 @@ ON vfs.[file_id]= df.[file_id] OPTION (RECOMPILE); --- Get most frequently executed queries for this database (Query 55) (Query Execution Counts) +-- Get most frequently executed queries for this database (Query 54) (Query Execution Counts) SELECT TOP(50) LEFT(t.[text], 50) AS [Short Query Text], qs.execution_count AS [Execution Count], qs.total_logical_reads AS [Total Logical Reads], qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], qs.total_worker_time AS [Total Worker Time], qs.total_worker_time/qs.execution_count AS [Avg Worker Time], qs.total_elapsed_time AS [Total Elapsed Time], -qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], qs.creation_time AS [Creation Time] --,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) @@ -1310,15 +1390,21 @@ ORDER BY qs.execution_count DESC OPTION (RECOMPILE); -- Queries 55 through 60 are the "Bad Man List" for stored procedures --- Top Cached SPs By Execution Count (Query 56) (SP Execution Counts) -SELECT TOP(100) p.name AS [SP Name], qs.execution_count, + +-- Top Cached SPs By Execution Count (Query 55) (SP Execution Counts) +SELECT TOP(100) p.name AS [SP Name], qs.execution_count AS [Execution Count], ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], -qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], qs.total_worker_time AS [TotalWorkerTime], -qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], -qs.cached_time +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 ORDER BY qs.execution_count DESC OPTION (RECOMPILE); @@ -1328,15 +1414,20 @@ ORDER BY qs.execution_count DESC OPTION (RECOMPILE); -- This helps you characterize and baseline your workload --- Top Cached SPs By Avg Elapsed Time (Query 57) (SP Avg Elapsed Time) +-- Top Cached SPs By Avg Elapsed Time (Query 56) (SP Avg Elapsed Time) SELECT TOP(25) p.name AS [SP Name], qs.min_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], qs.max_elapsed_time, qs.last_elapsed_time, qs.total_elapsed_time, qs.execution_count, ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], -qs.total_worker_time AS [TotalWorkerTime], qs.cached_time +qs.total_worker_time AS [TotalWorkerTime], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 ORDER BY avg_elapsed_time DESC OPTION (RECOMPILE); @@ -1347,15 +1438,19 @@ ORDER BY avg_elapsed_time DESC OPTION (RECOMPILE); --- Top Cached SPs By Total Worker time. Worker time relates to CPU cost (Query 58) (SP Worker Time) +-- Top Cached SPs By Total Worker time. Worker time relates to CPU cost (Query 57) (SP Worker Time) SELECT TOP(25) p.name AS [SP Name], qs.total_worker_time AS [TotalWorkerTime], qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], qs.execution_count, ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], -qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count -AS [avg_elapsed_time], qs.cached_time +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); @@ -1365,15 +1460,19 @@ ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); -- You should look at this if you see signs of CPU pressure --- Top Cached SPs By Total Logical Reads. Logical reads relate to memory pressure (Query 59) (SP Logical Reads) +-- Top Cached SPs By Total Logical Reads. Logical reads relate to memory pressure (Query 58) (SP Logical Reads) SELECT TOP(25) p.name AS [SP Name], qs.total_logical_reads AS [TotalLogicalReads], qs.total_logical_reads/qs.execution_count AS [AvgLogicalReads],qs.execution_count, ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], -qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count -AS [avg_elapsed_time], qs.cached_time +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE); @@ -1383,14 +1482,18 @@ ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE); -- You should look at this if you see signs of memory pressure --- Top Cached SPs By Total Physical Reads. Physical reads relate to disk read I/O pressure (Query 60) (SP Physical Reads) +-- Top Cached SPs By Total Physical Reads. Physical reads relate to disk read I/O pressure (Query 59) (SP Physical Reads) SELECT TOP(25) p.name AS [SP Name],qs.total_physical_reads AS [TotalPhysicalReads], qs.total_physical_reads/qs.execution_count AS [AvgPhysicalReads], qs.execution_count, -qs.total_logical_reads,qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count -AS [avg_elapsed_time], qs.cached_time +qs.total_logical_reads,qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND qs.total_physical_reads > 0 ORDER BY qs.total_physical_reads DESC, qs.total_logical_reads DESC OPTION (RECOMPILE); @@ -1401,16 +1504,20 @@ ORDER BY qs.total_physical_reads DESC, qs.total_logical_reads DESC OPTION (RECOM --- Top Cached SPs By Total Logical Writes (Query 61) (SP Logical Writes) +-- Top Cached SPs By Total Logical Writes (Query 60) (SP Logical Writes) -- Logical writes relate to both memory and disk I/O pressure SELECT TOP(25) p.name AS [SP Name], qs.total_logical_writes AS [TotalLogicalWrites], qs.total_logical_writes/qs.execution_count AS [AvgLogicalWrites], qs.execution_count, ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], -qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], -qs.cached_time +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND qs.total_logical_writes > 0 AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 @@ -1421,7 +1528,7 @@ ORDER BY qs.total_logical_writes DESC OPTION (RECOMPILE); -- You should look at this if you see signs of I/O pressure or of memory pressure --- Lists the top statements by average input/output usage for the current database (Query 62) (Top IO Statements) +-- Lists the top statements by average input/output usage for the current database (Query 61) (Top IO Statements) SELECT TOP(50) OBJECT_NAME(qt.objectid, dbid) AS [SP Name], (qs.total_logical_reads + qs.total_logical_writes) /qs.execution_count AS [Avg IO], qs.execution_count AS [Execution Count], SUBSTRING(qt.[text],qs.statement_start_offset/2, @@ -1440,19 +1547,24 @@ ORDER BY [Avg IO] DESC OPTION (RECOMPILE); --- Possible Bad NC Indexes (writes > reads) (Query 63) (Bad NC Indexes) -SELECT OBJECT_NAME(s.[object_id]) AS [Table Name], i.name AS [Index Name], i.index_id, +-- Possible Bad NC Indexes (writes > reads) (Query 62) (Bad NC Indexes) +SELECT SCHEMA_NAME(o.[schema_id]) AS [Schema Name], +OBJECT_NAME(s.[object_id]) AS [Table Name], +i.name AS [Index Name], i.index_id, i.is_disabled, i.is_hypothetical, i.has_filter, i.fill_factor, -user_updates AS [Total Writes], user_seeks + user_scans + user_lookups AS [Total Reads], -user_updates - (user_seeks + user_scans + user_lookups) AS [Difference] +s.user_updates AS [Total Writes], s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], +s.user_updates - (s.user_seeks + s.user_scans + s.user_lookups) AS [Difference] FROM sys.dm_db_index_usage_stats AS s WITH (NOLOCK) INNER JOIN sys.indexes AS i WITH (NOLOCK) ON s.[object_id] = i.[object_id] AND i.index_id = s.index_id +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON i.[object_id] = o.[object_id] WHERE OBJECTPROPERTY(s.[object_id],'IsUserTable') = 1 AND s.database_id = DB_ID() -AND user_updates > (user_seeks + user_scans + user_lookups) -AND i.index_id > 1 +AND s.user_updates > (s.user_seeks + s.user_scans + s.user_lookups) +AND i.index_id > 1 AND i.[type_desc] = N'NONCLUSTERED' +AND i.is_primary_key = 0 AND i.is_unique_constraint = 0 AND i.is_unique = 0 ORDER BY [Difference] DESC, [Total Writes] DESC, [Total Reads] ASC OPTION (RECOMPILE); ------ @@ -1461,11 +1573,11 @@ ORDER BY [Difference] DESC, [Total Writes] DESC, [Total Reads] ASC OPTION (RECOM -- Investigate further before dropping an index! --- Missing Indexes for current database by Index Advantage (Query 64) (Missing Indexes) -SELECT DISTINCT CONVERT(decimal(18,2), user_seeks * avg_total_user_cost * (avg_user_impact * 0.01)) AS [index_advantage], +-- Missing Indexes for current database by Index Advantage (Query 63) (Missing Indexes) +SELECT DISTINCT CONVERT(decimal(18,2), migs.user_seeks * migs.avg_total_user_cost * (migs.avg_user_impact * 0.01)) AS [index_advantage], migs.last_user_seek, mid.[statement] AS [Database.Schema.Table], mid.equality_columns, mid.inequality_columns, mid.included_columns, -migs.unique_compiles, migs.user_seeks, migs.avg_total_user_cost, migs.avg_user_impact, +migs.user_seeks, migs.avg_total_user_cost, migs.avg_user_impact, OBJECT_NAME(mid.[object_id]) AS [Table Name], p.rows AS [Table Rows] FROM sys.dm_db_missing_index_group_stats AS migs WITH (NOLOCK) INNER JOIN sys.dm_db_missing_index_groups AS mig WITH (NOLOCK) @@ -1482,12 +1594,13 @@ ORDER BY index_advantage DESC OPTION (RECOMPILE); -- Look at index advantage, last user seek time, number of user seeks to help determine source and importance -- SQL Server is overly eager to add included columns, so beware -- Do not just blindly add indexes that show up from this query!!! +-- Hkan Winther has given me some great suggestions for this query --- Find missing index warnings for cached plans in the current database (Query 65) (Missing Index Warnings) +-- Find missing index warnings for cached plans in the current database (Query 64) (Missing Index Warnings) -- Note: This query could take some time on a busy instance SELECT TOP(25) OBJECT_NAME(objectid) AS [ObjectName], - cp.objtype, cp.usecounts, cp.size_in_bytes, query_plan + cp.objtype, cp.usecounts, cp.size_in_bytes, qp.query_plan FROM sys.dm_exec_cached_plans AS cp WITH (NOLOCK) CROSS APPLY sys.dm_exec_query_plan(cp.plan_handle) AS qp WHERE CAST(query_plan AS NVARCHAR(MAX)) LIKE N'%MissingIndex%' @@ -1499,9 +1612,10 @@ ORDER BY cp.usecounts DESC OPTION (RECOMPILE); -- This can help you decide whether to add them or not --- Breaks down buffers used by current database by object (table, index) in the buffer cache (Query 66) (Buffer Usage) +-- Breaks down buffers used by current database by object (table, index) in the buffer cache (Query 65) (Buffer Usage) -- Note: This query could take some time on a busy instance -SELECT OBJECT_NAME(p.[object_id]) AS [Object Name], p.index_id, +SELECT SCHEMA_NAME(o.Schema_ID) AS [Schema Name], +OBJECT_NAME(p.[object_id]) AS [Object Name], p.index_id, CAST(COUNT(*)/128.0 AS DECIMAL(10, 2)) AS [Buffer size(MB)], COUNT(*) AS [BufferCount], p.[Rows] AS [Row Count], p.data_compression_desc AS [Compression Type] @@ -1510,12 +1624,14 @@ INNER JOIN sys.dm_os_buffer_descriptors AS b WITH (NOLOCK) ON a.allocation_unit_id = b.allocation_unit_id INNER JOIN sys.partitions AS p WITH (NOLOCK) ON a.container_id = p.hobt_id +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON p.object_id = o.object_id WHERE b.database_id = CONVERT(int, DB_ID()) AND p.[object_id] > 100 AND OBJECT_NAME(p.[object_id]) NOT LIKE N'plan_%' AND OBJECT_NAME(p.[object_id]) NOT LIKE N'sys%' AND OBJECT_NAME(p.[object_id]) NOT LIKE N'xml_index_nodes%' -GROUP BY p.[object_id], p.index_id, p.data_compression_desc, p.[Rows] +GROUP BY o.Schema_ID, p.[object_id], p.index_id, p.data_compression_desc, p.[Rows] ORDER BY [BufferCount] DESC OPTION (RECOMPILE); ------ @@ -1523,29 +1639,32 @@ ORDER BY [BufferCount] DESC OPTION (RECOMPILE); -- It can help identify possible candidates for data compression --- Get Table names, row counts, and compression status for clustered index or heap (Query 67) (Table Sizes) -SELECT OBJECT_NAME(object_id) AS [ObjectName], -SUM(Rows) AS [RowCount], data_compression_desc AS [CompressionType] -FROM sys.partitions WITH (NOLOCK) +-- Get Table names, row counts, and compression status for clustered index or heap (Query 66) (Table Sizes) +SELECT SCHEMA_NAME(o.Schema_ID) AS [Schema Name], OBJECT_NAME(p.object_id) AS [ObjectName], +SUM(p.Rows) AS [RowCount], p.data_compression_desc AS [Compression Type] +FROM sys.partitions AS p WITH (NOLOCK) +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON p.object_id = o.object_id WHERE index_id < 2 --ignore the partitions from the non-clustered index if any -AND OBJECT_NAME(object_id) NOT LIKE N'sys%' -AND OBJECT_NAME(object_id) NOT LIKE N'queue_%' -AND OBJECT_NAME(object_id) NOT LIKE N'filestream_tombstone%' -AND OBJECT_NAME(object_id) NOT LIKE N'fulltext%' -AND OBJECT_NAME(object_id) NOT LIKE N'ifts_comp_fragment%' -AND OBJECT_NAME(object_id) NOT LIKE N'filetable_updates%' -AND OBJECT_NAME(object_id) NOT LIKE N'xml_index_nodes%' -AND OBJECT_NAME(object_id) NOT LIKE N'sqlagent_job%' -AND OBJECT_NAME(object_id) NOT LIKE N'plan_persist%' -GROUP BY object_id, data_compression_desc -ORDER BY SUM(Rows) DESC OPTION (RECOMPILE); +AND OBJECT_NAME(p.object_id) NOT LIKE N'sys%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'spt_%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'queue_%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'filestream_tombstone%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'fulltext%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'ifts_comp_fragment%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'filetable_updates%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'xml_index_nodes%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'sqlagent_job%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'plan_persist%' +GROUP BY SCHEMA_NAME(o.Schema_ID), p.object_id, data_compression_desc +ORDER BY SUM(p.Rows) DESC OPTION (RECOMPILE); ------ -- Gives you an idea of table sizes, and possible data compression opportunities --- Get some key table properties (Query 68) (Table Properties) +-- Get some key table properties (Query 67) (Table Properties) SELECT OBJECT_NAME(t.[object_id]) AS [ObjectName], p.[rows] AS [Table Rows], p.index_id, p.data_compression_desc AS [Index Data Compression], t.create_date, t.lock_on_bulk_load, t.is_replicated, t.has_replication_filter, @@ -1564,11 +1683,11 @@ ORDER BY OBJECT_NAME(t.[object_id]), p.index_id OPTION (RECOMPILE); -- temporal_type_desc, is_remote_data_archive_enabled, is_external are new in SQL Server 2016 -- sys.tables (Transact-SQL) --- https://msdn.microsoft.com/en-us/library/ms187406.aspx +-- https://bit.ly/2Gk7998 --- When were Statistics last updated on all indexes? (Query 69) (Statistics Update) +-- When were Statistics last updated on all indexes? (Query 68) (Statistics Update) SELECT SCHEMA_NAME(o.Schema_ID) + N'.' + o.[NAME] AS [Object Name], o.[type_desc] AS [Object Type], i.[name] AS [Index Name], STATS_DATE(i.[object_id], i.index_id) AS [Statistics Date], s.auto_created, s.no_recompute, s.user_created, s.is_incremental, s.is_temporary, @@ -1591,11 +1710,14 @@ ORDER BY STATS_DATE(i.[object_id], i.index_id) DESC OPTION (RECOMPILE); -- Also gives you an idea which indexes are the most active -- sys.stats (Transact-SQL) --- https://msdn.microsoft.com/en-us/library/ms177623.aspx +-- https://bit.ly/2GyAxrn + +-- UPDATEs to Statistics (Erin Stellato) +-- https://bit.ly/2vhrYQy --- Look at most frequently modified indexes and statistics (Query 70) (Volatile Indexes) +-- Look at most frequently modified indexes and statistics (Query 69) (Volatile Indexes) SELECT o.[name] AS [Object Name], o.[object_id], o.[type_desc], s.[name] AS [Statistics Name], s.stats_id, s.no_recompute, s.auto_created, s.is_incremental, s.is_temporary, sp.modification_counter, sp.[rows], sp.rows_sampled, sp.last_updated @@ -1613,7 +1735,7 @@ ORDER BY sp.modification_counter DESC, o.name OPTION (RECOMPILE); --- Get fragmentation info for all indexes above a certain size in the current database (Query 71) (Index Fragmentation) +-- Get fragmentation info for all indexes above a certain size in the current database (Query 70) (Index Fragmentation) -- Note: This query could take some time on a very large database SELECT DB_NAME(ps.database_id) AS [Database Name], SCHEMA_NAME(o.[schema_id]) AS [Schema Name], OBJECT_NAME(ps.OBJECT_ID) AS [Object Name], i.[name] AS [Index Name], ps.index_id, @@ -1635,7 +1757,7 @@ ORDER BY ps.avg_fragmentation_in_percent DESC OPTION (RECOMPILE); -- and how effective your index maintenance strategy is ---- Index Read/Write stats (all tables in current DB) ordered by Reads (Query 72) (Overall Index Usage - Reads) +--- Index Read/Write stats (all tables in current DB) ordered by Reads (Query 71) (Overall Index Usage - Reads) SELECT OBJECT_NAME(i.[object_id]) AS [ObjectName], i.[name] AS [IndexName], i.index_id, s.user_seeks, s.user_scans, s.user_lookups, s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], @@ -1654,7 +1776,7 @@ ORDER BY s.user_seeks + s.user_scans + s.user_lookups DESC OPTION (RECOMPILE); - -- Show which indexes in the current database are most active for Reads ---- Index Read/Write stats (all tables in current DB) ordered by Writes (Query 73) (Overall Index Usage - Writes) +--- Index Read/Write stats (all tables in current DB) ordered by Writes (Query 72) (Overall Index Usage - Writes) SELECT OBJECT_NAME(i.[object_id]) AS [ObjectName], i.[name] AS [IndexName], i.index_id, s.user_updates AS [Writes], s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], i.[type_desc] AS [Index Type], i.fill_factor AS [Fill Factor], i.has_filter, i.filter_definition, @@ -1671,7 +1793,7 @@ ORDER BY s.user_updates DESC OPTION (RECOMPILE); -- Order by writes -- Show which indexes in the current database are most active for Writes --- Get in-memory OLTP index usage (Query 74) (XTP Index Usage) +-- Get in-memory OLTP index usage (Query 73) (XTP Index Usage) SELECT OBJECT_NAME(i.[object_id]) AS [Object Name], i.index_id, i.[name] AS [Index Name], i.[type_desc], xis.scans_started, xis.scans_retries, xis.rows_touched, xis.rows_returned @@ -1686,10 +1808,10 @@ ORDER BY OBJECT_NAME(i.[object_id]) OPTION (RECOMPILE); -- Returns no data if you are not using in-memory OLTP -- Guidelines for Using Indexes on Memory-Optimized Tables --- https://msdn.microsoft.com/en-us/library/dn133166.aspx +-- https://bit.ly/2GCP8lF --- Look at Columnstore index physical statistics (Query 75) (Columnstore Index Physical Stat) +-- Look at Columnstore index physical statistics (Query 74) (Columnstore Index Physical Stat) SELECT OBJECT_NAME(ps.object_id) AS [TableName], i.[name] AS [IndexName], ps.index_id, ps.partition_number, ps.delta_store_hobt_id, ps.state_desc, ps.total_rows, ps.size_in_bytes, @@ -1704,10 +1826,10 @@ ORDER BY ps.object_id, ps.partition_number, ps.row_group_id OPTION (RECOMPILE); ------ -- sys.dm_db_column_store_row_group_physical_stats (Transact-SQL) --- https://msdn.microsoft.com/en-us/library/dn832030.aspx +-- https://bit.ly/2q276XQ --- Get lock waits for current database (Query 76) (Lock Waits) +-- Get lock waits for current database (Query 75) (Lock Waits) SELECT o.name AS [table_name], i.name AS [index_name], ios.index_id, ios.partition_number, SUM(ios.row_lock_wait_count) AS [total_row_lock_waits], SUM(ios.row_lock_wait_in_ms) AS [total_row_lock_wait_in_ms], @@ -1730,10 +1852,11 @@ ORDER BY total_lock_wait_in_ms DESC OPTION (RECOMPILE); --- Look at UDF execution statistics (Query 77) (UDF Statistics) +-- Look at UDF execution statistics (Query 76) (UDF Statistics) SELECT OBJECT_NAME(object_id) AS [Function Name], execution_count, - total_worker_time, total_logical_reads, total_physical_reads, - total_elapsed_time + total_worker_time, total_logical_reads, total_physical_reads, total_elapsed_time, + total_elapsed_time/execution_count AS [avg_elapsed_time], + FORMAT(cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] FROM sys.dm_exec_function_stats WITH (NOLOCK) WHERE database_id = DB_ID() ORDER BY total_worker_time DESC OPTION (RECOMPILE); @@ -1741,12 +1864,13 @@ ORDER BY total_worker_time DESC OPTION (RECOMPILE); -- New for SQL Server 2016 -- Helps you investigate scalar UDF performance issues +-- Does not return information for table valued functions -- sys.dm_exec_function_stats (Transact-SQL) --- https://msdn.microsoft.com/en-US/library/mt429371.aspx +-- https://bit.ly/2q1Q6BM --- Get Query Store Options for this database (Query 78) (QueryStore Options) +-- Get Query Store Options for this database (Query 77) (QueryStore Options) SELECT actual_state_desc, desired_state_desc, [interval_length_minutes], current_storage_size_mb, [max_storage_size_mb], query_capture_mode_desc, size_based_cleanup_mode_desc @@ -1757,53 +1881,11 @@ FROM sys.database_query_store_options WITH (NOLOCK) OPTION (RECOMPILE); -- Requires that Query Store is enabled for this database -- Tuning Workload Performance with Query Store --- http://blogs.technet.com/b/dataplatforminsider/archive/2015/12/16/tuning-workload-performance-with-query-store.aspx +-- https://bit.ly/1kHSl7w --- Get highest aggregate duration queries over last hour (Query 79) (High Aggregate Duration Queries) -WITH AggregatedDurationLastHour -AS -(SELECT q.query_id, SUM(count_executions * avg_duration) AS total_duration, - COUNT (distinct p.plan_id) AS number_of_plans - FROM sys.query_store_query_text AS qt WITH (NOLOCK) - INNER JOIN sys.query_store_query AS q WITH (NOLOCK) - ON qt.query_text_id = q.query_text_id - INNER JOIN sys.query_store_plan AS p WITH (NOLOCK) - ON q.query_id = p.query_id - INNER JOIN sys.query_store_runtime_stats AS rs WITH (NOLOCK) - ON rs.plan_id = p.plan_id - INNER JOIN sys.query_store_runtime_stats_interval AS rsi WITH (NOLOCK) - ON rsi.runtime_stats_interval_id = rs.runtime_stats_interval_id - WHERE rsi.start_time >= DATEADD(hour, -1, GETUTCDATE()) - AND rs.execution_type_desc = N'Regular' - GROUP BY q.query_id), -OrderedDuration AS -(SELECT query_id, total_duration, number_of_plans, - ROW_NUMBER () OVER (ORDER BY total_duration DESC, query_id) AS RN - FROM AggregatedDurationLastHour) -SELECT OBJECT_NAME(q.object_id) AS [Containing Object], qt.query_sql_text, -od.total_duration AS [Total Duration (microsecs)], -od.number_of_plans AS [Plan Count], -p.is_forced_plan, p.is_parallel_plan, p.is_trivial_plan, -q.query_parameterization_type_desc, p.[compatibility_level], -p.last_compile_start_time, q.last_execution_time, -CONVERT(xml, p.query_plan) AS query_plan_xml -FROM OrderedDuration AS od -INNER JOIN sys.query_store_query AS q WITH (NOLOCK) -ON q.query_id = od.query_id -INNER JOIN sys.query_store_query_text AS qt WITH (NOLOCK) -ON q.query_text_id = qt.query_text_id -INNER JOIN sys.query_store_plan AS p WITH (NOLOCK) -ON q.query_id = p.query_id -WHERE od.RN <= 50 -ORDER BY total_duration DESC OPTION (RECOMPILE); ------- --- New for SQL Server 2016 --- Requires that QueryStore is enabled for this database - - --- Get input buffer information for the current database (Query 80) (Input Buffer) +-- Get input buffer information for the current database (Query 78) (Input Buffer) SELECT es.session_id, DB_NAME(es.database_id) AS [Database Name], es.login_time, es.cpu_time, es.logical_reads, es.[status], ib.event_info AS [Input Buffer] @@ -1817,11 +1899,11 @@ AND es.session_id <> @@SPID OPTION (RECOMPILE); -- Replaces DBCC INPUTBUFFER -- New DMF for retrieving input buffer in SQL Server --- https://blogs.msdn.microsoft.com/sql_server_team/new-dmf-for-retrieving-input-buffer-in-sql-server/ +-- https://bit.ly/2uHKMbz --- Look at recent Full backups for the current database (Query 81) (Recent Full Backups) +-- Look at recent Full backups for the current database (Query 79) (Recent Full Backups) SELECT TOP (30) bs.machine_name, bs.server_name, bs.database_name AS [Database Name], bs.recovery_model, CONVERT (BIGINT, bs.backup_size / 1048576 ) AS [Uncompressed Backup Size (MB)], CONVERT (BIGINT, bs.compressed_backup_size / 1048576 ) AS [Compressed Backup Size (MB)], @@ -1845,36 +1927,38 @@ ORDER BY bs.backup_finish_date DESC OPTION (RECOMPILE); -- Have you done any backup tuning with striped backups, or changing the parameters of the backup command? -- In SQL Server 2016, native SQL Server backup compression actually works much better with databases that are using TDE than in previous versions --- https://blogs.msdn.microsoft.com/sqlcat/2016/06/20/sqlsweet16-episode-1-backup-compression-for-tde-enabled-databases/ +-- https://bit.ly/28Rpb2x + + +-- These six Pluralsight Courses go into more detail about how to run these queries and interpret the results + +-- Azure SQL Database: Diagnosing Performance Issues with DMVs +-- https://bit.ly/2meDRCN +-- SQL Server 2017: Diagnosing Performance Issues with DMVs +-- https://bit.ly/2FqCeti --- These three Pluralsight Courses go into more detail about how to run these queries and interpret the results +-- SQL Server 2017: Diagnosing Configuration Issues with DMVs +-- https://bit.ly/2MSUDUL -- SQL Server 2014 DMV Diagnostic Queries Part 1 --- https://www.pluralsight.com/courses/sql-server-2014-dmv-diagnostic-queries-part1 +-- https://bit.ly/2plxCer -- SQL Server 2014 DMV Diagnostic Queries Part 2 --- https://www.pluralsight.com/courses/sql-server-2014-dmv-diagnostic-queries-part2 +-- https://bit.ly/2IuJpzI -- SQL Server 2014 DMV Diagnostic Queries Part 3 --- https://www.pluralsight.com/courses/sql-server-2014-dmv-diagnostic-queries-part3 +-- https://bit.ly/2FIlCPb --- Sign up for Microsoft Visual Studio Dev Essentials and get a free three month pass to Pluralsight - -- Microsoft Visual Studio Dev Essentials --- http://bit.ly/1q6xbDL - - --- Sign up for Microsoft IT Pro Cloud Essentials and get lots of free Azure usage credits, MCP exam voucher, three month Pluralsight subscription - --- Microsoft IT Pro Cloud Essentials --- http://bit.ly/2443SAd - +-- https://bit.ly/2qjNRxi --- August 2017 blog series about upgrading and migrating SQL Server --- https://www.sqlskills.com/blogs/glenn/category/upgrading-sql-server/ +-- Microsoft Azure Learn +-- https://bit.ly/2O0Hacc +-- August 2017 blog series about upgrading and migrating to SQL Server 2016/2017 +-- https://bit.ly/2ftKVrX diff --git a/Scripts/SQL Server 2016 SP1 Diagnostic Information Queries.sql b/Scripts/SQL Server 2016 SP1 Diagnostic Information Queries.sql new file mode 100644 index 00000000..061677ad --- /dev/null +++ b/Scripts/SQL Server 2016 SP1 Diagnostic Information Queries.sql @@ -0,0 +1,2015 @@ + +-- SQL Server 2016 Diagnostic Information Queries +-- Glenn Berry +-- Last Modified: December 3, 2020 +-- https://glennsqlperformance.com/ +-- https://sqlserverperformance.wordpress.com/ +-- YouTube: https://bit.ly/2PkoAM1 +-- Twitter: GlennAlanBerry + +-- Diagnostic Queries are available here +-- https://glennsqlperformance.com/resources/ + + +-- Please make sure you are using the correct version of these diagnostic queries for your version of SQL Server + + +-- If you like PowerShell, there is a very useful community solution for running these queries in an automated fashion +-- https://dbatools.io/ + +-- Invoke-DbaDiagnosticQuery +-- https://dbatools.io/functions/invoke-dbadiagnosticquery/ + + +--****************************************************************************** +--* Copyright (C) 2020 Glenn Berry +--* All rights reserved. +--* +--* +--* You may alter this code for your own *non-commercial* purposes. You may +--* republish altered code as long as you include this copyright and give due credit. +--* +--* +--* THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF +--* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED +--* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +--* PARTICULAR PURPOSE. +--* +--****************************************************************************** + +-- Check the major product version to see if it is SQL Server 2016 CTP 2 or greater +IF NOT EXISTS (SELECT * WHERE CONVERT(varchar(128), SERVERPROPERTY('ProductVersion')) LIKE '13%') + BEGIN + DECLARE @ProductVersion varchar(128) = CONVERT(varchar(128), SERVERPROPERTY('ProductVersion')); + RAISERROR ('Script does not match the ProductVersion [%s] of this instance. Many of these queries may not work on this version.' , 18 , 16 , @ProductVersion); + END + ELSE + PRINT N'You have the correct major version of SQL Server for this diagnostic information script'; + + +-- Instance level queries ******************************* + +-- SQL and OS Version information for current instance (Query 1) (Version Info) +SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version Info]; +------ + +-- SQL Server 2016 RTM Branch Builds -- SQL Server 2016 SP1 Branch Builds -- SQL Server 2016 SP2 Branch Builds +-- Build Description Release Date Build Description Release Date Build Description Release Date +-- 13.0.200.172 CTP 2.0 5/26/2015 +-- 13.0.300.44 CTP 2.1 6/14/2015 +-- 13.0.407.1 CTP 2.2 7/28/2015 +-- 13.0.500.53 CTP 2.3 9/4/2015 +-- 13.0.600.65 CTP 2.4 9/30/2015 +-- 13.0.700.242 CTP 3.0 10/29/2015 +-- 13.0.900.73 CTP 3.2 12/12/2015 +-- 13.0.1000.276 CTP 3.3 1/27/2016 +-- 13.0.1100.288 RC0 3/2/2016 +-- 13.0.1200.242 RC1 3/18/2016 +-- 13.0.1300.275 RC2 3/28/2016 +-- 13.0.1400.361 RC3 4/11/2016 +-- 13.0.1601.5 RTM 6/1/2016 +-- 13.0.1708.0 RTM-GDR 6/12/2016 +-- 13.0.2149.0 RTM CU1 7/25/2016 +-- 13.0.2164.0 RTM CU2 9/22/2016 +-- 13.0.2186.0 RTM CU3 11/16/2016 ----> 13.0.4001.0 SP1 RTM 11/16/2016 +-- 13.0.2193.0 RTM CU4 1/18/2017 ----> 13.0.4411.0 SP1 CU1 1/18/2017 +-- 13.0.2197.0 RTM CU5 3/20/2017 ----> 13.0.4422.0 SP1 CU2 3/20/2017 +-- 13.0.2204.0 RTM CU6 5/15/2017 ----> 13.0.4435.0 SP1 CU3 5/15/2017 +-- 13.0.2210.0 RTM CU7 8/8/2017 ----> 13.0.4446.0 SP1 CU4 8/8/2017 +-- 13.0.2213.0 RTM CU8 9/18/2017 ----> 13.0.4451.0 SP1 CU5 9/18/2017 +-- 13.0.2216.0 RTM CU9 11/21/2017 ----> 13.0.4457.0 SP1 CU6 11/21/2017 +-- 13.0.4466.4 SP1 CU7 1/4/2018 +-- 13.0.4474.0 SP1 CU8 3/20/2018 ----> 13.0.5026.0 SP2 RTM 4/24/2018 +-- 13.0.4502.0 SP1 CU9 5/30/2018 ----> 13.0.5149.0 SP2 CU1 5/30/2018 +-- 13.0.4514.0 SP1 CU10 7/16/2018 ----> 13.0.5153.0 SP2 CU2 7/16/2018 +-- 13.0.4528.0 SP1 CU11 9/17/2018 ----> 13.0.5216.0 SP2 CU3 9/20/2018 +-- 13.0.4541.0 SP1 CU12 11/13/2018 ----> 13.0.5233.0 SP2 CU4 11/13/2018 +-- 13.0.4550.1 SP1 CU13 1/23/2019 ----> 13.0.5264.1 SP2 CU5 1/23/2019 +-- 13.0.4560.0 SP1 CU14 3/19/2019 ----> 13.0.5292.0 SP2 CU6 3/19/2019 +-- 13.0.4574.0 SP1 CU15 5/16/2019 ----> 13.0.5337.0 SP2 CU7 5/22/2019 +-- 13.0.5426.0 SP2 CU8 7/31/2019 +-- 13.0.5470.0 SP2 CU9 9/30/2019 +-- 13.0.5492.2 SP2 CU10 10/8/2019 +-- 13.0.5598.27 SP2 CU11 12/9/2019 +-- 13.0.5698.0 SP2 CU12 2/25/2020 +-- 13.0.5820.21 SP2 CU13 5/28/2020 +-- 13.0.5830.85 SP2 CU14 8/6/2020 +-- 13.0.5850.14 SP2 CU15 9/28/2020 + +-- How to determine the version, edition and update level of SQL Server and its components +-- https://bit.ly/2oAjKgW + +-- How to obtain the latest Service Pack for SQL Server 2016 +-- https://bit.ly/2egtfzK + +-- SQL Server 2016 build versions +-- https://bit.ly/2epkTDT + +-- Recommended updates and configuration options for SQL Server 2017 and 2016 with high-performance workloads +-- https://bit.ly/2JsReue + +-- Performance and Stability Related Fixes in Post-SQL Server 2016 SP1 Builds +-- https://bit.ly/2gr7k9L + +-- Performance and Stability Related Fixes in Post-SQL Server 2016 SP2 Builds +-- https://bit.ly/2K3LoPf + +-- Update Center for Microsoft SQL Server +-- https://bit.ly/2pZptuQ + +-- Download SQL Server Management Studio (SSMS) +-- https://bit.ly/1OcupT9 + +-- Download and install Azure Data Studio +-- https://bit.ly/2vgke1A + +-- SQL Server 2016 Configuration Manager is SQLServerManager13.msc + + +-- Get socket, physical core and logical core count from the SQL Server Error log. (Query 2) (Core Counts) +-- This query might take a few seconds depending on the size of your error log +EXEC sys.xp_readerrorlog 0, 1, N'detected', N'socket'; +------ + +-- This can help you determine the exact core counts used by SQL Server and whether HT is enabled or not +-- It can also help you confirm your SQL Server licensing model +-- Be on the lookout for this message "using 40 logical processors based on SQL Server licensing" +-- (when you have more than 40 logical cores) which means grandfathered Server/CAL licensing +-- This query will return no results if your error log has been recycled since the instance was last started + + + +-- Get selected server properties (Query 3) (Server Properties) +SELECT SERVERPROPERTY('MachineName') AS [MachineName], +SERVERPROPERTY('ServerName') AS [ServerName], +SERVERPROPERTY('InstanceName') AS [Instance], +SERVERPROPERTY('IsClustered') AS [IsClustered], +SERVERPROPERTY('ComputerNamePhysicalNetBIOS') AS [ComputerNamePhysicalNetBIOS], +SERVERPROPERTY('Edition') AS [Edition], +SERVERPROPERTY('ProductLevel') AS [ProductLevel], -- What servicing branch (RTM/SP/CU) +SERVERPROPERTY('ProductUpdateLevel') AS [ProductUpdateLevel], -- Within a servicing branch, what CU# is applied +SERVERPROPERTY('ProductVersion') AS [ProductVersion], +SERVERPROPERTY('ProductMajorVersion') AS [ProductMajorVersion], +SERVERPROPERTY('ProductMinorVersion') AS [ProductMinorVersion], +SERVERPROPERTY('ProductBuild') AS [ProductBuild], +SERVERPROPERTY('ProductBuildType') AS [ProductBuildType], -- Is this a GDR or OD hotfix (NULL if on a CU build) +SERVERPROPERTY('ProductUpdateReference') AS [ProductUpdateReference], -- KB article number that is applicable for this build +SERVERPROPERTY('ProcessID') AS [ProcessID], +SERVERPROPERTY('Collation') AS [Collation], +SERVERPROPERTY('IsFullTextInstalled') AS [IsFullTextInstalled], +SERVERPROPERTY('IsIntegratedSecurityOnly') AS [IsIntegratedSecurityOnly], +SERVERPROPERTY('FilestreamConfiguredLevel') AS [FilestreamConfiguredLevel], +SERVERPROPERTY('IsHadrEnabled') AS [IsHadrEnabled], +SERVERPROPERTY('HadrManagerStatus') AS [HadrManagerStatus], +SERVERPROPERTY('InstanceDefaultDataPath') AS [InstanceDefaultDataPath], +SERVERPROPERTY('InstanceDefaultLogPath') AS [InstanceDefaultLogPath], +SERVERPROPERTY('ErrorLogFileName') AS [ErrorLogFileName], +SERVERPROPERTY('BuildClrVersion') AS [Build CLR Version], +SERVERPROPERTY('IsXTPSupported') AS [IsXTPSupported], +SERVERPROPERTY('IsPolybaseInstalled') AS [IsPolybaseInstalled], -- New for SQL Server 2016 +SERVERPROPERTY('IsAdvancedAnalyticsInstalled') AS [IsRServicesInstalled]; -- New for SQL Server 2016 +------ + +-- This gives you a lot of useful information about your instance of SQL Server, +-- such as the ProcessID for SQL Server and your collation +-- Note: Some columns will be NULL on older SQL Server builds + +-- SERVERPROPERTY (Transact-SQL) +-- https://bit.ly/2eeaXeI + + + +-- Get instance-level configuration values for instance (Query 4) (Configuration Values) +SELECT name, value, value_in_use, minimum, maximum, [description], is_dynamic, is_advanced +FROM sys.configurations WITH (NOLOCK) +ORDER BY name OPTION (RECOMPILE); +------ + +-- Focus on these settings: +-- automatic soft-NUMA disabled (should be 0 in most cases) +-- backup checksum default (should be 1) +-- backup compression default (should be 1 in most cases) +-- clr enabled (only enable if it is needed) +-- cost threshold for parallelism (depends on your workload) +-- lightweight pooling (should be zero) +-- max degree of parallelism (depends on your workload and hardware) +-- max server memory (MB) (set to an appropriate value, not the default) +-- optimize for ad hoc workloads (should be 1) +-- priority boost (should be zero) +-- remote admin connections (should be 1) + + +-- sys.configurations (Transact-SQL) +-- https://bit.ly/2HsyDZI + +-- New configuration options for SQL Server 2016 +-- allow polybase export (Allow INSERT into a Hadoop external table) +-- automatic soft-NUMA disabled (Automatic soft-NUMA is enabled by default) +-- external scripts enabled (Allows execution of external scripts, for R Services) +-- hadoop connectivity (Configure SQL Server to connect to external Hadoop or Microsoft Azure storage blob data sources through PolyBase) +-- polybase network encryption (Configure SQL Server to encrypt control and data channels when using PolyBase) +-- remote data archive (Allow the use of the REMOTE_DATA_ARCHIVE data access for Stretch databases) + +-- SQLSweet16!, Episode 1: Backup Compression for TDE-enabled Databases +-- https://bit.ly/28Rpb2x + + + +-- Returns a list of all global trace flags that are enabled (Query 5) (Global Trace Flags) +DBCC TRACESTATUS (-1); +------ + +-- If no global trace flags are enabled, no results will be returned. +-- It is very useful to know what global trace flags are currently enabled as part of the diagnostic process. + +-- Common trace flags that should be enabled in most cases +-- TF 460 - Improvement: Optional replacement for "String or binary data would be truncated" message with extended information in SQL Server 2017 +-- https://bit.ly/2sboMli (added in SP2 CU6) + +-- TF 3226 - Supresses logging of successful database backup messages to the SQL Server Error Log +-- https://bit.ly/38zDNAK + +-- TF 6534 - Enables use of native code to improve performance with spatial data +-- https://bit.ly/2HrQUpU + +-- TF 7745 - Prevents Query Store data from being written to disk in case of a failover or shutdown command +-- https://bit.ly/2GU69Km + +-- TF 7752 - Enables asynchronous load of Query Store +-- This allows a database to become online and queries to be executed before the Query Store has been fully recovered + +-- The behavior of TF 1117, 1118 are enabled for tempdb in SQL Server 2016 by default +-- SQL 2016 It Just Runs Faster: -T1117 and -T1118 changes for TEMPDB and user databases +-- https://bit.ly/2lbNWxK + +-- The behavior of TF 2371 is enabled by default in SQL Server 2016 and newer (in compat level 130 and higher) + +-- DBCC TRACEON - Trace Flags (Transact-SQL) +-- https://bit.ly/2FuSvPg + +-- Recommended updates and configuration options for SQL Server 2017 and 2016 with high-performance workloads +-- https://bit.ly/2VVRGTY + + + + +-- SQL Server Process Address space info (Query 6) (Process Memory) +-- (shows whether locked pages is enabled, among other things) +SELECT physical_memory_in_use_kb/1024 AS [SQL Server Memory Usage (MB)], + locked_page_allocations_kb/1024 AS [SQL Server Locked Pages Allocation (MB)], + large_page_allocations_kb/1024 AS [SQL Server Large Pages Allocation (MB)], + page_fault_count, memory_utilization_percentage, available_commit_limit_kb, + process_physical_memory_low, process_virtual_memory_low +FROM sys.dm_os_process_memory WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- You want to see 0 for process_physical_memory_low +-- You want to see 0 for process_virtual_memory_low +-- This indicates that you are not under internal memory pressure +-- If locked_page_allocations_kb > 0, then LPIM is enabled + +-- How to enable the "locked pages" feature in SQL Server 2012 +-- https://bit.ly/2F5UjOA + +-- Memory Management Architecture Guide +-- https://bit.ly/2JKkadC + + + +-- SQL Server Services information (Query 7) (SQL Server Services Info) +SELECT servicename, process_id, startup_type_desc, status_desc, +last_startup_time, service_account, is_clustered, cluster_nodename, [filename], +instant_file_initialization_enabled +FROM sys.dm_server_services WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- Tells you the account being used for the SQL Server Service and the SQL Agent Service +-- Shows the process_id, when they were last started, and their current status +-- Also shows whether you are running on a failover cluster instance, and what node you are running on +-- Also shows whether IFI is enabled + +-- sys.dm_server_services (Transact-SQL) +-- https://bit.ly/2oKa1Un + + +-- Last backup information by database (Query 8) (Last Backup By Database) +SELECT ISNULL(d.[name], bs.[database_name]) AS [Database], d.recovery_model_desc AS [Recovery Model], + d.log_reuse_wait_desc AS [Log Reuse Wait Desc], + MAX(CASE WHEN [type] = 'D' THEN bs.backup_finish_date ELSE NULL END) AS [Last Full Backup], + MAX(CASE WHEN [type] = 'D' THEN bmf.physical_device_name ELSE NULL END) AS [Last Full Backup Location], + MAX(CASE WHEN [type] = 'I' THEN bs.backup_finish_date ELSE NULL END) AS [Last Differential Backup], + MAX(CASE WHEN [type] = 'I' THEN bmf.physical_device_name ELSE NULL END) AS [Last Differential Backup Location], + MAX(CASE WHEN [type] = 'L' THEN bs.backup_finish_date ELSE NULL END) AS [Last Log Backup], + MAX(CASE WHEN [type] = 'L' THEN bmf.physical_device_name ELSE NULL END) AS [Last Log Backup Location] +FROM sys.databases AS d WITH (NOLOCK) +LEFT OUTER JOIN msdb.dbo.backupset AS bs WITH (NOLOCK) +ON bs.[database_name] = d.[name] +LEFT OUTER JOIN msdb.dbo.backupmediafamily AS bmf WITH (NOLOCK) +ON bs.media_set_id = bmf.media_set_id +AND bs.backup_finish_date > GETDATE()- 30 +WHERE d.name <> N'tempdb' +GROUP BY ISNULL(d.[name], bs.[database_name]), d.recovery_model_desc, d.log_reuse_wait_desc, d.[name] +ORDER BY d.recovery_model_desc, d.[name] OPTION (RECOMPILE); +------ + +-- This helps you spot runaway transaction logs and other issues with your backup schedule + + +-- Get SQL Server Agent jobs and Category information (Query 9) (SQL Server Agent Jobs) +SELECT sj.name AS [Job Name], sj.[description] AS [Job Description], SUSER_SNAME(sj.owner_sid) AS [Job Owner], +sj.date_created AS [Date Created], sj.[enabled] AS [Job Enabled], +sj.notify_email_operator_id, sj.notify_level_email, sc.name AS [CategoryName], +s.[enabled] AS [Sched Enabled], js.next_run_date, js.next_run_time +FROM msdb.dbo.sysjobs AS sj WITH (NOLOCK) +INNER JOIN msdb.dbo.syscategories AS sc WITH (NOLOCK) +ON sj.category_id = sc.category_id +LEFT OUTER JOIN msdb.dbo.sysjobschedules AS js WITH (NOLOCK) +ON sj.job_id = js.job_id +LEFT OUTER JOIN msdb.dbo.sysschedules AS s WITH (NOLOCK) +ON js.schedule_id = s.schedule_id +ORDER BY sj.name OPTION (RECOMPILE); +------ + +-- Gives you some basic information about your SQL Server Agent jobs, who owns them and how they are configured +-- Look for Agent jobs that are not owned by sa +-- Look for jobs that have a notify_email_operator_id set to 0 (meaning no operator) +-- Look for jobs that have a notify_level_email set to 0 (meaning no e-mail is ever sent) +-- +-- MSDN sysjobs documentation +-- https://bit.ly/2paDEOP + +-- SQL Server Maintenance Solution +-- https://bit.ly/1pgchQu + +-- You can use this script to add default schedules to the standard Ola Hallengren Maintenance Solution jobs +-- https://bit.ly/3ane0gN + + +-- Get SQL Server Agent Alert Information (Query 10) (SQL Server Agent Alerts) +SELECT name, event_source, message_id, severity, [enabled], has_notification, + delay_between_responses, occurrence_count, last_occurrence_date, last_occurrence_time +FROM msdb.dbo.sysalerts WITH (NOLOCK) +ORDER BY name OPTION (RECOMPILE); +------ + +-- Gives you some basic information about your SQL Server Agent Alerts +-- (which are different from SQL Server Agent jobs) +-- Read more about Agent Alerts here: https://bit.ly/2v5YR37 + + + +-- Windows information (Query 11) (Windows Info) +SELECT windows_release, windows_service_pack_level, + windows_sku, os_language_version +FROM sys.dm_os_windows_info WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- Gives you major OS version, Service Pack, Edition, and language info for the operating system +-- 10.0 is either Windows 10 or Windows Server 2016 +-- 6.3 is either Windows 8.1 or Windows Server 2012 R2 +-- 6.2 is either Windows 8 or Windows Server 2012 + + +-- Windows SKU codes +-- 4 is Enterprise Edition +-- 7 is Standard Server Edition +-- 8 is Datacenter Server Edition +-- 10 is Enterprise Server Edition +-- 48 is Professional Edition +-- 161 is Pro for Workstations + +-- 1033 for os_language_version is US-English + +-- SQL Server 2016 requires Windows Server 2012 or newer + +-- Quick-Start Installation of SQL Server 2016 +-- https://bit.ly/2qtxQ3G + +-- Hardware and Software Requirements for Installing SQL Server 2016 +-- https://bit.ly/2JJIUTl + +-- Using SQL Server in Windows 8 and later versions of Windows operating system +-- https://bit.ly/2F7Ax0P + + +-- SQL Server NUMA Node information (Query 12) (SQL Server NUMA Info) +SELECT node_id, node_state_desc, memory_node_id, processor_group, online_scheduler_count, + idle_scheduler_count, active_worker_count, avg_load_balance, resource_monitor_state +FROM sys.dm_os_nodes WITH (NOLOCK) +WHERE node_state_desc <> N'ONLINE DAC' OPTION (RECOMPILE); +------ + +-- Gives you some useful information about the composition and relative load on your NUMA nodes +-- You want to see an equal number of schedulers on each NUMA node +-- Watch out if SQL Server 2016 Standard Edition has been installed +-- on a physical or virtual machine with more than four sockets or more than 24 physical cores + +-- sys.dm_os_nodes (Transact-SQL) +-- https://bit.ly/2pn5Mw8 + +-- How to Balance SQL Server Core Licenses Across NUMA Nodes +-- https://bit.ly/3i4TyVR + + + +-- Good basic information about OS memory amounts and state (Query 13) (System Memory) +SELECT total_physical_memory_kb/1024 AS [Physical Memory (MB)], + available_physical_memory_kb/1024 AS [Available Memory (MB)], + total_page_file_kb/1024 AS [Page File Commit Limit (MB)], + total_page_file_kb/1024 - total_physical_memory_kb/1024 AS [Physical Page File Size (MB)], + available_page_file_kb/1024 AS [Available Page File (MB)], + system_cache_kb/1024 AS [System Cache (MB)], + system_memory_state_desc AS [System Memory State] +FROM sys.dm_os_sys_memory WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- You want to see "Available physical memory is high" for System Memory State +-- This indicates that you are not under external memory pressure + +-- Possible System Memory State values: +-- Available physical memory is high +-- Physical memory usage is steady +-- Available physical memory is low +-- Available physical memory is running low +-- Physical memory state is transitioning + +-- sys.dm_os_sys_memory (Transact-SQL) +-- https://bit.ly/2pcV0xq + + + +-- You can skip the next two queries if you know you don't have a clustered instance + + +-- Get information about your cluster nodes and their status (Query 14) (Cluster Node Properties) +-- (if your database server is in a failover cluster) +SELECT NodeName, status_description, is_current_owner +FROM sys.dm_os_cluster_nodes WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- Knowing which node owns the cluster resources is critical +-- Especially when you are installing Windows or SQL Server updates +-- You will see no results if your instance is not clustered + +-- Recommended hotfixes and updates for Windows Server 2012 R2-based failover clusters +-- https://bit.ly/1z5BfCw + + +-- Get information about any AlwaysOn AG cluster this instance is a part of (Query 15) (AlwaysOn AG Cluster) +SELECT cluster_name, quorum_type_desc, quorum_state_desc +FROM sys.dm_hadr_cluster WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- You will see no results if your instance is not using AlwaysOn AGs + + +-- Good overview of AG health and status (Query 16) (AG Status) +SELECT ag.name AS [AG Name], ar.replica_server_name, ar.availability_mode_desc, adc.[database_name], + drs.is_local, drs.is_primary_replica, drs.synchronization_state_desc, drs.is_commit_participant, + drs.synchronization_health_desc, drs.recovery_lsn, drs.truncation_lsn, drs.last_sent_lsn, + drs.last_sent_time, drs.last_received_lsn, drs.last_received_time, drs.last_hardened_lsn, + drs.last_hardened_time, drs.last_redone_lsn, drs.last_redone_time, drs.log_send_queue_size, + drs.log_send_rate, drs.redo_queue_size, drs.redo_rate, drs.filestream_send_rate, + drs.end_of_log_lsn, drs.last_commit_lsn, drs.last_commit_time, drs.database_state_desc +FROM sys.dm_hadr_database_replica_states AS drs WITH (NOLOCK) +INNER JOIN sys.availability_databases_cluster AS adc WITH (NOLOCK) +ON drs.group_id = adc.group_id +AND drs.group_database_id = adc.group_database_id +INNER JOIN sys.availability_groups AS ag WITH (NOLOCK) +ON ag.group_id = drs.group_id +INNER JOIN sys.availability_replicas AS ar WITH (NOLOCK) +ON drs.group_id = ar.group_id +AND drs.replica_id = ar.replica_id +ORDER BY ag.name, ar.replica_server_name, adc.[database_name] OPTION (RECOMPILE); + +-- You will see no results if your instance is not using AlwaysOn AGs + +-- SQL Server 2016 It Just Runs Faster: Always On Availability Groups Turbocharged +-- https://bit.ly/2dn1H6r + + +-- Hardware information from SQL Server 2016 (Query 17) (Hardware Info) +SELECT cpu_count AS [Logical CPU Count], scheduler_count, + hyperthread_ratio AS [Hyperthread Ratio], + cpu_count/hyperthread_ratio AS [Physical CPU Count], + physical_memory_kb/1024 AS [Physical Memory (MB)], + committed_kb/1024 AS [Committed Memory (MB)], + committed_target_kb/1024 AS [Committed Target Memory (MB)], + max_workers_count AS [Max Workers Count], + affinity_type_desc AS [Affinity Type], + sqlserver_start_time AS [SQL Server Start Time], + DATEDIFF(hour, sqlserver_start_time, GETDATE()) AS [SQL Server Up Time (hrs)], + virtual_machine_type_desc AS [Virtual Machine Type], + softnuma_configuration_desc AS [Soft NUMA Configuration], + sql_memory_model_desc -- New in SQL Server 2016 +FROM sys.dm_os_sys_info WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- Gives you some good basic hardware information about your database server +-- Note: virtual_machine_type_desc of HYPERVISOR does not automatically mean you are running SQL Server inside of a VM +-- It merely indicates that you have a hypervisor running on your host + +-- sys.dm_os_sys_info (Transact-SQL) +-- https://bit.ly/2pczOYs + +-- Soft NUMA configuration was a new column for SQL Server 2016 +-- OFF = Soft-NUMA feature is OFF +-- ON = SQL Server automatically determines the NUMA node sizes for Soft-NUMA +-- MANUAL = Manually configured soft-NUMA + +-- Configure SQL Server to Use Soft-NUMA (SQL Server) +-- https://bit.ly/2HTpKJt + +-- sql_memory_model_desc values (Added in SQL Server 2016 SP1) +-- CONVENTIONAL +-- LOCK_PAGES +-- LARGE_PAGES + + +-- Get System Manufacturer and model number from SQL Server Error log (Query 18) (System Manufacturer) +EXEC sys.xp_readerrorlog 0, 1, N'Manufacturer'; +------ + +-- This can help you determine the capabilities and capacities of your database server +-- Can also be used to confirm if you are running in a VM +-- This query might take a few seconds if you have not recycled your error log recently +-- This query will return no results if your error log has been recycled since the instance was started + + +-- Get BIOS date from Windows Registry (Query 19) (BIOS Date) +EXEC sys.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'HARDWARE\DESCRIPTION\System\BIOS', N'BiosReleaseDate'; +------ + +-- Helps you understand whether the main system BIOS is up to date, and the possible age of the hardware +-- Not as useful for virtualization + + +-- Get processor description from Windows Registry (Query 20) (Processor Description) +EXEC sys.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'HARDWARE\DESCRIPTION\System\CentralProcessor\0', N'ProcessorNameString'; +------ + +-- Gives you the model number and rated clock speed of your processor(s) +-- Your processors may be running at less than the rated clock speed due +-- to the Windows Power Plan or hardware power management + +-- You can use CPU-Z to get your actual CPU core speed and a lot of other useful information +-- https://bit.ly/QhR6xF + +-- You can learn more about processor selection for SQL Server by following this link +-- https://bit.ly/2F3aVlP + + + + +-- Get information on location, time and size of any memory dumps from SQL Server (Query 21) (Memory Dump Info) +SELECT [filename], creation_time, size_in_bytes/1048576.0 AS [Size (MB)] +FROM sys.dm_server_memory_dumps WITH (NOLOCK) +ORDER BY creation_time DESC OPTION (RECOMPILE); +------ + +-- This will not return any rows if you have +-- not had any memory dumps (which is a good thing) + +-- sys.dm_server_memory_dumps (Transact-SQL) +-- https://bit.ly/2elwWll + + + +-- Look at Suspect Pages table (Query 22) (Suspect Pages) +SELECT DB_NAME(database_id) AS [Database Name], [file_id], page_id, + event_type, error_count, last_update_date +FROM msdb.dbo.suspect_pages WITH (NOLOCK) +ORDER BY database_id OPTION (RECOMPILE); +------ + +-- event_type value descriptions +-- 1 = 823 error caused by an operating system CRC error +-- or 824 error other than a bad checksum or a torn page (for example, a bad page ID) +-- 2 = Bad checksum +-- 3 = Torn page +-- 4 = Restored (The page was restored after it was marked bad) +-- 5 = Repaired (DBCC repaired the page) +-- 7 = Deallocated by DBCC + +-- Ideally, this query returns no results. The table is limited to 1000 rows. +-- If you do get results here, you should do further investigation to determine the root cause + +-- Manage the suspect_pages Table +-- https://bit.ly/2Fvr1c9 + + +-- Get number of data files in tempdb database (Query 23) (TempDB Data Files) +EXEC sys.xp_readerrorlog 0, 1, N'The tempdb database has'; +------ + +-- Get the number of data files in the tempdb database +-- 4-8 data files that are all the same size is a good starting point +-- This query will return no results if your error log has been recycled since the instance was last started + + +-- File names and paths for all user and system databases on instance (Query 24) (Database Filenames and Paths) +SELECT DB_NAME([database_id]) AS [Database Name], + [file_id], [name], physical_name, [type_desc], state_desc, + is_percent_growth, growth, + CONVERT(bigint, growth/128.0) AS [Growth in MB], + CONVERT(bigint, size/128.0) AS [Total Size in MB], max_size +FROM sys.master_files WITH (NOLOCK) +ORDER BY DB_NAME([database_id]), [file_id] OPTION (RECOMPILE); +------ + +-- Things to look at: +-- Are data files and log files on different drives? +-- Is everything on the C: drive? +-- Is tempdb on dedicated drives? +-- Is there only one tempdb data file? +-- Are all of the tempdb data files the same size? +-- Are there multiple data files for user databases? +-- Is percent growth enabled for any files (which is bad)? + + +-- Volume info for all LUNS that have database files on the current instance (Query 25) (Volume Info) +SELECT DISTINCT vs.volume_mount_point, vs.file_system_type, vs.logical_volume_name, +CONVERT(DECIMAL(18,2), vs.total_bytes/1073741824.0) AS [Total Size (GB)], +CONVERT(DECIMAL(18,2), vs.available_bytes/1073741824.0) AS [Available Size (GB)], +CONVERT(DECIMAL(18,2), vs.available_bytes * 1. / vs.total_bytes * 100.) AS [Space Free %], +vs.supports_compression, vs.is_compressed, +vs.supports_sparse_files, vs.supports_alternate_streams +FROM sys.master_files AS f WITH (NOLOCK) +CROSS APPLY sys.dm_os_volume_stats(f.database_id, f.[file_id]) AS vs +ORDER BY vs.volume_mount_point OPTION (RECOMPILE); +------ + +-- Shows you the total and free space on the LUNs where you have database files +-- Being low on free space can negatively affect performance + +-- sys.dm_os_volume_stats (Transact-SQL) +-- https://bit.ly/2oBPNNr + + + +-- Drive level latency information (Query 26) (Drive Level Latency) +SELECT tab.[Drive], tab.volume_mount_point AS [Volume Mount Point], + CASE + WHEN num_of_reads = 0 THEN 0 + ELSE (io_stall_read_ms/num_of_reads) + END AS [Read Latency], + CASE + WHEN num_of_writes = 0 THEN 0 + ELSE (io_stall_write_ms/num_of_writes) + END AS [Write Latency], + CASE + WHEN (num_of_reads = 0 AND num_of_writes = 0) THEN 0 + ELSE (io_stall/(num_of_reads + num_of_writes)) + END AS [Overall Latency], + CASE + WHEN num_of_reads = 0 THEN 0 + ELSE (num_of_bytes_read/num_of_reads) + END AS [Avg Bytes/Read], + CASE + WHEN num_of_writes = 0 THEN 0 + ELSE (num_of_bytes_written/num_of_writes) + END AS [Avg Bytes/Write], + CASE + WHEN (num_of_reads = 0 AND num_of_writes = 0) THEN 0 + ELSE ((num_of_bytes_read + num_of_bytes_written)/(num_of_reads + num_of_writes)) + END AS [Avg Bytes/Transfer] +FROM (SELECT LEFT(UPPER(mf.physical_name), 2) AS Drive, SUM(num_of_reads) AS num_of_reads, + SUM(io_stall_read_ms) AS io_stall_read_ms, SUM(num_of_writes) AS num_of_writes, + SUM(io_stall_write_ms) AS io_stall_write_ms, SUM(num_of_bytes_read) AS num_of_bytes_read, + SUM(num_of_bytes_written) AS num_of_bytes_written, SUM(io_stall) AS io_stall, vs.volume_mount_point + FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS vfs + INNER JOIN sys.master_files AS mf WITH (NOLOCK) + ON vfs.database_id = mf.database_id AND vfs.file_id = mf.file_id + CROSS APPLY sys.dm_os_volume_stats(mf.database_id, mf.[file_id]) AS vs + GROUP BY LEFT(UPPER(mf.physical_name), 2), vs.volume_mount_point) AS tab +ORDER BY [Overall Latency] OPTION (RECOMPILE); +------ + +-- Shows you the drive-level latency for reads and writes, in milliseconds +-- Latency above 30-40ms is usually a problem +-- These latency numbers include all file activity against all SQL Server +-- database files on each drive since SQL Server was last started + +-- sys.dm_io_virtual_file_stats (Transact-SQL) +-- https://bit.ly/3bRWUc0 + +-- sys.dm_os_volume_stats (Transact-SQL) +-- https://bit.ly/33thz2j + + +-- Calculates average stalls per read, per write, and per total input/output for each database file (Query 27) (IO Latency by File) +SELECT DB_NAME(fs.database_id) AS [Database Name], CAST(fs.io_stall_read_ms/(1.0 + fs.num_of_reads) AS NUMERIC(10,1)) AS [avg_read_latency_ms], +CAST(fs.io_stall_write_ms/(1.0 + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_write_latency_ms], +CAST((fs.io_stall_read_ms + fs.io_stall_write_ms)/(1.0 + fs.num_of_reads + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_io_latency_ms], +CONVERT(DECIMAL(18,2), mf.size/128.0) AS [File Size (MB)], mf.physical_name, mf.type_desc, fs.io_stall_read_ms, fs.num_of_reads, +fs.io_stall_write_ms, fs.num_of_writes, fs.io_stall_read_ms + fs.io_stall_write_ms AS [io_stalls], fs.num_of_reads + fs.num_of_writes AS [total_io], +io_stall_queued_read_ms AS [Resource Governor Total Read IO Latency (ms)], io_stall_queued_write_ms AS [Resource Governor Total Write IO Latency (ms)] +FROM sys.dm_io_virtual_file_stats(null,null) AS fs +INNER JOIN sys.master_files AS mf WITH (NOLOCK) +ON fs.database_id = mf.database_id +AND fs.[file_id] = mf.[file_id] +ORDER BY avg_io_latency_ms DESC OPTION (RECOMPILE); +------ + +-- Helps determine which database files on the entire instance have the most I/O bottlenecks +-- This can help you decide whether certain LUNs are overloaded and whether you might +-- want to move some files to a different location or perhaps improve your I/O performance +-- These latency numbers include all file activity against each SQL Server +-- database file since SQL Server was last started + +-- sys.dm_io_virtual_file_stats (Transact-SQL) +-- https://bit.ly/3bRWUc0 + + +-- Look for I/O requests taking longer than 15 seconds in the six most recent SQL Server Error Logs (Query 28) (IO Warnings) +CREATE TABLE #IOWarningResults(LogDate datetime, ProcessInfo sysname, LogText nvarchar(1000)); + + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 0, 1, N'taking longer than 15 seconds'; + + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 1, 1, N'taking longer than 15 seconds'; + + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 2, 1, N'taking longer than 15 seconds'; + + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 3, 1, N'taking longer than 15 seconds'; + + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 4, 1, N'taking longer than 15 seconds'; + + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 5, 1, N'taking longer than 15 seconds'; + +SELECT LogDate, ProcessInfo, LogText +FROM #IOWarningResults +ORDER BY LogDate DESC; + +DROP TABLE #IOWarningResults; +------ + +-- Finding 15 second I/O warnings in the SQL Server Error Log is useful evidence of +-- poor I/O performance (which might have many different causes) +-- Look to see if you see any patterns in the results (same files, same drives, same time of day, etc.) + +-- Diagnostics in SQL Server help detect stalled and stuck I/O operations +-- https://bit.ly/2qtaw73 + + +-- Resource Governor Resource Pool information (Query 29) (RG Resource Pools) +SELECT pool_id, [Name], statistics_start_time, + min_memory_percent, max_memory_percent, + max_memory_kb/1024 AS [max_memory_mb], + used_memory_kb/1024 AS [used_memory_mb], + target_memory_kb/1024 AS [target_memory_mb], + min_iops_per_volume, max_iops_per_volume +FROM sys.dm_resource_governor_resource_pools WITH (NOLOCK) +OPTION (RECOMPILE); +------ + +-- sys.dm_resource_governor_resource_pools (Transact-SQL) +-- https://bit.ly/2MVU0Vy + + + +-- Recovery model, log reuse wait description, log file size, log usage size (Query 30) (Database Properties) +-- and compatibility level for all databases on instance +SELECT db.[name] AS [Database Name], SUSER_SNAME(db.owner_sid) AS [Database Owner], db.recovery_model_desc AS [Recovery Model], +db.state_desc, db.containment_desc, db.log_reuse_wait_desc AS [Log Reuse Wait Description], +CONVERT(DECIMAL(18,2), ls.cntr_value/1024.0) AS [Log Size (MB)], CONVERT(DECIMAL(18,2), lu.cntr_value/1024.0) AS [Log Used (MB)], +CAST(CAST(lu.cntr_value AS FLOAT) / CAST(ls.cntr_value AS FLOAT)AS DECIMAL(18,2)) * 100 AS [Log Used %], +db.[compatibility_level] AS [DB Compatibility Level], +db.is_mixed_page_allocation_on, db.page_verify_option_desc AS [Page Verify Option], +db.is_auto_create_stats_on, db.is_auto_update_stats_on, db.is_auto_update_stats_async_on, db.is_parameterization_forced, +db.snapshot_isolation_state_desc, db.is_read_committed_snapshot_on, db.is_auto_close_on, db.is_auto_shrink_on, +db.target_recovery_time_in_seconds, db.is_cdc_enabled, db.is_published, db.is_distributor, +db.group_database_id, db.replica_id,db.is_memory_optimized_elevate_to_snapshot_on, +db.delayed_durability_desc, db.is_query_store_on, db.is_sync_with_backup, db.is_remote_data_archive_enabled, +db.is_encrypted, de.encryption_state, de.percent_complete, de.key_algorithm, de.key_length +FROM sys.databases AS db WITH (NOLOCK) +INNER JOIN sys.dm_os_performance_counters AS lu WITH (NOLOCK) +ON db.name = lu.instance_name +INNER JOIN sys.dm_os_performance_counters AS ls WITH (NOLOCK) +ON db.name = ls.instance_name +LEFT OUTER JOIN sys.dm_database_encryption_keys AS de WITH (NOLOCK) +ON db.database_id = de.database_id +WHERE lu.counter_name LIKE N'Log File(s) Used Size (KB)%' +AND ls.counter_name LIKE N'Log File(s) Size (KB)%' +AND ls.cntr_value > 0 +ORDER BY db.[name] OPTION (RECOMPILE); +------ + +-- sys.databases (Transact-SQL) +-- https://bit.ly/2G5wqaX + +-- sys.dm_os_performance_counters (Transact-SQL) +-- https://bit.ly/3kEO2JR + +-- sys.dm_database_encryption_keys (Transact-SQL) +-- https://bit.ly/3mE7kkx + +-- Things to look at: +-- How many databases are on the instance? +-- What recovery models are they using? +-- What is the log reuse wait description? +-- How full are the transaction logs? +-- What compatibility level are the databases on? +-- What is the Page Verify Option? (should be CHECKSUM) +-- Is Auto Update Statistics Asynchronously enabled? +-- Is Delayed Durability enabled +-- Make sure auto_shrink and auto_close are not enabled! + +-- is_mixed_page_allocation_on is a new property for SQL Server 2016. Equivalent to TF 1118 for a user database +-- SQL Server 2016: Changes in default behavior for autogrow and allocations for tempdb and user databases +-- https://bit.ly/2evRZSR + +-- A non-zero value for target_recovery_time_in_seconds means that indirect checkpoint is enabled +-- If the setting has a zero value it indicates that automatic checkpoint is enabled + +-- Changes in SQL Server 2016 Checkpoint Behavior +-- https://bit.ly/2pdggk3 + + +-- Missing Indexes for all databases by Index Advantage (Query 31) (Missing Indexes All Databases) +SELECT CONVERT(decimal(18,2), migs.user_seeks * migs.avg_total_user_cost * (migs.avg_user_impact * 0.01)) AS [index_advantage], +FORMAT(migs.last_user_seek, 'yyyy-MM-dd HH:mm:ss') AS [last_user_seek], mid.[statement] AS [Database.Schema.Table], +COUNT(1) OVER(PARTITION BY mid.[statement]) AS [missing_indexes_for_table], +COUNT(1) OVER(PARTITION BY mid.[statement], equality_columns) AS [similar_missing_indexes_for_table], +mid.equality_columns, mid.inequality_columns, mid.included_columns, migs.user_seeks, +CONVERT(decimal(18,2), migs.avg_total_user_cost) AS [avg_total_user_cost], migs.avg_user_impact +FROM sys.dm_db_missing_index_group_stats AS migs WITH (NOLOCK) +INNER JOIN sys.dm_db_missing_index_groups AS mig WITH (NOLOCK) +ON migs.group_handle = mig.index_group_handle +INNER JOIN sys.dm_db_missing_index_details AS mid WITH (NOLOCK) +ON mig.index_handle = mid.index_handle +ORDER BY index_advantage DESC OPTION (RECOMPILE); +------ + +-- Getting missing index information for all of the databases on the instance is very useful +-- Look at last user seek time, number of user seeks to help determine source and importance +-- Also look at avg_user_impact and avg_total_user_cost to help determine importance +-- SQL Server is overly eager to add included columns, so beware +-- Do not just blindly add indexes that show up from this query!!! +-- Hkan Winther has given me some great suggestions for this query + +-- SQL Server Index Design Guide +-- https://bit.ly/2qtZr4N + + + +-- Get VLF Counts for all databases on the instance (Query 32) (VLF Counts) +-- (adapted from Michelle Ufford) +CREATE TABLE #VLFInfo (RecoveryUnitID int, FileID int, + FileSize bigint, StartOffset bigint, + FSeqNo bigint, [Status] bigint, + Parity bigint, CreateLSN numeric(38)); + +CREATE TABLE #VLFCountResults(DatabaseName sysname, VLFCount int); + +EXEC sp_MSforeachdb N'Use [?]; + + INSERT INTO #VLFInfo + EXEC sp_executesql N''DBCC LOGINFO([?])''; + + INSERT INTO #VLFCountResults + SELECT DB_NAME(), COUNT(*) + FROM #VLFInfo; + + TRUNCATE TABLE #VLFInfo;' + +SELECT DatabaseName, VLFCount +FROM #VLFCountResults +ORDER BY VLFCount DESC; + +DROP TABLE #VLFInfo; +DROP TABLE #VLFCountResults; +------ + +-- High VLF counts can affect write performance to the log file +-- and they can make full database restores and crash recovery take much longer +-- Try to keep your VLF counts under 200 in most cases (depending on log file size) + +-- Important change to VLF creation algorithm in SQL Server 2014 +-- https://bit.ly/2Hsjbg4 + +-- SQL Server Transaction Log Architecture and Management Guide +-- https://bit.ly/2JjmQRZ + + + + +-- Get CPU utilization by database (Query 33) (CPU Usage by Database) +WITH DB_CPU_Stats +AS +(SELECT pa.DatabaseID, DB_Name(pa.DatabaseID) AS [Database Name], SUM(qs.total_worker_time/1000) AS [CPU_Time_Ms] + FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) + CROSS APPLY (SELECT CONVERT(int, value) AS [DatabaseID] + FROM sys.dm_exec_plan_attributes(qs.plan_handle) + WHERE attribute = N'dbid') AS pa + GROUP BY DatabaseID) +SELECT ROW_NUMBER() OVER(ORDER BY [CPU_Time_Ms] DESC) AS [CPU Rank], + [Database Name], [CPU_Time_Ms] AS [CPU Time (ms)], + CAST([CPU_Time_Ms] * 1.0 / SUM([CPU_Time_Ms]) OVER() * 100.0 AS DECIMAL(5, 2)) AS [CPU Percent] +FROM DB_CPU_Stats +WHERE DatabaseID <> 32767 -- ResourceDB +ORDER BY [CPU Rank] OPTION (RECOMPILE); +------ + +-- Helps determine which database is using the most CPU resources on the instance +-- Note: This only reflects CPU usage from the currently cached query plans + + +-- Get I/O utilization by database (Query 34) (IO Usage By Database) +WITH Aggregate_IO_Statistics +AS (SELECT DB_NAME(database_id) AS [Database Name], + CAST(SUM(num_of_bytes_read + num_of_bytes_written) / 1048576 AS DECIMAL(12, 2)) AS [ioTotalMB], + CAST(SUM(num_of_bytes_read ) / 1048576 AS DECIMAL(12, 2)) AS [ioReadMB], + CAST(SUM(num_of_bytes_written) / 1048576 AS DECIMAL(12, 2)) AS [ioWriteMB] + FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS [DM_IO_STATS] + GROUP BY database_id) +SELECT ROW_NUMBER() OVER (ORDER BY ioTotalMB DESC) AS [I/O Rank], + [Database Name], ioTotalMB AS [Total I/O (MB)], + CAST(ioTotalMB / SUM(ioTotalMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Total I/O %], + ioReadMB AS [Read I/O (MB)], + CAST(ioReadMB / SUM(ioReadMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Read I/O %], + ioWriteMB AS [Write I/O (MB)], + CAST(ioWriteMB / SUM(ioWriteMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Write I/O %] +FROM Aggregate_IO_Statistics +ORDER BY [I/O Rank] OPTION (RECOMPILE); +------ + +-- Helps determine which database is using the most I/O resources on the instance +-- These numbers are cumulative since the last service restart +-- They include all I/O activity, not just the nominal I/O workload + + +-- Get total buffer usage by database for current instance (Query 35) (Total Buffer Usage by Database) +-- This make take some time to run on a busy instance +WITH AggregateBufferPoolUsage +AS +(SELECT DB_NAME(database_id) AS [Database Name], +CAST(COUNT(*) * 8/1024.0 AS DECIMAL (10,2)) AS [CachedSize] +FROM sys.dm_os_buffer_descriptors WITH (NOLOCK) +WHERE database_id <> 32767 -- ResourceDB +GROUP BY DB_NAME(database_id)) +SELECT ROW_NUMBER() OVER(ORDER BY CachedSize DESC) AS [Buffer Pool Rank], [Database Name], CachedSize AS [Cached Size (MB)], + CAST(CachedSize / SUM(CachedSize) OVER() * 100.0 AS DECIMAL(5,2)) AS [Buffer Pool Percent] +FROM AggregateBufferPoolUsage +ORDER BY [Buffer Pool Rank] OPTION (RECOMPILE); +------ + +-- Tells you how much memory (in the buffer pool) +-- is being used by each database on the instance + + +-- Clear Wait Stats with this command +-- DBCC SQLPERF('sys.dm_os_wait_stats', CLEAR); + +-- Isolate top waits for server instance since last restart or wait statistics clear (Query 36) (Top Waits) +WITH [Waits] +AS (SELECT wait_type, wait_time_ms/ 1000.0 AS [WaitS], + (wait_time_ms - signal_wait_time_ms) / 1000.0 AS [ResourceS], + signal_wait_time_ms / 1000.0 AS [SignalS], + waiting_tasks_count AS [WaitCount], + 100.0 * wait_time_ms / SUM (wait_time_ms) OVER() AS [Percentage], + ROW_NUMBER() OVER(ORDER BY wait_time_ms DESC) AS [RowNum] + FROM sys.dm_os_wait_stats WITH (NOLOCK) + WHERE [wait_type] NOT IN ( + N'BROKER_EVENTHANDLER', N'BROKER_RECEIVE_WAITFOR', N'BROKER_TASK_STOP', + N'BROKER_TO_FLUSH', N'BROKER_TRANSMITTER', N'CHECKPOINT_QUEUE', + N'CHKPT', N'CLR_AUTO_EVENT', N'CLR_MANUAL_EVENT', N'CLR_SEMAPHORE', + N'DBMIRROR_DBM_EVENT', N'DBMIRROR_EVENTS_QUEUE', N'DBMIRROR_WORKER_QUEUE', + N'DBMIRRORING_CMD', N'DIRTY_PAGE_POLL', N'DISPATCHER_QUEUE_SEMAPHORE', + N'EXECSYNC', N'FSAGENT', N'FT_IFTS_SCHEDULER_IDLE_WAIT', N'FT_IFTSHC_MUTEX', + N'HADR_CLUSAPI_CALL', N'HADR_FILESTREAM_IOMGR_IOCOMPLETION', N'HADR_LOGCAPTURE_WAIT', + N'HADR_NOTIFICATION_DEQUEUE', N'HADR_TIMER_TASK', N'HADR_WORK_QUEUE', + N'KSOURCE_WAKEUP', N'LAZYWRITER_SLEEP', N'LOGMGR_QUEUE', + N'MEMORY_ALLOCATION_EXT', N'ONDEMAND_TASK_QUEUE', + N'PARALLEL_REDO_DRAIN_WORKER', N'PARALLEL_REDO_LOG_CACHE', N'PARALLEL_REDO_TRAN_LIST', + N'PARALLEL_REDO_WORKER_SYNC', N'PARALLEL_REDO_WORKER_WAIT_WORK', + N'PREEMPTIVE_HADR_LEASE_MECHANISM', N'PREEMPTIVE_SP_SERVER_DIAGNOSTICS', + N'PREEMPTIVE_OS_LIBRARYOPS', N'PREEMPTIVE_OS_COMOPS', N'PREEMPTIVE_OS_CRYPTOPS', + N'PREEMPTIVE_OS_PIPEOPS', N'PREEMPTIVE_OS_AUTHENTICATIONOPS', + N'PREEMPTIVE_OS_GENERICOPS', N'PREEMPTIVE_OS_VERIFYTRUST', + N'PREEMPTIVE_OS_FILEOPS', N'PREEMPTIVE_OS_DEVICEOPS', N'PREEMPTIVE_OS_QUERYREGISTRY', + N'PREEMPTIVE_OS_WRITEFILE', + N'PREEMPTIVE_XE_CALLBACKEXECUTE', N'PREEMPTIVE_XE_DISPATCHER', + N'PREEMPTIVE_XE_GETTARGETSTATE', N'PREEMPTIVE_XE_SESSIONCOMMIT', + N'PREEMPTIVE_XE_TARGETINIT', N'PREEMPTIVE_XE_TARGETFINALIZE', + N'PWAIT_ALL_COMPONENTS_INITIALIZED', N'PWAIT_DIRECTLOGCONSUMER_GETNEXT', + N'QDS_PERSIST_TASK_MAIN_LOOP_SLEEP', + N'QDS_ASYNC_QUEUE', + N'QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEP', N'REQUEST_FOR_DEADLOCK_SEARCH', + N'RESOURCE_QUEUE', N'SERVER_IDLE_CHECK', N'SLEEP_BPOOL_FLUSH', N'SLEEP_DBSTARTUP', + N'SLEEP_DCOMSTARTUP', N'SLEEP_MASTERDBREADY', N'SLEEP_MASTERMDREADY', + N'SLEEP_MASTERUPGRADED', N'SLEEP_MSDBSTARTUP', N'SLEEP_SYSTEMTASK', N'SLEEP_TASK', + N'SLEEP_TEMPDBSTARTUP', N'SNI_HTTP_ACCEPT', N'SP_SERVER_DIAGNOSTICS_SLEEP', + N'SQLTRACE_BUFFER_FLUSH', N'SQLTRACE_INCREMENTAL_FLUSH_SLEEP', N'SQLTRACE_WAIT_ENTRIES', + N'WAIT_FOR_RESULTS', N'WAITFOR', N'WAITFOR_TASKSHUTDOWN', N'WAIT_XTP_HOST_WAIT', + N'WAIT_XTP_OFFLINE_CKPT_NEW_LOG', N'WAIT_XTP_CKPT_CLOSE', N'WAIT_XTP_RECOVERY', + N'XE_BUFFERMGR_ALLPROCESSED_EVENT', N'XE_DISPATCHER_JOIN', + N'XE_DISPATCHER_WAIT', N'XE_LIVE_TARGET_TVF', N'XE_TIMER_EVENT') + AND waiting_tasks_count > 0) +SELECT + MAX (W1.wait_type) AS [WaitType], + CAST (MAX (W1.Percentage) AS DECIMAL (5,2)) AS [Wait Percentage], + CAST ((MAX (W1.WaitS) / MAX (W1.WaitCount)) AS DECIMAL (16,4)) AS [AvgWait_Sec], + CAST ((MAX (W1.ResourceS) / MAX (W1.WaitCount)) AS DECIMAL (16,4)) AS [AvgRes_Sec], + CAST ((MAX (W1.SignalS) / MAX (W1.WaitCount)) AS DECIMAL (16,4)) AS [AvgSig_Sec], + CAST (MAX (W1.WaitS) AS DECIMAL (16,2)) AS [Wait_Sec], + CAST (MAX (W1.ResourceS) AS DECIMAL (16,2)) AS [Resource_Sec], + CAST (MAX (W1.SignalS) AS DECIMAL (16,2)) AS [Signal_Sec], + MAX (W1.WaitCount) AS [Wait Count], + CAST (N'https://www.sqlskills.com/help/waits/' + W1.wait_type AS XML) AS [Help/Info URL] +FROM Waits AS W1 +INNER JOIN Waits AS W2 +ON W2.RowNum <= W1.RowNum +GROUP BY W1.RowNum, W1.wait_type +HAVING SUM (W2.Percentage) - MAX (W1.Percentage) < 99 -- percentage threshold +OPTION (RECOMPILE); +------ + +-- Cumulative wait stats are not as useful on an idle instance that is not under load or performance pressure + +-- SQL Server Wait Types Library +-- https://bit.ly/2ePzYO2 + +-- The SQL Server Wait Type Repository +-- https://bit.ly/1afzfjC + +-- Wait statistics, or please tell me where it hurts +-- https://bit.ly/2wsQHQE + +-- SQL Server 2005 Performance Tuning using the Waits and Queues +-- https://bit.ly/1o2NFoF + +-- sys.dm_os_wait_stats (Transact-SQL) +-- https://bit.ly/2Hjq9Yl + + + +-- Get a count of SQL connections by IP address (Query 37) (Connection Counts by IP Address) +SELECT ec.client_net_address, es.[program_name], es.[host_name], es.login_name, +COUNT(ec.session_id) AS [connection count] +FROM sys.dm_exec_sessions AS es WITH (NOLOCK) +INNER JOIN sys.dm_exec_connections AS ec WITH (NOLOCK) +ON es.session_id = ec.session_id +GROUP BY ec.client_net_address, es.[program_name], es.[host_name], es.login_name +ORDER BY ec.client_net_address, es.[program_name] OPTION (RECOMPILE); +------ + +-- This helps you figure where your database load is coming from +-- and verifies connectivity from other machines + +-- Solving Connectivity errors to SQL Server +-- https://bit.ly/2EgzoD0 + + + +-- Get Average Task Counts (run multiple times) (Query 38) (Avg Task Counts) +SELECT AVG(current_tasks_count) AS [Avg Task Count], +AVG(work_queue_count) AS [Avg Work Queue Count], +AVG(runnable_tasks_count) AS [Avg Runnable Task Count], +AVG(pending_disk_io_count) AS [Avg Pending DiskIO Count] +FROM sys.dm_os_schedulers WITH (NOLOCK) +WHERE scheduler_id < 255 OPTION (RECOMPILE); +------ + +-- Sustained values above 10 suggest further investigation in that area +-- High Avg Task Counts are often caused by blocking/deadlocking or other resource contention + +-- Sustained values above 1 suggest further investigation in that area +-- High Avg Runnable Task Counts are a good sign of CPU pressure +-- High Avg Pending DiskIO Counts are a sign of disk pressure + +-- How to Do Some Very Basic SQL Server Monitoring +-- https://bit.ly/30IRla0 + + + +-- Detect blocking (run multiple times) (Query 39) (Detect Blocking) +SELECT t1.resource_type AS [lock type], DB_NAME(resource_database_id) AS [database], +t1.resource_associated_entity_id AS [blk object],t1.request_mode AS [lock req], -- lock requested +t1.request_session_id AS [waiter sid], t2.wait_duration_ms AS [wait time], -- spid of waiter +(SELECT [text] FROM sys.dm_exec_requests AS r WITH (NOLOCK) -- get sql for waiter +CROSS APPLY sys.dm_exec_sql_text(r.[sql_handle]) +WHERE r.session_id = t1.request_session_id) AS [waiter_batch], +(SELECT SUBSTRING(qt.[text],r.statement_start_offset/2, + (CASE WHEN r.statement_end_offset = -1 + THEN LEN(CONVERT(nvarchar(max), qt.[text])) * 2 + ELSE r.statement_end_offset END - r.statement_start_offset)/2) +FROM sys.dm_exec_requests AS r WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(r.[sql_handle]) AS qt +WHERE r.session_id = t1.request_session_id) AS [waiter_stmt], -- statement blocked +t2.blocking_session_id AS [blocker sid], -- spid of blocker +(SELECT [text] FROM sys.sysprocesses AS p -- get sql for blocker +CROSS APPLY sys.dm_exec_sql_text(p.[sql_handle]) +WHERE p.spid = t2.blocking_session_id) AS [blocker_batch] +FROM sys.dm_tran_locks AS t1 WITH (NOLOCK) +INNER JOIN sys.dm_os_waiting_tasks AS t2 WITH (NOLOCK) +ON t1.lock_owner_address = t2.resource_address OPTION (RECOMPILE); +------ + +-- Helps troubleshoot blocking and deadlocking issues +-- The results will change from second to second on a busy system +-- You should run this query multiple times when you see signs of blocking + + + +-- Get CPU Utilization History for last 256 minutes (in one minute intervals) (Query 40) (CPU Utilization History) +DECLARE @ts_now bigint = (SELECT cpu_ticks/(cpu_ticks/ms_ticks) FROM sys.dm_os_sys_info WITH (NOLOCK)); + +SELECT TOP(256) SQLProcessUtilization AS [SQL Server Process CPU Utilization], + SystemIdle AS [System Idle Process], + 100 - SystemIdle - SQLProcessUtilization AS [Other Process CPU Utilization], + DATEADD(ms, -1 * (@ts_now - [timestamp]), GETDATE()) AS [Event Time] +FROM (SELECT record.value('(./Record/@id)[1]', 'int') AS record_id, + record.value('(./Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int') + AS [SystemIdle], + record.value('(./Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]', 'int') + AS [SQLProcessUtilization], [timestamp] + FROM (SELECT [timestamp], CONVERT(xml, record) AS [record] + FROM sys.dm_os_ring_buffers WITH (NOLOCK) + WHERE ring_buffer_type = N'RING_BUFFER_SCHEDULER_MONITOR' + AND record LIKE N'%%') AS x) AS y +ORDER BY record_id DESC OPTION (RECOMPILE); +------ + +-- Look at the trend over the entire period +-- Also look at high sustained 'Other Process' CPU Utilization values +-- Note: This query sometimes gives inaccurate results (negative values) +-- on high core count (> 64 cores) systems + + +-- Get top total worker time queries for entire instance (Query 41) (Top Worker Time Queries) +SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], +REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], +qs.total_worker_time AS [Total Worker Time], qs.min_worker_time AS [Min Worker Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.max_worker_time AS [Max Worker Time], +qs.min_elapsed_time AS [Min Elapsed Time], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.max_elapsed_time AS [Max Elapsed Time], +qs.min_logical_reads AS [Min Logical Reads], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +qs.max_logical_reads AS [Max Logical Reads], +qs.execution_count AS [Execution Count], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] +--,t.[text] AS [Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel +FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t +CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp +ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); +------ + + +-- Helps you find the most expensive queries from a CPU perspective across the entire instance +-- Can also help track down parameter sniffing issues + + + +-- Page Life Expectancy (PLE) value for each NUMA node in current instance (Query 42) (PLE by NUMA Node) +SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], + instance_name, cntr_value AS [Page Life Expectancy] +FROM sys.dm_os_performance_counters WITH (NOLOCK) +WHERE [object_name] LIKE N'%Buffer Node%' -- Handles named instances +AND counter_name = N'Page life expectancy' OPTION (RECOMPILE); +------ + +-- PLE is a good measurement of internal memory pressure +-- Higher PLE is better. Watch the trend over time, not the absolute value +-- This will only return one row for non-NUMA systems + +-- Page Life Expectancy isnt what you think +-- https://bit.ly/2EgynLa + + +-- Memory Grants Pending value for current instance (Query 43) (Memory Grants Pending) +SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], cntr_value AS [Memory Grants Pending] +FROM sys.dm_os_performance_counters WITH (NOLOCK) +WHERE [object_name] LIKE N'%Memory Manager%' -- Handles named instances +AND counter_name = N'Memory Grants Pending' OPTION (RECOMPILE); +------ + +-- Run multiple times, and run periodically if you suspect you are under memory pressure +-- Memory Grants Pending above zero for a sustained period is a very strong indicator of internal memory pressure + + +-- Memory Clerk Usage for instance (Query 44) (Memory Clerk Usage) +-- Look for high value for CACHESTORE_SQLCP (Ad-hoc query plans) +SELECT TOP(10) mc.[type] AS [Memory Clerk Type], + CAST((SUM(mc.pages_kb)/1024.0) AS DECIMAL (15,2)) AS [Memory Usage (MB)] +FROM sys.dm_os_memory_clerks AS mc WITH (NOLOCK) +GROUP BY mc.[type] +ORDER BY SUM(mc.pages_kb) DESC OPTION (RECOMPILE); +------ + +-- MEMORYCLERK_SQLBUFFERPOOL was new for SQL Server 2012. It should be your highest consumer of memory + +-- CACHESTORE_SQLCP SQL Plans +-- These are cached SQL statements or batches that aren't in stored procedures, functions and triggers +-- Watch out for high values for CACHESTORE_SQLCP +-- Enabling 'optimize for ad hoc workloads' at the instance level can help reduce this +-- Running DBCC FREESYSTEMCACHE ('SQL Plans') periodically may be required to better control this + +-- CACHESTORE_OBJCP Object Plans +-- These are compiled plans for stored procedures, functions and triggers + +-- sys.dm_os_memory_clerks (Transact-SQL) +-- https://bit.ly/2H31xDR + + + +-- Find single-use, ad-hoc and prepared queries that are bloating the plan cache (Query 45) (Ad hoc Queries) +SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], t.[text] AS [Query Text], +cp.objtype AS [Object Type], cp.cacheobjtype AS [Cache Object Type], +cp.size_in_bytes/1024 AS [Plan Size in KB] +FROM sys.dm_exec_cached_plans AS cp WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t +WHERE cp.cacheobjtype = N'Compiled Plan' +AND cp.objtype IN (N'Adhoc', N'Prepared') +AND cp.usecounts = 1 +ORDER BY cp.size_in_bytes DESC, DB_NAME(t.[dbid]) OPTION (RECOMPILE); +------ + +-- Gives you the text, type and size of single-use ad-hoc and prepared queries that waste space in the plan cache +-- Enabling 'optimize for ad hoc workloads' for the instance can help (SQL Server 2008 and above only) +-- Running DBCC FREESYSTEMCACHE ('SQL Plans') periodically may be required to better control this +-- Enabling forced parameterization for the database can help, but test first! + +-- Plan cache, adhoc workloads and clearing the single-use plan cache bloat +-- https://bit.ly/2EfYOkl + + +-- Get top total logical reads queries for entire instance (Query 46) (Top Logical Reads Queries) +SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], +REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], +qs.total_logical_reads AS [Total Logical Reads], +qs.min_logical_reads AS [Min Logical Reads], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +qs.max_logical_reads AS [Max Logical Reads], +qs.min_worker_time AS [Min Worker Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.max_worker_time AS [Max Worker Time], +qs.min_elapsed_time AS [Min Elapsed Time], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.max_elapsed_time AS [Max Elapsed Time], +qs.execution_count AS [Execution Count], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] +--,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel +FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t +CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp +ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE); +------ + + +-- Helps you find the most expensive queries from a memory perspective across the entire instance +-- Can also help track down parameter sniffing issues + + +-- Get top average elapsed time queries for entire instance (Query 47) (Top Avg Elapsed Time Queries) +SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], +REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.min_elapsed_time, qs.max_elapsed_time, qs.last_elapsed_time, +qs.execution_count AS [Execution Count], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +qs.total_physical_reads/qs.execution_count AS [Avg Physical Reads], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] +--,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel +FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t +CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp +ORDER BY qs.total_elapsed_time/qs.execution_count DESC OPTION (RECOMPILE); +------ + +-- Helps you find the highest average elapsed time queries across the entire instance +-- Can also help track down parameter sniffing issues + + +-- Look at UDF execution statistics (Query 48) (UDF Stats by DB) +SELECT TOP (25) DB_NAME(database_id) AS [Database Name], + OBJECT_NAME(object_id, database_id) AS [Function Name], + total_worker_time, execution_count, total_elapsed_time, + total_elapsed_time/execution_count AS [avg_elapsed_time], + last_elapsed_time, last_execution_time, cached_time, [type_desc] +FROM sys.dm_exec_function_stats WITH (NOLOCK) +ORDER BY total_worker_time DESC OPTION (RECOMPILE); +------ + +-- sys.dm_exec_function_stats (Transact-SQL) +-- https://bit.ly/2q1Q6BM + +-- Showplan Enhancements for UDFs +-- https://bit.ly/2LVqiQ1 + +-- Database specific queries ***************************************************************** + +-- **** Please switch to a user database that you are interested in! ***** +--USE YourDatabaseName; -- make sure to change to an actual database on your instance, not the master system database +--GO + +-- Individual File Sizes and space available for current database (Query 49) (File Sizes and Space) +SELECT f.name AS [File Name] , f.physical_name AS [Physical Name], +CAST((f.size/128.0) AS DECIMAL(15,2)) AS [Total Size in MB], +CAST(f.size/128.0 - CAST(FILEPROPERTY(f.name, 'SpaceUsed') AS int)/128.0 AS DECIMAL(15,2)) +AS [Available Space In MB], +CAST((f.size/128.0) AS DECIMAL(15,2)) - +CAST(f.size/128.0 - CAST(FILEPROPERTY(f.name, 'SpaceUsed') AS int)/128.0 AS DECIMAL(15,2)) AS [Used Space in MB], +f.[file_id], fg.name AS [Filegroup Name], +f.is_percent_growth, f.growth, fg.is_default, fg.is_read_only, +fg.is_autogrow_all_files +FROM sys.database_files AS f WITH (NOLOCK) +LEFT OUTER JOIN sys.filegroups AS fg WITH (NOLOCK) +ON f.data_space_id = fg.data_space_id +ORDER BY f.[file_id] OPTION (RECOMPILE); +------ + +-- Look at how large and how full the files are and where they are located +-- Make sure the transaction log is not full!! + +-- is_autogrow_all_files is new for SQL Server 2016. Equivalent to TF 1117 for user databases + +-- SQL Server 2016: Changes in default behavior for autogrow and allocations for tempdb and user databases +-- https://bit.ly/2evRZSR + + +-- Log space usage for current database (Query 50) (Log Space Usage) +SELECT DB_NAME(lsu.database_id) AS [Database Name], db.recovery_model_desc AS [Recovery Model], + CAST(lsu.total_log_size_in_bytes/1048576.0 AS DECIMAL(10, 2)) AS [Total Log Space (MB)], + CAST(lsu.used_log_space_in_bytes/1048576.0 AS DECIMAL(10, 2)) AS [Used Log Space (MB)], + CAST(lsu.used_log_space_in_percent AS DECIMAL(10, 2)) AS [Used Log Space %], + CAST(lsu.log_space_in_bytes_since_last_backup/1048576.0 AS DECIMAL(10, 2)) AS [Used Log Space Since Last Backup (MB)], + db.log_reuse_wait_desc +FROM sys.dm_db_log_space_usage AS lsu WITH (NOLOCK) +INNER JOIN sys.databases AS db WITH (NOLOCK) +ON lsu.database_id = db.database_id +OPTION (RECOMPILE); +------ + +-- Look at log file size and usage, along with the log reuse wait description for the current database + +-- sys.dm_db_log_space_usage (Transact-SQL) +-- https://bit.ly/2H4MQw9 + + +-- Get database scoped configuration values for current database (Query 51) (Database-scoped Configurations) +SELECT configuration_id, name, [value] AS [value_for_primary], value_for_secondary +FROM sys.database_scoped_configurations WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- This lets you see the value of these new properties for the current database + +-- Clear plan cache for current database +-- ALTER DATABASE SCOPED CONFIGURATION CLEAR PROCEDURE_CACHE; + +-- ALTER DATABASE SCOPED CONFIGURATION (Transact-SQL) +-- https://bit.ly/2sOH7nb + + +-- I/O Statistics by file for the current database (Query 52) (IO Stats By File) +SELECT DB_NAME(DB_ID()) AS [Database Name], df.name AS [Logical Name], vfs.[file_id], df.type_desc, +df.physical_name AS [Physical Name], CAST(vfs.size_on_disk_bytes/1048576.0 AS DECIMAL(16, 2)) AS [Size on Disk (MB)], +vfs.num_of_reads, vfs.num_of_writes, vfs.io_stall_read_ms, vfs.io_stall_write_ms, +CAST(100. * vfs.io_stall_read_ms/(vfs.io_stall_read_ms + vfs.io_stall_write_ms) AS DECIMAL(16,1)) AS [IO Stall Reads Pct], +CAST(100. * vfs.io_stall_write_ms/(vfs.io_stall_write_ms + vfs.io_stall_read_ms) AS DECIMAL(16,1)) AS [IO Stall Writes Pct], +(vfs.num_of_reads + vfs.num_of_writes) AS [Writes + Reads], +CAST(vfs.num_of_bytes_read/1048576.0 AS DECIMAL(16, 2)) AS [MB Read], +CAST(vfs.num_of_bytes_written/1048576.0 AS DECIMAL(16, 2)) AS [MB Written], +CAST(100. * vfs.num_of_reads/(vfs.num_of_reads + vfs.num_of_writes) AS DECIMAL(16,1)) AS [# Reads Pct], +CAST(100. * vfs.num_of_writes/(vfs.num_of_reads + vfs.num_of_writes) AS DECIMAL(16,1)) AS [# Write Pct], +CAST(100. * vfs.num_of_bytes_read/(vfs.num_of_bytes_read + vfs.num_of_bytes_written) AS DECIMAL(16,1)) AS [Read Bytes Pct], +CAST(100. * vfs.num_of_bytes_written/(vfs.num_of_bytes_read + vfs.num_of_bytes_written) AS DECIMAL(16,1)) AS [Written Bytes Pct] +FROM sys.dm_io_virtual_file_stats(DB_ID(), NULL) AS vfs +INNER JOIN sys.database_files AS df WITH (NOLOCK) +ON vfs.[file_id]= df.[file_id] OPTION (RECOMPILE); +------ + +-- This helps you characterize your workload better from an I/O perspective for this database +-- It helps you determine whether you has an OLTP or DW/DSS type of workload + + + +-- Get most frequently executed queries for this database (Query 53) (Query Execution Counts) +SELECT TOP(50) LEFT(t.[text], 50) AS [Short Query Text], qs.execution_count AS [Execution Count], +qs.total_logical_reads AS [Total Logical Reads], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +qs.total_worker_time AS [Total Worker Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.total_elapsed_time AS [Total Elapsed Time], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] +--,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel +FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t +CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp +WHERE t.dbid = DB_ID() +ORDER BY qs.execution_count DESC OPTION (RECOMPILE); +------ + + +-- Queries 54 through 60 are the "Bad Man List" for stored procedures + +-- Top Cached SPs By Execution Count (Query 54) (SP Execution Counts) +SELECT TOP(100) p.name AS [SP Name], qs.execution_count AS [Execution Count], +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +ORDER BY qs.execution_count DESC OPTION (RECOMPILE); +------ + +-- Tells you which cached stored procedures are called the most often +-- This helps you characterize and baseline your workload +-- It also helps you find possible caching opportunities + + +-- Top Cached SPs By Avg Elapsed Time (Query 55) (SP Avg Elapsed Time) +SELECT TOP(25) p.name AS [SP Name], qs.min_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +qs.max_elapsed_time, qs.last_elapsed_time, qs.total_elapsed_time, qs.execution_count, +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], +qs.total_worker_time AS [TotalWorkerTime], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +ORDER BY avg_elapsed_time DESC OPTION (RECOMPILE); +------ + +-- This helps you find high average elapsed time cached stored procedures that +-- may be easy to optimize with standard query tuning techniques + + + +-- Top Cached SPs By Total Worker time. Worker time relates to CPU cost (Query 56) (SP Worker Time) +SELECT TOP(25) p.name AS [SP Name], qs.total_worker_time AS [TotalWorkerTime], +qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], qs.execution_count, +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); +------ + +-- This helps you find the most expensive cached stored procedures from a CPU perspective +-- You should look at this if you see signs of CPU pressure + + +-- Top Cached SPs By Total Logical Reads. Logical reads relate to memory pressure (Query 57) (SP Logical Reads) +SELECT TOP(25) p.name AS [SP Name], qs.total_logical_reads AS [TotalLogicalReads], +qs.total_logical_reads/qs.execution_count AS [AvgLogicalReads],qs.execution_count, +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE); +------ + +-- This helps you find the most expensive cached stored procedures from a memory perspective +-- You should look at this if you see signs of memory pressure + + +-- Top Cached SPs By Total Physical Reads. Physical reads relate to disk read I/O pressure (Query 58) (SP Physical Reads) +SELECT TOP(25) p.name AS [SP Name],qs.total_physical_reads AS [TotalPhysicalReads], +qs.total_physical_reads/qs.execution_count AS [AvgPhysicalReads], qs.execution_count, +qs.total_logical_reads,qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND qs.total_physical_reads > 0 +ORDER BY qs.total_physical_reads DESC, qs.total_logical_reads DESC OPTION (RECOMPILE); +------ + +-- This helps you find the most expensive cached stored procedures from a read I/O perspective +-- You should look at this if you see signs of I/O pressure or of memory pressure + + + +-- Top Cached SPs By Total Logical Writes (Query 59) (SP Logical Writes) +-- Logical writes relate to both memory and disk I/O pressure +SELECT TOP(25) p.name AS [SP Name], qs.total_logical_writes AS [TotalLogicalWrites], +qs.total_logical_writes/qs.execution_count AS [AvgLogicalWrites], qs.execution_count, +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND qs.total_logical_writes > 0 +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +ORDER BY qs.total_logical_writes DESC OPTION (RECOMPILE); +------ + +-- This helps you find the most expensive cached stored procedures from a write I/O perspective +-- You should look at this if you see signs of I/O pressure or of memory pressure + + + +-- Cached SPs Missing Indexes by Execution Count (Query 60) (SP Missing Index) +SELECT TOP(25) p.name AS [SP Name], qs.execution_count AS [Execution Count], +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +AND CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' +ORDER BY qs.execution_count DESC OPTION (RECOMPILE); +------ + +-- This helps you find the most frequently executed cached stored procedures that have missing index warnings +-- This can often help you find index tuning candidates + + + +-- Lists the top statements by average input/output usage for the current database (Query 61) (Top IO Statements) +SELECT TOP(50) OBJECT_NAME(qt.objectid, dbid) AS [SP Name], +(qs.total_logical_reads + qs.total_logical_writes) /qs.execution_count AS [Avg IO], qs.execution_count AS [Execution Count], +SUBSTRING(qt.[text],qs.statement_start_offset/2, + (CASE + WHEN qs.statement_end_offset = -1 + THEN LEN(CONVERT(nvarchar(max), qt.[text])) * 2 + ELSE qs.statement_end_offset + END - qs.statement_start_offset)/2) AS [Query Text] +FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS qt +WHERE qt.[dbid] = DB_ID() +ORDER BY [Avg IO] DESC OPTION (RECOMPILE); +------ + +-- Helps you find the most expensive statements for I/O by SP + + + +-- Possible Bad NC Indexes (writes > reads) (Query 62) (Bad NC Indexes) +SELECT SCHEMA_NAME(o.[schema_id]) AS [Schema Name], +OBJECT_NAME(s.[object_id]) AS [Table Name], +i.name AS [Index Name], i.index_id, +i.is_disabled, i.is_hypothetical, i.has_filter, i.fill_factor, +s.user_updates AS [Total Writes], s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], +s.user_updates - (s.user_seeks + s.user_scans + s.user_lookups) AS [Difference] +FROM sys.dm_db_index_usage_stats AS s WITH (NOLOCK) +INNER JOIN sys.indexes AS i WITH (NOLOCK) +ON s.[object_id] = i.[object_id] +AND i.index_id = s.index_id +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON i.[object_id] = o.[object_id] +WHERE OBJECTPROPERTY(s.[object_id],'IsUserTable') = 1 +AND s.database_id = DB_ID() +AND s.user_updates > (s.user_seeks + s.user_scans + s.user_lookups) +AND i.index_id > 1 AND i.[type_desc] = N'NONCLUSTERED' +AND i.is_primary_key = 0 AND i.is_unique_constraint = 0 AND i.is_unique = 0 +ORDER BY [Difference] DESC, [Total Writes] DESC, [Total Reads] ASC OPTION (RECOMPILE); +------ + +-- Look for indexes with high numbers of writes and zero or very low numbers of reads +-- Consider your complete workload, and how long your instance has been running +-- Investigate further before dropping an index! + + +-- Missing Indexes for current database by Index Advantage (Query 63) (Missing Indexes) +SELECT DISTINCT CONVERT(decimal(18,2), migs.user_seeks * migs.avg_total_user_cost * (migs.avg_user_impact * 0.01)) AS [index_advantage], +migs.last_user_seek, mid.[statement] AS [Database.Schema.Table], +mid.equality_columns, mid.inequality_columns, mid.included_columns, +migs.user_seeks, migs.avg_total_user_cost, migs.avg_user_impact, +OBJECT_NAME(mid.[object_id]) AS [Table Name], p.rows AS [Table Rows] +FROM sys.dm_db_missing_index_group_stats AS migs WITH (NOLOCK) +INNER JOIN sys.dm_db_missing_index_groups AS mig WITH (NOLOCK) +ON migs.group_handle = mig.index_group_handle +INNER JOIN sys.dm_db_missing_index_details AS mid WITH (NOLOCK) +ON mig.index_handle = mid.index_handle +INNER JOIN sys.partitions AS p WITH (NOLOCK) +ON p.[object_id] = mid.[object_id] +WHERE mid.database_id = DB_ID() +AND p.index_id < 2 +ORDER BY index_advantage DESC OPTION (RECOMPILE); +------ + +-- Look at index advantage, last user seek time, number of user seeks to help determine source and importance +-- SQL Server is overly eager to add included columns, so beware +-- Do not just blindly add indexes that show up from this query!!! +-- Hkan Winther has given me some great suggestions for this query + + +-- Find missing index warnings for cached plans in the current database (Query 64) (Missing Index Warnings) +-- Note: This query could take some time on a busy instance +SELECT TOP(25) OBJECT_NAME(objectid) AS [ObjectName], + cp.objtype, cp.usecounts, cp.size_in_bytes, qp.query_plan +FROM sys.dm_exec_cached_plans AS cp WITH (NOLOCK) +CROSS APPLY sys.dm_exec_query_plan(cp.plan_handle) AS qp +WHERE CAST(query_plan AS NVARCHAR(MAX)) LIKE N'%MissingIndex%' +AND dbid = DB_ID() +ORDER BY cp.usecounts DESC OPTION (RECOMPILE); +------ + +-- Helps you connect missing indexes to specific stored procedures or queries +-- This can help you decide whether to add them or not + + +-- Breaks down buffers used by current database by object (table, index) in the buffer cache (Query 65) (Buffer Usage) +-- Note: This query could take some time on a busy instance +SELECT fg.name AS [Filegroup Name], SCHEMA_NAME(o.Schema_ID) AS [Schema Name], +OBJECT_NAME(p.[object_id]) AS [Object Name], p.index_id, +CAST(COUNT(*)/128.0 AS DECIMAL(10, 2)) AS [Buffer size(MB)], +COUNT(*) AS [BufferCount], p.[Rows] AS [Row Count], +p.data_compression_desc AS [Compression Type] +FROM sys.allocation_units AS a WITH (NOLOCK) +INNER JOIN sys.dm_os_buffer_descriptors AS b WITH (NOLOCK) +ON a.allocation_unit_id = b.allocation_unit_id +INNER JOIN sys.partitions AS p WITH (NOLOCK) +ON a.container_id = p.hobt_id +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON p.object_id = o.object_id +INNER JOIN sys.database_files AS f WITH (NOLOCK) +ON b.file_id = f.file_id +INNER JOIN sys.filegroups AS fg WITH (NOLOCK) +ON f.data_space_id = fg.data_space_id +WHERE b.database_id = CONVERT(int, DB_ID()) +AND p.[object_id] > 100 +AND OBJECT_NAME(p.[object_id]) NOT LIKE N'plan_%' +AND OBJECT_NAME(p.[object_id]) NOT LIKE N'sys%' +AND OBJECT_NAME(p.[object_id]) NOT LIKE N'xml_index_nodes%' +GROUP BY fg.name, o.Schema_ID, p.[object_id], p.index_id, + p.data_compression_desc, p.[Rows] +ORDER BY [BufferCount] DESC OPTION (RECOMPILE); +------ + +-- Tells you what tables and indexes are using the most memory in the buffer cache +-- It can help identify possible candidates for data compression + + +-- Get Table names, row counts, and compression status for clustered index or heap (Query 66) (Table Sizes) +SELECT SCHEMA_NAME(o.Schema_ID) AS [Schema Name], OBJECT_NAME(p.object_id) AS [ObjectName], +SUM(p.Rows) AS [RowCount], p.data_compression_desc AS [Compression Type] +FROM sys.partitions AS p WITH (NOLOCK) +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON p.object_id = o.object_id +WHERE index_id < 2 --ignore the partitions from the non-clustered index if any +AND OBJECT_NAME(p.object_id) NOT LIKE N'sys%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'spt_%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'queue_%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'filestream_tombstone%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'fulltext%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'ifts_comp_fragment%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'filetable_updates%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'xml_index_nodes%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'sqlagent_job%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'plan_persist%' +GROUP BY SCHEMA_NAME(o.Schema_ID), p.object_id, data_compression_desc +ORDER BY SUM(p.Rows) DESC OPTION (RECOMPILE); +------ + +-- Gives you an idea of table sizes, and possible data compression opportunities + + + +-- Get some key table properties (Query 67) (Table Properties) +SELECT OBJECT_NAME(t.[object_id]) AS [ObjectName], p.[rows] AS [Table Rows], p.index_id, + p.data_compression_desc AS [Index Data Compression], + t.create_date, t.lock_on_bulk_load, t.is_replicated, t.has_replication_filter, + t.is_tracked_by_cdc, t.lock_escalation_desc, t.is_filetable, + t.is_memory_optimized, t.durability_desc, + t.temporal_type_desc, t.is_remote_data_archive_enabled, t.is_external -- new for SQL Server 2016 +FROM sys.tables AS t WITH (NOLOCK) +INNER JOIN sys.partitions AS p WITH (NOLOCK) +ON t.[object_id] = p.[object_id] +WHERE OBJECT_NAME(t.[object_id]) NOT LIKE N'sys%' +ORDER BY OBJECT_NAME(t.[object_id]), p.index_id OPTION (RECOMPILE); +------ + +-- Gives you some good information about your tables +-- is_memory_optimized and durability_desc were new in SQL Server 2014 +-- temporal_type_desc, is_remote_data_archive_enabled, is_external were new in SQL Server 2016 + +-- sys.tables (Transact-SQL) +-- https://bit.ly/2Gk7998 + + + +-- When were Statistics last updated on all indexes? (Query 68) (Statistics Update) +SELECT SCHEMA_NAME(o.Schema_ID) + N'.' + o.[NAME] AS [Object Name], o.[type_desc] AS [Object Type], + i.[name] AS [Index Name], STATS_DATE(i.[object_id], i.index_id) AS [Statistics Date], + s.auto_created, s.no_recompute, s.user_created, s.is_incremental, s.is_temporary, + st.row_count, st.used_page_count +FROM sys.objects AS o WITH (NOLOCK) +INNER JOIN sys.indexes AS i WITH (NOLOCK) +ON o.[object_id] = i.[object_id] +INNER JOIN sys.stats AS s WITH (NOLOCK) +ON i.[object_id] = s.[object_id] +AND i.index_id = s.stats_id +INNER JOIN sys.dm_db_partition_stats AS st WITH (NOLOCK) +ON o.[object_id] = st.[object_id] +AND i.[index_id] = st.[index_id] +WHERE o.[type] IN ('U', 'V') +AND st.row_count > 0 +ORDER BY STATS_DATE(i.[object_id], i.index_id) DESC OPTION (RECOMPILE); +------ + +-- Helps discover possible problems with out-of-date statistics +-- Also gives you an idea which indexes are the most active + +-- sys.stats (Transact-SQL) +-- https://bit.ly/2GyAxrn + +-- UPDATEs to Statistics (Erin Stellato) +-- https://bit.ly/2vhrYQy + + + + +-- Look at most frequently modified indexes and statistics (Query 69) (Volatile Indexes) +SELECT o.[name] AS [Object Name], o.[object_id], o.[type_desc], s.[name] AS [Statistics Name], + s.stats_id, s.no_recompute, s.auto_created, s.is_incremental, s.is_temporary, + sp.modification_counter, sp.[rows], sp.rows_sampled, sp.last_updated +FROM sys.objects AS o WITH (NOLOCK) +INNER JOIN sys.stats AS s WITH (NOLOCK) +ON s.object_id = o.object_id +CROSS APPLY sys.dm_db_stats_properties(s.object_id, s.stats_id) AS sp +WHERE o.[type_desc] NOT IN (N'SYSTEM_TABLE', N'INTERNAL_TABLE') +AND sp.modification_counter > 0 +ORDER BY sp.modification_counter DESC, o.name OPTION (RECOMPILE); +------ + +-- This helps you understand your workload and make better decisions about +-- things like data compression and adding new indexes to a table + + + +-- Get fragmentation info for all indexes above a certain size in the current database (Query 70) (Index Fragmentation) +-- Note: This query could take some time on a very large database +SELECT DB_NAME(ps.database_id) AS [Database Name], SCHEMA_NAME(o.[schema_id]) AS [Schema Name], +OBJECT_NAME(ps.OBJECT_ID) AS [Object Name], i.[name] AS [Index Name], ps.index_id, +ps.index_type_desc, ps.avg_fragmentation_in_percent, +ps.fragment_count, ps.page_count, i.fill_factor, i.has_filter, +i.filter_definition, i.[allow_page_locks] +FROM sys.dm_db_index_physical_stats(DB_ID(),NULL, NULL, NULL , N'LIMITED') AS ps +INNER JOIN sys.indexes AS i WITH (NOLOCK) +ON ps.[object_id] = i.[object_id] +AND ps.index_id = i.index_id +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON i.[object_id] = o.[object_id] +WHERE ps.database_id = DB_ID() +AND ps.page_count > 2500 +ORDER BY ps.avg_fragmentation_in_percent DESC OPTION (RECOMPILE); +------ + +-- Helps determine whether you have framentation in your relational indexes +-- and how effective your index maintenance strategy is + + +--- Index Read/Write stats (all tables in current DB) ordered by Reads (Query 71) (Overall Index Usage - Reads) +SELECT SCHEMA_NAME(t.[schema_id]) AS [SchemaName], OBJECT_NAME(i.[object_id]) AS [ObjectName], + i.[name] AS [IndexName], i.index_id, + s.user_seeks, s.user_scans, s.user_lookups, + s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], + s.user_updates AS [Writes], + i.[type_desc] AS [Index Type], i.fill_factor AS [Fill Factor], i.has_filter, i.filter_definition, + s.last_user_scan, s.last_user_lookup, s.last_user_seek +FROM sys.indexes AS i WITH (NOLOCK) +LEFT OUTER JOIN sys.dm_db_index_usage_stats AS s WITH (NOLOCK) +ON i.[object_id] = s.[object_id] +AND i.index_id = s.index_id +AND s.database_id = DB_ID() +LEFT OUTER JOIN sys.tables AS t WITH (NOLOCK) +ON t.[object_id] = i.[object_id] +WHERE OBJECTPROPERTY(i.[object_id],'IsUserTable') = 1 +ORDER BY s.user_seeks + s.user_scans + s.user_lookups DESC OPTION (RECOMPILE); -- Order by reads +------ + +-- Show which indexes in the current database are most active for Reads + + +--- Index Read/Write stats (all tables in current DB) ordered by Writes (Query 72) (Overall Index Usage - Writes) +SELECT SCHEMA_NAME(t.[schema_id]) AS [SchemaName],OBJECT_NAME(i.[object_id]) AS [ObjectName], + i.[name] AS [IndexName], i.index_id, + s.user_updates AS [Writes], s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], + i.[type_desc] AS [Index Type], i.fill_factor AS [Fill Factor], i.has_filter, i.filter_definition, + s.last_system_update, s.last_user_update +FROM sys.indexes AS i WITH (NOLOCK) +LEFT OUTER JOIN sys.dm_db_index_usage_stats AS s WITH (NOLOCK) +ON i.[object_id] = s.[object_id] +AND i.index_id = s.index_id +AND s.database_id = DB_ID() +LEFT OUTER JOIN sys.tables AS t WITH (NOLOCK) +ON t.[object_id] = i.[object_id] +WHERE OBJECTPROPERTY(i.[object_id],'IsUserTable') = 1 +ORDER BY s.user_updates DESC OPTION (RECOMPILE); -- Order by writes +------ + +-- Show which indexes in the current database are most active for Writes + + +-- Get in-memory OLTP index usage (Query 73) (XTP Index Usage) +SELECT OBJECT_NAME(i.[object_id]) AS [Object Name], i.index_id, i.[name] AS [Index Name], + i.[type_desc], xis.scans_started, xis.scans_retries, + xis.rows_touched, xis.rows_returned +FROM sys.dm_db_xtp_index_stats AS xis WITH (NOLOCK) +INNER JOIN sys.indexes AS i WITH (NOLOCK) +ON i.[object_id] = xis.[object_id] +AND i.index_id = xis.index_id +ORDER BY OBJECT_NAME(i.[object_id]) OPTION (RECOMPILE); +------ + +-- This gives you some index usage statistics for in-memory OLTP +-- Returns no data if you are not using in-memory OLTP + +-- Guidelines for Using Indexes on Memory-Optimized Tables +-- https://bit.ly/2GCP8lF + + + +-- Look at Columnstore index physical statistics (Query 74) (Columnstore Index Physical Stat) +SELECT OBJECT_NAME(ps.object_id) AS [TableName], + i.[name] AS [IndexName], ps.index_id, ps.partition_number, + ps.delta_store_hobt_id, ps.state_desc, ps.total_rows, ps.size_in_bytes, + ps.trim_reason_desc, ps.generation, ps.transition_to_compressed_state_desc, + ps.has_vertipaq_optimization, ps.deleted_rows, + 100 * (ISNULL(ps.deleted_rows, 0))/ps.total_rows AS [Fragmentation] +FROM sys.dm_db_column_store_row_group_physical_stats AS ps WITH (NOLOCK) +INNER JOIN sys.indexes AS i WITH (NOLOCK) +ON ps.object_id = i.object_id +AND ps.index_id = i.index_id +ORDER BY ps.object_id, ps.partition_number, ps.row_group_id OPTION (RECOMPILE); +------ + +-- sys.dm_db_column_store_row_group_physical_stats (Transact-SQL) +-- https://bit.ly/2q276XQ + + + +-- Get lock waits for current database (Query 75) (Lock Waits) +SELECT o.name AS [table_name], i.name AS [index_name], ios.index_id, ios.partition_number, + SUM(ios.row_lock_wait_count) AS [total_row_lock_waits], + SUM(ios.row_lock_wait_in_ms) AS [total_row_lock_wait_in_ms], + SUM(ios.page_lock_wait_count) AS [total_page_lock_waits], + SUM(ios.page_lock_wait_in_ms) AS [total_page_lock_wait_in_ms], + SUM(ios.page_lock_wait_in_ms)+ SUM(row_lock_wait_in_ms) AS [total_lock_wait_in_ms] +FROM sys.dm_db_index_operational_stats(DB_ID(), NULL, NULL, NULL) AS ios +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON ios.[object_id] = o.[object_id] +INNER JOIN sys.indexes AS i WITH (NOLOCK) +ON ios.[object_id] = i.[object_id] +AND ios.index_id = i.index_id +WHERE o.[object_id] > 100 +GROUP BY o.name, i.name, ios.index_id, ios.partition_number +HAVING SUM(ios.page_lock_wait_in_ms)+ SUM(row_lock_wait_in_ms) > 0 +ORDER BY total_lock_wait_in_ms DESC OPTION (RECOMPILE); +------ + +-- This query is helpful for troubleshooting blocking and deadlocking issues + + + +-- Look at UDF execution statistics (Query 76) (UDF Statistics) +SELECT OBJECT_NAME(object_id) AS [Function Name], execution_count, + total_worker_time, total_logical_reads, total_physical_reads, total_elapsed_time, + total_elapsed_time/execution_count AS [avg_elapsed_time], + FORMAT(cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +FROM sys.dm_exec_function_stats WITH (NOLOCK) +WHERE database_id = DB_ID() +ORDER BY total_worker_time DESC OPTION (RECOMPILE); +------ + +-- New for SQL Server 2016 +-- Helps you investigate scalar UDF performance issues +-- Does not return information for table valued functions + +-- sys.dm_exec_function_stats (Transact-SQL) +-- https://bit.ly/2q1Q6BM + + +-- Get QueryStore Options for this database (Query 77) (QueryStore Options) +SELECT actual_state_desc, desired_state_desc, [interval_length_minutes], + current_storage_size_mb, [max_storage_size_mb], + query_capture_mode_desc, size_based_cleanup_mode_desc +FROM sys.database_query_store_options WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- New for SQL Server 2016 +-- Requires that Query Store is enabled for this database + +-- Make sure that the actual_state_desc is the same as desired_state_desc +-- Make sure that the current_storage_size_mb is less than the max_storage_size_mb + +-- Tuning Workload Performance with Query Store +-- https://bit.ly/1kHSl7w + + + +-- Get input buffer information for the current database (Query 78) (Input Buffer) +SELECT es.session_id, DB_NAME(es.database_id) AS [Database Name], + es.login_time, es.cpu_time, es.logical_reads, es.memory_usage, + es.[status], ib.event_info AS [Input Buffer] +FROM sys.dm_exec_sessions AS es WITH (NOLOCK) +CROSS APPLY sys.dm_exec_input_buffer(es.session_id, NULL) AS ib +WHERE es.database_id = DB_ID() +AND es.session_id > 50 +AND es.session_id <> @@SPID OPTION (RECOMPILE); +------ + +-- Gives you input buffer information from all non-system sessions for the current database +-- Replaces DBCC INPUTBUFFER + +-- New DMF for retrieving input buffer in SQL Server +-- https://bit.ly/2uHKMbz + +-- sys.dm_exec_input_buffer (Transact-SQL) +-- https://bit.ly/2J5Hf9q + + + +-- Look at recent Full backups for the current database (Query 79) (Recent Full Backups) +SELECT TOP (30) bs.machine_name, bs.server_name, bs.database_name AS [Database Name], bs.recovery_model, +CONVERT (BIGINT, bs.backup_size / 1048576 ) AS [Uncompressed Backup Size (MB)], +CONVERT (BIGINT, bs.compressed_backup_size / 1048576 ) AS [Compressed Backup Size (MB)], +CONVERT (NUMERIC (20,2), (CONVERT (FLOAT, bs.backup_size) / +CONVERT (FLOAT, bs.compressed_backup_size))) AS [Compression Ratio], bs.has_backup_checksums, bs.is_copy_only, bs.encryptor_type, +DATEDIFF (SECOND, bs.backup_start_date, bs.backup_finish_date) AS [Backup Elapsed Time (sec)], +bs.backup_finish_date AS [Backup Finish Date], bmf.physical_device_name AS [Backup Location], bmf.physical_block_size +FROM msdb.dbo.backupset AS bs WITH (NOLOCK) +INNER JOIN msdb.dbo.backupmediafamily AS bmf WITH (NOLOCK) +ON bs.media_set_id = bmf.media_set_id +WHERE bs.database_name = DB_NAME(DB_ID()) +AND bs.[type] = 'D' -- Change to L if you want Log backups +ORDER BY bs.backup_finish_date DESC OPTION (RECOMPILE); +------ + +-- Are your backup sizes and times changing over time? +-- Are you using backup compression? +-- Are you using backup checksums? +-- Are you doing copy_only backups? +-- Are you doing encrypted backups? +-- Have you done any backup tuning with striped backups, or changing the parameters of the backup command? + +-- In SQL Server 2016, native SQL Server backup compression actually works +-- much better with databases that are using TDE than in previous versions +-- https://bit.ly/28Rpb2x + + +-- Microsoft Visual Studio Dev Essentials +-- https://bit.ly/2qjNRxi + +-- Microsoft Azure Learn +-- https://bit.ly/2O0Hacc + + + + diff --git a/Scripts/SQL Server 2016 SP2 Diagnostic Information Queries.sql b/Scripts/SQL Server 2016 SP2 Diagnostic Information Queries.sql new file mode 100644 index 00000000..8a4d729d --- /dev/null +++ b/Scripts/SQL Server 2016 SP2 Diagnostic Information Queries.sql @@ -0,0 +1,1997 @@ + +-- SQL Server 2016 SP2 Diagnostic Information Queries +-- Glenn Berry +-- Last Modified: December 3, 2020 +-- https://glennsqlperformance.com/ +-- https://sqlserverperformance.wordpress.com/ +-- YouTube: https://bit.ly/2PkoAM1 +-- Twitter: GlennAlanBerry + +-- Diagnostic Queries are available here +-- https://glennsqlperformance.com/resources/ + + +-- Please make sure you are using the correct version of these diagnostic queries for your version of SQL Server + + +-- If you like PowerShell, there is a very useful community solution for running these queries in an automated fashion +-- https://dbatools.io/ + +-- Invoke-DbaDiagnosticQuery +-- https://dbatools.io/functions/invoke-dbadiagnosticquery/ + + +--****************************************************************************** +--* Copyright (C) 2020 Glenn Berry +--* All rights reserved. +--* +--* +--* You may alter this code for your own *non-commercial* purposes. You may +--* republish altered code as long as you include this copyright and give due credit. +--* +--* +--* THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF +--* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED +--* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +--* PARTICULAR PURPOSE. +--* +--****************************************************************************** + +-- Check the major product version to see if it is SQL Server 2016 SP2 or greater +IF EXISTS (SELECT * WHERE CONVERT(varchar(128), SERVERPROPERTY('ProductVersion')) LIKE '13%') + BEGIN + IF CONVERT(int, SERVERPROPERTY('ProductBuild')) >= 5026 + PRINT N'You have the correct Service Pack of SQL Server 2016 for this diagnostic information script'; + IF CONVERT(int, SERVERPROPERTY('ProductBuild')) < 5026 + PRINT N'You do NOT have the correct Service Pack of SQL Server 2016 for this diagnostic information script'; + END +ELSE + BEGIN + DECLARE @ProductVersion varchar(128) = CONVERT(varchar(128), SERVERPROPERTY('ProductVersion')); + RAISERROR ('Script does not match the ProductVersion [%s] of this instance. Many of these queries may not work on this version.' , 18 , 16 , @ProductVersion); + END + + + +-- Instance level queries ******************************* + +-- SQL and OS Version information for current instance (Query 1) (Version Info) +SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version Info]; +------ + +-- SQL Server 2016 Builds +-- Build Description Release Date URL to KB Article +-- 13.0.5026.0 SP2 RTM 4/24/2018 https://bit.ly/2FEvN2q +-- 13.0.5149.0 SP2 CU1 5/30/2018 https://support.microsoft.com/en-us/help/4135048/cumulative-update-1-for-sql-server-2016-sp2 +-- 13.0.5153.0 SP2 CU2 7/16/2018 https://support.microsoft.com/en-us/help/4340355 +-- 13.0.5216.0 SP2 CU3 9/20/2018 https://support.microsoft.com/en-us/help/4458871 +-- 13.0.5233.0 SP2 CU4 11/13/2018 https://support.microsoft.com/en-us/help/4464106/cumulative-update-4-for-sql-server-2016-sp2 +-- 13.0.5264.1 SP2 CU5 1/23/2019 https://support.microsoft.com/en-us/help/4475776/cumulative-update-5-for-sql-server-2016-sp2 +-- 13.0.5292.0 SP2 CU6 3/19/2019 https://support.microsoft.com/en-us/help/4488536/cumulative-update-6-for-sql-server-2016-sp2 +-- 13.0.5337.0 SP2 CU7 5/22/2019 https://support.microsoft.com/en-us/help/4495256/cumulative-update-7-for-sql-server-2016-sp2 +-- 13.0.5366.0 SP2 CU7 + Security Update 7/9/2019 https://support.microsoft.com/en-us/help/4505222/security-update-for-sql-server-2016-sp2-cu7-gdr-july-9-2019 +-- 13.0.5426.0 SP2 CU8 7/31/2019 https://support.microsoft.com/en-us/help/4505830/cumulative-update-8-for-sql-server-2016-sp2 +-- 13.0.5470.0 SP2 CU9 9/30/2019 https://support.microsoft.com/en-us/help/4515435/cumulative-update-9-for-sql-server-2016-sp2 +-- 13.0.5492.2 SP2 CU10 10/8/2019 https://support.microsoft.com/en-us/help/4524334/cumulative-update-10-for-sql-server-2016-sp2 +-- 13.0.5598.27 SP2 CU11 12/9/2019 https://support.microsoft.com/en-us/help/4527378/cumulative-update-11-for-sql-server-2016-sp2 +-- 13.0.5622.0 SP2 CU11 + Security Update 2/11/2010 https://support.microsoft.com/en-us/help/4535706/description-of-the-security-update-for-sql-server-2016-sp2-cu11-februa +-- 13.0.5698.0 SP2 CU12 2/25/2020 https://support.microsoft.com/en-us/help/4536648/cumulative-update-12-for-sql-server-2016-sp2 +-- 13.0.5820.21 SP2 CU13 5/38/2020 https://support.microsoft.com/en-us/help/4549825/cumulative-update-13-for-sql-server-2016-sp2 +-- 13.0.5830.85 SP2 CU14 8/6/2020 https://support.microsoft.com/en-us/help/4564903/cumulative-update-14-for-sql-server-2016-sp2 +-- 13.0.5850.14 SP2 CU15 9/28/2020 https://support.microsoft.com/en-us/help/4577775/cumulative-update-15-for-sql-server-2016-sp2 + + +-- How to determine the version, edition and update level of SQL Server and its components +-- https://bit.ly/2oAjKgW + +-- How to obtain the latest Service Pack for SQL Server 2016 +-- https://bit.ly/2egtfzK + +-- SQL Server 2016 build versions +-- https://bit.ly/2epkTDT + +-- Recommended updates and configuration options for SQL Server 2017 and 2016 with high-performance workloads +-- https://bit.ly/2JsReue + +-- Where to find information about the latest SQL Server builds +-- https://bit.ly/2IGHbfY + +-- Performance and Stability Related Fixes in Post-SQL Server 2016 SP2 Builds +-- https://bit.ly/2K3LoPf + +-- Update Center for Microsoft SQL Server +-- https://bit.ly/2pZptuQ + +-- Download SQL Server Management Studio (SSMS) +-- https://bit.ly/1OcupT9 + +-- Download and install Azure Data Studio +-- https://bit.ly/2vgke1A + +-- SQL Server 2016 Configuration Manager is SQLServerManager13.msc + +-- Get socket, physical core and logical core count from the SQL Server Error log. (Query 2) (Core Counts) +-- This query might take a few seconds depending on the size of your error log +EXEC sys.xp_readerrorlog 0, 1, N'detected', N'socket'; +------ + +-- This can help you determine the exact core counts used by SQL Server and whether HT is enabled or not +-- It can also help you confirm your SQL Server licensing model +-- Be on the lookout for this message "using 40 logical processors based on SQL Server licensing" +-- (when you have more than 40 logical cores) which means grandfathered Server/CAL licensing +-- This query will return no results if your error log has been recycled since the instance was last started + + + +-- Get selected server properties (Query 3) (Server Properties) +SELECT SERVERPROPERTY('MachineName') AS [MachineName], +SERVERPROPERTY('ServerName') AS [ServerName], +SERVERPROPERTY('InstanceName') AS [Instance], +SERVERPROPERTY('IsClustered') AS [IsClustered], +SERVERPROPERTY('ComputerNamePhysicalNetBIOS') AS [ComputerNamePhysicalNetBIOS], +SERVERPROPERTY('Edition') AS [Edition], +SERVERPROPERTY('ProductLevel') AS [ProductLevel], -- What servicing branch (RTM/SP/CU) +SERVERPROPERTY('ProductUpdateLevel') AS [ProductUpdateLevel], -- Within a servicing branch, what CU# is applied +SERVERPROPERTY('ProductVersion') AS [ProductVersion], +SERVERPROPERTY('ProductMajorVersion') AS [ProductMajorVersion], +SERVERPROPERTY('ProductMinorVersion') AS [ProductMinorVersion], +SERVERPROPERTY('ProductBuild') AS [ProductBuild], +SERVERPROPERTY('ProductBuildType') AS [ProductBuildType], -- Is this a GDR or OD hotfix (NULL if on a CU build) +SERVERPROPERTY('ProductUpdateReference') AS [ProductUpdateReference], -- KB article number that is applicable for this build +SERVERPROPERTY('ProcessID') AS [ProcessID], +SERVERPROPERTY('Collation') AS [Collation], +SERVERPROPERTY('IsFullTextInstalled') AS [IsFullTextInstalled], +SERVERPROPERTY('IsIntegratedSecurityOnly') AS [IsIntegratedSecurityOnly], +SERVERPROPERTY('FilestreamConfiguredLevel') AS [FilestreamConfiguredLevel], +SERVERPROPERTY('IsHadrEnabled') AS [IsHadrEnabled], +SERVERPROPERTY('HadrManagerStatus') AS [HadrManagerStatus], +SERVERPROPERTY('InstanceDefaultDataPath') AS [InstanceDefaultDataPath], +SERVERPROPERTY('InstanceDefaultLogPath') AS [InstanceDefaultLogPath], +SERVERPROPERTY('ErrorLogFileName') AS [ErrorLogFileName], +SERVERPROPERTY('BuildClrVersion') AS [Build CLR Version], +SERVERPROPERTY('IsXTPSupported') AS [IsXTPSupported], +SERVERPROPERTY('IsPolybaseInstalled') AS [IsPolybaseInstalled], -- New for SQL Server 2016 +SERVERPROPERTY('IsAdvancedAnalyticsInstalled') AS [IsRServicesInstalled]; -- New for SQL Server 2016 +------ + +-- This gives you a lot of useful information about your instance of SQL Server, +-- such as the ProcessID for SQL Server and your collation +-- Note: Some columns will be NULL on older SQL Server builds + +-- SERVERPROPERTY (Transact-SQL) +-- https://bit.ly/2eeaXeI + + + +-- Get instance-level configuration values for instance (Query 4) (Configuration Values) +SELECT name, value, value_in_use, minimum, maximum, [description], is_dynamic, is_advanced +FROM sys.configurations WITH (NOLOCK) +ORDER BY name OPTION (RECOMPILE); +------ + +-- Focus on these settings: +-- automatic soft-NUMA disabled (should be 0 in most cases) +-- backup checksum default (should be 1) +-- backup compression default (should be 1 in most cases) +-- clr enabled (only enable if it is needed) +-- cost threshold for parallelism (depends on your workload) +-- lightweight pooling (should be zero) +-- max degree of parallelism (depends on your workload and hardware) +-- max server memory (MB) (set to an appropriate value, not the default) +-- optimize for ad hoc workloads (should be 1) +-- priority boost (should be zero) +-- remote admin connections (should be 1) + + +-- sys.configurations (Transact-SQL) +-- https://bit.ly/2HsyDZI + + +-- Returns a list of all global trace flags that are enabled (Query 5) (Global Trace Flags) +DBCC TRACESTATUS (-1); +------ + +-- If no global trace flags are enabled, no results will be returned. +-- It is very useful to know what global trace flags are currently enabled as part of the diagnostic process. + +-- Common trace flags that should be enabled in most cases +-- TF 460 - Improvement: Optional replacement for "String or binary data would be truncated" message with extended information in SQL Server 2017 +-- https://bit.ly/2sboMli (added in SP2 CU6) + +-- TF 3226 - Supresses logging of successful database backup messages to the SQL Server Error Log +-- https://bit.ly/38zDNAK + +-- TF 6534 - Enables use of native code to improve performance with spatial data +-- https://bit.ly/2HrQUpU + +-- TF 7745 - Prevents Query Store data from being written to disk in case of a failover or shutdown command +-- https://bit.ly/2GU69Km + +-- TF 7752 - Enables asynchronous load of Query Store +-- This allows a database to become online and queries to be executed before the Query Store has been fully recovered + +-- The behavior of TF 1117, 1118 are enabled for tempdb in SQL Server 2016 by default +-- SQL 2016 It Just Runs Faster: -T1117 and -T1118 changes for TEMPDB and user databases +-- https://bit.ly/2lbNWxK + +-- The behavior of TF 2371 is enabled by default in SQL Server 2016 and newer (in compat level 130 and higher) + +-- DBCC TRACEON - Trace Flags (Transact-SQL) +-- https://bit.ly/2FuSvPg + +-- Recommended updates and configuration options for SQL Server 2017 and 2016 with high-performance workloads +-- https://bit.ly/2VVRGTY + + + + +-- SQL Server Process Address space info (Query 6) (Process Memory) +-- (shows whether locked pages is enabled, among other things) +SELECT physical_memory_in_use_kb/1024 AS [SQL Server Memory Usage (MB)], + locked_page_allocations_kb/1024 AS [SQL Server Locked Pages Allocation (MB)], + large_page_allocations_kb/1024 AS [SQL Server Large Pages Allocation (MB)], + page_fault_count, memory_utilization_percentage, available_commit_limit_kb, + process_physical_memory_low, process_virtual_memory_low +FROM sys.dm_os_process_memory WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- You want to see 0 for process_physical_memory_low +-- You want to see 0 for process_virtual_memory_low +-- This indicates that you are not under internal memory pressure +-- If locked_page_allocations_kb > 0, then LPIM is enabled + +-- How to enable the "locked pages" feature in SQL Server 2012 +-- https://bit.ly/2F5UjOA + +-- Memory Management Architecture Guide +-- https://bit.ly/2JKkadC + + + +-- SQL Server Services information (Query 7) (SQL Server Services Info) +SELECT servicename, process_id, startup_type_desc, status_desc, +last_startup_time, service_account, is_clustered, cluster_nodename, [filename], +instant_file_initialization_enabled +FROM sys.dm_server_services WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- Tells you the account being used for the SQL Server Service and the SQL Agent Service +-- Shows the process_id, when they were last started, and their current status +-- Also shows whether you are running on a failover cluster instance, and what node you are running on +-- Also shows whether IFI is enabled + +-- sys.dm_server_services (Transact-SQL) +-- https://bit.ly/2oKa1Un + + +-- Last backup information by database (Query 8) (Last Backup By Database) +SELECT ISNULL(d.[name], bs.[database_name]) AS [Database], d.recovery_model_desc AS [Recovery Model], + d.log_reuse_wait_desc AS [Log Reuse Wait Desc], + MAX(CASE WHEN [type] = 'D' THEN bs.backup_finish_date ELSE NULL END) AS [Last Full Backup], + MAX(CASE WHEN [type] = 'D' THEN bmf.physical_device_name ELSE NULL END) AS [Last Full Backup Location], + MAX(CASE WHEN [type] = 'I' THEN bs.backup_finish_date ELSE NULL END) AS [Last Differential Backup], + MAX(CASE WHEN [type] = 'I' THEN bmf.physical_device_name ELSE NULL END) AS [Last Differential Backup Location], + MAX(CASE WHEN [type] = 'L' THEN bs.backup_finish_date ELSE NULL END) AS [Last Log Backup], + MAX(CASE WHEN [type] = 'L' THEN bmf.physical_device_name ELSE NULL END) AS [Last Log Backup Location] +FROM sys.databases AS d WITH (NOLOCK) +LEFT OUTER JOIN msdb.dbo.backupset AS bs WITH (NOLOCK) +ON bs.[database_name] = d.[name] +LEFT OUTER JOIN msdb.dbo.backupmediafamily AS bmf WITH (NOLOCK) +ON bs.media_set_id = bmf.media_set_id +AND bs.backup_finish_date > GETDATE()- 30 +WHERE d.name <> N'tempdb' +GROUP BY ISNULL(d.[name], bs.[database_name]), d.recovery_model_desc, d.log_reuse_wait_desc, d.[name] +ORDER BY d.recovery_model_desc, d.[name] OPTION (RECOMPILE); +------ + +-- This helps you spot runaway transaction logs and other issues with your backup schedule + + +-- Get SQL Server Agent jobs and Category information (Query 9) (SQL Server Agent Jobs) +SELECT sj.name AS [Job Name], sj.[description] AS [Job Description], SUSER_SNAME(sj.owner_sid) AS [Job Owner], +sj.date_created AS [Date Created], sj.[enabled] AS [Job Enabled], +sj.notify_email_operator_id, sj.notify_level_email, sc.name AS [CategoryName], +s.[enabled] AS [Sched Enabled], js.next_run_date, js.next_run_time +FROM msdb.dbo.sysjobs AS sj WITH (NOLOCK) +INNER JOIN msdb.dbo.syscategories AS sc WITH (NOLOCK) +ON sj.category_id = sc.category_id +LEFT OUTER JOIN msdb.dbo.sysjobschedules AS js WITH (NOLOCK) +ON sj.job_id = js.job_id +LEFT OUTER JOIN msdb.dbo.sysschedules AS s WITH (NOLOCK) +ON js.schedule_id = s.schedule_id +ORDER BY sj.name OPTION (RECOMPILE); +------ + +-- Gives you some basic information about your SQL Server Agent jobs, who owns them and how they are configured +-- Look for Agent jobs that are not owned by sa +-- Look for jobs that have a notify_email_operator_id set to 0 (meaning no operator) +-- Look for jobs that have a notify_level_email set to 0 (meaning no e-mail is ever sent) +-- +-- MSDN sysjobs documentation +-- https://bit.ly/2paDEOP + +-- SQL Server Maintenance Solution +-- https://bit.ly/1pgchQu + +-- You can use this script to add default schedules to the standard Ola Hallengren Maintenance Solution jobs +-- https://bit.ly/3ane0gN + + +-- Get SQL Server Agent Alert Information (Query 10) (SQL Server Agent Alerts) +SELECT name, event_source, message_id, severity, [enabled], has_notification, + delay_between_responses, occurrence_count, last_occurrence_date, last_occurrence_time +FROM msdb.dbo.sysalerts WITH (NOLOCK) +ORDER BY name OPTION (RECOMPILE); +------ + +-- Gives you some basic information about your SQL Server Agent Alerts +-- (which are different from SQL Server Agent jobs) +-- Read more about Agent Alerts here: https://bit.ly/2v5YR37 + + + +-- Windows information (Query 11) (Windows Info) +SELECT windows_release, windows_service_pack_level, + windows_sku, os_language_version +FROM sys.dm_os_windows_info WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- Gives you major OS version, Service Pack, Edition, and language info for the operating system +-- 10.0 is either Windows 10 or Windows Server 2016 +-- 6.3 is either Windows 8.1 or Windows Server 2012 R2 +-- 6.2 is either Windows 8 or Windows Server 2012 + + +-- Windows SKU codes +-- 4 is Enterprise Edition +-- 7 is Standard Server Edition +-- 8 is Datacenter Server Edition +-- 10 is Enterprise Server Edition +-- 48 is Professional Edition +-- 161 is Pro for Workstations + +-- 1033 for os_language_version is US-English + +-- SQL Server 2016 requires Windows Server 2012 or newer + +-- Quick-Start Installation of SQL Server 2016 +-- https://bit.ly/2qtxQ3G + +-- Hardware and Software Requirements for Installing SQL Server 2016 +-- https://bit.ly/2JJIUTl + +-- Using SQL Server in Windows 8 and later versions of Windows operating system +-- https://bit.ly/2F7Ax0P + + +-- SQL Server NUMA Node information (Query 12) (SQL Server NUMA Info) +SELECT node_id, node_state_desc, memory_node_id, processor_group, cpu_count, online_scheduler_count, + idle_scheduler_count, active_worker_count, avg_load_balance, resource_monitor_state +FROM sys.dm_os_nodes WITH (NOLOCK) +WHERE node_state_desc <> N'ONLINE DAC' OPTION (RECOMPILE); +------ + +-- Gives you some useful information about the composition and relative load on your NUMA nodes +-- You want to see an equal number of schedulers on each NUMA node +-- Watch out if SQL Server 2016 Standard Edition has been installed +-- on a physical or virtual machine with more than four sockets or more than 24 physical cores + +-- sys.dm_os_nodes (Transact-SQL) +-- https://bit.ly/2pn5Mw8 + +-- How to Balance SQL Server Core Licenses Across NUMA Nodes +-- https://bit.ly/3i4TyVR + + + +-- Good basic information about OS memory amounts and state (Query 13) (System Memory) +SELECT total_physical_memory_kb/1024 AS [Physical Memory (MB)], + available_physical_memory_kb/1024 AS [Available Memory (MB)], + total_page_file_kb/1024 AS [Page File Commit Limit (MB)], + total_page_file_kb/1024 - total_physical_memory_kb/1024 AS [Physical Page File Size (MB)], + available_page_file_kb/1024 AS [Available Page File (MB)], + system_cache_kb/1024 AS [System Cache (MB)], + system_memory_state_desc AS [System Memory State] +FROM sys.dm_os_sys_memory WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- You want to see "Available physical memory is high" for System Memory State +-- This indicates that you are not under external memory pressure + +-- Possible System Memory State values: +-- Available physical memory is high +-- Physical memory usage is steady +-- Available physical memory is low +-- Available physical memory is running low +-- Physical memory state is transitioning + +-- sys.dm_os_sys_memory (Transact-SQL) +-- https://bit.ly/2pcV0xq + + + +-- You can skip the next two queries if you know you don't have a clustered instance + + +-- Get information about your cluster nodes and their status (Query 14) (Cluster Node Properties) +-- (if your database server is in a failover cluster) +SELECT NodeName, status_description, is_current_owner +FROM sys.dm_os_cluster_nodes WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- Knowing which node owns the cluster resources is critical +-- Especially when you are installing Windows or SQL Server updates +-- You will see no results if your instance is not clustered + +-- Recommended hotfixes and updates for Windows Server 2012 R2-based failover clusters +-- https://bit.ly/1z5BfCw + + +-- Get information about any AlwaysOn AG cluster this instance is a part of (Query 15) (AlwaysOn AG Cluster) +SELECT cluster_name, quorum_type_desc, quorum_state_desc +FROM sys.dm_hadr_cluster WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- You will see no results if your instance is not using AlwaysOn AGs + + +-- Good overview of AG health and status (Query 16) (AG Status) +SELECT ag.name AS [AG Name], ar.replica_server_name, ar.availability_mode_desc, adc.[database_name], + drs.is_local, drs.is_primary_replica, drs.synchronization_state_desc, drs.is_commit_participant, + drs.synchronization_health_desc, drs.recovery_lsn, drs.truncation_lsn, drs.last_sent_lsn, + drs.last_sent_time, drs.last_received_lsn, drs.last_received_time, drs.last_hardened_lsn, + drs.last_hardened_time, drs.last_redone_lsn, drs.last_redone_time, drs.log_send_queue_size, + drs.log_send_rate, drs.redo_queue_size, drs.redo_rate, drs.filestream_send_rate, + drs.end_of_log_lsn, drs.last_commit_lsn, drs.last_commit_time, drs.database_state_desc +FROM sys.dm_hadr_database_replica_states AS drs WITH (NOLOCK) +INNER JOIN sys.availability_databases_cluster AS adc WITH (NOLOCK) +ON drs.group_id = adc.group_id +AND drs.group_database_id = adc.group_database_id +INNER JOIN sys.availability_groups AS ag WITH (NOLOCK) +ON ag.group_id = drs.group_id +INNER JOIN sys.availability_replicas AS ar WITH (NOLOCK) +ON drs.group_id = ar.group_id +AND drs.replica_id = ar.replica_id +ORDER BY ag.name, ar.replica_server_name, adc.[database_name] OPTION (RECOMPILE); + +-- You will see no results if your instance is not using AlwaysOn AGs + +-- SQL Server 2016 It Just Runs Faster: Always On Availability Groups Turbocharged +-- https://bit.ly/2dn1H6r + + +-- Hardware information from SQL Server 2016 SP2 (Query 17) (Hardware Info) +SELECT cpu_count AS [Logical CPU Count], scheduler_count, + (socket_count * cores_per_socket) AS [Physical Core Count], + socket_count AS [Socket Count], cores_per_socket, numa_node_count, + physical_memory_kb/1024 AS [Physical Memory (MB)], + max_workers_count AS [Max Workers Count], + affinity_type_desc AS [Affinity Type], + sqlserver_start_time AS [SQL Server Start Time], + DATEDIFF(hour, sqlserver_start_time, GETDATE()) AS [SQL Server Up Time (hrs)], + virtual_machine_type_desc AS [Virtual Machine Type], + softnuma_configuration_desc AS [Soft NUMA Configuration], + sql_memory_model_desc +FROM sys.dm_os_sys_info WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- Gives you some good basic hardware information about your database server +-- Note: virtual_machine_type_desc of HYPERVISOR does not automatically mean you are running SQL Server inside of a VM +-- It merely indicates that you have a hypervisor running on your host + +-- sys.dm_os_sys_info (Transact-SQL) +-- https://bit.ly/2pczOYs + +-- Soft NUMA configuration was a new column for SQL Server 2016 +-- OFF = Soft-NUMA feature is OFF +-- ON = SQL Server automatically determines the NUMA node sizes for Soft-NUMA +-- MANUAL = Manually configured soft-NUMA + +-- Configure SQL Server to Use Soft-NUMA (SQL Server) +-- https://bit.ly/2HTpKJt + +-- sql_memory_model_desc values (Added in SQL Server 2016 SP1) +-- CONVENTIONAL +-- LOCK_PAGES +-- LARGE_PAGES + + +-- Get System Manufacturer and model number from SQL Server Error log (Query 18) (System Manufacturer) +EXEC sys.xp_readerrorlog 0, 1, N'Manufacturer'; +------ + +-- This can help you determine the capabilities and capacities of your database server +-- Can also be used to confirm if you are running in a VM +-- This query might take a few seconds if you have not recycled your error log recently +-- This query will return no results if your error log has been recycled since the instance was started + + +-- Get BIOS date from Windows Registry (Query 19) (BIOS Date) +EXEC sys.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'HARDWARE\DESCRIPTION\System\BIOS', N'BiosReleaseDate'; +------ + +-- Helps you understand whether the main system BIOS is up to date, and the possible age of the hardware +-- Not as useful for virtualization + + +-- Get processor description from Windows Registry (Query 20) (Processor Description) +EXEC sys.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'HARDWARE\DESCRIPTION\System\CentralProcessor\0', N'ProcessorNameString'; +------ + +-- Gives you the model number and rated clock speed of your processor(s) +-- Your processors may be running at less than the rated clock speed due +-- to the Windows Power Plan or hardware power management + +-- You can use CPU-Z to get your actual CPU core speed and a lot of other useful information +-- https://bit.ly/QhR6xF + +-- You can learn more about processor selection for SQL Server by following this link +-- https://bit.ly/2F3aVlP + + + + +-- Get information on location, time and size of any memory dumps from SQL Server (Query 21) (Memory Dump Info) +SELECT [filename], creation_time, size_in_bytes/1048576.0 AS [Size (MB)] +FROM sys.dm_server_memory_dumps WITH (NOLOCK) +ORDER BY creation_time DESC OPTION (RECOMPILE); +------ + +-- This will not return any rows if you have +-- not had any memory dumps (which is a good thing) + +-- sys.dm_server_memory_dumps (Transact-SQL) +-- https://bit.ly/2elwWll + + + +-- Look at Suspect Pages table (Query 22) (Suspect Pages) +SELECT DB_NAME(database_id) AS [Database Name], [file_id], page_id, + event_type, error_count, last_update_date +FROM msdb.dbo.suspect_pages WITH (NOLOCK) +ORDER BY database_id OPTION (RECOMPILE); +------ + +-- event_type value descriptions +-- 1 = 823 error caused by an operating system CRC error +-- or 824 error other than a bad checksum or a torn page (for example, a bad page ID) +-- 2 = Bad checksum +-- 3 = Torn page +-- 4 = Restored (The page was restored after it was marked bad) +-- 5 = Repaired (DBCC repaired the page) +-- 7 = Deallocated by DBCC + +-- Ideally, this query returns no results. The table is limited to 1000 rows. +-- If you do get results here, you should do further investigation to determine the root cause + +-- Manage the suspect_pages Table +-- https://bit.ly/2Fvr1c9 + + +-- Get number of data files in tempdb database (Query 23) (TempDB Data Files) +EXEC sys.xp_readerrorlog 0, 1, N'The tempdb database has'; +------ + +-- Get the number of data files in the tempdb database +-- 4-8 data files that are all the same size is a good starting point +-- This query will return no results if your error log has been recycled since the instance was last started + + +-- File names and paths for all user and system databases on instance (Query 24) (Database Filenames and Paths) +SELECT DB_NAME([database_id]) AS [Database Name], + [file_id], [name], physical_name, [type_desc], state_desc, + is_percent_growth, growth, + CONVERT(bigint, growth/128.0) AS [Growth in MB], + CONVERT(bigint, size/128.0) AS [Total Size in MB], max_size +FROM sys.master_files WITH (NOLOCK) +ORDER BY DB_NAME([database_id]), [file_id] OPTION (RECOMPILE); +------ + +-- Things to look at: +-- Are data files and log files on different drives? +-- Is everything on the C: drive? +-- Is tempdb on dedicated drives? +-- Is there only one tempdb data file? +-- Are all of the tempdb data files the same size? +-- Are there multiple data files for user databases? +-- Is percent growth enabled for any files (which is bad)? + + + +-- Volume info for all LUNS that have database files on the current instance (Query 25) (Volume Info) +SELECT DISTINCT vs.volume_mount_point, vs.file_system_type, vs.logical_volume_name, +CONVERT(DECIMAL(18,2), vs.total_bytes/1073741824.0) AS [Total Size (GB)], +CONVERT(DECIMAL(18,2), vs.available_bytes/1073741824.0) AS [Available Size (GB)], +CONVERT(DECIMAL(18,2), vs.available_bytes * 1. / vs.total_bytes * 100.) AS [Space Free %], +vs.supports_compression, vs.is_compressed, +vs.supports_sparse_files, vs.supports_alternate_streams +FROM sys.master_files AS f WITH (NOLOCK) +CROSS APPLY sys.dm_os_volume_stats(f.database_id, f.[file_id]) AS vs +ORDER BY vs.volume_mount_point OPTION (RECOMPILE); +------ + +-- Shows you the total and free space on the LUNs where you have database files +-- Being low on free space can negatively affect performance + +-- sys.dm_os_volume_stats (Transact-SQL) +-- https://bit.ly/2oBPNNr + + + +-- Drive level latency information (Query 26) (Drive Level Latency) +SELECT tab.[Drive], tab.volume_mount_point AS [Volume Mount Point], + CASE + WHEN num_of_reads = 0 THEN 0 + ELSE (io_stall_read_ms/num_of_reads) + END AS [Read Latency], + CASE + WHEN num_of_writes = 0 THEN 0 + ELSE (io_stall_write_ms/num_of_writes) + END AS [Write Latency], + CASE + WHEN (num_of_reads = 0 AND num_of_writes = 0) THEN 0 + ELSE (io_stall/(num_of_reads + num_of_writes)) + END AS [Overall Latency], + CASE + WHEN num_of_reads = 0 THEN 0 + ELSE (num_of_bytes_read/num_of_reads) + END AS [Avg Bytes/Read], + CASE + WHEN num_of_writes = 0 THEN 0 + ELSE (num_of_bytes_written/num_of_writes) + END AS [Avg Bytes/Write], + CASE + WHEN (num_of_reads = 0 AND num_of_writes = 0) THEN 0 + ELSE ((num_of_bytes_read + num_of_bytes_written)/(num_of_reads + num_of_writes)) + END AS [Avg Bytes/Transfer] +FROM (SELECT LEFT(UPPER(mf.physical_name), 2) AS Drive, SUM(num_of_reads) AS num_of_reads, + SUM(io_stall_read_ms) AS io_stall_read_ms, SUM(num_of_writes) AS num_of_writes, + SUM(io_stall_write_ms) AS io_stall_write_ms, SUM(num_of_bytes_read) AS num_of_bytes_read, + SUM(num_of_bytes_written) AS num_of_bytes_written, SUM(io_stall) AS io_stall, vs.volume_mount_point + FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS vfs + INNER JOIN sys.master_files AS mf WITH (NOLOCK) + ON vfs.database_id = mf.database_id AND vfs.file_id = mf.file_id + CROSS APPLY sys.dm_os_volume_stats(mf.database_id, mf.[file_id]) AS vs + GROUP BY LEFT(UPPER(mf.physical_name), 2), vs.volume_mount_point) AS tab +ORDER BY [Overall Latency] OPTION (RECOMPILE); +------ + +-- Shows you the drive-level latency for reads and writes, in milliseconds +-- Latency above 30-40ms is usually a problem +-- These latency numbers include all file activity against all SQL Server +-- database files on each drive since SQL Server was last started + +-- sys.dm_io_virtual_file_stats (Transact-SQL) +-- https://bit.ly/3bRWUc0 + +-- sys.dm_os_volume_stats (Transact-SQL) +-- https://bit.ly/33thz2j + + +-- Calculates average stalls per read, per write, and per total input/output for each database file (Query 27) (IO Latency by File) +SELECT DB_NAME(fs.database_id) AS [Database Name], CAST(fs.io_stall_read_ms/(1.0 + fs.num_of_reads) AS NUMERIC(10,1)) AS [avg_read_latency_ms], +CAST(fs.io_stall_write_ms/(1.0 + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_write_latency_ms], +CAST((fs.io_stall_read_ms + fs.io_stall_write_ms)/(1.0 + fs.num_of_reads + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_io_latency_ms], +CONVERT(DECIMAL(18,2), mf.size/128.0) AS [File Size (MB)], mf.physical_name, mf.type_desc, fs.io_stall_read_ms, fs.num_of_reads, +fs.io_stall_write_ms, fs.num_of_writes, fs.io_stall_read_ms + fs.io_stall_write_ms AS [io_stalls], fs.num_of_reads + fs.num_of_writes AS [total_io], +io_stall_queued_read_ms AS [Resource Governor Total Read IO Latency (ms)], io_stall_queued_write_ms AS [Resource Governor Total Write IO Latency (ms)] +FROM sys.dm_io_virtual_file_stats(null,null) AS fs +INNER JOIN sys.master_files AS mf WITH (NOLOCK) +ON fs.database_id = mf.database_id +AND fs.[file_id] = mf.[file_id] +ORDER BY avg_io_latency_ms DESC OPTION (RECOMPILE); +------ + +-- Helps determine which database files on the entire instance have the most I/O bottlenecks +-- This can help you decide whether certain LUNs are overloaded and whether you might +-- want to move some files to a different location or perhaps improve your I/O performance +-- These latency numbers include all file activity against each SQL Server +-- database file since SQL Server was last started + +-- sys.dm_io_virtual_file_stats (Transact-SQL) +-- https://bit.ly/3bRWUc0 + + +-- Look for I/O requests taking longer than 15 seconds in the six most recent SQL Server Error Logs (Query 28) (IO Warnings) +CREATE TABLE #IOWarningResults(LogDate datetime, ProcessInfo sysname, LogText nvarchar(1000)); + + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 0, 1, N'taking longer than 15 seconds'; + + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 1, 1, N'taking longer than 15 seconds'; + + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 2, 1, N'taking longer than 15 seconds'; + + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 3, 1, N'taking longer than 15 seconds'; + + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 4, 1, N'taking longer than 15 seconds'; + + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 5, 1, N'taking longer than 15 seconds'; + +SELECT LogDate, ProcessInfo, LogText +FROM #IOWarningResults +ORDER BY LogDate DESC; + +DROP TABLE #IOWarningResults; +------ + +-- Finding 15 second I/O warnings in the SQL Server Error Log is useful evidence of +-- poor I/O performance (which might have many different causes) +-- Look to see if you see any patterns in the results (same files, same drives, same time of day, etc.) + +-- Diagnostics in SQL Server help detect stalled and stuck I/O operations +-- https://bit.ly/2qtaw73 + + +-- Resource Governor Resource Pool information (Query 29) (RG Resource Pools) +SELECT pool_id, [Name], statistics_start_time, + min_memory_percent, max_memory_percent, + max_memory_kb/1024 AS [max_memory_mb], + used_memory_kb/1024 AS [used_memory_mb], + target_memory_kb/1024 AS [target_memory_mb], + min_iops_per_volume, max_iops_per_volume +FROM sys.dm_resource_governor_resource_pools WITH (NOLOCK) +OPTION (RECOMPILE); +------ + +-- sys.dm_resource_governor_resource_pools (Transact-SQL) +-- https://bit.ly/2MVU0Vy + + + +-- Recovery model, log reuse wait description, log file size, log usage size (Query 30) (Database Properties) +-- and compatibility level for all databases on instance +SELECT db.[name] AS [Database Name], SUSER_SNAME(db.owner_sid) AS [Database Owner], db.recovery_model_desc AS [Recovery Model], +db.state_desc, db.containment_desc, db.log_reuse_wait_desc AS [Log Reuse Wait Description], +CONVERT(DECIMAL(18,2), ls.cntr_value/1024.0) AS [Log Size (MB)], CONVERT(DECIMAL(18,2), lu.cntr_value/1024.0) AS [Log Used (MB)], +CAST(CAST(lu.cntr_value AS FLOAT) / CAST(ls.cntr_value AS FLOAT)AS DECIMAL(18,2)) * 100 AS [Log Used %], +db.[compatibility_level] AS [DB Compatibility Level], +db.is_mixed_page_allocation_on, db.page_verify_option_desc AS [Page Verify Option], +db.is_auto_create_stats_on, db.is_auto_update_stats_on, db.is_auto_update_stats_async_on, db.is_parameterization_forced, +db.snapshot_isolation_state_desc, db.is_read_committed_snapshot_on, db.is_auto_close_on, db.is_auto_shrink_on, +db.target_recovery_time_in_seconds, db.is_cdc_enabled, db.is_published, db.is_distributor, +db.group_database_id, db.replica_id,db.is_memory_optimized_elevate_to_snapshot_on, +db.delayed_durability_desc, db.is_query_store_on, db.is_sync_with_backup, db.is_remote_data_archive_enabled, +db.is_encrypted, de.encryption_state, de.percent_complete, de.key_algorithm, de.key_length +FROM sys.databases AS db WITH (NOLOCK) +INNER JOIN sys.dm_os_performance_counters AS lu WITH (NOLOCK) +ON db.name = lu.instance_name +INNER JOIN sys.dm_os_performance_counters AS ls WITH (NOLOCK) +ON db.name = ls.instance_name +LEFT OUTER JOIN sys.dm_database_encryption_keys AS de WITH (NOLOCK) +ON db.database_id = de.database_id +WHERE lu.counter_name LIKE N'Log File(s) Used Size (KB)%' +AND ls.counter_name LIKE N'Log File(s) Size (KB)%' +AND ls.cntr_value > 0 +ORDER BY db.[name] OPTION (RECOMPILE); +------ + +-- sys.databases (Transact-SQL) +-- https://bit.ly/2G5wqaX + +-- sys.dm_os_performance_counters (Transact-SQL) +-- https://bit.ly/3kEO2JR + +-- sys.dm_database_encryption_keys (Transact-SQL) +-- https://bit.ly/3mE7kkx + +-- Things to look at: +-- How many databases are on the instance? +-- What recovery models are they using? +-- What is the log reuse wait description? +-- How full are the transaction logs? +-- What compatibility level are the databases on? +-- What is the Page Verify Option? (should be CHECKSUM) +-- Is Auto Update Statistics Asynchronously enabled? +-- Is Delayed Durability enabled +-- Make sure auto_shrink and auto_close are not enabled! + +-- is_mixed_page_allocation_on is a new property for SQL Server 2016. Equivalent to TF 1118 for a user database +-- SQL Server 2016: Changes in default behavior for autogrow and allocations for tempdb and user databases +-- https://bit.ly/2evRZSR + +-- A non-zero value for target_recovery_time_in_seconds means that indirect checkpoint is enabled +-- If the setting has a zero value it indicates that automatic checkpoint is enabled + +-- Changes in SQL Server 2016 Checkpoint Behavior +-- https://bit.ly/2pdggk3 + + +-- Missing Indexes for all databases by Index Advantage (Query 31) (Missing Indexes All Databases) +SELECT CONVERT(decimal(18,2), migs.user_seeks * migs.avg_total_user_cost * (migs.avg_user_impact * 0.01)) AS [index_advantage], +FORMAT(migs.last_user_seek, 'yyyy-MM-dd HH:mm:ss') AS [last_user_seek], mid.[statement] AS [Database.Schema.Table], +COUNT(1) OVER(PARTITION BY mid.[statement]) AS [missing_indexes_for_table], +COUNT(1) OVER(PARTITION BY mid.[statement], equality_columns) AS [similar_missing_indexes_for_table], +mid.equality_columns, mid.inequality_columns, mid.included_columns, migs.user_seeks, +CONVERT(decimal(18,2), migs.avg_total_user_cost) AS [avg_total_user_cost], migs.avg_user_impact +FROM sys.dm_db_missing_index_group_stats AS migs WITH (NOLOCK) +INNER JOIN sys.dm_db_missing_index_groups AS mig WITH (NOLOCK) +ON migs.group_handle = mig.index_group_handle +INNER JOIN sys.dm_db_missing_index_details AS mid WITH (NOLOCK) +ON mig.index_handle = mid.index_handle +ORDER BY index_advantage DESC OPTION (RECOMPILE); +------ + +-- Getting missing index information for all of the databases on the instance is very useful +-- Look at last user seek time, number of user seeks to help determine source and importance +-- Also look at avg_user_impact and avg_total_user_cost to help determine importance +-- SQL Server is overly eager to add included columns, so beware +-- Do not just blindly add indexes that show up from this query!!! +-- Hkan Winther has given me some great suggestions for this query + +-- SQL Server Index Design Guide +-- https://bit.ly/2qtZr4N + + + +-- Get VLF Counts for all databases on the instance (Query 32) (VLF Counts) +SELECT [name] AS [Database Name], [VLF Count] +FROM sys.databases AS db WITH (NOLOCK) +CROSS APPLY (SELECT file_id, COUNT(*) AS [VLF Count] + FROM sys.dm_db_log_info(db.database_id) + GROUP BY file_id) AS li +ORDER BY [VLF Count] DESC OPTION (RECOMPILE); +------ + +-- High VLF counts can affect write performance to the log file +-- and they can make full database restores and crash recovery take much longer +-- Try to keep your VLF counts under 200 in most cases (depending on log file size) + +-- Important change to VLF creation algorithm in SQL Server 2014 +-- https://bit.ly/2Hsjbg4 + +-- SQL Server Transaction Log Architecture and Management Guide +-- https://bit.ly/2JjmQRZ + + + +-- Get CPU utilization by database (Query 33) (CPU Usage by Database) +WITH DB_CPU_Stats +AS +(SELECT pa.DatabaseID, DB_Name(pa.DatabaseID) AS [Database Name], SUM(qs.total_worker_time/1000) AS [CPU_Time_Ms] + FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) + CROSS APPLY (SELECT CONVERT(int, value) AS [DatabaseID] + FROM sys.dm_exec_plan_attributes(qs.plan_handle) + WHERE attribute = N'dbid') AS pa + GROUP BY DatabaseID) +SELECT ROW_NUMBER() OVER(ORDER BY [CPU_Time_Ms] DESC) AS [CPU Rank], + [Database Name], [CPU_Time_Ms] AS [CPU Time (ms)], + CAST([CPU_Time_Ms] * 1.0 / SUM([CPU_Time_Ms]) OVER() * 100.0 AS DECIMAL(5, 2)) AS [CPU Percent] +FROM DB_CPU_Stats +WHERE DatabaseID <> 32767 -- ResourceDB +ORDER BY [CPU Rank] OPTION (RECOMPILE); +------ + +-- Helps determine which database is using the most CPU resources on the instance +-- Note: This only reflects CPU usage from the currently cached query plans + + +-- Get I/O utilization by database (Query 34) (IO Usage By Database) +WITH Aggregate_IO_Statistics +AS (SELECT DB_NAME(database_id) AS [Database Name], + CAST(SUM(num_of_bytes_read + num_of_bytes_written) / 1048576 AS DECIMAL(12, 2)) AS [ioTotalMB], + CAST(SUM(num_of_bytes_read ) / 1048576 AS DECIMAL(12, 2)) AS [ioReadMB], + CAST(SUM(num_of_bytes_written) / 1048576 AS DECIMAL(12, 2)) AS [ioWriteMB] + FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS [DM_IO_STATS] + GROUP BY database_id) +SELECT ROW_NUMBER() OVER (ORDER BY ioTotalMB DESC) AS [I/O Rank], + [Database Name], ioTotalMB AS [Total I/O (MB)], + CAST(ioTotalMB / SUM(ioTotalMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Total I/O %], + ioReadMB AS [Read I/O (MB)], + CAST(ioReadMB / SUM(ioReadMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Read I/O %], + ioWriteMB AS [Write I/O (MB)], + CAST(ioWriteMB / SUM(ioWriteMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Write I/O %] +FROM Aggregate_IO_Statistics +ORDER BY [I/O Rank] OPTION (RECOMPILE); +------ + +-- Helps determine which database is using the most I/O resources on the instance +-- These numbers are cumulative since the last service restart +-- They include all I/O activity, not just the nominal I/O workload + + +-- Get total buffer usage by database for current instance (Query 35) (Total Buffer Usage by Database) +-- This make take some time to run on a busy instance +WITH AggregateBufferPoolUsage +AS +(SELECT DB_NAME(database_id) AS [Database Name], +CAST(COUNT(*) * 8/1024.0 AS DECIMAL (10,2)) AS [CachedSize] +FROM sys.dm_os_buffer_descriptors WITH (NOLOCK) +WHERE database_id <> 32767 -- ResourceDB +GROUP BY DB_NAME(database_id)) +SELECT ROW_NUMBER() OVER(ORDER BY CachedSize DESC) AS [Buffer Pool Rank], [Database Name], CachedSize AS [Cached Size (MB)], + CAST(CachedSize / SUM(CachedSize) OVER() * 100.0 AS DECIMAL(5,2)) AS [Buffer Pool Percent] +FROM AggregateBufferPoolUsage +ORDER BY [Buffer Pool Rank] OPTION (RECOMPILE); +------ + +-- Tells you how much memory (in the buffer pool) +-- is being used by each database on the instance + + +-- Get tempdb version store space usage by database (Query 36) (Version Store Space Usage) +SELECT DB_NAME(database_id) AS [Database Name], + reserved_page_count AS [Version Store Reserved Page Count], + reserved_space_kb/1024 AS [Version Store Reserved Space (MB)] +FROM sys.dm_tran_version_store_space_usage WITH (NOLOCK) +ORDER BY reserved_space_kb/1024 DESC OPTION (RECOMPILE); +------ + +-- sys.dm_tran_version_store_space_usage (Transact-SQL) +-- https://bit.ly/2vh3Bmk + + + + +-- Clear Wait Stats with this command +-- DBCC SQLPERF('sys.dm_os_wait_stats', CLEAR); + +-- Isolate top waits for server instance since last restart or wait statistics clear (Query 37) (Top Waits) +WITH [Waits] +AS (SELECT wait_type, wait_time_ms/ 1000.0 AS [WaitS], + (wait_time_ms - signal_wait_time_ms) / 1000.0 AS [ResourceS], + signal_wait_time_ms / 1000.0 AS [SignalS], + waiting_tasks_count AS [WaitCount], + 100.0 * wait_time_ms / SUM (wait_time_ms) OVER() AS [Percentage], + ROW_NUMBER() OVER(ORDER BY wait_time_ms DESC) AS [RowNum] + FROM sys.dm_os_wait_stats WITH (NOLOCK) + WHERE [wait_type] NOT IN ( + N'BROKER_EVENTHANDLER', N'BROKER_RECEIVE_WAITFOR', N'BROKER_TASK_STOP', + N'BROKER_TO_FLUSH', N'BROKER_TRANSMITTER', N'CHECKPOINT_QUEUE', + N'CHKPT', N'CLR_AUTO_EVENT', N'CLR_MANUAL_EVENT', N'CLR_SEMAPHORE', N'CXCONSUMER', + N'DBMIRROR_DBM_EVENT', N'DBMIRROR_EVENTS_QUEUE', N'DBMIRROR_WORKER_QUEUE', + N'DBMIRRORING_CMD', N'DIRTY_PAGE_POLL', N'DISPATCHER_QUEUE_SEMAPHORE', + N'EXECSYNC', N'FSAGENT', N'FT_IFTS_SCHEDULER_IDLE_WAIT', N'FT_IFTSHC_MUTEX', + N'HADR_CLUSAPI_CALL', N'HADR_FILESTREAM_IOMGR_IOCOMPLETION', N'HADR_LOGCAPTURE_WAIT', + N'HADR_NOTIFICATION_DEQUEUE', N'HADR_TIMER_TASK', N'HADR_WORK_QUEUE', + N'KSOURCE_WAKEUP', N'LAZYWRITER_SLEEP', N'LOGMGR_QUEUE', + N'MEMORY_ALLOCATION_EXT', N'ONDEMAND_TASK_QUEUE', + N'PARALLEL_REDO_DRAIN_WORKER', N'PARALLEL_REDO_LOG_CACHE', N'PARALLEL_REDO_TRAN_LIST', + N'PARALLEL_REDO_WORKER_SYNC', N'PARALLEL_REDO_WORKER_WAIT_WORK', + N'PREEMPTIVE_HADR_LEASE_MECHANISM', N'PREEMPTIVE_SP_SERVER_DIAGNOSTICS', + N'PREEMPTIVE_OS_LIBRARYOPS', N'PREEMPTIVE_OS_COMOPS', N'PREEMPTIVE_OS_CRYPTOPS', + N'PREEMPTIVE_OS_PIPEOPS', N'PREEMPTIVE_OS_AUTHENTICATIONOPS', + N'PREEMPTIVE_OS_GENERICOPS', N'PREEMPTIVE_OS_VERIFYTRUST', + N'PREEMPTIVE_OS_FILEOPS', N'PREEMPTIVE_OS_DEVICEOPS', N'PREEMPTIVE_OS_QUERYREGISTRY', + N'PREEMPTIVE_OS_WRITEFILE', + N'PREEMPTIVE_XE_CALLBACKEXECUTE', N'PREEMPTIVE_XE_DISPATCHER', + N'PREEMPTIVE_XE_GETTARGETSTATE', N'PREEMPTIVE_XE_SESSIONCOMMIT', + N'PREEMPTIVE_XE_TARGETINIT', N'PREEMPTIVE_XE_TARGETFINALIZE', + N'PWAIT_ALL_COMPONENTS_INITIALIZED', N'PWAIT_DIRECTLOGCONSUMER_GETNEXT', + N'QDS_PERSIST_TASK_MAIN_LOOP_SLEEP', + N'QDS_ASYNC_QUEUE', + N'QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEP', N'REQUEST_FOR_DEADLOCK_SEARCH', + N'RESOURCE_QUEUE', N'SERVER_IDLE_CHECK', N'SLEEP_BPOOL_FLUSH', N'SLEEP_DBSTARTUP', + N'SLEEP_DCOMSTARTUP', N'SLEEP_MASTERDBREADY', N'SLEEP_MASTERMDREADY', + N'SLEEP_MASTERUPGRADED', N'SLEEP_MSDBSTARTUP', N'SLEEP_SYSTEMTASK', N'SLEEP_TASK', + N'SLEEP_TEMPDBSTARTUP', N'SNI_HTTP_ACCEPT', N'SP_SERVER_DIAGNOSTICS_SLEEP', + N'SQLTRACE_BUFFER_FLUSH', N'SQLTRACE_INCREMENTAL_FLUSH_SLEEP', N'SQLTRACE_WAIT_ENTRIES', + N'WAIT_FOR_RESULTS', N'WAITFOR', N'WAITFOR_TASKSHUTDOWN', N'WAIT_XTP_HOST_WAIT', + N'WAIT_XTP_OFFLINE_CKPT_NEW_LOG', N'WAIT_XTP_CKPT_CLOSE', N'WAIT_XTP_RECOVERY', + N'XE_BUFFERMGR_ALLPROCESSED_EVENT', N'XE_DISPATCHER_JOIN', + N'XE_DISPATCHER_WAIT', N'XE_LIVE_TARGET_TVF', N'XE_TIMER_EVENT') + AND waiting_tasks_count > 0) +SELECT + MAX (W1.wait_type) AS [WaitType], + CAST (MAX (W1.Percentage) AS DECIMAL (5,2)) AS [Wait Percentage], + CAST ((MAX (W1.WaitS) / MAX (W1.WaitCount)) AS DECIMAL (16,4)) AS [AvgWait_Sec], + CAST ((MAX (W1.ResourceS) / MAX (W1.WaitCount)) AS DECIMAL (16,4)) AS [AvgRes_Sec], + CAST ((MAX (W1.SignalS) / MAX (W1.WaitCount)) AS DECIMAL (16,4)) AS [AvgSig_Sec], + CAST (MAX (W1.WaitS) AS DECIMAL (16,2)) AS [Wait_Sec], + CAST (MAX (W1.ResourceS) AS DECIMAL (16,2)) AS [Resource_Sec], + CAST (MAX (W1.SignalS) AS DECIMAL (16,2)) AS [Signal_Sec], + MAX (W1.WaitCount) AS [Wait Count], + CAST (N'https://www.sqlskills.com/help/waits/' + W1.wait_type AS XML) AS [Help/Info URL] +FROM Waits AS W1 +INNER JOIN Waits AS W2 +ON W2.RowNum <= W1.RowNum +GROUP BY W1.RowNum, W1.wait_type +HAVING SUM (W2.Percentage) - MAX (W1.Percentage) < 99 -- percentage threshold +OPTION (RECOMPILE); +------ + +-- Cumulative wait stats are not as useful on an idle instance that is not under load or performance pressure + +-- SQL Server Wait Types Library +-- https://bit.ly/2ePzYO2 + +-- The SQL Server Wait Type Repository +-- https://bit.ly/1afzfjC + +-- Wait statistics, or please tell me where it hurts +-- https://bit.ly/2wsQHQE + +-- SQL Server 2005 Performance Tuning using the Waits and Queues +-- https://bit.ly/1o2NFoF + +-- sys.dm_os_wait_stats (Transact-SQL) +-- https://bit.ly/2Hjq9Yl + + + +-- Get a count of SQL connections by IP address (Query 38) (Connection Counts by IP Address) +SELECT ec.client_net_address, es.[program_name], es.[host_name], es.login_name, +COUNT(ec.session_id) AS [connection count] +FROM sys.dm_exec_sessions AS es WITH (NOLOCK) +INNER JOIN sys.dm_exec_connections AS ec WITH (NOLOCK) +ON es.session_id = ec.session_id +GROUP BY ec.client_net_address, es.[program_name], es.[host_name], es.login_name +ORDER BY ec.client_net_address, es.[program_name] OPTION (RECOMPILE); +------ + +-- This helps you figure where your database load is coming from +-- and verifies connectivity from other machines + +-- Solving Connectivity errors to SQL Server +-- https://bit.ly/2EgzoD0 + + + +-- Get Average Task Counts (run multiple times) (Query 39) (Avg Task Counts) +SELECT AVG(current_tasks_count) AS [Avg Task Count], +AVG(work_queue_count) AS [Avg Work Queue Count], +AVG(runnable_tasks_count) AS [Avg Runnable Task Count], +AVG(pending_disk_io_count) AS [Avg Pending DiskIO Count] +FROM sys.dm_os_schedulers WITH (NOLOCK) +WHERE scheduler_id < 255 OPTION (RECOMPILE); +------ + +-- Sustained values above 10 suggest further investigation in that area +-- High Avg Task Counts are often caused by blocking/deadlocking or other resource contention + +-- Sustained values above 1 suggest further investigation in that area +-- High Avg Runnable Task Counts are a good sign of CPU pressure +-- High Avg Pending DiskIO Counts are a sign of disk pressure + +-- How to Do Some Very Basic SQL Server Monitoring +-- https://bit.ly/30IRla0 + + + +-- Detect blocking (run multiple times) (Query 40) (Detect Blocking) +SELECT t1.resource_type AS [lock type], DB_NAME(resource_database_id) AS [database], +t1.resource_associated_entity_id AS [blk object],t1.request_mode AS [lock req], -- lock requested +t1.request_session_id AS [waiter sid], t2.wait_duration_ms AS [wait time], -- spid of waiter +(SELECT [text] FROM sys.dm_exec_requests AS r WITH (NOLOCK) -- get sql for waiter +CROSS APPLY sys.dm_exec_sql_text(r.[sql_handle]) +WHERE r.session_id = t1.request_session_id) AS [waiter_batch], +(SELECT SUBSTRING(qt.[text],r.statement_start_offset/2, + (CASE WHEN r.statement_end_offset = -1 + THEN LEN(CONVERT(nvarchar(max), qt.[text])) * 2 + ELSE r.statement_end_offset END - r.statement_start_offset)/2) +FROM sys.dm_exec_requests AS r WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(r.[sql_handle]) AS qt +WHERE r.session_id = t1.request_session_id) AS [waiter_stmt], -- statement blocked +t2.blocking_session_id AS [blocker sid], -- spid of blocker +(SELECT [text] FROM sys.sysprocesses AS p -- get sql for blocker +CROSS APPLY sys.dm_exec_sql_text(p.[sql_handle]) +WHERE p.spid = t2.blocking_session_id) AS [blocker_batch] +FROM sys.dm_tran_locks AS t1 WITH (NOLOCK) +INNER JOIN sys.dm_os_waiting_tasks AS t2 WITH (NOLOCK) +ON t1.lock_owner_address = t2.resource_address OPTION (RECOMPILE); +------ + +-- Helps troubleshoot blocking and deadlocking issues +-- The results will change from second to second on a busy system +-- You should run this query multiple times when you see signs of blocking + + + +-- Get CPU Utilization History for last 256 minutes (in one minute intervals) (Query 41) (CPU Utilization History) +DECLARE @ts_now bigint = (SELECT cpu_ticks/(cpu_ticks/ms_ticks) FROM sys.dm_os_sys_info WITH (NOLOCK)); + +SELECT TOP(256) SQLProcessUtilization AS [SQL Server Process CPU Utilization], + SystemIdle AS [System Idle Process], + 100 - SystemIdle - SQLProcessUtilization AS [Other Process CPU Utilization], + DATEADD(ms, -1 * (@ts_now - [timestamp]), GETDATE()) AS [Event Time] +FROM (SELECT record.value('(./Record/@id)[1]', 'int') AS record_id, + record.value('(./Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int') + AS [SystemIdle], + record.value('(./Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]', 'int') + AS [SQLProcessUtilization], [timestamp] + FROM (SELECT [timestamp], CONVERT(xml, record) AS [record] + FROM sys.dm_os_ring_buffers WITH (NOLOCK) + WHERE ring_buffer_type = N'RING_BUFFER_SCHEDULER_MONITOR' + AND record LIKE N'%%') AS x) AS y +ORDER BY record_id DESC OPTION (RECOMPILE); +------ + +-- Look at the trend over the entire period +-- Also look at high sustained 'Other Process' CPU Utilization values +-- Note: This query sometimes gives inaccurate results (negative values) +-- on high core count (> 64 cores) systems + + +-- Get top total worker time queries for entire instance (Query 42) (Top Worker Time Queries) +SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], +REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], +qs.total_worker_time AS [Total Worker Time], qs.min_worker_time AS [Min Worker Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.max_worker_time AS [Max Worker Time], +qs.min_elapsed_time AS [Min Elapsed Time], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.max_elapsed_time AS [Max Elapsed Time], +qs.min_logical_reads AS [Min Logical Reads], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +qs.max_logical_reads AS [Max Logical Reads], +qs.execution_count AS [Execution Count], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] +--,t.[text] AS [Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel +FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t +CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp +ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); +------ + + +-- Helps you find the most expensive queries from a CPU perspective across the entire instance +-- Can also help track down parameter sniffing issues + + + +-- Page Life Expectancy (PLE) value for each NUMA node in current instance (Query 43) (PLE by NUMA Node) +SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], + instance_name, cntr_value AS [Page Life Expectancy] +FROM sys.dm_os_performance_counters WITH (NOLOCK) +WHERE [object_name] LIKE N'%Buffer Node%' -- Handles named instances +AND counter_name = N'Page life expectancy' OPTION (RECOMPILE); +------ + +-- PLE is a good measurement of internal memory pressure +-- Higher PLE is better. Watch the trend over time, not the absolute value +-- This will only return one row for non-NUMA systems + +-- Page Life Expectancy isnt what you think +-- https://bit.ly/2EgynLa + + +-- Memory Grants Pending value for current instance (Query 44) (Memory Grants Pending) +SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], cntr_value AS [Memory Grants Pending] +FROM sys.dm_os_performance_counters WITH (NOLOCK) +WHERE [object_name] LIKE N'%Memory Manager%' -- Handles named instances +AND counter_name = N'Memory Grants Pending' OPTION (RECOMPILE); +------ + +-- Run multiple times, and run periodically if you suspect you are under memory pressure +-- Memory Grants Pending above zero for a sustained period is a very strong indicator of internal memory pressure + + +-- Memory Clerk Usage for instance (Query 45) (Memory Clerk Usage) +-- Look for high value for CACHESTORE_SQLCP (Ad-hoc query plans) +SELECT TOP(10) mc.[type] AS [Memory Clerk Type], + CAST((SUM(mc.pages_kb)/1024.0) AS DECIMAL (15,2)) AS [Memory Usage (MB)] +FROM sys.dm_os_memory_clerks AS mc WITH (NOLOCK) +GROUP BY mc.[type] +ORDER BY SUM(mc.pages_kb) DESC OPTION (RECOMPILE); +------ + +-- MEMORYCLERK_SQLBUFFERPOOL was new for SQL Server 2012. It should be your highest consumer of memory + +-- CACHESTORE_SQLCP SQL Plans +-- These are cached SQL statements or batches that aren't in stored procedures, functions and triggers +-- Watch out for high values for CACHESTORE_SQLCP +-- Enabling 'optimize for ad hoc workloads' at the instance level can help reduce this +-- Running DBCC FREESYSTEMCACHE ('SQL Plans') periodically may be required to better control this + +-- CACHESTORE_OBJCP Object Plans +-- These are compiled plans for stored procedures, functions and triggers + +-- sys.dm_os_memory_clerks (Transact-SQL) +-- https://bit.ly/2H31xDR + + + +-- Find single-use, ad-hoc and prepared queries that are bloating the plan cache (Query 46) (Ad hoc Queries) +SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], t.[text] AS [Query Text], +cp.objtype AS [Object Type], cp.cacheobjtype AS [Cache Object Type], +cp.size_in_bytes/1024 AS [Plan Size in KB] +FROM sys.dm_exec_cached_plans AS cp WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t +WHERE cp.cacheobjtype = N'Compiled Plan' +AND cp.objtype IN (N'Adhoc', N'Prepared') +AND cp.usecounts = 1 +ORDER BY cp.size_in_bytes DESC, DB_NAME(t.[dbid]) OPTION (RECOMPILE); +------ + +-- Gives you the text, type and size of single-use ad-hoc and prepared queries that waste space in the plan cache +-- Enabling 'optimize for ad hoc workloads' for the instance can help (SQL Server 2008 and above only) +-- Running DBCC FREESYSTEMCACHE ('SQL Plans') periodically may be required to better control this +-- Enabling forced parameterization for the database can help, but test first! + +-- Plan cache, adhoc workloads and clearing the single-use plan cache bloat +-- https://bit.ly/2EfYOkl + + +-- Get top total logical reads queries for entire instance (Query 47) (Top Logical Reads Queries) +SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], +REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], +qs.total_logical_reads AS [Total Logical Reads], +qs.min_logical_reads AS [Min Logical Reads], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +qs.max_logical_reads AS [Max Logical Reads], +qs.min_worker_time AS [Min Worker Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.max_worker_time AS [Max Worker Time], +qs.min_elapsed_time AS [Min Elapsed Time], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.max_elapsed_time AS [Max Elapsed Time], +qs.execution_count AS [Execution Count], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] +--,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel +FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t +CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp +ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE); +------ + + +-- Helps you find the most expensive queries from a memory perspective across the entire instance +-- Can also help track down parameter sniffing issues + + +-- Get top average elapsed time queries for entire instance (Query 48) (Top Avg Elapsed Time Queries) +SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], +REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.min_elapsed_time, qs.max_elapsed_time, qs.last_elapsed_time, +qs.execution_count AS [Execution Count], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +qs.total_physical_reads/qs.execution_count AS [Avg Physical Reads], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] +--,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel +FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t +CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp +ORDER BY qs.total_elapsed_time/qs.execution_count DESC OPTION (RECOMPILE); +------ + +-- Helps you find the highest average elapsed time queries across the entire instance +-- Can also help track down parameter sniffing issues + + +-- Look at UDF execution statistics (Query 49) (UDF Stats by DB) +SELECT TOP (25) DB_NAME(database_id) AS [Database Name], + OBJECT_NAME(object_id, database_id) AS [Function Name], + total_worker_time, execution_count, total_elapsed_time, + total_elapsed_time/execution_count AS [avg_elapsed_time], + last_elapsed_time, last_execution_time, cached_time, [type_desc] +FROM sys.dm_exec_function_stats WITH (NOLOCK) +ORDER BY total_worker_time DESC OPTION (RECOMPILE); +------ + +-- sys.dm_exec_function_stats (Transact-SQL) +-- https://bit.ly/2q1Q6BM + +-- Showplan Enhancements for UDFs +-- https://bit.ly/2LVqiQ1 + +-- Database specific queries ***************************************************************** + +-- **** Please switch to a user database that you are interested in! ***** +--USE YourDatabaseName; -- make sure to change to an actual database on your instance, not the master system database +--GO + +-- Individual File Sizes and space available for current database (Query 50) (File Sizes and Space) +SELECT f.name AS [File Name] , f.physical_name AS [Physical Name], +CAST((f.size/128.0) AS DECIMAL(15,2)) AS [Total Size in MB], +CAST(f.size/128.0 - CAST(FILEPROPERTY(f.name, 'SpaceUsed') AS int)/128.0 AS DECIMAL(15,2)) +AS [Available Space In MB], +CAST((f.size/128.0) AS DECIMAL(15,2)) - +CAST(f.size/128.0 - CAST(FILEPROPERTY(f.name, 'SpaceUsed') AS int)/128.0 AS DECIMAL(15,2)) AS [Used Space in MB], +f.[file_id], fg.name AS [Filegroup Name], +f.is_percent_growth, f.growth, fg.is_default, fg.is_read_only, +fg.is_autogrow_all_files +FROM sys.database_files AS f WITH (NOLOCK) +LEFT OUTER JOIN sys.filegroups AS fg WITH (NOLOCK) +ON f.data_space_id = fg.data_space_id +ORDER BY f.[file_id] OPTION (RECOMPILE); +------ + +-- Look at how large and how full the files are and where they are located +-- Make sure the transaction log is not full!! + +-- is_autogrow_all_files is new for SQL Server 2016. Equivalent to TF 1117 for user databases + +-- SQL Server 2016: Changes in default behavior for autogrow and allocations for tempdb and user databases +-- https://bit.ly/2evRZSR + + +-- Log space usage for current database (Query 51) (Log Space Usage) +SELECT DB_NAME(lsu.database_id) AS [Database Name], db.recovery_model_desc AS [Recovery Model], + CAST(lsu.total_log_size_in_bytes/1048576.0 AS DECIMAL(10, 2)) AS [Total Log Space (MB)], + CAST(lsu.used_log_space_in_bytes/1048576.0 AS DECIMAL(10, 2)) AS [Used Log Space (MB)], + CAST(lsu.used_log_space_in_percent AS DECIMAL(10, 2)) AS [Used Log Space %], + CAST(lsu.log_space_in_bytes_since_last_backup/1048576.0 AS DECIMAL(10, 2)) AS [Used Log Space Since Last Backup (MB)], + db.log_reuse_wait_desc +FROM sys.dm_db_log_space_usage AS lsu WITH (NOLOCK) +INNER JOIN sys.databases AS db WITH (NOLOCK) +ON lsu.database_id = db.database_id +OPTION (RECOMPILE); +------ + +-- Look at log file size and usage, along with the log reuse wait description for the current database + +-- sys.dm_db_log_space_usage (Transact-SQL) +-- https://bit.ly/2H4MQw9 + + +-- Status of last VLF for current database (Query 52) (Last VLF Status) +SELECT TOP(1) DB_NAME(li.database_id) AS [Database Name], li.[file_id], + li.vlf_size_mb, li.vlf_sequence_number, li.vlf_active, li.vlf_status +FROM sys.dm_db_log_info(DB_ID()) AS li +ORDER BY vlf_sequence_number DESC OPTION (RECOMPILE); +------ + +-- Determine whether you will be able to shrink the transaction log file + +-- vlf_status Values +-- 0 is inactive +-- 1 is initialized but unused +-- 2 is active + +-- sys.dm_db_log_info (Transact-SQL) +-- https://bit.ly/2EQUU1v + + + +-- Get database scoped configuration values for current database (Query 53) (Database-scoped Configurations) +SELECT configuration_id, name, [value] AS [value_for_primary], value_for_secondary +FROM sys.database_scoped_configurations WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- This lets you see the value of these new properties for the current database + +-- Clear plan cache for current database +-- ALTER DATABASE SCOPED CONFIGURATION CLEAR PROCEDURE_CACHE; + +-- ALTER DATABASE SCOPED CONFIGURATION (Transact-SQL) +-- https://bit.ly/2sOH7nb + + +-- I/O Statistics by file for the current database (Query 54) (IO Stats By File) +SELECT DB_NAME(DB_ID()) AS [Database Name], df.name AS [Logical Name], vfs.[file_id], df.type_desc, +df.physical_name AS [Physical Name], CAST(vfs.size_on_disk_bytes/1048576.0 AS DECIMAL(16, 2)) AS [Size on Disk (MB)], +vfs.num_of_reads, vfs.num_of_writes, vfs.io_stall_read_ms, vfs.io_stall_write_ms, +CAST(100. * vfs.io_stall_read_ms/(vfs.io_stall_read_ms + vfs.io_stall_write_ms) AS DECIMAL(16,1)) AS [IO Stall Reads Pct], +CAST(100. * vfs.io_stall_write_ms/(vfs.io_stall_write_ms + vfs.io_stall_read_ms) AS DECIMAL(16,1)) AS [IO Stall Writes Pct], +(vfs.num_of_reads + vfs.num_of_writes) AS [Writes + Reads], +CAST(vfs.num_of_bytes_read/1048576.0 AS DECIMAL(16, 2)) AS [MB Read], +CAST(vfs.num_of_bytes_written/1048576.0 AS DECIMAL(16, 2)) AS [MB Written], +CAST(100. * vfs.num_of_reads/(vfs.num_of_reads + vfs.num_of_writes) AS DECIMAL(16,1)) AS [# Reads Pct], +CAST(100. * vfs.num_of_writes/(vfs.num_of_reads + vfs.num_of_writes) AS DECIMAL(16,1)) AS [# Write Pct], +CAST(100. * vfs.num_of_bytes_read/(vfs.num_of_bytes_read + vfs.num_of_bytes_written) AS DECIMAL(16,1)) AS [Read Bytes Pct], +CAST(100. * vfs.num_of_bytes_written/(vfs.num_of_bytes_read + vfs.num_of_bytes_written) AS DECIMAL(16,1)) AS [Written Bytes Pct] +FROM sys.dm_io_virtual_file_stats(DB_ID(), NULL) AS vfs +INNER JOIN sys.database_files AS df WITH (NOLOCK) +ON vfs.[file_id]= df.[file_id] OPTION (RECOMPILE); +------ + +-- This helps you characterize your workload better from an I/O perspective for this database +-- It helps you determine whether you has an OLTP or DW/DSS type of workload + + + +-- Get most frequently executed queries for this database (Query 55) (Query Execution Counts) +SELECT TOP(50) LEFT(t.[text], 50) AS [Short Query Text], qs.execution_count AS [Execution Count], +qs.total_logical_reads AS [Total Logical Reads], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +qs.total_worker_time AS [Total Worker Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.total_elapsed_time AS [Total Elapsed Time], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] +--,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel +FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t +CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp +WHERE t.dbid = DB_ID() +ORDER BY qs.execution_count DESC OPTION (RECOMPILE); +------ + + +-- Queries 56 through 62 are the "Bad Man List" for stored procedures + +-- Top Cached SPs By Execution Count (Query 56) (SP Execution Counts) +SELECT TOP(100) p.name AS [SP Name], qs.execution_count AS [Execution Count], +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +ORDER BY qs.execution_count DESC OPTION (RECOMPILE); +------ + +-- Tells you which cached stored procedures are called the most often +-- This helps you characterize and baseline your workload +-- It also helps you find possible caching opportunities + + +-- Top Cached SPs By Avg Elapsed Time (Query 57) (SP Avg Elapsed Time) +SELECT TOP(25) p.name AS [SP Name], qs.min_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +qs.max_elapsed_time, qs.last_elapsed_time, qs.total_elapsed_time, qs.execution_count, +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], +qs.total_worker_time AS [TotalWorkerTime], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +ORDER BY avg_elapsed_time DESC OPTION (RECOMPILE); +------ + +-- This helps you find high average elapsed time cached stored procedures that +-- may be easy to optimize with standard query tuning techniques + + + +-- Top Cached SPs By Total Worker time. Worker time relates to CPU cost (Query 58) (SP Worker Time) +SELECT TOP(25) p.name AS [SP Name], qs.total_worker_time AS [TotalWorkerTime], +qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], qs.execution_count, +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); +------ + +-- This helps you find the most expensive cached stored procedures from a CPU perspective +-- You should look at this if you see signs of CPU pressure + + +-- Top Cached SPs By Total Logical Reads. Logical reads relate to memory pressure (Query 59) (SP Logical Reads) +SELECT TOP(25) p.name AS [SP Name], qs.total_logical_reads AS [TotalLogicalReads], +qs.total_logical_reads/qs.execution_count AS [AvgLogicalReads],qs.execution_count, +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE); +------ + +-- This helps you find the most expensive cached stored procedures from a memory perspective +-- You should look at this if you see signs of memory pressure + + +-- Top Cached SPs By Total Physical Reads. Physical reads relate to disk read I/O pressure (Query 60) (SP Physical Reads) +SELECT TOP(25) p.name AS [SP Name],qs.total_physical_reads AS [TotalPhysicalReads], +qs.total_physical_reads/qs.execution_count AS [AvgPhysicalReads], qs.execution_count, +qs.total_logical_reads,qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND qs.total_physical_reads > 0 +ORDER BY qs.total_physical_reads DESC, qs.total_logical_reads DESC OPTION (RECOMPILE); +------ + +-- This helps you find the most expensive cached stored procedures from a read I/O perspective +-- You should look at this if you see signs of I/O pressure or of memory pressure + + + +-- Top Cached SPs By Total Logical Writes (Query 61) (SP Logical Writes) +-- Logical writes relate to both memory and disk I/O pressure +SELECT TOP(25) p.name AS [SP Name], qs.total_logical_writes AS [TotalLogicalWrites], +qs.total_logical_writes/qs.execution_count AS [AvgLogicalWrites], qs.execution_count, +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND qs.total_logical_writes > 0 +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +ORDER BY qs.total_logical_writes DESC OPTION (RECOMPILE); +------ + +-- This helps you find the most expensive cached stored procedures from a write I/O perspective +-- You should look at this if you see signs of I/O pressure or of memory pressure + + + +-- Cached SPs Missing Indexes by Execution Count (Query 62) (SP Missing Index) +SELECT TOP(25) p.name AS [SP Name], qs.execution_count AS [Execution Count], +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +AND CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' +ORDER BY qs.execution_count DESC OPTION (RECOMPILE); +------ + +-- This helps you find the most frequently executed cached stored procedures that have missing index warnings +-- This can often help you find index tuning candidates + + + +-- Lists the top statements by average input/output usage for the current database (Query 63) (Top IO Statements) +SELECT TOP(50) OBJECT_NAME(qt.objectid, dbid) AS [SP Name], +(qs.total_logical_reads + qs.total_logical_writes) /qs.execution_count AS [Avg IO], qs.execution_count AS [Execution Count], +SUBSTRING(qt.[text],qs.statement_start_offset/2, + (CASE + WHEN qs.statement_end_offset = -1 + THEN LEN(CONVERT(nvarchar(max), qt.[text])) * 2 + ELSE qs.statement_end_offset + END - qs.statement_start_offset)/2) AS [Query Text] +FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS qt +WHERE qt.[dbid] = DB_ID() +ORDER BY [Avg IO] DESC OPTION (RECOMPILE); +------ + +-- Helps you find the most expensive statements for I/O by SP + + + +-- Possible Bad NC Indexes (writes > reads) (Query 64) (Bad NC Indexes) +SELECT SCHEMA_NAME(o.[schema_id]) AS [Schema Name], +OBJECT_NAME(s.[object_id]) AS [Table Name], +i.name AS [Index Name], i.index_id, +i.is_disabled, i.is_hypothetical, i.has_filter, i.fill_factor, +s.user_updates AS [Total Writes], s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], +s.user_updates - (s.user_seeks + s.user_scans + s.user_lookups) AS [Difference] +FROM sys.dm_db_index_usage_stats AS s WITH (NOLOCK) +INNER JOIN sys.indexes AS i WITH (NOLOCK) +ON s.[object_id] = i.[object_id] +AND i.index_id = s.index_id +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON i.[object_id] = o.[object_id] +WHERE OBJECTPROPERTY(s.[object_id],'IsUserTable') = 1 +AND s.database_id = DB_ID() +AND s.user_updates > (s.user_seeks + s.user_scans + s.user_lookups) +AND i.index_id > 1 AND i.[type_desc] = N'NONCLUSTERED' +AND i.is_primary_key = 0 AND i.is_unique_constraint = 0 AND i.is_unique = 0 +ORDER BY [Difference] DESC, [Total Writes] DESC, [Total Reads] ASC OPTION (RECOMPILE); +------ + +-- Look for indexes with high numbers of writes and zero or very low numbers of reads +-- Consider your complete workload, and how long your instance has been running +-- Investigate further before dropping an index! + + +-- Missing Indexes for current database by Index Advantage (Query 65) (Missing Indexes) +SELECT DISTINCT CONVERT(decimal(18,2), migs.user_seeks * migs.avg_total_user_cost * (migs.avg_user_impact * 0.01)) AS [index_advantage], +migs.last_user_seek, mid.[statement] AS [Database.Schema.Table], +mid.equality_columns, mid.inequality_columns, mid.included_columns, +migs.user_seeks, migs.avg_total_user_cost, migs.avg_user_impact, +OBJECT_NAME(mid.[object_id]) AS [Table Name], p.rows AS [Table Rows] +FROM sys.dm_db_missing_index_group_stats AS migs WITH (NOLOCK) +INNER JOIN sys.dm_db_missing_index_groups AS mig WITH (NOLOCK) +ON migs.group_handle = mig.index_group_handle +INNER JOIN sys.dm_db_missing_index_details AS mid WITH (NOLOCK) +ON mig.index_handle = mid.index_handle +INNER JOIN sys.partitions AS p WITH (NOLOCK) +ON p.[object_id] = mid.[object_id] +WHERE mid.database_id = DB_ID() +AND p.index_id < 2 +ORDER BY index_advantage DESC OPTION (RECOMPILE); +------ + +-- Look at index advantage, last user seek time, number of user seeks to help determine source and importance +-- SQL Server is overly eager to add included columns, so beware +-- Do not just blindly add indexes that show up from this query!!! +-- Hkan Winther has given me some great suggestions for this query + + +-- Find missing index warnings for cached plans in the current database (Query 66) (Missing Index Warnings) +-- Note: This query could take some time on a busy instance +SELECT TOP(25) OBJECT_NAME(objectid) AS [ObjectName], + cp.objtype, cp.usecounts, cp.size_in_bytes, qp.query_plan +FROM sys.dm_exec_cached_plans AS cp WITH (NOLOCK) +CROSS APPLY sys.dm_exec_query_plan(cp.plan_handle) AS qp +WHERE CAST(query_plan AS NVARCHAR(MAX)) LIKE N'%MissingIndex%' +AND dbid = DB_ID() +ORDER BY cp.usecounts DESC OPTION (RECOMPILE); +------ + +-- Helps you connect missing indexes to specific stored procedures or queries +-- This can help you decide whether to add them or not + + +-- Breaks down buffers used by current database by object (table, index) in the buffer cache (Query 67) (Buffer Usage) +-- Note: This query could take some time on a busy instance +SELECT fg.name AS [Filegroup Name], SCHEMA_NAME(o.Schema_ID) AS [Schema Name], +OBJECT_NAME(p.[object_id]) AS [Object Name], p.index_id, +CAST(COUNT(*)/128.0 AS DECIMAL(10, 2)) AS [Buffer size(MB)], +COUNT(*) AS [BufferCount], p.[Rows] AS [Row Count], +p.data_compression_desc AS [Compression Type] +FROM sys.allocation_units AS a WITH (NOLOCK) +INNER JOIN sys.dm_os_buffer_descriptors AS b WITH (NOLOCK) +ON a.allocation_unit_id = b.allocation_unit_id +INNER JOIN sys.partitions AS p WITH (NOLOCK) +ON a.container_id = p.hobt_id +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON p.object_id = o.object_id +INNER JOIN sys.database_files AS f WITH (NOLOCK) +ON b.file_id = f.file_id +INNER JOIN sys.filegroups AS fg WITH (NOLOCK) +ON f.data_space_id = fg.data_space_id +WHERE b.database_id = CONVERT(int, DB_ID()) +AND p.[object_id] > 100 +AND OBJECT_NAME(p.[object_id]) NOT LIKE N'plan_%' +AND OBJECT_NAME(p.[object_id]) NOT LIKE N'sys%' +AND OBJECT_NAME(p.[object_id]) NOT LIKE N'xml_index_nodes%' +GROUP BY fg.name, o.Schema_ID, p.[object_id], p.index_id, + p.data_compression_desc, p.[Rows] +ORDER BY [BufferCount] DESC OPTION (RECOMPILE); +------ + +-- Tells you what tables and indexes are using the most memory in the buffer cache +-- It can help identify possible candidates for data compression + + +-- Get Table names, row counts, and compression status for clustered index or heap (Query 68) (Table Sizes) +SELECT SCHEMA_NAME(o.Schema_ID) AS [Schema Name], OBJECT_NAME(p.object_id) AS [ObjectName], +SUM(p.Rows) AS [RowCount], p.data_compression_desc AS [Compression Type] +FROM sys.partitions AS p WITH (NOLOCK) +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON p.object_id = o.object_id +WHERE index_id < 2 --ignore the partitions from the non-clustered index if any +AND OBJECT_NAME(p.object_id) NOT LIKE N'sys%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'spt_%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'queue_%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'filestream_tombstone%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'fulltext%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'ifts_comp_fragment%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'filetable_updates%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'xml_index_nodes%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'sqlagent_job%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'plan_persist%' +GROUP BY SCHEMA_NAME(o.Schema_ID), p.object_id, data_compression_desc +ORDER BY SUM(p.Rows) DESC OPTION (RECOMPILE); +------ + +-- Gives you an idea of table sizes, and possible data compression opportunities + + + +-- Get some key table properties (Query 69) (Table Properties) +SELECT OBJECT_NAME(t.[object_id]) AS [ObjectName], p.[rows] AS [Table Rows], p.index_id, + p.data_compression_desc AS [Index Data Compression], + t.create_date, t.lock_on_bulk_load, t.is_replicated, t.has_replication_filter, + t.is_tracked_by_cdc, t.lock_escalation_desc, t.is_filetable, + t.is_memory_optimized, t.durability_desc, + t.temporal_type_desc, t.is_remote_data_archive_enabled, t.is_external -- new for SQL Server 2016 +FROM sys.tables AS t WITH (NOLOCK) +INNER JOIN sys.partitions AS p WITH (NOLOCK) +ON t.[object_id] = p.[object_id] +WHERE OBJECT_NAME(t.[object_id]) NOT LIKE N'sys%' +ORDER BY OBJECT_NAME(t.[object_id]), p.index_id OPTION (RECOMPILE); +------ + +-- Gives you some good information about your tables +-- is_memory_optimized and durability_desc were new in SQL Server 2014 +-- temporal_type_desc, is_remote_data_archive_enabled, is_external were new in SQL Server 2016 + +-- sys.tables (Transact-SQL) +-- https://bit.ly/2Gk7998 + + + +-- When were Statistics last updated on all indexes? (Query 70) (Statistics Update) +SELECT SCHEMA_NAME(o.Schema_ID) + N'.' + o.[NAME] AS [Object Name], o.[type_desc] AS [Object Type], + i.[name] AS [Index Name], STATS_DATE(i.[object_id], i.index_id) AS [Statistics Date], + s.auto_created, s.no_recompute, s.user_created, s.is_incremental, s.is_temporary, + st.row_count, st.used_page_count +FROM sys.objects AS o WITH (NOLOCK) +INNER JOIN sys.indexes AS i WITH (NOLOCK) +ON o.[object_id] = i.[object_id] +INNER JOIN sys.stats AS s WITH (NOLOCK) +ON i.[object_id] = s.[object_id] +AND i.index_id = s.stats_id +INNER JOIN sys.dm_db_partition_stats AS st WITH (NOLOCK) +ON o.[object_id] = st.[object_id] +AND i.[index_id] = st.[index_id] +WHERE o.[type] IN ('U', 'V') +AND st.row_count > 0 +ORDER BY STATS_DATE(i.[object_id], i.index_id) DESC OPTION (RECOMPILE); +------ + +-- Helps discover possible problems with out-of-date statistics +-- Also gives you an idea which indexes are the most active + +-- sys.stats (Transact-SQL) +-- https://bit.ly/2GyAxrn + +-- UPDATEs to Statistics (Erin Stellato) +-- https://bit.ly/2vhrYQy + + + + +-- Look at most frequently modified indexes and statistics (Query 71) (Volatile Indexes) +SELECT o.[name] AS [Object Name], o.[object_id], o.[type_desc], s.[name] AS [Statistics Name], + s.stats_id, s.no_recompute, s.auto_created, s.is_incremental, s.is_temporary, + sp.modification_counter, sp.[rows], sp.rows_sampled, sp.last_updated +FROM sys.objects AS o WITH (NOLOCK) +INNER JOIN sys.stats AS s WITH (NOLOCK) +ON s.object_id = o.object_id +CROSS APPLY sys.dm_db_stats_properties(s.object_id, s.stats_id) AS sp +WHERE o.[type_desc] NOT IN (N'SYSTEM_TABLE', N'INTERNAL_TABLE') +AND sp.modification_counter > 0 +ORDER BY sp.modification_counter DESC, o.name OPTION (RECOMPILE); +------ + +-- This helps you understand your workload and make better decisions about +-- things like data compression and adding new indexes to a table + + + +-- Get fragmentation info for all indexes above a certain size in the current database (Query 72) (Index Fragmentation) +-- Note: This query could take some time on a very large database +SELECT DB_NAME(ps.database_id) AS [Database Name], SCHEMA_NAME(o.[schema_id]) AS [Schema Name], +OBJECT_NAME(ps.OBJECT_ID) AS [Object Name], i.[name] AS [Index Name], ps.index_id, +ps.index_type_desc, ps.avg_fragmentation_in_percent, +ps.fragment_count, ps.page_count, i.fill_factor, i.has_filter, +i.filter_definition, i.[allow_page_locks] +FROM sys.dm_db_index_physical_stats(DB_ID(),NULL, NULL, NULL , N'LIMITED') AS ps +INNER JOIN sys.indexes AS i WITH (NOLOCK) +ON ps.[object_id] = i.[object_id] +AND ps.index_id = i.index_id +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON i.[object_id] = o.[object_id] +WHERE ps.database_id = DB_ID() +AND ps.page_count > 2500 +ORDER BY ps.avg_fragmentation_in_percent DESC OPTION (RECOMPILE); +------ + +-- Helps determine whether you have framentation in your relational indexes +-- and how effective your index maintenance strategy is + + +--- Index Read/Write stats (all tables in current DB) ordered by Reads (Query 73) (Overall Index Usage - Reads) +SELECT SCHEMA_NAME(t.[schema_id]) AS [SchemaName], OBJECT_NAME(i.[object_id]) AS [ObjectName], + i.[name] AS [IndexName], i.index_id, + s.user_seeks, s.user_scans, s.user_lookups, + s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], + s.user_updates AS [Writes], + i.[type_desc] AS [Index Type], i.fill_factor AS [Fill Factor], i.has_filter, i.filter_definition, + s.last_user_scan, s.last_user_lookup, s.last_user_seek +FROM sys.indexes AS i WITH (NOLOCK) +LEFT OUTER JOIN sys.dm_db_index_usage_stats AS s WITH (NOLOCK) +ON i.[object_id] = s.[object_id] +AND i.index_id = s.index_id +AND s.database_id = DB_ID() +LEFT OUTER JOIN sys.tables AS t WITH (NOLOCK) +ON t.[object_id] = i.[object_id] +WHERE OBJECTPROPERTY(i.[object_id],'IsUserTable') = 1 +ORDER BY s.user_seeks + s.user_scans + s.user_lookups DESC OPTION (RECOMPILE); -- Order by reads +------ + +-- Show which indexes in the current database are most active for Reads + + +--- Index Read/Write stats (all tables in current DB) ordered by Writes (Query 74) (Overall Index Usage - Writes) +SELECT SCHEMA_NAME(t.[schema_id]) AS [SchemaName],OBJECT_NAME(i.[object_id]) AS [ObjectName], + i.[name] AS [IndexName], i.index_id, + s.user_updates AS [Writes], s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], + i.[type_desc] AS [Index Type], i.fill_factor AS [Fill Factor], i.has_filter, i.filter_definition, + s.last_system_update, s.last_user_update +FROM sys.indexes AS i WITH (NOLOCK) +LEFT OUTER JOIN sys.dm_db_index_usage_stats AS s WITH (NOLOCK) +ON i.[object_id] = s.[object_id] +AND i.index_id = s.index_id +AND s.database_id = DB_ID() +LEFT OUTER JOIN sys.tables AS t WITH (NOLOCK) +ON t.[object_id] = i.[object_id] +WHERE OBJECTPROPERTY(i.[object_id],'IsUserTable') = 1 +ORDER BY s.user_updates DESC OPTION (RECOMPILE); -- Order by writes +------ + +-- Show which indexes in the current database are most active for Writes + + +-- Get in-memory OLTP index usage (Query 75) (XTP Index Usage) +SELECT OBJECT_NAME(i.[object_id]) AS [Object Name], i.index_id, i.[name] AS [Index Name], + i.[type_desc], xis.scans_started, xis.scans_retries, + xis.rows_touched, xis.rows_returned +FROM sys.dm_db_xtp_index_stats AS xis WITH (NOLOCK) +INNER JOIN sys.indexes AS i WITH (NOLOCK) +ON i.[object_id] = xis.[object_id] +AND i.index_id = xis.index_id +ORDER BY OBJECT_NAME(i.[object_id]) OPTION (RECOMPILE); +------ + +-- This gives you some index usage statistics for in-memory OLTP +-- Returns no data if you are not using in-memory OLTP + +-- Guidelines for Using Indexes on Memory-Optimized Tables +-- https://bit.ly/2GCP8lF + + + +-- Look at Columnstore index physical statistics (Query 76) (Columnstore Index Physical Stat) +SELECT OBJECT_NAME(ps.object_id) AS [TableName], + i.[name] AS [IndexName], ps.index_id, ps.partition_number, + ps.delta_store_hobt_id, ps.state_desc, ps.total_rows, ps.size_in_bytes, + ps.trim_reason_desc, ps.generation, ps.transition_to_compressed_state_desc, + ps.has_vertipaq_optimization, ps.deleted_rows, + 100 * (ISNULL(ps.deleted_rows, 0))/ps.total_rows AS [Fragmentation] +FROM sys.dm_db_column_store_row_group_physical_stats AS ps WITH (NOLOCK) +INNER JOIN sys.indexes AS i WITH (NOLOCK) +ON ps.object_id = i.object_id +AND ps.index_id = i.index_id +ORDER BY ps.object_id, ps.partition_number, ps.row_group_id OPTION (RECOMPILE); +------ + +-- sys.dm_db_column_store_row_group_physical_stats (Transact-SQL) +-- https://bit.ly/2q276XQ + + + +-- Get lock waits for current database (Query 77) (Lock Waits) +SELECT o.name AS [table_name], i.name AS [index_name], ios.index_id, ios.partition_number, + SUM(ios.row_lock_wait_count) AS [total_row_lock_waits], + SUM(ios.row_lock_wait_in_ms) AS [total_row_lock_wait_in_ms], + SUM(ios.page_lock_wait_count) AS [total_page_lock_waits], + SUM(ios.page_lock_wait_in_ms) AS [total_page_lock_wait_in_ms], + SUM(ios.page_lock_wait_in_ms)+ SUM(row_lock_wait_in_ms) AS [total_lock_wait_in_ms] +FROM sys.dm_db_index_operational_stats(DB_ID(), NULL, NULL, NULL) AS ios +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON ios.[object_id] = o.[object_id] +INNER JOIN sys.indexes AS i WITH (NOLOCK) +ON ios.[object_id] = i.[object_id] +AND ios.index_id = i.index_id +WHERE o.[object_id] > 100 +GROUP BY o.name, i.name, ios.index_id, ios.partition_number +HAVING SUM(ios.page_lock_wait_in_ms)+ SUM(row_lock_wait_in_ms) > 0 +ORDER BY total_lock_wait_in_ms DESC OPTION (RECOMPILE); +------ + +-- This query is helpful for troubleshooting blocking and deadlocking issues + + + +-- Look at UDF execution statistics (Query 78) (UDF Statistics) +SELECT OBJECT_NAME(object_id) AS [Function Name], execution_count, + total_worker_time, total_logical_reads, total_physical_reads, total_elapsed_time, + total_elapsed_time/execution_count AS [avg_elapsed_time], + FORMAT(cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +FROM sys.dm_exec_function_stats WITH (NOLOCK) +WHERE database_id = DB_ID() +ORDER BY total_worker_time DESC OPTION (RECOMPILE); +------ + +-- New for SQL Server 2016 +-- Helps you investigate scalar UDF performance issues +-- Does not return information for table valued functions + +-- sys.dm_exec_function_stats (Transact-SQL) +-- https://bit.ly/2q1Q6BM + + +-- Get QueryStore Options for this database (Query 79) (QueryStore Options) +SELECT actual_state_desc, desired_state_desc, [interval_length_minutes], + current_storage_size_mb, [max_storage_size_mb], + query_capture_mode_desc, size_based_cleanup_mode_desc +FROM sys.database_query_store_options WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- New for SQL Server 2016 +-- Requires that Query Store is enabled for this database + +-- Make sure that the actual_state_desc is the same as desired_state_desc +-- Make sure that the current_storage_size_mb is less than the max_storage_size_mb + +-- Tuning Workload Performance with Query Store +-- https://bit.ly/1kHSl7w + + + +-- Get input buffer information for the current database (Query 80) (Input Buffer) +SELECT es.session_id, DB_NAME(es.database_id) AS [Database Name], + es.login_time, es.cpu_time, es.logical_reads, es.memory_usage, + es.[status], ib.event_info AS [Input Buffer] +FROM sys.dm_exec_sessions AS es WITH (NOLOCK) +CROSS APPLY sys.dm_exec_input_buffer(es.session_id, NULL) AS ib +WHERE es.database_id = DB_ID() +AND es.session_id > 50 +AND es.session_id <> @@SPID OPTION (RECOMPILE); +------ + +-- Gives you input buffer information from all non-system sessions for the current database +-- Replaces DBCC INPUTBUFFER + +-- New DMF for retrieving input buffer in SQL Server +-- https://bit.ly/2uHKMbz + +-- sys.dm_exec_input_buffer (Transact-SQL) +-- https://bit.ly/2J5Hf9q + + + +-- Look at recent Full backups for the current database (Query 81) (Recent Full Backups) +SELECT TOP (30) bs.machine_name, bs.server_name, bs.database_name AS [Database Name], bs.recovery_model, +CONVERT (BIGINT, bs.backup_size / 1048576 ) AS [Uncompressed Backup Size (MB)], +CONVERT (BIGINT, bs.compressed_backup_size / 1048576 ) AS [Compressed Backup Size (MB)], +CONVERT (NUMERIC (20,2), (CONVERT (FLOAT, bs.backup_size) / +CONVERT (FLOAT, bs.compressed_backup_size))) AS [Compression Ratio], bs.has_backup_checksums, bs.is_copy_only, bs.encryptor_type, +DATEDIFF (SECOND, bs.backup_start_date, bs.backup_finish_date) AS [Backup Elapsed Time (sec)], +bs.backup_finish_date AS [Backup Finish Date], bmf.physical_device_name AS [Backup Location], bmf.physical_block_size +FROM msdb.dbo.backupset AS bs WITH (NOLOCK) +INNER JOIN msdb.dbo.backupmediafamily AS bmf WITH (NOLOCK) +ON bs.media_set_id = bmf.media_set_id +WHERE bs.database_name = DB_NAME(DB_ID()) +AND bs.[type] = 'D' -- Change to L if you want Log backups +ORDER BY bs.backup_finish_date DESC OPTION (RECOMPILE); +------ + +-- Are your backup sizes and times changing over time? +-- Are you using backup compression? +-- Are you using backup checksums? +-- Are you doing copy_only backups? +-- Are you doing encrypted backups? +-- Have you done any backup tuning with striped backups, or changing the parameters of the backup command? + +-- In SQL Server 2016, native SQL Server backup compression actually works +-- much better with databases that are using TDE than in previous versions +-- https://bit.ly/28Rpb2x + + +-- Microsoft Visual Studio Dev Essentials +-- https://bit.ly/2qjNRxi + +-- Microsoft Azure Learn +-- https://bit.ly/2O0Hacc + + diff --git a/Scripts/SQL Server 2017 Diagnostic Information Queries.sql b/Scripts/SQL Server 2017 Diagnostic Information Queries.sql index 73a89e54..f86f3537 100644 --- a/Scripts/SQL Server 2017 Diagnostic Information Queries.sql +++ b/Scripts/SQL Server 2017 Diagnostic Information Queries.sql @@ -1,26 +1,30 @@ -- SQL Server 2017 Diagnostic Information Queries -- Glenn Berry --- Last Modified: December 7, 2017 --- https://www.sqlskills.com/blogs/glenn/ --- http://sqlserverperformance.wordpress.com/ +-- Last Modified: December 3, 2020 +-- https://glennsqlperformance.com/ +-- https://sqlserverperformance.wordpress.com/ +-- YouTube: https://bit.ly/2PkoAM1 -- Twitter: GlennAlanBerry --- Please listen to my Pluralsight courses --- https://www.pluralsight.com/author/glenn-berry - --- If you want to find all of our SQLskills SQL101 blog posts, check out https://www.sqlskills.com/help/sql101/ +-- Diagnostic Queries are available here +-- https://glennsqlperformance.com/resources/ -- Please make sure you are using the correct version of these diagnostic queries for your version of SQL Server +-- If you like PowerShell, there is a very useful community solution for running these queries in an automated fashion +-- https://dbatools.io/ + +-- Invoke-DbaDiagnosticQuery +-- https://dbatools.io/functions/invoke-dbadiagnosticquery/ + + --****************************************************************************** ---* Copyright (C) 2017 Glenn Berry, SQLskills.com +--* Copyright (C) 2020 Glenn Berry --* All rights reserved. --* ---* For more scripts and sample code, check out ---* https://www.sqlskills.com/blogs/glenn --* --* You may alter this code for your own *non-commercial* purposes. You may --* republish altered code as long as you include this copyright and give due credit. @@ -50,55 +54,78 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In ------ -- SQL Server 2017 Builds --- Build Description Release Date --- 14.0.1.246 CTP 1.0 11/30/2016 --- 14.0.100.187 CTP 1.1 12/16/2016 --- 14.0.200.24 CTP 1.2 1/19/2017 --- 14.0.304.138 CTP 1.3 2/17/2017 --- 14.0.405.198 CTP 1.4 3/20/2017 --- 14.0.500.272 CTP 2.0 4/19/2017 --- 14.0.600.250 CTP 2.1 5/17/2017 --- 14.0.800.90 RC1 7/17/2017 --- 14.0.900.75 RC2 8/2/2017 --- 14.0.1000.169 RTM 10/2/2017 --- 14.0.3006.16 CU1 10/24/2017 --- 14.0.3008.27 CU2 11/28/2017 - +-- Build Description Release Date URL to KB Article +-- 14.0.1.246 CTP 1.0 11/30/2016 +-- 14.0.100.187 CTP 1.1 12/16/2016 +-- 14.0.200.24 CTP 1.2 1/19/2017 +-- 14.0.304.138 CTP 1.3 2/17/2017 +-- 14.0.405.198 CTP 1.4 3/20/2017 +-- 14.0.500.272 CTP 2.0 4/19/2017 +-- 14.0.600.250 CTP 2.1 5/17/2017 +-- 14.0.800.90 RC1 7/17/2017 +-- 14.0.900.75 RC2 8/2/2017 +-- 14.0.1000.169 RTM 10/2/2017 +-- 14.0.3006.16 CU1 10/24/2017 https://support.microsoft.com/en-us/help/4038634 +-- 14.0.3008.27 CU2 11/28/2017 https://support.microsoft.com/en-us/help/4052574 +-- 14.0.3015.40 CU3 1/4/2018 https://support.microsoft.com/en-us/help/4052987 +-- 14.0.3022.28 CU4 2/20/2018 https://support.microsoft.com/en-us/help/4056498 +-- 14.0.3023.8 CU5 3/20/2018 https://support.microsoft.com/en-us/help/4092643 +-- 14.0.3025.34 CU6 4/17/2018 https://support.microsoft.com/en-us/help/4101464 +-- 14.0.3026.27 CU7 5/23/2018 https://support.microsoft.com/en-us/help/4229789 +-- 14.0.3029.16 CU8 6/19/2018 https://support.microsoft.com/en-us/help/4338363 +-- 14.0.3030.27 CU9 7/19/2018 https://support.microsoft.com/en-us/help/4341265 +-- 14.0.3035.2 CU9 + Security Update 8/13/2018 https://www.microsoft.com/en-us/download/details.aspx?id=57263 +-- 14.0.3037.1 CU10 8/27/2018 https://support.microsoft.com/en-us/help/4342123/cumulative-update-10-for-sql-server-2017 +-- 14.0.3038.14 CU11 9/20/2018 https://support.microsoft.com/en-us/help/4462262 +-- 14.0.3045.24 CU12 10/23/2018 https://support.microsoft.com/en-us/help/4464082/cumulative-update-12-for-sql-server-2017 +-- 14.0.3048.4 CU13 12/18/2018 https://support.microsoft.com/en-us/help/4466404/cumulative-update-13-for-sql-server-2017 +-- 14.0.3076.1 CU14 3/25/2019 https://support.microsoft.com/en-us/help/4484710/cumulative-update-14-for-sql-server-2017 +-- 14.0.3103.1 CU14 + Security Update 5/14/2019 https://support.microsoft.com/en-us/help/4494352/security-update-for-sql-server-2017-cu-14-gdr-may-14-2019 +-- 14.0.3162.1 CU15 5/23/2019 https://support.microsoft.com/en-us/help/4498951/cumulative-update-15-for-sql-server-2017 +-- 14.0.3192.2 CU15 + Security Update 7/9/2019 https://support.microsoft.com/en-us/help/4505225/security-update-for-sql-server-2017-cu15-gdr-july-9-2019 +-- 14.0.3223.3 CU16 8/1/2019 https://support.microsoft.com/en-us/help/4508218/cumulative-update-16-for-sql-server-2017 +-- 14.0.3238.1 CU17 10/8/2019 https://support.microsoft.com/en-us/help/4515579/cumulative-update-17-for-sql-server-2017 +-- 14.0.3257.3 CU18 12/9/2019 https://support.microsoft.com/en-us/help/4527377/cumulative-update-18-for-sql-server-2017 +-- 14.0.3281.6 CU19 2/5/2020 https://support.microsoft.com/en-us/help/4535007/cumulative-update-19-for-sql-server-2017 +-- 14.0.3294.2 CU20 4/7/2020 https://support.microsoft.com/en-us/help/4541283/cumulative-update-20-for-sql-server-2017 +-- 14.0.3335.7 CU21 7/1/2020 https://support.microsoft.com/en-us/help/4557397/cumulative-update-21-for-sql-server-2017 +-- 14.0.3356.20 CU22 9/10/2020 https://support.microsoft.com/en-us/help/4577467/cumulative-update-22-for-sql-server-2017 -- How to determine the version, edition and update level of SQL Server and its components --- https://support.microsoft.com/en-us/kb/321185 +-- https://bit.ly/2oAjKgW -- SQL Server 2017 build versions --- https://support.microsoft.com/en-us/help/4047329/sql-server-2017-build-versions +-- https://bit.ly/2FLY88I --- Performance and Stability Fixes in SQL Server 2017 CU Builds --- https://www.sqlskills.com/blogs/glenn/performance-and-stability-fixes-in-sql-server-2017-cu-builds/ +-- Recommended updates and configuration options for SQL Server 2017 and 2016 with high-performance workloads +-- https://bit.ly/2JsReue --- Microsoft for the Modern Data Estate --- https://blogs.technet.microsoft.com/dataplatforminsider/2017/09/25/microsoft-for-the-modern-data-estate/ +-- Performance and Stability Fixes in SQL Server 2017 CU Builds +-- https://bit.ly/2GV3CNM -- What's New in SQL Server 2017 (Database Engine) --- https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/what-s-new-in-sql-server-2017-database-engine +-- https://bit.ly/2HjSeyQ -- What's New in SQL Server 2017 --- https://docs.microsoft.com/en-us/sql/sql-server/what-s-new-in-sql-server-2017 +-- https://bit.ly/2saQ4Yh -- Announcing the Modern Servicing Model for SQL Server --- https://blogs.msdn.microsoft.com/sqlreleaseservices/announcing-the-modern-servicing-model-for-sql-server/ +-- https://bit.ly/2KtJ8SS -- SQL Server Service Packs are discontinued starting from SQL Server 2017 --- https://support.microsoft.com/en-us/help/4041553 +-- https://bit.ly/2GTkbgt -- Update Center for Microsoft SQL Server --- http://bit.ly/2pZptuQ +-- https://bit.ly/2pZptuQ -- Download SQL Server Management Studio (SSMS) --- https://msdn.microsoft.com/en-us/library/mt238290.aspx +-- https://bit.ly/1OcupT9 --- Download and install Microsoft SQL Operations Studio --- https://docs.microsoft.com/en-us/sql/sql-operations-studio/download +-- Download and install Azure Data Studio +-- https://bit.ly/2vgke1A +-- SQL Server 2017 Configuration Manager is SQLServerManager14.msc -- Get socket, physical core and logical core count from the SQL Server Error log. (Query 2) (Core Counts) @@ -138,10 +165,11 @@ SERVERPROPERTY('IsHadrEnabled') AS [IsHadrEnabled], SERVERPROPERTY('HadrManagerStatus') AS [HadrManagerStatus], SERVERPROPERTY('InstanceDefaultDataPath') AS [InstanceDefaultDataPath], SERVERPROPERTY('InstanceDefaultLogPath') AS [InstanceDefaultLogPath], +SERVERPROPERTY('ErrorLogFileName') AS [ErrorLogFileName], SERVERPROPERTY('BuildClrVersion') AS [Build CLR Version], SERVERPROPERTY('IsXTPSupported') AS [IsXTPSupported], -SERVERPROPERTY('IsPolybaseInstalled') AS [IsPolybaseInstalled], -- New for SQL Server 2016 -SERVERPROPERTY('IsAdvancedAnalyticsInstalled') AS [IsRServicesInstalled]; -- New for SQL Server 2016 +SERVERPROPERTY('IsPolybaseInstalled') AS [IsPolybaseInstalled], +SERVERPROPERTY('IsAdvancedAnalyticsInstalled') AS [IsRServicesInstalled]; ------ -- This gives you a lot of useful information about your instance of SQL Server, @@ -149,7 +177,7 @@ SERVERPROPERTY('IsAdvancedAnalyticsInstalled') AS [IsRServicesInstalled]; -- New -- Note: Some columns will be NULL on older SQL Server builds -- SERVERPROPERTY (Transact-SQL) --- http://bit.ly/2eeaXeI +-- https://bit.ly/2eeaXeI @@ -175,7 +203,8 @@ ORDER BY name OPTION (RECOMPILE); -- New configuration options for SQL Server 2017 -- clr strict security is new in SQL Server 2017, and is enabled by default - +-- sys.configurations (Transact-SQL) +-- https://bit.ly/2HsyDZI -- Returns a list of all global trace flags that are enabled (Query 5) (Global Trace Flags) @@ -186,46 +215,42 @@ DBCC TRACESTATUS (-1); -- It is very useful to know what global trace flags are currently enabled as part of the diagnostic process. -- Common trace flags that should be enabled in most cases +-- TF 460 - Improvement: Optional replacement for "String or binary data would be truncated" message with extended information in SQL Server 2017 +-- https://bit.ly/2sboMli (added in CU12) + -- TF 3226 - Supresses logging of successful database backup messages to the SQL Server Error Log --- https://www.sqlskills.com/blogs/paul/fed-up-with-backup-success-messages-bloating-your-error-logs/ +-- https://bit.ly/38zDNAK -- TF 6534 - Enables use of native code to improve performance with spatial data --- https://blogs.msdn.microsoft.com/bobsql/2016/06/03/sql-2016-it-just-runs-faster-native-spatial-implementations/ +-- https://bit.ly/2HrQUpU + +-- TF 7745 - Prevents Query Store data from being written to disk in case of a failover or shutdown command +-- https://bit.ly/2GU69Km + +-- TF 7752 - Enables asynchronous load of Query Store +-- This allows a database to become online and queries to be executed before the Query Store has been fully recovered + -- The behavior of TF 1117, 1118 are enabled for tempdb in SQL Server 2016 by default -- SQL 2016 It Just Runs Faster: -T1117 and -T1118 changes for TEMPDB and user databases --- https://blogs.msdn.microsoft.com/psssql/2016/03/15/sql-2016-it-just-runs-faster-t1117-and-t1118-changes-for-tempdb-and-user-databases/ +-- https://bit.ly/2lbNWxK -- The behavior of TF 2371 is enabled by default in SQL Server 2016 and newer (in compat level 130 and higher) -- DBCC TRACEON - Trace Flags (Transact-SQL) --- https://docs.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-traceon-trace-flags-transact-sql - - - - - --- Returns status of instant file initialization (Query 6) (IFI Status) -EXEC sys.xp_readerrorlog 0, 1, N'Database Instant File Initialization'; ------- - --- Lets you determine whether Instant File Initialization (IFI) is enabled for the instance --- This should be enabled in the vast majority of cases --- SQL Server 2016 lets you enable this during the SQL server installation process +-- https://bit.ly/2FuSvPg --- Database Instant File Initialization --- https://docs.microsoft.com/en-us/sql/relational-databases/databases/database-instant-file-initialization +-- Recommended updates and configuration options for SQL Server 2017 and 2016 with high-performance workloads +-- https://bit.ly/2VVRGTY --- Misconceptions around instant file initialization --- https://www.sqlskills.com/blogs/paul/misconceptions-around-instant-file-initialization/ - --- SQL Server Process Address space info (Query 7) (Process Memory) +-- SQL Server Process Address space info (Query 6) (Process Memory) -- (shows whether locked pages is enabled, among other things) SELECT physical_memory_in_use_kb/1024 AS [SQL Server Memory Usage (MB)], - large_page_allocations_kb, locked_page_allocations_kb, page_fault_count, - memory_utilization_percentage, available_commit_limit_kb, + locked_page_allocations_kb/1024 AS [SQL Server Locked Pages Allocation (MB)], + large_page_allocations_kb/1024 AS [SQL Server Large Pages Allocation (MB)], + page_fault_count, memory_utilization_percentage, available_commit_limit_kb, process_physical_memory_low, process_virtual_memory_low FROM sys.dm_os_process_memory WITH (NOLOCK) OPTION (RECOMPILE); ------ @@ -236,14 +261,17 @@ FROM sys.dm_os_process_memory WITH (NOLOCK) OPTION (RECOMPILE); -- If locked_page_allocations_kb > 0, then LPIM is enabled -- How to enable the "locked pages" feature in SQL Server 2012 --- https://support.microsoft.com/en-us/kb/2659143 +-- https://bit.ly/2F5UjOA + +-- Memory Management Architecture Guide +-- https://bit.ly/2JKkadC --- SQL Server Services information (Query 8) (SQL Server Services Info) +-- SQL Server Services information (Query 7) (SQL Server Services Info) SELECT servicename, process_id, startup_type_desc, status_desc, last_startup_time, service_account, is_clustered, cluster_nodename, [filename], -instant_file_initialization_enabled +instant_file_initialization_enabled FROM sys.dm_server_services WITH (NOLOCK) OPTION (RECOMPILE); ------ @@ -252,25 +280,34 @@ FROM sys.dm_server_services WITH (NOLOCK) OPTION (RECOMPILE); -- Also shows whether you are running on a failover cluster instance, and what node you are running on -- Also shows whether IFI is enabled +-- sys.dm_server_services (Transact-SQL) +-- https://bit.ly/2oKa1Un --- Last backup information by database (Query 9) (Last Backup By Database) + +-- Last backup information by database (Query 8) (Last Backup By Database) SELECT ISNULL(d.[name], bs.[database_name]) AS [Database], d.recovery_model_desc AS [Recovery Model], d.log_reuse_wait_desc AS [Log Reuse Wait Desc], MAX(CASE WHEN [type] = 'D' THEN bs.backup_finish_date ELSE NULL END) AS [Last Full Backup], + MAX(CASE WHEN [type] = 'D' THEN bmf.physical_device_name ELSE NULL END) AS [Last Full Backup Location], MAX(CASE WHEN [type] = 'I' THEN bs.backup_finish_date ELSE NULL END) AS [Last Differential Backup], - MAX(CASE WHEN [type] = 'L' THEN bs.backup_finish_date ELSE NULL END) AS [Last Log Backup] + MAX(CASE WHEN [type] = 'I' THEN bmf.physical_device_name ELSE NULL END) AS [Last Differential Backup Location], + MAX(CASE WHEN [type] = 'L' THEN bs.backup_finish_date ELSE NULL END) AS [Last Log Backup], + MAX(CASE WHEN [type] = 'L' THEN bmf.physical_device_name ELSE NULL END) AS [Last Log Backup Location] FROM sys.databases AS d WITH (NOLOCK) LEFT OUTER JOIN msdb.dbo.backupset AS bs WITH (NOLOCK) -ON bs.[database_name] = d.[name] +ON bs.[database_name] = d.[name] +LEFT OUTER JOIN msdb.dbo.backupmediafamily AS bmf WITH (NOLOCK) +ON bs.media_set_id = bmf.media_set_id AND bs.backup_finish_date > GETDATE()- 30 -GROUP BY ISNULL(d.[name], bs.[database_name]), d.recovery_model_desc, d.log_reuse_wait_desc -ORDER BY d.recovery_model_desc OPTION (RECOMPILE); +WHERE d.name <> N'tempdb' +GROUP BY ISNULL(d.[name], bs.[database_name]), d.recovery_model_desc, d.log_reuse_wait_desc, d.[name] +ORDER BY d.recovery_model_desc, d.[name] OPTION (RECOMPILE); ------ -- This helps you spot runaway transaction logs and other issues with your backup schedule --- Get SQL Server Agent jobs and Category information (Query 10) (SQL Server Agent Jobs) +-- Get SQL Server Agent jobs and Category information (Query 9) (SQL Server Agent Jobs) SELECT sj.name AS [Job Name], sj.[description] AS [Job Description], SUSER_SNAME(sj.owner_sid) AS [Job Owner], sj.date_created AS [Date Created], sj.[enabled] AS [Job Enabled], sj.notify_email_operator_id, sj.notify_level_email, sc.name AS [CategoryName], @@ -291,32 +328,37 @@ ORDER BY sj.name OPTION (RECOMPILE); -- Look for jobs that have a notify_level_email set to 0 (meaning no e-mail is ever sent) -- -- MSDN sysjobs documentation --- https://msdn.microsoft.com/en-us/library/ms189817.aspx +-- https://bit.ly/2paDEOP + +-- SQL Server Maintenance Solution (Ola Hallengren) +-- https://bit.ly/1pgchQu --- SQL Server Maintenance Solution --- https://ola.hallengren.com/ +-- You can use this script to add default schedules to the standard Ola Hallengren Maintenance Solution jobs +-- https://bit.ly/3ane0gN --- Get SQL Server Agent Alert Information (Query 11) (SQL Server Agent Alerts) +-- Get SQL Server Agent Alert Information (Query 10) (SQL Server Agent Alerts) SELECT name, event_source, message_id, severity, [enabled], has_notification, delay_between_responses, occurrence_count, last_occurrence_date, last_occurrence_time FROM msdb.dbo.sysalerts WITH (NOLOCK) ORDER BY name OPTION (RECOMPILE); ------ --- Gives you some basic information about your SQL Server Agent Alerts (which are different from SQL Server Agent jobs) --- Read more about Agent Alerts here: https://www.sqlskills.com/blogs/glenn/creating-sql-server-agent-alerts-for-critical-errors/ +-- Gives you some basic information about your SQL Server Agent Alerts +-- (which are different from SQL Server Agent jobs) +-- Read more about Agent Alerts here: https://bit.ly/2v5YR37 --- Host information (Query 12) (Host Info) +-- Host information (Query 11) (Host Info) SELECT host_platform, host_distribution, host_release, host_service_pack_level, host_sku, os_language_version FROM sys.dm_os_host_info WITH (NOLOCK) OPTION (RECOMPILE); ------ -- host_release codes (only valid for Windows) --- 6.3 is either Windows 8.1, Windows 10 or Windows Server 2012 R2, Windows Server 2016 +-- 10.0 is either Windows 10 or Windows Server 2016 +-- 6.3 is either Windows 8.1 or Windows Server 2012 R2 -- 6.2 is either Windows 8 or Windows Server 2012 @@ -326,19 +368,20 @@ FROM sys.dm_os_host_info WITH (NOLOCK) OPTION (RECOMPILE); -- 8 is Datacenter Server Edition -- 10 is Enterprise Server Edition -- 48 is Professional Edition +-- 161 is Pro for Workstations -- 1033 for os_language_version is US-English -- SQL Server 2017 requires Windows Server 2012 or newer -- Hardware and Software Requirements for Installing SQL Server --- https://docs.microsoft.com/en-us/sql/sql-server/install/hardware-and-software-requirements-for-installing-sql-server +-- https://bit.ly/2y3ka5L --- Using SQL Server in Windows 8 and later versions of Windows operating system --- https://support.microsoft.com/en-us/kb/2681562 +-- Using SQL Server in Windows 8 and later versions of Windows operating system +-- https://bit.ly/2F7Ax0P --- SQL Server NUMA Node information (Query 13) (SQL Server NUMA Info) +-- SQL Server NUMA Node information (Query 12) (SQL Server NUMA Info) SELECT node_id, node_state_desc, memory_node_id, processor_group, cpu_count, online_scheduler_count, idle_scheduler_count, active_worker_count, avg_load_balance, resource_monitor_state FROM sys.dm_os_nodes WITH (NOLOCK) @@ -347,18 +390,22 @@ WHERE node_state_desc <> N'ONLINE DAC' OPTION (RECOMPILE); -- Gives you some useful information about the composition and relative load on your NUMA nodes -- You want to see an equal number of schedulers on each NUMA node --- Watch out if SQL Server 2016 Standard Edition has been installed on a machine with more than 24 physical cores --- Watch out if you have a VM with more than 4 NUMA nodes with SQL Server Standard Edition, since there is a four-socket license limit +-- Watch out if SQL Server 2017 Standard Edition has been installed +-- on a physical or virtual machine with more than four sockets or more than 24 physical cores --- Balancing Your Available SQL Server Core Licenses Evenly Across NUMA Nodes --- https://www.sqlskills.com/blogs/glenn/balancing-your-available-sql-server-core-licenses-evenly-across-numa-nodes/ +-- sys.dm_os_nodes (Transact-SQL) +-- https://bit.ly/2pn5Mw8 +-- How to Balance SQL Server Core Licenses Across NUMA Nodes +-- https://bit.ly/3i4TyVR --- Good basic information about OS memory amounts and state (Query 14) (System Memory) + +-- Good basic information about OS memory amounts and state (Query 13) (System Memory) SELECT total_physical_memory_kb/1024 AS [Physical Memory (MB)], available_physical_memory_kb/1024 AS [Available Memory (MB)], - total_page_file_kb/1024 AS [Total Page File (MB)], + total_page_file_kb/1024 AS [Page File Commit Limit (MB)], + total_page_file_kb/1024 - total_physical_memory_kb/1024 AS [Physical Page File Size (MB)], available_page_file_kb/1024 AS [Available Page File (MB)], system_cache_kb/1024 AS [System Cache (MB)], system_memory_state_desc AS [System Memory State] @@ -375,11 +422,15 @@ FROM sys.dm_os_sys_memory WITH (NOLOCK) OPTION (RECOMPILE); -- Available physical memory is running low -- Physical memory state is transitioning +-- sys.dm_os_sys_memory (Transact-SQL) +-- https://bit.ly/2pcV0xq + + -- You can skip the next two queries if you know you don't have a clustered instance --- Get information about your cluster nodes and their status (Query 15) (Cluster Node Properties) +-- Get information about your cluster nodes and their status (Query 14) (Cluster Node Properties) -- (if your database server is in a failover cluster) SELECT NodeName, status_description, is_current_owner FROM sys.dm_os_cluster_nodes WITH (NOLOCK) OPTION (RECOMPILE); @@ -390,10 +441,10 @@ FROM sys.dm_os_cluster_nodes WITH (NOLOCK) OPTION (RECOMPILE); -- You will see no results if your instance is not clustered -- Recommended hotfixes and updates for Windows Server 2012 R2-based failover clusters --- http://support.microsoft.com/kb/2920151 +-- https://bit.ly/1z5BfCw --- Get information about any AlwaysOn AG cluster this instance is a part of (Query 16) (AlwaysOn AG Cluster) +-- Get information about any AlwaysOn AG cluster this instance is a part of (Query 15) (AlwaysOn AG Cluster) SELECT cluster_name, quorum_type_desc, quorum_state_desc FROM sys.dm_hadr_cluster WITH (NOLOCK) OPTION (RECOMPILE); ------ @@ -401,7 +452,7 @@ FROM sys.dm_hadr_cluster WITH (NOLOCK) OPTION (RECOMPILE); -- You will see no results if your instance is not using AlwaysOn AGs --- Good overview of AG health and status (Query 17) (AlwaysOn AG Status) +-- Good overview of AG health and status (Query 16) (AG Status) SELECT ag.name AS [AG Name], ar.replica_server_name, ar.availability_mode_desc, adc.[database_name], drs.is_local, drs.is_primary_replica, drs.synchronization_state_desc, drs.is_commit_participant, drs.synchronization_health_desc, drs.recovery_lsn, drs.truncation_lsn, drs.last_sent_lsn, @@ -423,41 +474,46 @@ ORDER BY ag.name, ar.replica_server_name, adc.[database_name] OPTION (RECOMPILE) -- You will see no results if your instance is not using AlwaysOn AGs -- SQL Server 2016 It Just Runs Faster: Always On Availability Groups Turbocharged --- https://blogs.msdn.microsoft.com/bobsql/2016/09/26/sql-server-2016-it-just-runs-faster-always-on-availability-groups-turbocharged/ - - --- Hardware information from SQL Server 2017 (Query 18) (Hardware Info) -SELECT cpu_count AS [Logical CPU Count], scheduler_count, (socket_count * cores_per_socket) AS [Physical CPU Count], -socket_count AS [Socket Count], cores_per_socket, numa_node_count, -physical_memory_kb/1024 AS [Physical Memory (MB)], committed_kb/1024 AS [Committed Memory (MB)], -committed_target_kb/1024 AS [Committed Target Memory (MB)], -max_workers_count AS [Max Workers Count], affinity_type_desc AS [Affinity Type], -sqlserver_start_time AS [SQL Server Start Time], virtual_machine_type_desc AS [Virtual Machine Type], -softnuma_configuration_desc AS [Soft NUMA Configuration], sql_memory_model_desc, -process_physical_affinity -- New in SQL Server 2017 +-- https://bit.ly/2dn1H6r + + +-- Hardware information from SQL Server 2017 (Query 17) (Hardware Info) +SELECT cpu_count AS [Logical CPU Count], scheduler_count, + (socket_count * cores_per_socket) AS [Physical Core Count], + socket_count AS [Socket Count], cores_per_socket, numa_node_count, + physical_memory_kb/1024 AS [Physical Memory (MB)], + max_workers_count AS [Max Workers Count], + affinity_type_desc AS [Affinity Type], + sqlserver_start_time AS [SQL Server Start Time], + DATEDIFF(hour, sqlserver_start_time, GETDATE()) AS [SQL Server Up Time (hrs)], + virtual_machine_type_desc AS [Virtual Machine Type], + softnuma_configuration_desc AS [Soft NUMA Configuration], + sql_memory_model_desc, process_physical_affinity -- New in SQL Server 2017 FROM sys.dm_os_sys_info WITH (NOLOCK) OPTION (RECOMPILE); ------ -- Gives you some good basic hardware information about your database server --- Cannot distinguish between HT and multi-core -- Note: virtual_machine_type_desc of HYPERVISOR does not automatically mean you are running SQL Server inside of a VM -- It merely indicates that you have a hypervisor running on your host --- Soft NUMA configuration is a new column for SQL Server 2016 +-- sys.dm_os_sys_info (Transact-SQL) +-- https://bit.ly/2pczOYs + +-- Soft NUMA configuration was a new column for SQL Server 2016 -- OFF = Soft-NUMA feature is OFF -- ON = SQL Server automatically determines the NUMA node sizes for Soft-NUMA -- MANUAL = Manually configured soft-NUMA -- Configure SQL Server to Use Soft-NUMA (SQL Server) --- https://msdn.microsoft.com/en-us/library/ms345357(v=sql.130).aspx +-- https://bit.ly/2HTpKJt --- sql_memory_model_desc values (New in SQL Server 2016 SP1) +-- sql_memory_model_desc values (Added in SQL Server 2016 SP1) -- CONVENTIONAL -- LOCK_PAGES -- LARGE_PAGES --- Get System Manufacturer and model number from SQL Server Error log (Query 19) (System Manufacturer) +-- Get System Manufacturer and model number from SQL Server Error log (Query 18) (System Manufacturer) EXEC sys.xp_readerrorlog 0, 1, N'Manufacturer'; ------ @@ -467,62 +523,34 @@ EXEC sys.xp_readerrorlog 0, 1, N'Manufacturer'; -- This query will return no results if your error log has been recycled since the instance was started --- Get BIOS date from Windows Registry (Query 20) (BIOS Date) +-- Get BIOS date from Windows Registry (Query 19) (BIOS Date) EXEC sys.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'HARDWARE\DESCRIPTION\System\BIOS', N'BiosReleaseDate'; ------ -- Helps you understand whether the main system BIOS is up to date, and the possible age of the hardware -- Not as useful for virtualization +-- Does not work on Linux --- Get processor description from Windows Registry (Query 21) (Processor Description) +-- Get processor description from Windows Registry (Query 20) (Processor Description) EXEC sys.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'HARDWARE\DESCRIPTION\System\CentralProcessor\0', N'ProcessorNameString'; ------ -- Gives you the model number and rated clock speed of your processor(s) -- Your processors may be running at less than the rated clock speed due -- to the Windows Power Plan or hardware power management +-- Does not work on Linux -- You can use CPU-Z to get your actual CPU core speed and a lot of other useful information --- http://www.cpuid.com/softwares/cpu-z.html +-- https://bit.ly/QhR6xF -- You can learn more about processor selection for SQL Server by following this link --- https://www.sqlskills.com/blogs/glenn/processor-selection-for-sql-server/ - - - --- See if buffer pool extension (BPE) is enabled (Query 22) (BPE Configuration) -SELECT [path], state_description, current_size_in_kb, -CAST(current_size_in_kb/1048576.0 AS DECIMAL(10,2)) AS [Size (GB)] -FROM sys.dm_os_buffer_pool_extension_configuration WITH (NOLOCK) OPTION (RECOMPILE); ------- - --- BPE is available in both Standard Edition and Enterprise Edition --- It is a more interesting feature for Standard Edition +-- https://bit.ly/2F3aVlP --- Buffer Pool Extension to SSDs in SQL Server 2014 --- http://blogs.technet.com/b/dataplatforminsider/archive/2013/07/25/buffer-pool-extension-to-ssds-in-sql-server-2014.aspx --- Buffer Pool Extension --- https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/buffer-pool-extension - --- Look at buffer descriptors to see BPE usage by database (Query 23) (BPE Usage) -SELECT DB_NAME(database_id) AS [Database Name], COUNT(page_id) AS [Page Count], -CAST(COUNT(*)/128.0 AS DECIMAL(10, 2)) AS [Buffer size(MB)], -AVG(read_microsec) AS [Avg Read Time (microseconds)] -FROM sys.dm_os_buffer_descriptors WITH (NOLOCK) -WHERE database_id <> 32767 -AND is_in_bpool_extension = 1 -GROUP BY DB_NAME(database_id) -ORDER BY [Buffer size(MB)] DESC OPTION (RECOMPILE); ------- - --- You will see no results if BPE is not enabled or if there is no BPE usage - - --- Get information on location, time and size of any memory dumps from SQL Server (Query 24) (Memory Dump Info) +-- Get information on location, time and size of any memory dumps from SQL Server (Query 21) (Memory Dump Info) SELECT [filename], creation_time, size_in_bytes/1048576.0 AS [Size (MB)] FROM sys.dm_server_memory_dumps WITH (NOLOCK) ORDER BY creation_time DESC OPTION (RECOMPILE); @@ -532,13 +560,11 @@ ORDER BY creation_time DESC OPTION (RECOMPILE); -- not had any memory dumps (which is a good thing) -- sys.dm_server_memory_dumps (Transact-SQL) --- http://bit.ly/2elwWll +-- https://bit.ly/2elwWll --- SQL Server Diagnostics (Preview) --- http://bit.ly/2sOfkFB --- Look at Suspect Pages table (Query 25) (Suspect Pages) +-- Look at Suspect Pages table (Query 22) (Suspect Pages) SELECT DB_NAME(database_id) AS [Database Name], [file_id], page_id, event_type, error_count, last_update_date FROM msdb.dbo.suspect_pages WITH (NOLOCK) @@ -546,34 +572,36 @@ ORDER BY database_id OPTION (RECOMPILE); ------ -- event_type value descriptions --- 1 = 823 error caused by an operating system CRC error or 824 error other than a bad checksum or a torn page (for example, a bad page ID) +-- 1 = 823 error caused by an operating system CRC error +-- or 824 error other than a bad checksum or a torn page (for example, a bad page ID) -- 2 = Bad checksum -- 3 = Torn page -- 4 = Restored (The page was restored after it was marked bad) -- 5 = Repaired (DBCC repaired the page) -- 7 = Deallocated by DBCC --- Manage the suspect_pages Table --- https://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/manage-the-suspect-pages-table-sql-server - -- Ideally, this query returns no results. The table is limited to 1000 rows. -- If you do get results here, you should do further investigation to determine the root cause +-- Manage the suspect_pages Table +-- https://bit.ly/2Fvr1c9 + --- Get number of data files in tempdb database (Query 26) (TempDB Data Files) +-- Get number of data files in tempdb database (Query 23) (TempDB Data Files) EXEC sys.xp_readerrorlog 0, 1, N'The tempdb database has'; ------ -- Get the number of data files in the tempdb database -- 4-8 data files that are all the same size is a good starting point +-- This query will return no results if your error log has been recycled since the instance was last started --- File names and paths for all user and system databases on instance (Query 27) (Database Filenames and Paths) +-- File names and paths for all user and system databases on instance (Query 24) (Database Filenames and Paths) SELECT DB_NAME([database_id]) AS [Database Name], [file_id], [name], physical_name, [type_desc], state_desc, - is_percent_growth, growth, + is_percent_growth, growth, CONVERT(bigint, growth/128.0) AS [Growth in MB], - CONVERT(bigint, size/128.0) AS [Total Size in MB] + CONVERT(bigint, size/128.0) AS [Total Size in MB], max_size FROM sys.master_files WITH (NOLOCK) ORDER BY DB_NAME([database_id]), [file_id] OPTION (RECOMPILE); ------ @@ -588,21 +616,27 @@ ORDER BY DB_NAME([database_id]), [file_id] OPTION (RECOMPILE); -- Is percent growth enabled for any files (which is bad)? --- Drive information for all fixed drives visible the operating system (Query 28) (Fixed Drives) +-- Drive information for all fixed drives visible to the operating system (Query 25) (Fixed Drives) SELECT fixed_drive_path, drive_type_desc, -CONVERT(DECIMAL(18,2),free_space_in_bytes/1073741824.0) AS [Available Space (GB)] +CONVERT(DECIMAL(18,2), free_space_in_bytes/1073741824.0) AS [Available Space (GB)] FROM sys.dm_os_enumerate_fixed_drives WITH (NOLOCK) OPTION (RECOMPILE); ------ --- This shows all of your fixed drives, not just LUNs with SQL Server database files +-- This shows all of your drives, not just LUNs with SQL Server database files +-- New in SQL Server 2017 + +-- sys.dm_os_enumerate_fixed_drives (Transact-SQL) +-- https://bit.ly/2EZoHLj --- Volume info for all LUNS that have database files on the current instance (Query 29) (Volume Info) -SELECT DISTINCT vs.volume_mount_point, vs.file_system_type, -vs.logical_volume_name, CONVERT(DECIMAL(18,2),vs.total_bytes/1073741824.0) AS [Total Size (GB)], +-- Volume info for all LUNS that have database files on the current instance (Query 26) (Volume Info) +SELECT DISTINCT vs.volume_mount_point, vs.file_system_type, vs.logical_volume_name, +CONVERT(DECIMAL(18,2), vs.total_bytes/1073741824.0) AS [Total Size (GB)], CONVERT(DECIMAL(18,2), vs.available_bytes/1073741824.0) AS [Available Size (GB)], -CONVERT(DECIMAL(18,2), vs.available_bytes * 1. / vs.total_bytes * 100.) AS [Space Free %] +CONVERT(DECIMAL(18,2), vs.available_bytes * 1. / vs.total_bytes * 100.) AS [Space Free %], +vs.supports_compression, vs.is_compressed, +vs.supports_sparse_files, vs.supports_alternate_streams FROM sys.master_files AS f WITH (NOLOCK) CROSS APPLY sys.dm_os_volume_stats(f.database_id, f.[file_id]) AS vs ORDER BY vs.volume_mount_point OPTION (RECOMPILE); @@ -611,10 +645,12 @@ ORDER BY vs.volume_mount_point OPTION (RECOMPILE); -- Shows you the total and free space on the LUNs where you have database files -- Being low on free space can negatively affect performance +-- sys.dm_os_volume_stats (Transact-SQL) +-- https://bit.ly/2oBPNNr --- Drive level latency information (Query 30) (Drive Level Latency) --- Based on code from Jimmy May + +-- Drive level latency information (Query 27) (Drive Level Latency) SELECT tab.[Drive], tab.volume_mount_point AS [Volume Mount Point], CASE WHEN num_of_reads = 0 THEN 0 @@ -657,11 +693,17 @@ ORDER BY [Overall Latency] OPTION (RECOMPILE); -- These latency numbers include all file activity against all SQL Server -- database files on each drive since SQL Server was last started +-- sys.dm_io_virtual_file_stats (Transact-SQL) +-- https://bit.ly/3bRWUc0 + +-- sys.dm_os_volume_stats (Transact-SQL) +-- https://bit.ly/33thz2j + --- Calculates average stalls per read, per write, and per total input/output for each database file (Query 31) (IO Stalls by File) -SELECT DB_NAME(fs.database_id) AS [Database Name], CAST(fs.io_stall_read_ms/(1.0 + fs.num_of_reads) AS NUMERIC(10,1)) AS [avg_read_stall_ms], -CAST(fs.io_stall_write_ms/(1.0 + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_write_stall_ms], -CAST((fs.io_stall_read_ms + fs.io_stall_write_ms)/(1.0 + fs.num_of_reads + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_io_stall_ms], +-- Calculates average stalls per read, per write, and per total input/output for each database file (Query 28) (IO Latency by File) +SELECT DB_NAME(fs.database_id) AS [Database Name], CAST(fs.io_stall_read_ms/(1.0 + fs.num_of_reads) AS NUMERIC(10,1)) AS [avg_read_latency_ms], +CAST(fs.io_stall_write_ms/(1.0 + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_write_latency_ms], +CAST((fs.io_stall_read_ms + fs.io_stall_write_ms)/(1.0 + fs.num_of_reads + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_io_latency_ms], CONVERT(DECIMAL(18,2), mf.size/128.0) AS [File Size (MB)], mf.physical_name, mf.type_desc, fs.io_stall_read_ms, fs.num_of_reads, fs.io_stall_write_ms, fs.num_of_writes, fs.io_stall_read_ms + fs.io_stall_write_ms AS [io_stalls], fs.num_of_reads + fs.num_of_writes AS [total_io], io_stall_queued_read_ms AS [Resource Governor Total Read IO Latency (ms)], io_stall_queued_write_ms AS [Resource Governor Total Write IO Latency (ms)] @@ -669,7 +711,7 @@ FROM sys.dm_io_virtual_file_stats(null,null) AS fs INNER JOIN sys.master_files AS mf WITH (NOLOCK) ON fs.database_id = mf.database_id AND fs.[file_id] = mf.[file_id] -ORDER BY avg_io_stall_ms DESC OPTION (RECOMPILE); +ORDER BY avg_io_latency_ms DESC OPTION (RECOMPILE); ------ -- Helps determine which database files on the entire instance have the most I/O bottlenecks @@ -678,8 +720,11 @@ ORDER BY avg_io_stall_ms DESC OPTION (RECOMPILE); -- These latency numbers include all file activity against each SQL Server -- database file since SQL Server was last started +-- sys.dm_io_virtual_file_stats (Transact-SQL) +-- https://bit.ly/3bRWUc0 --- Look for I/O requests taking longer than 15 seconds in the five most recent SQL Server Error Logs (Query 32) (IO Warnings) + +-- Look for I/O requests taking longer than 15 seconds in the six most recent SQL Server Error Logs (Query 29) (IO Warnings) CREATE TABLE #IOWarningResults(LogDate datetime, ProcessInfo sysname, LogText nvarchar(1000)); INSERT INTO #IOWarningResults @@ -697,6 +742,9 @@ CREATE TABLE #IOWarningResults(LogDate datetime, ProcessInfo sysname, LogText nv INSERT INTO #IOWarningResults EXEC xp_readerrorlog 4, 1, N'taking longer than 15 seconds'; + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 5, 1, N'taking longer than 15 seconds'; + SELECT LogDate, ProcessInfo, LogText FROM #IOWarningResults ORDER BY LogDate DESC; @@ -709,11 +757,26 @@ DROP TABLE #IOWarningResults; -- Look to see if you see any patterns in the results (same files, same drives, same time of day, etc.) -- Diagnostics in SQL Server help detect stalled and stuck I/O operations --- https://support.microsoft.com/en-us/kb/897284 +-- https://bit.ly/2qtaw73 + + +-- Resource Governor Resource Pool information (Query 30) (RG Resource Pools) +SELECT pool_id, [Name], statistics_start_time, + min_memory_percent, max_memory_percent, + max_memory_kb/1024 AS [max_memory_mb], + used_memory_kb/1024 AS [used_memory_mb], + target_memory_kb/1024 AS [target_memory_mb], + min_iops_per_volume, max_iops_per_volume +FROM sys.dm_resource_governor_resource_pools WITH (NOLOCK) +OPTION (RECOMPILE); +------ +-- sys.dm_resource_governor_resource_pools (Transact-SQL) +-- https://bit.ly/2MVU0Vy --- Recovery model, log reuse wait description, log file size, log usage size (Query 33) (Database Properties) + +-- Recovery model, log reuse wait description, log file size, log usage size (Query 31) (Database Properties) -- and compatibility level for all databases on instance SELECT db.[name] AS [Database Name], SUSER_SNAME(db.owner_sid) AS [Database Owner], db.recovery_model_desc AS [Recovery Model], db.state_desc, db.containment_desc, db.log_reuse_wait_desc AS [Log Reuse Wait Description], @@ -727,7 +790,7 @@ db.target_recovery_time_in_seconds, db.is_cdc_enabled, db.is_published, db.is_di db.group_database_id, db.replica_id,db.is_memory_optimized_elevate_to_snapshot_on, db.delayed_durability_desc, db.is_auto_create_stats_incremental_on, db.is_query_store_on, db.is_sync_with_backup, db.is_temporal_history_retention_enabled, -db.is_supplemental_logging_enabled, db.is_remote_data_archive_enabled, +db.is_remote_data_archive_enabled, db.is_encrypted, de.encryption_state, de.percent_complete, de.key_algorithm, de.key_length FROM sys.databases AS db WITH (NOLOCK) INNER JOIN sys.dm_os_performance_counters AS lu WITH (NOLOCK) @@ -742,6 +805,16 @@ AND ls.cntr_value > 0 ORDER BY db.[name] OPTION (RECOMPILE); ------ +-- sys.databases (Transact-SQL) +-- https://bit.ly/2G5wqaX + +-- sys.dm_os_performance_counters (Transact-SQL) +-- https://bit.ly/3kEO2JR + +-- sys.dm_database_encryption_keys (Transact-SQL) +-- https://bit.ly/3mE7kkx + + -- Things to look at: -- How many databases are on the instance? -- What recovery models are they using? @@ -755,20 +828,22 @@ ORDER BY db.[name] OPTION (RECOMPILE); -- is_mixed_page_allocation_on is a new property for SQL Server 2016. Equivalent to TF 1118 for a user database -- SQL Server 2016: Changes in default behavior for autogrow and allocations for tempdb and user databases --- https://blogs.msdn.microsoft.com/sql_server_team/sql-server-2016-changes-in-default-behavior-for-autogrow-and-allocations-for-tempdb-and-user-databases/ +-- https://bit.ly/2evRZSR -- A non-zero value for target_recovery_time_in_seconds means that indirect checkpoint is enabled -- If the setting has a zero value it indicates that automatic checkpoint is enabled -- Changes in SQL Server 2016 Checkpoint Behavior --- https://blogs.msdn.microsoft.com/sqlcat/2016/08/03/changes-in-sql-server-2016-checkpoint-behavior/ +-- https://bit.ly/2pdggk3 --- Missing Indexes for all databases by Index Advantage (Query 34) (Missing Indexes All Databases) -SELECT CONVERT(decimal(18,2), user_seeks * avg_total_user_cost * (avg_user_impact * 0.01)) AS [index_advantage], -migs.last_user_seek, mid.[statement] AS [Database.Schema.Table], -mid.equality_columns, mid.inequality_columns, mid.included_columns, -migs.unique_compiles, migs.user_seeks, migs.avg_total_user_cost, migs.avg_user_impact +-- Missing Indexes for all databases by Index Advantage (Query 32) (Missing Indexes All Databases) +SELECT CONVERT(decimal(18,2), migs.user_seeks * migs.avg_total_user_cost * (migs.avg_user_impact * 0.01)) AS [index_advantage], +FORMAT(migs.last_user_seek, 'yyyy-MM-dd HH:mm:ss') AS [last_user_seek], mid.[statement] AS [Database.Schema.Table], +COUNT(1) OVER(PARTITION BY mid.[statement]) AS [missing_indexes_for_table], +COUNT(1) OVER(PARTITION BY mid.[statement], mid.equality_columns) AS [similar_missing_indexes_for_table], +mid.equality_columns, mid.inequality_columns, mid.included_columns, migs.user_seeks, +CONVERT(decimal(18,2), migs.avg_total_user_cost) AS [avg_total_user_cost], migs.avg_user_impact FROM sys.dm_db_missing_index_group_stats AS migs WITH (NOLOCK) INNER JOIN sys.dm_db_missing_index_groups AS mig WITH (NOLOCK) ON migs.group_handle = mig.index_group_handle @@ -782,16 +857,20 @@ ORDER BY index_advantage DESC OPTION (RECOMPILE); -- Also look at avg_user_impact and avg_total_user_cost to help determine importance -- SQL Server is overly eager to add included columns, so beware -- Do not just blindly add indexes that show up from this query!!! +-- Hkan Winther has given me some great suggestions for this query +-- SQL Server Index Design Guide +-- https://bit.ly/2qtZr4N --- Get VLF Counts for all databases on the instance (Query 35) (VLF Counts) -SELECT[name] AS [Database Name],[VLF Count] -FROMsys.databasesAS db WITH (NOLOCK) -CROSS APPLY(SELECTfile_id, COUNT(*)AS [VLF Count] - FROM sys.dm_db_log_info(db.database_id) - GROUP BYfile_id)AS li -ORDER BY [VLF Count] DESC OPTION (RECOMPILE); + +-- Get VLF Counts for all databases on the instance (Query 33) (VLF Counts) +SELECT [name] AS [Database Name], [VLF Count] +FROM sys.databases AS db WITH (NOLOCK) +CROSS APPLY (SELECT file_id, COUNT(*) AS [VLF Count] + FROM sys.dm_db_log_info(db.database_id) + GROUP BY file_id) AS li +ORDER BY [VLF Count] DESC OPTION (RECOMPILE); ------ -- High VLF counts can affect write performance to the log file @@ -799,11 +878,14 @@ ORDER BY [VLF Count] DESC OPTION (RECOMPILE); -- Try to keep your VLF counts under 200 in most cases (depending on log file size) -- Important change to VLF creation algorithm in SQL Server 2014 --- https://www.sqlskills.com/blogs/paul/important-change-vlf-creation-algorithm-sql-server-2014/ +-- https://bit.ly/2Hsjbg4 +-- SQL Server Transaction Log Architecture and Management Guide +-- https://bit.ly/2JjmQRZ --- Get CPU utilization by database (Query 36) (CPU Usage by Database) + +-- Get CPU utilization by database (Query 34) (CPU Usage by Database) WITH DB_CPU_Stats AS (SELECT pa.DatabaseID, DB_Name(pa.DatabaseID) AS [Database Name], SUM(qs.total_worker_time/1000) AS [CPU_Time_Ms] @@ -821,25 +903,34 @@ ORDER BY [CPU Rank] OPTION (RECOMPILE); ------ -- Helps determine which database is using the most CPU resources on the instance +-- Note: This only reflects CPU usage from the currently cached query plans --- Get I/O utilization by database (Query 37) (IO Usage By Database) +-- Get I/O utilization by database (Query 35) (IO Usage By Database) WITH Aggregate_IO_Statistics -AS -(SELECT DB_NAME(database_id) AS [Database Name], -CAST(SUM(num_of_bytes_read + num_of_bytes_written)/1048576 AS DECIMAL(12, 2)) AS io_in_mb -FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS [DM_IO_STATS] -GROUP BY database_id) -SELECT ROW_NUMBER() OVER(ORDER BY io_in_mb DESC) AS [I/O Rank], [Database Name], io_in_mb AS [Total I/O (MB)], - CAST(io_in_mb/ SUM(io_in_mb) OVER() * 100.0 AS DECIMAL(5,2)) AS [I/O Percent] +AS (SELECT DB_NAME(database_id) AS [Database Name], + CAST(SUM(num_of_bytes_read + num_of_bytes_written) / 1048576 AS DECIMAL(12, 2)) AS [ioTotalMB], + CAST(SUM(num_of_bytes_read ) / 1048576 AS DECIMAL(12, 2)) AS [ioReadMB], + CAST(SUM(num_of_bytes_written) / 1048576 AS DECIMAL(12, 2)) AS [ioWriteMB] + FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS [DM_IO_STATS] + GROUP BY database_id) +SELECT ROW_NUMBER() OVER (ORDER BY ioTotalMB DESC) AS [I/O Rank], + [Database Name], ioTotalMB AS [Total I/O (MB)], + CAST(ioTotalMB / SUM(ioTotalMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Total I/O %], + ioReadMB AS [Read I/O (MB)], + CAST(ioReadMB / SUM(ioReadMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Read I/O %], + ioWriteMB AS [Write I/O (MB)], + CAST(ioWriteMB / SUM(ioWriteMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Write I/O %] FROM Aggregate_IO_Statistics ORDER BY [I/O Rank] OPTION (RECOMPILE); ------ -- Helps determine which database is using the most I/O resources on the instance +-- These numbers are cumulative since the last service restart +-- They include all I/O activity, not just the nominal I/O workload --- Get total buffer usage by database for current instance (Query 38) (Total Buffer Usage by Database) +-- Get total buffer usage by database for current instance (Query 36) (Total Buffer Usage by Database) -- This make take some time to run on a busy instance WITH AggregateBufferPoolUsage AS @@ -858,7 +949,7 @@ ORDER BY [Buffer Pool Rank] OPTION (RECOMPILE); -- is being used by each database on the instance --- Get tempdb version store space usage by database (Query 39) (Version Store Space Usage) +-- Get tempdb version store space usage by database (Query 37) (Version Store Space Usage) SELECT DB_NAME(database_id) AS [Database Name], reserved_page_count AS [Version Store Reserved Page Count], reserved_space_kb/1024 AS [Version Store Reserved Space (MB)] @@ -867,7 +958,7 @@ ORDER BY reserved_space_kb/1024 DESC OPTION (RECOMPILE); ------ -- sys.dm_tran_version_store_space_usage (Transact-SQL) --- https://docs.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-tran-version-store-space-usage +-- https://bit.ly/2vh3Bmk @@ -875,7 +966,7 @@ ORDER BY reserved_space_kb/1024 DESC OPTION (RECOMPILE); -- Clear Wait Stats with this command -- DBCC SQLPERF('sys.dm_os_wait_stats', CLEAR); --- Isolate top waits for server instance since last restart or wait statistics clear (Query 40) (Top Waits) +-- Isolate top waits for server instance since last restart or wait statistics clear (Query 38) (Top Waits) WITH [Waits] AS (SELECT wait_type, wait_time_ms/ 1000.0 AS [WaitS], (wait_time_ms - signal_wait_time_ms) / 1000.0 AS [ResourceS], @@ -887,7 +978,7 @@ AS (SELECT wait_type, wait_time_ms/ 1000.0 AS [WaitS], WHERE [wait_type] NOT IN ( N'BROKER_EVENTHANDLER', N'BROKER_RECEIVE_WAITFOR', N'BROKER_TASK_STOP', N'BROKER_TO_FLUSH', N'BROKER_TRANSMITTER', N'CHECKPOINT_QUEUE', - N'CHKPT', N'CLR_AUTO_EVENT', N'CLR_MANUAL_EVENT', N'CLR_SEMAPHORE', + N'CHKPT', N'CLR_AUTO_EVENT', N'CLR_MANUAL_EVENT', N'CLR_SEMAPHORE', N'CXCONSUMER', N'DBMIRROR_DBM_EVENT', N'DBMIRROR_EVENTS_QUEUE', N'DBMIRROR_WORKER_QUEUE', N'DBMIRRORING_CMD', N'DIRTY_PAGE_POLL', N'DISPATCHER_QUEUE_SEMAPHORE', N'EXECSYNC', N'FSAGENT', N'FT_IFTS_SCHEDULER_IDLE_WAIT', N'FT_IFTSHC_MUTEX', @@ -895,7 +986,8 @@ AS (SELECT wait_type, wait_time_ms/ 1000.0 AS [WaitS], N'HADR_NOTIFICATION_DEQUEUE', N'HADR_TIMER_TASK', N'HADR_WORK_QUEUE', N'KSOURCE_WAKEUP', N'LAZYWRITER_SLEEP', N'LOGMGR_QUEUE', N'MEMORY_ALLOCATION_EXT', N'ONDEMAND_TASK_QUEUE', - N'PARALLEL_REDO_WORKER_WAIT_WORK', + N'PARALLEL_REDO_DRAIN_WORKER', N'PARALLEL_REDO_LOG_CACHE', N'PARALLEL_REDO_TRAN_LIST', + N'PARALLEL_REDO_WORKER_SYNC', N'PARALLEL_REDO_WORKER_WAIT_WORK', N'PREEMPTIVE_HADR_LEASE_MECHANISM', N'PREEMPTIVE_SP_SERVER_DIAGNOSTICS', N'PREEMPTIVE_OS_LIBRARYOPS', N'PREEMPTIVE_OS_COMOPS', N'PREEMPTIVE_OS_CRYPTOPS', N'PREEMPTIVE_OS_PIPEOPS', N'PREEMPTIVE_OS_AUTHENTICATIONOPS', @@ -940,24 +1032,24 @@ OPTION (RECOMPILE); -- Cumulative wait stats are not as useful on an idle instance that is not under load or performance pressure --- SQL Server Wait Types Library (Paul Randal) --- https://www.sqlskills.com/help/waits/ +-- SQL Server Wait Types Library +-- https://bit.ly/2ePzYO2 -- The SQL Server Wait Type Repository --- http://blogs.msdn.com/b/psssql/archive/2009/11/03/the-sql-server-wait-type-repository.aspx +-- https://bit.ly/1afzfjC -- Wait statistics, or please tell me where it hurts --- https://www.sqlskills.com/blogs/paul/wait-statistics-or-please-tell-me-where-it-hurts/ +-- https://bit.ly/2wsQHQE -- SQL Server 2005 Performance Tuning using the Waits and Queues --- http://technet.microsoft.com/en-us/library/cc966413.aspx +-- https://bit.ly/1o2NFoF -- sys.dm_os_wait_stats (Transact-SQL) --- http://msdn.microsoft.com/en-us/library/ms179984(v=sql.120).aspx +-- https://bit.ly/2Hjq9Yl --- Get a count of SQL connections by IP address (Query 41) (Connection Counts by IP Address) +-- Get a count of SQL connections by IP address (Query 39) (Connection Counts by IP Address) SELECT ec.client_net_address, es.[program_name], es.[host_name], es.login_name, COUNT(ec.session_id) AS [connection count] FROM sys.dm_exec_sessions AS es WITH (NOLOCK) @@ -971,11 +1063,11 @@ ORDER BY ec.client_net_address, es.[program_name] OPTION (RECOMPILE); -- and verifies connectivity from other machines -- Solving Connectivity errors to SQL Server --- https://support.microsoft.com/en-us/help/4009936/solving-connectivity-errors-to-sql-server +-- https://bit.ly/2EgzoD0 --- Get Average Task Counts (run multiple times) (Query 42) (Avg Task Counts) +-- Get Average Task Counts (run multiple times) (Query 40) (Avg Task Counts) SELECT AVG(current_tasks_count) AS [Avg Task Count], AVG(work_queue_count) AS [Avg Work Queue Count], AVG(runnable_tasks_count) AS [Avg Runnable Task Count], @@ -992,11 +1084,11 @@ WHERE scheduler_id < 255 OPTION (RECOMPILE); -- High Avg Pending DiskIO Counts are a sign of disk pressure -- How to Do Some Very Basic SQL Server Monitoring --- https://www.sqlskills.com/blogs/glenn/how-to-do-some-very-basic-sql-server-monitoring/ +-- https://bit.ly/30IRla0 --- Detect blocking (run multiple times) (Query 43) (Detect Blocking) +-- Detect blocking (run multiple times) (Query 41) (Detect Blocking) SELECT t1.resource_type AS [lock type], DB_NAME(resource_database_id) AS [database], t1.resource_associated_entity_id AS [blk object],t1.request_mode AS [lock req], -- lock requested t1.request_session_id AS [waiter sid], t2.wait_duration_ms AS [wait time], -- spid of waiter @@ -1025,31 +1117,32 @@ ON t1.lock_owner_address = t2.resource_address OPTION (RECOMPILE); --- Get CPU Utilization History for last 256 minutes (in one minute intervals) (Query 44) (CPU Utilization History) -DECLARE @ts_now bigint = (SELECT cpu_ticks/(cpu_ticks/ms_ticks) FROM sys.dm_os_sys_info WITH (NOLOCK)); +-- Get CPU Utilization History for last 256 minutes (in one minute intervals) (Query 42) (CPU Utilization History) +DECLARE @ts_now bigint = (SELECT ms_ticks FROM sys.dm_os_sys_info WITH (NOLOCK)); SELECT TOP(256) SQLProcessUtilization AS [SQL Server Process CPU Utilization], SystemIdle AS [System Idle Process], 100 - SystemIdle - SQLProcessUtilization AS [Other Process CPU Utilization], DATEADD(ms, -1 * (@ts_now - [timestamp]), GETDATE()) AS [Event Time] FROM (SELECT record.value('(./Record/@id)[1]', 'int') AS record_id, - record.value('(./Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int') - AS [SystemIdle], - record.value('(./Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]', 'int') - AS [SQLProcessUtilization], [timestamp] - FROM (SELECT [timestamp], CONVERT(xml, record) AS [record] - FROM sys.dm_os_ring_buffers WITH (NOLOCK) - WHERE ring_buffer_type = N'RING_BUFFER_SCHEDULER_MONITOR' - AND record LIKE N'%%') AS x) AS y + record.value('(./Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int') + AS [SystemIdle], + record.value('(./Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]', 'int') + AS [SQLProcessUtilization], [timestamp] + FROM (SELECT [timestamp], CONVERT(xml, record) AS [record] + FROM sys.dm_os_ring_buffers WITH (NOLOCK) + WHERE ring_buffer_type = N'RING_BUFFER_SCHEDULER_MONITOR' + AND record LIKE N'%%') AS x) AS y ORDER BY record_id DESC OPTION (RECOMPILE); ------ -- Look at the trend over the entire period -- Also look at high sustained 'Other Process' CPU Utilization values +-- Note: This query sometimes gives inaccurate results (negative values) +-- on high core count (> 64 cores) systems - --- Get top total worker time queries for entire instance (Query 45) (Top Worker Time Queries) +-- Get top total worker time queries for entire instance (Query 43) (Top Worker Time Queries) SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], qs.total_worker_time AS [Total Worker Time], qs.min_worker_time AS [Min Worker Time], @@ -1061,7 +1154,9 @@ qs.max_elapsed_time AS [Max Elapsed Time], qs.min_logical_reads AS [Min Logical Reads], qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], qs.max_logical_reads AS [Max Logical Reads], -qs.execution_count AS [Execution Count], qs.creation_time AS [Creation Time] +qs.execution_count AS [Execution Count], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] --,t.[text] AS [Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t @@ -1075,8 +1170,9 @@ ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); --- Page Life Expectancy (PLE) value for each NUMA node in current instance (Query 46) (PLE by NUMA Node) -SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], instance_name, cntr_value AS [Page Life Expectancy] +-- Page Life Expectancy (PLE) value for each NUMA node in current instance (Query 44) (PLE by NUMA Node) +SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], + instance_name, cntr_value AS [Page Life Expectancy] FROM sys.dm_os_performance_counters WITH (NOLOCK) WHERE [object_name] LIKE N'%Buffer Node%' -- Handles named instances AND counter_name = N'Page life expectancy' OPTION (RECOMPILE); @@ -1087,10 +1183,10 @@ AND counter_name = N'Page life expectancy' OPTION (RECOMPILE); -- This will only return one row for non-NUMA systems -- Page Life Expectancy isnt what you think --- https://www.sqlskills.com/blogs/paul/page-life-expectancy-isnt-what-you-think/ +-- https://bit.ly/2EgynLa --- Memory Grants Pending value for current instance (Query 47) (Memory Grants Pending) +-- Memory Grants Pending value for current instance (Query 45) (Memory Grants Pending) SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], cntr_value AS [Memory Grants Pending] FROM sys.dm_os_performance_counters WITH (NOLOCK) WHERE [object_name] LIKE N'%Memory Manager%' -- Handles named instances @@ -1101,7 +1197,7 @@ AND counter_name = N'Memory Grants Pending' OPTION (RECOMPILE); -- Memory Grants Pending above zero for a sustained period is a very strong indicator of internal memory pressure --- Memory Clerk Usage for instance (Query 48) (Memory Clerk Usage) +-- Memory Clerk Usage for instance (Query 46) (Memory Clerk Usage) -- Look for high value for CACHESTORE_SQLCP (Ad-hoc query plans) SELECT TOP(10) mc.[type] AS [Memory Clerk Type], CAST((SUM(mc.pages_kb)/1024.0) AS DECIMAL (15,2)) AS [Memory Usage (MB)] @@ -1121,16 +1217,21 @@ ORDER BY SUM(mc.pages_kb) DESC OPTION (RECOMPILE); -- CACHESTORE_OBJCP Object Plans -- These are compiled plans for stored procedures, functions and triggers +-- sys.dm_os_memory_clerks (Transact-SQL) +-- https://bit.ly/2H31xDR + --- Find single-use, ad-hoc and prepared queries that are bloating the plan cache (Query 49) (Ad hoc Queries) -SELECT TOP(50) [text] AS [QueryText], cp.cacheobjtype, cp.objtype, cp.size_in_bytes/1024 AS [Plan Size in KB] +-- Find single-use, ad-hoc and prepared queries that are bloating the plan cache (Query 47) (Ad hoc Queries) +SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], t.[text] AS [Query Text], +cp.objtype AS [Object Type], cp.cacheobjtype AS [Cache Object Type], +cp.size_in_bytes/1024 AS [Plan Size in KB] FROM sys.dm_exec_cached_plans AS cp WITH (NOLOCK) -CROSS APPLY sys.dm_exec_sql_text(plan_handle) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t WHERE cp.cacheobjtype = N'Compiled Plan' AND cp.objtype IN (N'Adhoc', N'Prepared') AND cp.usecounts = 1 -ORDER BY cp.size_in_bytes DESC OPTION (RECOMPILE); +ORDER BY cp.size_in_bytes DESC, DB_NAME(t.[dbid]) OPTION (RECOMPILE); ------ -- Gives you the text, type and size of single-use ad-hoc and prepared queries that waste space in the plan cache @@ -1139,10 +1240,10 @@ ORDER BY cp.size_in_bytes DESC OPTION (RECOMPILE); -- Enabling forced parameterization for the database can help, but test first! -- Plan cache, adhoc workloads and clearing the single-use plan cache bloat --- https://www.sqlskills.com/blogs/kimberly/plan-cache-adhoc-workloads-and-clearing-the-single-use-plan-cache-bloat/ +-- https://bit.ly/2EfYOkl --- Get top total logical reads queries for entire instance (Query 50) (Top Logical Reads Queries) +-- Get top total logical reads queries for entire instance (Query 48) (Top Logical Reads Queries) SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], qs.total_logical_reads AS [Total Logical Reads], @@ -1155,7 +1256,9 @@ qs.max_worker_time AS [Max Worker Time], qs.min_elapsed_time AS [Min Elapsed Time], qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], qs.max_elapsed_time AS [Max Elapsed Time], -qs.execution_count AS [Execution Count], qs.creation_time AS [Creation Time] +qs.execution_count AS [Execution Count], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] --,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t @@ -1168,7 +1271,7 @@ ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE); -- Can also help track down parameter sniffing issues --- Get top average elapsed time queries for entire instance (Query 51) (Top Avg Elapsed Time Queries) +-- Get top average elapsed time queries for entire instance (Query 49) (Top Avg Elapsed Time Queries) SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], @@ -1177,8 +1280,9 @@ qs.execution_count AS [Execution Count], qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], qs.total_physical_reads/qs.execution_count AS [Avg Physical Reads], qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], qs.creation_time AS [Creation Time] -, qp.query_plan AS [Query Plan] -- comment out this column if copying results to Excel +--,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp @@ -1189,7 +1293,7 @@ ORDER BY qs.total_elapsed_time/qs.execution_count DESC OPTION (RECOMPILE); -- Can also help track down parameter sniffing issues --- Look at UDF execution statistics (Query 52) (UDF Stats by DB) +-- Look at UDF execution statistics (Query 50) (UDF Stats by DB) SELECT TOP (25) DB_NAME(database_id) AS [Database Name], OBJECT_NAME(object_id, database_id) AS [Function Name], total_worker_time, execution_count, total_elapsed_time, @@ -1200,8 +1304,10 @@ ORDER BY total_worker_time DESC OPTION (RECOMPILE); ------ -- sys.dm_exec_function_stats (Transact-SQL) --- https://msdn.microsoft.com/en-US/library/mt429371.aspx +-- https://bit.ly/2q1Q6BM +-- Showplan Enhancements for UDFs +-- https://bit.ly/2LVqiQ1 -- Database specific queries ***************************************************************** @@ -1210,11 +1316,14 @@ ORDER BY total_worker_time DESC OPTION (RECOMPILE); --USE YourDatabaseName; -- make sure to change to an actual database on your instance, not the master system database --GO --- Individual File Sizes and space available for current database (Query 53) (File Sizes and Space) +-- Individual File Sizes and space available for current database (Query 51) (File Sizes and Space) SELECT f.name AS [File Name] , f.physical_name AS [Physical Name], CAST((f.size/128.0) AS DECIMAL(15,2)) AS [Total Size in MB], CAST(f.size/128.0 - CAST(FILEPROPERTY(f.name, 'SpaceUsed') AS int)/128.0 AS DECIMAL(15,2)) -AS [Available Space In MB], f.[file_id], fg.name AS [Filegroup Name], +AS [Available Space In MB], +CAST((f.size/128.0) AS DECIMAL(15,2)) - +CAST(f.size/128.0 - CAST(FILEPROPERTY(f.name, 'SpaceUsed') AS int)/128.0 AS DECIMAL(15,2)) AS [Used Space in MB], +f.[file_id], fg.name AS [Filegroup Name], f.is_percent_growth, f.growth, fg.is_default, fg.is_read_only, fg.is_autogrow_all_files FROM sys.database_files AS f WITH (NOLOCK) @@ -1229,10 +1338,10 @@ ORDER BY f.[file_id] OPTION (RECOMPILE); -- is_autogrow_all_files was new for SQL Server 2016. Equivalent to TF 1117 for user databases -- SQL Server 2016: Changes in default behavior for autogrow and allocations for tempdb and user databases --- http://bit.ly/2evRZSR +-- https://bit.ly/2evRZSR --- Log space usage for current database (Query 54) (Log Space Usage) +-- Log space usage for current database (Query 52) (Log Space Usage) SELECT DB_NAME(lsu.database_id) AS [Database Name], db.recovery_model_desc AS [Recovery Model], CAST(lsu.total_log_size_in_bytes/1048576.0 AS DECIMAL(10, 2)) AS [Total Log Space (MB)], CAST(lsu.used_log_space_in_bytes/1048576.0 AS DECIMAL(10, 2)) AS [Used Log Space (MB)], @@ -1247,10 +1356,13 @@ OPTION (RECOMPILE); -- Look at log file size and usage, along with the log reuse wait description for the current database +-- sys.dm_db_log_space_usage (Transact-SQL) +-- https://bit.ly/2H4MQw9 --- Status of last VLF for current database (Query 55) (Last VLF Status) + +-- Status of last VLF for current database (Query 53) (Last VLF Status) SELECT TOP(1) DB_NAME(li.database_id) AS [Database Name], li.[file_id], - li.vlf_size_mb, li.vlf_sequence_number, li.vlf_active, li.vlf_status + li.vlf_size_mb, li.vlf_sequence_number, li.vlf_active, li.vlf_status FROM sys.dm_db_log_info(DB_ID()) AS li ORDER BY vlf_sequence_number DESC OPTION (RECOMPILE); ------ @@ -1262,9 +1374,12 @@ ORDER BY vlf_sequence_number DESC OPTION (RECOMPILE); -- 1 is initialized but unused -- 2 is active +-- sys.dm_db_log_info (Transact-SQL) +-- https://bit.ly/2EQUU1v + --- Get database scoped configuration values for current database (Query 56) (Database-scoped Configurations) +-- Get database scoped configuration values for current database (Query 54) (Database-scoped Configurations) SELECT configuration_id, name, [value] AS [value_for_primary], value_for_secondary FROM sys.database_scoped_configurations WITH (NOLOCK) OPTION (RECOMPILE); ------ @@ -1275,22 +1390,22 @@ FROM sys.database_scoped_configurations WITH (NOLOCK) OPTION (RECOMPILE); -- ALTER DATABASE SCOPED CONFIGURATION CLEAR PROCEDURE_CACHE; -- ALTER DATABASE SCOPED CONFIGURATION (Transact-SQL) --- https://msdn.microsoft.com/en-us/library/mt629158.aspx +-- https://bit.ly/2sOH7nb --- I/O Statistics by file for the current database (Query 57) (IO Stats By File) +-- I/O Statistics by file for the current database (Query 55) (IO Stats By File) SELECT DB_NAME(DB_ID()) AS [Database Name], df.name AS [Logical Name], vfs.[file_id], df.type_desc, -df.physical_name AS [Physical Name], CAST(vfs.size_on_disk_bytes/1048576.0 AS DECIMAL(10, 2)) AS [Size on Disk (MB)], +df.physical_name AS [Physical Name], CAST(vfs.size_on_disk_bytes/1048576.0 AS DECIMAL(16, 2)) AS [Size on Disk (MB)], vfs.num_of_reads, vfs.num_of_writes, vfs.io_stall_read_ms, vfs.io_stall_write_ms, -CAST(100. * vfs.io_stall_read_ms/(vfs.io_stall_read_ms + vfs.io_stall_write_ms) AS DECIMAL(10,1)) AS [IO Stall Reads Pct], -CAST(100. * vfs.io_stall_write_ms/(vfs.io_stall_write_ms + vfs.io_stall_read_ms) AS DECIMAL(10,1)) AS [IO Stall Writes Pct], +CAST(100. * vfs.io_stall_read_ms/(vfs.io_stall_read_ms + vfs.io_stall_write_ms) AS DECIMAL(16,1)) AS [IO Stall Reads Pct], +CAST(100. * vfs.io_stall_write_ms/(vfs.io_stall_write_ms + vfs.io_stall_read_ms) AS DECIMAL(16,1)) AS [IO Stall Writes Pct], (vfs.num_of_reads + vfs.num_of_writes) AS [Writes + Reads], -CAST(vfs.num_of_bytes_read/1048576.0 AS DECIMAL(10, 2)) AS [MB Read], -CAST(vfs.num_of_bytes_written/1048576.0 AS DECIMAL(10, 2)) AS [MB Written], -CAST(100. * vfs.num_of_reads/(vfs.num_of_reads + vfs.num_of_writes) AS DECIMAL(10,1)) AS [# Reads Pct], -CAST(100. * vfs.num_of_writes/(vfs.num_of_reads + vfs.num_of_writes) AS DECIMAL(10,1)) AS [# Write Pct], -CAST(100. * vfs.num_of_bytes_read/(vfs.num_of_bytes_read + vfs.num_of_bytes_written) AS DECIMAL(10,1)) AS [Read Bytes Pct], -CAST(100. * vfs.num_of_bytes_written/(vfs.num_of_bytes_read + vfs.num_of_bytes_written) AS DECIMAL(10,1)) AS [Written Bytes Pct] +CAST(vfs.num_of_bytes_read/1048576.0 AS DECIMAL(16, 2)) AS [MB Read], +CAST(vfs.num_of_bytes_written/1048576.0 AS DECIMAL(16, 2)) AS [MB Written], +CAST(100. * vfs.num_of_reads/(vfs.num_of_reads + vfs.num_of_writes) AS DECIMAL(16,1)) AS [# Reads Pct], +CAST(100. * vfs.num_of_writes/(vfs.num_of_reads + vfs.num_of_writes) AS DECIMAL(16,1)) AS [# Write Pct], +CAST(100. * vfs.num_of_bytes_read/(vfs.num_of_bytes_read + vfs.num_of_bytes_written) AS DECIMAL(16,1)) AS [Read Bytes Pct], +CAST(100. * vfs.num_of_bytes_written/(vfs.num_of_bytes_read + vfs.num_of_bytes_written) AS DECIMAL(16,1)) AS [Written Bytes Pct] FROM sys.dm_io_virtual_file_stats(DB_ID(), NULL) AS vfs INNER JOIN sys.database_files AS df WITH (NOLOCK) ON vfs.[file_id]= df.[file_id] OPTION (RECOMPILE); @@ -1301,14 +1416,15 @@ ON vfs.[file_id]= df.[file_id] OPTION (RECOMPILE); --- Get most frequently executed queries for this database (Query 58) (Query Execution Counts) +-- Get most frequently executed queries for this database (Query 56) (Query Execution Counts) SELECT TOP(50) LEFT(t.[text], 50) AS [Short Query Text], qs.execution_count AS [Execution Count], qs.total_logical_reads AS [Total Logical Reads], qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], qs.total_worker_time AS [Total Worker Time], qs.total_worker_time/qs.execution_count AS [Avg Worker Time], qs.total_elapsed_time AS [Total Elapsed Time], -qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], qs.creation_time AS [Creation Time] --,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) @@ -1319,16 +1435,22 @@ ORDER BY qs.execution_count DESC OPTION (RECOMPILE); ------ --- Queries 57 through 62 are the "Bad Man List" for stored procedures --- Top Cached SPs By Execution Count (Query 59) (SP Execution Counts) -SELECT TOP(100) p.name AS [SP Name], qs.execution_count, +-- Queries 57 through 63 are the "Bad Man List" for stored procedures + +-- Top Cached SPs By Execution Count (Query 57) (SP Execution Counts) +SELECT TOP(100) p.name AS [SP Name], qs.execution_count AS [Execution Count], ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], -qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], qs.total_worker_time AS [TotalWorkerTime], -qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], -qs.cached_time +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 ORDER BY qs.execution_count DESC OPTION (RECOMPILE); @@ -1336,17 +1458,23 @@ ORDER BY qs.execution_count DESC OPTION (RECOMPILE); -- Tells you which cached stored procedures are called the most often -- This helps you characterize and baseline your workload +-- It also helps you find possible caching opportunities --- Top Cached SPs By Avg Elapsed Time (Query 60) (SP Avg Elapsed Time) +-- Top Cached SPs By Avg Elapsed Time (Query 58) (SP Avg Elapsed Time) SELECT TOP(25) p.name AS [SP Name], qs.min_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], qs.max_elapsed_time, qs.last_elapsed_time, qs.total_elapsed_time, qs.execution_count, ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], -qs.total_worker_time AS [TotalWorkerTime], qs.cached_time +qs.total_worker_time AS [TotalWorkerTime], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 ORDER BY avg_elapsed_time DESC OPTION (RECOMPILE); @@ -1357,15 +1485,19 @@ ORDER BY avg_elapsed_time DESC OPTION (RECOMPILE); --- Top Cached SPs By Total Worker time. Worker time relates to CPU cost (Query 61) (SP Worker Time) +-- Top Cached SPs By Total Worker time. Worker time relates to CPU cost (Query 59) (SP Worker Time) SELECT TOP(25) p.name AS [SP Name], qs.total_worker_time AS [TotalWorkerTime], qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], qs.execution_count, ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], -qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count -AS [avg_elapsed_time], qs.cached_time +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); @@ -1375,15 +1507,19 @@ ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); -- You should look at this if you see signs of CPU pressure --- Top Cached SPs By Total Logical Reads. Logical reads relate to memory pressure (Query 62) (SP Logical Reads) +-- Top Cached SPs By Total Logical Reads. Logical reads relate to memory pressure (Query 60) (SP Logical Reads) SELECT TOP(25) p.name AS [SP Name], qs.total_logical_reads AS [TotalLogicalReads], qs.total_logical_reads/qs.execution_count AS [AvgLogicalReads],qs.execution_count, ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], -qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count -AS [avg_elapsed_time], qs.cached_time +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE); @@ -1393,14 +1529,18 @@ ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE); -- You should look at this if you see signs of memory pressure --- Top Cached SPs By Total Physical Reads. Physical reads relate to disk read I/O pressure (Query 63) (SP Physical Reads) +-- Top Cached SPs By Total Physical Reads. Physical reads relate to disk read I/O pressure (Query 61) (SP Physical Reads) SELECT TOP(25) p.name AS [SP Name],qs.total_physical_reads AS [TotalPhysicalReads], qs.total_physical_reads/qs.execution_count AS [AvgPhysicalReads], qs.execution_count, -qs.total_logical_reads,qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count -AS [avg_elapsed_time], qs.cached_time +qs.total_logical_reads,qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND qs.total_physical_reads > 0 ORDER BY qs.total_physical_reads DESC, qs.total_logical_reads DESC OPTION (RECOMPILE); @@ -1411,16 +1551,20 @@ ORDER BY qs.total_physical_reads DESC, qs.total_logical_reads DESC OPTION (RECOM --- Top Cached SPs By Total Logical Writes (Query 64) (SP Logical Writes) +-- Top Cached SPs By Total Logical Writes (Query 62) (SP Logical Writes) -- Logical writes relate to both memory and disk I/O pressure SELECT TOP(25) p.name AS [SP Name], qs.total_logical_writes AS [TotalLogicalWrites], qs.total_logical_writes/qs.execution_count AS [AvgLogicalWrites], qs.execution_count, ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], -qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], -qs.cached_time +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan FROM sys.procedures AS p WITH (NOLOCK) INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.database_id = DB_ID() AND qs.total_logical_writes > 0 AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 @@ -1431,7 +1575,32 @@ ORDER BY qs.total_logical_writes DESC OPTION (RECOMPILE); -- You should look at this if you see signs of I/O pressure or of memory pressure --- Lists the top statements by average input/output usage for the current database (Query 65) (Top IO Statements) + +-- Cached SPs Missing Indexes by Execution Count (Query 63) (SP Missing Index) +SELECT TOP(25) p.name AS [SP Name], qs.execution_count AS [Execution Count], +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +AND CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' +ORDER BY qs.execution_count DESC OPTION (RECOMPILE); +------ + +-- This helps you find the most frequently executed cached stored procedures that have missing index warnings +-- This can often help you find index tuning candidates + + + +-- Lists the top statements by average input/output usage for the current database (Query 64) (Top IO Statements) SELECT TOP(50) OBJECT_NAME(qt.objectid, dbid) AS [SP Name], (qs.total_logical_reads + qs.total_logical_writes) /qs.execution_count AS [Avg IO], qs.execution_count AS [Execution Count], SUBSTRING(qt.[text],qs.statement_start_offset/2, @@ -1450,19 +1619,24 @@ ORDER BY [Avg IO] DESC OPTION (RECOMPILE); --- Possible Bad NC Indexes (writes > reads) (Query 66) (Bad NC Indexes) -SELECT OBJECT_NAME(s.[object_id]) AS [Table Name], i.name AS [Index Name], i.index_id, +-- Possible Bad NC Indexes (writes > reads) (Query 65) (Bad NC Indexes) +SELECT SCHEMA_NAME(o.[schema_id]) AS [Schema Name], +OBJECT_NAME(s.[object_id]) AS [Table Name], +i.name AS [Index Name], i.index_id, i.is_disabled, i.is_hypothetical, i.has_filter, i.fill_factor, -user_updates AS [Total Writes], user_seeks + user_scans + user_lookups AS [Total Reads], -user_updates - (user_seeks + user_scans + user_lookups) AS [Difference] +s.user_updates AS [Total Writes], s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], +s.user_updates - (s.user_seeks + s.user_scans + s.user_lookups) AS [Difference] FROM sys.dm_db_index_usage_stats AS s WITH (NOLOCK) INNER JOIN sys.indexes AS i WITH (NOLOCK) ON s.[object_id] = i.[object_id] AND i.index_id = s.index_id +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON i.[object_id] = o.[object_id] WHERE OBJECTPROPERTY(s.[object_id],'IsUserTable') = 1 AND s.database_id = DB_ID() -AND user_updates > (user_seeks + user_scans + user_lookups) -AND i.index_id > 1 +AND s.user_updates > (s.user_seeks + s.user_scans + s.user_lookups) +AND i.index_id > 1 AND i.[type_desc] = N'NONCLUSTERED' +AND i.is_primary_key = 0 AND i.is_unique_constraint = 0 AND i.is_unique = 0 ORDER BY [Difference] DESC, [Total Writes] DESC, [Total Reads] ASC OPTION (RECOMPILE); ------ @@ -1471,11 +1645,11 @@ ORDER BY [Difference] DESC, [Total Writes] DESC, [Total Reads] ASC OPTION (RECOM -- Investigate further before dropping an index! --- Missing Indexes for current database by Index Advantage (Query 67) (Missing Indexes) -SELECT DISTINCT CONVERT(decimal(18,2), user_seeks * avg_total_user_cost * (avg_user_impact * 0.01)) AS [index_advantage], +-- Missing Indexes for current database by Index Advantage (Query 66) (Missing Indexes) +SELECT DISTINCT CONVERT(decimal(18,2), migs.user_seeks * migs.avg_total_user_cost * (migs.avg_user_impact * 0.01)) AS [index_advantage], migs.last_user_seek, mid.[statement] AS [Database.Schema.Table], mid.equality_columns, mid.inequality_columns, mid.included_columns, -migs.unique_compiles, migs.user_seeks, migs.avg_total_user_cost, migs.avg_user_impact, +migs.user_seeks, migs.avg_total_user_cost, migs.avg_user_impact, OBJECT_NAME(mid.[object_id]) AS [Table Name], p.rows AS [Table Rows] FROM sys.dm_db_missing_index_group_stats AS migs WITH (NOLOCK) INNER JOIN sys.dm_db_missing_index_groups AS mig WITH (NOLOCK) @@ -1492,12 +1666,13 @@ ORDER BY index_advantage DESC OPTION (RECOMPILE); -- Look at index advantage, last user seek time, number of user seeks to help determine source and importance -- SQL Server is overly eager to add included columns, so beware -- Do not just blindly add indexes that show up from this query!!! +-- Hkan Winther has given me some great suggestions for this query --- Find missing index warnings for cached plans in the current database (Query 68) (Missing Index Warnings) +-- Find missing index warnings for cached plans in the current database (Query 67) (Missing Index Warnings) -- Note: This query could take some time on a busy instance SELECT TOP(25) OBJECT_NAME(objectid) AS [ObjectName], - cp.objtype, cp.usecounts, cp.size_in_bytes, query_plan + cp.objtype, cp.usecounts, cp.size_in_bytes, qp.query_plan FROM sys.dm_exec_cached_plans AS cp WITH (NOLOCK) CROSS APPLY sys.dm_exec_query_plan(cp.plan_handle) AS qp WHERE CAST(query_plan AS NVARCHAR(MAX)) LIKE N'%MissingIndex%' @@ -1509,9 +1684,10 @@ ORDER BY cp.usecounts DESC OPTION (RECOMPILE); -- This can help you decide whether to add them or not --- Breaks down buffers used by current database by object (table, index) in the buffer cache (Query 69) (Buffer Usage) +-- Breaks down buffers used by current database by object (table, index) in the buffer cache (Query 68) (Buffer Usage) -- Note: This query could take some time on a busy instance -SELECT OBJECT_NAME(p.[object_id]) AS [Object Name], p.index_id, +SELECT fg.name AS [Filegroup Name], SCHEMA_NAME(o.Schema_ID) AS [Schema Name], +OBJECT_NAME(p.[object_id]) AS [Object Name], p.index_id, CAST(COUNT(*)/128.0 AS DECIMAL(10, 2)) AS [Buffer size(MB)], COUNT(*) AS [BufferCount], p.[Rows] AS [Row Count], p.data_compression_desc AS [Compression Type] @@ -1520,12 +1696,19 @@ INNER JOIN sys.dm_os_buffer_descriptors AS b WITH (NOLOCK) ON a.allocation_unit_id = b.allocation_unit_id INNER JOIN sys.partitions AS p WITH (NOLOCK) ON a.container_id = p.hobt_id +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON p.object_id = o.object_id +INNER JOIN sys.database_files AS f WITH (NOLOCK) +ON b.file_id = f.file_id +INNER JOIN sys.filegroups AS fg WITH (NOLOCK) +ON f.data_space_id = fg.data_space_id WHERE b.database_id = CONVERT(int, DB_ID()) AND p.[object_id] > 100 AND OBJECT_NAME(p.[object_id]) NOT LIKE N'plan_%' AND OBJECT_NAME(p.[object_id]) NOT LIKE N'sys%' AND OBJECT_NAME(p.[object_id]) NOT LIKE N'xml_index_nodes%' -GROUP BY p.[object_id], p.index_id, p.data_compression_desc, p.[Rows] +GROUP BY fg.name, o.Schema_ID, p.[object_id], p.index_id, + p.data_compression_desc, p.[Rows] ORDER BY [BufferCount] DESC OPTION (RECOMPILE); ------ @@ -1533,29 +1716,32 @@ ORDER BY [BufferCount] DESC OPTION (RECOMPILE); -- It can help identify possible candidates for data compression --- Get Table names, row counts, and compression status for clustered index or heap (Query 70) (Table Sizes) -SELECT OBJECT_NAME(object_id) AS [ObjectName], -SUM(Rows) AS [RowCount], data_compression_desc AS [CompressionType] -FROM sys.partitions WITH (NOLOCK) +-- Get Table names, row counts, and compression status for clustered index or heap (Query 69) (Table Sizes) +SELECT SCHEMA_NAME(o.Schema_ID) AS [Schema Name], OBJECT_NAME(p.object_id) AS [ObjectName], +SUM(p.Rows) AS [RowCount], p.data_compression_desc AS [Compression Type] +FROM sys.partitions AS p WITH (NOLOCK) +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON p.object_id = o.object_id WHERE index_id < 2 --ignore the partitions from the non-clustered index if any -AND OBJECT_NAME(object_id) NOT LIKE N'sys%' -AND OBJECT_NAME(object_id) NOT LIKE N'queue_%' -AND OBJECT_NAME(object_id) NOT LIKE N'filestream_tombstone%' -AND OBJECT_NAME(object_id) NOT LIKE N'fulltext%' -AND OBJECT_NAME(object_id) NOT LIKE N'ifts_comp_fragment%' -AND OBJECT_NAME(object_id) NOT LIKE N'filetable_updates%' -AND OBJECT_NAME(object_id) NOT LIKE N'xml_index_nodes%' -AND OBJECT_NAME(object_id) NOT LIKE N'sqlagent_job%' -AND OBJECT_NAME(object_id) NOT LIKE N'plan_persist%' -GROUP BY object_id, data_compression_desc -ORDER BY SUM(Rows) DESC OPTION (RECOMPILE); +AND OBJECT_NAME(p.object_id) NOT LIKE N'sys%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'spt_%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'queue_%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'filestream_tombstone%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'fulltext%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'ifts_comp_fragment%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'filetable_updates%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'xml_index_nodes%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'sqlagent_job%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'plan_persist%' +GROUP BY SCHEMA_NAME(o.Schema_ID), p.object_id, data_compression_desc +ORDER BY SUM(p.Rows) DESC OPTION (RECOMPILE); ------ -- Gives you an idea of table sizes, and possible data compression opportunities --- Get some key table properties (Query 71) (Table Properties) +-- Get some key table properties (Query 70) (Table Properties) SELECT OBJECT_NAME(t.[object_id]) AS [ObjectName], p.[rows] AS [Table Rows], p.index_id, p.data_compression_desc AS [Index Data Compression], t.create_date, t.lock_on_bulk_load, t.is_replicated, t.has_replication_filter, @@ -1574,11 +1760,11 @@ ORDER BY OBJECT_NAME(t.[object_id]), p.index_id OPTION (RECOMPILE); -- temporal_type_desc, is_remote_data_archive_enabled, is_external were new in SQL Server 2016 -- sys.tables (Transact-SQL) --- https://msdn.microsoft.com/en-us/library/ms187406.aspx +-- https://bit.ly/2Gk7998 --- When were Statistics last updated on all indexes? (Query 72) (Statistics Update) +-- When were Statistics last updated on all indexes? (Query 71) (Statistics Update) SELECT SCHEMA_NAME(o.Schema_ID) + N'.' + o.[NAME] AS [Object Name], o.[type_desc] AS [Object Type], i.[name] AS [Index Name], STATS_DATE(i.[object_id], i.index_id) AS [Statistics Date], s.auto_created, s.no_recompute, s.user_created, s.is_incremental, s.is_temporary, @@ -1601,11 +1787,15 @@ ORDER BY STATS_DATE(i.[object_id], i.index_id) DESC OPTION (RECOMPILE); -- Also gives you an idea which indexes are the most active -- sys.stats (Transact-SQL) --- https://msdn.microsoft.com/en-us/library/ms177623.aspx +-- https://bit.ly/2GyAxrn + +-- UPDATEs to Statistics (Erin Stellato) +-- https://bit.ly/2vhrYQy --- Look at most frequently modified indexes and statistics (Query 73) (Volatile Indexes) + +-- Look at most frequently modified indexes and statistics (Query 72) (Volatile Indexes) SELECT o.[name] AS [Object Name], o.[object_id], o.[type_desc], s.[name] AS [Statistics Name], s.stats_id, s.no_recompute, s.auto_created, s.is_incremental, s.is_temporary, sp.modification_counter, sp.[rows], sp.rows_sampled, sp.last_updated @@ -1623,7 +1813,7 @@ ORDER BY sp.modification_counter DESC, o.name OPTION (RECOMPILE); --- Get fragmentation info for all indexes above a certain size in the current database (Query 74) (Index Fragmentation) +-- Get fragmentation info for all indexes above a certain size in the current database (Query 73) (Index Fragmentation) -- Note: This query could take some time on a very large database SELECT DB_NAME(ps.database_id) AS [Database Name], SCHEMA_NAME(o.[schema_id]) AS [Schema Name], OBJECT_NAME(ps.OBJECT_ID) AS [Object Name], i.[name] AS [Index Name], ps.index_id, @@ -1645,8 +1835,9 @@ ORDER BY ps.avg_fragmentation_in_percent DESC OPTION (RECOMPILE); -- and how effective your index maintenance strategy is ---- Index Read/Write stats (all tables in current DB) ordered by Reads (Query 75) (Overall Index Usage - Reads) -SELECT OBJECT_NAME(i.[object_id]) AS [ObjectName], i.[name] AS [IndexName], i.index_id, +--- Index Read/Write stats (all tables in current DB) ordered by Reads (Query 74) (Overall Index Usage - Reads) +SELECT SCHEMA_NAME(t.[schema_id]) AS [SchemaName], OBJECT_NAME(i.[object_id]) AS [ObjectName], + i.[name] AS [IndexName], i.index_id, s.user_seeks, s.user_scans, s.user_lookups, s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], s.user_updates AS [Writes], @@ -1657,6 +1848,8 @@ LEFT OUTER JOIN sys.dm_db_index_usage_stats AS s WITH (NOLOCK) ON i.[object_id] = s.[object_id] AND i.index_id = s.index_id AND s.database_id = DB_ID() +LEFT OUTER JOIN sys.tables AS t WITH (NOLOCK) +ON t.[object_id] = i.[object_id] WHERE OBJECTPROPERTY(i.[object_id],'IsUserTable') = 1 ORDER BY s.user_seeks + s.user_scans + s.user_lookups DESC OPTION (RECOMPILE); -- Order by reads ------ @@ -1664,8 +1857,9 @@ ORDER BY s.user_seeks + s.user_scans + s.user_lookups DESC OPTION (RECOMPILE); - -- Show which indexes in the current database are most active for Reads ---- Index Read/Write stats (all tables in current DB) ordered by Writes (Query 76) (Overall Index Usage - Writes) -SELECT OBJECT_NAME(i.[object_id]) AS [ObjectName], i.[name] AS [IndexName], i.index_id, +--- Index Read/Write stats (all tables in current DB) ordered by Writes (Query 75) (Overall Index Usage - Writes) +SELECT SCHEMA_NAME(t.[schema_id]) AS [SchemaName],OBJECT_NAME(i.[object_id]) AS [ObjectName], + i.[name] AS [IndexName], i.index_id, s.user_updates AS [Writes], s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], i.[type_desc] AS [Index Type], i.fill_factor AS [Fill Factor], i.has_filter, i.filter_definition, s.last_system_update, s.last_user_update @@ -1674,6 +1868,8 @@ LEFT OUTER JOIN sys.dm_db_index_usage_stats AS s WITH (NOLOCK) ON i.[object_id] = s.[object_id] AND i.index_id = s.index_id AND s.database_id = DB_ID() +LEFT OUTER JOIN sys.tables AS t WITH (NOLOCK) +ON t.[object_id] = i.[object_id] WHERE OBJECTPROPERTY(i.[object_id],'IsUserTable') = 1 ORDER BY s.user_updates DESC OPTION (RECOMPILE); -- Order by writes ------ @@ -1681,7 +1877,7 @@ ORDER BY s.user_updates DESC OPTION (RECOMPILE); -- Order by writes -- Show which indexes in the current database are most active for Writes --- Get in-memory OLTP index usage (Query 77) (XTP Index Usage) +-- Get in-memory OLTP index usage (Query 76) (XTP Index Usage) SELECT OBJECT_NAME(i.[object_id]) AS [Object Name], i.index_id, i.[name] AS [Index Name], i.[type_desc], xis.scans_started, xis.scans_retries, xis.rows_touched, xis.rows_returned @@ -1696,11 +1892,11 @@ ORDER BY OBJECT_NAME(i.[object_id]) OPTION (RECOMPILE); -- Returns no data if you are not using in-memory OLTP -- Guidelines for Using Indexes on Memory-Optimized Tables --- https://msdn.microsoft.com/en-us/library/dn133166.aspx +-- https://bit.ly/2GCP8lF --- Look at Columnstore index physical statistics (Query 78) (Columnstore Index Physical Stat) +-- Look at Columnstore index physical statistics (Query 77) (Columnstore Index Physical Stat) SELECT OBJECT_NAME(ps.object_id) AS [TableName], i.[name] AS [IndexName], ps.index_id, ps.partition_number, ps.delta_store_hobt_id, ps.state_desc, ps.total_rows, ps.size_in_bytes, @@ -1715,11 +1911,11 @@ ORDER BY ps.object_id, ps.partition_number, ps.row_group_id OPTION (RECOMPILE); ------ -- sys.dm_db_column_store_row_group_physical_stats (Transact-SQL) --- https://msdn.microsoft.com/en-us/library/dn832030.aspx +-- https://bit.ly/2q276XQ --- Get lock waits for current database (Query 79) (Lock Waits) +-- Get lock waits for current database (Query 78) (Lock Waits) SELECT o.name AS [table_name], i.name AS [index_name], ios.index_id, ios.partition_number, SUM(ios.row_lock_wait_count) AS [total_row_lock_waits], SUM(ios.row_lock_wait_in_ms) AS [total_row_lock_wait_in_ms], @@ -1742,10 +1938,11 @@ ORDER BY total_lock_wait_in_ms DESC OPTION (RECOMPILE); --- Look at UDF execution statistics (Query 80) (UDF Statistics) +-- Look at UDF execution statistics (Query 79) (UDF Statistics) SELECT OBJECT_NAME(object_id) AS [Function Name], execution_count, - total_worker_time, total_logical_reads, total_physical_reads, - total_elapsed_time, [type_desc] + total_worker_time, total_logical_reads, total_physical_reads, total_elapsed_time, + total_elapsed_time/execution_count AS [avg_elapsed_time], + FORMAT(cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] FROM sys.dm_exec_function_stats WITH (NOLOCK) WHERE database_id = DB_ID() ORDER BY total_worker_time DESC OPTION (RECOMPILE); @@ -1753,12 +1950,13 @@ ORDER BY total_worker_time DESC OPTION (RECOMPILE); -- New for SQL Server 2016 -- Helps you investigate scalar UDF performance issues +-- Does not return information for table valued functions -- sys.dm_exec_function_stats (Transact-SQL) --- https://msdn.microsoft.com/en-US/library/mt429371.aspx +-- https://bit.ly/2q1Q6BM --- Get QueryStore Options for this database (Query 81) (QueryStore Options) +-- Get QueryStore Options for this database (Query 80) (QueryStore Options) SELECT actual_state_desc, desired_state_desc, [interval_length_minutes], current_storage_size_mb, [max_storage_size_mb], query_capture_mode_desc, size_based_cleanup_mode_desc @@ -1766,55 +1964,17 @@ FROM sys.database_query_store_options WITH (NOLOCK) OPTION (RECOMPILE); ------ -- New for SQL Server 2016 +-- Requires that Query Store is enabled for this database --- Tuning Workload Performance with Query Store --- http://blogs.technet.com/b/dataplatforminsider/archive/2015/12/16/tuning-workload-performance-with-query-store.aspx - +-- Make sure that the actual_state_desc is the same as desired_state_desc +-- Make sure that the current_storage_size_mb is less than the max_storage_size_mb --- Get highest aggregate duration queries over last hour (Query 82) (High Aggregate Duration Queries) -WITH AggregatedDurationLastHour -AS -(SELECT q.query_id, SUM(count_executions * avg_duration) AS total_duration, - COUNT (distinct p.plan_id) AS number_of_plans - FROM sys.query_store_query_text AS qt WITH (NOLOCK) - INNER JOIN sys.query_store_query AS q WITH (NOLOCK) - ON qt.query_text_id = q.query_text_id - INNER JOIN sys.query_store_plan AS p WITH (NOLOCK) - ON q.query_id = p.query_id - INNER JOIN sys.query_store_runtime_stats AS rs WITH (NOLOCK) - ON rs.plan_id = p.plan_id - INNER JOIN sys.query_store_runtime_stats_interval AS rsi WITH (NOLOCK) - ON rsi.runtime_stats_interval_id = rs.runtime_stats_interval_id - WHERE rsi.start_time >= DATEADD(hour, -1, GETUTCDATE()) - AND rs.execution_type_desc = N'Regular' - GROUP BY q.query_id), -OrderedDuration AS -(SELECT query_id, total_duration, number_of_plans, - ROW_NUMBER () OVER (ORDER BY total_duration DESC, query_id) AS RN - FROM AggregatedDurationLastHour) -SELECT OBJECT_NAME(q.object_id) AS [Containing Object], qt.query_sql_text, -od.total_duration AS [Total Duration (microsecs)], -od.number_of_plans AS [Plan Count], -p.is_forced_plan, p.is_parallel_plan, p.is_trivial_plan, -q.query_parameterization_type_desc, p.[compatibility_level], -p.last_compile_start_time, q.last_execution_time, -CONVERT(xml, p.query_plan) AS query_plan_xml -FROM OrderedDuration AS od -INNER JOIN sys.query_store_query AS q WITH (NOLOCK) -ON q.query_id = od.query_id -INNER JOIN sys.query_store_query_text AS qt WITH (NOLOCK) -ON q.query_text_id = qt.query_text_id -INNER JOIN sys.query_store_plan AS p WITH (NOLOCK) -ON q.query_id = p.query_id -WHERE od.RN <= 50 -ORDER BY total_duration DESC OPTION (RECOMPILE); ------- +-- Tuning Workload Performance with Query Store +-- https://bit.ly/1kHSl7w --- New for SQL Server 2016 --- Requires that QueryStore is enabled for this database --- Get input buffer information for the current database (Query 83) (Input Buffer) +-- Get input buffer information for the current database (Query 81) (Input Buffer) SELECT es.session_id, DB_NAME(es.database_id) AS [Database Name], es.login_time, es.cpu_time, es.logical_reads, es.memory_usage, es.[status], ib.event_info AS [Input Buffer] @@ -1829,33 +1989,37 @@ AND es.session_id <> @@SPID OPTION (RECOMPILE); -- Replaces DBCC INPUTBUFFER -- New DMF for retrieving input buffer in SQL Server --- https://blogs.msdn.microsoft.com/sql_server_team/new-dmf-for-retrieving-input-buffer-in-sql-server/ +-- https://bit.ly/2uHKMbz +-- sys.dm_exec_input_buffer (Transact-SQL) +-- https://bit.ly/2J5Hf9q --- Get any resumable index rebuild operation information (Query 84) (Resumable Index Rebuild) + +-- Get any resumable index rebuild operation information (Query 82) (Resumable Index Rebuild) SELECT OBJECT_NAME(iro.object_id) AS [Object Name], iro.index_id, iro.name AS [Index Name], - iro.sql_text, iro.last_max_dop_used, iro.partition_number, iro.state_desc, iro.start_time, iro.percent_complete + iro.sql_text, iro.last_max_dop_used, iro.partition_number, iro.state_desc, + iro.start_time, iro.percent_complete FROM sys.index_resumable_operations AS iro WITH (NOLOCK) OPTION (RECOMPILE); ------ -- index_resumable_operations (Transact-SQL) --- https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-index-resumable-operations +-- https://bit.ly/2pYSWqq --- Get database automatic tuning options (Query 85) (Automatic Tuning Options) +-- Get database automatic tuning options (Query 83) (Automatic Tuning Options) SELECT [name], desired_state_desc, actual_state_desc, reason_desc FROM sys.database_automatic_tuning_options WITH (NOLOCK) OPTION (RECOMPILE); ------ -- sys.database_automatic_tuning_options (Transact-SQL) --- https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-database-automatic-tuning-options-transact-sql +-- https://bit.ly/2FHhLkL --- Look at recent Full backups for the current database (Query 86) (Recent Full Backups) +-- Look at recent Full backups for the current database (Query 84) (Recent Full Backups) SELECT TOP (30) bs.machine_name, bs.server_name, bs.database_name AS [Database Name], bs.recovery_model, CONVERT (BIGINT, bs.backup_size / 1048576 ) AS [Uncompressed Backup Size (MB)], CONVERT (BIGINT, bs.compressed_backup_size / 1048576 ) AS [Compressed Backup Size (MB)], @@ -1878,34 +2042,15 @@ ORDER BY bs.backup_finish_date DESC OPTION (RECOMPILE); -- Are you doing encrypted backups? -- Have you done any backup tuning with striped backups, or changing the parameters of the backup command? --- In SQL Server 2016, native SQL Server backup compression actually works much better with databases that are using TDE than in previous versions --- https://blogs.msdn.microsoft.com/sqlcat/2016/06/20/sqlsweet16-episode-1-backup-compression-for-tde-enabled-databases/ - - --- These three Pluralsight Courses go into more detail about how to run these queries and interpret the results +-- In SQL Server 2016, native SQL Server backup compression actually works +-- much better with databases that are using TDE than in previous versions +-- https://bit.ly/28Rpb2x --- SQL Server 2014 DMV Diagnostic Queries Part 1 --- https://www.pluralsight.com/courses/sql-server-2014-dmv-diagnostic-queries-part1 - --- SQL Server 2014 DMV Diagnostic Queries Part 2 --- https://www.pluralsight.com/courses/sql-server-2014-dmv-diagnostic-queries-part2 - --- SQL Server 2014 DMV Diagnostic Queries Part 3 --- https://www.pluralsight.com/courses/sql-server-2014-dmv-diagnostic-queries-part3 - - - --- Sign up for Microsoft Visual Studio Dev Essentials and get a free three month pass to Pluralsight -- Microsoft Visual Studio Dev Essentials --- http://bit.ly/1q6xbDL - - --- Sign up for Microsoft IT Pro Cloud Essentials and get lots of free Azure usage credits, MCP exam voucher, three month Pluralsight subscription +-- https://bit.ly/2qjNRxi --- Microsoft IT Pro Cloud Essentials --- http://bit.ly/2443SAd +-- Microsoft Azure Learn +-- https://bit.ly/2O0Hacc --- August 2017 blog series about upgrading and migrating SQL Server --- https://www.sqlskills.com/blogs/glenn/category/upgrading-sql-server/ diff --git a/Scripts/SQL Server 2019 Diagnostic Information Queries.sql b/Scripts/SQL Server 2019 Diagnostic Information Queries.sql new file mode 100644 index 00000000..ec3ec91a --- /dev/null +++ b/Scripts/SQL Server 2019 Diagnostic Information Queries.sql @@ -0,0 +1,2069 @@ + +-- SQL Server 2019 Diagnostic Information Queries +-- Glenn Berry +-- Last Modified: December 3, 2020 +-- https://glennsqlperformance.com/ +-- https://sqlserverperformance.wordpress.com/ +-- YouTube: https://bit.ly/2PkoAM1 +-- Twitter: GlennAlanBerry + +-- Diagnostic Queries are available here +-- https://glennsqlperformance.com/resources/ + + +-- Please make sure you are using the correct version of these diagnostic queries for your version of SQL Server + + +-- If you like PowerShell, there is a very useful community solution for running these queries in an automated fashion +-- https://dbatools.io/ + +-- Invoke-DbaDiagnosticQuery +-- https://dbatools.io/functions/invoke-dbadiagnosticquery/ + + +--****************************************************************************** +--* Copyright (C) 2020 Glenn Berry +--* All rights reserved. +--* +--* +--* You may alter this code for your own *non-commercial* purposes. You may +--* republish altered code as long as you include this copyright and give due credit. +--* +--* +--* THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF +--* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED +--* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +--* PARTICULAR PURPOSE. +--* +--****************************************************************************** + +-- Check the major product version to see if it is SQL Server 2019 CTP 2 or greater +IF NOT EXISTS (SELECT * WHERE CONVERT(varchar(128), SERVERPROPERTY('ProductVersion')) LIKE '15%') + BEGIN + DECLARE @ProductVersion varchar(128) = CONVERT(varchar(128), SERVERPROPERTY('ProductVersion')); + RAISERROR ('Script does not match the ProductVersion [%s] of this instance. Many of these queries may not work on this version.' , 18 , 16 , @ProductVersion); + END + ELSE + PRINT N'You have the correct major version of SQL Server for this diagnostic information script'; + + +-- Instance level queries ******************************* + +-- SQL and OS Version information for current instance (Query 1) (Version Info) +SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version Info]; +------ + +-- SQL Server 2019 Builds +-- Build Description Release Date URL to KB Article +-- 15.0.1000.34 CTP 2.0 9/24/2018 +-- 15.0.1100.94 CTP 2.1 11/7/2018 +-- 15.0.1200.24 CTP 2.2 12/6/2018 +-- 15.0.1300.359 CTP 2.3 3/1/2019 +-- 15.0.1400.75 CTP 2.4 3/26/2019 +-- 15.0.1500.28 CTP 2.5 4/23/2019 +-- 15.0.1600.8 CTP 3.0 5/22/2019 +-- 15.0.1700.37 CTP 3.1 6/26/2019 +-- 15.0.1800.32 CTP 3.2 7/24/2019 +-- 15.0.1900.25 RC1/RC1 Refresh 8/29/2019 +-- 15.0.2000.5 RTM 11/4/2019 +-- 15.0.2070.41 GDR1 11/4/2019 https://support.microsoft.com/en-us/help/4517790/servicing-update-for-sql-server-2019-rtm +-- 15.0.4003.23 CU1 1/7/2020 https://support.microsoft.com/en-us/help/4527376/cumulative-update-1-for-sql-server-2019 +-- 15.0.4013.40 CU2 2/13/2020 https://support.microsoft.com/en-us/help/4536075/cumulative-update-2-for-sql-server-2019 +-- 15.0.4023.6 CU3 3/12/2020 https://support.microsoft.com/en-us/help/4538853/cumulative-update-3-for-sql-server-2019 +-- 15.0.4033.1 CU4 3/31/2020 https://support.microsoft.com/en-us/help/4548597/cumulative-update-4-for-sql-server-2019 +-- 15.0.4043.16 CU5 6/22/2020 https://support.microsoft.com/en-us/help/4552255/cumulative-update-5-for-sql-server-2019 +-- 15.0.4053.23 CU6 8/4/2020 https://support.microsoft.com/en-us/help/4563110/cumulative-update-6-for-sql-server-2019 +-- 15.0.4063.15 CU7 9/2/2020 -- CU7 was removed by Microsoft +-- 15.0.4073.23 CU8 10/1/2020 https://support.microsoft.com/en-in/help/4577194/cumulative-update-8-for-sql-server-2019 + +-- Performance and Stability Fixes in SQL Server 2019 CU Builds +-- https://bit.ly/3712NQQ + +-- What's New in SQL Server 2019 (Database Engine) +-- https://bit.ly/2Q29fhz + +-- What's New in SQL Server 2019 +-- https://bit.ly/2PY442b + +-- Announcing the Modern Servicing Model for SQL Server +-- https://bit.ly/2KtJ8SS + +-- Update Center for Microsoft SQL Server +-- https://bit.ly/2pZptuQ + +-- Download SQL Server Management Studio (SSMS) +-- https://bit.ly/1OcupT9 + +-- Download and install Azure Data Studio +-- https://bit.ly/2vgke1A + +-- SQL Server 2019 Configuration Manager is SQLServerManager15.msc + + +-- Get socket, physical core and logical core count from the SQL Server Error log. (Query 2) (Core Counts) +-- This query might take a few seconds depending on the size of your error log +EXEC sys.xp_readerrorlog 0, 1, N'detected', N'socket'; +------ + +-- This can help you determine the exact core counts used by SQL Server and whether HT is enabled or not +-- It can also help you confirm your SQL Server licensing model +-- Be on the lookout for this message "using 40 logical processors based on SQL Server licensing" +-- (when you have more than 40 logical cores) which means grandfathered Server/CAL licensing +-- This query will return no results if your error log has been recycled since the instance was last started + + + +-- Get selected server properties (Query 3) (Server Properties) +SELECT SERVERPROPERTY('MachineName') AS [MachineName], +SERVERPROPERTY('ServerName') AS [ServerName], +SERVERPROPERTY('InstanceName') AS [Instance], +SERVERPROPERTY('IsClustered') AS [IsClustered], +SERVERPROPERTY('ComputerNamePhysicalNetBIOS') AS [ComputerNamePhysicalNetBIOS], +SERVERPROPERTY('Edition') AS [Edition], +SERVERPROPERTY('ProductLevel') AS [ProductLevel], -- What servicing branch (RTM/SP/CU) +SERVERPROPERTY('ProductUpdateLevel') AS [ProductUpdateLevel], -- Within a servicing branch, what CU# is applied +SERVERPROPERTY('ProductVersion') AS [ProductVersion], +SERVERPROPERTY('ProductMajorVersion') AS [ProductMajorVersion], +SERVERPROPERTY('ProductMinorVersion') AS [ProductMinorVersion], +SERVERPROPERTY('ProductBuild') AS [ProductBuild], +SERVERPROPERTY('ProductBuildType') AS [ProductBuildType], -- Is this a GDR or OD hotfix (NULL if on a CU build) +SERVERPROPERTY('ProductUpdateReference') AS [ProductUpdateReference], -- KB article number that is applicable for this build +SERVERPROPERTY('ProcessID') AS [ProcessID], +SERVERPROPERTY('Collation') AS [Collation], +SERVERPROPERTY('IsFullTextInstalled') AS [IsFullTextInstalled], +SERVERPROPERTY('IsIntegratedSecurityOnly') AS [IsIntegratedSecurityOnly], +SERVERPROPERTY('FilestreamConfiguredLevel') AS [FilestreamConfiguredLevel], +SERVERPROPERTY('IsHadrEnabled') AS [IsHadrEnabled], +SERVERPROPERTY('HadrManagerStatus') AS [HadrManagerStatus], +SERVERPROPERTY('InstanceDefaultDataPath') AS [InstanceDefaultDataPath], +SERVERPROPERTY('InstanceDefaultLogPath') AS [InstanceDefaultLogPath], +SERVERPROPERTY('ErrorLogFileName') AS [ErrorLogFileName], +SERVERPROPERTY('BuildClrVersion') AS [Build CLR Version], +SERVERPROPERTY('IsXTPSupported') AS [IsXTPSupported], +SERVERPROPERTY('IsPolybaseInstalled') AS [IsPolybaseInstalled], +SERVERPROPERTY('IsAdvancedAnalyticsInstalled') AS [IsRServicesInstalled], +SERVERPROPERTY('IsTempdbMetadataMemoryOptimized') AS [IsTempdbMetadataMemoryOptimized]; +------ + +-- This gives you a lot of useful information about your instance of SQL Server, +-- such as the ProcessID for SQL Server and your collation +-- Note: Some columns will be NULL on older SQL Server builds + +-- SERVERPROPERTY('IsTempdbMetadataMemoryOptimized') is a new option for SQL Server 2019 + +-- SERVERPROPERTY (Transact-SQL) +-- https://bit.ly/2eeaXeI + + + +-- Get instance-level configuration values for instance (Query 4) (Configuration Values) +SELECT name, value, value_in_use, minimum, maximum, [description], is_dynamic, is_advanced +FROM sys.configurations WITH (NOLOCK) +ORDER BY name OPTION (RECOMPILE); +------ + +-- Focus on these settings: +-- automatic soft-NUMA disabled (should be 0 in most cases) +-- backup checksum default (should be 1) +-- backup compression default (should be 1 in most cases) +-- clr enabled (only enable if it is needed) +-- cost threshold for parallelism (depends on your workload) +-- lightweight pooling (should be zero) +-- max degree of parallelism (depends on your workload and hardware) +-- max server memory (MB) (set to an appropriate value, not the default) +-- optimize for ad hoc workloads (should be 1) +-- priority boost (should be zero) +-- remote admin connections (should be 1) +-- tempdb metadata memory-optimized (0 by default, some workloads may benefit by enabling) + +-- sys.configurations (Transact-SQL) +-- https://bit.ly/2HsyDZI + + +-- Returns a list of all global trace flags that are enabled (Query 5) (Global Trace Flags) +DBCC TRACESTATUS (-1); +------ + +-- If no global trace flags are enabled, no results will be returned. +-- It is very useful to know what global trace flags are currently enabled as part of the diagnostic process. + +-- Common trace flags that should be enabled in most cases +-- TF 3226 - Supresses logging of successful database backup messages to the SQL Server Error Log +-- https://bit.ly/38zDNAK + +-- TF 6534 - Enables use of native code to improve performance with spatial data +-- https://bit.ly/2HrQUpU + +-- TF 7745 - Prevents Query Store data from being written to disk in case of a failover or shutdown command +-- https://bit.ly/2GU69Km + + +-- DBCC TRACEON - Trace Flags (Transact-SQL) +-- https://bit.ly/2FuSvPg + + + +-- SQL Server Process Address space info (Query 6) (Process Memory) +-- (shows whether locked pages is enabled, among other things) +SELECT physical_memory_in_use_kb/1024 AS [SQL Server Memory Usage (MB)], + locked_page_allocations_kb/1024 AS [SQL Server Locked Pages Allocation (MB)], + large_page_allocations_kb/1024 AS [SQL Server Large Pages Allocation (MB)], + page_fault_count, memory_utilization_percentage, available_commit_limit_kb, + process_physical_memory_low, process_virtual_memory_low +FROM sys.dm_os_process_memory WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- You want to see 0 for process_physical_memory_low +-- You want to see 0 for process_virtual_memory_low +-- This indicates that you are not under internal memory pressure +-- If locked_page_allocations_kb > 0, then LPIM is enabled + +-- sys.dm_os_process_memory (Transact-SQL) +-- https://bit.ly/3iUgQgC + +-- How to enable the "locked pages" feature in SQL Server 2012 +-- https://bit.ly/2F5UjOA + +-- Memory Management Architecture Guide +-- https://bit.ly/2JKkadC + + + +-- SQL Server Services information (Query 7) (SQL Server Services Info) +SELECT servicename, process_id, startup_type_desc, status_desc, +last_startup_time, service_account, is_clustered, cluster_nodename, [filename], +instant_file_initialization_enabled +FROM sys.dm_server_services WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- Tells you the account being used for the SQL Server Service and the SQL Agent Service +-- Shows the process_id, when they were last started, and their current status +-- Also shows whether you are running on a failover cluster instance, and what node you are running on +-- Also shows whether IFI is enabled + +-- sys.dm_server_services (Transact-SQL) +-- https://bit.ly/2oKa1Un + + +-- Last backup information by database (Query 8) (Last Backup By Database) +SELECT ISNULL(d.[name], bs.[database_name]) AS [Database], d.recovery_model_desc AS [Recovery Model], + d.log_reuse_wait_desc AS [Log Reuse Wait Desc], + MAX(CASE WHEN [type] = 'D' THEN bs.backup_finish_date ELSE NULL END) AS [Last Full Backup], + MAX(CASE WHEN [type] = 'D' THEN bmf.physical_device_name ELSE NULL END) AS [Last Full Backup Location], + MAX(CASE WHEN [type] = 'I' THEN bs.backup_finish_date ELSE NULL END) AS [Last Differential Backup], + MAX(CASE WHEN [type] = 'I' THEN bmf.physical_device_name ELSE NULL END) AS [Last Differential Backup Location], + MAX(CASE WHEN [type] = 'L' THEN bs.backup_finish_date ELSE NULL END) AS [Last Log Backup], + MAX(CASE WHEN [type] = 'L' THEN bmf.physical_device_name ELSE NULL END) AS [Last Log Backup Location] +FROM sys.databases AS d WITH (NOLOCK) +LEFT OUTER JOIN msdb.dbo.backupset AS bs WITH (NOLOCK) +ON bs.[database_name] = d.[name] +LEFT OUTER JOIN msdb.dbo.backupmediafamily AS bmf WITH (NOLOCK) +ON bs.media_set_id = bmf.media_set_id +AND bs.backup_finish_date > GETDATE()- 30 +WHERE d.name <> N'tempdb' +GROUP BY ISNULL(d.[name], bs.[database_name]), d.recovery_model_desc, d.log_reuse_wait_desc, d.[name] +ORDER BY d.recovery_model_desc, d.[name] OPTION (RECOMPILE); +------ + +-- This helps you spot runaway transaction logs and other issues with your backup schedule + + +-- Get SQL Server Agent jobs and Category information (Query 9) (SQL Server Agent Jobs) +SELECT sj.name AS [Job Name], sj.[description] AS [Job Description], SUSER_SNAME(sj.owner_sid) AS [Job Owner], +sj.date_created AS [Date Created], sj.[enabled] AS [Job Enabled], +sj.notify_email_operator_id, sj.notify_level_email, sc.name AS [CategoryName], +s.[enabled] AS [Sched Enabled], js.next_run_date, js.next_run_time +FROM msdb.dbo.sysjobs AS sj WITH (NOLOCK) +INNER JOIN msdb.dbo.syscategories AS sc WITH (NOLOCK) +ON sj.category_id = sc.category_id +LEFT OUTER JOIN msdb.dbo.sysjobschedules AS js WITH (NOLOCK) +ON sj.job_id = js.job_id +LEFT OUTER JOIN msdb.dbo.sysschedules AS s WITH (NOLOCK) +ON js.schedule_id = s.schedule_id +ORDER BY sj.name OPTION (RECOMPILE); +------ + +-- Gives you some basic information about your SQL Server Agent jobs, who owns them and how they are configured +-- Look for Agent jobs that are not owned by sa +-- Look for jobs that have a notify_email_operator_id set to 0 (meaning no operator) +-- Look for jobs that have a notify_level_email set to 0 (meaning no e-mail is ever sent) +-- +-- MSDN sysjobs documentation +-- https://bit.ly/2paDEOP + +-- SQL Server Maintenance Solution (Ola Hallengren) +-- https://bit.ly/1pgchQu + +-- You can use this script to add default schedules to the standard Ola Hallengren Maintenance Solution jobs +-- https://bit.ly/3ane0gN + + +-- Get SQL Server Agent Alert Information (Query 10) (SQL Server Agent Alerts) +SELECT name, event_source, message_id, severity, [enabled], has_notification, + delay_between_responses, occurrence_count, last_occurrence_date, last_occurrence_time +FROM msdb.dbo.sysalerts WITH (NOLOCK) +ORDER BY name OPTION (RECOMPILE); +------ + +-- Gives you some basic information about your SQL Server Agent Alerts +-- (which are different from SQL Server Agent jobs) +-- Read more about Agent Alerts here: https://bit.ly/2v5YR37 + + + +-- Host information (Query 11) (Host Info) +SELECT host_platform, host_distribution, host_release, + host_service_pack_level, host_sku, os_language_version +FROM sys.dm_os_host_info WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- host_release codes (only valid for Windows) +-- 10.0 is either Windows 10 or Windows Server 2016 +-- 6.3 is either Windows 8.1 or Windows Server 2012 R2 +-- 6.2 is either Windows 8 or Windows Server 2012 + + +-- host_sku codes (only valid for Windows) +-- 4 is Enterprise Edition +-- 7 is Standard Server Edition +-- 8 is Datacenter Server Edition +-- 10 is Enterprise Server Edition +-- 48 is Professional Edition +-- 161 is Pro for Workstations + +-- 1033 for os_language_version is US-English + +-- SQL Server 2019 requires Windows Server 2016 or newer + +-- Hardware and Software Requirements for Installing SQL Server +-- https://bit.ly/2y3ka5L + +-- Using SQL Server in Windows 8 and later versions of Windows operating system +-- https://bit.ly/2F7Ax0P + + +-- SQL Server NUMA Node information (Query 12) (SQL Server NUMA Info) +SELECT node_id, node_state_desc, memory_node_id, processor_group, cpu_count, online_scheduler_count, + idle_scheduler_count, active_worker_count, avg_load_balance, resource_monitor_state +FROM sys.dm_os_nodes WITH (NOLOCK) +WHERE node_state_desc <> N'ONLINE DAC' OPTION (RECOMPILE); +------ + +-- Gives you some useful information about the composition and relative load on your NUMA nodes +-- You want to see an equal number of schedulers on each NUMA node +-- Watch out if SQL Server 2019 Standard Edition has been installed +-- on a physical or virtual machine with more than four sockets or more than 24 physical cores + +-- sys.dm_os_nodes (Transact-SQL) +-- https://bit.ly/2pn5Mw8 + +-- How to Balance SQL Server Core Licenses Across NUMA Nodes +-- https://bit.ly/3i4TyVR + + + +-- Good basic information about OS memory amounts and state (Query 13) (System Memory) +SELECT total_physical_memory_kb/1024 AS [Physical Memory (MB)], + available_physical_memory_kb/1024 AS [Available Memory (MB)], + total_page_file_kb/1024 AS [Page File Commit Limit (MB)], + total_page_file_kb/1024 - total_physical_memory_kb/1024 AS [Physical Page File Size (MB)], + available_page_file_kb/1024 AS [Available Page File (MB)], + system_cache_kb/1024 AS [System Cache (MB)], + system_memory_state_desc AS [System Memory State] +FROM sys.dm_os_sys_memory WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- You want to see "Available physical memory is high" for System Memory State +-- This indicates that you are not under external memory pressure + +-- Possible System Memory State values: +-- Available physical memory is high +-- Physical memory usage is steady +-- Available physical memory is low +-- Available physical memory is running low +-- Physical memory state is transitioning + +-- sys.dm_os_sys_memory (Transact-SQL) +-- https://bit.ly/2pcV0xq + + + +-- You can skip the next two queries if you know you don't have a clustered instance + + +-- Get information about your cluster nodes and their status (Query 14) (Cluster Node Properties) +-- (if your database server is in a failover cluster) +SELECT NodeName, status_description, is_current_owner +FROM sys.dm_os_cluster_nodes WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- Knowing which node owns the cluster resources is critical +-- Especially when you are installing Windows or SQL Server updates +-- You will see no results if your instance is not clustered + +-- Recommended hotfixes and updates for Windows Server 2012 R2-based failover clusters +-- https://bit.ly/1z5BfCw + + +-- Get information about any AlwaysOn AG cluster this instance is a part of (Query 15) (AlwaysOn AG Cluster) +SELECT cluster_name, quorum_type_desc, quorum_state_desc +FROM sys.dm_hadr_cluster WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- You will see no results if your instance is not using AlwaysOn AGs + + +-- Good overview of AG health and status (Query 16) (AG Status) +SELECT ag.name AS [AG Name], ar.replica_server_name, ar.availability_mode_desc, adc.[database_name], + drs.is_local, drs.is_primary_replica, drs.synchronization_state_desc, drs.is_commit_participant, + drs.synchronization_health_desc, drs.recovery_lsn, drs.truncation_lsn, drs.last_sent_lsn, + drs.last_sent_time, drs.last_received_lsn, drs.last_received_time, drs.last_hardened_lsn, + drs.last_hardened_time, drs.last_redone_lsn, drs.last_redone_time, drs.log_send_queue_size, + drs.log_send_rate, drs.redo_queue_size, drs.redo_rate, drs.filestream_send_rate, + drs.end_of_log_lsn, drs.last_commit_lsn, drs.last_commit_time, drs.database_state_desc +FROM sys.dm_hadr_database_replica_states AS drs WITH (NOLOCK) +INNER JOIN sys.availability_databases_cluster AS adc WITH (NOLOCK) +ON drs.group_id = adc.group_id +AND drs.group_database_id = adc.group_database_id +INNER JOIN sys.availability_groups AS ag WITH (NOLOCK) +ON ag.group_id = drs.group_id +INNER JOIN sys.availability_replicas AS ar WITH (NOLOCK) +ON drs.group_id = ar.group_id +AND drs.replica_id = ar.replica_id +ORDER BY ag.name, ar.replica_server_name, adc.[database_name] OPTION (RECOMPILE); + +-- You will see no results if your instance is not using AlwaysOn AGs + +-- SQL Server 2016 It Just Runs Faster: Always On Availability Groups Turbocharged +-- https://bit.ly/2dn1H6r + + +-- Hardware information from SQL Server 2019 (Query 17) (Hardware Info) +SELECT cpu_count AS [Logical CPU Count], scheduler_count, + (socket_count * cores_per_socket) AS [Physical Core Count], + socket_count AS [Socket Count], cores_per_socket, numa_node_count, + physical_memory_kb/1024 AS [Physical Memory (MB)], + max_workers_count AS [Max Workers Count], + affinity_type_desc AS [Affinity Type], + sqlserver_start_time AS [SQL Server Start Time], + DATEDIFF(hour, sqlserver_start_time, GETDATE()) AS [SQL Server Up Time (hrs)], + virtual_machine_type_desc AS [Virtual Machine Type], + softnuma_configuration_desc AS [Soft NUMA Configuration], + sql_memory_model_desc, + container_type_desc -- New in SQL Server 2019 +FROM sys.dm_os_sys_info WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- Gives you some good basic hardware information about your database server +-- Note: virtual_machine_type_desc of HYPERVISOR does not automatically mean you are running SQL Server inside of a VM +-- It merely indicates that you have a hypervisor running on your host + +-- sys.dm_os_sys_info (Transact-SQL) +-- https://bit.ly/2pczOYs + +-- Soft NUMA configuration was a new column for SQL Server 2016 +-- OFF = Soft-NUMA feature is OFF +-- ON = SQL Server automatically determines the NUMA node sizes for Soft-NUMA +-- MANUAL = Manually configured soft-NUMA + +-- Configure SQL Server to Use Soft-NUMA (SQL Server) +-- https://bit.ly/2HTpKJt + +-- sql_memory_model_desc values (Added in SQL Server 2016 SP1) +-- CONVENTIONAL +-- LOCK_PAGES +-- LARGE_PAGES + + +-- Get System Manufacturer and model number from SQL Server Error log (Query 18) (System Manufacturer) +EXEC sys.xp_readerrorlog 0, 1, N'Manufacturer'; +------ + +-- This can help you determine the capabilities and capacities of your database server +-- Can also be used to confirm if you are running in a VM +-- This query might take a few seconds if you have not recycled your error log recently +-- This query will return no results if your error log has been recycled since the instance was started + + +-- Get BIOS date from Windows Registry (Query 19) (BIOS Date) +EXEC sys.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'HARDWARE\DESCRIPTION\System\BIOS', N'BiosReleaseDate'; +------ + +-- Helps you understand whether the main system BIOS is up to date, and the possible age of the hardware +-- Not as useful for virtualization +-- Does not work on Linux + + +-- Get processor description from Windows Registry (Query 20) (Processor Description) +EXEC sys.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'HARDWARE\DESCRIPTION\System\CentralProcessor\0', N'ProcessorNameString'; +------ + +-- Gives you the model number and rated clock speed of your processor(s) +-- Your processors may be running at less than the rated clock speed due +-- to the Windows Power Plan or hardware power management +-- Does not work on Linux + +-- You can use CPU-Z to get your actual CPU core speed and a lot of other useful information +-- https://bit.ly/QhR6xF + +-- You can learn more about processor selection for SQL Server by following this link +-- https://bit.ly/2F3aVlP + + + + +-- Get information on location, time and size of any memory dumps from SQL Server (Query 21) (Memory Dump Info) +SELECT [filename], creation_time, size_in_bytes/1048576.0 AS [Size (MB)] +FROM sys.dm_server_memory_dumps WITH (NOLOCK) +ORDER BY creation_time DESC OPTION (RECOMPILE); +------ + +-- This will not return any rows if you have +-- not had any memory dumps (which is a good thing) + +-- sys.dm_server_memory_dumps (Transact-SQL) +-- https://bit.ly/2elwWll + + + +-- Look at Suspect Pages table (Query 22) (Suspect Pages) +SELECT DB_NAME(database_id) AS [Database Name], [file_id], page_id, + event_type, error_count, last_update_date +FROM msdb.dbo.suspect_pages WITH (NOLOCK) +ORDER BY database_id OPTION (RECOMPILE); +------ + +-- event_type value descriptions +-- 1 = 823 error caused by an operating system CRC error +-- or 824 error other than a bad checksum or a torn page (for example, a bad page ID) +-- 2 = Bad checksum +-- 3 = Torn page +-- 4 = Restored (The page was restored after it was marked bad) +-- 5 = Repaired (DBCC repaired the page) +-- 7 = Deallocated by DBCC + +-- Ideally, this query returns no results. The table is limited to 1000 rows. +-- If you do get results here, you should do further investigation to determine the root cause + +-- Manage the suspect_pages Table +-- https://bit.ly/2Fvr1c9 + + +-- Read most recent entries from all SQL Server Error Logs (Query 23) (Error Log Entries) +DROP TABLE IF EXISTS #ErrorLogFiles; + CREATE TABLE #ErrorLogFiles + ([Archive #] INT,[Date] NVARCHAR(25),[Log File Size (Byte)]INT) + +INSERT INTO #ErrorLogFiles +([Archive #],[Date],[Log File Size (Byte)]) +EXEC master.sys.xp_enumerrorlogs; + +DROP TABLE IF EXISTS #SQLErrorLog_AllLogs; + CREATE TABLE #SQLErrorLog_AllLogs + (LogDate DATETIME ,ProcessInfo NVARCHAR(12), LogText NVARCHAR(4000)) + +DECLARE @i INT = 0; +DECLARE @sql NVARCHAR(200) = N''; +DECLARE @logCount INT = (SELECT COUNT(*) FROM #ErrorLogFiles); + +WHILE (@i < @logCount) + BEGIN + SET @sql = 'INSERT INTO #SQLErrorLog_AllLogs + (LogDate, ProcessInfo, LogText) + EXEC master.sys.sp_readerrorlog ' + CAST(@i AS NVARCHAR(2)) + N';' + EXEC master.sys.sp_executesql @sql; + SET @i += 1; + END + +SELECT TOP(1000)LogDate, ProcessInfo, LogText +FROM #SQLErrorLog_AllLogs WITH (NOLOCK) +ORDER BY LogDate DESC OPTION (RECOMPILE); + +DROP TABLE IF EXISTS #ErrorLogFiles; +DROP TABLE IF EXISTS #SQLErrorLog_AllLogs; +GO + + +-- Get number of data files in tempdb database (Query 24) (TempDB Data Files) +EXEC sys.xp_readerrorlog 0, 1, N'The tempdb database has'; +------ + +-- Get the number of data files in the tempdb database +-- 4-8 data files that are all the same size is a good starting point +-- This query will return no results if your error log has been recycled since the instance was last started + + +-- File names and paths for all user and system databases on instance (Query 25) (Database Filenames and Paths) +SELECT DB_NAME([database_id]) AS [Database Name], + [file_id], [name], physical_name, [type_desc], state_desc, + is_percent_growth, growth, + CONVERT(bigint, growth/128.0) AS [Growth in MB], + CONVERT(bigint, size/128.0) AS [Total Size in MB], max_size +FROM sys.master_files WITH (NOLOCK) +ORDER BY DB_NAME([database_id]), [file_id] OPTION (RECOMPILE); +------ + +-- Things to look at: +-- Are data files and log files on different drives? +-- Is everything on the C: drive? +-- Is tempdb on dedicated drives? +-- Is there only one tempdb data file? +-- Are all of the tempdb data files the same size? +-- Are there multiple data files for user databases? +-- Is percent growth enabled for any files (which is bad)? + + +-- Drive information for all fixed drives visible to the operating system (Query 26) (Fixed Drives) +SELECT fixed_drive_path, drive_type_desc, +CONVERT(DECIMAL(18,2), free_space_in_bytes/1073741824.0) AS [Available Space (GB)] +FROM sys.dm_os_enumerate_fixed_drives WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- This shows all of your drives, not just LUNs with SQL Server database files +-- New in SQL Server 2017 + +-- sys.dm_os_enumerate_fixed_drives (Transact-SQL) +-- https://bit.ly/2EZoHLj + + + +-- Volume info for all LUNS that have database files on the current instance (Query 27) (Volume Info) +SELECT DISTINCT vs.volume_mount_point, vs.file_system_type, vs.logical_volume_name, +CONVERT(DECIMAL(18,2), vs.total_bytes/1073741824.0) AS [Total Size (GB)], +CONVERT(DECIMAL(18,2), vs.available_bytes/1073741824.0) AS [Available Size (GB)], +CONVERT(DECIMAL(18,2), vs.available_bytes * 1. / vs.total_bytes * 100.) AS [Space Free %], +vs.supports_compression, vs.is_compressed, +vs.supports_sparse_files, vs.supports_alternate_streams +FROM sys.master_files AS f WITH (NOLOCK) +CROSS APPLY sys.dm_os_volume_stats(f.database_id, f.[file_id]) AS vs +ORDER BY vs.volume_mount_point OPTION (RECOMPILE); +------ + +-- Shows you the total and free space on the LUNs where you have database files +-- Being low on free space can negatively affect performance + +-- sys.dm_os_volume_stats (Transact-SQL) +-- https://bit.ly/2oBPNNr + + + +-- Drive level latency information (Query 28) (Drive Level Latency) +SELECT tab.[Drive], tab.volume_mount_point AS [Volume Mount Point], + CASE + WHEN num_of_reads = 0 THEN 0 + ELSE (io_stall_read_ms/num_of_reads) + END AS [Read Latency], + CASE + WHEN num_of_writes = 0 THEN 0 + ELSE (io_stall_write_ms/num_of_writes) + END AS [Write Latency], + CASE + WHEN (num_of_reads = 0 AND num_of_writes = 0) THEN 0 + ELSE (io_stall/(num_of_reads + num_of_writes)) + END AS [Overall Latency], + CASE + WHEN num_of_reads = 0 THEN 0 + ELSE (num_of_bytes_read/num_of_reads) + END AS [Avg Bytes/Read], + CASE + WHEN num_of_writes = 0 THEN 0 + ELSE (num_of_bytes_written/num_of_writes) + END AS [Avg Bytes/Write], + CASE + WHEN (num_of_reads = 0 AND num_of_writes = 0) THEN 0 + ELSE ((num_of_bytes_read + num_of_bytes_written)/(num_of_reads + num_of_writes)) + END AS [Avg Bytes/Transfer] +FROM (SELECT LEFT(UPPER(mf.physical_name), 2) AS Drive, SUM(num_of_reads) AS num_of_reads, + SUM(io_stall_read_ms) AS io_stall_read_ms, SUM(num_of_writes) AS num_of_writes, + SUM(io_stall_write_ms) AS io_stall_write_ms, SUM(num_of_bytes_read) AS num_of_bytes_read, + SUM(num_of_bytes_written) AS num_of_bytes_written, SUM(io_stall) AS io_stall, vs.volume_mount_point + FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS vfs + INNER JOIN sys.master_files AS mf WITH (NOLOCK) + ON vfs.database_id = mf.database_id AND vfs.file_id = mf.file_id + CROSS APPLY sys.dm_os_volume_stats(mf.database_id, mf.[file_id]) AS vs + GROUP BY LEFT(UPPER(mf.physical_name), 2), vs.volume_mount_point) AS tab +ORDER BY [Overall Latency] OPTION (RECOMPILE); +------ + +-- Shows you the drive-level latency for reads and writes, in milliseconds +-- Latency above 30-40ms is usually a problem +-- These latency numbers include all file activity against all SQL Server +-- database files on each drive since SQL Server was last started + +-- sys.dm_io_virtual_file_stats (Transact-SQL) +-- https://bit.ly/3bRWUc0 + +-- sys.dm_os_volume_stats (Transact-SQL) +-- https://bit.ly/33thz2j + + +-- Calculates average latency per read, per write, and per total input/output for each database file (Query 29) (IO Latency by File) +SELECT DB_NAME(fs.database_id) AS [Database Name], CAST(fs.io_stall_read_ms/(1.0 + fs.num_of_reads) AS NUMERIC(10,1)) AS [avg_read_latency_ms], +CAST(fs.io_stall_write_ms/(1.0 + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_write_latency_ms], +CAST((fs.io_stall_read_ms + fs.io_stall_write_ms)/(1.0 + fs.num_of_reads + fs.num_of_writes) AS NUMERIC(10,1)) AS [avg_io_latency_ms], +CONVERT(DECIMAL(18,2), mf.size/128.0) AS [File Size (MB)], mf.physical_name, mf.type_desc, fs.io_stall_read_ms, fs.num_of_reads, +fs.io_stall_write_ms, fs.num_of_writes, fs.io_stall_read_ms + fs.io_stall_write_ms AS [io_stalls], fs.num_of_reads + fs.num_of_writes AS [total_io], +io_stall_queued_read_ms AS [Resource Governor Total Read IO Latency (ms)], io_stall_queued_write_ms AS [Resource Governor Total Write IO Latency (ms)] +FROM sys.dm_io_virtual_file_stats(null,null) AS fs +INNER JOIN sys.master_files AS mf WITH (NOLOCK) +ON fs.database_id = mf.database_id +AND fs.[file_id] = mf.[file_id] +ORDER BY avg_io_latency_ms DESC OPTION (RECOMPILE); +------ + +-- Helps determine which database files on the entire instance have the most I/O bottlenecks +-- This can help you decide whether certain LUNs are overloaded and whether you might +-- want to move some files to a different location or perhaps improve your I/O performance +-- These latency numbers include all file activity against each SQL Server +-- database file since SQL Server was last started + +-- sys.dm_io_virtual_file_stats (Transact-SQL) +-- https://bit.ly/3bRWUc0 + + +-- Look for I/O requests taking longer than 15 seconds in the six most recent SQL Server Error Logs (Query 30) (IO Warnings) +CREATE TABLE #IOWarningResults(LogDate datetime, ProcessInfo sysname, LogText nvarchar(1000)); + + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 0, 1, N'taking longer than 15 seconds'; + + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 1, 1, N'taking longer than 15 seconds'; + + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 2, 1, N'taking longer than 15 seconds'; + + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 3, 1, N'taking longer than 15 seconds'; + + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 4, 1, N'taking longer than 15 seconds'; + + INSERT INTO #IOWarningResults + EXEC xp_readerrorlog 5, 1, N'taking longer than 15 seconds'; + +SELECT LogDate, ProcessInfo, LogText +FROM #IOWarningResults +ORDER BY LogDate DESC; + +DROP TABLE #IOWarningResults; +------ + +-- Finding 15 second I/O warnings in the SQL Server Error Log is useful evidence of +-- poor I/O performance (which might have many different causes) +-- Look to see if you see any patterns in the results (same files, same drives, same time of day, etc.) + +-- Diagnostics in SQL Server help detect stalled and stuck I/O operations +-- https://bit.ly/2qtaw73 + + +-- Resource Governor Resource Pool information (Query 31) (RG Resource Pools) +SELECT pool_id, [Name], statistics_start_time, + min_memory_percent, max_memory_percent, + max_memory_kb/1024 AS [max_memory_mb], + used_memory_kb/1024 AS [used_memory_mb], + target_memory_kb/1024 AS [target_memory_mb], + min_iops_per_volume, max_iops_per_volume +FROM sys.dm_resource_governor_resource_pools WITH (NOLOCK) +OPTION (RECOMPILE); +------ + +-- sys.dm_resource_governor_resource_pools (Transact-SQL) +-- https://bit.ly/2MVU0Vy + + + +-- Recovery model, log reuse wait description, log file size, log usage size (Query 32) (Database Properties) +-- and compatibility level for all databases on instance +SELECT db.[name] AS [Database Name], SUSER_SNAME(db.owner_sid) AS [Database Owner], db.recovery_model_desc AS [Recovery Model], +db.state_desc, db.containment_desc, db.log_reuse_wait_desc AS [Log Reuse Wait Description], +CONVERT(DECIMAL(18,2), ls.cntr_value/1024.0) AS [Log Size (MB)], CONVERT(DECIMAL(18,2), lu.cntr_value/1024.0) AS [Log Used (MB)], +CAST(CAST(lu.cntr_value AS FLOAT) / CAST(ls.cntr_value AS FLOAT)AS DECIMAL(18,2)) * 100 AS [Log Used %], +db.[compatibility_level] AS [DB Compatibility Level], +db.is_mixed_page_allocation_on, db.page_verify_option_desc AS [Page Verify Option], +db.is_auto_create_stats_on, db.is_auto_update_stats_on, db.is_auto_update_stats_async_on, db.is_parameterization_forced, +db.snapshot_isolation_state_desc, db.is_read_committed_snapshot_on, db.is_auto_close_on, db.is_auto_shrink_on, +db.target_recovery_time_in_seconds, db.is_cdc_enabled, db.is_published, db.is_distributor, +db.group_database_id, db.replica_id,db.is_memory_optimized_elevate_to_snapshot_on, +db.delayed_durability_desc, db.is_query_store_on, db.is_sync_with_backup, +db.is_temporal_history_retention_enabled, db.is_remote_data_archive_enabled, +db.is_encrypted, de.encryption_state, de.percent_complete, de.key_algorithm, de.key_length, +db.is_accelerated_database_recovery_on +FROM sys.databases AS db WITH (NOLOCK) +INNER JOIN sys.dm_os_performance_counters AS lu WITH (NOLOCK) +ON db.name = lu.instance_name +INNER JOIN sys.dm_os_performance_counters AS ls WITH (NOLOCK) +ON db.name = ls.instance_name +LEFT OUTER JOIN sys.dm_database_encryption_keys AS de WITH (NOLOCK) +ON db.database_id = de.database_id +WHERE lu.counter_name LIKE N'Log File(s) Used Size (KB)%' +AND ls.counter_name LIKE N'Log File(s) Size (KB)%' +AND ls.cntr_value > 0 +ORDER BY db.[name] OPTION (RECOMPILE); +------ + +-- sys.databases (Transact-SQL) +-- https://bit.ly/2G5wqaX + +-- sys.dm_os_performance_counters (Transact-SQL) +-- https://bit.ly/3kEO2JR + +-- sys.dm_database_encryption_keys (Transact-SQL) +-- https://bit.ly/3mE7kkx + + +-- Things to look at: +-- How many databases are on the instance? +-- What recovery models are they using? +-- What is the log reuse wait description? +-- How full are the transaction logs? +-- What compatibility level are the databases on? +-- What is the Page Verify Option? (should be CHECKSUM) +-- Is Auto Update Statistics Asynchronously enabled? +-- What is target_recovery_time_in_seconds? +-- Is Delayed Durability enabled? +-- Make sure auto_shrink and auto_close are not enabled! + +-- is_mixed_page_allocation_on is a new property for SQL Server 2016. Equivalent to TF 1118 for a user database +-- SQL Server 2016: Changes in default behavior for autogrow and allocations for tempdb and user databases +-- https://bit.ly/2evRZSR + +-- A non-zero value for target_recovery_time_in_seconds means that indirect checkpoint is enabled +-- If the setting has a zero value it indicates that automatic checkpoint is enabled + +-- Changes in SQL Server 2016 Checkpoint Behavior +-- https://bit.ly/2pdggk3 + + +-- Missing Indexes for all databases by Index Advantage (Query 33) (Missing Indexes All Databases) +SELECT CONVERT(decimal(18,2), migs.user_seeks * migs.avg_total_user_cost * (migs.avg_user_impact * 0.01)) AS [index_advantage], +FORMAT(migs.last_user_seek, 'yyyy-MM-dd HH:mm:ss') AS [last_user_seek], mid.[statement] AS [Database.Schema.Table], +COUNT(1) OVER(PARTITION BY mid.[statement]) AS [missing_indexes_for_table], +COUNT(1) OVER(PARTITION BY mid.[statement], mid.equality_columns) AS [similar_missing_indexes_for_table], +mid.equality_columns, mid.inequality_columns, mid.included_columns, migs.user_seeks, +CONVERT(decimal(18,2), migs.avg_total_user_cost) AS [avg_total_user_,cost], migs.avg_user_impact, +REPLACE(REPLACE(LEFT(st.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text] +FROM sys.dm_db_missing_index_groups AS mig WITH (NOLOCK) +INNER JOIN sys.dm_db_missing_index_group_stats_query AS migs WITH(NOLOCK) +ON mig.index_group_handle = migs.group_handle +CROSS APPLY sys.dm_exec_sql_text(migs.last_sql_handle) AS st +INNER JOIN sys.dm_db_missing_index_details AS mid WITH (NOLOCK) +ON mig.index_handle = mid.index_handle +ORDER BY index_advantage DESC OPTION (RECOMPILE); +------ + +-- Getting missing index information for all of the databases on the instance is very useful +-- Look at last user seek time, number of user seeks to help determine source and importance +-- Also look at avg_user_impact and avg_total_user_cost to help determine importance +-- SQL Server is overly eager to add included columns, so beware +-- Do not just blindly add indexes that show up from this query!!! +-- Hkan Winther has given me some great suggestions for this query + +-- SQL Server Index Design Guide +-- https://bit.ly/2qtZr4N + + + +-- Get VLF Counts for all databases on the instance (Query 34) (VLF Counts) +SELECT [name] AS [Database Name], [VLF Count] +FROM sys.databases AS db WITH (NOLOCK) +CROSS APPLY (SELECT file_id, COUNT(*) AS [VLF Count] + FROM sys.dm_db_log_info(db.database_id) + GROUP BY file_id) AS li +ORDER BY [VLF Count] DESC OPTION (RECOMPILE); +------ + +-- High VLF counts can affect write performance to the log file +-- and they can make full database restores and crash recovery take much longer +-- Try to keep your VLF counts under 200 in most cases (depending on log file size) + +-- sys.dm_db_log_info (Transact-SQL) +-- https://bit.ly/3jpmqsd + +-- sys.databases (Transact-SQL) +-- https://bit.ly/2G5wqaX + +-- SQL Server Transaction Log Architecture and Management Guide +-- https://bit.ly/2JjmQRZ + +-- VLF Growth Formula (SQL Server 2014 and newer) +-- If the log growth increment is less than 1/8th the current size of the log +-- Then: 1 new VLF +-- Otherwise: +-- Up to 64MB: 4 new VLFs +-- 64MB to 1GB: 8 new VLFs +-- More than 1GB: 16 new VLFs + + + +-- Get CPU utilization by database (Query 35) (CPU Usage by Database) +WITH DB_CPU_Stats +AS +(SELECT pa.DatabaseID, DB_Name(pa.DatabaseID) AS [Database Name], SUM(qs.total_worker_time/1000) AS [CPU_Time_Ms] + FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) + CROSS APPLY (SELECT CONVERT(int, value) AS [DatabaseID] + FROM sys.dm_exec_plan_attributes(qs.plan_handle) + WHERE attribute = N'dbid') AS pa + GROUP BY DatabaseID) +SELECT ROW_NUMBER() OVER(ORDER BY [CPU_Time_Ms] DESC) AS [CPU Rank], + [Database Name], [CPU_Time_Ms] AS [CPU Time (ms)], + CAST([CPU_Time_Ms] * 1.0 / SUM([CPU_Time_Ms]) OVER() * 100.0 AS DECIMAL(5, 2)) AS [CPU Percent] +FROM DB_CPU_Stats +WHERE DatabaseID <> 32767 -- ResourceDB +ORDER BY [CPU Rank] OPTION (RECOMPILE); +------ + +-- Helps determine which database is using the most CPU resources on the instance +-- Note: This only reflects CPU usage from the currently cached query plans + +-- sys.dm_exec_query_stats (Transact-SQL) +-- https://bit.ly/32tHCGH + +-- sys.dm_exec_plan_attributes (Transact-SQL) +-- https://bit.ly/35iP2hV + + +-- Get I/O utilization by database (Query 36) (IO Usage By Database) +WITH Aggregate_IO_Statistics +AS (SELECT DB_NAME(database_id) AS [Database Name], + CAST(SUM(num_of_bytes_read + num_of_bytes_written) / 1048576 AS DECIMAL(12, 2)) AS [ioTotalMB], + CAST(SUM(num_of_bytes_read ) / 1048576 AS DECIMAL(12, 2)) AS [ioReadMB], + CAST(SUM(num_of_bytes_written) / 1048576 AS DECIMAL(12, 2)) AS [ioWriteMB] + FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS [DM_IO_STATS] + GROUP BY database_id) +SELECT ROW_NUMBER() OVER (ORDER BY ioTotalMB DESC) AS [I/O Rank], + [Database Name], ioTotalMB AS [Total I/O (MB)], + CAST(ioTotalMB / SUM(ioTotalMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Total I/O %], + ioReadMB AS [Read I/O (MB)], + CAST(ioReadMB / SUM(ioReadMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Read I/O %], + ioWriteMB AS [Write I/O (MB)], + CAST(ioWriteMB / SUM(ioWriteMB) OVER () * 100.0 AS DECIMAL(5, 2)) AS [Write I/O %] +FROM Aggregate_IO_Statistics +ORDER BY [I/O Rank] OPTION (RECOMPILE); +------ + +-- Helps determine which database is using the most I/O resources on the instance +-- These numbers are cumulative since the last service restart +-- They include all I/O activity, not just the nominal I/O workload + +-- sys.dm_io_virtual_file_stats (Transact-SQL) +-- https://bit.ly/3bRWUc0 + + +-- Get total buffer usage by database for current instance (Query 37) (Total Buffer Usage by Database) +-- This make take some time to run on a busy instance +WITH AggregateBufferPoolUsage +AS +(SELECT DB_NAME(database_id) AS [Database Name], +CAST(COUNT(*) * 8/1024.0 AS DECIMAL (10,2)) AS [CachedSize] +FROM sys.dm_os_buffer_descriptors WITH (NOLOCK) +WHERE database_id <> 32767 -- ResourceDB +GROUP BY DB_NAME(database_id)) +SELECT ROW_NUMBER() OVER(ORDER BY CachedSize DESC) AS [Buffer Pool Rank], [Database Name], CachedSize AS [Cached Size (MB)], + CAST(CachedSize / SUM(CachedSize) OVER() * 100.0 AS DECIMAL(5,2)) AS [Buffer Pool Percent] +FROM AggregateBufferPoolUsage +ORDER BY [Buffer Pool Rank] OPTION (RECOMPILE); +------ + +-- Tells you how much memory (in the buffer pool) +-- is being used by each database on the instance + +-- sys.dm_os_buffer_descriptors (Transact-SQL) +-- https://bit.ly/36s7aFo + + +-- Get tempdb version store space usage by database (Query 38) (Version Store Space Usage) +SELECT DB_NAME(database_id) AS [Database Name], + reserved_page_count AS [Version Store Reserved Page Count], + reserved_space_kb/1024 AS [Version Store Reserved Space (MB)] +FROM sys.dm_tran_version_store_space_usage WITH (NOLOCK) +ORDER BY reserved_space_kb/1024 DESC OPTION (RECOMPILE); +------ + +-- sys.dm_tran_version_store_space_usage (Transact-SQL) +-- https://bit.ly/2vh3Bmk + + + + +-- Clear Wait Stats with this command +-- DBCC SQLPERF('sys.dm_os_wait_stats', CLEAR); + +-- Isolate top waits for server instance since last restart or wait statistics clear (Query 39) (Top Waits) +WITH [Waits] +AS (SELECT wait_type, wait_time_ms/ 1000.0 AS [WaitS], + (wait_time_ms - signal_wait_time_ms) / 1000.0 AS [ResourceS], + signal_wait_time_ms / 1000.0 AS [SignalS], + waiting_tasks_count AS [WaitCount], + 100.0 * wait_time_ms / SUM (wait_time_ms) OVER() AS [Percentage], + ROW_NUMBER() OVER(ORDER BY wait_time_ms DESC) AS [RowNum] + FROM sys.dm_os_wait_stats WITH (NOLOCK) + WHERE [wait_type] NOT IN ( + N'BROKER_EVENTHANDLER', N'BROKER_RECEIVE_WAITFOR', N'BROKER_TASK_STOP', + N'BROKER_TO_FLUSH', N'BROKER_TRANSMITTER', N'CHECKPOINT_QUEUE', + N'CHKPT', N'CLR_AUTO_EVENT', N'CLR_MANUAL_EVENT', N'CLR_SEMAPHORE', N'CXCONSUMER', + N'DBMIRROR_DBM_EVENT', N'DBMIRROR_EVENTS_QUEUE', N'DBMIRROR_WORKER_QUEUE', + N'DBMIRRORING_CMD', N'DIRTY_PAGE_POLL', N'DISPATCHER_QUEUE_SEMAPHORE', + N'EXECSYNC', N'FSAGENT', N'FT_IFTS_SCHEDULER_IDLE_WAIT', N'FT_IFTSHC_MUTEX', + N'HADR_CLUSAPI_CALL', N'HADR_FILESTREAM_IOMGR_IOCOMPLETION', N'HADR_LOGCAPTURE_WAIT', + N'HADR_NOTIFICATION_DEQUEUE', N'HADR_TIMER_TASK', N'HADR_WORK_QUEUE', + N'KSOURCE_WAKEUP', N'LAZYWRITER_SLEEP', N'LOGMGR_QUEUE', + N'MEMORY_ALLOCATION_EXT', N'ONDEMAND_TASK_QUEUE', + N'PARALLEL_REDO_DRAIN_WORKER', N'PARALLEL_REDO_LOG_CACHE', N'PARALLEL_REDO_TRAN_LIST', + N'PARALLEL_REDO_WORKER_SYNC', N'PARALLEL_REDO_WORKER_WAIT_WORK', + N'PREEMPTIVE_HADR_LEASE_MECHANISM', N'PREEMPTIVE_SP_SERVER_DIAGNOSTICS', + N'PREEMPTIVE_OS_LIBRARYOPS', N'PREEMPTIVE_OS_COMOPS', N'PREEMPTIVE_OS_CRYPTOPS', + N'PREEMPTIVE_OS_PIPEOPS', N'PREEMPTIVE_OS_AUTHENTICATIONOPS', + N'PREEMPTIVE_OS_GENERICOPS', N'PREEMPTIVE_OS_VERIFYTRUST', + N'PREEMPTIVE_OS_FILEOPS', N'PREEMPTIVE_OS_DEVICEOPS', N'PREEMPTIVE_OS_QUERYREGISTRY', + N'PREEMPTIVE_OS_WRITEFILE', N'PREEMPTIVE_OS_WRITEFILEGATHER', + N'PREEMPTIVE_XE_CALLBACKEXECUTE', N'PREEMPTIVE_XE_DISPATCHER', + N'PREEMPTIVE_XE_GETTARGETSTATE', N'PREEMPTIVE_XE_SESSIONCOMMIT', + N'PREEMPTIVE_XE_TARGETINIT', N'PREEMPTIVE_XE_TARGETFINALIZE', + N'PWAIT_ALL_COMPONENTS_INITIALIZED', N'PWAIT_DIRECTLOGCONSUMER_GETNEXT', + N'PWAIT_EXTENSIBILITY_CLEANUP_TASK', + N'QDS_PERSIST_TASK_MAIN_LOOP_SLEEP', N'QDS_ASYNC_QUEUE', + N'QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEP', N'REQUEST_FOR_DEADLOCK_SEARCH', + N'RESOURCE_QUEUE', N'SERVER_IDLE_CHECK', N'SLEEP_BPOOL_FLUSH', N'SLEEP_DBSTARTUP', + N'SLEEP_DCOMSTARTUP', N'SLEEP_MASTERDBREADY', N'SLEEP_MASTERMDREADY', + N'SLEEP_MASTERUPGRADED', N'SLEEP_MSDBSTARTUP', N'SLEEP_SYSTEMTASK', N'SLEEP_TASK', + N'SLEEP_TEMPDBSTARTUP', N'SNI_HTTP_ACCEPT', N'SOS_WORK_DISPATCHER', + N'SP_SERVER_DIAGNOSTICS_SLEEP', + N'SQLTRACE_BUFFER_FLUSH', N'SQLTRACE_INCREMENTAL_FLUSH_SLEEP', N'SQLTRACE_WAIT_ENTRIES', + N'STARTUP_DEPENDENCY_MANAGER', + N'WAIT_FOR_RESULTS', N'WAITFOR', N'WAITFOR_TASKSHUTDOWN', N'WAIT_XTP_HOST_WAIT', + N'WAIT_XTP_OFFLINE_CKPT_NEW_LOG', N'WAIT_XTP_CKPT_CLOSE', N'WAIT_XTP_RECOVERY', + N'XE_BUFFERMGR_ALLPROCESSED_EVENT', N'XE_DISPATCHER_JOIN', + N'XE_DISPATCHER_WAIT', N'XE_LIVE_TARGET_TVF', N'XE_TIMER_EVENT') + AND waiting_tasks_count > 0) +SELECT + MAX (W1.wait_type) AS [WaitType], + CAST (MAX (W1.Percentage) AS DECIMAL (5,2)) AS [Wait Percentage], + CAST ((MAX (W1.WaitS) / MAX (W1.WaitCount)) AS DECIMAL (16,4)) AS [AvgWait_Sec], + CAST ((MAX (W1.ResourceS) / MAX (W1.WaitCount)) AS DECIMAL (16,4)) AS [AvgRes_Sec], + CAST ((MAX (W1.SignalS) / MAX (W1.WaitCount)) AS DECIMAL (16,4)) AS [AvgSig_Sec], + CAST (MAX (W1.WaitS) AS DECIMAL (16,2)) AS [Wait_Sec], + CAST (MAX (W1.ResourceS) AS DECIMAL (16,2)) AS [Resource_Sec], + CAST (MAX (W1.SignalS) AS DECIMAL (16,2)) AS [Signal_Sec], + MAX (W1.WaitCount) AS [Wait Count], + CAST (N'https://www.sqlskills.com/help/waits/' + W1.wait_type AS XML) AS [Help/Info URL] +FROM Waits AS W1 +INNER JOIN Waits AS W2 +ON W2.RowNum <= W1.RowNum +GROUP BY W1.RowNum, W1.wait_type +HAVING SUM (W2.Percentage) - MAX (W1.Percentage) < 99 -- percentage threshold +OPTION (RECOMPILE); +------ + +-- Cumulative wait stats are not as useful on an idle instance that is not under load or performance pressure + +-- SQL Server Wait Types Library +-- https://bit.ly/2ePzYO2 + +-- The SQL Server Wait Type Repository +-- https://bit.ly/1afzfjC + +-- Wait statistics, or please tell me where it hurts +-- https://bit.ly/2wsQHQE + +-- SQL Server 2005 Performance Tuning using the Waits and Queues +-- https://bit.ly/1o2NFoF + +-- sys.dm_os_wait_stats (Transact-SQL) +-- https://bit.ly/2Hjq9Yl + + + +-- Get a count of SQL connections by IP address (Query 40) (Connection Counts by IP Address) +SELECT ec.client_net_address, es.[program_name], es.[host_name], es.login_name, +COUNT(ec.session_id) AS [connection count] +FROM sys.dm_exec_sessions AS es WITH (NOLOCK) +INNER JOIN sys.dm_exec_connections AS ec WITH (NOLOCK) +ON es.session_id = ec.session_id +GROUP BY ec.client_net_address, es.[program_name], es.[host_name], es.login_name +ORDER BY ec.client_net_address, es.[program_name] OPTION (RECOMPILE); +------ + +-- This helps you figure where your database load is coming from +-- and verifies connectivity from other machines + +-- Solving Connectivity errors to SQL Server +-- https://bit.ly/2EgzoD0 + + + +-- Get Average Task Counts (run multiple times) (Query 41) (Avg Task Counts) +SELECT AVG(current_tasks_count) AS [Avg Task Count], +AVG(work_queue_count) AS [Avg Work Queue Count], +AVG(runnable_tasks_count) AS [Avg Runnable Task Count], +AVG(pending_disk_io_count) AS [Avg Pending DiskIO Count] +FROM sys.dm_os_schedulers WITH (NOLOCK) +WHERE scheduler_id < 255 OPTION (RECOMPILE); +------ + +-- Sustained values above 10 suggest further investigation in that area +-- High Avg Task Counts are often caused by blocking/deadlocking or other resource contention + +-- Sustained values above 1 suggest further investigation in that area +-- High Avg Runnable Task Counts are a good sign of CPU pressure +-- High Avg Pending DiskIO Counts are a sign of disk pressure + +-- How to Do Some Very Basic SQL Server Monitoring +-- https://bit.ly/30IRla0 + + + +-- Detect blocking (run multiple times) (Query 42) (Detect Blocking) +SELECT t1.resource_type AS [lock type], DB_NAME(resource_database_id) AS [database], +t1.resource_associated_entity_id AS [blk object],t1.request_mode AS [lock req], -- lock requested +t1.request_session_id AS [waiter sid], t2.wait_duration_ms AS [wait time], -- spid of waiter +(SELECT [text] FROM sys.dm_exec_requests AS r WITH (NOLOCK) -- get sql for waiter +CROSS APPLY sys.dm_exec_sql_text(r.[sql_handle]) +WHERE r.session_id = t1.request_session_id) AS [waiter_batch], +(SELECT SUBSTRING(qt.[text],r.statement_start_offset/2, + (CASE WHEN r.statement_end_offset = -1 + THEN LEN(CONVERT(nvarchar(max), qt.[text])) * 2 + ELSE r.statement_end_offset END - r.statement_start_offset)/2) +FROM sys.dm_exec_requests AS r WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(r.[sql_handle]) AS qt +WHERE r.session_id = t1.request_session_id) AS [waiter_stmt], -- statement blocked +t2.blocking_session_id AS [blocker sid], -- spid of blocker +(SELECT [text] FROM sys.sysprocesses AS p -- get sql for blocker +CROSS APPLY sys.dm_exec_sql_text(p.[sql_handle]) +WHERE p.spid = t2.blocking_session_id) AS [blocker_batch] +FROM sys.dm_tran_locks AS t1 WITH (NOLOCK) +INNER JOIN sys.dm_os_waiting_tasks AS t2 WITH (NOLOCK) +ON t1.lock_owner_address = t2.resource_address OPTION (RECOMPILE); +------ + +-- Helps troubleshoot blocking and deadlocking issues +-- The results will change from second to second on a busy system +-- You should run this query multiple times when you see signs of blocking + + + +-- Get CPU Utilization History for last 256 minutes (in one minute intervals) (Query 43) (CPU Utilization History) +DECLARE @ts_now bigint = (SELECT ms_ticks FROM sys.dm_os_sys_info WITH (NOLOCK)); + +SELECT TOP(256) SQLProcessUtilization AS [SQL Server Process CPU Utilization], + SystemIdle AS [System Idle Process], + 100 - SystemIdle - SQLProcessUtilization AS [Other Process CPU Utilization], + DATEADD(ms, -1 * (@ts_now - [timestamp]), GETDATE()) AS [Event Time] +FROM (SELECT record.value('(./Record/@id)[1]', 'int') AS record_id, + record.value('(./Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int') + AS [SystemIdle], + record.value('(./Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]', 'int') + AS [SQLProcessUtilization], [timestamp] + FROM (SELECT [timestamp], CONVERT(xml, record) AS [record] + FROM sys.dm_os_ring_buffers WITH (NOLOCK) + WHERE ring_buffer_type = N'RING_BUFFER_SCHEDULER_MONITOR' + AND record LIKE N'%%') AS x) AS y +ORDER BY record_id DESC OPTION (RECOMPILE); +------ + +-- Look at the trend over the entire period +-- Also look at high sustained 'Other Process' CPU Utilization values +-- Note: This query sometimes gives inaccurate results (negative values) +-- on high core count (> 64 cores) systems + + +-- Get top total worker time queries for entire instance (Query 44) (Top Worker Time Queries) +SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], +REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], +qs.total_worker_time AS [Total Worker Time], qs.min_worker_time AS [Min Worker Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.max_worker_time AS [Max Worker Time], +qs.min_elapsed_time AS [Min Elapsed Time], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.max_elapsed_time AS [Max Elapsed Time], +qs.min_logical_reads AS [Min Logical Reads], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +qs.max_logical_reads AS [Max Logical Reads], +qs.execution_count AS [Execution Count], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] +--,t.[text] AS [Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel +FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t +CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp +ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); +------ + + +-- Helps you find the most expensive queries from a CPU perspective across the entire instance +-- Can also help track down parameter sniffing issues + + + +-- Page Life Expectancy (PLE) value for each NUMA node in current instance (Query 45) (PLE by NUMA Node) +SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], + instance_name, cntr_value AS [Page Life Expectancy] +FROM sys.dm_os_performance_counters WITH (NOLOCK) +WHERE [object_name] LIKE N'%Buffer Node%' -- Handles named instances +AND counter_name = N'Page life expectancy' OPTION (RECOMPILE); +------ + +-- PLE is a good measurement of internal memory pressure +-- Higher PLE is better. Watch the trend over time, not the absolute value +-- This will only return one row for non-NUMA systems + +-- Page Life Expectancy isnt what you think +-- https://bit.ly/2EgynLa + + +-- Memory Grants Pending value for current instance (Query 46) (Memory Grants Pending) +SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], cntr_value AS [Memory Grants Pending] +FROM sys.dm_os_performance_counters WITH (NOLOCK) +WHERE [object_name] LIKE N'%Memory Manager%' -- Handles named instances +AND counter_name = N'Memory Grants Pending' OPTION (RECOMPILE); +------ + +-- Run multiple times, and run periodically if you suspect you are under memory pressure +-- Memory Grants Pending above zero for a sustained period is a very strong indicator of internal memory pressure + + +-- Memory Clerk Usage for instance (Query 47) (Memory Clerk Usage) +-- Look for high value for CACHESTORE_SQLCP (Ad-hoc query plans) +SELECT TOP(10) mc.[type] AS [Memory Clerk Type], + CAST((SUM(mc.pages_kb)/1024.0) AS DECIMAL (15,2)) AS [Memory Usage (MB)] +FROM sys.dm_os_memory_clerks AS mc WITH (NOLOCK) +GROUP BY mc.[type] +ORDER BY SUM(mc.pages_kb) DESC OPTION (RECOMPILE); +------ + +-- MEMORYCLERK_SQLBUFFERPOOL was new for SQL Server 2012. It should be your highest consumer of memory + +-- CACHESTORE_SQLCP - SQL Plans +-- These are cached SQL statements or batches that aren't in stored procedures, functions and triggers +-- Watch out for high values for CACHESTORE_SQLCP +-- Enabling 'optimize for ad hoc workloads' at the instance level can help reduce this +-- Running DBCC FREESYSTEMCACHE ('SQL Plans') periodically may be required to better control this + +-- CACHESTORE_OBJCP - Object Plans +-- These are compiled plans for stored procedures, functions and triggers + +-- sys.dm_os_memory_clerks (Transact-SQL) +-- https://bit.ly/2H31xDR + + + +-- Find single-use, ad-hoc and prepared queries that are bloating the plan cache (Query 48) (Ad hoc Queries) +SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], t.[text] AS [Query Text], +cp.objtype AS [Object Type], cp.cacheobjtype AS [Cache Object Type], +cp.size_in_bytes/1024 AS [Plan Size in KB] +FROM sys.dm_exec_cached_plans AS cp WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t +WHERE cp.cacheobjtype = N'Compiled Plan' +AND cp.objtype IN (N'Adhoc', N'Prepared') +AND cp.usecounts = 1 +ORDER BY cp.size_in_bytes DESC, DB_NAME(t.[dbid]) OPTION (RECOMPILE); +------ + +-- Gives you the text, type and size of single-use ad-hoc and prepared queries that waste space in the plan cache +-- Enabling 'optimize for ad hoc workloads' for the instance can help (SQL Server 2008 and above only) +-- Running DBCC FREESYSTEMCACHE ('SQL Plans') periodically may be required to better control this +-- Enabling forced parameterization for the database can help, but test first! + +-- Plan cache, adhoc workloads and clearing the single-use plan cache bloat +-- https://bit.ly/2EfYOkl + + +-- Get top total logical reads queries for entire instance (Query 49) (Top Logical Reads Queries) +SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], +REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], +qs.total_logical_reads AS [Total Logical Reads], +qs.min_logical_reads AS [Min Logical Reads], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +qs.max_logical_reads AS [Max Logical Reads], +qs.min_worker_time AS [Min Worker Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.max_worker_time AS [Max Worker Time], +qs.min_elapsed_time AS [Min Elapsed Time], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.max_elapsed_time AS [Max Elapsed Time], +qs.execution_count AS [Execution Count], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] +--,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel +FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t +CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp +ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE); +------ + + +-- Helps you find the most expensive queries from a memory perspective across the entire instance +-- Can also help track down parameter sniffing issues + + +-- Get top average elapsed time queries for entire instance (Query 50) (Top Avg Elapsed Time Queries) +SELECT TOP(50) DB_NAME(t.[dbid]) AS [Database Name], +REPLACE(REPLACE(LEFT(t.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.min_elapsed_time, qs.max_elapsed_time, qs.last_elapsed_time, +qs.execution_count AS [Execution Count], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +qs.total_physical_reads/qs.execution_count AS [Avg Physical Reads], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] +--,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel +FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t +CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp +ORDER BY qs.total_elapsed_time/qs.execution_count DESC OPTION (RECOMPILE); +------ + +-- Helps you find the highest average elapsed time queries across the entire instance +-- Can also help track down parameter sniffing issues + + +-- Look at UDF execution statistics (Query 51) (UDF Stats by DB) +SELECT TOP (25) DB_NAME(database_id) AS [Database Name], + OBJECT_NAME(object_id, database_id) AS [Function Name], + total_worker_time, execution_count, total_elapsed_time, + total_elapsed_time/execution_count AS [avg_elapsed_time], + last_elapsed_time, last_execution_time, cached_time, [type_desc] +FROM sys.dm_exec_function_stats WITH (NOLOCK) +ORDER BY total_worker_time DESC OPTION (RECOMPILE); +------ + +-- sys.dm_exec_function_stats (Transact-SQL) +-- https://bit.ly/2q1Q6BM + +-- Showplan Enhancements for UDFs +-- https://bit.ly/2LVqiQ1 + + +-- Database specific queries ***************************************************************** + +-- **** Please switch to a user database that you are interested in! ***** +--USE YourDatabaseName; -- make sure to change to an actual database on your instance, not the master system database +--GO + +-- Individual File Sizes and space available for current database (Query 52) (File Sizes and Space) +SELECT f.[name] AS [File Name] , f.physical_name AS [Physical Name], +CAST((f.size/128.0) AS DECIMAL(15,2)) AS [Total Size in MB], +CAST((f.size/128.0) AS DECIMAL(15,2)) - +CAST(f.size/128.0 - CAST(FILEPROPERTY(f.name, 'SpaceUsed') AS int)/128.0 AS DECIMAL(15,2)) +AS [Used Space in MB], +CAST(f.size/128.0 - CAST(FILEPROPERTY(f.name, 'SpaceUsed') AS int)/128.0 AS DECIMAL(15,2)) +AS [Available Space In MB], +f.[file_id], fg.name AS [Filegroup Name], +f.is_percent_growth, f.growth, fg.is_default, fg.is_read_only, fg.is_autogrow_all_files +FROM sys.database_files AS f WITH (NOLOCK) +LEFT OUTER JOIN sys.filegroups AS fg WITH (NOLOCK) +ON f.data_space_id = fg.data_space_id +ORDER BY f.[type], f.[file_id] OPTION (RECOMPILE); +------ + +-- Look at how large and how full the files are and where they are located +-- Make sure the transaction log is not full!! + +-- is_autogrow_all_files was new for SQL Server 2016. Equivalent to TF 1117 for user databases + +-- SQL Server 2016: Changes in default behavior for autogrow and allocations for tempdb and user databases +-- https://bit.ly/2evRZSR + + +-- Log space usage for current database (Query 53) (Log Space Usage) +SELECT DB_NAME(lsu.database_id) AS [Database Name], db.recovery_model_desc AS [Recovery Model], + CAST(lsu.total_log_size_in_bytes/1048576.0 AS DECIMAL(10, 2)) AS [Total Log Space (MB)], + CAST(lsu.used_log_space_in_bytes/1048576.0 AS DECIMAL(10, 2)) AS [Used Log Space (MB)], + CAST(lsu.used_log_space_in_percent AS DECIMAL(10, 2)) AS [Used Log Space %], + CAST(lsu.log_space_in_bytes_since_last_backup/1048576.0 AS DECIMAL(10, 2)) AS [Used Log Space Since Last Backup (MB)], + db.log_reuse_wait_desc +FROM sys.dm_db_log_space_usage AS lsu WITH (NOLOCK) +INNER JOIN sys.databases AS db WITH (NOLOCK) +ON lsu.database_id = db.database_id +OPTION (RECOMPILE); +------ + +-- Look at log file size and usage, along with the log reuse wait description for the current database + +-- sys.dm_db_log_space_usage (Transact-SQL) +-- https://bit.ly/2H4MQw9 + + +-- Status of last VLF for current database (Query 54) (Last VLF Status) +SELECT TOP(1) DB_NAME(li.database_id) AS [Database Name], li.[file_id], + li.vlf_size_mb, li.vlf_sequence_number, li.vlf_active, li.vlf_status +FROM sys.dm_db_log_info(DB_ID()) AS li +ORDER BY vlf_sequence_number DESC OPTION (RECOMPILE); +------ + +-- Determine whether you will be able to shrink the transaction log file + +-- vlf_status Values +-- 0 is inactive +-- 1 is initialized but unused +-- 2 is active + +-- sys.dm_db_log_info (Transact-SQL) +-- https://bit.ly/2EQUU1v + + + +-- Get database scoped configuration values for current database (Query 55) (Database-scoped Configurations) +SELECT configuration_id, name, [value] AS [value_for_primary], value_for_secondary +FROM sys.database_scoped_configurations WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- This lets you see the value of these new properties for the current database + +-- Clear plan cache for current database +-- ALTER DATABASE SCOPED CONFIGURATION CLEAR PROCEDURE_CACHE; + +-- ALTER DATABASE SCOPED CONFIGURATION (Transact-SQL) +-- https://bit.ly/2sOH7nb + + +-- I/O Statistics by file for the current database (Query 56) (IO Stats By File) +SELECT DB_NAME(DB_ID()) AS [Database Name], df.name AS [Logical Name], vfs.[file_id], df.type_desc, +df.physical_name AS [Physical Name], CAST(vfs.size_on_disk_bytes/1048576.0 AS DECIMAL(10, 2)) AS [Size on Disk (MB)], +vfs.num_of_reads, vfs.num_of_writes, vfs.io_stall_read_ms, vfs.io_stall_write_ms, +CAST(100. * vfs.io_stall_read_ms/(vfs.io_stall_read_ms + vfs.io_stall_write_ms) AS DECIMAL(10,1)) AS [IO Stall Reads Pct], +CAST(100. * vfs.io_stall_write_ms/(vfs.io_stall_write_ms + vfs.io_stall_read_ms) AS DECIMAL(10,1)) AS [IO Stall Writes Pct], +(vfs.num_of_reads + vfs.num_of_writes) AS [Writes + Reads], +CAST(vfs.num_of_bytes_read/1048576.0 AS DECIMAL(10, 2)) AS [MB Read], +CAST(vfs.num_of_bytes_written/1048576.0 AS DECIMAL(10, 2)) AS [MB Written], +CAST(100. * vfs.num_of_reads/(vfs.num_of_reads + vfs.num_of_writes) AS DECIMAL(10,1)) AS [# Reads Pct], +CAST(100. * vfs.num_of_writes/(vfs.num_of_reads + vfs.num_of_writes) AS DECIMAL(10,1)) AS [# Write Pct], +CAST(100. * vfs.num_of_bytes_read/(vfs.num_of_bytes_read + vfs.num_of_bytes_written) AS DECIMAL(10,1)) AS [Read Bytes Pct], +CAST(100. * vfs.num_of_bytes_written/(vfs.num_of_bytes_read + vfs.num_of_bytes_written) AS DECIMAL(10,1)) AS [Written Bytes Pct] +FROM sys.dm_io_virtual_file_stats(DB_ID(), NULL) AS vfs +INNER JOIN sys.database_files AS df WITH (NOLOCK) +ON vfs.[file_id]= df.[file_id] OPTION (RECOMPILE); +------ + +-- This helps you characterize your workload better from an I/O perspective for this database +-- It helps you determine whether you have an OLTP or DW/DSS type of workload + + + +-- Get most frequently executed queries for this database (Query 57) (Query Execution Counts) +SELECT TOP(50) LEFT(t.[text], 50) AS [Short Query Text], qs.execution_count AS [Execution Count], +qs.total_logical_reads AS [Total Logical Reads], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +qs.total_worker_time AS [Total Worker Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.total_elapsed_time AS [Total Elapsed Time], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +qs.creation_time AS [Creation Time] +--,t.[text] AS [Complete Query Text], qp.query_plan AS [Query Plan] -- uncomment out these columns if not copying results to Excel +FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS t +CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp +WHERE t.dbid = DB_ID() +ORDER BY qs.execution_count DESC OPTION (RECOMPILE); +------ + +-- Tells you which cached queries are called the most often +-- This helps you characterize and baseline your workload +-- It also helps you find possible caching opportunities + + +-- Queries 58 through 64 are the "Bad Man List" for stored procedures + +-- Top Cached SPs By Execution Count (Query 58) (SP Execution Counts) +SELECT TOP(100) p.name AS [SP Name], qs.execution_count AS [Execution Count], +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +ORDER BY qs.execution_count DESC OPTION (RECOMPILE); +------ + +-- Tells you which cached stored procedures are called the most often +-- This helps you characterize and baseline your workload +-- It also helps you find possible caching opportunities + + +-- Top Cached SPs By Avg Elapsed Time (Query 59) (SP Avg Elapsed Time) +SELECT TOP(25) p.name AS [SP Name], qs.min_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +qs.max_elapsed_time, qs.last_elapsed_time, qs.total_elapsed_time, qs.execution_count, +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], +qs.total_worker_time AS [TotalWorkerTime], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +ORDER BY avg_elapsed_time DESC OPTION (RECOMPILE); +------ + +-- This helps you find high average elapsed time cached stored procedures that +-- may be easy to optimize with standard query tuning techniques + + + +-- Top Cached SPs By Total Worker time. Worker time relates to CPU cost (Query 60) (SP Worker Time) +SELECT TOP(25) p.name AS [SP Name], qs.total_worker_time AS [TotalWorkerTime], +qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], qs.execution_count, +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE); +------ + +-- This helps you find the most expensive cached stored procedures from a CPU perspective +-- You should look at this if you see signs of CPU pressure + + +-- Top Cached SPs By Total Logical Reads. Logical reads relate to memory pressure (Query 61) (SP Logical Reads) +SELECT TOP(25) p.name AS [SP Name], qs.total_logical_reads AS [TotalLogicalReads], +qs.total_logical_reads/qs.execution_count AS [AvgLogicalReads],qs.execution_count, +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +ORDER BY qs.total_logical_reads DESC OPTION (RECOMPILE); +------ + +-- This helps you find the most expensive cached stored procedures from a memory perspective +-- You should look at this if you see signs of memory pressure + + +-- Top Cached SPs By Total Physical Reads. Physical reads relate to disk read I/O pressure (Query 62) (SP Physical Reads) +SELECT TOP(25) p.name AS [SP Name],qs.total_physical_reads AS [TotalPhysicalReads], +qs.total_physical_reads/qs.execution_count AS [AvgPhysicalReads], qs.execution_count, +qs.total_logical_reads,qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND qs.total_physical_reads > 0 +ORDER BY qs.total_physical_reads DESC, qs.total_logical_reads DESC OPTION (RECOMPILE); +------ + +-- This helps you find the most expensive cached stored procedures from a read I/O perspective +-- You should look at this if you see signs of I/O pressure or of memory pressure + + + +-- Top Cached SPs By Total Logical Writes (Query 63) (SP Logical Writes) +-- Logical writes relate to both memory and disk I/O pressure +SELECT TOP(25) p.name AS [SP Name], qs.total_logical_writes AS [TotalLogicalWrites], +qs.total_logical_writes/qs.execution_count AS [AvgLogicalWrites], qs.execution_count, +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], +CASE WHEN CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' THEN 1 ELSE 0 END AS [Has Missing Index], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND qs.total_logical_writes > 0 +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +ORDER BY qs.total_logical_writes DESC OPTION (RECOMPILE); +------ + +-- This helps you find the most expensive cached stored procedures from a write I/O perspective +-- You should look at this if you see signs of I/O pressure or of memory pressure + + + +-- Cached SPs Missing Indexes by Execution Count (Query 64) (SP Missing Index) +SELECT TOP(25) p.name AS [SP Name], qs.execution_count AS [Execution Count], +ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, GETDATE()), 0) AS [Calls/Minute], +qs.total_elapsed_time/qs.execution_count AS [Avg Elapsed Time], +qs.total_worker_time/qs.execution_count AS [Avg Worker Time], +qs.total_logical_reads/qs.execution_count AS [Avg Logical Reads], +FORMAT(qs.last_execution_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Last Execution Time], +FORMAT(qs.cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +-- ,qp.query_plan AS [Query Plan] -- Uncomment if you want the Query Plan +FROM sys.procedures AS p WITH (NOLOCK) +INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK) +ON p.[object_id] = qs.[object_id] +CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp +WHERE qs.database_id = DB_ID() +AND DATEDIFF(Minute, qs.cached_time, GETDATE()) > 0 +AND CONVERT(nvarchar(max), qp.query_plan) COLLATE Latin1_General_BIN2 LIKE N'%%' +ORDER BY qs.execution_count DESC OPTION (RECOMPILE); +------ + +-- This helps you find the most frequently executed cached stored procedures that have missing index warnings +-- This can often help you find index tuning candidates + + + +-- Lists the top statements by average input/output usage for the current database (Query 65) (Top IO Statements) +SELECT TOP(50) OBJECT_NAME(qt.objectid, dbid) AS [SP Name], +(qs.total_logical_reads + qs.total_logical_writes) /qs.execution_count AS [Avg IO], qs.execution_count AS [Execution Count], +SUBSTRING(qt.[text],qs.statement_start_offset/2, + (CASE + WHEN qs.statement_end_offset = -1 + THEN LEN(CONVERT(nvarchar(max), qt.[text])) * 2 + ELSE qs.statement_end_offset + END - qs.statement_start_offset)/2) AS [Query Text] +FROM sys.dm_exec_query_stats AS qs WITH (NOLOCK) +CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS qt +WHERE qt.[dbid] = DB_ID() +ORDER BY [Avg IO] DESC OPTION (RECOMPILE); +------ + +-- Helps you find the most expensive statements for I/O by SP + + + +-- Possible Bad NC Indexes (writes > reads) (Query 66) (Bad NC Indexes) +SELECT SCHEMA_NAME(o.[schema_id]) AS [Schema Name], +OBJECT_NAME(s.[object_id]) AS [Table Name], +i.name AS [Index Name], i.index_id, +i.is_disabled, i.is_hypothetical, i.has_filter, i.fill_factor, +s.user_updates AS [Total Writes], s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], +s.user_updates - (s.user_seeks + s.user_scans + s.user_lookups) AS [Difference] +FROM sys.dm_db_index_usage_stats AS s WITH (NOLOCK) +INNER JOIN sys.indexes AS i WITH (NOLOCK) +ON s.[object_id] = i.[object_id] +AND i.index_id = s.index_id +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON i.[object_id] = o.[object_id] +WHERE OBJECTPROPERTY(s.[object_id],'IsUserTable') = 1 +AND s.database_id = DB_ID() +AND s.user_updates > (s.user_seeks + s.user_scans + s.user_lookups) +AND i.index_id > 1 AND i.[type_desc] = N'NONCLUSTERED' +AND i.is_primary_key = 0 AND i.is_unique_constraint = 0 AND i.is_unique = 0 +ORDER BY [Difference] DESC, [Total Writes] DESC, [Total Reads] ASC OPTION (RECOMPILE); +------ + +-- Look for indexes with high numbers of writes and zero or very low numbers of reads +-- Consider your complete workload, and how long your instance has been running +-- Investigate further before dropping an index! + + +-- Missing Indexes for current database by Index Advantage (Query 67) (Missing Indexes) +SELECT CONVERT(decimal(18,2), migs.user_seeks * migs.avg_total_user_cost * (migs.avg_user_impact * 0.01)) AS [index_advantage], +FORMAT(migs.last_user_seek, 'yyyy-MM-dd HH:mm:ss') AS [last_user_seek], mid.[statement] AS [Database.Schema.Table], +COUNT(1) OVER(PARTITION BY mid.[statement]) AS [missing_indexes_for_table], +COUNT(1) OVER(PARTITION BY mid.[statement], mid.equality_columns) AS [similar_missing_indexes_for_table], +mid.equality_columns, mid.inequality_columns, mid.included_columns, migs.user_seeks, +CONVERT(decimal(18,2), migs.avg_total_user_cost) AS [avg_total_user_,cost], migs.avg_user_impact, +REPLACE(REPLACE(LEFT(st.[text], 255), CHAR(10),''), CHAR(13),'') AS [Short Query Text], +OBJECT_NAME(mid.[object_id]) AS [Table Name], p.rows AS [Table Rows] +FROM sys.dm_db_missing_index_groups AS mig WITH (NOLOCK) +INNER JOIN sys.dm_db_missing_index_group_stats_query AS migs WITH(NOLOCK) +ON mig.index_group_handle = migs.group_handle +CROSS APPLY sys.dm_exec_sql_text(migs.last_sql_handle) AS st +INNER JOIN sys.dm_db_missing_index_details AS mid WITH (NOLOCK) +ON mig.index_handle = mid.index_handle +INNER JOIN sys.partitions AS p WITH (NOLOCK) +ON p.[object_id] = mid.[object_id] +WHERE mid.database_id = DB_ID() +AND p.index_id < 2 +ORDER BY index_advantage DESC OPTION (RECOMPILE); +------ + +-- Look at index advantage, last user seek time, number of user seeks to help determine source and importance +-- SQL Server is overly eager to add included columns, so beware +-- Do not just blindly add indexes that show up from this query!!! +-- Hkan Winther has given me some great suggestions for this query + + +-- Find missing index warnings for cached plans in the current database (Query 68) (Missing Index Warnings) +-- Note: This query could take some time on a busy instance +SELECT TOP(25) OBJECT_NAME(objectid) AS [ObjectName], + cp.objtype, cp.usecounts, cp.size_in_bytes, qp.query_plan +FROM sys.dm_exec_cached_plans AS cp WITH (NOLOCK) +CROSS APPLY sys.dm_exec_query_plan(cp.plan_handle) AS qp +WHERE CAST(query_plan AS NVARCHAR(MAX)) LIKE N'%MissingIndex%' +AND dbid = DB_ID() +ORDER BY cp.usecounts DESC OPTION (RECOMPILE); +------ + +-- Helps you connect missing indexes to specific stored procedures or queries +-- This can help you decide whether to add them or not + + +-- Breaks down buffers used by current database by object (table, index) in the buffer cache (Query 69) (Buffer Usage) +-- Note: This query could take some time on a busy instance +SELECT fg.name AS [Filegroup Name], SCHEMA_NAME(o.Schema_ID) AS [Schema Name], +OBJECT_NAME(p.[object_id]) AS [Object Name], p.index_id, +CAST(COUNT(*)/128.0 AS DECIMAL(10, 2)) AS [Buffer size(MB)], +COUNT(*) AS [BufferCount], p.[Rows] AS [Row Count], +p.data_compression_desc AS [Compression Type] +FROM sys.allocation_units AS a WITH (NOLOCK) +INNER JOIN sys.dm_os_buffer_descriptors AS b WITH (NOLOCK) +ON a.allocation_unit_id = b.allocation_unit_id +INNER JOIN sys.partitions AS p WITH (NOLOCK) +ON a.container_id = p.hobt_id +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON p.object_id = o.object_id +INNER JOIN sys.database_files AS f WITH (NOLOCK) +ON b.file_id = f.file_id +INNER JOIN sys.filegroups AS fg WITH (NOLOCK) +ON f.data_space_id = fg.data_space_id +WHERE b.database_id = CONVERT(int, DB_ID()) +AND p.[object_id] > 100 +AND OBJECT_NAME(p.[object_id]) NOT LIKE N'plan_%' +AND OBJECT_NAME(p.[object_id]) NOT LIKE N'sys%' +AND OBJECT_NAME(p.[object_id]) NOT LIKE N'xml_index_nodes%' +GROUP BY fg.name, o.Schema_ID, p.[object_id], p.index_id, + p.data_compression_desc, p.[Rows] +ORDER BY [BufferCount] DESC OPTION (RECOMPILE); +------ + +-- Tells you what tables and indexes are using the most memory in the buffer cache +-- It can help identify possible candidates for data compression + + +-- Get Table names, row counts, and compression status for clustered index or heap (Query 70) (Table Sizes) +SELECT SCHEMA_NAME(o.Schema_ID) AS [Schema Name], OBJECT_NAME(p.object_id) AS [ObjectName], +SUM(p.Rows) AS [RowCount], p.data_compression_desc AS [Compression Type] +FROM sys.partitions AS p WITH (NOLOCK) +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON p.object_id = o.object_id +WHERE index_id < 2 --ignore the partitions from the non-clustered index if any +AND OBJECT_NAME(p.object_id) NOT LIKE N'sys%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'spt_%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'queue_%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'filestream_tombstone%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'fulltext%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'ifts_comp_fragment%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'filetable_updates%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'xml_index_nodes%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'sqlagent_job%' +AND OBJECT_NAME(p.object_id) NOT LIKE N'plan_persist%' +GROUP BY SCHEMA_NAME(o.Schema_ID), p.object_id, data_compression_desc +ORDER BY SUM(p.Rows) DESC OPTION (RECOMPILE); +------ + +-- Gives you an idea of table sizes, and possible data compression opportunities + + + +-- Get some key table properties (Query 71) (Table Properties) +SELECT OBJECT_NAME(t.[object_id]) AS [ObjectName], p.[rows] AS [Table Rows], p.index_id, + p.data_compression_desc AS [Index Data Compression], + t.create_date, t.lock_on_bulk_load, t.is_replicated, t.has_replication_filter, + t.is_tracked_by_cdc, t.lock_escalation_desc, t.is_filetable, + t.is_memory_optimized, t.durability_desc, + t.temporal_type_desc, t.is_remote_data_archive_enabled, t.is_external -- new for SQL Server 2016 +FROM sys.tables AS t WITH (NOLOCK) +INNER JOIN sys.partitions AS p WITH (NOLOCK) +ON t.[object_id] = p.[object_id] +WHERE OBJECT_NAME(t.[object_id]) NOT LIKE N'sys%' +ORDER BY OBJECT_NAME(t.[object_id]), p.index_id OPTION (RECOMPILE); +------ + +-- Gives you some good information about your tables +-- is_memory_optimized and durability_desc were new in SQL Server 2014 +-- temporal_type_desc, is_remote_data_archive_enabled, is_external were new in SQL Server 2016 + +-- sys.tables (Transact-SQL) +-- https://bit.ly/2Gk7998 + + + +-- When were Statistics last updated on all indexes? (Query 72) (Statistics Update) +SELECT SCHEMA_NAME(o.Schema_ID) + N'.' + o.[NAME] AS [Object Name], o.[type_desc] AS [Object Type], + i.[name] AS [Index Name], STATS_DATE(i.[object_id], i.index_id) AS [Statistics Date], + s.auto_created, s.no_recompute, s.user_created, s.is_incremental, s.is_temporary, + st.row_count, st.used_page_count +FROM sys.objects AS o WITH (NOLOCK) +INNER JOIN sys.indexes AS i WITH (NOLOCK) +ON o.[object_id] = i.[object_id] +INNER JOIN sys.stats AS s WITH (NOLOCK) +ON i.[object_id] = s.[object_id] +AND i.index_id = s.stats_id +INNER JOIN sys.dm_db_partition_stats AS st WITH (NOLOCK) +ON o.[object_id] = st.[object_id] +AND i.[index_id] = st.[index_id] +WHERE o.[type] IN ('U', 'V') +AND st.row_count > 0 +ORDER BY STATS_DATE(i.[object_id], i.index_id) DESC OPTION (RECOMPILE); +------ + +-- Helps discover possible problems with out-of-date statistics +-- Also gives you an idea which indexes are the most active + +-- sys.stats (Transact-SQL) +-- https://bit.ly/2GyAxrn + +-- UPDATEs to Statistics (Erin Stellato) +-- https://bit.ly/2vhrYQy + + + + +-- Look at most frequently modified indexes and statistics (Query 73) (Volatile Indexes) +SELECT o.[name] AS [Object Name], o.[object_id], o.[type_desc], s.[name] AS [Statistics Name], + s.stats_id, s.no_recompute, s.auto_created, s.is_incremental, s.is_temporary, + sp.modification_counter, sp.[rows], sp.rows_sampled, sp.last_updated +FROM sys.objects AS o WITH (NOLOCK) +INNER JOIN sys.stats AS s WITH (NOLOCK) +ON s.object_id = o.object_id +CROSS APPLY sys.dm_db_stats_properties(s.object_id, s.stats_id) AS sp +WHERE o.[type_desc] NOT IN (N'SYSTEM_TABLE', N'INTERNAL_TABLE') +AND sp.modification_counter > 0 +ORDER BY sp.modification_counter DESC, o.name OPTION (RECOMPILE); +------ + +-- This helps you understand your workload and make better decisions about +-- things like data compression and adding new indexes to a table + + + +-- Get fragmentation info for all indexes above a certain size in the current database (Query 74) (Index Fragmentation) +-- Note: This query could take some time on a very large database +SELECT DB_NAME(ps.database_id) AS [Database Name], SCHEMA_NAME(o.[schema_id]) AS [Schema Name], +OBJECT_NAME(ps.OBJECT_ID) AS [Object Name], i.[name] AS [Index Name], ps.index_id, +ps.index_type_desc, ps.avg_fragmentation_in_percent, +ps.fragment_count, ps.page_count, i.fill_factor, i.has_filter, +i.filter_definition, i.[allow_page_locks] +FROM sys.dm_db_index_physical_stats(DB_ID(),NULL, NULL, NULL , N'LIMITED') AS ps +INNER JOIN sys.indexes AS i WITH (NOLOCK) +ON ps.[object_id] = i.[object_id] +AND ps.index_id = i.index_id +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON i.[object_id] = o.[object_id] +WHERE ps.database_id = DB_ID() +AND ps.page_count > 2500 +ORDER BY ps.avg_fragmentation_in_percent DESC OPTION (RECOMPILE); +------ + +-- Helps determine whether you have framentation in your relational indexes +-- and how effective your index maintenance strategy is + + +--- Index Read/Write stats (all tables in current DB) ordered by Reads (Query 75) (Overall Index Usage - Reads) +SELECT SCHEMA_NAME(t.[schema_id]) AS [SchemaName], OBJECT_NAME(i.[object_id]) AS [ObjectName], + i.[name] AS [IndexName], i.index_id, + s.user_seeks, s.user_scans, s.user_lookups, + s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], + s.user_updates AS [Writes], + i.[type_desc] AS [Index Type], i.fill_factor AS [Fill Factor], i.has_filter, i.filter_definition, + s.last_user_scan, s.last_user_lookup, s.last_user_seek +FROM sys.indexes AS i WITH (NOLOCK) +LEFT OUTER JOIN sys.dm_db_index_usage_stats AS s WITH (NOLOCK) +ON i.[object_id] = s.[object_id] +AND i.index_id = s.index_id +AND s.database_id = DB_ID() +LEFT OUTER JOIN sys.tables AS t WITH (NOLOCK) +ON t.[object_id] = i.[object_id] +WHERE OBJECTPROPERTY(i.[object_id],'IsUserTable') = 1 +ORDER BY s.user_seeks + s.user_scans + s.user_lookups DESC OPTION (RECOMPILE); -- Order by reads +------ + +-- Show which indexes in the current database are most active for Reads + + +--- Index Read/Write stats (all tables in current DB) ordered by Writes (Query 76) (Overall Index Usage - Writes) +SELECT SCHEMA_NAME(t.[schema_id]) AS [SchemaName],OBJECT_NAME(i.[object_id]) AS [ObjectName], + i.[name] AS [IndexName], i.index_id, + s.user_updates AS [Writes], s.user_seeks + s.user_scans + s.user_lookups AS [Total Reads], + i.[type_desc] AS [Index Type], i.fill_factor AS [Fill Factor], i.has_filter, i.filter_definition, + s.last_system_update, s.last_user_update +FROM sys.indexes AS i WITH (NOLOCK) +LEFT OUTER JOIN sys.dm_db_index_usage_stats AS s WITH (NOLOCK) +ON i.[object_id] = s.[object_id] +AND i.index_id = s.index_id +AND s.database_id = DB_ID() +LEFT OUTER JOIN sys.tables AS t WITH (NOLOCK) +ON t.[object_id] = i.[object_id] +WHERE OBJECTPROPERTY(i.[object_id],'IsUserTable') = 1 +ORDER BY s.user_updates DESC OPTION (RECOMPILE); -- Order by writes +------ + +-- Show which indexes in the current database are most active for Writes + + + +-- Get lock waits for current database (Query 77) (Lock Waits) +SELECT o.name AS [table_name], i.name AS [index_name], ios.index_id, ios.partition_number, + SUM(ios.row_lock_wait_count) AS [total_row_lock_waits], + SUM(ios.row_lock_wait_in_ms) AS [total_row_lock_wait_in_ms], + SUM(ios.page_lock_wait_count) AS [total_page_lock_waits], + SUM(ios.page_lock_wait_in_ms) AS [total_page_lock_wait_in_ms], + SUM(ios.page_lock_wait_in_ms)+ SUM(row_lock_wait_in_ms) AS [total_lock_wait_in_ms] +FROM sys.dm_db_index_operational_stats(DB_ID(), NULL, NULL, NULL) AS ios +INNER JOIN sys.objects AS o WITH (NOLOCK) +ON ios.[object_id] = o.[object_id] +INNER JOIN sys.indexes AS i WITH (NOLOCK) +ON ios.[object_id] = i.[object_id] +AND ios.index_id = i.index_id +WHERE o.[object_id] > 100 +GROUP BY o.name, i.name, ios.index_id, ios.partition_number +HAVING SUM(ios.page_lock_wait_in_ms)+ SUM(row_lock_wait_in_ms) > 0 +ORDER BY total_lock_wait_in_ms DESC OPTION (RECOMPILE); +------ + +-- This query is helpful for troubleshooting blocking and deadlocking issues + + + +-- Look at UDF execution statistics (Query 78) (UDF Statistics) +SELECT OBJECT_NAME(object_id) AS [Function Name], execution_count, + total_worker_time, total_logical_reads, total_physical_reads, total_elapsed_time, + total_elapsed_time/execution_count AS [avg_elapsed_time], + FORMAT(cached_time, 'yyyy-MM-dd HH:mm:ss', 'en-US') AS [Plan Cached Time] +FROM sys.dm_exec_function_stats WITH (NOLOCK) +WHERE database_id = DB_ID() +ORDER BY total_worker_time DESC OPTION (RECOMPILE); +------ + +-- New for SQL Server 2016 +-- Helps you investigate scalar UDF performance issues +-- Does not return information for table valued functions + +-- sys.dm_exec_function_stats (Transact-SQL) +-- https://bit.ly/2q1Q6BM + + +-- Determine which scalar UDFs are in-lineable (Query 79) (Inlineable UDFs) +SELECT OBJECT_NAME(m.object_id) AS [Function Name], is_inlineable, inline_type +FROM sys.sql_modules AS m WITH (NOLOCK) +LEFT OUTER JOIN sys.dm_exec_function_stats AS efs WITH (NOLOCK) +ON m.object_id = efs.object_id +WHERE efs.type_desc = N'SQL_SCALAR_FUNCTION' +OPTION (RECOMPILE); +------ + +-- Scalar UDF Inlining +-- https://bit.ly/2JU971M + +-- sys.sql_modules (Transact-SQL) +-- https://bit.ly/2Qt216S + + +-- Get QueryStore Options for this database (Query 80) (QueryStore Options) +SELECT actual_state_desc, desired_state_desc, [interval_length_minutes], + current_storage_size_mb, [max_storage_size_mb], + query_capture_mode_desc, size_based_cleanup_mode_desc +FROM sys.database_query_store_options WITH (NOLOCK) OPTION (RECOMPILE); +------ + +-- New for SQL Server 2016 +-- Requires that Query Store is enabled for this database + +-- Make sure that the actual_state_desc is the same as desired_state_desc +-- Make sure that the current_storage_size_mb is less than the max_storage_size_mb + +-- Tuning Workload Performance with Query Store +-- https://bit.ly/1kHSl7w + + + +-- Get input buffer information for the current database (Query 81) (Input Buffer) +SELECT es.session_id, DB_NAME(es.database_id) AS [Database Name], + es.login_time, es.cpu_time, es.logical_reads, es.memory_usage, + es.[status], ib.event_info AS [Input Buffer] +FROM sys.dm_exec_sessions AS es WITH (NOLOCK) +CROSS APPLY sys.dm_exec_input_buffer(es.session_id, NULL) AS ib +WHERE es.database_id = DB_ID() +AND es.session_id > 50 +AND es.session_id <> @@SPID OPTION (RECOMPILE); +------ + +-- Gives you input buffer information from all non-system sessions for the current database +-- Replaces DBCC INPUTBUFFER + +-- New DMF for retrieving input buffer in SQL Server +-- https://bit.ly/2uHKMbz + +-- sys.dm_exec_input_buffer (Transact-SQL) +-- https://bit.ly/2J5Hf9q + + + +-- Get any resumable index rebuild operation information (Query 82) (Resumable Index Rebuild) +SELECT OBJECT_NAME(iro.object_id) AS [Object Name], iro.index_id, iro.name AS [Index Name], + iro.sql_text, iro.last_max_dop_used, iro.partition_number, iro.state_desc, + iro.start_time, iro.percent_complete +FROM sys.index_resumable_operations AS iro WITH (NOLOCK) +OPTION (RECOMPILE); +------ + +-- index_resumable_operations (Transact-SQL) +-- https://bit.ly/2pYSWqq + + +-- Get database automatic tuning options (Query 83) (Automatic Tuning Options) +SELECT [name], desired_state_desc, actual_state_desc, reason_desc +FROM sys.database_automatic_tuning_options WITH (NOLOCK) +OPTION (RECOMPILE); +------ + +-- sys.database_automatic_tuning_options (Transact-SQL) +-- https://bit.ly/2FHhLkL + + + +-- Look at recent Full backups for the current database (Query 84) (Recent Full Backups) +SELECT TOP (30) bs.machine_name, bs.server_name, bs.database_name AS [Database Name], bs.recovery_model, +CONVERT (BIGINT, bs.backup_size / 1048576 ) AS [Uncompressed Backup Size (MB)], +CONVERT (BIGINT, bs.compressed_backup_size / 1048576 ) AS [Compressed Backup Size (MB)], +CONVERT (NUMERIC (20,2), (CONVERT (FLOAT, bs.backup_size) / +CONVERT (FLOAT, bs.compressed_backup_size))) AS [Compression Ratio], bs.has_backup_checksums, bs.is_copy_only, bs.encryptor_type, +DATEDIFF (SECOND, bs.backup_start_date, bs.backup_finish_date) AS [Backup Elapsed Time (sec)], +bs.backup_finish_date AS [Backup Finish Date], bmf.physical_device_name AS [Backup Location], bmf.physical_block_size +FROM msdb.dbo.backupset AS bs WITH (NOLOCK) +INNER JOIN msdb.dbo.backupmediafamily AS bmf WITH (NOLOCK) +ON bs.media_set_id = bmf.media_set_id +WHERE bs.database_name = DB_NAME(DB_ID()) +AND bs.[type] = 'D' -- Change to L if you want Log backups +ORDER BY bs.backup_finish_date DESC OPTION (RECOMPILE); +------ + +-- Things to look at: +-- Are your backup sizes and times changing over time? +-- Are you using backup compression? +-- Are you using backup checksums? +-- Are you doing copy_only backups? +-- Are you doing encrypted backups? +-- Have you done any backup tuning with striped backups, or changing the parameters of the backup command? +-- Where are the backups going to? + +-- In SQL Server 2016, native SQL Server backup compression actually works +-- much better with databases that are using TDE than in previous versions +-- https://bit.ly/28Rpb2x + + +-- Microsoft Visual Studio Dev Essentials +-- https://bit.ly/2qjNRxi + +-- Microsoft Azure Learn +-- https://bit.ly/2O0Hacc + diff --git a/Scripts/SQLServer_Memory_Information.sql b/Scripts/SQLServer_Memory_Information.sql new file mode 100644 index 00000000..10753f37 --- /dev/null +++ b/Scripts/SQLServer_Memory_Information.sql @@ -0,0 +1,377 @@ +/* + + Get SQL Server memory detailed information. + 3 row sets: 1 - countes info; 2 - min, max, target memory info; 3 - detailed tree memory info. + ? + 2020-02-04 by Konstantin Taranov + 1.0 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/SQLServer_Memory_Information.sql + +*/ + + +SET NOCOUNT ON; +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SET LOCK_TIMEOUT 10000; + +DECLARE @ServiceName nvarchar(100); +SET @ServiceName = + CASE + WHEN @@SERVICENAME = 'MSSQLSERVER' THEN 'SQLServer:' + ELSE 'MSSQL$' + @@SERVICENAME + ':' + END; + +DECLARE @Perf TABLE ( + object_name nvarchar(20), + counter_name nvarchar(128), + instance_name nvarchar(128), + cntr_value bigint, + formatted_value numeric(20, 2), + shortname nvarchar(20) +); +INSERT INTO @Perf (object_name, counter_name, instance_name, cntr_value, formatted_value, shortname) + SELECT + CASE + WHEN CHARINDEX('Memory Manager', object_name) > 0 THEN 'Memory Manager' + WHEN CHARINDEX('Buffer Manager', object_name) > 0 THEN 'Buffer Manager' + WHEN CHARINDEX('Plan Cache', object_name) > 0 THEN 'Plan Cache' + WHEN CHARINDEX('Buffer Node', object_name) > 0 THEN 'Buffer Node' -- 2008 + WHEN CHARINDEX('Memory Node', object_name) > 0 THEN 'Memory Node' -- 2012 + WHEN CHARINDEX('Cursor', object_name) > 0 THEN 'Cursor' + ELSE NULL + END AS object_name, + CAST(RTRIM(counter_name) AS nvarchar(100)) AS counter_name, + RTRIM(instance_name) AS instance_name, + cntr_value, + CAST(NULL AS decimal(20, 2)) AS formatted_value, + SUBSTRING(counter_name, 1, PATINDEX('% %', counter_name)) shortname + FROM sys.dm_os_performance_counters + WHERE (object_name LIKE @ServiceName + 'Buffer Node%' -- LIKE is faster than =. I have no idea why + OR object_name LIKE @ServiceName + 'Buffer Manager%' + OR object_name LIKE @ServiceName + 'Memory Node%' + OR object_name LIKE @ServiceName + 'Plan Cache%') + AND (counter_name LIKE '%pages %' + OR counter_name LIKE '%Node Memory (KB)%' + OR counter_name = 'Page life expectancy' + ) + OR (object_name = @ServiceName + 'Memory Manager' + AND counter_name IN ('Granted Workspace Memory (KB)', 'Maximum Workspace Memory (KB)', + 'Memory Grants Outstanding', 'Memory Grants Pending', + 'Target Server Memory (KB)', 'Total Server Memory (KB)', + 'Connection Memory (KB)', 'Lock Memory (KB)', + 'Optimizer Memory (KB)', 'SQL Cache Memory (KB)', + -- for 2012 + 'Free Memory (KB)', 'Reserved Server Memory (KB)', + 'Database Cache Memory (KB)', 'Stolen Server Memory (KB)') + ) + OR (object_name LIKE @ServiceName + 'Cursor Manager by Type%' + AND counter_name = 'Cursor memory usage' + AND instance_name = '_Total' + ); + +-- Add unit to 'Cursor memory usage' +UPDATE @Perf +SET counter_name = counter_name + ' (KB)' +WHERE counter_name = 'Cursor memory usage'; + +-- Convert values from pages and KB to MB and rename counters accordingly +UPDATE @Perf +SET counter_name = REPLACE(REPLACE(REPLACE(counter_name, ' pages', ''), ' (KB)', ''), ' (MB)', ''), + formatted_value = + CASE + WHEN counter_name LIKE '%pages' THEN cntr_value / 128. + WHEN counter_name LIKE '%(KB)' THEN cntr_value / 1024. + ELSE cntr_value + END; + +-- Delete some pre 2012 counters for 2012 in order to remove duplicates +DELETE P2008 + FROM @Perf P2008 + INNER JOIN @Perf P2012 + ON REPLACE(P2008.object_name, 'Buffer', 'Memory') = P2012.object_name + AND P2008.shortname = P2012.shortname +WHERE P2008.object_name IN ('Buffer Manager', 'Buffer Node'); + +-- Update counter/object names so they look like in 2012 +UPDATE PC +SET object_name = REPLACE(object_name, 'Buffer', 'Memory'), + counter_name = ISNULL(M.NewName, counter_name) +FROM @Perf PC +LEFT JOIN (SELECT + 'Free' AS OldName, + 'Free Memory' AS NewName +UNION ALL +SELECT + 'Database', + 'Database Cache Memory' +UNION ALL +SELECT + 'Stolen', + 'Stolen Server Memory' +UNION ALL +SELECT + 'Reserved', + 'Reserved Server Memory' +UNION ALL +SELECT + 'Foreign', + 'Foreign Node Memory') M + ON M.OldName = PC.counter_name + AND NewName NOT IN (SELECT + counter_name + FROM @Perf + WHERE object_name = 'Memory Manager') +WHERE object_name IN ('Buffer Manager', 'Buffer Node'); + + +-- Build Memory Tree +DECLARE @MemTree TABLE ( + Id int, + ParentId int, + counter_name nvarchar(128), + formatted_value numeric(20, 2), + shortname nvarchar(20) +); + +-- Level 5 +INSERT @MemTree (Id, ParentId, counter_name, formatted_value, shortname) + SELECT + Id = 1226, + ParentId = 1225, + instance_name AS counter_name, + formatted_value, + shortname + FROM @Perf + WHERE object_name = 'Plan Cache' + AND counter_name IN ('Cache') + AND instance_name <> '_Total'; + +-- Level 4 +INSERT @MemTree (Id, ParentId, counter_name, formatted_value, shortname) + SELECT + Id = 1225, + ParentId = 1220, + 'Plan ' + counter_name AS counter_name, + formatted_value, + shortname + FROM @Perf + WHERE object_name = 'Plan Cache' + AND counter_name IN ('Cache') + AND instance_name = '_Total' + + UNION ALL + + SELECT + Id = 1222, + ParentId = 1220, + counter_name, + formatted_value, + shortname + FROM @Perf + WHERE object_name = 'Cursor' + OR (object_name = 'Memory Manager' + AND shortname IN ('Connection', 'Lock', 'Optimizer', 'SQL')) + + UNION ALL + + SELECT + Id = 1112, + ParentId = 1110, + counter_name, + formatted_value, + shortname + FROM @Perf + WHERE object_name = 'Memory Manager' + AND shortname IN ('Reserved') + UNION ALL + SELECT + Id = P.ParentID + 1, + ParentID = P.ParentID, + 'Used Workspace Memory' AS counter_name, + SUM(used_memory_kb) / 1024. AS formatted_value, + NULL AS shortname + FROM sys.dm_exec_query_resource_semaphores + CROSS JOIN (SELECT + 1220 AS ParentID + UNION ALL + SELECT + 1110) P + GROUP BY P.ParentID; + +-- Level 3 +INSERT @MemTree (Id, ParentId, counter_name, formatted_value, shortname) + SELECT + Id = + CASE counter_name + WHEN 'Granted Workspace Memory' THEN 1110 + WHEN 'Stolen Server Memory' THEN 1220 + ELSE 1210 + END, + ParentId = + CASE counter_name + WHEN 'Granted Workspace Memory' THEN 1100 + ELSE 1200 + END, + counter_name, + formatted_value, + shortname + FROM @Perf + WHERE object_name = 'Memory Manager' + AND counter_name IN ('Stolen Server Memory', 'Database Cache Memory', 'Free Memory', 'Granted Workspace Memory'); + +-- Level 2 +INSERT @MemTree (Id, ParentId, counter_name, formatted_value, shortname) + SELECT + Id = + CASE + WHEN counter_name = 'Maximum Workspace Memory' THEN 1100 + ELSE 1200 + END, + ParentId = 1000, + counter_name, + formatted_value, + shortname + FROM @Perf + WHERE object_name = 'Memory Manager' + AND counter_name IN ('Total Server Memory', 'Maximum Workspace Memory'); + +-- Level 1 +INSERT @MemTree (Id, ParentId, counter_name, formatted_value, shortname) + SELECT + Id = 1000, + ParentId = NULL, + counter_name, + formatted_value, + shortname + FROM @Perf + WHERE object_name = 'Memory Manager' + AND counter_name IN ('Target Server Memory'); + +-- Level 4 -- 'Other Stolen Server Memory' = 'Stolen Server Memory' - SUM(Children of 'Stolen Server Memory') +INSERT @MemTree (Id, ParentId, counter_name, formatted_value, shortname) + SELECT + Id = 1222, + ParentId = 1220, + counter_name = '', + formatted_value = (SELECT + SSM.formatted_value + FROM @MemTree SSM + WHERE Id = 1220) + - SUM(formatted_value), + shortname = 'Other Stolen' + FROM @MemTree + WHERE ParentId = 1220; + +-- Results: + +-- PLE and Memory Grants +SELECT + [Counter Name] = P.counter_name + ISNULL(' (Node: ' + NULLIF(P.instance_name, '') + ')', ''), + cntr_value AS Value, + RecommendedMinimum = + CASE + WHEN P.counter_name = 'Page life expectancy' AND + R.Value <= 300 -- no less than 300 + THEN 300 + WHEN P.counter_name = 'Page life expectancy' AND + R.Value > 300 THEN R.Value + ELSE NULL + END +FROM @Perf P +LEFT JOIN -- Recommended PLE calculations +(SELECT + object_name, + counter_name, + instance_name, + CEILING(formatted_value / 4096. * 5) * 60 AS Value -- 300 per every 4GB of Buffer Pool memory or around 60 seconds (1 minute) per every 819MB +FROM @Perf PD +WHERE counter_name = 'Database Cache Memory') R + ON R.object_name = P.object_name + AND R.instance_name = P.instance_name +WHERE (P.object_name = 'Memory Manager' +AND P.counter_name IN ('Memory Grants Outstanding', 'Memory Grants Pending', 'Page life expectancy') +) +OR -- For NUMA +( +P.object_name = 'Memory Node' +AND P.counter_name = 'Page life expectancy' +AND (SELECT + COUNT(DISTINCT instance_name) +FROM @Perf +WHERE object_name = 'Memory Node') +> 1 +) +ORDER BY P.counter_name DESC, P.instance_name; + +-- Get physical memory +-- You can also extract this information from sys.dm_os_sys_info but the column names have changed starting from 2012 +IF OBJECT_ID('tempdb..#msver') IS NOT NULL + DROP TABLE #msver +CREATE TABLE #msver ( + ID int, + Name sysname, + Internal_Value int, + Value nvarchar(512) +); +INSERT #msver EXEC master.dbo.xp_msver 'PhysicalMemory'; + +-- Physical memory, config parameters and Target memory +SELECT + min_server_mb = (SELECT + CAST(value_in_use AS decimal(20, 2)) + FROM sys.configurations + WHERE name = 'min server memory (MB)'), + max_server_mb = (SELECT + CAST(value_in_use AS decimal(20, 2)) + FROM sys.configurations + WHERE name = 'max server memory (MB)'), + target_mb = (SELECT + formatted_value + FROM @Perf + WHERE object_name = 'Memory Manager' + AND counter_name IN ('Target Server Memory')), + physical_mb = CAST(Internal_Value AS decimal(20, 2)) +FROM #msver; + +-- Memory tree +; +WITH CTE +AS (SELECT + 0 AS lvl, + counter_name, + formatted_value, + Id, + NULL AS ParentId, + shortname, + formatted_value AS TargetServerMemory, + CAST(NULL AS decimal(20, 4)) AS Perc, + CAST(NULL AS decimal(20, 4)) AS PercOfTarget +FROM @MemTree +WHERE ParentId IS NULL +UNION ALL +SELECT + CTE.lvl + 1, + CAST(REPLICATE(' ', 6 * (CTE.lvl)) + NCHAR(124) + REPLICATE(NCHAR(183), 3) + MT.counter_name AS nvarchar(128)), + MT.formatted_value, + MT.Id, + MT.ParentId, + MT.shortname, + CTE.TargetServerMemory, + CAST(ISNULL(1.0 * MT.formatted_value / NULLIF(CTE.formatted_value, 0), 0) AS decimal(20, 4)) AS Perc, + CAST(ISNULL(1.0 * MT.formatted_value / NULLIF(CTE.TargetServerMemory, 0), 0) AS decimal(20, 4)) AS PercOfTarget +FROM @MemTree MT +INNER JOIN CTE + ON MT.ParentId = CTE.Id) +SELECT + counter_name AS [Counter Name], + CASE + WHEN formatted_value > 0 THEN formatted_value + ELSE NULL + END AS [Memory MB], + Perc AS [% of Parent], + CASE + WHEN lvl >= 2 THEN PercOfTarget + ELSE NULL + END AS [% of Target] +FROM CTE +ORDER BY ISNULL(Id, 10000), formatted_value DESC; diff --git a/Scripts/SQL_Azure_Approximate_Datetime_Restart.sql b/Scripts/SQL_Azure_Approximate_Datetime_Restart.sql new file mode 100644 index 00000000..780f3d58 --- /dev/null +++ b/Scripts/SQL_Azure_Approximate_Datetime_Restart.sql @@ -0,0 +1,42 @@ +/* +Author: Mitch Wheat +Original link: https://mitchwheat.com/2018/10/12/when-did-my-azure-sql-database-server-restart/ +Created Date: 2018-10-18 +Modified Date: 2018-10-18 +*/ + +;with cte as +( + SELECT wait_time_ms + FROM sys.dm_os_wait_stats w with(nolock) + WHERE wait_type IN + ( + 'BROKER_TASK_STOP', + 'DIRTY_PAGE_POLL', + 'HADR_FILESTREAM_IOMGR_IOCOMPLETION', + 'LAZYWRITER_SLEEP', + 'LOGMGR_QUEUE', + 'REQUEST_FOR_DEADLOCK_SEARCH', + 'XE_DISPATCHER_WAIT', + 'XE_TIMER_EVENT' + ) +) +select + approx_ms_since_restart = AVG(wait_time_ms), + approximate_restart_date = DATEADD(s, AVG(-wait_time_ms)/1000, GETDATE()) +from +cte +cross join + (select + q1 = min(wait_time_ms), + q3 = max(wait_time_ms), + iqr = max(wait_time_ms) - min(wait_time_ms) + from (select + wait_time_ms, + row_number() over (order by wait_time_ms) as seqnum, + count(*) over (partition by null) as total + from cte + ) t + where seqnum = cast(total * 0.25 as int) or seqnum = cast(total * 0.75 as int) + ) qts + where (wait_time_ms >= q1 - 1.5 * iqr) AND (wait_time_ms <= q3 + 1.5 * iqr); diff --git a/Scripts/SQL_Server_Defaults.sql b/Scripts/SQL_Server_Defaults.sql new file mode 100644 index 00000000..07eeb70a --- /dev/null +++ b/Scripts/SQL_Server_Defaults.sql @@ -0,0 +1,161 @@ +WITH CTE_Defaults (ObjectName, AppliesToObjectType, SettingTypeName, SettingName, ConfiguredValue) AS ( + SELECT 'Global', 'Analysis Services', 'Analysis Services', 'Collect Memory by Category Data', 'No' UNION + SELECT 'Global', 'Analysis Services', 'Analysis Services', 'Maintenance Window Enabled', 'No' UNION + SELECT 'Global', 'Analysis Services', 'Analysis Services', 'Maintenance Window Name', 'None' UNION + SELECT 'Global', 'Analysis Services', 'Analysis Services', 'Synchronization Threshold', '0.00:30:00' UNION + SELECT 'Global', 'Analysis Services', 'Analysis Services', 'Synchronization Type', 'Don''t synchronize automatically.' UNION + SELECT 'Global', 'Analysis Services', 'Top Commands Source', 'Auto-Watch New Objects', 'Yes' UNION + SELECT 'Global', 'Analysis Services', 'Top Commands Source', 'Collect MDX/DMX/XMLA Events', 'Yes' UNION + SELECT 'Global', 'Analysis Services', 'Top Commands Source', 'Maximum Rows To Synchronize', '5000' UNION + SELECT 'Global', 'Analysis Services', 'Top Commands Source', 'Minimum Duration', '0.00:00:01' UNION + SELECT 'Global', 'Analysis Services', 'Top Commands Source', 'Missed Run Wait Time', '0.00:05:00' UNION + SELECT 'Global', 'Analytics Platform System', 'Analytics Platform System', 'Maintenance Window Enabled', 'No' UNION + SELECT 'Global', 'Analytics Platform System', 'Analytics Platform System', 'Maintenance Window Name', 'None' UNION + SELECT 'Global', 'APS', 'APS Distributed Queries Source', 'Auto-Watch New Objects', 'Yes' UNION + SELECT 'Global', 'APS', 'APS Distributed Queries Source', 'Maximum Rows To Synchronize', '5000' UNION + SELECT 'Global', 'APS', 'APS Distributed Queries Source', 'Missed Run Wait Time', '0.00:05:00' UNION + SELECT 'Global', 'APS', 'APS Health Alerts Source', 'Auto-Watch New Objects', 'Yes' UNION + SELECT 'Global', 'APS', 'APS Health Alerts Source', 'Maximum Rows To Synchronize', '5000' UNION + SELECT 'Global', 'APS', 'APS Health Alerts Source', 'Missed Run Wait Time', '0.00:05:00' UNION + SELECT 'Global', 'APS', 'APS Loader Backup Runs Source', 'Auto-Watch New Objects', 'Yes' UNION + SELECT 'Global', 'APS', 'APS Loader Backup Runs Source', 'Maximum Rows To Synchronize', '5000' UNION + SELECT 'Global', 'APS', 'APS Loader Backup Runs Source', 'Missed Run Wait Time', '0.00:05:00' UNION + SELECT 'Global', 'APS Distributed Queries', 'APS Distributed Queries', 'Maximum Runtime Threshold', '0.00:00:00' UNION + SELECT 'Global', 'APS Distributed Queries', 'APS Distributed Queries', 'Maximum Runtime Threshold Percent', '250%' UNION + SELECT 'Global', 'APS Distributed Queries', 'APS Distributed Queries', 'Minimum Runtime Threshold', '0.00:00:00' UNION + SELECT 'Global', 'APS Distributed Queries', 'APS Distributed Queries', 'Minimum Runtime Threshold Percent', '10%' UNION + SELECT 'Global', 'APS Loader Backup Run', 'APS Loader Backup Run', 'Maximum Runtime Threshold', '0.00:00:00' UNION + SELECT 'Global', 'APS Loader Backup Run', 'APS Loader Backup Run', 'Maximum Runtime Threshold Percent', '250%' UNION + SELECT 'Global', 'APS Loader Backup Run', 'APS Loader Backup Run', 'Minimum Runtime Threshold', '0.00:00:00' UNION + SELECT 'Global', 'APS Loader Backup Run', 'APS Loader Backup Run', 'Minimum Runtime Threshold Percent', '10%' UNION + SELECT 'Global', 'Azure SQL Data Warehouse', 'Azure SQL Data Warehouse', 'Maintenance Window Enabled', 'No' UNION + SELECT 'Global', 'Azure SQL Data Warehouse', 'Azure SQL Data Warehouse', 'Maintenance Window Name', 'None' UNION + SELECT 'Global', 'Azure SQL Data Warehouse', 'Azure SQL Data Warehouse Distributed Queries Source', 'Auto-Watch New Objects', 'Yes' UNION + SELECT 'Global', 'Azure SQL Data Warehouse', 'Azure SQL Data Warehouse Distributed Queries Source', 'Maximum Rows To Synchronize', '5000' UNION + SELECT 'Global', 'Azure SQL Data Warehouse', 'Azure SQL Data Warehouse Distributed Queries Source', 'Missed Run Wait Time', '0.00:05:00' UNION + SELECT 'Global', 'Azure SQL Data Warehouse', 'Azure SQL Data Warehouse Loader Backup Runs Source', 'Auto-Watch New Objects', 'Yes' UNION + SELECT 'Global', 'Azure SQL Data Warehouse', 'Azure SQL Data Warehouse Loader Backup Runs Source', 'Maximum Rows To Synchronize', '5000' UNION + SELECT 'Global', 'Azure SQL Data Warehouse', 'Azure SQL Data Warehouse Loader Backup Runs Source', 'Missed Run Wait Time', '0.00:05:00' UNION + SELECT 'Global', 'Azure SQL Data Warehouse Distributed Queries', 'Azure SQL Data Warehouse Distributed Queries', 'Maximum Runtime Threshold', '0.00:00:00' UNION + SELECT 'Global', 'Azure SQL Data Warehouse Distributed Queries', 'Azure SQL Data Warehouse Distributed Queries', 'Maximum Runtime Threshold Percent', '250%' UNION + SELECT 'Global', 'Azure SQL Data Warehouse Distributed Queries', 'Azure SQL Data Warehouse Distributed Queries', 'Minimum Runtime Threshold', '0.00:00:00' UNION + SELECT 'Global', 'Azure SQL Data Warehouse Distributed Queries', 'Azure SQL Data Warehouse Distributed Queries', 'Minimum Runtime Threshold Percent', '10%' UNION + SELECT 'Global', 'Azure SQL Data Warehouse Loader Backup Run', 'Azure SQL Data Warehouse Loader Backup Run', 'Maximum Runtime Threshold', '0.00:00:00' UNION + SELECT 'Global', 'Azure SQL Data Warehouse Loader Backup Run', 'Azure SQL Data Warehouse Loader Backup Run', 'Maximum Runtime Threshold Percent', '250%' UNION + SELECT 'Global', 'Azure SQL Data Warehouse Loader Backup Run', 'Azure SQL Data Warehouse Loader Backup Run', 'Minimum Runtime Threshold', '0.00:00:00' UNION + SELECT 'Global', 'Azure SQL Data Warehouse Loader Backup Run', 'Azure SQL Data Warehouse Loader Backup Run', 'Minimum Runtime Threshold Percent', '10%' UNION + SELECT 'Global', 'Azure SQL Database', 'Azure SQL Database', 'Maintenance Window Enabled', 'No' UNION + SELECT 'Global', 'Azure SQL Database', 'Azure SQL Database', 'Maintenance Window Name', 'None' UNION + SELECT 'Global', 'Azure SQL Database', 'Top SQL Source', 'Auto-Watch New Objects', 'Yes' UNION + SELECT 'Global', 'Azure SQL Database', 'Top SQL Source', 'Collect Batch and RPC Events', 'No' UNION + SELECT 'Global', 'Azure SQL Database', 'Top SQL Source', 'Collect Statement Events', 'No' UNION + SELECT 'Global', 'Azure SQL Database', 'Top SQL Source', 'Maximum Rows To Synchronize', '5000' UNION + SELECT 'Global', 'Azure SQL Database', 'Top SQL Source', 'Minimum CPU', '0' UNION + SELECT 'Global', 'Azure SQL Database', 'Top SQL Source', 'Minimum Duration', '0.00:00:05' UNION + SELECT 'Global', 'Azure SQL Database', 'Top SQL Source', 'Minimum Reads', '0' UNION + SELECT 'Global', 'Azure SQL Database', 'Top SQL Source', 'Minimum Writes', '0' UNION + SELECT 'Global', 'Azure SQL Database', 'Top SQL Source', 'Missed Run Wait Time', '0.00:05:00' UNION + SELECT 'Global', 'Blocking SQL', 'Blocking SQL', 'Maximum Runtime Threshold', '0.00:00:00' UNION + SELECT 'Global', 'Blocking SQL', 'Blocking SQL', 'Maximum Runtime Threshold Percent', '250%' UNION + SELECT 'Global', 'Blocking SQL', 'Blocking SQL', 'Minimum Runtime Threshold', '0.00:00:00' UNION + SELECT 'Global', 'Blocking SQL', 'Blocking SQL', 'Minimum Runtime Threshold Percent', '10%' UNION + SELECT 'Global', 'Database', 'Databases Source', 'Auto-Watch New Objects', 'Yes' UNION + SELECT 'Global', 'Database', 'Databases Source', 'Collect Buffer Data when Buffer > 8GB', 'False' UNION + SELECT 'Global', 'Database', 'Databases Source', 'Max Index Size (MB) to Collect Fragmentation Data', '50000' UNION + SELECT 'Global', 'Database', 'Databases Source', 'Max Partitions to Collect per Database', '500' UNION + SELECT 'Global', 'Database', 'Databases Source', 'Maximum Rows To Synchronize', '5000' UNION + SELECT 'Global', 'Database', 'Databases Source', 'Min Index Size (MB) to Collect Fragmentation Data', '10' UNION + SELECT 'Global', 'Database', 'Databases Source', 'Missed Run Wait Time', '0.00:05:00' UNION + SELECT 'Global', 'Index', 'Index Defragmentation', 'Enable Index Defragmentation', 'False' UNION + SELECT 'Global', 'Index', 'Index Defragmentation', 'Fragmentation Scan Mode', 'Limited' UNION + SELECT 'Global', 'Index', 'Index Defragmentation', 'MAXDOP', '0' UNION + SELECT 'Global', 'Index', 'Index Defragmentation', 'Maximum Concurrent Defrag Operations', '1' UNION + SELECT 'Global', 'Index', 'Index Defragmentation', 'Maximum Duration', '0.02:00:00' UNION + SELECT 'Global', 'Index', 'Index Defragmentation', 'Maximum Runtime Threshold', '0.00:00:00' UNION + SELECT 'Global', 'Index', 'Index Defragmentation', 'Maximum Runtime Threshold Percent', '250%' UNION + SELECT 'Global', 'Index', 'Index Defragmentation', 'Minimum Runtime Threshold', '0.00:00:00' UNION + SELECT 'Global', 'Index', 'Index Defragmentation', 'Minimum Runtime Threshold Percent', '10%' UNION + SELECT 'Global', 'Index', 'Index Defragmentation', 'Partitions', 'All' UNION + SELECT 'Global', 'Index', 'Index Defragmentation', 'Rebuild Threshold %', '30' UNION + SELECT 'Global', 'Index', 'Index Defragmentation', 'Reorg Threshold %', '10' UNION + SELECT 'Global', 'Index', 'Index Defragmentation', 'Run Post-defrag Analysis', 'True' UNION + SELECT 'Global', 'Index', 'Index Defragmentation', 'Schedule', '' UNION + SELECT 'Global', 'Index', 'Index Defragmentation', 'Sort in tempdb', 'False' UNION + SELECT 'Global', 'Index', 'Index Defragmentation', 'Use Online Rebuild', 'True' UNION + SELECT 'Global', 'Reporting Services Report', 'Reporting Services Report', 'Maximum Runtime Threshold', '0.00:00:00' UNION + SELECT 'Global', 'Reporting Services Report', 'Reporting Services Report', 'Maximum Runtime Threshold Percent', '250%' UNION + SELECT 'Global', 'Reporting Services Report', 'Reporting Services Report', 'Minimum Runtime Threshold', '0.00:00:00' UNION + SELECT 'Global', 'Reporting Services Report', 'Reporting Services Report', 'Minimum Runtime Threshold Percent', '10%' UNION + SELECT 'Global', 'SQL Server', 'Blocking SQL Source', 'Auto-Watch New Objects', 'Yes' UNION + SELECT 'Global', 'SQL Server', 'Blocking SQL Source', 'Maximum Rows To Synchronize', '5000' UNION + SELECT 'Global', 'SQL Server', 'Blocking SQL Source', 'Minimum Block Duration', '0.00:00:15' UNION + SELECT 'Global', 'SQL Server', 'Blocking SQL Source', 'Missed Run Wait Time', '0.00:05:00' UNION + SELECT 'Global', 'SQL Server', 'Deadlocks Source', 'Auto-Watch New Objects', 'Yes' UNION + SELECT 'Global', 'SQL Server', 'Deadlocks Source', 'Collect Deadlock Events', 'Yes' UNION + SELECT 'Global', 'SQL Server', 'Deadlocks Source', 'Maximum Rows To Synchronize', '5000' UNION + SELECT 'Global', 'SQL Server', 'Deadlocks Source', 'Missed Run Wait Time', '0.00:05:00' UNION + SELECT 'Global', 'SQL Server', 'Maintenance Plans Source', 'Auto-Watch New Objects', 'Yes' UNION + SELECT 'Global', 'SQL Server', 'Maintenance Plans Source', 'Maximum Rows To Synchronize', '5000' UNION + SELECT 'Global', 'SQL Server', 'Maintenance Plans Source', 'Missed Run Wait Time', '0.00:05:00' UNION + SELECT 'Global', 'SQL Server', 'Reporting Services Reports Source', 'Auto-Watch New Objects', 'Yes' UNION + SELECT 'Global', 'SQL Server', 'Reporting Services Reports Source', 'Maximum Rows To Synchronize', '5000' UNION + SELECT 'Global', 'SQL Server', 'Reporting Services Reports Source', 'Missed Run Wait Time', '0.00:05:00' UNION + SELECT 'Global', 'SQL Server', 'SQL Server', 'Auto-enable SQL Server Agent Tokens', 'Yes' UNION + SELECT 'Global', 'SQL Server', 'SQL Server', 'Auto-recycle Large SQL Server Agent Logs', 'No' UNION + SELECT 'Global', 'SQL Server', 'SQL Server', 'Maintenance Window Enabled', 'No' UNION + SELECT 'Global', 'SQL Server', 'SQL Server', 'Maintenance Window Name', 'None' UNION + SELECT 'Global', 'SQL Server', 'SQL Server', 'Max Databases to Synchronize (largest first)', '100' UNION + SELECT 'Global', 'SQL Server', 'SQL Server', 'Maximum Queue Length', '5' UNION + SELECT 'Global', 'SQL Server', 'SQL Server', 'Synchronization Threshold', '0.00:30:00' UNION + SELECT 'Global', 'SQL Server', 'SQL Server', 'Synchronization Type', 'Don''t synchronize automatically.' UNION + SELECT 'Global', 'SQL Server', 'SQL Server Agent Alerts Source', 'Auto-Watch New Objects', 'Yes' UNION + SELECT 'Global', 'SQL Server', 'SQL Server Agent Alerts Source', 'Maximum Rows To Synchronize', '5000' UNION + SELECT 'Global', 'SQL Server', 'SQL Server Agent Alerts Source', 'Missed Run Wait Time', '0.00:05:00' UNION + SELECT 'Global', 'SQL Server', 'SQL Server Agent Jobs Source', 'Auto-Watch New Objects', 'Yes' UNION + SELECT 'Global', 'SQL Server', 'SQL Server Agent Jobs Source', 'Maximum Rows To Synchronize', '5000' UNION + SELECT 'Global', 'SQL Server', 'SQL Server Agent Jobs Source', 'Missed Run Wait Time', '0.00:05:00' UNION + SELECT 'Global', 'SQL Server', 'SQL Server Agent Log Source', 'Auto-Watch New Objects', 'Yes' UNION + SELECT 'Global', 'SQL Server', 'SQL Server Agent Log Source', 'Maximum Rows To Synchronize', '5000' UNION + SELECT 'Global', 'SQL Server', 'SQL Server Agent Log Source', 'Missed Run Wait Time', '0.00:05:00' UNION + SELECT 'Global', 'SQL Server', 'Top SQL Source', 'Auto-Watch New Objects', 'Yes' UNION + SELECT 'Global', 'SQL Server', 'Top SQL Source', 'Collect Batch and RPC Events', 'Yes' UNION + SELECT 'Global', 'SQL Server', 'Top SQL Source', 'Collect Statement Events', 'Yes' UNION + SELECT 'Global', 'SQL Server', 'Top SQL Source', 'Maximum Rows To Synchronize', '5000' UNION + SELECT 'Global', 'SQL Server', 'Top SQL Source', 'Minimum CPU', '0' UNION + SELECT 'Global', 'SQL Server', 'Top SQL Source', 'Minimum Duration', '0.00:00:05' UNION + SELECT 'Global', 'SQL Server', 'Top SQL Source', 'Minimum Reads', '0' UNION + SELECT 'Global', 'SQL Server', 'Top SQL Source', 'Minimum Writes', '0' UNION + SELECT 'Global', 'SQL Server', 'Top SQL Source', 'Missed Run Wait Time', '0.00:05:00' UNION + SELECT 'Global', 'SQL Server Agent Job', 'SQL Server Agent Job', 'Auto-start Threshold', '0.04:00:00' UNION + SELECT 'Global', 'SQL Server Agent Job', 'SQL Server Agent Job', 'Auto-start Threshold Enabled', 'No' UNION + SELECT 'Global', 'SQL Server Agent Job', 'SQL Server Agent Job', 'Auto-start Type', 'Use default setting.' UNION + SELECT 'Global', 'SQL Server Agent Job', 'SQL Server Agent Job', 'Behavior When Queued', 'Never Queue.' UNION + SELECT 'Global', 'SQL Server Agent Job', 'SQL Server Agent Job', 'Behavior When Queuing', 'Never Queue.' UNION + SELECT 'Global', 'SQL Server Agent Job', 'SQL Server Agent Job', 'Maximum Runtime Threshold', '0.00:00:00' UNION + SELECT 'Global', 'SQL Server Agent Job', 'SQL Server Agent Job', 'Maximum Runtime Threshold Percent', '250%' UNION + SELECT 'Global', 'SQL Server Agent Job', 'SQL Server Agent Job', 'Minimum Runtime Threshold', '0.00:00:00' UNION + SELECT 'Global', 'SQL Server Agent Job', 'SQL Server Agent Job', 'Minimum Runtime Threshold Percent', '10%' UNION + SELECT 'Global', 'SQL Server Agent Job', 'SQL Server Agent Job', 'Queue For', '0.00:30:00' UNION + SELECT 'Global', 'SQL Server Agent Job', 'SQL Server Agent Job', 'Queue Others For', '0.00:30:00' UNION + SELECT 'Global', 'Top Commands', 'Top Commands', 'Maximum Runtime Threshold', '0.01:00:00' UNION + SELECT 'Global', 'Top Commands', 'Top Commands', 'Maximum Runtime Threshold Percent', '250%' UNION + SELECT 'Global', 'Top Commands', 'Top Commands', 'Minimum Runtime Threshold', '0.00:00:00' UNION + SELECT 'Global', 'Top Commands', 'Top Commands', 'Minimum Runtime Threshold Percent', '10%' UNION + SELECT 'Global', 'Top SQL', 'Top SQL', 'Maximum Runtime Threshold', '0.01:00:00' UNION + SELECT 'Global', 'Top SQL', 'Top SQL', 'Maximum Runtime Threshold Percent', '250%' UNION + SELECT 'Global', 'Top SQL', 'Top SQL', 'Minimum Runtime Threshold', '0.00:00:00' UNION + SELECT 'Global', 'Top SQL', 'Top SQL', 'Minimum Runtime Threshold Percent', '10%' UNION + SELECT 'Global', 'Windows', 'Windows Event Logs Source', 'Auto-Watch New Objects', 'Yes' UNION + SELECT 'Global', 'Windows', 'Windows Event Logs Source', 'Maximum Rows To Synchronize', '5000' UNION + SELECT 'Global', 'Windows', 'Windows Event Logs Source', 'Missed Run Wait Time', '0.00:05:00' UNION + SELECT 'Global', 'Windows', 'Windows Tasks Source', 'Auto-Watch New Objects', 'Yes' UNION + SELECT 'Global', 'Windows', 'Windows Tasks Source', 'Maximum Rows To Synchronize', '5000' UNION + SELECT 'Global', 'Windows', 'Windows Tasks Source', 'Missed Run Wait Time', '0.00:05:00' UNION + SELECT 'Global', 'Windows Computer', 'Windows Computer', 'Maintenance Window Enabled', 'No' UNION + SELECT 'Global', 'Windows Computer', 'Windows Computer', 'Maintenance Window Name', 'None' UNION + SELECT 'Global', 'Windows Task', 'Windows Task', 'Maximum Runtime Threshold', '0.00:00:00' UNION + SELECT 'Global', 'Windows Task', 'Windows Task', 'Maximum Runtime Threshold Percent', '250%' UNION + SELECT 'Global', 'Windows Task', 'Windows Task', 'Minimum Runtime Threshold', '0.00:00:00' UNION + SELECT 'Global', 'Windows Task', 'Windows Task', 'Minimum Runtime Threshold Percent', '10%' +) +SELECT * FROM CTE_Defaults; diff --git a/Scripts/Save_Error_Log_To_Table.sql b/Scripts/Save_Error_Log_To_Table.sql new file mode 100644 index 00000000..ba051fea --- /dev/null +++ b/Scripts/Save_Error_Log_To_Table.sql @@ -0,0 +1,64 @@ +/* +Original link: https://sqlstudies.com/2018/05/31/updated-query-to-view-data-in-the-error-log/ +Author: Kenneth Fisher +*/ + +IF OBJECT_ID(N'tempdb..#LogInfo', 'U') IS NOT NULL DROP TABLE #LogInfo; + +DECLARE @searchstring1 nvarchar(500) = ''; +DECLARE @searchstring2 nvarchar(500) = ''; + +---------------------------------------------------------------------- +-- This part of the code was found here: +-- https://ask.sqlservercentral.com/questions/99484/number-of-error-log-files.html + +DECLARE @FileList AS TABLE ( + subdirectory NVARCHAR(4000) NOT NULL + ,DEPTH BIGINT NOT NULL + ,[FILE] BIGINT NOT NULL +); + +DECLARE @ErrorLog NVARCHAR(4000), @ErrorLogPath NVARCHAR(4000); +SELECT @ErrorLog = CAST(SERVERPROPERTY(N'errorlogfilename') AS NVARCHAR(4000)); +SELECT @ErrorLogPath = SUBSTRING(@ErrorLog, 1, LEN(@ErrorLog) - CHARINDEX(N'\', REVERSE(@ErrorLog))) + N'\'; + +INSERT INTO @FileList +EXEC xp_dirtree @ErrorLogPath, 0, 1; + +DECLARE @NumberOfLogfiles INT; +SET @NumberOfLogfiles = (SELECT COUNT(*) FROM @FileList WHERE [@FileList].subdirectory LIKE N'ERRORLOG%'); +-- SELECT @NumberOfLogfiles; +---------------------------------------------------------------------- + +CREATE TABLE #LogInfo ( + LogDate datetime, + ProcessInfo nvarchar(500), + ErrorText nvarchar(max)); + +DECLARE @p1 INT = 0; + +WHILE @p1 < @NumberOfLogfiles +BEGIN + -- P1 is the file number starting at 0 + DECLARE + @p2 INT = 1, + -- P2 1 for SQL logs, 2 for SQL Agent logs + @p3 NVARCHAR(255) = @searchstring1, + -- P3 is a value to search on + @p4 NVARCHAR(255) = @searchstring2 + -- P4 is another search value + +BEGIN TRY + INSERT INTO #LogInfo + EXEC sys.xp_readerrorlog @p1,@p2,@p3,@p4; +END TRY +BEGIN CATCH + PRINT 'Error occurred processing file ' + cast(@p1 as varchar(10)); +END CATCH; + +SET @p1 = @p1 + 1; +END; + +SELECT * FROM #LogInfo +WHERE ProcessInfo NOT IN ('Backup','Logon') +ORDER BY LogDate DESC; diff --git a/Scripts/Security_Audit_Report.sql b/Scripts/Security_Audit_Report.sql new file mode 100644 index 00000000..3bdf3342 --- /dev/null +++ b/Scripts/Security_Audit_Report.sql @@ -0,0 +1,273 @@ +/* +Author: Jeremy +Modified by: John Zabroski +Original link: https://stackoverflow.com/a/52320673/2298061 + +Security Audit Report +1) List all access provisioned to a sql user or windows user/group directly +2) List all access provisioned to a sql user or windows user/group through a database or application role +3) List all access provisioned to the public role + +Columns Returned: +UserName : SQL or Windows/Active Directory user account. This could also be an Active Directory group. +UserType : Value will be either 'SQL User' or 'Windows User'. This reflects the type of user defined for the + SQL Server user account. +PrinciaplUserName: if UserName is not blank, then UserName else DatabaseUserName +PrincipalType : Possible values are 'SQL User', 'Windows User', 'Database Role', 'Windows Group' +DatabaseUserName : Name of the associated user as defined in the database user account. The database user may not be the + same as the server user. +Role : The role name. This will be null if the associated permissions to the object are defined at directly + on the user account, otherwise this will be the name of the role that the user is a member of. +PermissionType : Type of permissions the user/role has on an object. Examples could include CONNECT, EXECUTE, SELECT + DELETE, INSERT, ALTER, CONTROL, TAKE OWNERSHIP, VIEW DEFINITION, etc. + This value may not be populated for all roles. Some built in roles have implicit permission + definitions. +PermissionState : Reflects the state of the permission type, examples could include GRANT, DENY, etc. + This value may not be populated for all roles. Some built in roles have implicit permission + definitions. +ObjectType : Type of object the user/role is assigned permissions on. Examples could include USER_TABLE, + SQL_SCALAR_FUNCTION, SQL_INLINE_TABLE_VALUED_FUNCTION, SQL_STORED_PROCEDURE, VIEW, etc. + This value may not be populated for all roles. Some built in roles have implicit permission + definitions. +ObjectName : Name of the object that the user/role is assigned permissions on. + This value may not be populated for all roles. Some built in roles have implicit permission + definitions. +ColumnName : Name of the column of the object that the user/role is assigned permissions on. This value + is only populated if the object is a table, view or a table value function. +*/ + +DECLARE @HideDatabaseDiagrams BIT = 1; + +--List all access provisioned to a sql user or windows user/group directly +SELECT + [UserName] = CASE princ.[type] + WHEN 'S' THEN princ.[name] + WHEN 'U' THEN ulogin.[name] COLLATE Latin1_General_CI_AI + WHEN 'R' THEN NULL -- Database Role + WHEN 'G' THEN NULL -- Windows Group + ELSE NULL + END, + [UserType] = CASE princ.[type] + WHEN 'S' THEN 'SQL User' + WHEN 'U' THEN 'Windows User' + WHEN 'R' THEN NULL -- Database Role + WHEN 'G' THEN NULL -- Windows Group + ELSE princ.[type] + END, + [PrincipalUserName] = COALESCE( + CASE princ.[type] + WHEN 'S' THEN princ.[name] + WHEN 'U' THEN ulogin.[name] COLLATE Latin1_General_CI_AI + WHEN 'R' THEN NULL -- Database Role + WHEN 'G' THEN NULL -- Windows Group + ELSE NULL + END, + princ.[name] + ), + [PrincipalType] = CASE princ.[type] + WHEN 'S' THEN 'SQL User' + WHEN 'U' THEN 'Windows User' + WHEN 'R' THEN 'Database Role' + WHEN 'G' THEN 'Windows Group' + END, + [DatabaseUserName] = princ.[name], + [Role] = null, + [PermissionType] = perm.[permission_name], + [PermissionState] = perm.[state_desc], + [ObjectType] = obj.type_desc,--perm.[class_desc], + [ObjectSchema] = OBJECT_SCHEMA_NAME(perm.major_id), + [ObjectName] = OBJECT_NAME(perm.major_id), + [ColumnName] = col.[name] +FROM + --database user + sys.database_principals princ +LEFT JOIN + --Login accounts + sys.login_token ulogin on princ.[sid] = ulogin.[sid] +LEFT JOIN + --Permissions + sys.database_permissions perm ON perm.[grantee_principal_id] = princ.[principal_id] +LEFT JOIN + --Table columns + sys.columns col ON col.[object_id] = perm.major_id + AND col.[column_id] = perm.[minor_id] +LEFT JOIN + sys.objects obj ON perm.[major_id] = obj.[object_id] +WHERE + princ.[type] in ('S','U') + AND CASE + WHEN @HideDatabaseDiagrams = 1 AND + princ.[name] = 'guest' + AND ( + ( + obj.type_desc = 'SQL_SCALAR_FUNCTION' + AND OBJECT_NAME(perm.major_id) = 'fn_diagramobjects' + ) + OR ( + obj.type_desc = 'SQL_STORED_PROCEDURE' + AND OBJECT_NAME(perm.major_id) IN + ( + N'sp_alterdiagram', + N'sp_creatediagram', + N'sp_dropdiagram', + N'sp_helpdiagramdefinition', + N'sp_helpdiagrams', + N'sp_renamediagram' + ) + ) + ) + THEN 0 + ELSE 1 + END = 1 +UNION +--List all access provisioned to a sql user or windows user/group through a database or application role +SELECT + [UserName] = CASE memberprinc.[type] + WHEN 'S' THEN memberprinc.[name] + WHEN 'U' THEN ulogin.[name] COLLATE Latin1_General_CI_AI + WHEN 'R' THEN NULL -- Database Role + WHEN 'G' THEN NULL -- Windows Group + ELSE NULL + END, + [UserType] = CASE memberprinc.[type] + WHEN 'S' THEN 'SQL User' + WHEN 'U' THEN 'Windows User' + WHEN 'R' THEN NULL -- Database Role + WHEN 'G' THEN NULL -- Windows Group + END, + [PrincipalUserName] = COALESCE( + CASE memberprinc.[type] + WHEN 'S' THEN memberprinc.[name] + WHEN 'U' THEN ulogin.[name] COLLATE Latin1_General_CI_AI + WHEN 'R' THEN NULL -- Database Role + WHEN 'G' THEN NULL -- Windows Group + ELSE NULL + END, + memberprinc.[name] + ), + [PrincipalType] = CASE memberprinc.[type] + WHEN 'S' THEN 'SQL User' + WHEN 'U' THEN 'Windows User' + WHEN 'R' THEN 'Database Role' + WHEN 'G' THEN 'Windows Group' + END, + [DatabaseUserName] = memberprinc.[name], + [Role] = roleprinc.[name], + [PermissionType] = perm.[permission_name], + [PermissionState] = perm.[state_desc], + [ObjectType] = obj.type_desc,--perm.[class_desc], + [ObjectSchema] = OBJECT_SCHEMA_NAME(perm.major_id), + [ObjectName] = OBJECT_NAME(perm.major_id), + [ColumnName] = col.[name] +FROM + --Role/member associations + sys.database_role_members members +JOIN + --Roles + sys.database_principals roleprinc ON roleprinc.[principal_id] = members.[role_principal_id] +JOIN + --Role members (database users) + sys.database_principals memberprinc ON memberprinc.[principal_id] = members.[member_principal_id] +LEFT JOIN + --Login accounts + sys.login_token ulogin on memberprinc.[sid] = ulogin.[sid] +LEFT JOIN + --Permissions + sys.database_permissions perm ON perm.[grantee_principal_id] = roleprinc.[principal_id] +LEFT JOIN + --Table columns + sys.columns col on col.[object_id] = perm.major_id + AND col.[column_id] = perm.[minor_id] +LEFT JOIN + sys.objects obj ON perm.[major_id] = obj.[object_id] +WHERE + CASE + WHEN @HideDatabaseDiagrams = 1 AND + memberprinc.[name] = 'guest' + AND ( + ( + obj.type_desc = 'SQL_SCALAR_FUNCTION' + AND OBJECT_NAME(perm.major_id) = 'fn_diagramobjects' + ) + OR ( + obj.type_desc = 'SQL_STORED_PROCEDURE' + AND OBJECT_NAME(perm.major_id) IN + ( + N'sp_alterdiagram', + N'sp_creatediagram', + N'sp_dropdiagram', + N'sp_helpdiagramdefinition', + N'sp_helpdiagrams', + N'sp_renamediagram' + ) + ) + ) + THEN 0 + ELSE 1 + END = 1 +UNION +--List all access provisioned to the public role, which everyone gets by default +SELECT + [UserName] = '{All Users}', + [UserType] = '{All Users}', + [PrincipalUserName] = '{All Users}', + [PrincipalType] = '{All Users}', + [DatabaseUserName] = '{All Users}', + [Role] = roleprinc.[name], + [PermissionType] = perm.[permission_name], + [PermissionState] = perm.[state_desc], + [ObjectType] = obj.type_desc,--perm.[class_desc], + [ObjectSchema] = OBJECT_SCHEMA_NAME(perm.major_id), + [ObjectName] = OBJECT_NAME(perm.major_id), + [ColumnName] = col.[name] +FROM + --Roles + sys.database_principals roleprinc +LEFT JOIN + --Role permissions + sys.database_permissions perm ON perm.[grantee_principal_id] = roleprinc.[principal_id] +LEFT JOIN + --Table columns + sys.columns col on col.[object_id] = perm.major_id + AND col.[column_id] = perm.[minor_id] +JOIN + --All objects + sys.objects obj ON obj.[object_id] = perm.[major_id] +WHERE + --Only roles + roleprinc.[type] = 'R' AND + --Only public role + roleprinc.[name] = 'public' AND + --Only objects of ours, not the MS objects + obj.is_ms_shipped = 0 + AND CASE + WHEN @HideDatabaseDiagrams = 1 AND + roleprinc.[name] = 'public' + AND ( + ( + obj.type_desc = 'SQL_SCALAR_FUNCTION' + AND OBJECT_NAME(perm.major_id) = 'fn_diagramobjects' + ) + OR ( + obj.type_desc = 'SQL_STORED_PROCEDURE' + AND OBJECT_NAME(perm.major_id) IN + ( + N'sp_alterdiagram', + N'sp_creatediagram', + N'sp_dropdiagram', + N'sp_helpdiagramdefinition', + N'sp_helpdiagrams', + N'sp_renamediagram' + ) + ) + ) + THEN 0 + ELSE 1 + END = 1 +ORDER BY + princ.[name], + OBJECT_NAME(perm.major_id), + col.[name], + perm.[permission_name], + perm.[state_desc], + obj.type_desc; diff --git a/Scripts/Selects_That_Cause_Writes.sql b/Scripts/Selects_That_Cause_Writes.sql new file mode 100644 index 00000000..24f86ccd --- /dev/null +++ b/Scripts/Selects_That_Cause_Writes.sql @@ -0,0 +1,67 @@ +/* +Created by: Eric Darling +Modified: 2019-04-08 by Konstantin Taranov +Original link: https://erikdarlingdata.com/2019/04/selects-that-cause-writes/ +Source link: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Selects_That_Cause_Writes.sql +*/ + +WITH XMLNAMESPACES ( 'http://schemas.microsoft.com/sqlserver/2004/07/showplan' AS x ) +, writes AS + ( + SELECT TOP(100) + deqs.statement_start_offset, + deqs.statement_end_offset, + deqs.plan_handle, + deqs.creation_time, + deqs.last_execution_time, + deqs.total_logical_writes, + deqs.last_logical_writes, + deqs.min_logical_writes, + deqs.max_logical_writes, + deqs.query_hash, + deqs.query_plan_hash + FROM sys.dm_exec_query_stats AS deqs + WHERE deqs.min_logical_writes > 1024. + ORDER BY deqs.min_logical_writes DESC + ), + plans + AS + ( + SELECT DISTINCT + w.plan_handle, + w.statement_start_offset, + w.statement_end_offset, + w.creation_time, + w.last_execution_time, + w.total_logical_writes, + w.last_logical_writes, + w.min_logical_writes, + w.max_logical_writes + FROM writes AS w + CROSS APPLY sys.dm_exec_query_plan(w.plan_handle) AS deqp + CROSS APPLY deqp.query_plan.nodes('//x:StmtSimple') AS s(c) + WHERE deqp.dbid > 4 + AND s.c.value('@StatementType', 'VARCHAR(100)') = 'SELECT' + AND NOT EXISTS ( SELECT 1/0 --If nothing comes up, quote out the NOT EXISTS. + FROM writes AS w2 + CROSS APPLY deqp.query_plan.nodes('//x:StmtSimple') AS s2(c) + WHERE w2.query_hash = w.query_hash + AND w2.query_plan_hash = w.query_plan_hash + AND s2.c.value('@StatementType', 'VARCHAR(100)') <> 'SELECT' ) + ) +SELECT p.creation_time, + p.last_execution_time, + p.total_logical_writes, + p.last_logical_writes, + p.min_logical_writes, + p.max_logical_writes, + SUBSTRING( + dest.text, ( p.statement_start_offset / 2 ) + 1, + (( CASE p.statement_end_offset WHEN -1 THEN DATALENGTH(dest.text) ELSE p.statement_end_offset END + - p.statement_start_offset ) / 2 ) + 1) AS text, + deqp.query_plan +FROM plans AS p +CROSS APPLY sys.dm_exec_sql_text(p.plan_handle) AS dest +CROSS APPLY sys.dm_exec_query_plan(p.plan_handle) AS deqp +ORDER BY p.min_logical_writes DESC +OPTION (RECOMPILE); diff --git a/Scripts/Shredding_XML_Data_From_Extended_Events.sql b/Scripts/Shredding_XML_Data_From_Extended_Events.sql new file mode 100644 index 00000000..20440f85 --- /dev/null +++ b/Scripts/Shredding_XML_Data_From_Extended_Events.sql @@ -0,0 +1,129 @@ +/* +Author: Max Vernon +Created Date: 2019-02-10 +Original link: https://itsalljustelectrons.blogspot.com/2019/02/shredding-xml-data-from-extended-events.html +Source link: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Shredding_XML_Data_From_Extended_Events.sql +Modified: 2019-02-14 by Konstantin Taranov +*/ + +USE master; +GO + +IF OBJECT_ID('XE_TSQL_TypeXref') IS NULL +EXEC('CREATE VIEW XE_TSQL_TypeXref AS SELECT 1 AS Alias'); +GO + +/* + This view attempts to map each Extended Events data type + to a TSQL data type. +*/ +ALTER VIEW dbo.XE_TSQL_TypeXref +AS +SELECT + o.name XE_type, o.description XE_type_description, + o.capabilities, o.capabilities_desc, o.type_size XE_type_size, + CASE type_name + --These mappings should be safe. + --They correspond almost directly to each other. + WHEN 'ansi_string' THEN 'VARCHAR(MAX)' + WHEN 'binary_data' THEN 'VARBINARY(MAX)' + WHEN 'boolean' THEN 'BIT' + WHEN 'char' THEN 'VARCHAR(MAX)' + WHEN 'guid' THEN 'UNIQUEIDENTIFIER' + WHEN 'int16' THEN 'SMALLINT' + WHEN 'int32' THEN 'INT' + WHEN 'int64' THEN 'BIGINT' + WHEN 'int8' THEN 'SMALLINT' + WHEN 'uint16' THEN 'INT' + WHEN 'uint32' THEN 'BIGINT' + WHEN 'uint64' THEN 'BIGINT' --possible overflow? + WHEN 'uint8' THEN 'SMALLINT' + WHEN 'unicode_string' THEN 'NVARCHAR(MAX)' + WHEN 'xml' THEN 'XML' + + --These mappings are based off of descriptions and type_size. + WHEN 'cpu_cycle' THEN 'BIGINT' + WHEN 'filetime' THEN 'BIGINT' + WHEN 'wchar' THEN 'NVARCHAR(2)' + + --How many places of precision? + WHEN 'float32' THEN 'NUMERIC(30, 4)' + WHEN 'float64' THEN 'NUMERIC(30, 4)' + + --These mappings? Not sure. Default to NVARCHAR(MAX). + WHEN 'activity_id' THEN 'NVARCHAR(MAX)' + WHEN 'activity_id_xfer' THEN 'NVARCHAR(MAX)' + WHEN 'ansi_string_ptr' THEN 'NVARCHAR(MAX)' + WHEN 'callstack' THEN 'NVARCHAR(MAX)' + WHEN 'guid_ptr' THEN 'NVARCHAR(MAX)' + WHEN 'null' THEN 'NVARCHAR(MAX)' + WHEN 'ptr' THEN 'NVARCHAR(MAX)' + WHEN 'unicode_string_ptr' THEN 'NVARCHAR(MAX)' + END AS SqlDataType +FROM sys.dm_xe_objects o +WHERE o.object_type = 'type'; +GO + + +DECLARE @XESessionName SYSNAME = N'system_health'; +DECLARE @Tsql NVARCHAR(MAX) = N''; + +;WITH AllSessionEventFields AS +( + --Unique Global Fields (Actions) across all events for the session. + SELECT DISTINCT sa.name EventField, 'action' AS XmlNodeName, + CASE WHEN x.SqlDataType IS NULL THEN 'text' ELSE 'value' END AS XmlSubNodeName, + 'Global Fields (Action)' AS FieldType, o.type_name XE_type, + COALESCE(x.SqlDataType, 'NVARCHAR(MAX)') AS SqlDataType + FROM sys.server_event_sessions s + JOIN sys.server_event_session_events se + ON se.event_session_id = s.event_session_id + JOIN sys.server_event_session_actions sa + ON sa.event_session_id = s.event_session_id + AND sa.event_id = se.event_id + JOIN sys.dm_xe_objects o ON o.name = sa.name AND o.object_type = 'action' + LEFT JOIN master.dbo.XE_TSQL_TypeXref x ON x.XE_type = o.type_name + WHERE s.name = @XESessionName + UNION + --Unique Event Fields across all events for the session. + SELECT DISTINCT c.name EventField, 'data' AS XmlNodeName, + CASE WHEN x.SqlDataType IS NULL THEN 'text' ELSE 'value' END AS XmlSubNodeName, + 'Event Fields' AS FieldType, c.type_name XE_type, + COALESCE(x.SqlDataType, 'NVARCHAR(MAX)') AS SqlDataType + FROM sys.server_event_sessions s + JOIN sys.server_event_session_events se + ON se.event_session_id = s.event_session_id + JOIN sys.dm_xe_object_columns c + ON c.object_name = se.name + AND c.column_type = 'data' + LEFT JOIN master.dbo.XE_TSQL_TypeXref x + ON x.XE_type = c.type_name + WHERE s.name = @XESessionName +) +SELECT @Tsql = @Tsql + CHAR(9) + + CASE + WHEN f.SqlDataType = 'XML' THEN + 'event_data.query (''(/event/' + f.XmlNodeName + '[@name=''''' + f.EventField + ''''']/' + + f.XmlSubNodeName + ')[1]'') AS [' + f.EventField + '],' + CHAR(13) + CHAR(10) + ELSE + 'event_data.value (''(/event/' + f.XmlNodeName + '[@name=''''' + f.EventField + ''''']/' + + f.XmlSubNodeName + ')[1]'', ''' + f.SqlDataType + ''') AS [' + f.EventField + '],' + CHAR(13) + CHAR(10) + END +FROM AllSessionEventFields f +ORDER BY f.EventField; + +SELECT @Tsql = LEFT(@Tsql, LEN(@Tsql) - 3); +SELECT @Tsql = ';WITH XEvents AS +( + SELECT object_name, CAST(event_data AS XML) AS event_data + FROM sys.fn_xe_file_target_read_file ( ''' + @XESessionName + '*.xel'', NULL, NULL, NULL ) +) +SELECT TOP(100) object_name, event_data,' + CHAR(13) + CHAR(10) + @Tsql + ' +FROM XEvents;'; + +/* +PRINT does not work - truncated @tsql variable, using XML trick instead +PRINT(@Tsql); +*/ +SELECT CAST('' AS XML); +EXECUTE sp_executesql @Tsql; diff --git a/Scripts/Simulate_Permissions_Logins_Change.sql b/Scripts/Simulate_Permissions_Logins_Change.sql new file mode 100644 index 00000000..b73c1839 --- /dev/null +++ b/Scripts/Simulate_Permissions_Logins_Change.sql @@ -0,0 +1,111 @@ +USE master; + --create a user + CREATE LOGIN HenryTheGreenEngine WITH PASSWORD = 'ePaCqshha7m4iyhj'; + GO + CREATE LOGIN PercyTheSmallEngine WITH PASSWORD = 'tRoUbl3som3Eng1n3s'; + GO + Declare @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,rAnd()*60)),2);WAITFOR DELAY @delay; + CREATE SERVER ROLE Pirates AUTHORIZATION sysadmin; + GO + Declare @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,rAnd()*60)),2);WAITFOR DELAY @delay; + ALTER SERVER ROLE Pirates ADD MEMBER PercyTheSmallEngine; + GO + Declare @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,rAnd()*60)),2);WAITFOR DELAY @delay; + ALTER SERVER ROLE serveradmin ADD MEMBER Pirates; + GO + Declare @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,rAnd()*60)),2);WAITFOR DELAY @delay; + ALTER SERVER ROLE setupadmin ADD MEMBER Pirates; + GO + Declare @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,rAnd()*60)),2);WAITFOR DELAY @delay; + GRANT ALTER ON LOGIN::[NT Service\MSSQLSERVER] TO Pirates; + GO + Declare @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,rAnd()*60)),2);WAITFOR DELAY @delay; + GRANT CONTROL ON LOGIN::[NT Service\MSSQLSERVER] TO Pirates; + GO + Declare @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,rAnd()*60)),2);WAITFOR DELAY @delay; + GRANT IMPERSONATE ON LOGIN::[NT Service\MSSQLSERVER] TO Pirates; + GO + Declare @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,rAnd()*60)),2);WAITFOR DELAY @delay; + GRANT VIEW DEFINITION ON LOGIN::[NT Service\MSSQLSERVER] TO Pirates; + GO + Declare @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,rAnd()*60)),2);WAITFOR DELAY @delay; + GRANT ALTER ON LOGIN::[NT SERVICE\SQLWriter] TO Pirates; + GO + Declare @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,rAnd()*60)),2);WAITFOR DELAY @delay; + GRANT CONTROL ON LOGIN::[NT SERVICE\SQLWriter] TO Pirates; + GO + Declare @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,rAnd()*60)),2);WAITFOR DELAY @delay; + GRANT IMPERSONATE ON LOGIN::[NT SERVICE\SQLWriter] TO Pirates; + -- + USE AdventureWorks2016; + GO + Declare @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,rAnd()*60)),2);WAITFOR DELAY @delay; + --greate user in adventureworks + CREATE USER dodgy FOR LOGIN HenryTheGreenEngine WITH DEFAULT_SCHEMA = dbo; + GO + Declare @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,rAnd()*60)),2);WAITFOR DELAY @delay; + ALTER ROLE db_owner ADD MEMBER dodgy; + GO + CREATE TABLE silly (TheKey INT IDENTITY); + GO + Declare @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,rAnd()*60)),2);WAITFOR DELAY @delay; + GRANT SELECT ON silly TO dodgy WITH GRANT OPTION; + GO + Declare @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,rAnd()*60)),2);WAITFOR DELAY @delay; + REVOKE SELECT ON silly FROM dodgy CASCADE; + GO + CREATE USER TankEngineThomas WITHOUT LOGIN WITH DEFAULT_SCHEMA = dbo; + GO + Declare @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,rAnd()*60)),2);WAITFOR DELAY @delay; + ALTER ROLE db_owner ADD MEMBER TankEngineThomas; + DROP USER TankEngineThomas; + GO + Declare @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,rAnd()*60)),2);WAITFOR DELAY @delay; + DROP USER dodgy; + DROP TABLE silly; + DROP LOGIN HenryTheGreenEngine; + DROP LOGIN PercyTheSmallEngine + GO + DECLARE @RoleName sysname; + SET @RoleName = N'Pirates'; + IF @RoleName <> N'public' + AND + ( + SELECT server_principals.is_fixed_role + FROM sys.server_principals + WHERE server_principals.name = @RoleName + ) = 0 + BEGIN + DECLARE @RoleMemberName sysname; + DECLARE Member_Cursor CURSOR FOR + SELECT server_principals.name + FROM sys.server_principals + WHERE server_principals.principal_id IN + ( + SELECT server_role_members.member_principal_id + FROM sys.server_role_members + WHERE server_role_members.role_principal_id IN + ( + SELECT principal_id FROM sys.server_principals WHERE name = @RoleName + AND type = 'R' + ) + ); + OPEN Member_Cursor; + FETCH NEXT FROM Member_Cursor + INTO @RoleMemberName; + DECLARE @SQL NVARCHAR(4000); + WHILE @@Fetch_Status = 0 + BEGIN + SET @SQL = + N'ALTER SERVER ROLE ' + QuoteName(@RoleName, '[') + N' DROP MEMBER ' + + QuoteName(@RoleMemberName, '['); + EXEC (@SQL); + FETCH NEXT FROM Member_Cursor + INTO @RoleMemberName; + END; + CLOSE Member_Cursor; + DEALLOCATE Member_Cursor; + END; + DROP SERVER ROLE Pirates; + GO + \ No newline at end of file diff --git a/Scripts/Simulate_SQL_Server_Users_Hack.sql b/Scripts/Simulate_SQL_Server_Users_Hack.sql new file mode 100644 index 00000000..6d0c5e71 --- /dev/null +++ b/Scripts/Simulate_SQL_Server_Users_Hack.sql @@ -0,0 +1,121 @@ +/* +Author: Phill Factor +Created date: 2018-10-04 +Modified date: 2019-03-12 by Konstantin Taranov +Original link: https://www.red-gate.com/hub/product-learning/sql-monitor/monitoring-changes-permissions-users-roles-logins +Source link: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Simulate_SQL_Server_Users_Hack.sql +*/ + +USE master; +--create a user +CREATE LOGIN HenryTheGreenEngine WITH PASSWORD = 'ePaCqshha7m4iyhj'; +GO +CREATE LOGIN PercyTheSmallEngine WITH PASSWORD = 'tRoUbl3som3Eng1n3s'; +GO +DECLARE @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,RAND()*60)),2);WAITFOR DELAY @delay; +CREATE SERVER ROLE Pirates AUTHORIZATION sysadmin; +GO +DECLARE @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,RAND()*60)),2);WAITFOR DELAY @delay; +ALTER SERVER ROLE Pirates ADD MEMBER PercyTheSmallEngine; +GO +DECLARE @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,RAND()*60)),2);WAITFOR DELAY @delay; +ALTER SERVER ROLE serveradmin ADD MEMBER Pirates; +GO +DECLARE @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,RAND()*60)),2);WAITFOR DELAY @delay; +ALTER SERVER ROLE setupadmin ADD MEMBER Pirates; +GO +DECLARE @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,RAND()*60)),2);WAITFOR DELAY @delay; +GRANT ALTER ON LOGIN::[NT Service\MSSQLSERVER] TO Pirates; +GO +DECLARE @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,RAND()*60)),2);WAITFOR DELAY @delay; +GRANT CONTROL ON LOGIN::[NT Service\MSSQLSERVER] TO Pirates; +GO +DECLARE @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,RAND()*60)),2);WAITFOR DELAY @delay; +GRANT IMPERSONATE ON LOGIN::[NT Service\MSSQLSERVER] TO Pirates; +GO +DECLARE @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,RAND()*60)),2);WAITFOR DELAY @delay; +GRANT VIEW DEFINITION ON LOGIN::[NT Service\MSSQLSERVER] TO Pirates; +GO +DECLARE @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,RAND()*60)),2);WAITFOR DELAY @delay; +GRANT ALTER ON LOGIN::[NT SERVICE\SQLWriter] TO Pirates; +GO +DECLARE @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,RAND()*60)),2);WAITFOR DELAY @delay; +GRANT CONTROL ON LOGIN::[NT SERVICE\SQLWriter] TO Pirates; +GO +DECLARE @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,RAND()*60)),2);WAITFOR DELAY @delay; +GRANT IMPERSONATE ON LOGIN::[NT SERVICE\SQLWriter] TO Pirates; + + +/* Create users in any not system database */ +USE AdventureWorks2016; +GO +DECLARE @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,RAND()*60)),2);WAITFOR DELAY @delay; +--greate user in adventureworks +CREATE USER dodgy FOR LOGIN HenryTheGreenEngine WITH DEFAULT_SCHEMA = dbo; +GO +DECLARE @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,RAND()*60)),2);WAITFOR DELAY @delay; +ALTER ROLE db_owner ADD MEMBER dodgy; +GO +CREATE TABLE silly (TheKey INT IDENTITY); +GO +DECLARE @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,RAND()*60)),2);WAITFOR DELAY @delay; +GRANT SELECT ON silly TO dodgy WITH GRANT OPTION; +GO +DECLARE @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,RAND()*60)),2);WAITFOR DELAY @delay; +REVOKE SELECT ON silly FROM dodgy CASCADE; +GO +CREATE USER TankEngineThomas WITHOUT LOGIN WITH DEFAULT_SCHEMA = dbo; +GO +DECLARE @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,RAND()*60)),2);WAITFOR DELAY @delay; +ALTER ROLE db_owner ADD MEMBER TankEngineThomas; +DROP USER TankEngineThomas; +GO +DECLARE @delay varchar(8)= '00:00:'+Right('0'+convert(varchar(2),convert(int,RAND()*60)),2);WAITFOR DELAY @delay; +DROP USER dodgy; +DROP TABLE silly; +DROP LOGIN HenryTheGreenEngine; +DROP LOGIN PercyTheSmallEngine +GO +DECLARE @RoleName sysname; +SET @RoleName = N'Pirates'; +IF @RoleName <> N'public' + AND + ( + SELECT server_principals.is_fixed_role + FROM sys.server_principals + WHERE server_principals.name = @RoleName + ) = 0 + BEGIN + DECLARE @RoleMemberName sysname; + DECLARE Member_Cursor CURSOR FOR + SELECT server_principals.name + FROM sys.server_principals + WHERE server_principals.principal_id IN + ( + SELECT server_role_members.member_principal_id + FROM sys.server_role_members + WHERE server_role_members.role_principal_id IN + ( + SELECT principal_id FROM sys.server_principals WHERE name = @RoleName +AND type = 'R' + ) + ); + OPEN Member_Cursor; + FETCH NEXT FROM Member_Cursor + INTO @RoleMemberName; + DECLARE @SQL NVARCHAR(4000); + WHILE @@Fetch_Status = 0 + BEGIN + SET @SQL = + N'ALTER SERVER ROLE ' + QuoteName(@RoleName, '[') + N' DROP MEMBER ' + + QuoteName(@RoleMemberName, '['); + EXEC (@SQL); + FETCH NEXT FROM Member_Cursor + INTO @RoleMemberName; + END; + CLOSE Member_Cursor; + DEALLOCATE Member_Cursor; + END; +DROP SERVER ROLE Pirates; +GO + diff --git a/Scripts/Sort_SQL_Server_Tables_into_similarly_sized_buckets.sql b/Scripts/Sort_SQL_Server_Tables_into_similarly_sized_buckets.sql new file mode 100644 index 00000000..ee01e0a7 --- /dev/null +++ b/Scripts/Sort_SQL_Server_Tables_into_similarly_sized_buckets.sql @@ -0,0 +1,133 @@ +/* +Author: Bill Fellows +Original link: http://billfellows.blogspot.com/2018/04/sort-sql-server-tables-into-similarly_5.html +*/ + +SET NOCOUNT ON; +DECLARE + @bucketCount tinyint = 6; + +IF OBJECT_ID('tempdb..#work') IS NOT NULL +BEGIN + DROP TABLE #work; +END + +CREATE TABLE #work ( + _row int IDENTITY(1, 1) NOT NULL, + [SchemaName] sysname, + [TableName] sysname, + [RowsCounted] bigint NOT NULL, + GroupNumber int NOT NULL, + moved tinyint NOT NULL, + PRIMARY KEY CLUSTERED ([RowsCounted], _row) +); + +WITH cte AS ( +SELECT B.RowsCounted +, B.SchemaName +, B.TableName + FROM + ( + SELECT + s.[Name] as [SchemaName] + , t.[name] as [TableName] + , SUM(p.rows) as [RowsCounted] + FROM + sys.schemas s + LEFT OUTER JOIN + sys.tables t + ON s.schema_id = t.schema_id + LEFT OUTER JOIN + sys.partitions p + ON t.object_id = p.object_id + LEFT OUTER JOIN + sys.allocation_units a + ON p.partition_id = a.container_id + WHERE + p.index_id IN (0,1) + AND p.rows IS NOT NULL + AND a.type = 1 + GROUP BY + s.[Name] + , t.[name] + ) B +); + +INSERT INTO #work ([RowsCounted], SchemaName, TableName, GroupNumber, moved) +SELECT [RowsCounted], SchemaName, TableName, ROW_NUMBER() OVER (ORDER BY [RowsCounted]) % @bucketCount AS GroupNumber, 0 +FROM cte; + +WHILE (@@ROWCOUNT!=0) +WITH cte AS +( + SELECT + * + , SUM(RowsCounted) OVER (PARTITION BY GroupNumber) - SUM(RowsCounted) OVER (PARTITION BY (SELECT NULL)) / @bucketCount AS _GroupNumberoffset + FROM + #work +) +UPDATE + w +SET + w.GroupNumber = (CASE w._row + WHEN x._pos_row THEN x._neg_GroupNumber + ELSE x._pos_GroupNumber + END + ) +, w.moved = w.moved + 1 +FROM + #work AS w + INNER JOIN + ( + SELECT TOP 1 + pos._row AS _pos_row + , pos.GroupNumber AS _pos_GroupNumber + , neg._row AS _neg_row + , neg.GroupNumber AS _neg_GroupNumber + FROM + cte AS pos + INNER JOIN + cte AS neg + ON pos._GroupNumberoffset > 0 + AND neg._GroupNumberoffset < 0 + AND + --- To prevent infinite recursion: + pos.moved < @bucketCount + AND neg.moved < @bucketCount + WHERE --- must improve positive side's offset: + ABS(pos._GroupNumberoffset - pos.RowsCounted + neg.RowsCounted) <= pos._GroupNumberoffset + AND + --- must improve negative side's offset: + ABS(neg._GroupNumberoffset - neg.RowsCounted + pos.RowsCounted) <= ABS(neg._GroupNumberoffset) + --- Largest changes first: + ORDER BY + ABS(pos.RowsCounted - neg.RowsCounted) DESC + ) AS x + ON w._row IN + ( + x._pos_row + , x._neg_row + ); + +SELECT + W.GroupNumber +, COUNT_BIG(1) AS TotalTables +, SUM(W.RowsCounted) AS GroupTotalRows +FROM + #work AS W +GROUP BY + W.GroupNumber +ORDER BY + W.GroupNumber; + +SELECT + W.GroupNumber +, W.SchemaName +, W.TableName +, W.RowsCounted +, COUNT_BIG(1) OVER (PARTITION BY W.GroupNumber ORDER BY (SELECT NULL)) AS TotalTables +, SUM(W.RowsCounted) OVER (PARTITION BY W.GroupNumber ORDER BY (SELECT NULL)) AS GroupTotalRows +FROM + #work AS W +ORDER BY + W.GroupNumber; diff --git a/Scripts/Sort_UID_Demo.sql b/Scripts/Sort_UID_Demo.sql new file mode 100644 index 00000000..aef7e815 --- /dev/null +++ b/Scripts/Sort_UID_Demo.sql @@ -0,0 +1,36 @@ +/* + + uniqueidentifier (UID) sorting demo + Sorted UID CTE + 2007-08-31 by Alberto Ferrari + 2020-04-14 by Konstantin Taranov + 1.0 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Sort_UID_Demo.sql + https://web.archive.org/web/20181129024526/http://sqlblog.com:80/blogs/alberto_ferrari/archive/2007/08/31/how-are-guids-sorted-by-sql-server.aspx + +*/ + + +WITH CTE_UID AS (/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ + SELECT ID = 1, UID = CAST('00000000-0000-0000-0000-010000000000' AS uniqueidentifier) + UNION ALL SELECT ID = 2, UID = CAST('00000000-0000-0000-0000-000100000000' AS uniqueidentifier) + UNION ALL SELECT ID = 3, UID = CAST('00000000-0000-0000-0000-000001000000' AS uniqueidentifier) + UNION ALL SELECT ID = 4, UID = CAST('00000000-0000-0000-0000-000000010000' AS uniqueidentifier) + UNION ALL SELECT ID = 5, UID = CAST('00000000-0000-0000-0000-000000000100' AS uniqueidentifier) + UNION ALL SELECT ID = 6, UID = CAST('00000000-0000-0000-0000-000000000001' AS uniqueidentifier) + UNION ALL SELECT ID = 7, UID = CAST('00000000-0000-0000-0100-000000000000' AS uniqueidentifier) + UNION ALL SELECT ID = 8, UID = CAST('00000000-0000-0000-0010-000000000000' AS uniqueidentifier) + UNION ALL SELECT ID = 9, UID = CAST('00000000-0000-0001-0000-000000000000' AS uniqueidentifier) + UNION ALL SELECT ID = 10, UID = CAST('00000000-0000-0100-0000-000000000000' AS uniqueidentifier) + UNION ALL SELECT ID = 11, UID = CAST('00000000-0001-0000-0000-000000000000' AS uniqueidentifier) + UNION ALL SELECT ID = 12, UID = CAST('00000000-0100-0000-0000-000000000000' AS uniqueidentifier) + UNION ALL SELECT ID = 13, UID = CAST('00000001-0000-0000-0000-000000000000' AS uniqueidentifier) + UNION ALL SELECT ID = 14, UID = CAST('00000100-0000-0000-0000-000000000000' AS uniqueidentifier) + UNION ALL SELECT ID = 15, UID = CAST('00010000-0000-0000-0000-000000000000' AS uniqueidentifier) + UNION ALL SELECT ID = 16, UID = CAST('01000000-0000-0000-0000-000000000000' AS uniqueidentifier) +) +SELECT + ID + , UID +FROM CTE_UID +ORDER BY UID, ID; diff --git a/Scripts/Table Count alternative.sql b/Scripts/Table Count alternative.sql deleted file mode 100644 index 184f8177..00000000 --- a/Scripts/Table Count alternative.sql +++ /dev/null @@ -1,22 +0,0 @@ --- source: http://www.brentozar.com/archive/2014/02/count-number-rows-table-sql-server/ -DECLARE @TableName sysname -SET @TableName = 'bigTransactionHistory' - -SELECT TBL.object_id, TBL.name, SUM(PART.rows) AS rows -FROM sys.tables TBL -INNER JOIN sys.partitions PART ON TBL.object_id = PART.object_id -INNER JOIN sys.indexes IDX ON PART.object_id = IDX.object_id -AND PART.index_id = IDX.index_id -WHERE TBL.name = @TableName -AND IDX.index_id < 2 -GROUP BY TBL.object_id, TBL.name; - - -DECLARE @TableName sysname -SET @TableName = 'bigTransactionHistory' - -SELECT OBJECT_NAME(object_id), SUM(row_count) AS rows -FROM sys.dm_db_partition_stats -WHERE object_id = OBJECT_ID(@TableName) -AND index_id < 2 -GROUP BY OBJECT_NAME(object_id); \ No newline at end of file diff --git a/Scripts/Table_Count_Fast_Alternatives.sql b/Scripts/Table_Count_Fast_Alternatives.sql new file mode 100644 index 00000000..60516aee --- /dev/null +++ b/Scripts/Table_Count_Fast_Alternatives.sql @@ -0,0 +1,26 @@ +-- source: http://www.brentozar.com/archive/2014/02/count-number-rows-table-sql-server/ +DECLARE @TableName sysname = N'bigTransactionHistory'; + +SELECT TBL.object_id + , TBL.name + , SUM(PART.rows) AS NumberOfRows +FROM sys.tables AS TBL +INNER JOIN sys.partitions AS PART ON TBL.object_id = PART.object_id +INNER JOIN sys.indexes AS IDX ON PART.object_id = IDX.object_id +AND PART.index_id = IDX.index_id +WHERE TBL.name = @TableName +AND IDX.index_id < 2 +GROUP BY TBL.object_id, TBL.name; + + +DECLARE @tableName sysname = N'bigTransactionHistory'; + +SELECT object_id + , SCHEMA_NAME(object_id) AS SchemaName + , OBJECT_NAME(object_id) AS TableName + , SUM(row_count) AS NumberOfRows + FROM sys.dm_db_partition_stats + WHERE object_id = OBJECT_ID(@tableName) AND index_id < 2 + GROUP BY object_id + , SCHEMA_NAME(object_id) + , OBJECT_NAME(object_id); diff --git a/Scripts/Table_Parameters.sql b/Scripts/Table_Parameters.sql index da198b46..9f8f7c6c 100644 --- a/Scripts/Table_Parameters.sql +++ b/Scripts/Table_Parameters.sql @@ -1,152 +1,226 @@ /* -Author: SSMS +Author: Konstantin Taranov +Source: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Table_Parameters.sql */ -exec sp_executesql N' - CREATE TABLE #tmp_extended_remote_data_archive_tables - (object_id int not null, remote_table_name nvarchar(128) null, filter_predicate nvarchar(max) null, migration_state tinyint null) - IF EXISTS(SELECT 1 FROM master.sys.syscolumns WHERE Name = N''remote_data_archive_migration_state'' AND ID = Object_ID(N''sys.tables'')) - EXECUTE(N''INSERT INTO #tmp_extended_remote_data_archive_tables SELECT rdat.object_id, rdat.remote_table_name, - SUBSTRING(rdat.filter_predicate, 2, LEN(rdat.filter_predicate) - 2) as filter_predicate, - CASE - WHEN tbl.remote_data_archive_migration_state_desc = N''''PAUSED'''' THEN 1 - WHEN tbl.remote_data_archive_migration_state_desc = N''''OUTBOUND'''' THEN 3 - WHEN tbl.remote_data_archive_migration_state_desc = N''''INBOUND'''' THEN 4 - WHEN tbl.remote_data_archive_migration_state_desc = N''''DISABLED'''' THEN 0 - ELSE 0 - END AS migration_state - FROM sys.tables tbl LEFT JOIN sys.remote_data_archive_tables rdat ON rdat.object_id = tbl.object_id - WHERE rdat.object_id IS NOT NULL'') - ELSE - EXECUTE(N''INSERT INTO #tmp_extended_remote_data_archive_tables SELECT rdat.object_id, rdat.remote_table_name, - SUBSTRING(rdat.filter_predicate, 2, LEN(rdat.filter_predicate) - 2) as filter_predicate, - CASE - WHEN rdat.is_migration_paused = 1 AND rdat.migration_direction_desc = N''''OUTBOUND'''' THEN 1 - WHEN rdat.is_migration_paused = 1 AND rdat.migration_direction_desc = N''''INBOUND'''' THEN 2 - WHEN rdat.is_migration_paused = 0 AND rdat.migration_direction_desc = N''''OUTBOUND'''' THEN 3 - WHEN rdat.is_migration_paused = 0 AND rdat.migration_direction_desc = N''''INBOUND'''' THEN 4 - ELSE 0 - END AS migration_state - FROM sys.tables tbl LEFT JOIN sys.remote_data_archive_tables rdat ON rdat.object_id = tbl.object_id - WHERE rdat.object_id IS NOT NULL'') - +DECLARE @databaseName SYSNAME = N'AdventureWorks2017'; +DECLARE @schemaName SYSNAME = N'Person'; +DECLARE @tableName SYSNAME = N'CountryRegion'; +DECLARE @_msparam_0 INT = 2; +DECLARE @TROW50000 NVARCHAR(1000) = N'Table ' + @schemaName + '.' + @tableName+ N' is not exists in database ' + QUOTENAME(@databaseName) + N'!!!'; +IF OBJECT_ID(CASE WHEN @databaseName <> '' THEN QUOTENAME(@databaseName) + '.' ELSE '' END + QUOTENAME(@schemaName) + '.' + QUOTENAME(@tableName)) IS NULL +THROW 50000, @TROW50000, 1; -SELECT -tbl.name AS [Name], -tbl.object_id AS [ID], -tbl.create_date AS [CreateDate], -tbl.modify_date AS [DateLastModified], -ISNULL(stbl.name, N'''') AS [Owner], -CAST(case when tbl.principal_id is null then 1 else 0 end AS bit) AS [IsSchemaOwned], -SCHEMA_NAME(tbl.schema_id) AS [Schema], -CAST( - case - when tbl.is_ms_shipped = 1 then 1 - when ( - select - major_id - from - sys.extended_properties - where - major_id = tbl.object_id and - minor_id = 0 and - class = 1 and - name = N''microsoft_database_tools_support'') - is not null then 1 - else 0 -end - AS bit) AS [IsSystemObject], -CAST(OBJECTPROPERTY(tbl.object_id, N''HasAfterTrigger'') AS bit) AS [HasAfterTrigger], -CAST(OBJECTPROPERTY(tbl.object_id, N''HasInsertTrigger'') AS bit) AS [HasInsertTrigger], -CAST(OBJECTPROPERTY(tbl.object_id, N''HasDeleteTrigger'') AS bit) AS [HasDeleteTrigger], -CAST(OBJECTPROPERTY(tbl.object_id, N''HasInsteadOfTrigger'') AS bit) AS [HasInsteadOfTrigger], -CAST(OBJECTPROPERTY(tbl.object_id, N''HasUpdateTrigger'') AS bit) AS [HasUpdateTrigger], -CAST(OBJECTPROPERTY(tbl.object_id, N''IsIndexed'') AS bit) AS [HasIndex], -CAST(OBJECTPROPERTY(tbl.object_id, N''IsIndexable'') AS bit) AS [IsIndexable], -CAST(CASE idx.index_id WHEN 1 THEN 1 ELSE 0 END AS bit) AS [HasClusteredIndex], -CAST(CASE idx.type WHEN 0 THEN 1 ELSE 0 END AS bit) AS [HasHeapIndex], -tbl.uses_ansi_nulls AS [AnsiNullsStatus], -CAST(ISNULL(OBJECTPROPERTY(tbl.object_id,N''IsQuotedIdentOn''),0) AS bit) AS [QuotedIdentifierStatus], -CAST(0 AS bit) AS [FakeSystemTable], -ISNULL(dstext.name,N'''') AS [TextFileGroup], -CAST(tbl.is_memory_optimized AS bit) AS [IsMemoryOptimized], -case when (tbl.durability=1) then 0 else 1 end AS [Durability], -tbl.is_replicated AS [Replicated], -tbl.lock_escalation AS [LockEscalation], -CAST(case when ctt.object_id is null then 0 else 1 end AS bit) AS [ChangeTrackingEnabled], -CAST(ISNULL(ctt.is_track_columns_updated_on,0) AS bit) AS [TrackColumnsUpdatedEnabled], -tbl.is_filetable AS [IsFileTable], -ISNULL(ft.directory_name,N'''') AS [FileTableDirectoryName], -ISNULL(ft.filename_collation_name,N'''') AS [FileTableNameColumnCollation], -CAST(ISNULL(ft.is_enabled,0) AS bit) AS [FileTableNamespaceEnabled], -CASE WHEN ''PS''=dsidx.type THEN dsidx.name ELSE N'''' END AS [PartitionScheme], -CAST(CASE WHEN ''PS''=dsidx.type THEN 1 ELSE 0 END AS bit) AS [IsPartitioned], -CASE WHEN ''FD''=dstbl.type THEN dstbl.name ELSE N'''' END AS [FileStreamFileGroup], -CASE WHEN ''PS''=dstbl.type THEN dstbl.name ELSE N'''' END AS [FileStreamPartitionScheme], -CAST(CASE idx.type WHEN 5 THEN 1 ELSE 0 END AS bit) AS [HasClusteredColumnStoreIndex], -CAST(CASE tbl.temporal_type WHEN 2 THEN 1 ELSE 0 END AS bit) AS [IsSystemVersioned], -CAST(ISNULL(historyTable.name, N'''') AS sysname) AS [HistoryTableName], -CAST(ISNULL(SCHEMA_NAME(historyTable.schema_id), N'''') AS sysname) AS [HistoryTableSchema], -CAST(ISNULL(historyTable.object_id, 0) AS int) AS [HistoryTableID], -CAST(CASE WHEN periods.start_column_id IS NULL THEN 0 ELSE 1 END AS bit) AS [HasSystemTimePeriod], -CAST( - ISNULL((SELECT cols.name - FROM sys.columns cols - WHERE periods.object_id = tbl.object_id - AND cols.object_id = tbl.object_id - AND cols.column_id = periods.start_column_id), N'''') - AS sysname) AS [SystemTimePeriodStartColumn], -CAST( - ISNULL((SELECT cols.name - FROM sys.columns cols - WHERE periods.object_id = tbl.object_id - AND cols.object_id = tbl.object_id - AND cols.column_id = periods.end_column_id), N'''') - AS sysname) AS [SystemTimePeriodEndColumn], -tbl.temporal_type AS [TemporalType], -CAST(tbl.is_remote_data_archive_enabled AS bit) AS [RemoteDataArchiveEnabled], -CAST( - ISNULL(rdat.migration_state, 0) - AS tinyint) AS [RemoteDataArchiveDataMigrationState], -CAST(rdat.filter_predicate AS varchar(4000)) AS [RemoteDataArchiveFilterPredicate], -CAST(rdat.remote_table_name AS sysname) AS [RemoteTableName], -CAST(CASE WHEN rdat.remote_table_name IS NULL THEN 0 ELSE 1 END AS bit) AS [RemoteTableProvisioned], -CAST(tbl.is_external AS bit) AS [IsExternal], -eds.name AS [DataSourceName], -ISNULL(eff.name,N'''') AS [FileFormatName], -ISNULL(et.location,N'''') AS [Location], +IF LEFT(@databaseName, 1) = N'[' OR + LEFT(@tableName, 1) = N'[' OR + LEFT(@schemaName, 1) = N'[' +THROW 50001, 'Please do not use square quotes in Database, Table or Schema names! In the code it is alredy done with QUOTENAME function.', 1; - CASE et.reject_type - WHEN ''VALUE'' THEN 0 - WHEN ''PERCENTAGE'' THEN 1 - ELSE -1 - END - AS [RejectType], -ISNULL(et.reject_value,0) AS [RejectValue], -ISNULL(et.reject_sample_value,-1) AS [RejectSampleValue] -FROM -sys.tables AS tbl -LEFT OUTER JOIN sys.periods as periods ON periods.object_id = tbl.object_id -LEFT OUTER JOIN sys.tables as historyTable ON historyTable.object_id = tbl.history_table_id -LEFT OUTER JOIN sys.database_principals AS stbl ON stbl.principal_id = ISNULL(tbl.principal_id, (OBJECTPROPERTY(tbl.object_id, ''OwnerId''))) -INNER JOIN sys.indexes AS idx ON - idx.object_id = tbl.object_id and (idx.index_id < @_msparam_0 or (tbl.is_memory_optimized = 1 and idx.index_id = (select min(index_id) from sys.indexes where object_id = tbl.object_id))) - -LEFT OUTER JOIN sys.data_spaces AS dstext ON tbl.lob_data_space_id = dstext.data_space_id -LEFT OUTER JOIN sys.change_tracking_tables AS ctt ON ctt.object_id = tbl.object_id -LEFT OUTER JOIN sys.filetables AS ft ON ft.object_id = tbl.object_id -LEFT OUTER JOIN sys.data_spaces AS dsidx ON dsidx.data_space_id = idx.data_space_id -LEFT OUTER JOIN sys.tables AS t ON t.object_id = idx.object_id -LEFT OUTER JOIN sys.data_spaces AS dstbl ON dstbl.data_space_id = t.Filestream_data_space_id and (idx.index_id < 2 or (idx.type = 7 and idx.index_id < 3)) -LEFT OUTER JOIN #tmp_extended_remote_data_archive_tables AS rdat ON rdat.object_id = tbl.object_id -LEFT OUTER JOIN sys.external_tables AS et ON et.object_id = tbl.object_id -LEFT OUTER JOIN sys.external_data_sources AS eds ON eds.data_source_id = et.data_source_id -LEFT OUTER JOIN sys.external_file_formats AS eff ON eff.file_format_id = et.file_format_id -WHERE -(tbl.name=@_msparam_1 and SCHEMA_NAME(tbl.schema_id)=@_msparam_2) - DROP TABLE #tmp_extended_remote_data_archive_tables - -',N'@_msparam_0 nvarchar(4000),@_msparam_1 nvarchar(4000),@_msparam_2 nvarchar(4000)',@_msparam_0=N'2',@_msparam_1=N'Node',@_msparam_2=N'dictionary'; +IF OBJECT_ID('tempdb..#tmp_extended_remote_data_archive_tables', 'U') IS NOT NULL DROP TABLE #tmp_extended_remote_data_archive_tables; +CREATE TABLE #tmp_extended_remote_data_archive_tables( + object_id INT NOT NULL + , remote_table_name NVARCHAR(128) NULL + , filter_predicate NVARCHAR(max) NULL + , migration_state TINYINT NULL + ); + +DECLARE @productMajorVersion INT = CAST(SERVERPROPERTY('ProductMajorVersion') AS INT); +IF @productMajorVersion > 12 +BEGIN + IF EXISTS(SELECT 1 FROM master.sys.syscolumns WHERE [name] = N'remote_data_archive_migration_state' AND [id]= Object_ID(N'sys.tables')) + EXECUTE(N' + INSERT INTO #tmp_extended_remote_data_archive_tables + SELECT rdat.object_id, rdat.remote_table_name, + SUBSTRING(rdat.filter_predicate, 2, LEN(rdat.filter_predicate) - 2) AS filter_predicate, + CASE WHEN tbl.remote_data_archive_migration_state_desc = N''PAUSED'' THEN 1 + WHEN tbl.remote_data_archive_migration_state_desc = N''OUTBOUND'' THEN 3 + WHEN tbl.remote_data_archive_migration_state_desc = N''INBOUND'' THEN 4 + WHEN tbl.remote_data_archive_migration_state_desc = N''DISABLED'' THEN 0 + ELSE 0 + END AS migration_state + FROM sys.tables tbl LEFT JOIN sys.remote_data_archive_tables rdat ON rdat.object_id = tbl.object_id + WHERE rdat.object_id IS NOT NULL; + ') + ELSE + EXECUTE(N' + INSERT INTO #tmp_extended_remote_data_archive_tables + SELECT rdat.object_id, rdat.remote_table_name, + SUBSTRING(rdat.filter_predicate, 2, LEN(rdat.filter_predicate) - 2) AS filter_predicate, + CASE WHEN rdat.is_migration_paused = 1 AND rdat.migration_direction_desc = N''OUTBOUND'' THEN 1 + WHEN rdat.is_migration_paused = 1 AND rdat.migration_direction_desc = N''INBOUND'' THEN 2 + WHEN rdat.is_migration_paused = 0 AND rdat.migration_direction_desc = N''OUTBOUND'' THEN 3 + WHEN rdat.is_migration_paused = 0 AND rdat.migration_direction_desc = N''INBOUND'' THEN 4 + ELSE 0 + END AS migration_state + FROM sys.tables tbl LEFT JOIN sys.remote_data_archive_tables rdat ON rdat.object_id = tbl.object_id + WHERE rdat.object_id IS NOT NULL + '); +END; + +SELECT tbl.name AS [Name] + ,SCHEMA_NAME(tbl.schema_id) AS [Schema] + ,tbl.object_id + ,tbl.create_date AS [CreateDate] + ,tbl.modify_date AS [DateLastModified] + ,ISNULL(stbl.name, N'') AS [Owner] + ,CAST(CASE WHEN tbl.principal_id IS NULL THEN 1 ELSE 0 END AS BIT) AS [IsSchemaOwned] + ,CAST(CASE + WHEN tbl.is_ms_shipped = 1 THEN 1 + WHEN (SELECT major_id + FROM sys.extended_properties + WHERE major_id = tbl.object_id + AND minor_id = 0 + AND class = 1 + AND name = N'microsoft_database_tools_support') IS + NOT NULL + THEN 1 + ELSE 0 + END AS BIT) AS [IsSystemObject] + ,CAST(Objectproperty(tbl.object_id, N'HasAfterTrigger') AS BIT) AS [HasAfterTrigger] + ,CAST(Objectproperty(tbl.object_id, N'HasInsertTrigger') AS BIT) AS [HasInsertTrigger] + ,CAST(Objectproperty(tbl.object_id, N'HasDeleteTrigger') AS BIT) AS [HasDeleteTrigger] + ,CAST(Objectproperty(tbl.object_id, N'HasInsteadOfTrigger') AS BIT) AS [HasInsteadOfTrigger] + ,CAST(Objectproperty(tbl.object_id, N'HasUpdateTrigger') AS BIT) AS [HasUpdateTrigger] + ,CAST(Objectproperty(tbl.object_id, N'IsIndexed') AS BIT) AS [HasIndex] + ,CAST(Objectproperty(tbl.object_id, N'IsIndexable') AS BIT) AS [IsIndexable] + ,CAST(CASE idx.index_id WHEN 1 THEN 1 ELSE 0 END AS BIT) AS [HasClusteredIndex] + ,CAST(CASE idx.type WHEN 0 THEN 1 ELSE 0 END AS BIT) AS [HasHeapIndex] + ,tbl.uses_ansi_nulls AS [AnsiNullsStatus] + ,CAST(ISNULL(Objectproperty(tbl.object_id, N'IsQuotedIdentOn'), 0) AS BIT) AS [QuotedIdentifierStatus] + ,CAST(0 AS BIT) AS [FakeSystemTable] + ,ISNULL(dstext.name, N'') AS [TextFileGroup] + ,CAST(tbl.is_memory_optimized AS BIT) AS [IsMemoryOptimized] + ,CASE WHEN ( tbl.durability = 1 ) THEN 0 ELSE 1 END AS [Durability] + ,tbl.is_replicated AS [Replicated] + ,tbl.lock_escalation AS [LockEscalation] + ,CAST(CASE + WHEN ctt.object_id IS NULL THEN 0 + ELSE 1 + END AS BIT) + AS [ChangeTrackingEnabled] + ,CAST(ISNULL(ctt.is_track_columns_updated_on, 0) AS BIT) AS [TrackColumnsUpdatedEnabled] + ,tbl.is_filetable AS [IsFileTable] + ,ISNULL(ft.directory_name, N'') AS [FileTableDirectoryName] + ,ISNULL(ft.filename_collation_name, N'') + AS [FileTableNameColumnCollation] + ,CAST(ISNULL(ft.is_enabled, 0) AS BIT) + AS [FileTableNamespaceEnabled] + ,CASE + WHEN 'PS' = dsidx.type THEN dsidx.name + ELSE N'' + END + AS [PartitionScheme] + ,CAST(CASE + WHEN 'PS' = dsidx.type THEN 1 + ELSE 0 + END AS BIT) + AS [IsPartitioned] + ,CASE + WHEN 'FD' = dstbl.type THEN dstbl.name + ELSE N'' + END + AS [FileStreamFileGroup] + ,CASE + WHEN 'PS' = dstbl.type THEN dstbl.name + ELSE N'' + END + AS [FileStreamPartitionScheme] + ,CAST(CASE idx.type + WHEN 5 THEN 1 + ELSE 0 + END AS BIT) + AS [HasClusteredColumnStoreIndex] + --,CAST(CASE tbl.temporal_type + -- WHEN 2 THEN 1 + -- ELSE 0 + -- END AS BIT) + --AS [IsSystemVersioned] + --,CAST(ISNULL(historyTable.name, N'') AS SYSNAME) AS [HistoryTableName] + --,CAST(ISNULL(SCHEMA_NAME(historyTable.schema_id), N'') AS SYSNAME) AS [HistoryTableSchema] + --,CAST(ISNULL(historyTable.object_id, 0) AS INT) AS [HistoryTableID] + --,CAST(CASE WHEN periods.start_column_id IS NULL THEN 0 + -- ELSE 1 + -- END AS BIT) AS [HasSystemTimePeriod] + --,CAST(ISNULL((SELECT cols.NAME + -- FROM sys.columns cols + -- WHERE periods.object_id = tbl.object_id + -- AND cols.object_id = tbl.object_id + -- AND cols.column_id = periods.start_column_id), N'') + -- AS + -- SYSNAME) + -- AS [SystemTimePeriodStartColumn] + --,CAST(ISNULL((SELECT cols.NAME + -- FROM sys.columns cols + -- WHERE periods.object_id = tbl.object_id + -- AND cols.object_id = tbl.object_id + -- AND cols.column_id = periods.end_column_id), N'') AS + -- SYSNAME + -- ) + -- AS [SystemTimePeriodEndColumn] + --,tbl.temporal_type AS [TemporalType] + --,CAST(tbl.is_remote_data_archive_enabled AS BIT) AS [RemoteDataArchiveEnabled] + ,CAST(ISNULL(rdat.migration_state, 0) AS TINYINT) AS [RemoteDataArchiveDataMigrationState] + ,CAST(rdat.filter_predicate AS VARCHAR(4000)) AS [RemoteDataArchiveFilterPredicate] + ,CAST(rdat.remote_table_name AS SYSNAME) AS [RemoteTableName] + ,CAST(CASE + WHEN rdat.remote_table_name IS NULL THEN 0 + ELSE 1 + END AS BIT) + AS [RemoteTableProvisioned] + --,CAST(tbl.is_external AS BIT) AS [IsExternal] + ,eds.name AS [DataSourceName] + ,ISNULL(eff.name, N'') AS [FileFormatName] + ,ISNULL(et.location, N'') AS [Location] + ,CASE et.reject_type + WHEN 'VALUE' THEN 0 + WHEN 'PERCENTAGE' THEN 1 + ELSE -1 + END + AS [RejectType] + ,ISNULL(et.reject_value, 0) + AS [RejectValue] + ,ISNULL(et.reject_sample_value, -1) + AS [RejectSampleValue] +FROM sys.tables AS tbl + --LEFT OUTER JOIN sys.periods AS periods ON periods.object_id = tbl.object_id + --LEFT OUTER JOIN sys.tables AS historyTable ON historyTable.object_id = tbl.history_table_id + LEFT OUTER JOIN sys.database_principals AS stbl + ON stbl.principal_id = ISNULL(tbl.principal_id, ( + Objectproperty(tbl.object_id, + 'OwnerId') )) + INNER JOIN sys.indexes AS idx + ON idx.object_id = tbl.object_id + AND ( idx.index_id < @_msparam_0 + OR ( tbl.is_memory_optimized = 1 + AND idx.index_id = (SELECT Min(index_id) + FROM sys.indexes + WHERE + object_id = tbl.object_id) ) ) + LEFT OUTER JOIN sys.data_spaces AS dstext + ON tbl.lob_data_space_id = dstext.data_space_id + LEFT OUTER JOIN sys.change_tracking_tables AS ctt + ON ctt.object_id = tbl.object_id + LEFT OUTER JOIN sys.filetables AS ft + ON ft.object_id = tbl.object_id + LEFT OUTER JOIN sys.data_spaces AS dsidx + ON dsidx.data_space_id = idx.data_space_id + LEFT OUTER JOIN sys.tables AS t + ON t.object_id = idx.object_id + LEFT OUTER JOIN sys.data_spaces AS dstbl + ON dstbl.data_space_id = t.filestream_data_space_id + AND ( idx.index_id < 2 + OR ( idx.type = 7 + AND idx.index_id < 3 ) ) + LEFT OUTER JOIN #tmp_extended_remote_data_archive_tables AS rdat + ON rdat.object_id = tbl.object_id + LEFT OUTER JOIN sys.external_tables AS et + ON et.object_id = tbl.object_id + LEFT OUTER JOIN sys.external_data_sources AS eds + ON eds.data_source_id = et.data_source_id + LEFT OUTER JOIN sys.external_file_formats AS eff + ON eff.file_format_id = et.file_format_id +--WHERE tbl.name = @tableName +-- AND SCHEMA_NAME(tbl.schema_id) = @schemaName; diff --git a/Scripts/Table_and_Index_storage_size.sql b/Scripts/Table_and_Index_storage_size.sql deleted file mode 100644 index 3e1e593a..00000000 --- a/Scripts/Table_and_Index_storage_size.sql +++ /dev/null @@ -1,63 +0,0 @@ ---Get Table and Index storage size in sql server ---Link: http://stackoverflow.com/questions/15896564/get-table-and-index-storage-size-in-sql-server#15896658 -/* -Author: marc_s -This query here will list the total size that a table takes up - clustered index, heap and all nonclustered indices -If you want to separate table space from index space, you need to use AND i.index_id IN (0,1) for the table space -(index_id = 0 is the heap space, index_id = 1 is the size of the clustered index = data pages) and AND i.index_id > 1 for the index-only space -*/ - -SELECT - s.Name AS SchemaName, - t.NAME AS TableName, - p.rows AS RowCounts, - SUM(a.total_pages) * 8 AS TotalSpaceKB, - SUM(a.used_pages) * 8 AS UsedSpaceKB, - (SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB -FROM - sys.tables t -INNER JOIN - sys.schemas s ON s.schema_id = t.schema_id -INNER JOIN - sys.indexes i ON t.OBJECT_ID = i.object_id -INNER JOIN - sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id -INNER JOIN - sys.allocation_units a ON p.partition_id = a.container_id -WHERE - t.NAME NOT LIKE 'dt%' -- filter out system tables for diagramming - AND t.is_ms_shipped = 0 - AND i.OBJECT_ID > 255 -GROUP BY - t.Name, s.Name, p.Rows -ORDER BY - s.Name, t.Name - ------------------------------ -/* -Author: Muhmud -Takes into account internal tables, such as those used for XML storage. -Edit: If you divide the data_kb and index_kb values by 1024.0, you will get the numbers you see in the GUI. -*/ - - with pages as ( - SELECT object_id, SUM (reserved_page_count) as reserved_pages, SUM (used_page_count) as used_pages, - SUM (case - when (index_id < 2) then (in_row_data_page_count + lob_used_page_count + row_overflow_used_page_count) - else lob_used_page_count + row_overflow_used_page_count - end) as pages - FROM sys.dm_db_partition_stats - group by object_id -), extra as ( - SELECT p.object_id, sum(reserved_page_count) as reserved_pages, sum(used_page_count) as used_pages - FROM sys.dm_db_partition_stats p, sys.internal_tables it - WHERE it.internal_type IN (202,204,211,212,213,214,215,216) AND p.object_id = it.object_id - group by p.object_id -) -SELECT object_schema_name(p.object_id) + '.' + object_name(p.object_id) as TableName, (p.reserved_pages + isnull(e.reserved_pages, 0)) * 8 as reserved_kb, - pages * 8 as data_kb, - (CASE WHEN p.used_pages + isnull(e.used_pages, 0) > pages THEN (p.used_pages + isnull(e.used_pages, 0) - pages) ELSE 0 END) * 8 as index_kb, - (CASE WHEN p.reserved_pages + isnull(e.reserved_pages, 0) > p.used_pages + isnull(e.used_pages, 0) THEN (p.reserved_pages + isnull(e.reserved_pages, 0) - p.used_pages + isnull(e.used_pages, 0)) else 0 end) * 8 as unused_kb -from pages p -left outer join extra e on p.object_id = e.object_id - \ No newline at end of file diff --git a/Scripts/Table_upload_order.sql b/Scripts/Table_upload_order.sql deleted file mode 100644 index 5122aa6a..00000000 --- a/Scripts/Table_upload_order.sql +++ /dev/null @@ -1,76 +0,0 @@ -/* -Author: -Link: -*/ - -WITH fk_tables AS - (SELECT s1.name AS from_schema - , o1.name AS from_table - , s2.name AS to_schema - , o2.name AS to_table - FROM sys.foreign_keys fk - INNER JOIN sys.objects o1 ON fk.parent_object_id = o1.object_id - INNER JOIN sys.schemas s1 ON o1.schema_id = s1.schema_id - INNER JOIN sys.objects o2 ON fk.referenced_object_id = o2.object_id - INNER JOIN sys.schemas s2 ON o2.schema_id = s2.schema_id - INNER JOIN (SELECT object_id, SUM(row_count) AS row_count - FROM sys.dm_db_partition_stats - WHERE index_id < 2 - GROUP BY object_id - ) AS rc ON o1.object_id = rc.object_id - /*For the purposes of finding dependency hierarchy - we're not worried about self-referencing tables*/ - WHERE NOT - (s1.name = s2.name - AND o1.name = o2.name - ) - ) - , ordered_tables AS - (SELECT s.name AS schemaName - , t.name AS tableName - , 0 AS TableLevel - FROM(SELECT * - FROM sys.tables - ) t - INNER JOIN sys.schemas s ON t.schema_id = s.schema_id - LEFT OUTER JOIN fk_tables fk ON s.name = fk.from_schema AND t.name = fk.from_table - WHERE fk.from_schema IS NULL - UNION ALL - SELECT fk.from_schema - , fk.from_table - , ot.TableLevel + 1 - FROM fk_tables fk - INNER JOIN ordered_tables ot ON fk.to_schema = ot.schemaName AND fk.to_table = ot.tableName - ) - , final AS - (SELECT DISTINCT ot.schemaName - , ot.tableName - , ot.TableLevel - FROM ordered_tables ot - INNER JOIN - (SELECT schemaName - , tableName - , MAX(TableLevel) maxTableLevel - FROM ordered_tables - GROUP BY schemaName - , tableName - ) mx ON ot.schemaName = mx.schemaName AND ot.tableName = mx.tableName AND mx.maxTableLevel = ot.TableLevel - ) -SELECT QUOTENAME(final.schemaName) + '.' + QUOTENAME(final.tableName) - , TableLevel -FROM final -WHERE( - -- exclude some schemes by IN - final.schemaName NOT IN('dbo' - , 'consumption') - -- exclude some tables by IN - AND final.tableName NOT IN('TP6' - , 'WorldScenarioResult') - -- exclude some tables by mask - AND final.tableName NOT LIKE '%Temp' - ) - -- add some tables by mask and with IN - OR final.tableName IN('IPAdmin') - OR final.tableName LIKE 'AspNet%' - OR final.tableName LIKE 'Application%' -ORDER BY TableLevel; \ No newline at end of file diff --git a/Scripts/Test_job.sql b/Scripts/Test_job.sql new file mode 100644 index 00000000..d768ed01 --- /dev/null +++ b/Scripts/Test_job.sql @@ -0,0 +1,88 @@ +/* +Source: https://sqlpal.blogspot.com/2018/04/how-to-start-sql-server-job-using-tsql.html +Author: ? +*/ + +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SET NOCOUNT ON; + +DECLARE +@job_name SYSNAME = 'test', -- INPUT YOUR JOB NAME HERE +@WaitTime DATETIME = '00:00:05', -- default check frequency +@JobCompletionStatus INT + + +-- CHECK IF IT IS A VALID AND EXISTING JOB NAME + +IF NOT EXISTS (SELECT * FROM msdb..sysjobs WHERE name =@job_name) +BEGIN + RAISERROR ('[ERROR]:[%s] job does not exist. Please check',16, 1, @job_name) WITH LOG; + RETURN; +END; + + +DECLARE @job_id UNIQUEIDENTIFIER; +DECLARE @job_owner SYSNAME; + +--Createing TEMP TABLE +CREATE TABLE #xp_results (job_id UNIQUEIDENTIFIER NOT NULL, + last_run_date INT NOT NULL, + last_run_time INT NOT NULL, + next_run_date INT NOT NULL, + next_run_time INT NOT NULL, + next_run_schedule_id INT NOT NULL, + requested_to_run INT NOT NULL, -- BOOL + request_source INT NOT NULL, + request_source_id sysname COLLATE database_default NULL, + running INT NOT NULL, -- BOOL + current_step INT NOT NULL, + current_retry_attempt INT NOT NULL, + job_state INT NOT NULL); + +SELECT @job_id = job_id FROM msdb.dbo.sysjobs WHERE name =@job_name; + +SET @job_owner = SUSER_SNAME(); + +INSERT INTO #xp_results EXECUTE master.dbo.xp_sqlagent_enum_jobs 1, @job_owner, @job_id; + +-- Start the job only if it is not already running +IF NOT EXISTS(SELECT TOP 1 * FROM #xp_results WHERE running = 1) + EXEC msdb.dbo.sp_start_job @job_name = @job_name; + +-- Give it 2 seconds for think time. +WAITFOR DELAY '00:00:02'; + +DELETE FROM #xp_results; +INSERT INTO #xp_results +EXECUTE master.dbo.xp_sqlagent_enum_jobs 1, @job_owner, @job_id; + +WHILE EXISTS(SELECT TOP 1 * FROM #xp_results WHERE running = 1) +BEGIN + + WAITFOR DELAY @WaitTime; + + -- Display informational message at each interval + raiserror('JOB IS RUNNING', 0, 1 ) WITH NOWAIT; + + DELETE FROM #xp_results; + + INSERT INTO #xp_results + EXECUTE master.dbo.xp_sqlagent_enum_jobs 1, @job_owner, @job_id; + +END + +SELECT top 1 @JobCompletionStatus =run_status +FROM msdb.dbo.sysjobhistory +WHERE job_id = @job_id + AND step_id = 0 +ORDER BY run_date desc, run_time desc; + + +IF @JobCompletionStatus = 1 + PRINT 'The job ran Successful' +ELSE IF @JobCompletionStatus =3 + PRINT 'The job is Cancelled' +ELSE +BEGIN + RAISERROR ('[ERROR]:%s job is either failed or not in good state. Please check',16, 1, @job_name) WITH LOG; +END; diff --git a/Scripts/Trace_Flag/Trace_Flag_1165.sql b/Scripts/Trace_Flag/Trace_Flag_1165.sql new file mode 100644 index 00000000..6abbf4e6 --- /dev/null +++ b/Scripts/Trace_Flag/Trace_Flag_1165.sql @@ -0,0 +1,63 @@ +/* +https://www.sqlshack.com/understanding-sql-server-proportional-fill-algorithm/ +*/ + +DBCC TRACEON (1165, 3605); +GO + +EXEC sp_cycle_errorlog; +GO + +CREATE DATABASE PropFillDemo +ON PRIMARY +( NAME = N'PropFillDemo', FILENAME = N'g:\MSSQL19\MSSQL15.MSSQL19\MSSQL\DATA\PropFillDemo2.mdf', SIZE = 10MB , MAXSIZE = 1GB, FILEGROWTH = 10MB), +( NAME = N'PropFillDemo_1', FILENAME = N'g:\MSSQL19\MSSQL15.MSSQL19\MSSQL\DATA\PropFillDemo2_1.ndf', SIZE = 10MB , MAXSIZE = 1GB, FILEGROWTH = 10MB), +( NAME = N'PropFillDemo_2', FILENAME = N'g:\MSSQL19\MSSQL15.MSSQL19\MSSQL\DATA\PropFillDemo2_2.ndf', SIZE = 10MB , MAXSIZE = 1GB, FILEGROWTH = 10MB), +( NAME = N'PropFillDemo_3', FILENAME = N'g:\MSSQL19\MSSQL15.MSSQL19\MSSQL\DATA\PropFillDemo2_3.ndf', SIZE = 10MB , MAXSIZE = 1GB, FILEGROWTH = 10MB) + LOG ON ( NAME = N'PropFillDemo_log', FILENAME = N'g:\MSSQL19\MSSQL15.MSSQL19\MSSQL\DATA\PropFillDemo_log.ldf',SIZE = 10MB , MAXSIZE = 2GB , FILEGROWTH = 10%); + +EXEC xp_readerrorlog; +GO + +USE PropFillDemo; +GO + +SELECT [name] AS DBFileName + , [file_id] AS DBFileID + , [physical_name] AS PathAndPhysicalName + , (size * 8.0/1024) AS FileSizeMB + , ((size * 8.0/1024) - (FILEPROPERTY(name, 'SpaceUsed') * 8.0/1024)) AS FileFreeSpaceMB + , CAST((((size * 8.0/1024) - (FILEPROPERTY(name, 'SpaceUsed') * 8.0/1024))/(size * 8.0/1024))*100 AS decimal(6,2)) AS FreeSpacePercent + FROM sys.database_files; + + +DBCC showfilestats; + +CREATE TABLE PropFillTest( + ID int IDENTITY (1,1) + , First_Name nvarchar(50) NOT NULL + , Last_Name nvarchar(50) NOT NULL +); + +INSERT INTO PropFillTest VALUES('Ahmad', 'Yaseen'), ('John', 'Mikel'); +GO 500 + + +INSERT INTO PropFillTest VALUES('Ahmad', 'Yaseen'), ('John', 'Mikel'); +GO 15000 + +DBCC showfilestats; + +DBCC IND ('PropFillDemo', 'PropFillTest', -1); + + +INSERT INTO [PropFillTest] VALUES('Ahmad','Yaseen'),('John','Mikel') +GO 15000000 + +USE [master] +GO +ALTER DATABASE [PropFillDemo] ADD FILE ( NAME = N'PropFillDemo_4', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\PropFillDemo_4.ndf' , SIZE = 15360KB , FILEGROWTH = 10240KB ) TO FILEGROUP [PRIMARY]; +GO + +EXEC xp_readerrorlog; +GO diff --git a/Scripts/Trace_Flag/Trace_Flag_2371.sql b/Scripts/Trace_Flag/Trace_Flag_2371.sql new file mode 100644 index 00000000..2b499c5d --- /dev/null +++ b/Scripts/Trace_Flag/Trace_Flag_2371.sql @@ -0,0 +1,111 @@ +/* +https://www.sqlservergeeks.com/sql-server-trace-flag-2371/ +*/ + +USE master; +GO + +--Drop this database if alreay exist +IF DB_ID('StatsDemo2014') > 0 +BEGIN + ALTER DATABASE StatsDemo2014 SET single_user; + + DROP DATABASE StatsDemo2014; +END +GO + +--Create a database for Demo at default files location +CREATE DATABASE StatsDemo2014; +GO + +USE StatsDemo2014; +GO + +--Create table +CREATE TABLE xtstatsdemo ( + id int NOT NULL + , balance int NOT NULL + , name varchar(25) NULL + ); +GO + +-- Now I am inserting 50000 rows in the table. +-- Here id and balance both are having same values for demo purpose +SET NOCOUNT ON; + +DECLARE @counter INT = 1; +DECLARE @balance INT = 1; + +WHILE (@counter <= 50000) +BEGIN + IF (@counter % 2 = 0) + BEGIN + INSERT INTO xtstatsdemo + VALUES ( + @counter + , @balance + , 'data1' + ); + END + ELSE + BEGIN + INSERT INTO xtstatsdemo + VALUES ( + @counter + , @balance + , 'data2' + ); + END + + SET @counter = @counter + 1; + SET @balance = @balance + 1; +END +GO + +--You can check number of rows inside the table +SELECT count(*) FROM xtstatsdemo; +GO + + +/* Now run the below code, here select statement will create a statistic on id column. */ +USE master +GO + +DBCC TRACEON (2371, - 1) +GO + +USE StatsDemo2014; +GO + +SELECT * FROM xtstatsdemo WHERE id > 8000; +GO + + +/* Now check the auto created statistic on id column from SSMS. +Change the name of stats _WA_Sys_00000001_21B6055D as per your environment */ +DBCC Show_Statistics('xtstatsdemo','_WA_Sys_00000001_21B6055D') with stat_header; + + +/* Now I am going to delete 8000 rows */ +DELETE FROM xtstatsdemo WHERE id < 8001; +GO +/* Statement to update the stats automatically */ +SELECT name FROM xtstatsdemo WHERE id > 8000; +GO + +DBCC TRACEOFF(2371,-1) +GO +/* Now check the stats details and change the name of stats _WA_Sys_00000001_21B6055D as per your environment */ +DBCC Show_Statistics('xtstatsdemo','_WA_Sys_00000001_21B6055D') with stat_header; + + +/* Now I am going to delete 8000 rows */ +DELETE FROM xtstatsdemo where id < 8001; +GO +/* Statement to update the stats automatically */ +SELECT name FROM xtstatsdemo WHERE id > 8000; +GO +DBCC TRACEOFF(2371,-1) +GO +/* Now check the stats details and change the name of stats _WA_Sys_00000001_21B6055D as per your environment */ +DBCC Show_Statistics('xtstatsdemo','_WA_Sys_00000001_21B6055D') with stat_header; diff --git a/Scripts/Trace_Flag/Trace_Flag_3895.sql b/Scripts/Trace_Flag/Trace_Flag_3895.sql new file mode 100644 index 00000000..abc9dd86 --- /dev/null +++ b/Scripts/Trace_Flag/Trace_Flag_3895.sql @@ -0,0 +1,53 @@ +/* +Trace Flag Demo: 3895 +!!! Undocumented trace flag !!! +Function: In SQL Server 2019, when you enable the [Memory-Optimized TempDB Metadata](https://docs.microsoft.com/en-us/sql/relational-databases/databases/tempdb-database) feature, this trace flag is automatically enabled after the next restart. +When you disable that feature, the trace flag is automatically removed after the next restart. +Also if you add race flag 3895 to startup parameters after restarting SQL Server option `IsTempdbMetadataMemoryOptimized` will be enabled. +SQL Server Version: 2019 +Information link: https://github.com/ktaranov/sqlserver-kit/blob/master/SQL%20Server%20Trace%20Flag.md#3895 +*/ + +/* Check is it session trace flag? */ +DBCC TRACEON (3895); +GO +/* Answer - NO +Ignoring trace flag 3895. It is either an invalid trace flag or a trace flag that can only be specified during server startup. +DBCC execution completed. If DBCC printed error messages, contact your system administrator. +*/ + +/* Check current working flags */ +DBCC TRACESTATUS(-1); +GO + +/* https://docs.microsoft.com/en-us/sql/relational-databases/databases/tempdb-database */ +ALTER SERVER CONFIGURATION SET MEMORY_OPTIMIZED TEMPDB_METADATA = ON; + +/* RESTART SQL SERVER */ +DBCC TRACESTATUS(-1); +GO +/* Return that 3895 trace flag is enabled */ + +SELECT SERVERPROPERTY('IsTempdbMetadataMemoryOptimized') AS IsTempdbMetadataMemoryOptimized; +/* Return 1 (enabled) */ + +ALTER SERVER CONFIGURATION SET MEMORY_OPTIMIZED TEMPDB_METADATA = OFF; + +/* RESTART SQL SERVER */ + +SELECT SERVERPROPERTY('IsTempdbMetadataMemoryOptimized') AS IsTempdbMetadataMemoryOptimized; +/* Return 0 (disabled) */ + + +/* Add trace flag 3894 in SQL Server startup parameteres using SQL Server Configuration Manager +RESTART SQL SERVER +*/ + +SELECT SERVERPROPERTY('IsTempdbMetadataMemoryOptimized') AS IsTempdbMetadataMemoryOptimized; +/* Return 1 (enabled) */ + +/* Remoce trace flag 3894 in SQL Server startup parameteres using SQL Server Configuration Manager +RESTART SQL SERVER +*/ +SELECT SERVERPROPERTY('IsTempdbMetadataMemoryOptimized') AS IsTempdbMetadataMemoryOptimized; +/* Return 0 (disabled) */ diff --git a/Scripts/Trace_Flag/Trace_Flag_460.sql b/Scripts/Trace_Flag/Trace_Flag_460.sql new file mode 100644 index 00000000..c86ba5dc --- /dev/null +++ b/Scripts/Trace_Flag/Trace_Flag_460.sql @@ -0,0 +1,68 @@ +SET NOEXEC OFF; + +DECLARE @msg NVARCHAR(MAX) = N''; +DECLARE @productMajorVersion INT; +DECLARE @productBuild INT; +SET @productMajorVersion = CAST(SERVERPROPERTY('ProductMajorVersion') AS INT); +SET @productMajorVersion = CAST(SERVERPROPERTY('ProductBuild') AS INT); +PRINT('@productMajorVersion = ' + ISNULL(CAST(@productMajorVersion AS VARCHAR(30)), 'NULL')); +PRINT('@ProductBuild = ' + ISNULL(CAST(@productMajorVersion AS VARCHAR(30)), 'NULL')); + +IF @productMajorVersion < 14 OR (@productMajorVersion = 14 AND SERVERPROPERTY('ProductBuild') < 3045) +BEGIN + RAISERROR(N'Sorry, Trace flag 460 only works for SQL Server 2019 and SQL Server >= 2017 CU12 on this moment.', 16, 1); + SET NOEXEC ON; +END; + +USE tempdb; +GO + +DROP TABLE IF EXISTS dbo.WorldSeries; +GO + +CREATE TABLE dbo.WorldSeries (TeamName VARCHAR(200), Championships VARCHAR(3)); +GO + +DBCC TRACEOFF(460); /* if this flag alredy activated */ +INSERT INTO dbo.WorldSeries (TeamName, Championships) VALUES ('Texas Rangers', null); +INSERT INTO dbo.WorldSeries (TeamName, Championships) VALUES + ('Houston Astros', 'one') + , ('Bavaria', 'five') /* too long Championships value */ + , ('Spartak Moscow', 'hundred'); /* too long Championships value */ +GO + +DBCC TRACEON(460); +INSERT INTO dbo.WorldSeries (TeamName, Championships) VALUES + ('Real Madrid', 'one') + , ('Chelsi Chelsi', 'two') + , ('Bavaria', 'five') /* too long Championships value */ + , ('Spartak Moscow', 'hundred'); /* too long Championships value */ +GO + +IF OBJECT_ID(N'dbo.WorldSeries', 'U') IS NOT NULL DROP TABLE dbo.WorldSeries; +GO + + +/* +Dont leave this trace flag enabled on global scope for SQL Server 2017 CU12 and CU13! +https://www.brentozar.com/archive/2019/03/how-to-fix-the-error-string-or-binary-data-would-be-truncated/ +*/ + +CREATE OR ALTER PROC dbo.Repro @BigString varchar(8000) AS +BEGIN + + DECLARE @Table TABLE (SmallString varchar(128)); + + IF ( 1 = 0 ) + /* This will never run */ + INSERT INTO @Table (SmallString) + VALUES(@BigString) + OPTION (QUERYTRACEON 460); +END; +GO + +DECLARE @BigString varchar(8000) = REPLICATE('blah', 100); +EXEC dbo.Repro @BigString; +GO + +DROP PROCEDURE IF EXISTS dbo.Repro; diff --git a/Scripts/Trace_Flag/Trace_Flag_8602.sql b/Scripts/Trace_Flag/Trace_Flag_8602.sql new file mode 100644 index 00000000..3f97dea9 --- /dev/null +++ b/Scripts/Trace_Flag/Trace_Flag_8602.sql @@ -0,0 +1,76 @@ +/* +Trace Flag Demo: 8602 +Function: This trace flag is used to ignore all the index hints specified in query or stored procedure. +We can use this trace flag to troubleshooting the query performance without changing index hints. +SQL Server Version: 2008-2017 +Information link: https://github.com/ktaranov/sqlserver-kit/blob/master/SQL%20Server%20Trace%20Flag.md#8602 +*/ + +USE master +GO + +IF DB_ID(N'Trace8602') IS NOT NULL +BEGIN + ALTER DATABASE Trace8602 SET SINGLE_USER WITH ROLLBACK IMMEDIATE; + DROP DATABASE Trace8602; +END; +GO + +CREATE DATABASE Trace8602; +GO + +USE Trace8602; +GO + +CREATE TABLE xttrace8602 + ( + id INT identity(1, 1) PRIMARY KEY + , bal INT + , name VARCHAR(100) + ); +GO +CREATE NONCLUSTERED INDEX IX_xttrace8602_bal_name ON xttrace8602 + ( + bal + , name + ); +CREATE NONCLUSTERED INDEX IX_xttrace8602_bal ON xttrace8602(bal) ; +GO + +INSERT INTO xttrace8602(bal, name) +SELECT TOP(10000) RAND() * 786 AS bal + , 'SQLServerGeeks.com' AS name + FROM sys.all_objects + CROSS JOIN sys.all_columns; +GO + +CREATE PROC usp_First +AS + SELECT id + , name + FROM xttrace8602 AS tf WITH(INDEX(IX_xttrace8602_bal)) + WHERE bal < 100; +GO + +/*Ctrl+M Include Actual Execution Plan in SSMS*/ +EXEC usp_First; +GO +/*Enable Trace flag*/ +DBCC TRACEON(8602, -1); +GO +/*Clear procedure cache*/ +DECLARE @planHandle VARBINARY(64); +SELECT @planHandle = cp.plan_handle + FROM sys.dm_exec_cached_plans AS cp + CROSS APPLY sys.dm_exec_sql_text(cp.plan_handle) AS st + WHERE st.[text] LIKE '%CREATE PROC usp_First%' AND objtype = 'Proc'; +PRINT(@planHandle); +IF @planHandle IS NOT NULL DBCC FREEPROCCACHE (@planHandle); +GO + +EXEC usp_First; +GO + +/*Disable Trace flag*/ +DBCC TRACEOff(8602,-1) +GO diff --git a/Scripts/Trace_Flag/Trace_Flag_8726.sql b/Scripts/Trace_Flag/Trace_Flag_8726.sql new file mode 100644 index 00000000..452a3e41 --- /dev/null +++ b/Scripts/Trace_Flag/Trace_Flag_8726.sql @@ -0,0 +1,28 @@ +/* +Trace Flag Demo: 8726 +!!! Undocumented trace flag !!! +Function: Disables the heuristic that discourages the optimizer from producing an index union plan. +SQL Server Version: ? +Information link: https://github.com/ktaranov/sqlserver-kit/blob/master/SQL%20Server%20Trace%20Flag.md#8726 +*/ + +USE StackOverflow2010; +GO + +/* Execution Plan: https://www.brentozar.com/pastetheplan/?id=B1mSzXGv8 */ +/* No index union (seek on Users, multiple scans on Comments) */ +SELECT * +FROM Users u + LEFT JOIN Comments c + ON u.Id = c.UserId + OR u.Id = c.PostId +WHERE u.DisplayName = 'alex'; + +/* Gets the index union plan */ +SELECT * +FROM Users u + LEFT JOIN Comments c + ON u.Id = c.UserId + OR u.Id = c.PostId +WHERE u.DisplayName = 'alex' +OPTION (QUERYTRACEON 8726); diff --git a/Scripts/Trace_Flag/Trace_Flag_8727.sql b/Scripts/Trace_Flag/Trace_Flag_8727.sql new file mode 100644 index 00000000..2e0d73ad --- /dev/null +++ b/Scripts/Trace_Flag/Trace_Flag_8727.sql @@ -0,0 +1,38 @@ +/* +Trace Flag Demo: 8727 +!!! Undocumented trace flag !!! +Function: Can be used to prevent unwanted index union plans. +SQL Server Version: ? +Information link: https://github.com/ktaranov/sqlserver-kit/blob/master/SQL%20Server%20Trace%20Flag.md#8727 +*/ + +USE StackOverflow2010; +GO + +/* Execution Plan: https://www.brentozar.com/pastetheplan/?id=HkwhlQGwL */ +/* Gets an index union plan normally */ +SELECT * +FROM dbo.Users u +OUTER APPLY +( + SELECT * + FROM dbo.Comments c + WHERE + u.Id = c.UserId + OR u.Id = c.PostId +) c +WHERE u.DisplayName = 'alex'; + +/* No index union (seek on Users, multiple scans on Comments) */ +SELECT * +FROM dbo.Users u +OUTER APPLY +( + SELECT * + FROM dbo.Comments c + WHERE + u.Id = c.UserId + OR u.Id = c.PostId +) c +WHERE u.DisplayName = 'alex' +OPTION (QUERYTRACEON 8727); diff --git a/Scripts/Uppercase_All_String_Columns.sql b/Scripts/Uppercase_All_String_Columns.sql new file mode 100644 index 00000000..b9db080f --- /dev/null +++ b/Scripts/Uppercase_All_String_Columns.sql @@ -0,0 +1,288 @@ +/* + ------- Uppercase All String Columns (and in a Single Query!) ------- + +Created By: Solomon Rutzky / Sql Quantum Leap +Created On: 2019-03-20 +Updated On: n/a + +Location: https://pastebin.com/vbzz0LqN +Related blog post: https://sqlquantumleap.com/2019/03/20/uppercase-all-characters-and-in-a-single-query/ +---------------------------------------------------------------------- +*/ + + +USE [tempdb]; +SET NOCOUNT ON; + + +IF (OBJECT_ID(N'dbo.One''Column') IS NULL) +BEGIN + CREATE TABLE dbo.[One'Column] + ( + [One'ColumnID] INT NOT NULL IDENTITY(1, 1) + CONSTRAINT [PK_One'Column] PRIMARY KEY, + [String] VARCHAR(100) COLLATE SQL_Latin1_General_CP1_CI_AS, + [SomeDate] DATETIME + ); + + CREATE TABLE dbo.TwoColumns + ( + [TwoColumnsID] INT NOT NULL IDENTITY(1, 1) + CONSTRAINT [PK_TwoColumns] PRIMARY KEY, + [Stringy]]] NCHAR(50) COLLATE SQL_Latin1_General_CP1_CI_AS, + [SomeDate] DATETIME, + [LOBy] TEXT COLLATE SQL_Latin1_General_CP1_CI_AS + ); + + CREATE TABLE dbo.NoColumns + ( + [NoColumnsID] INT NOT NULL IDENTITY(1, 1) + CONSTRAINT [PK_NoColumns] PRIMARY KEY, + [SomeDate] DATETIME, + [SomeMoney] MONEY + ); + + CREATE TABLE dbo.[Another]]One'Column] + ( + [Another]]One'ColumnID] INT NOT NULL IDENTITY(1, 1) + CONSTRAINT [PK_Another]]One'Column] PRIMARY KEY, + [Stringy] CHAR(100) COLLATE Latin1_General_100_CI_AS, + [SomeDate] DATETIME, + + ); + + CREATE TABLE dbo.ThreeColumns + ( + [ThreeColumnsID] INT NOT NULL IDENTITY(1, 1) + CONSTRAINT [PK_ThreeColumns] PRIMARY KEY, + ['FarCar] VARCHAR(100) COLLATE Latin1_General_CI_AS, + [SomeDate] DATETIME, + [InTharKahr] NVARCHAR(50) COLLATE Latin1_General_100_CI_AS, + [💣EnTexxed💥] NTEXT COLLATE Latin1_General_CI_AS + ); + + CREATE TABLE dbo.[Yet🙀Another]]One'Column] + ( + [Yet🙀Another]]One'ColumnID] INT NOT NULL IDENTITY(1, 1) + CONSTRAINT [PK_Yet🙀Another]]One'Column] PRIMARY KEY, + [Stringy] NVARCHAR(50) COLLATE Syriac_90_CI_AS_SC, + [SomeDate] DATETIME, + + ); + + CREATE TABLE dbo.[DatabaseCollation] + ( + [DatabaseCollationID] INT NOT NULL IDENTITY(1, 1) + CONSTRAINT [PK_DatabaseCollation] PRIMARY KEY, + [VarChar] VARCHAR(100), + [NVarChar] NVARCHAR(50), + [SomeDate] DATETIME, + + ); + + + DECLARE @TestValue NVARCHAR(100) = NCHAR(0xE0) + NCHAR(0xE1) + NCHAR(0xE2) + NCHAR(0xE3) + NCHAR(0xE4) + + NCHAR(0xE4) + NCHAR(0xE5) + NCHAR(0xE6) + NCHAR(0xE7) + NCHAR(0xE8) + NCHAR(0xE9) + + NCHAR(0xEA) + NCHAR(0xEB) + NCHAR(0xEC) + NCHAR(0xED) + NCHAR(0xEE) + NCHAR(0xEF) + + NCHAR(0xF1) + NCHAR(0xF2) + NCHAR(0xF3) + NCHAR(0xF4) + NCHAR(0xF5) + NCHAR(0xF6) + + NCHAR(0xF8) + NCHAR(0xF9) + NCHAR(0xFA) + NCHAR(0xFB) + NCHAR(0xFC) + NCHAR(0xFD) + + NCHAR(0xFE) + N' ' + NCHAR(0x01F9) + N' ' + NCHAR(0x0219) + N' ' + NCHAR(0x03E1) + + N' ' + NCHAR(0x1F90); + + SELECT @TestValue AS [NVarCharValue], + DATALENGTH(@TestValue) AS [NVarCharBytes], + CONVERT(VARCHAR(100), @TestValue) AS [VarCharValue], + DATALENGTH(CONVERT(VARCHAR(100), @TestValue)) AS [VarCharBytes]; + + + INSERT INTO dbo.[One'Column] ([SomeDate], [String]) + VALUES (GETDATE(), @TestValue); -- VC (SQL) + INSERT INTO dbo.TwoColumns ([Stringy]]], [SomeDate], [LOBy]) + VALUES (@TestValue, GETDATE(), @TestValue); -- NC (SQL), TX (SQL) + INSERT INTO dbo.NoColumns ([SomeDate], [SomeMoney]) + VALUES (GETDATE(), $123.45); + INSERT INTO dbo.[Another]]One'Column] ([Stringy], [SomeDate]) + VALUES (@TestValue, GETDATE()); -- C (100) + INSERT INTO dbo.ThreeColumns (['FarCar], [SomeDate], [InTharKahr], [💣EnTexxed💥]) + VALUES (@TestValue, GETDATE(), @TestValue, @TestValue); -- VC (80), NVC (100), NTX (80) + INSERT INTO dbo.[Yet🙀Another]]One'Column] ([Stringy], [SomeDate]) + VALUES (@TestValue, GETDATE()); -- NVC (90) + INSERT INTO dbo.[DatabaseCollation] ([VarChar], [NVarChar], [SomeDate]) + VALUES (@TestValue, @TestValue, GETDATE()); -- VC (DATABASE_DEFAULT), NVC (DATABASE_DEFAULT) + +END; + + +SELECT 'BEFORE' AS [WHEN], @@TRANCOUNT AS [@@TRANCOUNT]; +SELECT * FROM dbo.[One'Column]; +SELECT * FROM dbo.TwoColumns; +SELECT * FROM dbo.NoColumns; +SELECT * FROM dbo.[Another]]One'Column]; +SELECT * FROM dbo.ThreeColumns; +SELECT * FROM dbo.[Yet🙀Another]]One'Column] +SELECT * FROM dbo.[DatabaseCollation]; + +------------------------------------------------------------------------------- +--===========================================================================-- +------------------------------------------------------------------------------- +DECLARE @TablesPerTransaction TINYINT = 2, + @FixNVarCharCollation BIT = 1; + +DECLARE @SQL NVARCHAR(MAX) = N'', + @CurrentTableName NVARCHAR(MAX) = N'', + @PreviousTableName NVARCHAR(MAX) = N'', + @FullScript NVARCHAR(MAX) = N''; + +;WITH pieces AS +( + SELECT QUOTENAME(sch.[name]) AS [SchemaName], + QUOTENAME(obj.[name]) AS [TableName], + QUOTENAME(col.[name]) AS [ColumnName], + typ.[name] AS [DataType], + IIF( COLLATIONPROPERTY(col.[collation_name], 'version') < 2 + AND ( typ.[name] IN (N'nchar', N'nvarchar', N'ntext') + OR col.[collation_name] LIKE N'%UTF8%'), + 1, 0) AS [CollationNeedsFixin], + ROW_NUMBER() OVER (PARTITION BY sch.[name], obj.[name] + ORDER BY sch.[name], obj.[name], col.[name]) AS [ColumnNum], + DENSE_RANK() OVER (ORDER BY sch.[name], obj.[name]) AS [ObjectNum] + FROM sys.objects obj + INNER JOIN sys.schemas sch + ON sch.[schema_id] = obj.[schema_id] + INNER JOIN sys.columns col + ON col.[object_id] = obj.[object_id] + INNER JOIN sys.types typ + ON typ.[user_type_id] = col.[system_type_id] + WHERE obj.[is_ms_shipped] = 0 + AND obj.[type] = N'U' + AND typ.[name] IN (N'char', N'varchar', N'text', N'nchar', N'nvarchar', N'ntext') + --ORDER BY sch.[name], obj.[name], col.[name] +), core AS +( + SELECT NCHAR(0x000D) + NCHAR(0x000A) AS [CRLF], + NCHAR(0x0009) AS [TAB], + NCHAR(0x0027) AS [APOS], -- single-quote + NCHAR(0x0027) + NCHAR(0x0027) AS [APOSx2], -- double single-quote + CONVERT(NVARCHAR(128), SERVERPROPERTY('ProductVersion')) AS [ProdVer] +), util AS +( + SELECT core.[CRLF], -- pass-through + core.[TAB], -- pass-through + core.[APOS], -- pass-through + core.[APOSx2], -- pass-through + CONVERT(INT, SUBSTRING(core.[ProdVer], 1, CHARINDEX(N'.', core.[ProdVer]) - 1)) AS [Version], + N'DECLARE @ErrorMessage NVARCHAR(MAX),' + core.[CRLF] + + N' @CurrentTime NVARCHAR(50);' + core.[CRLF] AS [ScriptStart], + N'BEGIN TRAN;' + core.[CRLF] AS [TranStart], + N'BEGIN TRY' + core.[CRLF] + + core.[TAB] + N'SET @CurrentTime = CONVERT(VARCHAR(50), SYSDATETIME(), 121);' + core.[CRLF] + + core.[TAB] + N'RAISERROR(N''%s -- %s ...'', 10, 1, @CurrentTime, N''{{TABLE_NAME}}'') WITH NOWAIT;' + + core.[CRLF] AS [TryCatchStart], + core.[TAB] + N'UPDATE {{TABLE_NAME}} SET' + core.[CRLF] AS [TableStart], + N',' + core.[CRLF] AS [ColumnEnd], + N';' + core.[CRLF] AS [TableEnd], + N'END TRY' + core.[CRLF] + + N'BEGIN CATCH' + core.[CRLF] + + core.[TAB] + N'IF (@@TRANCOUNT > 0) ROLLBACK TRAN;' + core.[CRLF] + + core.[TAB] + N'SET @ErrorMessage = N''( {{TABLE_NAME}} ): '' + ERROR_MESSAGE();' + core.[CRLF] + + core.[TAB] + N'RAISERROR(@ErrorMessage, 16, 1);' + core.[CRLF] + + core.[TAB] + N'RETURN;' + core.[CRLF] + + N'END CATCH;' + core.[CRLF] + core.[CRLF] AS [TryCatchEnd], + N'IF (@@TRANCOUNT > 0) COMMIT TRAN;' + core.[CRLF] AS [TranEnd] + FROM core +) +SELECT -- { store value to use multiple times in remaining variable concatenations } + @CurrentTableName = p.[SchemaName] + N'.' + p.[TableName], + + -- { main script generation } + @SQL += -- { end previous line } + IIF(DATALENGTH(@SQL) = 0, + u.[ScriptStart] + u.[CRLF] -- no previous line + + IIF((@TablesPerTransaction > 1) AND (p.[ObjectNum] % @TablesPerTransaction = 1), + N'', + N'--') + u.[TranStart] + u.[CRLF], + IIF(p.[ColumnNum] = 1, -- previous line was final column of a table + u.[TableEnd] + + REPLACE(u.[TryCatchEnd], N'{{TABLE_NAME}}', @PreviousTableName) + + IIF((@TablesPerTransaction > 1) AND (p.[ObjectNum] % @TablesPerTransaction = 1), + u.[TranEnd] + u.[TranStart], + N'--' + u.[TranEnd] + N'--' + u.[TranStart]) + u.[CRLF], + u.[ColumnEnd])) + -- { start new table } + + IIF(p.[ColumnNum] = 1, + REPLACE(u.[TryCatchStart], N'{{TABLE_NAME}}', REPLACE(@CurrentTableName, u.[APOS], u.[APOSx2])) + + REPLACE(u.[TableStart], N'{{TABLE_NAME}}', @CurrentTableName), + N'') + -- { start column } + + u.[TAB] + u.[TAB] + p.[ColumnName] + N' = UPPER(' + -- { TEXT and NTEXT aren't valid for UPPER() ; UTF8 needs special handling } + + CASE + WHEN (p.[DataType] IN (N'char', N'varchar')) AND (p.[CollationNeedsFixin] = 1) + THEN N'CONVERT(NVARCHAR(MAX), ' + p.[ColumnName] + N')' + WHEN p.[DataType] = N'text' THEN N'CONVERT(VARCHAR(MAX), ' + p.[ColumnName] + N')' + WHEN p.[DataType] = N'ntext' THEN N'CONVERT(NVARCHAR(MAX), ' + p.[ColumnName] + N')' + ELSE p.[ColumnName] + END + -- { For SQL Server 2008 or newer, NVARCHAR data must use a version 100 (or newer) collation } + + IIF((@FixNVarCharCollation = 1) AND (p.[CollationNeedsFixin] = 1), + N' COLLATE ' + + CASE + WHEN u.[Version] = 9 THEN N'Latin1_General_BIN2' -- 2005 + WHEN u.[Version] < 14 THEN N'Latin1_General_100_BIN2' -- 2008, 2008 R2, 2012, 2014, 2016 + ELSE N'Japanese_XJIS_140_BIN2' -- 2017 and newer + END, + N'') + -- { finish column } + + N')', + + -- { store value to use at beginning of next row } + @PreviousTableName = REPLACE(@CurrentTableName, u.[APOS], u.[APOSx2]), -- store TableName for CATCH BLOCK + + -- { store value to use after query finishes } + @FullScript = @SQL + u.[TableEnd] + + REPLACE(u.[TryCatchEnd], N'{{TABLE_NAME}}', @PreviousTableName) + + u.[TranEnd] + + u.[CRLF] + u.[CRLF] +FROM pieces p +CROSS JOIN util u +ORDER BY p.[ObjectNum], p.[ColumnNum]; + + + +PRINT '-----------------------'; +--PRINT @PreviousTableName; +--PRINT @SQL; + +PRINT @FullScript; -- DEBUG (this is usually commented-out) +PRINT '-----------------------'; + +EXEC (@FullScript); +------------------------------------------------------------------------------- +--===========================================================================-- +------------------------------------------------------------------------------- + +SELECT 'AFTER' AS [WHEN], @@TRANCOUNT AS [@@TRANCOUNT]; +SELECT * FROM dbo.[One'Column]; +SELECT * FROM dbo.TwoColumns; +SELECT * FROM dbo.NoColumns; +SELECT * FROM dbo.[Another]]One'Column]; +SELECT * FROM dbo.ThreeColumns; +SELECT * FROM dbo.[Yet🙀Another]]One'Column] +SELECT * FROM dbo.[DatabaseCollation]; +GO + + +IF (OBJECT_ID(N'dbo.One''Column') IS NOT NULL) +BEGIN + RAISERROR('Deleting test tables...', 10, 1) WITH NOWAIT; + DROP TABLE dbo.[One'Column]; + DROP TABLE dbo.TwoColumns; + DROP TABLE dbo.NoColumns; + DROP TABLE dbo.[Another]]One'Column]; + DROP TABLE dbo.ThreeColumns; + DROP TABLE dbo.[Yet🙀Another]]One'Column]; + DROP TABLE dbo.[DatabaseCollation]; +END; + +GO +---------------------------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/Scripts/Using_OPENROWSET_to_Query_Excel.sql b/Scripts/Using_OPENROWSET_to_Query_Excel.sql new file mode 100644 index 00000000..dfe27c34 --- /dev/null +++ b/Scripts/Using_OPENROWSET_to_Query_Excel.sql @@ -0,0 +1,31 @@ +/* +https://www.mssqltips.com/sqlservertip/6178/read-excel-file-in-sql-server-with-openrowset-or-opendatasource/ +*/ + +CREATE TABLE #Provider ( + ProviderName varchar(100) NOT NULL + , [ParseName] varchar(100) NOT NULL + , ProviderDescription varchar(100) NOT NULL + ); + +INSERT INTO #Provider EXEC sys.sp_enum_oledb_providers; + +IF NOT EXISTS (SELECT 1 FROM #Provider WHERE ProviderName LIKE 'Microsoft.ACE.OLEDB%') +PRINT('Please install Microsoft.ACE.OLEDB driver: 16 - https://www.microsoft.com/en-us/download/details.aspx?id=54920 or 12 - https://www.microsoft.com/en-US/download/details.aspx?id=13255'); +ELSE PRINT('Microsoft.ACE.OLEDB is installed. Go next.'); + +IF (SELECT "value" FROM sys.configurations WHERE "name" = 'Ad Hoc Distributed Queries') <> 1 +BEGIN + EXEC sp_configure 'show advanced option', '1'; + RECONFIGURE; + EXEC sp_configure 'Ad Hoc Distributed Queries', 1; + RECONFIGURE; +END; + +EXEC master.[sys].[sp_MSset_oledb_prop] N'Microsoft.ACE.OLEDB.16.0', N'AllowInProcess', 0; + +SELECT * + FROM OPENROWSET( + 'Microsoft.ACE.OLEDB.16.0' + , 'Excel 12.0;Database=g:\MSSQL17\Instagram_Statistics.xlsx' + , 'SELECT * FROM [decoupagpro$]') AS op; diff --git a/Scripts/VLF_Info.sql b/Scripts/VLF_Info.sql new file mode 100644 index 00000000..d0b5decb --- /dev/null +++ b/Scripts/VLF_Info.sql @@ -0,0 +1,122 @@ +/* + + Detailed information about VLF files. + 2 data sets: first with agregated vlf information and second with detailed info. + No + Kev Riley + 2016-12-07 + 2019-06-25 by Konstantin Taranov + 1.1 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/VLF_Info.sql + https://gallery.technet.microsoft.com/scriptcenter/SQL-Script-to-list-VLF-e6315249 + +*/ + +SET NOCOUNT ON; + +/* variables to hold each 'iteration' */ +DECLARE @query nvarchar(200); +DECLARE @dbName sysname; + +/* table variable used to 'loop' over databases */ +DECLARE @databases TABLE (dbname sysname); +/* only choose online databases */ +INSERT INTO @databases +SELECT [name] FROM sys.databases WHERE [state] = 0; + +DECLARE @majorVersion tinyint; +SET @majorVersion = LEFT(CAST(SERVERPROPERTY('ProductVersion') AS nvarchar(max)), + CHARINDEX('.',CAST(SERVERPROPERTY('ProductVersion') AS nvarchar(max))) - 1); + +DECLARE DatabaseIteration CURSOR LOCAL STATIC READ_ONLY FORWARD_ONLY FOR +SELECT [name] AS DatabaseName FROM sys.databases WHERE [state] = 0; + +BEGIN + + OPEN DatabaseIteration; + + DECLARE @DbccLogInfo TABLE( + RecoveryUnitId int NULL, + fileid smallint NOT NULL, + file_size bigint NOT NULL, + start_offset bigint NOT NULL, + fseqno int NOT NULL, + [status] tinyint NOT NULL, + parity tinyint NOT NULL, + create_lsn numeric(25,0) NOT NULL, + DBName sysname NULL, + [DBID] int NULL + ); + + FETCH NEXT FROM DatabaseIteration INTO @dbName; + + WHILE @@FETCH_STATUS = 0 + BEGIN + + SET @query = N'DBCC LOGINFO (N' + N'''' + @dbName + N''') WITH NO_INFOMSGS;'; + PRINT(@query); + + IF @majorVersion < 11 /* pre SQL 2012 versions */ + BEGIN + INSERT INTO @DbccLogInfo( + fileid + , file_size + , start_offset + , fseqno + , [status] + , parity + , create_lsn + ) + EXEC sp_executesql @query; + END; + ELSE + BEGIN + INSERT INTO @DbccLogInfo( + RecoveryUnitId + , fileid + , file_size + , start_offset + , fseqno + , [status] + , parity + , create_lsn + ) + EXEC sp_executesql @query; + END; + + UPDATE @DbccLogInfo + SET DBName = @dbName + , [DBID] = DB_ID(@dbName) + WHERE DBName IS NULL; + + FETCH NEXT FROM DatabaseIteration INTO @dbName; + + END; + + CLOSE DatabaseIteration; + DEALLOCATE DatabaseIteration; + +END; + +/* output the full list */ +WITH CTE_VLF AS ( + SELECT dc.[DBID] + , dc.DBName + , MIN(dc.file_size) / 1024 / 1024 AS FileSizeMbMIN + , MAX(dc.file_size) / 1024 / 1024 AS FileSizeMbMAX + , AVG(dc.file_size) / 1024 / 1024 AS FileSizeMbAVG + , SUM(dc.file_size) / 1024 / 1024 AS FileSizeMbSUM + , COUNT(dc.fileid) AS VLFCount + FROM @DbccLogInfo AS dc + GROUP BY dc.[DBID] + , dc.DBName +) +SELECT CTE_VLF.* + , CASE WHEN VLFCount >= 1000 THEN 'Check your VLF count, maybe you need reduce it' + WHEN FileSizeMbAVG >= 500 THEN 'Check your VLF size, maybe you need decrease it' + ELSE 'Maybe it is ok' + END Warnings +FROM CTE_VLF +ORDER BY VLFCount DESC; + +SELECT * FROM @DbccLogInfo; diff --git a/Scripts/Visualizing_VLF.sql b/Scripts/Visualizing_VLF.sql index 40fc962a..93b6233b 100644 --- a/Scripts/Visualizing_VLF.sql +++ b/Scripts/Visualizing_VLF.sql @@ -18,9 +18,11 @@ DECLARE @logInfoResults AS TABLE INSERT INTO @logInfoResults EXEC sp_executesql N'DBCC LOGINFO WITH NO_INFOMSGS'; -SELECT cast(FileSize / 1024.0 / 1024 AS DECIMAL(20,1)) as FileSizeInMB, -case when FSeqNo = 0 then 'Available - Never Used' else (Case when status = 2 then 'In Use' else 'Available' end) end as TextStatus, -[Status] , -REPLICATE('x', FileSize / MIN(FileSize) over()) as [BarChart ________________________________________________________________________________________________] +SELECT cast(FileSize / 1024.0 / 1024 AS DECIMAL(20,1)) as FileSizeInMB + , CASE WHEN FSeqNo = 0 THEN 'Available - Never Used' + ELSE (CASE WHEN [Status] = 2 THEN 'In Use' ELSE 'Available' END) + END AS TextStatus + , [Status] + , REPLICATE('x', FileSize / MIN(FileSize) over()) as [BarChart ________________________________________________________________________________________________] FROM @logInfoResults; GO diff --git a/Scripts/Wait_Statistics.sql b/Scripts/Wait_Statistics.sql index 1524d25a..bd24871c 100644 --- a/Scripts/Wait_Statistics.sql +++ b/Scripts/Wait_Statistics.sql @@ -1,6 +1,13 @@ /* -Author: Paul Randal -Original link: http://www.sqlskills.com/blogs/paul/wait-statistics-or-please-tell-me-where-it-hurts/ + + Generate complex query plan + Reads and writes per database. + 2010-12-09 by Paul Randal + 2019-02-26 by Paul Randal + 1.1 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Wait_Statistics.sql + https://www.sqlskills.com/blogs/paul/wait-statistics-or-please-tell-me-where-it-hurts/ + */ WITH [Waits] AS @@ -14,41 +21,95 @@ WITH [Waits] AS ROW_NUMBER() OVER(ORDER BY [wait_time_ms] DESC) AS [RowNum] FROM sys.dm_os_wait_stats WHERE [wait_type] NOT IN ( - N'BROKER_EVENTHANDLER', N'BROKER_RECEIVE_WAITFOR', - N'BROKER_TASK_STOP', N'BROKER_TO_FLUSH', - N'BROKER_TRANSMITTER', N'CHECKPOINT_QUEUE', - N'CHKPT', N'CLR_AUTO_EVENT', - N'CLR_MANUAL_EVENT', N'CLR_SEMAPHORE', - N'DBMIRROR_DBM_EVENT', N'DBMIRROR_EVENTS_QUEUE', - N'DBMIRROR_WORKER_QUEUE', N'DBMIRRORING_CMD', - N'DIRTY_PAGE_POLL', N'DISPATCHER_QUEUE_SEMAPHORE', - N'EXECSYNC', N'FSAGENT', - N'FT_IFTS_SCHEDULER_IDLE_WAIT', N'FT_IFTSHC_MUTEX', - N'HADR_CLUSAPI_CALL', N'HADR_FILESTREAM_IOMGR_IOCOMPLETION', - N'HADR_LOGCAPTURE_WAIT', N'HADR_NOTIFICATION_DEQUEUE', - N'HADR_TIMER_TASK', N'HADR_WORK_QUEUE', - N'KSOURCE_WAKEUP', N'LAZYWRITER_SLEEP', - N'LOGMGR_QUEUE', N'ONDEMAND_TASK_QUEUE', - N'PWAIT_ALL_COMPONENTS_INITIALIZED', - N'QDS_PERSIST_TASK_MAIN_LOOP_SLEEP', - N'QDS_SHUTDOWN_QUEUE', + -- These wait types are almost 100% never a problem and so they are + -- filtered out to avoid them skewing the results. Click on the URL + -- for more information. + N'BROKER_EVENTHANDLER', -- https://www.sqlskills.com/help/waits/BROKER_EVENTHANDLER + N'BROKER_RECEIVE_WAITFOR', -- https://www.sqlskills.com/help/waits/BROKER_RECEIVE_WAITFOR + N'BROKER_TASK_STOP', -- https://www.sqlskills.com/help/waits/BROKER_TASK_STOP + N'BROKER_TO_FLUSH', -- https://www.sqlskills.com/help/waits/BROKER_TO_FLUSH + N'BROKER_TRANSMITTER', -- https://www.sqlskills.com/help/waits/BROKER_TRANSMITTER + N'CHECKPOINT_QUEUE', -- https://www.sqlskills.com/help/waits/CHECKPOINT_QUEUE + N'CHKPT', -- https://www.sqlskills.com/help/waits/CHKPT + N'CLR_AUTO_EVENT', -- https://www.sqlskills.com/help/waits/CLR_AUTO_EVENT + N'CLR_MANUAL_EVENT', -- https://www.sqlskills.com/help/waits/CLR_MANUAL_EVENT + N'CLR_SEMAPHORE', -- https://www.sqlskills.com/help/waits/CLR_SEMAPHORE + N'CXCONSUMER', -- https://www.sqlskills.com/help/waits/CXCONSUMER + + -- Maybe comment these four out if you have mirroring issues + N'DBMIRROR_DBM_EVENT', -- https://www.sqlskills.com/help/waits/DBMIRROR_DBM_EVENT + N'DBMIRROR_EVENTS_QUEUE', -- https://www.sqlskills.com/help/waits/DBMIRROR_EVENTS_QUEUE + N'DBMIRROR_WORKER_QUEUE', -- https://www.sqlskills.com/help/waits/DBMIRROR_WORKER_QUEUE + N'DBMIRRORING_CMD', -- https://www.sqlskills.com/help/waits/DBMIRRORING_CMD + + N'DIRTY_PAGE_POLL', -- https://www.sqlskills.com/help/waits/DIRTY_PAGE_POLL + N'DISPATCHER_QUEUE_SEMAPHORE', -- https://www.sqlskills.com/help/waits/DISPATCHER_QUEUE_SEMAPHORE + N'EXECSYNC', -- https://www.sqlskills.com/help/waits/EXECSYNC + N'FSAGENT', -- https://www.sqlskills.com/help/waits/FSAGENT + N'FT_IFTS_SCHEDULER_IDLE_WAIT', -- https://www.sqlskills.com/help/waits/FT_IFTS_SCHEDULER_IDLE_WAIT + N'FT_IFTSHC_MUTEX', -- https://www.sqlskills.com/help/waits/FT_IFTSHC_MUTEX + + -- Maybe comment these six out if you have AG issues + N'HADR_CLUSAPI_CALL', -- https://www.sqlskills.com/help/waits/HADR_CLUSAPI_CALL + N'HADR_FILESTREAM_IOMGR_IOCOMPLETION', -- https://www.sqlskills.com/help/waits/HADR_FILESTREAM_IOMGR_IOCOMPLETION + N'HADR_LOGCAPTURE_WAIT', -- https://www.sqlskills.com/help/waits/HADR_LOGCAPTURE_WAIT + N'HADR_NOTIFICATION_DEQUEUE', -- https://www.sqlskills.com/help/waits/HADR_NOTIFICATION_DEQUEUE + N'HADR_TIMER_TASK', -- https://www.sqlskills.com/help/waits/HADR_TIMER_TASK + N'HADR_WORK_QUEUE', -- https://www.sqlskills.com/help/waits/HADR_WORK_QUEUE + + N'KSOURCE_WAKEUP', -- https://www.sqlskills.com/help/waits/KSOURCE_WAKEUP + N'LAZYWRITER_SLEEP', -- https://www.sqlskills.com/help/waits/LAZYWRITER_SLEEP + N'LOGMGR_QUEUE', -- https://www.sqlskills.com/help/waits/LOGMGR_QUEUE + N'MEMORY_ALLOCATION_EXT', -- https://www.sqlskills.com/help/waits/MEMORY_ALLOCATION_EXT + N'ONDEMAND_TASK_QUEUE', -- https://www.sqlskills.com/help/waits/ONDEMAND_TASK_QUEUE + N'PARALLEL_REDO_DRAIN_WORKER', -- https://www.sqlskills.com/help/waits/PARALLEL_REDO_DRAIN_WORKER + N'PARALLEL_REDO_LOG_CACHE', -- https://www.sqlskills.com/help/waits/PARALLEL_REDO_LOG_CACHE + N'PARALLEL_REDO_TRAN_LIST', -- https://www.sqlskills.com/help/waits/PARALLEL_REDO_TRAN_LIST + N'PARALLEL_REDO_WORKER_SYNC', -- https://www.sqlskills.com/help/waits/PARALLEL_REDO_WORKER_SYNC + N'PARALLEL_REDO_WORKER_WAIT_WORK', -- https://www.sqlskills.com/help/waits/PARALLEL_REDO_WORKER_WAIT_WORK + N'PREEMPTIVE_OS_FLUSHFILEBUFFERS', -- https://www.sqlskills.com/help/waits/PREEMPTIVE_OS_FLUSHFILEBUFFERS + N'PREEMPTIVE_XE_GETTARGETSTATE', -- https://www.sqlskills.com/help/waits/PREEMPTIVE_XE_GETTARGETSTATE + N'PWAIT_ALL_COMPONENTS_INITIALIZED', -- https://www.sqlskills.com/help/waits/PWAIT_ALL_COMPONENTS_INITIALIZED + N'PWAIT_DIRECTLOGCONSUMER_GETNEXT', -- https://www.sqlskills.com/help/waits/PWAIT_DIRECTLOGCONSUMER_GETNEXT + N'QDS_PERSIST_TASK_MAIN_LOOP_SLEEP', -- https://www.sqlskills.com/help/waits/QDS_PERSIST_TASK_MAIN_LOOP_SLEEP + N'QDS_ASYNC_QUEUE', -- https://www.sqlskills.com/help/waits/QDS_ASYNC_QUEUE N'QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEP', - N'REQUEST_FOR_DEADLOCK_SEARCH', N'RESOURCE_QUEUE', - N'SERVER_IDLE_CHECK', N'SLEEP_BPOOL_FLUSH', - N'SLEEP_DBSTARTUP', N'SLEEP_DCOMSTARTUP', - N'SLEEP_MASTERDBREADY', N'SLEEP_MASTERMDREADY', - N'SLEEP_MASTERUPGRADED', N'SLEEP_MSDBSTARTUP', - N'SLEEP_SYSTEMTASK', N'SLEEP_TASK', - N'SLEEP_TEMPDBSTARTUP', N'SNI_HTTP_ACCEPT', - N'SP_SERVER_DIAGNOSTICS_SLEEP', N'SQLTRACE_BUFFER_FLUSH', - N'SQLTRACE_INCREMENTAL_FLUSH_SLEEP', - N'SQLTRACE_WAIT_ENTRIES', N'WAIT_FOR_RESULTS', - N'WAITFOR', N'WAITFOR_TASKSHUTDOWN', - N'WAIT_XTP_HOST_WAIT', N'WAIT_XTP_OFFLINE_CKPT_NEW_LOG', - N'WAIT_XTP_CKPT_CLOSE', N'XE_DISPATCHER_JOIN', - N'XE_DISPATCHER_WAIT', N'XE_TIMER_EVENT') + -- https://www.sqlskills.com/help/waits/QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEP + N'QDS_SHUTDOWN_QUEUE', -- https://www.sqlskills.com/help/waits/QDS_SHUTDOWN_QUEUE + N'REDO_THREAD_PENDING_WORK', -- https://www.sqlskills.com/help/waits/REDO_THREAD_PENDING_WORK + N'REQUEST_FOR_DEADLOCK_SEARCH', -- https://www.sqlskills.com/help/waits/REQUEST_FOR_DEADLOCK_SEARCH + N'RESOURCE_QUEUE', -- https://www.sqlskills.com/help/waits/RESOURCE_QUEUE + N'SERVER_IDLE_CHECK', -- https://www.sqlskills.com/help/waits/SERVER_IDLE_CHECK + N'SLEEP_BPOOL_FLUSH', -- https://www.sqlskills.com/help/waits/SLEEP_BPOOL_FLUSH + N'SLEEP_DBSTARTUP', -- https://www.sqlskills.com/help/waits/SLEEP_DBSTARTUP + N'SLEEP_DCOMSTARTUP', -- https://www.sqlskills.com/help/waits/SLEEP_DCOMSTARTUP + N'SLEEP_MASTERDBREADY', -- https://www.sqlskills.com/help/waits/SLEEP_MASTERDBREADY + N'SLEEP_MASTERMDREADY', -- https://www.sqlskills.com/help/waits/SLEEP_MASTERMDREADY + N'SLEEP_MASTERUPGRADED', -- https://www.sqlskills.com/help/waits/SLEEP_MASTERUPGRADED + N'SLEEP_MSDBSTARTUP', -- https://www.sqlskills.com/help/waits/SLEEP_MSDBSTARTUP + N'SLEEP_SYSTEMTASK', -- https://www.sqlskills.com/help/waits/SLEEP_SYSTEMTASK + N'SLEEP_TASK', -- https://www.sqlskills.com/help/waits/SLEEP_TASK + N'SLEEP_TEMPDBSTARTUP', -- https://www.sqlskills.com/help/waits/SLEEP_TEMPDBSTARTUP + N'SNI_HTTP_ACCEPT', -- https://www.sqlskills.com/help/waits/SNI_HTTP_ACCEPT + N'SOS_WORK_DISPATCHER', -- https://www.sqlskills.com/help/waits/SOS_WORK_DISPATCHER + N'SP_SERVER_DIAGNOSTICS_SLEEP', -- https://www.sqlskills.com/help/waits/SP_SERVER_DIAGNOSTICS_SLEEP + N'SQLTRACE_BUFFER_FLUSH', -- https://www.sqlskills.com/help/waits/SQLTRACE_BUFFER_FLUSH + N'SQLTRACE_INCREMENTAL_FLUSH_SLEEP', -- https://www.sqlskills.com/help/waits/SQLTRACE_INCREMENTAL_FLUSH_SLEEP + N'SQLTRACE_WAIT_ENTRIES', -- https://www.sqlskills.com/help/waits/SQLTRACE_WAIT_ENTRIES + N'VDI_CLIENT_OTHER', -- https://www.sqlskills.com/help/waits/VDI_CLIENT_OTHER + N'WAIT_FOR_RESULTS', -- https://www.sqlskills.com/help/waits/WAIT_FOR_RESULTS + N'WAITFOR', -- https://www.sqlskills.com/help/waits/WAITFOR + N'WAITFOR_TASKSHUTDOWN', -- https://www.sqlskills.com/help/waits/WAITFOR_TASKSHUTDOWN + N'WAIT_XTP_RECOVERY', -- https://www.sqlskills.com/help/waits/WAIT_XTP_RECOVERY + N'WAIT_XTP_HOST_WAIT', -- https://www.sqlskills.com/help/waits/WAIT_XTP_HOST_WAIT + N'WAIT_XTP_OFFLINE_CKPT_NEW_LOG', -- https://www.sqlskills.com/help/waits/WAIT_XTP_OFFLINE_CKPT_NEW_LOG + N'WAIT_XTP_CKPT_CLOSE', -- https://www.sqlskills.com/help/waits/WAIT_XTP_CKPT_CLOSE + N'XE_DISPATCHER_JOIN', -- https://www.sqlskills.com/help/waits/XE_DISPATCHER_JOIN + N'XE_DISPATCHER_WAIT', -- https://www.sqlskills.com/help/waits/XE_DISPATCHER_WAIT + N'XE_TIMER_EVENT' -- https://www.sqlskills.com/help/waits/XE_TIMER_EVENT + ) AND [waiting_tasks_count] > 0 - ) + ) SELECT MAX ([W1].[wait_type]) AS [WaitType], CAST (MAX ([W1].[WaitS]) AS DECIMAL (16,2)) AS [Wait_S], @@ -58,10 +119,10 @@ SELECT CAST (MAX ([W1].[Percentage]) AS DECIMAL (5,2)) AS [Percentage], CAST ((MAX ([W1].[WaitS]) / MAX ([W1].[WaitCount])) AS DECIMAL (16,4)) AS [AvgWait_S], CAST ((MAX ([W1].[ResourceS]) / MAX ([W1].[WaitCount])) AS DECIMAL (16,4)) AS [AvgRes_S], - CAST ((MAX ([W1].[SignalS]) / MAX ([W1].[WaitCount])) AS DECIMAL (16,4)) AS [AvgSig_S] + CAST ((MAX ([W1].[SignalS]) / MAX ([W1].[WaitCount])) AS DECIMAL (16,4)) AS [AvgSig_S], + CAST ('https://www.sqlskills.com/help/waits/' + MAX ([W1].[wait_type]) as XML) AS [Help/Info URL] FROM [Waits] AS [W1] -INNER JOIN [Waits] AS [W2] - ON [W2].[RowNum] <= [W1].[RowNum] +INNER JOIN [Waits] AS [W2] ON [W2].[RowNum] <= [W1].[RowNum] GROUP BY [W1].[RowNum] -HAVING SUM ([W2].[Percentage]) - MAX ([W1].[Percentage]) < 95; -- percentage threshold +HAVING SUM ([W2].[Percentage]) - MAX( [W1].[Percentage] ) < 95; -- percentage threshold GO diff --git a/Scripts/Wait_Statistics_Snapshot.sql b/Scripts/Wait_Statistics_Snapshot.sql new file mode 100644 index 00000000..a03f8006 --- /dev/null +++ b/Scripts/Wait_Statistics_Snapshot.sql @@ -0,0 +1,74 @@ +/* + + Generate complex query plan + Reads and writes per database. + 2010-12-09 by Paul Randal + 2019-02-26 by Paul Randal + 1.1 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Wait_Statistics_Snapshot.sql + https://www.sqlskills.com/blogs/paul/wait-statistics-or-please-tell-me-where-it-hurts/ + + + File: WaitingTasks.sql + + Summary: Snapshot of waiting tasks + + SQL Server Versions: 2005 onward +------------------------------------------------------------------------------ + Written by Paul S. Randal, SQLskills.com + + (c) 2019, SQLskills.com. All rights reserved. + + For more scripts and sample code, check out + http://www.SQLskills.com + + You may alter this code for your own *non-commercial* purposes. You may + republish altered code as long as you include this copyright and give due + credit, but you must obtain prior permission before blogging this code. + + THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF + ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED + TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A + PARTICULAR PURPOSE. +*/ + +SELECT + [owt].[session_id] AS [SPID], + [owt].[exec_context_id] AS [Thread], + [ot].[scheduler_id] AS [Scheduler], + [owt].[wait_duration_ms] AS [wait_ms], + [owt].[wait_type], + [owt].[blocking_session_id] AS [Blocking SPID], + [owt].[resource_description], + CASE [owt].[wait_type] + WHEN N'CXPACKET' THEN + SUBSTRING ( -- earlier versions don't have anything after the nodeID... + [owt].[resource_description], + CHARINDEX (N'nodeId=', [owt].[resource_description]) + 7, + CHARINDEX (N' tid=', [owt].[resource_description] + ' tid=') - + CHARINDEX (N'nodeId=', [owt].[resource_description]) - 7 + ) + ELSE NULL + END AS [Node ID], + [eqmg].[dop] AS [DOP], + [er].[database_id] AS [DBID], + CAST ('https://www.sqlskills.com/help/waits/' + [owt].[wait_type] as XML) AS [Help/Info URL], + [eqp].[query_plan], + [est].text +FROM sys.dm_os_waiting_tasks [owt] +INNER JOIN sys.dm_os_tasks [ot] ON + [owt].[waiting_task_address] = [ot].[task_address] +INNER JOIN sys.dm_exec_sessions [es] ON + [owt].[session_id] = [es].[session_id] +INNER JOIN sys.dm_exec_requests [er] ON + [es].[session_id] = [er].[session_id] +FULL JOIN sys.dm_exec_query_memory_grants [eqmg] ON + [owt].[session_id] = [eqmg].[session_id] +OUTER APPLY sys.dm_exec_sql_text ([er].[sql_handle]) [est] +OUTER APPLY sys.dm_exec_query_plan ([er].[plan_handle]) [eqp] +WHERE + [es].[is_user_process] = 1 +ORDER BY + [owt].[session_id], + [owt].[exec_context_id]; +GO diff --git a/Scripts/When_SQL_Server_Was_Installed.sql b/Scripts/When_SQL_Server_Was_Installed.sql new file mode 100644 index 00000000..906bfb09 --- /dev/null +++ b/Scripts/When_SQL_Server_Was_Installed.sql @@ -0,0 +1,24 @@ +/* + + When SQL Server Was Installed. + Find in sys.server_principals oldest NT Service login. + No + Rebecca Lewis + 2019-04-25 + 2019-04-30 by Konstantin Taranov + 1.0 + https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/When_SQL_Server_Was_Installed.sql + +*/ + + +SELECT TOP(1) + SERVERPROPERTY('ProductVersion') AS ProductVersion + , SERVERPROPERTY('ProductLevel') AS ProductLevel + , SERVERPROPERTY('Edition') AS Edition + , SERVERPROPERTY('MachineName') AS MachineName + , create_date AS "SQL Server Installation Date" + , name AS SystemUserName +FROM sys.server_principals +WHERE name LIKE 'NT Service%' +ORDER BY create_date; diff --git a/Scripts/Who_dropped_altered_database_object.sql b/Scripts/Who_dropped_altered_database_object.sql new file mode 100644 index 00000000..4eaf122b --- /dev/null +++ b/Scripts/Who_dropped_altered_database_object.sql @@ -0,0 +1,49 @@ +/* +Created: 2018-10-31 by Rebecca Lewis +Modified: 2019-03-26 by Konstantin Taranov +Original link: http://www.sqlfingers.com/2018/10/who-dropped-that-table.html +Source link: https://github.com/ktaranov/sqlserver-kit/blob/master/Scripts/Who_dropped_altered_database_object.sql +*/ + +SET NOCOUNT ON; + +DECLARE @current NVARCHAR(255); +DECLARE @start NVARCHAR(255); +DECLARE @index INT; + +/* find your trace path */ +SELECT @current = path FROM sys.traces WHERE is_default = 1; + +SET @current = REVERSE(@current); +SET @index = PATINDEX('%\%', @current); +SET @current = REVERSE(@current); +SET @start = LEFT(@current, LEN(@current) - @index) + N'\log.trc'; + +/* query on the eventclasses for delete and alter */ +SELECT te.name AS EventName + , gt.DatabaseName + , gt.ObjectName + , gt.StartTime + , gt.EndTime + , gt.HostName + , gt.ApplicationName + , gt.NTUserName + , gt.NTDomainName + , gt.LoginName + , gt.SPID + , gt.EventClass + , gt.EventSubClass + , gt.TextData + , gt.FileName + , gt.IsSystem +FROM fn_trace_gettable(@start, DEFAULT) AS gt +LEFT JOIN sys.trace_events AS te ON gt.EventClass = te.trace_event_id +WHERE gt.EventSubClass = 0 + AND gt.DatabaseID <> 2 /* tempdb */ + /* + AND EventClass IN ( 164 /* Object:Deleted */ + , 47 /* Object:Altered */ + , 46 /* Object:Created */ + ) + */ +ORDER BY gt.StartTime; diff --git a/Scripts/Who_dropped_database.sql b/Scripts/Who_dropped_database.sql index a9940483..76dcfcfd 100644 --- a/Scripts/Who_dropped_database.sql +++ b/Scripts/Who_dropped_database.sql @@ -3,67 +3,62 @@ Author: Jason Brimhall Original link: http://jasonbrimhall.info/2016/09/09/database-dropped/ */ -DECLARE @DBName sysname = 'AdventureWorks2014' - ,@d1 DATETIME - ,@diff INT; +--DECLARE @DBName sysname = 'AdventureWorks2014'; +DECLARE @d1 DATETIME; +DECLARE @diff INT; SELECT ObjectName - , ObjectID - , DatabaseName - , StartTime - , EventClass - , EventSubClass - , ObjectType - , ServerName - , LoginName - , NTUserName - , ApplicationName - , CASE EventClass - WHEN 46 - THEN 'CREATE' - WHEN 47 - THEN 'DROP' - --WHEN 164 - -- THEN 'ALTER' - END AS DDLOperation - INTO #temp_trace - FROM sys.fn_trace_gettable(CONVERT(VARCHAR(150), - ( SELECT REVERSE(SUBSTRING(REVERSE(path), - CHARINDEX('\',REVERSE(path)),256)) + 'log.trc' - FROM sys.traces - WHERE is_default = 1)), DEFAULT) T - WHERE EventClass in (46,47) - AND EventSubclass = 0 - AND ObjectType = 16964-- i just want database related events - AND DatabaseName = ISNULL(@DBName,DatabaseName); + , ObjectID + , DatabaseName + , StartTime + , EventClass + , EventSubClass + , ObjectType + , ServerName + , LoginName + , NTUserName + , ApplicationName + , CASE EventClass + WHEN 46 THEN 'CREATE' + WHEN 47 THEN 'DROP' + WHEN 164 THEN 'ALTER' + END AS DDLOperation + INTO #temp_trace + FROM sys.fn_trace_gettable(CONVERT(VARCHAR(150), + (SELECT REVERSE(SUBSTRING(REVERSE(path), + CHARINDEX('\',REVERSE(path)),256)) + 'log.trc' + FROM sys.traces + WHERE is_default = 1)), DEFAULT) as t + WHERE EventClass in (46, 47, 164) + AND EventSubClass = 0 + AND ObjectType = 16964-- i just want database related events + --AND DatabaseName = ISNULL(@DBName,DatabaseName) +; - -SELECT @d1 = MIN(StartTime) - FROM #temp_trace; +SELECT @d1 = MIN(StartTime) FROM #temp_trace; SET @diff= DATEDIFF(hh,@d1,GETDATE()); - -SELECT @diff AS HrsSinceFirstChange - , @d1 AS FirstChangeDate - , sv.name AS obj_type_desc - , tt.ObjectType - , tt.DDLOperation - , tt.DatabaseName,tt.ObjectName,tt.StartTime - , tt.EventClass,tt.EventSubClass - , tt.ServerName,tt.LoginName, tt.NTUserName - , tt.ApplicationName - , (dense_rank() OVER (ORDER BY ObjectName,ObjectType ) )%2 AS l1 - , (dense_rank() OVER (ORDER BY ObjectName,ObjectType,StartTime ))%2 AS l2 - FROM #temp_trace tt - INNER JOIN sys.trace_events AS te - ON tt.EventClass = te.trace_event_id - INNER JOIN sys.trace_subclass_values tsv - ON tt.EventClass = tsv.trace_event_id - AND tt.ObjectType = tsv.subclass_value - INNER JOIN master.dbo.spt_values sv - ON tsv.subclass_value = sv.number - AND sv.type = 'EOD' - ORDER BY StartTime DESC; +SELECT @diff AS HrsSinceFirstChange + , @d1 AS FirstChangeDate + , sv.name AS obj_type_desc + , tt.ObjectType + , tt.DDLOperation + , tt.DatabaseName + , tt.ObjectName + , tt.StartTime + , tt.EventClass + , tt.EventSubClass + , tt.ServerName + , tt.LoginName + , tt.NTUserName + , tt.ApplicationName + , (DENSE_RANK() OVER (ORDER BY ObjectName,ObjectType ) )%2 AS l1 + , (DENSE_RANK() OVER (ORDER BY ObjectName,ObjectType,StartTime ))%2 AS l2 + FROM #temp_trace tt + INNER JOIN sys.trace_events AS te ON tt.EventClass = te.trace_event_id + INNER JOIN sys.trace_subclass_values tsv ON tt.EventClass = tsv.trace_event_id AND tt.ObjectType = tsv.subclass_value + INNER JOIN master.dbo.spt_values sv ON tsv.subclass_value = sv.number AND sv.type = 'EOD' +ORDER BY StartTime DESC; DROP TABLE #temp_trace; diff --git a/Scripts/glen_berry_diagnostic_queries_links.txt b/Scripts/glen_berry_diagnostic_queries_links.txt new file mode 100644 index 00000000..61ed9804 --- /dev/null +++ b/Scripts/glen_berry_diagnostic_queries_links.txt @@ -0,0 +1,9 @@ +https://www.dropbox.com/s/k1vauzxxhyh1fnb/SQL%20Server%202019%20Diagnostic%20Information%20Queries.sql?dl=1 +https://www.dropbox.com/s/3ix2lqhry34c5wy/SQL%20Server%202017%20Diagnostic%20Information%20Queries.sql?dl=1 +https://www.dropbox.com/s/pkpxihdkq3odgbj/SQL%20Server%202016%20SP2%20Diagnostic%20Information%20Queries.sql?dl=1 +https://www.dropbox.com/s/w6gi8j76k64fgbg/SQL%20Server%202016%20SP1%20Diagnostic%20Information%20Queries.sql?dl=1 +https://www.dropbox.com/s/uttp0843e5078vs/SQL%20Server%202014%20Diagnostic%20Information%20Queries.sql?dl=1 +https://www.dropbox.com/s/3l4yotzedk45xeh/SQL%20Server%202012%20Diagnostic%20Information%20Queries.sql?dl=1 +https://www.dropbox.com/s/fq6hyw899fe3crv/SQL%20Server%202008%20R2%20Diagnostic%20Information%20Queries.sql?dl=1 +https://www.dropbox.com/s/mjxw1w9tgw7eo6g/SQL%20Server%202008%20Diagnostic%20Information%20Queries.sql?dl=1 +https://www.dropbox.com/s/3kkskuheyzauih9/SQL%20Server%202005%20Diagnostic%20Information%20Queries.sql?dl=1 diff --git a/Scripts/mssql2csv.R b/Scripts/mssql2csv.R new file mode 100644 index 00000000..229945d3 --- /dev/null +++ b/Scripts/mssql2csv.R @@ -0,0 +1,118 @@ +options(stringsAsFactors = FALSE) + +library("data.table") +library("RODBC") +library("logging") + +loggerName <- "mmssql2csv" +addHandler(writeToConsole, logger = loggerName) + +loginfo(msg = "Start", logger = loggerName) + +rodbcSQLQeuryToDF <- function(connectionString, sqlQuery) { + ch <- odbcDriverConnect(connection = connectionString) + df <- sqlQuery(ch, sqlQuery, errors = TRUE) + odbcClose(ch) + return(as.data.table(df)) +} + +outputFolder <- "e:/333/" +numberOfProcess <- as.integer(Sys.getenv("NUMBER_OF_PROCESSORS")) +connectionString <- + "Driver=ODBC Driver 11 for SQL Server;Server=.;Database=NIIGAZ;Uid=asp_niigaz;pwd=;" + +pass <- readline(prompt = "Enter a SQL Server user password: ") + +connectionString <- + gsub("pwd=", paste0("pwd=", pass), connectionString) + + +listTables <- rodbcSQLQeuryToDF( + connectionString = connectionString, + sqlQuery = " + WITH TablePages AS ( + SELECT s.[object_id] + , SUM(s.reserved_page_count) AS reserved_pages + , SUM(s.used_page_count) AS used_pages + , SUM(CASE WHEN index_id < 2 THEN in_row_data_page_count + lob_used_page_count + row_overflow_used_page_count + ELSE lob_used_page_count + row_overflow_used_page_count + END) AS pages + , (SELECT COUNT(i.[object_id]) FROM sys.indexes AS i WHERE s.[object_id] = i.[object_id] AND i.[type] <> 0) AS IndexCount + , SUM(row_count) AS NumberOfRows + FROM sys.dm_db_partition_stats AS s + GROUP BY [object_id] + ) + , ExtraData AS ( + SELECT p.[object_id] + , COUNT(*) AS IndexCount + , SUM(reserved_page_count) AS reserved_pages + , SUM(used_page_count) AS used_pages + FROM sys.dm_db_partition_stats AS p + LEFT JOIN sys.internal_tables AS it ON p.[object_id] = it.[object_id] + WHERE it.internal_type IN (202, 204, 211, 212, 213, 214, 215, 216) + GROUP BY p.[object_id] + ) + SELECT --TOP(50) + p.[object_id] + , OBJECT_SCHEMA_NAME(p.[object_id]) AS ShemaName + , OBJECT_NAME(p.[object_id]) AS TableName + , QUOTENAME(OBJECT_SCHEMA_NAME(p.[object_id])) + N'.' + QUOTENAME(OBJECT_NAME(p.[object_id])) AS FullTableName + , p.NumberOfRows + , (p.reserved_pages + ISNULL(e.reserved_pages, 0)) * 8 AS ReservedKb + , p.pages * 8 AS DataKb + , p.IndexCount + , CASE WHEN p.IndexCount <> 0 AND p.used_pages + ISNULL(e.used_pages, 0) >= p.pages + THEN p.used_pages + ISNULL(e.used_pages, 0) - p.pages + ELSE 0 + END * 8 AS IndexAllKb + , CASE WHEN p.reserved_pages + ISNULL(e.reserved_pages, 0) > p.used_pages + ISNULL(e.used_pages, 0) + THEN p.reserved_pages + ISNULL(e.reserved_pages, 0) - p.used_pages + ISNULL(e.used_pages, 0) + ELSE 0 + END * 8 AS UnusedKb + FROM TablePages AS p + LEFT JOIN ExtraData AS e ON p.[object_id] = e.[object_id] + WHERE OBJECT_SCHEMA_NAME(p.[object_id]) <> 'sys' AND p.pages > 0 + ORDER BY DataKb ASC; + " + ) + +# GRANT VIEW DATABASE STATE TO asp_niigaz; + +for (n in listTables$FullTableName) { + tryCatch({ + loginfo(msg = paste0("Start reading: ", n)) + + dt <- rodbcSQLQeuryToDF( + connectionString = connectionString, + sqlQuery = + paste0("SELECT * FROM ", n, ";") + ) + + loginfo(msg = paste0("End reading: ", n)) + + fwrite(x = dt, file = paste0(outputFolder, n, ".csv")) + + }, + error = function(e) + logerror(paste(e, + n, + sep = "\t"), logger = loggerName), + finally = next) + +} + + +# Remove password, connection string and latest largest data.table object #### +rm(dt, pass, connectionString) +gc() + + +# Compare number of files with number of tables #### +csvFiles <- as.data.table(list.files(path = outputFolder, pattern = "*.csv")) +setnames(csvFiles, c("V1"), c("FullTableName")) +csvFiles[, FullTableName := gsub(".csv", "", FullTableName)] + +print("List of tables not exported from SQL Server:") +print(fsetdiff(listTables[, "FullTableName"], csvFiles)) + +loginfo(msg = "End", logger = loggerName) diff --git a/Scripts/tempdb_usage.sql b/Scripts/tempdb_usage.sql new file mode 100644 index 00000000..2f53716a --- /dev/null +++ b/Scripts/tempdb_usage.sql @@ -0,0 +1,64 @@ +SET nocount ON; + +--INSERT INTO msdb.dbo.tempdb_log_usage_v2 +SELECT GETDATE() AS 'collection_time', + p.*, + t.* +FROM (SELECT ss.session_id AS 'ss_session_id', + ss.login_time, + ss.host_name, + ss.program_name, + ss.client_interface_name, + ss.login_name, + ss.status AS 'session_status', + ss.last_request_start_time, + ss.last_request_end_time, + er.start_time, + er.status AS 'request_status', + er.command, + qt.text AS 'parent_query', + Substring (qt.text, er.statement_start_offset / 2, ( + CASE + WHEN er.statement_end_offset = -1 THEN + Len(CONVERT(NVARCHAR(max), qt.text)) * + 2 + ELSE er.statement_end_offset + END - er.statement_start_offset ) / 2) AS 'individual_query', + er.sql_handle, + er.plan_handle, + er.database_id AS 'er_database_id', + er.open_transaction_count, + er.transaction_id AS 'er_transaction_id', + er.total_elapsed_time / 1000 AS'running_time_sec', + er.reads, + er.writes, + er.logical_reads + FROM sys.dm_exec_sessions AS ss + LEFT JOIN sys.dm_exec_requests AS er + ON ss.session_id = er.session_id + CROSS apply sys.dm_exec_sql_text(er.sql_handle)AS qt + WHERE ss.status = 'running') AS p + INNER JOIN (SELECT st.session_id, + st.transaction_id AS 'dbt_transaction_id', + dbt.database_id, + dbt.database_transaction_begin_time, + dbt.database_transaction_log_record_count, + dbt.database_transaction_log_bytes_used, + dbt.database_transaction_log_bytes_reserved, + dbs.log_reuse_wait_desc, + (SELECT cntr_value / 1024 AS 'log_usage_mb' + FROM sys.dm_os_performance_counters + WHERE object_name LIKE'%:Databases%' + AND counter_name = 'Log File(s) Used Size (KB)' + AND instance_name = 'tempdb') AS 'tempdb_log_usage_mb' + FROM sys.dm_tran_database_transactions AS dbt + INNER JOIN sys.dm_tran_session_transactions AS st + ON dbt.transaction_id = st.transaction_id + INNER JOIN sys.databases AS dbs WITH (nolock) + ON dbt.database_id = dbs.database_id + WHERE dbt.database_id = 2 + AND dbt.database_transaction_log_bytes_reserved > 0) AS t + ON p.ss_session_id = t.session_id + AND p.er_transaction_id = t.dbt_transaction_id +WHERE p.ss_session_id <> @@SPID +OPTION (recompile); diff --git a/Solution/README.md b/Solution/README.md index 91913662..7f1a11be 100644 --- a/Solution/README.md +++ b/Solution/README.md @@ -3,5 +3,4 @@ - [dbWarden](/Solution/dbWarden) a free SQL Server Monitoring Package (by Stevie Rounds and Michael Rounds) - [Base line Collector script](/Solution/BaselineCollector) (by Robert Virag) - [Ola Maintenance Solution](/Solution/Ola_Maintenance_Solution) (by Ola Hallengren) - - [SQLQueryStress](/Solution/SQLQueryStress) (by Adam Machanic) - [SysJobHistory](/Solution/SysJobHistory) (by David Wentzel) diff --git a/Solution/SQLQueryStress/.gitignore b/Solution/SQLQueryStress/.gitignore deleted file mode 100644 index 57a1574c..00000000 --- a/Solution/SQLQueryStress/.gitignore +++ /dev/null @@ -1,196 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -build/ -bld/ -[Bb]in/ -[Oo]bj/ - -# Visual Studo 2015 cache/options directory -.vs/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding addin-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -_NCrunch_* -.*crunch*.local.xml - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# TODO: Comment the next line if you want to checkin your web deploy settings -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/packages/* -# except build/, which is used as an MSBuild target. -!**/packages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/packages/repositories.config - -# Windows Azure Build Output -csx/ -*.build.csdef - -# Windows Store app package directory -AppPackages/ - -# Others -*.[Cc]ache -ClientBin/ -[Ss]tyle[Cc]op.* -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.pfx -*.publishsettings -node_modules/ -bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -*.mdf -*.ldf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings - -# Microsoft Fakes -FakesAssemblies/ - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt diff --git a/Solution/SQLQueryStress/CONTRIBUTING.md b/Solution/SQLQueryStress/CONTRIBUTING.md deleted file mode 100644 index 92a947de..00000000 --- a/Solution/SQLQueryStress/CONTRIBUTING.md +++ /dev/null @@ -1,24 +0,0 @@ -## Contributing Issues - -### Before Submitting an Issue -First, please do a search in open issues to see if the issue or feature request has already been filed. If there is an issue add your comments to this issue. - - -## Writing Good Bug Reports and Feature Requests - -The more information you can provide, the more likely someone will be successful reproducing the issue and finding a fix. Whenever possible: - -* Provide reproducable steps, what the result of the steps was, an what you would have expected. -* Screen shots of the issue/input/any error messages -* Description of what you expect to happen -* Animated GIFs -* Code that demonstrates the issue - -## Contributing Code - -The general development process is: - -1. Fork this repo and clone it to your workstation. -2. Create a feature branch for your change. -3. Write code and tests. -4. Push your feature branch to github and open a pull request against master. diff --git a/Solution/SQLQueryStress/README.md b/Solution/SQLQueryStress/README.md deleted file mode 100644 index 0212f793..00000000 --- a/Solution/SQLQueryStress/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# SqlQueryStress -SQL query stress simulator created by Adam Machanic http://sqlblog.com/blogs/adam_machanic/archive/2016/01/04/sqlquerystress-the-source-code.aspx - -The goal of this tool was to enable the user to test a single query under some form of load -- up to 200 simultaneous threads. - -## Contributing - -Any and all contributions are welcome! Please see the full [contributing guide](CONTRIBUTING.md) for more details. diff --git a/Solution/SQLQueryStress/src/SQLQueryStress.sln b/Solution/SQLQueryStress/src/SQLQueryStress.sln deleted file mode 100644 index 6bf56fc0..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress.sln +++ /dev/null @@ -1,22 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQLQueryStress", "SQLQueryStress\SQLQueryStress.csproj", "{02A166A4-EE64-432F-AA6E-08C7984BD7BC}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {02A166A4-EE64-432F-AA6E-08C7984BD7BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {02A166A4-EE64-432F-AA6E-08C7984BD7BC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {02A166A4-EE64-432F-AA6E-08C7984BD7BC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {02A166A4-EE64-432F-AA6E-08C7984BD7BC}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/AboutBox.Designer.cs b/Solution/SQLQueryStress/src/SQLQueryStress/AboutBox.Designer.cs deleted file mode 100644 index 4daa5c34..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/AboutBox.Designer.cs +++ /dev/null @@ -1,193 +0,0 @@ -namespace SQLQueryStress -{ - partial class AboutBox - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AboutBox)); - this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); - this.logoPictureBox = new System.Windows.Forms.PictureBox(); - this.labelProductName = new System.Windows.Forms.Label(); - this.labelVersion = new System.Windows.Forms.Label(); - this.labelCopyright = new System.Windows.Forms.Label(); - this.labelCompanyName = new System.Windows.Forms.Label(); - this.textBoxDescription = new System.Windows.Forms.TextBox(); - this.okButton = new System.Windows.Forms.Button(); - this.tableLayoutPanel.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.logoPictureBox)).BeginInit(); - this.SuspendLayout(); - // - // tableLayoutPanel - // - this.tableLayoutPanel.ColumnCount = 2; - this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33F)); - this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 67F)); - this.tableLayoutPanel.Controls.Add(this.logoPictureBox, 0, 0); - this.tableLayoutPanel.Controls.Add(this.labelProductName, 1, 0); - this.tableLayoutPanel.Controls.Add(this.labelVersion, 1, 1); - this.tableLayoutPanel.Controls.Add(this.labelCopyright, 1, 2); - this.tableLayoutPanel.Controls.Add(this.labelCompanyName, 1, 3); - this.tableLayoutPanel.Controls.Add(this.textBoxDescription, 1, 4); - this.tableLayoutPanel.Controls.Add(this.okButton, 1, 5); - this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel.Location = new System.Drawing.Point(9, 9); - this.tableLayoutPanel.Name = "tableLayoutPanel"; - this.tableLayoutPanel.RowCount = 6; - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); - this.tableLayoutPanel.Size = new System.Drawing.Size(417, 265); - this.tableLayoutPanel.TabIndex = 0; - // - // logoPictureBox - // - this.logoPictureBox.Dock = System.Windows.Forms.DockStyle.Fill; - this.logoPictureBox.Image = ((System.Drawing.Image)(resources.GetObject("logoPictureBox.Image"))); - this.logoPictureBox.Location = new System.Drawing.Point(3, 3); - this.logoPictureBox.Name = "logoPictureBox"; - this.tableLayoutPanel.SetRowSpan(this.logoPictureBox, 6); - this.logoPictureBox.Size = new System.Drawing.Size(131, 259); - this.logoPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; - this.logoPictureBox.TabIndex = 12; - this.logoPictureBox.TabStop = false; - // - // labelProductName - // - this.labelProductName.Dock = System.Windows.Forms.DockStyle.Fill; - this.labelProductName.Location = new System.Drawing.Point(143, 0); - this.labelProductName.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0); - this.labelProductName.MaximumSize = new System.Drawing.Size(0, 17); - this.labelProductName.Name = "labelProductName"; - this.labelProductName.Size = new System.Drawing.Size(271, 17); - this.labelProductName.TabIndex = 19; - this.labelProductName.Text = "SQLQueryStress"; - this.labelProductName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // labelVersion - // - this.labelVersion.Dock = System.Windows.Forms.DockStyle.Fill; - this.labelVersion.Location = new System.Drawing.Point(143, 26); - this.labelVersion.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0); - this.labelVersion.MaximumSize = new System.Drawing.Size(0, 17); - this.labelVersion.Name = "labelVersion"; - this.labelVersion.Size = new System.Drawing.Size(271, 17); - this.labelVersion.TabIndex = 0; - this.labelVersion.Text = "Version 0.0.1"; - this.labelVersion.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // labelCopyright - // - this.labelCopyright.Dock = System.Windows.Forms.DockStyle.Fill; - this.labelCopyright.Location = new System.Drawing.Point(143, 52); - this.labelCopyright.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0); - this.labelCopyright.MaximumSize = new System.Drawing.Size(0, 17); - this.labelCopyright.Name = "labelCopyright"; - this.labelCopyright.Size = new System.Drawing.Size(271, 17); - this.labelCopyright.TabIndex = 21; - this.labelCopyright.Text = "Copyright Adam Machanic 2006"; - this.labelCopyright.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // labelCompanyName - // - this.labelCompanyName.Dock = System.Windows.Forms.DockStyle.Fill; - this.labelCompanyName.Location = new System.Drawing.Point(143, 78); - this.labelCompanyName.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0); - this.labelCompanyName.MaximumSize = new System.Drawing.Size(0, 17); - this.labelCompanyName.Name = "labelCompanyName"; - this.labelCompanyName.Size = new System.Drawing.Size(271, 17); - this.labelCompanyName.TabIndex = 22; - this.labelCompanyName.Text = "Company Name"; - this.labelCompanyName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // textBoxDescription - // - this.textBoxDescription.Cursor = System.Windows.Forms.Cursors.Hand; - this.textBoxDescription.Dock = System.Windows.Forms.DockStyle.Fill; - this.textBoxDescription.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.textBoxDescription.ForeColor = System.Drawing.SystemColors.ActiveCaption; - this.textBoxDescription.Location = new System.Drawing.Point(143, 107); - this.textBoxDescription.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3); - this.textBoxDescription.Multiline = true; - this.textBoxDescription.Name = "textBoxDescription"; - this.textBoxDescription.ReadOnly = true; - this.textBoxDescription.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.textBoxDescription.Size = new System.Drawing.Size(271, 126); - this.textBoxDescription.TabIndex = 23; - this.textBoxDescription.TabStop = false; - this.textBoxDescription.Text = "Please visit http://www.datamanipulation.net/SQLQueryStress for documentation and" + - " updates!"; - this.textBoxDescription.Click += new System.EventHandler(this.textBoxDescription_Click); - // - // okButton - // - this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.okButton.Location = new System.Drawing.Point(339, 239); - this.okButton.Name = "okButton"; - this.okButton.Size = new System.Drawing.Size(75, 23); - this.okButton.TabIndex = 24; - this.okButton.Text = "&OK"; - this.okButton.Click += new System.EventHandler(this.okButton_Click); - // - // AboutBox - // - this.AcceptButton = this.okButton; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.okButton; - this.ClientSize = new System.Drawing.Size(435, 283); - this.Controls.Add(this.tableLayoutPanel); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "AboutBox"; - this.Padding = new System.Windows.Forms.Padding(9); - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "AboutBox"; - this.tableLayoutPanel.ResumeLayout(false); - this.tableLayoutPanel.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.logoPictureBox)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel; - private System.Windows.Forms.PictureBox logoPictureBox; - private System.Windows.Forms.Label labelProductName; - private System.Windows.Forms.Label labelVersion; - private System.Windows.Forms.Label labelCopyright; - private System.Windows.Forms.Label labelCompanyName; - private System.Windows.Forms.TextBox textBoxDescription; - private System.Windows.Forms.Button okButton; - } -} diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/AboutBox.cs b/Solution/SQLQueryStress/src/SQLQueryStress/AboutBox.cs deleted file mode 100644 index 149902fa..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/AboutBox.cs +++ /dev/null @@ -1,164 +0,0 @@ -#region - -using System; -using System.Diagnostics; -using System.IO; -using System.Reflection; -using System.Windows.Forms; - -#endregion - -namespace SQLQueryStress -{ - internal partial class AboutBox : Form - { - public AboutBox() - { - InitializeComponent(); - - // Initialize the AboutBox to display the product information from the assembly information. - // Change assembly information settings for your application through either: - // - Project->Properties->Application->Assembly Information - // - AssemblyInfo.cs - Text = string.Format("About {0}", AssemblyTitle); - labelProductName.Text = AssemblyProduct; - labelVersion.Text = string.Format("Version {0}", AssemblyVersion); - labelCopyright.Text = AssemblyCopyright; - labelCompanyName.Text = AssemblyCompany; - /*this.textBoxDescription.Text = //AssemblyDescription; - @"SQL Server Query Load Test Tool - -- Enter the query or batch to be tested in the Query textbox -- The query will be run concurrently by the number of threads specified in the Number of Threads textbox -- Each thread will run the query as many times as specified in the Number of Iterations textbox -- Parameter Substitution allows you to dynamically replace variables in your query with values taken from another query. For instance, you can define the following batch: - -SELECT * -FROM sys.databases -WHERE [name] = @db_name - -If you then go into the Parameter Substitution window, you can enter the following query into the Parameter Query textbox: - -SELECT [name] -FROM sys.databases - -Click the Get Columns button and use the grid to assign the @db_name parameter to the 'name' column. During the test, the values used for @db_name will be taken from the 'name' column. If there are more iterations than unique values, the tool will loop back to the beginning of the list and will keep looping until the test is complete. - -- Once queries and optional parameterization are complete, use the GO button to start the test. The following information is reported by the tool: - -. Elapsed Time: The amount of time spent, starting the moment the GO button is clicked and ending the moment the test stops -. Iterations Completed: The number of times the query has been executed, aggregated for all threads -. Client Seconds/Iteration (Avg): The average amount of time the client waited for each execution of the query being tested. This timing is taken on the client. -. Total Exceptions: The number of exceptions that occurred. Click on the ellipsis button to see the messages of the actual exceptions. -. CPU Seconds/Iteration (Avg): The average number of seconds of CPU time spent processing the batch, as reported by SQL Server. This number includes both processing and execution time. -. Actual Seconds/Iteration (Avg): The average number of seconds elapsed for execution of the batch, as reported by SQL Server. This number includes both processing and execution time. -. Logical Reads/Iteration (Avg): The average number of logical reads required by the batch, as reported by SQL Server. - -To stop testing, click the Cancel button. Note that cancellation of a test may take some time if several threads are being used, as the test will not be stopped until all threads have successfully been aborted. The UI may continue to update while the test is being cancelled, as additional data is collected. - -Settings for a test, including the query, database information, and parameter assignments, can be saved and re-loaded using the File menu. Keep in mind that all database information is persisted -- do not save sensitive database passwords!"; - */ - } - - public sealed override string Text - { - get { return base.Text; } - set { base.Text = value; } - } - - private void okButton_Click(object sender, EventArgs e) - { - Dispose(); - } - - private void textBoxDescription_Click(object sender, EventArgs e) - { - Process.Start("https://github.com/ErikEJ/SqlQueryStress"); - } - - #region Assembly Attribute Accessors - - public string AssemblyTitle - { - get - { - // Get all Title attributes on this assembly - var attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof (AssemblyTitleAttribute), false); - // If there is at least one Title attribute - if (attributes.Length > 0) - { - // Select the first one - var titleAttribute = (AssemblyTitleAttribute) attributes[0]; - // If it is not an empty string, return it - if (titleAttribute.Title != "") - return titleAttribute.Title; - } - // If there was no Title attribute, or if the Title attribute was the empty string, return the .exe name - return Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase); - } - } - - public string AssemblyVersion - { - get { return Assembly.GetExecutingAssembly().GetName().Version.ToString(); } - } - - public string AssemblyDescription - { - get - { - // Get all Description attributes on this assembly - var attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof (AssemblyDescriptionAttribute), false); - // If there aren't any Description attributes, return an empty string - if (attributes.Length == 0) - return ""; - // If there is a Description attribute, return its value - return ((AssemblyDescriptionAttribute) attributes[0]).Description; - } - } - - public string AssemblyProduct - { - get - { - // Get all Product attributes on this assembly - var attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof (AssemblyProductAttribute), false); - // If there aren't any Product attributes, return an empty string - if (attributes.Length == 0) - return ""; - // If there is a Product attribute, return its value - return ((AssemblyProductAttribute) attributes[0]).Product; - } - } - - public string AssemblyCopyright - { - get - { - // Get all Copyright attributes on this assembly - var attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof (AssemblyCopyrightAttribute), false); - // If there aren't any Copyright attributes, return an empty string - if (attributes.Length == 0) - return ""; - // If there is a Copyright attribute, return its value - return ((AssemblyCopyrightAttribute) attributes[0]).Copyright; - } - } - - public string AssemblyCompany - { - get - { - // Get all Company attributes on this assembly - var attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof (AssemblyCompanyAttribute), false); - // If there aren't any Company attributes, return an empty string - if (attributes.Length == 0) - return ""; - // If there is a Company attribute, return its value - return ((AssemblyCompanyAttribute) attributes[0]).Company; - } - } - - #endregion - } -} \ No newline at end of file diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/AboutBox.resx b/Solution/SQLQueryStress/src/SQLQueryStress/AboutBox.resx deleted file mode 100644 index 6dd25dcb..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/AboutBox.resx +++ /dev/null @@ -1,610 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - - iVBORw0KGgoAAAANSUhEUgAAAHgAAAEGCAIAAAAhWcaAAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAcQNJREFUeF7tfQdc - lFfa/ez/K/tlExUVmN7ovQ1D74Kg2BWs2CvYEVEEG0VALHTpAip2xd57jzHGmF5MsokxdbPV/XY13//c - 9xleX2YAMTGJZnfy/PiNiATOnDn3POXe+xtZpew3v/mNCP/9v9/85j9+g4+i/xDhyf/7z//HnvzXb0T/ - yf7InuOvfiNij/8TiR6KRN+L/u/h/7EnDwTPv2fP2Sf/T/T9599///r3D28/nDFsRp8+fezt7f8f98D/ - zuiBb8l+hl/3A0DLK+WKKoWyWqmsUapqVeqNanW9WrNJo23SardptTu1VnusrA9YWx+2tj5qbXPCxuYU - Fydt8Nz6GPd5/G2ztdUuK6vtVlZbray2WFk1WllttLKqs9LkalSjVXJ3eW5u7htvvPHnP//5r3/96/37 - 9//3f//3H//4xz//+c8HDx48fPjwe+7xf7/ehwgoy6sMQKtqVAzoWrWmTqOp12gbtNpGrdVmDrhtVlY7 - raz3Wlvvs7Y+aG19xJpBzEcL1ta7ra12tMJaW6vV1mjV2WrlcKXMSVZSUvLJJ5/8C8LNgCY6M5RrWlCu - 02g3alnUa60aOHpusmKIN7UgvodDHEQ+xIGOANZ4AfDJvdZ4SYS8ZlhXa7VVWvVStXKQUmYl27x58x// - +Md/KbhFQFlRbQAaXFbXMTo/QrneyooPHnEQHPpAHOcRB8oIQE9YQ0bwBS0aYsC6Uqut0KrmqxSRiqSk - pBMnTvBw//3vf/91i4lIUalQVilV1RydazjR2GgA+hHERnAbIQ5d3sWpSjOHMgVhjb/CmwDvho1WBqwr - tNoNWm2JVjVFJfeRr1q16t133xXCDeE20u5fh26LFGUKRQXDmqFcq0Fo67QsNmrbBtqU4CQp4PgOK2i0 - AXGADugh2bQ8GmFdrtWWaTWZGuUwpcxW1tTU9Ic//AFw/+Uvf/nb3/4Gdv/61kmRYo1CuV6pKlWpylXq - SrWmWqOpYVgzzyAMIakfS3BICiEOYeGXR7we9QJel2m1pRy156oUYYrFixffuHEDcP/pT39qz5Y819QW - KXIVijyFMk+pWqNSF6o1pRpNuUYLMa1ibgH+rFOIQ0xMFRz2A5ICoKEhvBVpaI11iVZbrNXkaZQjmSdp - bGz85ptvvvvuO4JbKNzPuwUUKbIVyhylapVKladSr1YjNGs12vWMa0xMgTgMA2xDbec4bgQ3RAPSAROC - ANb88lhnxb4t9Bq8xv+oSKsp1KjmqRThiiVLlty+ffvbb7/llcR0kXweqS1SZCqUWUpVjgpYq3PV6jy1 - Jl+jKeACiBdyb3AB4p3iuBBukm/ATSFIZ1phXajVrNeoc9TKOKXMTrZ79+6vv/66TSV5TqktUq5QqjJV - qiwVcgr8nppVGuRyDGsebkK8iGMfONh5gpvCDUYT1rwVEfAapMb/SLNGo0pUyf3lq1ev/uyzz6Ak5Emw - SD7X1OaAXqlSZ6pZZKk1ORoWBHceB/fqFoKv0QALI0l5DMGNtJvYTcFjXdOiIRDr9Qas1UvUiliFVCa9 - dOnSV199ZUrt5y5xFwFlHmhNlsYQ2QK4TQm+joMbBG9R8CeDm/Id0hDe9pFe81hz2oUiicxRtm3bti++ - +OJ5pzYD+hGdeaDpCcHdHsGhJ8VPoidG7AbKIDVhTbYPLxuwxsIIXuPdQ1hDRvzk69evv3fvnpDapl77 - GV8hRYqpClU6w/oRnY3gxh87hru1fD+e3aicUPEEKFOYYr3uEdbqRWpFFDPab7311pdffskbEr4E+FzI - iCggIEBqJ5UHyxXDFKqZqo7gFuqJkXzz7O6MmAipTaVBfDTFGgsjmZ8CDRYP5WClVCk9f/48qA1DAq9t - tEI+425E1NDQUFRUlJKSMmLECD8/P7mnXBmrVE1WaZa26LURwTtgN2k30mvAjSUO1tso32kvpQTKFJTO - 8BoiwNog2fayffv2ff7558+djIi2b9++c+fOXdwD7rWgoGD69OlRUVFyN7myjxKlH82KthA3hbuFfcyZ - kPXujBEkC0hKgsATI702wnoy6yEggYTzwwpJMkIp+zNeihLt37//wIEDBw8ePHToEJ7gAco0NzeD5jNn - zmSIe8lRRFbNMlEVXklMrfcaY9/dKWoT4o/FeiYr+5WVlX366aeQEXIjqEaZSvYztTyKUBQ+efLkKe6B - J8ePHz927NiRI0cId4AOjk+cOFGmkSlCFaqxJpLSgXCTkoDaXNnkMUk8L9yENZVVSUOQNLaYEIMVmaeS - B8rXrFmDZk3Hkv3sYC26zD2uXLmCj8gOLly4cO7cuTNnzgB3vAY86DCzqEIMGDCAEXyYUr1A4FKMXKAw - q/wB1CYxwccOsVYvVOOFz87O/vjjj4WSLUwgn6nlUfTaa6/dunULH2/evPnqq6++8sor169fv3r1KnAH - 6FjlATqYDsSPHj0Kmq9bt27s2LEyZ5myvxIVzlYJTnuOW0ht0/qUUQGWqE3BY13Kqk6teL1ao05TKyIU - K1as+Oijj+7evQvnxyeQvMt+drAWocHxXsvj7bfffvPNN9GrBvTAHQXil19+GaCD6UD87NmzoDm0BYhX - V1djzZTZy5hFmcPBDV53RrV5Q9JBvbs9rJHI8EsungDrdDW6YkuXLr1z5w6/PPIlVn55fBZa7KLftzyg - d3gb4if+8MMPgfw777zDgw6mg+bXrl0DzXnEwXGs/rNmzWJw91Oq56kfYd0etcmQtFSmOlohQXOCG0+I - 1/hX4LUQaxRh8jXqDJbOZGRk4Cen5ZG3IsLs8RfHWgSThDcdbCme4KeE3oEaAJ9A/+CDDwA6Mf3111/n - ESeOQ1Wg45s2bUKnVeYiUw5Rqhe3lKWMsOZrgbyMtGn+2uzjcNxnyymwLtFqkDTyvOaxjlQsW7YMFMFP - zlsRah08I7wWQdeQZcEh4SOewy0BdEDPgw6mQwSJ5oQ4hIUQxxJ68eJFLJ6QlNra2smTJ8u95aoxnJII - jbZRWYrSSOQ1cCOPlWyCnpvFeYQ1b645oBmvoSERiszMTDBDiDVs3zOCtQgvO/9AUguBMwKdmE40FyIO - KccSCh2HpBDBT58+XVxcHB8fj0aJaoaqI6x5N9KmZLfHa+rLcE10VrkmXvNYY20MVeTl5QFr3vaRxX4W - sBbRD4EHyup4DtsPhwTo8fPxoEP1UF4gmhPipCpYSIWSAoKTnqxcuZIJ9yAlysqstE0ZjUmBm7VvqNb6 - WJdNpOZnFvBuQJGPN9c81ilqeYC8sLDw/ffff9awFqH0RQ+MweHRJuhgOtGcEOc5TjoOSUFdDY0+GBXS - E/hCpPUzZsxAo4SVTdrHGotbq+Wx49a7EGtKZHixJvOer4HjlOvlVVVVHWBNnu9nzmVEtBzTAz8BHm2C - TjQXIg4pB8FhYIng+MWg4KQnPNww3TJrmXKgEhraHq+fAOuWl4EpO/QdkyG8CWkhNcN6hgqFmq1btxph - LVwbf36sRUYvrBB0nulCmgNxXlWweBLB4VVgraDg0BMjuFFFgQVUBHKq3Y6GPDHWEGtK0GH4eBPCY52n - UU1UocN7+PBhHmsqifyCWBsDLcTdlOY84pByIcHxa5CCG8FNYgL3jYIJmlKqESqDWJs2JGH7hBa7PQ0R - kpo3fPzC2CIg6Hbi/4X6NXTsGcG6I6B50NtEnBZPnuCk4KQnQrih3fCCyDBRLUHuruijYF6bB1rY/O0M - 1oIXwDDMBxOCTiMtjAJS43+hHKCcO3culmve8+EnpLyRGup8a+Zn0OtOAW2KOOm4EcHJpeCX4dlN2o2l - EskOqihwgampqTAGqiSO2tSmEWLNr41GPkRo+EyxhgnhF0Ye61yNeoVa0UuRlZVlijVfe/rZsH4yoAlx - IcF5rwKOkJ4Q3CQm0G5aKskI0jqJ8qbMTaYap2JAt4c19NeoQcNjLVQVEmujhZFePHxnYL1AjeI1TAhe - bORceKthRaHaE2FNWw5+hgT9hwAtJLjQqJAZ5+GGmABu/GJwJjCC+D2xTkJJkOOgf8bcSJzyEdBCXqMk - Qv5aOIfWDqlZxkiVED6LEZCabeyYppI5yNDfwP+dak9U54OD4vsyP4MJ+VFAGxGc1xOCm8wJORPKdGBL - YLqJ2ugqjB8/HrVWvMENAiKYjTLkMlyObpiyNEoXOyPWHKkZ1lgYpVJoF2GNFx5rCXhAfRkqhvzUWD8F - oNuDm18qeeGGkiBhA7VRGgS1kdfMnj1b0VvBEkgjsaYcHeLL1Z4Y1qZ5ecdiTd+QMtJVGizC6enpWCog - Yni98ZPg5Rcavp9arJ8a0DzcJCb8Ugm4SbhJSYyoDf+HgQ3URtSpJlij9kSdMH56uAOsTZ01CUgLqfH9 - 5b7yyspKvMB4V0HKhEW+n8GEPGWghXCbKgkYBCXB25anNt7LYBm6JIoghSpZ1cZwJbCG/rZH6pYaiKEM - wjtrcnutSa2aqsLuApTRkb7y5poMn9HC+FO4vZ8EaKEz4eEmJcESBGqTasMDkCHBb45diMz2zeew5scq - ARYMHxZGXqz5bkBbJsTgrKnkRGUQntRcvUU5VIk0Fb4e64TQhPwMC+NPBbSRcJOS8Iskr9pkSGiFRPbI - ilDAGkALRlgNE8PV3DiOsPPSHtbk9ig1JwFpUWr1crUiRAF/idWYNyH8wkiFzJ9IrH9aoNtUEl61hTKC - 5A1Wl2ENXkNDhKQmseYFRNhRNMVa2B/gBYSUmiM1pibh9jC4gvYF1mSjhZEX66de3vs5gBYqCU9tkhFK - bSAjlNeAZfn5+YpgBQYbW/VhKWMkZ82T2khGhGUQ6g/w6aKA1GhHYFwCnWWkTrQwUuXaSKyfutv7mYBu - k9qU2pCMIK+B0QbWYBmmNZgPQWWVLzfD7VGXAAICQPnZD+re8u0uozoqantUb+JXRY7U6mVqrL1r165F - 6kTZOVaLnzqL+VmBJmrzJW8IolBG8KtSUoPlERMEimgFGybmsebdHjkQfn6sTax5AUG9SbgqUgsih0sX - bWQYyIK/FGYx5Kx/CgH5uYFuT0Yoh8S6xC+PycnJKL8JSW0oW1dyqyI/HUljTSa8NjgQvjnAr4oc0ExA - +ivnz5+PsiJlMbyzFrq9pyggvwDQRjJCboR3fuSy8WuDa9OmTcOZCK1I3ZIuGkhNA6hCsTZKFyHrqIEI - V8UWUrMUxkteU1OD1JycNdYJKjn9FG7vFwPaSEaEzo9cNrBGqxe1J7RLDFgDL6yKcCC0KgJffti3Lawf - FazJVpuQGntkRo8ejeYAnDU8D5Wc8Er/FALySwJtKtlUisLvyWMNHyZzl7GpM37rI+3koFWRDrfged2m - gMBWC1dFWL0W9cBmdNhq5EoQELi9n1RAfmGgO4M15vzkQXKDCeFJTbYaukGbM4yw5gWEXxWFuSJ5aih1 - tobl5RqWl8PtGQkIPxDyVFKYXx5ofnkUJutGvMYIErYdMlIDaH53KU9qfseRcGE0stVYFXmrJyR1tgb2 - BoUtoYBgQeZre8LmwI+pgTwTQJtaEdg+IdZQT0yJQFJp47Rh9wZPauHurvYcCHUGeKsnJPUsFcZ9MIhi - 5EAohXlaBetnBeiOsYYPwdAwjj9QzVYxoGlJ5KrVTKlpyyICMtIxqakAQolii3pgUhDTsHPmzMEcIRwI - 1ZtoVUT9i59QoI7XDyb1MwS0Kdb82kj+ur6+nmXnyGLQL8eSyCflEGja/Ny+WBvmQIxITZOYWRrMHGO0 - Hic9YRic6k1UA0F5gGz1j+/CPFtAt4c1mAWswTLMQaPUyYBGRs63BSAXRtueeQERrooogJS3DDeZknqg - MjExEU2fjlfFH0zqZw5o07URvEYGgTwCOTrKQMxZJ6kMQHOlaqYeEA06T4s/psIE61akJk8tUA91MiM1 - Rusx7sPbatNV8Qfnis8i0EZYU95IOToyNwzVwe3h/W7Y+M8viXQqCLCmcxNMV0Wa+gWpTZWa27SKjB+k - RpZEqyJf2KNcka9W/zBSP6NAm+aNhDWcAJJGtFlV8SoGdMvOUcOSKDx7RYi10OpRUk6JIu/zOKCZUjvI - tmzZgkEfKuyZ5oo/uF/+7AItxJrqIVRTxQIFbwBE8GZnQHM7B1iZCchyJ5UZzl5p04EQqYWeGvaDy1xo - exn2PmGKDHsYMF0vzBWFBZAfZj+eaaCNsKaaKrDGwoh0EXuEHm09p9IHAY3zm/jz9tpTaiqfUkeRlJoD - GscO4KDJPXv2mFo9vgDyw0j9rAPNY02tGeHCiNoeysqM0ZBpjCSg0AHvwZ12yLDmD8oywtqU1AKggTXG - 9dLS0mDbyerxBZAfSernAGgjrHmxxqwTmrlgJe2nM3gPOlaSP2yvPaXGP6HqB+/zWtQDWxRwCDP2sMLq - GeUvP4bUzwfQhDUVQ3ixRjkC1FMlqOjEISbTSAuhHnR+Jx0iSYejtklqlPRQOTFZEkFqvH5oXT5dUj9P - QFMPjBpgqIQgi4HnlXvIkSsaJsdIpun4ZToclU7rbFOpN7ROXlpkmin1CNXIkSOfLqmfG6DbE2t0ctGF - eQQ0J9OG81GBNU/q1qVqw7Av+TwT9UAPHskLdk4SqU3txw/w1M8T0EKsKYuBaGK9QrFJvVJtmEQgoOmw - ZQQEpD1SY34MyQtfO229JCr7Mp8HUsN+8J6aTxSF1Y9OlpmeM6B5sRYKCPRUGa80AM3l4uwIWqC8nxOQ - DkgNcRcuiUL1mMYmfXG8AHlqPlGkpiL1BJ7I5z2XQPPTqnB7SBfx1sY7HV6YOTxKW7Ae0hH5wLo9UpPP - w5JIWSIVTlu8B1sSfdlpkth9TYkiNRWNSnqdT16eP6CNBIRSGCg12gKGdi0BjQOs6ZB23PJApDapfjCl - xpLIlz5aA40y4bhx49DlouoH6lnUKUdti+rU1HzpZJnpuQTaVEBQ24T90K7lrn4g40FA0y0PROo2fR5a - t3yWSOl4y6lo2ISLdiI6L9jjDntDozaoU/PzY9R86SSpn2OgeQGhFIZ56ikqQ2GaHB7drgGs93Gkxmtg - SmosiSh98OohAJpliYHsxAScBQNSU52ab74YJS+PXRKfV6BNSY2TQzCJypZE3koD6KPcHSZ4AlKjfMod - QSac1aONRoatzlShFsg0aoSjRo3C5BhOEjDNyJ9oSXy+gTZaFXFgiCpFZQz0cY7XUGpUP0yTF1oSeUPd - 2uSxwqlGhqMBTX2esMvVGfV4joE2XRXR9EOblc5gZ9IBdT7GrkKyBtYHudth2lsSST0oc2mtHkjHoR5Y - EuHz+CWRpk+fSD2eb6CBNZ+XY2nC749GF7yaodxBQOOqqVM2TEPgqWlJbFM9KHOhqqnglFB4D+ysxv59 - 4ZJIE5HoQnS+8/LcA01zwHyxCexD+c1wZwakGUDjWq8z3LVeB7gl0bTLRerBZy5GMj2TZS7YD4olkVq3 - 1HkxyhIfqx7PPdDCVRGkBu8wZG69jbt9hwf6HMOaKTWWxDbVA96DMpc21cNTjoNHkCWi9MFniW0a6g68 - x68EaCGpUXjD9OIjoE/b2JznAqSGz2tPPZC5UNXURKZxGC6OacXhipQlokcuNNS8enScufwagDYiNY6v - RZGaJd+4MA3ScdrG9ryt/Xl7RupDLephtLMc6lHJHRbZlkzjfIB+/fqhz8Aban6aiUb0qMbUsXqwo34e - a7af/S8QKjXe3ShTMOOBVAVAn7GxO2/ndMEJcDNP3Z56GJk8gZvGyLpMy7rjP0Y9fiVAE6mprwh+IcuA - S2OifJwBDTq7XnQF1mB3R+rBm7zW6yEVmHJyckg9aMLmSdVDBGV59gnbmZ+QSE3lU6xd2CdAJtrmnA0g - 9rjk4X7RnZGa1ENo8gSncrYr0/2U6AWTeph6D34+rwP1YED/OtSDPDX5PJQmMA7JLm6FieaA9rzk6X3Z - 2/mCs0E92qx7VAlkunXaoprAOrbYfiBUDxTzTDOX9sBk5979aoCmBi5NJfTt2xclUGgF/AZ0Ayj7XfED - 3GxJRDrenskT5uKCtEWdopaqpDgWijIXTK2js4MtkZS5UCuAr5q2+f4TUUW1M+/NZ/9rhEsiinlAh1ZC - t4tuvld8g64GAWvoNUvHjUwerx5CmW59iwSumcAOaqgHqldQD9NWAFVN21MIUQd/9+wja/oT8qQG+5A9 - QzeALATa/6p/2MthoddCATrUgw00mcg0OzUIbprSFpP1EIM18+bNw1n81AowrZp2bPIY0L8y9aAlEe9r - tAJsDjOB9rrkBTr3ut4r8nokqM28xx5rVp42OaeJuWkUPdpKW1RxKtygApnmq6ZooWHi1DRFbFOKRU/U - j3kuOM4viUOGDLEtt4VA6y/rweU+1/v0e6UfnjDvgRSxTZmGm6at+ib5IcbPwsLCMJbHmzz0XIxkmu/Y - mgIleqJ+zHMBNK8emO61WWRDugE6D7gxYMirQ6KvRwN6ZvIg08KGCy/TtB6ijNfaeOBcRKyHuB6XN3k0 - MCbs2HYg0+z86I6Xy+cCXOEPyRtqgKIdoYXfgG4AX6A8/LXhg24MgnowmW7PTXewHrqx69F+mEyLOlkT - eb7gJvWAMVD5qwAr5KLvK33jbsYl3EoA1vgjZJoNjD12PWxtPODNYWaEMk3zHiTTwj6AqUyL+JoIfrJf - maHGG1kql/ru9o14OQK6MfrW6Em3J417fRzEGp6P9QG4m9CM+wBYD1HGI+PRGmi0b9At27t3Ly/TnXfT - Ijpn71e2JPIyjeaIvkQPZIfdHDbh9oTENxOnvzl96KtDmclDHwDrocm5hWgCMONBhWlBaYkNP45WDR48 - GDeKkZumaTHTokebqYmImoy/viWR1GP58uVeaV6g86hbo6a9OW3+2/MRY18fy2T6cDvrIZoAMB7k8IyA - nq4KCQnB7W1ouPBumm+4CJE0TVtEP2zu5tmXbCrm4RBUt3FuoPP418fPfmv24ncXp72XBlKHvxyOehPr - i3dgPEwcHu6NcnV13bFjB2Sab9di2AOHBfHnT7SXtoh+2NzNcwE0EjG0rh16O4DOU96YkvJOyor3V2R+ - kJn8djIMNbJzlh+2CTS1tUwcHho3aP7iLJX20hZ+PTTNAUWoPwmPAun8MNkzjjWZPBR9tG7acTfHzXxz - Jric+2FuwZ2CjPcy4ECwHrZtPHA3Bjk8U6BRmHZjt84ZrYfY54KjxvhBU1rwjJyFqM1hsl9HmYlkGteO - JhxPAIvB5fUfrS/9uDT3Tu7E2xNZ2gLjYeTwKG3hKx6tcxbadYGDtbAe4u4CmqqhJgBfxiO7bLoeivjD - yH7MTphnk90k04MGDUrYlpD+Xjq4XPn7ytrPaks+Lpn15izk5SwRN3J4BDSGxPjSkpGVjlBgQB3roTA/ - 5Cd66eQJ2g9gRFYR706Ei+avQ0DI5OEswZFlI3M+zCn7pGzT3U3b722v+6wu7d00pC0sEW/T4cFKtwM0 - WWmMmArzQ+GkB2/hjIGmRZM6BeSpf8AGjWeW0QAa7/S47Lh1H60Dvrvu7Trw5YEd93YAdyTlaMG0a6Xb - y1nilMOHDyfjQd0WzIl1xniI+BP2nu7xFM8I9KBVSUnJwAUDK35fsfXzrYe/Onzym5MHvzxY+FHh4FcH - M4eH0lIHOYtJcohBBoweYOyRNx40UkNtLd5WmBafRXREp/DUt18TqQE0Skt9J/et/6x+35f7Tn97+vJ3 - l/Gx5tMaZOSs4tEm0LXcIG9bWTjmzXr16gWgYTz4tlZnCtPsztmf4niKZ4TRkGnU6SPiIyAXx78+DpQp - wO7Jtyej/8JyFpOD1jE0zYZp2gQ6SYUr69G+ERamaSdzxw5PhD7YT3po0y+LOIBGIzWwTyDk4uIfLvJA - g90wHuhysWJpW0CzmUdk4SbSoZ6r9vLywpkhvMOjIbE2G7VCKy1Sqdzw+gg3Pf+aVkX8qrAE3kHeJBp8 - QKlT30nF9AFLDk2vDkDzsD2gF6pdXFwIaGGj9rGlJZGr63SUuPCyGB3aROXTZ62qB+Ae+zBqAiCVcPVy - FaKM52D38veXY6SGTae3CTT6LFRXau2jcXWznZ0dgG7TSguHpo1yFlFQUKODQxxuVjI6uPonOgtViALe - OlhGMPuDsTZMJuLSWNwWglcdKQYWHH9/f3d3d3t7e41Go1QqZdwDT/BHfBJ/hS+IiIgYOHAg/glO7oeN - Q/sDF+Ci3AMrhd8ZKyEe+L/YOdpd+sMlYQBrpOMY82BZeFuXYbDNFm0BrVmq0Wq1WGDbrOHxzo3vafG/ - L4De5OdXaGPTCyk87cUVnvr2tI6NxPeBB4IlwvWZOEw4Li4OMLk5OfYODUoYMmD+5HE5C+ZsyFq6rajg - aF355R2Ntw/tunP64L3LJ//4yvn7r1/9x5vXH779CgJP8Ed8En+FL7jd3HS5ofxoce62zEUbkqdnTx41 - L67fmMjg3t4ebnbWSL7xP8LEbY+ePfI25TVcaDjxyYmL31xk8e3FNR+u0V/UM0bzJ4kJdgK0C/QKjUql - AtDt5SxGxdJWQANrnW65Wu2FoiK1DExPvufvlOrk4oZWJN4i4BcOUIPDt7HSRoUETRsVvypl7ua1ueea - agHTP958+ft3bvzYuH3p+1dOPbx08OHpnQ+PbX64v+bhzpKHm1f/vXr5B7mzz6aMbZwwYG6A0/hgt1AX - rUohjhgUMW7BuKUblqY0p+hP6bXbufMnEEZXcGHzYZuMztTI5XIAbVosBUFpG0CbySEYvZmLTR4e8xQK - Wwh8myffd+aEPbyYGJcCZ6dMmWKt1faLjFgwZUJl9vIzm2s/u3DsxwLawUvy1svf3zz3/bVjD883Pzy+ - 9eHB2oe7GNYPalc+qEh7UJx8d1H8/VXj72eO/nDBgKMTwksG6mcFO0Y4y83Ev+0S2aXnqJ7ShVJVsYqu - dGYb6Gqt2C5PsneZXAiUGgoGrTNNDoVbEPmqtJDRTUFBWwhuF5fJuL8K8078NSWPPfkeSxPc4YYNGzBs - 6exgP3JAP3B2X2Xxh6cO/oTImoL+9vXvb138/vqJhxcPMGofrn+4p/zh1rUP6nMeVC29u2zc/TXTOKxH - 3V867G9LBv4tNfZP8yOujnOtitXM9RNH2He1sPzvLmFdzMeayzJkOA0LPlqdp1ZnqzUrW7AmxFGS5oCm - 5JCfeQQ72yz/PwI6OHhrUNAjrB0dR2FFavPke+E1JVgq8f/Azhz8X/tHRiyfk7i3fP1HZw7/rOAawf3m - te9fO9+C9Q6GdXPFwx1FDzfl381Nul82//66xPt5k+5nj7m/LP5v6YP/lNL73hzfuzM8705xvTvJ6XK8 - bWmUYqrOXG/14n+a/Uf3vt3FE8XKJezONBYrWTDQVzLpgCTCE1MWThtb2gOat9IiAC3Aeou/f5W9/WAc - 88uffE8rKRVRQXB8d7TcHexsxw0bVLpiybXdm39JcAlrQAw6v3oWKH9/5cjDC/sNen2g9mHzhgfbCz9f - l3K/Jv3+hpT7hbPvF0xl1F458i/pA+8lh9yd5XN3Oof1RMdPJjjcGe/w/lj7plj1Qj/LSNuu3Xv+d7eQ - bpajLZWLlLgshyG+VI3FEAc+Amg+C8emWqNyh2lDC0BvE2DNqO3nV2JnF4v7q1CUotMMgTXakVjW7Gxt - xg8bUpm97PWDux68xZzAT44yFkzG05MGBM/ueXh6x8MTWx8e28Li6KaHRxsfHmlg/EUc2vjwYN1Dhm/V - w70bHu4qfbij+J9Na+6tT7m/cfn9qsX3y5PvF81mMpI74S8rR3yRFnUXWM/2vztDd3eKG3jNsB7n8G6C - /dtj7N8cZbc7VrPYTxxl07V79/82CzcTjxfDR8Nf4jharIfIWfi5Ayp3dFBXEqGra4J1k4/PWhubKJzJ - jj4CblMXi8WDo6NWL06G8frra5f/fht+6+V/tliup4D1q2fZOgbUgE5TwYO6TLaIlSQ/WDvrwerpD3In - P8ie8CBz7IOVCQ9WjGaxfBT3ZMyDzIQHWeMe5ExgX5M39UFBIvsn6+c8KJrH/nnpwgfli/5RmnovawqD - uHT+/eK59wtn3V834/7qKX/JSfhiWb/PFwPrMIZ1kv7uNI+7k5w/neAIXr+XYP/WKLvbI+1ujbB9dbjt - 5hjVHG8Lf+1L//nSf1haWq5atQq7dOHwKDmkdI8vd9AhE0YFPFFY2P42sXZzy7K01Fur1bPGjd66Pv/T - c0e/uHzy25fP/OnVC3+7deV/fwTWzIqBdI25D0pTHuROebBsxD8XDfzn3N7/nBXxv4mhf5ke8sdpwd9M - DfpqatC9KUH3JgfenRT42aTATycF/n4iCzzBHxGfTw7E3345JejrqUF/mBaMf/XXGSF/Twz5Z1LoP2dH - sG+4IBbf+f7CQV8kRd5fFnd/xYj7WWPu5yTczxmL+EvWyHvLYj9Pi/48NfJucujdOQF3Z/owrKe4fDbR - 8aOxDh+MMWD92gjbG8NtX463vRZnWxQmG2PT01NhiWIp3uJ8+Z8f8MC7n59LF7ZoRRERxzisdxOvAwO3 - eHvXubiUuziXujhlaJSBq1PnvXVkN1wEsP7yyqk/XD/755sXeaxJQDrWEMbW7YWMX1njOEwjAQdwAUbA - 6+OJAXfGB7w/zv/dsf5vj/V/c6z/Gwn+txP8X0/wuzXG77UxfjfbCnwef4uvQeCL8a8Q+OfvjfP/YLz/ - nQkB+Lb45nglPh/v+0Gc03fT/f6a6P+3pKC/zQn/W3LU3xb2/VNqn88Xht5dEMYYPT/k7twgxmtgzSTb - 7e4Ep0/GMazfHW1PvAbWAPrKEJsrsbbHBriuDLDpaycLDw9PSUnBukXlf3J4lLPwDS1aDwH0SQ7rA4GB - O3S6OgeHYne3Ch/vmiC/BoTeM8taHZKfMvfto3vunD702XmG9XfXzz0Ga6B/bPODmmUPciYyZGeG/3l6 - CMEKCIApAQqAhFC+Otrvxwf/qtDLgNfs5nCvKwMc3hzr/e54/QcT9B9P9Lk72ffLKX5fT9PfneIE/jIW - Q6MhHRR4znjNsP79WMc7CQ7AGnptwHqozbX+dreGe96M97gR71ka7pDgprKRWi5YsADlaagH5vDoKHWs - h8JzlwD06dDQoz4+u11cNuo8N/rp64P9N7VEY7B/o94zx1Ybnj1v5jtH93505tDdC8e+unqasEY2TBpC - vH5wZjeT1+wJeM/+IzEUb2e864XI4jfnGfrjMe3kd7gy1P1Mf/vro7wQN0brbo7RvZ6ge2Os9xtjPV4Z - Y3trjN2bY+zfG2sPXYZiYD28O9mFoTzZ7e5El7vjnT4bx7B+fzSTkddH2r06zPbVQQ5vDPd8nWHt+epw - r1fiPRuinWforD3UMpSM0BpHmQX5Id2aw9/FIPLzO+TpsdNXvyckcH9Y0N7QwB3B/puNsPbV5dtZRWck - TXn3WDOw/vzicSHWf99T8fd1s/938eB/zAwDuJBOgIu38FucCPDgdhKXp/5lFwe5nhngeG2kF8XLo1gA - 9CujXE8Ptz4XZ30x3ubKcJvrI21vjrJ7A1qRYP/hOAfoxqfjHIEygnj9wWj7tyEjcXa3Bzu9M9LrzRFe - r4/wwtvlRjyw9ro+XLc91m2ur63eSgHtxvLIV+Xo5i2Rn8+BsOBjvcKOR4QeDQ85FB7cHBq4MyRgS2u4 - N/npC+1tBiRPTHi1eSth/WVjwbdZk7+b1+eP04IYuOMBrh8Dd+wvD67w1To/wPncIGceaP7JhREux+Ot - jg21OjHU6uRQqzPDrM9zoF8bYXt9hO2tkbZvjLKDaABfoIz4cAzD+p14+3fjXO6M9npvlO7tUbrbI3S3 - Rni9Olz3ynDdy8O9rw333tnfY66fvY+1EudpwfNBrOFAQG1Rr7BTXJzsFXYiIvRYeMjh8OB9YUG7QwKa - jLAO8K10shs+pW/EmdlxH86I+ni8/7vjfN9I8Hl9tM/N0b43mcL63mDhh3jqxPzB3/BsP8cLQ1xMgT43 - 3PnYMKtjQ1piqNVxDvHTQ63PDrO+MNTmSpwNnAa8HRQDugHQWcTZ3xnu+kmC7s4Y3fujvYH1W6N0r4/U - 3RzhfWOEN8N6hP7KCP22fh4zfe3ctYri4mIkIpARHmjC+iSwjgg9Eh4MGQHW2zisOSXxawjWVQd7bHBR - DZN16VnTy/F8nO5CnPfFeO9Lw70vj9BfG+lzbaTv9VG+r7B4hrA+1df+4jA3U6DPDndqBTSP+BCr40Os - Tg62OjXY+uxg6wuwGcNs4DeAONbD20Ps7gx3+zRB9/sE748T9B+O8X5vjPfbo73fGKW/NUp/Y6T+5RH6 - qyP0l4frL43Qb+zjPlFnZ6uSw3QLgeapDRk5Eh5ykJPsnSG+DcFeVcHuZUFupYFupQGupS6aCXIzzQp/ - qyODvU4O052J051ncON/AKx9TLEmjvPBvRIs8JUvj2RxdaTvlRE+l0f4XBzO4jwiXo84F68/G6c/Iwj8 - EYHP0xfgK/H1l7h/i++AVxrfDd+25Wdgb6/j0TaX4z2ujvRCCOE+M9yhbaAHWx0dxOLYIKvjgxjip4WI - D7B5O97tzmjdR2O8P0nQf5zgfSdB/0GC/t0xPm+N5t7co3yuj9RfYz+Snn6XwkjXoW7WAPo0Jx30USgj - R8P994Z5bwn13BjkXhXgVh7gWubvWkrhbjNXbe6Z5K48MNDz+BDd6WG6c/Fgt/7KcIY1Ufv6KL9XRvsJ - McXnAQf97wHW6Tj9iTjvY8O8Dw/VHRis28/FvsFewmge5GUURl9A/wr//NAQ3dGh7LudjPPGa4OXgb1s - 8boDUVYXh3teGuF5eYTnFS4I9JPx9keHCqSjhdFHCeiBhgDcPOJnBluf62uFMXashO+M8oJ03Bnj/VGC - /qOxPh+O9Xl/rO/bCb63x/i+NtoHvzVwwMt/gSMNfk0CunWEnuoVcKiXT3OE984w3fYQz81BHhsD3asD - 3Db4uZb7uZZxUertsMJG0iveTlId6XR0iO4UqB3vfSFefwlwM51iFLs8whd0I1hPxemFmAIvQnBvS+wZ - 6LWbi12dCPpK/BME/x3oG9IrQejv7efWFGF1ZKj7sWHuJ+Pcz8R7nBvucXEEw/14nM2RIdojg7VHh1hR - kF4bAS1EHAQ/Ea29OsTtRpzHa/Geb4wE3N7vj/H+MMHnzljfO+N8Pxjn926C31sJvrfG+N5gWPsS1vj1 - WwMNiP0P9/LZF6FvDvcGnfeEee8K0e0I9moK8mwI9Kjzd6v0bw23o2qErKt8hb81ZOTEUC/AfWoowhsf - jw9lVD04xGvfIF0z98sTrAQooblzgOeOAZ7bBbGtvyfFVpPg/wpPhP8E3wGBb0Xfk14AQn9rtFNDhNWu - ga6IPQPdmge7HRzifnSo+4k49+YhVvsGaQ4M0h4arD08WID4YKsjAkbzQLMn/a2OR1tfHup+daj7y3Es - YXlthNcbI73fGe39XoLPh+N8Pxzn9+E4ZKdwX36vj2HuAFIGrEG1Fo02hhgoI5pDdXtDdbtDvHaEeG0P - 8twU6FEf4F4jgJsR3M16jtpcN9FZ3hDjuneAx66BHrA47NfGc/bL4wnCaycHKwFkwLGf59anGNzLw78A - BH19L7uNkbbbBrhuH8hiB4c4YsdA54b+qi2xqu391Lv6q5sHavYN1BwcxCE+SHtkIMKKohXQ/axOxNhe - GuIOrK8M87g2zON6vOdNOLyR3m+O0r+bAPVgQH843h/Z7zssjWD1A6gosOaAJqHQ7+VYzCIUoWNAU/Bw - c9RuBLUfwe0GrMu9nXJtZP0tXuqxUK9t6OPaGOu2ua/75lj3LbHum/t5NPXzYB9jPZv6sXia4Hbw3bg3 - RGWIVV1v+839XZoQA1wRWznQN/W3r+6rrIlR1sYo6/ooN/VVbY1liO8doNk3QHNwgPbQAO0RCiHisVan - +tgxoBnWHleGelyN83w53uvGCN1rI/W3R+nfGuP77li/98f5od7yPuwvV2lAMgysRb18m3sxiKESLAhi - PhjKLRGi2xOi2xXMqN0U6NEQ4F7n51bj51bl61rp41qBcNYmKXp6xNlJ80MdqqJda2LcNsa4NfRxb+zr - vqmvx+ZYjy2xBrh/Hqzxohb6yOtiHBtiXRr7uWzq5wLEt3Cg18XabIhRVvRWVkYrq6JbI95XvStWvaef - Zl8/zcH+2sNCuPtYnY51aAX0MM+rcV4vI2EZ4X2TOTyfN8ZgSfR7lwmIgdfAGoUXUbj3rjDv3YhQoKyj - aIV1C9D7Qr0RzYA7WLczyGtbgOcWf48GP8DtXuvrVu0LxN2qdE4F1rLBFi9JprmpKnu7Vke71sW41ce4 - NzK4GdaIn43ajTGuJQEqoCwMQryyr7Y0WlEWpSjvrdzQ24B4NRCPVtT0Vm6MVqIAvb2PGoX/5n6aA/0N - BD8crT3T3+niEHdOPTygHleHeV6L87oWz9LCV0bqXx2ph+WA8Xgzwe/tsX5gNOCGhgBrUahue6j3Tggx - F62wDtHtRTxiNFD23hesQ+wN8tod6Lkj0HObv8dmP/dGX7eNvm6A2xCuNgvVlkGRavNUH2tQuzYa1HZv - k9o/qZLURTqWh2iNgKY/lkari3srSiIV6BMieMQreyuqohTVXNRGKRujVU0xql191XtiGcEPRGnODnC+ - MNgNQF8a6nF5mOcVDuiX43XXh3tfH6G/Mcrn1VEsT4bruD3Gj4OblSoRomCvLSHwcLodobpdPNacSjCU - DeHdDHCDdfgIlPcHGaI50Gt3gOeOAAb3Fj/3TX7uDb5u9RzoG31caxzUU2TdXQbbSDID7Wqi3UypDSXZ - HOtZHOWWFeacEuAwTW8/ysNmgItVLweNv63K00rlpFbYKOVquUyBHrBUisAT/BGfxF/hC/Bl+GL8E/xD - /HN8E3yrkii3LZx2V4XZVobbmAJdH+tcHK0silQU9WJRHPkI8XJwPFJREamojFRUI6IUNVHK+mjllhjV - jhj1nnD1qQEu5wa5XRhiwPpKHJMOMJqAfmWkz42RPjAbwPq10b5UpwWdUQISYWWDnQj22gZrAaxD4DEY - yoZg5NXtCfJiwT1vDtLtA9DB3gcQHOIM7kCvnRzcTRzBgXgjhbdzka1ipKSbdoSDLC/EAdReHea80N9h - ks5ugIs20FbloFI4OztjaikmJgZTRRMnTsRw16JFi9A/w7HvGBHBIANua6qrq8NwDx5o1uEyicrKSoyX - Yw42KysLnWJsKsEkCcZ0cLxPYGAghhAdVYogO3WoovsYN+XCQNuCXg5CuGv62hf1VvBAE9wIEJxFL3lZ - L3l5L8WGXgzuqha463opt4ZrD/dzOTHA9cwgt/OD3S8SqQE0V1HigYaDfnUUwxqWgy+Li+CLA9xr4SWC - PbdioQvR7eSw3h1swHc3oRzIRRDDGsFjfTDYG0GI7w302tVCcCAOBd/McPfY4uaQp5IO6fI7qaKnmaWF - OTaf4iSNqVOnoteOOTRs2wN2GzduBIiAEp18PFAcwAPjE+iB0gNzhaYPtKLxMP18eXl5cnKyhcQCc0k+ - 4T4WEnN3rSTGSTlRp80ItlsfZdUm0AzuCEVxhBxYl0TIyyJawx2maAiz2tnHaV+s85H+ricHuZ1lWHte - jvO6Gq8D1gD6+kgfRmoOaPAahTBgTc0gEXI8+LMA92p45CDPLaB2kNeOIK9dUGEKjrAGoNvB+lCwN4IQ - J4Lv8vXY7u2+1dOtyc21yd19u5fXThcXbAsZZWFhN3ToUOwcrqioqKqqAsRgKyBGA59HFsABPkyoYBoI - D/RAMVGIB7rO9MAQeJsP/gvwxajB+/fyz67PRmTVZc3JmTN69ujecb09AjwU8hf1Ni8Nde0+39eysIXO - Bl5HKIrC5YhiLgB3aQvcFSGKhnCbbTGOO2Kcd/d1PtDP9dhAt9ODPc4zrHVXh7PSHQN6FAOaYc0BTVgj - CGgEsupKf/daf49NAZ5bsdAFee0EXlwQ1o/gbuE1ZIQ05FCI/jAi2Puwv+6Q3nO/p3uzp2ezTrdfrz/g - 53cwIOCQvz+LgIDDXl4bbG0nisUumALFwSUgMlhM/AW+ABewEpSYmkAvDt1PPDDsgH4zHujK0wN9fqMH - /1f0lTihNG5q3Oqtq1c3rc7fkp+3OQ9zjrmNuasaVmlSNWZDzV4MePF/bP7HRvFCpH3Xad7m+WEyjtEM - ZRZhLAhrA7sDFQ297JqiHZFtbu/jtLOvy95+LocHup0c7HF2qNeleO8rwJqRGksiAxoVY2FpV+TrUuzr - WuLrUuqDcC33davxd28M8NgCzYUOtId1C7UZ1kHeB/y8Dvh4HfLyPKzTnfD1PR0QcCY4+GxQ0GlEYODJ - wMDjiIAA9hERFHTCx2eTg8MchSIgMjISJ0JBPQAxcRb4EqxowWEOCPNQeGASF9O9aOzjgV4RHjhR0ehB - n6evwRf7+vqmrEkp3FO4fvf6dbvWrdu5bu2OtQXbC+bWz5XlysSpYvFcsXi2uOeInl0jur7g/IJK9j8R - dl2neZkXhD4C+hHcQNxP3hDpsKm34+Zop60xwNoZWO+OdT0wwP3YYM8zQ71QMb4ynJWLoR6M11xpHs9h - BFETF/m4FOudi31cSvSGKOMc8UbIaztYP6K2v9devcceT/e9XgDa5yiH74Xg4EshIZe5uBQcfDE4+Hxw - 8LngYPwVC0IfT0JCzgQGHnZ3z7KyGmxhocJFHHTYGXgKZAlWQInD9TFzhS3dOJgLQ4HYqYouET2w+4Z/ - 8J/EF+DLsH56+XuVHypHlB0sKz1QiijZX1LcXDy0dqg0VypNk0oWSCTzuZgrYYiP6tk1tOsLdi/YSl/o - Z2+W7GNJKBsiRF4eqK6PcmiIIqydt8Y4b+vrsjPWdXc/t+b+HkcGe6K8g3IxKtGokV4f5QNDcn6gy9He - 1qdiHS8MchfpnYsQ3s7FCD1AZ3CX6l0qYIrhH2AkADdMhZDaAV67fTx2e7nvdnPdBX3w8zsSGHgiMPAU - ByLQPA+IQ0KuhGLLJIurXDDcEaGhF1riYmgo4lJY2BVf33onp3kqVQgRnC6pAl6EJgau0MzHEDAeGJ/A - hhGMBmJgxeiBT+KBv8XXwLcMmzSs7kxd3em62lO1NSdrqk9WV5+orjxWGVATIM+XY5JRtlgmXSSVpkql - KVJJMgf3DLHlRMsesT1e0r3Upft/+ahfGufWIz9EBqwLA+Ubgq3qIh02Rjo29HZsjHbaEuO8tY/L9ljX - nf3c9vR3R5Hn4GDPE0N1UJITA5yP9rE/GmN7pr/zxSEwf74IAF3ozQJYs2jBGnCX+bgi36sXUtvfc5e3 - xy4Pt12QYOivvz9YfAxBmsCpBOAGWxnWwDcMZ82FvRIefoP7iLiOwCfDcYyDICIiXunV60Z4+BW9foOj - 4wyl0h9GDasZ5BuoAT403zDchsEJjLliPzAeGOLGA+19/kGfwV4SPLBnIL04velq05YrW7Zc3rL58ubG - i40YRK86W2VfZ69Yo5CvlMuXyuUZclk6Q1y2SCZNlkoSJeLJYsx9iceKLUZYmIWaveDwgq3shcGO3dO9 - xJWhNrW9HDZGOdZHMaAbo50Z1n1dd8S67ezvDiVpirLfFG7dFKZtjnY41t/9/FDvS3E+V+J9rsb7MKBt - FcO8nddzYQr3I2r7uDfp3La6uW7T6Zp9fbG+AWIKBjRhDfHlgikD5AJYh4VdBbIREa9GRLwWEXGrVy8+ - XouMvBkZiY+PIirqVlTU6717v9mr13U/v1onp8kaTTBOQEtKSoJrxuQ1htswGosH5lRwNhceGJjHFhWj - BwRdF6ADvrtf273r5q6dN3fufHXnjhs7tl3ftvDkQnWDWrlWqVilUGQpFJkKxQqFfDlH8FSZdKZUmiiV - TJZIJkrEEwyI9+jb4yWXl2Qv/vcwB1mmvw2yTWDd0JsBDWpv7GVXG25TFaypCdY0hNtu7e20K9Zz3wCv - o4N0p4Z4nxumvxjnc5nDWtT9f16wksZ4OqxqC24m3F7OZe7Olc5OtZ6e23x9m/39mYsICDjCBQM6MJBn - NEh9Ijj4ZHDwKU6Fz0EcoAyEda9er0dGvhEV9VZU1NsUvXtTvMUFnrwTHf1uTAzivZiYDyIjryECAzd5 - ei61sxuhVHrGxsZCWOALId/oeGKiEGNBeGDOHoNY9BEP3FGWMCvhwDsH9r+zf9/b+1i8tW/vG3v33t47 - 6OggVb1KWaRUrlYq85XKPKVylVKZo1SsVMjT5LJ5MtlMmXS6VDpVKp3CIT5JIpkgsYyyRFaFoSRrcc9B - ttIMb9WGYG1ZgKrET7khSFMTZtsQ6dTUx2NbH4/tsZ47Yz139/Pc28/r0EDvE4O9zw7VX4jzAbVFWUF2 - fa0sVRYBrjapLVgb2O3pVOTqWORgX+TqWqnT1ev1W319d/r5AWuIBsM6MPAohzLRmWf0yZCQU1ycDgk5 - GxZ2Pjz8UkTENYgD+AvCEqDR0e8DTUSfPh9ycYeLj7j4uE+fT3r3vt279xsxMW/FxLzTp8970dE3Q0K2 - +/hku7pOsLYOlkhkMHDQYqSOWD8hLJgPwgOTK0gR8xrzjn549Oido/h45IMjiEPvHTr47kHvQ97qjWpV - qUpVqFKtU6nWqhjiq5WKHIV8iVy+QC6fK5fPkgNuWaJMNl0mmSKxmGDRzbMbdmIh4XzxxRe7d+8p7fJi - fyvLlb5Wdb2c6qNcGqNdG6PdtsS4M6z7eu4wYO21p7/uwADv44O9zwDrYXpRYbjzmjDH4fYyqZmjo2Yq - Ye3ltN7VYZ2D/ToXlzJPzypM43GxUa/f7Ou7zc9vj7///oCAg4GBwPpYUBCCoRwcTHQ2AB0aihmo02Fh - hPXFiIgr0ISoqFeBYHT02zEx73PIftK37+/79v20b9+7sbF3+/VDfN6v3z0Eod+378f9+n3cv//HAwf+ - fvDg38fFfTpixKejRn02dOjF2NimiIhVfn7T3dxira3d9Xo9Bg8HDBjghSzr9u6D7x089MGhIx8eYXAj - PjqadytPc1ADoNXlanWJWlWkUhYqFesUstUyaZbUcpGlxTyLnjN7dp/Wvdvkbi+Nf+nFhBd/N/p3L45+ - 6X/kv/Pw8O/TZ/jIkYnTp6ePHTs3LKyfg1Q8xkVTGAoNcd0U47Ypxn1LH/etfT2B9XbA3c9rd3+G9b4B - uqODvCEjotJeLoURDOupbirLLlIb+TBXh7WO9mtdXIo9PDbodOBylU5Xg2iBu8HHZ6uf305//2YO68NB - QUeDg49zAYgpThHKBHR4OOJcePiFiIhLkZFXo6Je6d37tejoNyERQLNv3084iO/17/9l//5fDxjw9cCB - Xw8ahI+fDRp0d8iQz4cO/Twu7t7w4fdGjvxizJgvxo37YsKELyZP/nLGjC9nzfpq/vyvUlO/Sku7t2DB - zVmzjvj4jBiXPHnfOweb3zmw9619e95s3nV7987Xd+64tSPqYNRL1S+9uPrFF3NefDGTxUsrX+qyskuX - ZV26LurWdW7XrrPMzBJ7dE/s2WOmhXmSpUWSRDxTZjFc2r27eVJSRmLisqSk5bNmZc6dmz1/fu7kyQsj - Ivrr1fIkL9v6aAb05j7A2gNYb4313B7rBax3cXA399cdHugtquztUhbJsF4b5jTaRfXb//xPS8tejo4r - vbwqEC1AM6y9vWv1+jq9Hryu9/Fp9PPb5u+/OzBwf1DQ4eDgoyEhx0NCToSGngwNBcqnwsIA8RkKDuiz - ERHnIiLOR0Rc7NXrclTUNcAdHf1aTMybkIXY2DuxsZ9yWDOIhwz5Ji7um/j4L4YP/2LUKID7ZULCl+PH - fzVp0tdTpnw9Y8bXSUlfz579TXLyN4sWfZOR8c2KFd+uWvWHgoI/5Od/IldZlx2qOfHp+RO/P3fi03Mn - Pzt38u65U1x4ndartmmV1VplhVZZzkJRqlGUaOTr1PJstWypSpamlC1USlOU0gVK6XwFQjJPYREpCQqK - Abhz5uTMm5ezYMHqhQsLFi1au2RJ8bJlZSjYhIT0jbZTLwtw3NzHA8GwjvVC8Fhvi/Fs6uUlQm0eWOeG - Og1z1drIxBC4/v37S6V6e/s5Xl6VFCC1tzfCgLWPz0Yfn3pfX2C9JSBgZ2Bgc3DwwZCQI8AaQIeFEcqn - w8MBsRBlAH2uV6/zXFyMjLzcwu6bMTFv9Onzbt++d/r1+7R//y8GDvwGWMfHfzV69FcJCd9MmPDN5Mnf - Tp36bVLSt3Pnfpec/F1q6ndpad8tW/bHrKw/5uX9ae3aP5WU/Lmy8i9z5mwZMCbu1N0Lpz6/cPrehTP3 - Lp794uJZfLx3ceVbOepjVqrNLUAD6w0c1iUaxTqNPEstX66Spatki1WyRSpZqopHvKeHOC5u6oIFeSkp - q1NT1y5eXJieXrJsWXlmZlVOzsa8vMaCgi0TJiTbymQJ7jblka5b+no0QUBivTZFe9ZHeG4M86wL9agP - dRehTDzfzz7YRgnviZIjrgzAFiDszerZU21lNdzDYz1HagPWen2NXl/r41MHrDmgEZv8/bHdCOPVGLI+ - HBqKCeAT4eGnwsMZ0BERIDIFQ5kHOjLyAhcM7qioK717v9y7942YmNf79Hm7b98PYmM/6d//cwjIsGHf - jBz57dixf5g8+Q/Tpn03e/Yfk5P/uGjRH9PT/7hixZ9WrfrTmjV/Li7+S0XFX2pr/7ply99iYqZl1uSd - /eLS2S8vnfvq8nkuzuH5l5cGXBui3melarRS1Vqpqrio1CIYqdcQ0Gr5kpZIMyAunarsKRODzosWrU9L - K8rIAIvLV6yozsmpy8/ftGbN1vXrdxYV7Sktbc7Orhk2bFKItTrZ27E23KM6hEVViHt1sFttCMJVNNrD - 2kYhw04sXECwdu1aeKO8vDxsHcCCHh0drVCEOjkt9Pau5BhdpddXA2sfn1pf3zqkc35+Df7+AHpzQMAW - jFcHB+8NCTkQiimn8OPh4Ri7Ph0RQViDyBRE50fRgji0G4hf7d37enT0q4R4bOwH/fr9HgQfNAjs/jYh - gcGdlPTdvHkMa9A5O5sBXVr6l6qqvzY0/DU7+2xgVMSh908wlL80oExY7/v8oPM5d/VOK1U9B3Q1Fwxr - K2WpVpGvUWSpFSvU8gwu0rngQJcMUISGxi5ZUgQWL11atnx5ZXZ2bW5uQ0FBU2HhzpKSZlieysojWVmH - Z8w4MGTIAU/PTPOXJIOstPm+zpVBrlXBhqgB0Dh8GiX20tJSJAXYkI1aOxDHA5UHfH7ChAmWljY2NqO9 - vAr1egBd5eMDoGt8fWv9/Db6+dX7+zOsOaAR2Gu0IySkOTT0YFjY0fDwExERp3r1OtOr11ku2oUb0Lfm - OEO8heNvgeP9+oHj9yApcXGM4FOmfDdz5ncLFjBqA+61a/9cVvaXwYPT5+Sknrl36UxrRgPoWbfnqY9Z - q5qsVHVWqhouOKyZWBdpFasAtEaxQqNYSvEIcUu9bPToWRyLKzIzQeSN+fmNa9ZsKyjYnZ6+b/r0g3Fx - h2NioJmHoZ/+/jvw/gZQKtVwvUQ+39WuMsilKtilMph9FKFbgQeyABhSPFAyx6OMewB9PNDsgGdSqUJd - XFJ8fKp9fYEyCz+/OmAdEFAfENAQEACssSUUG0OBNfbTEdwHwsOPcjsKTOE2prYJzaEql6AqLTSHjt8W - 0Pwe0RygT53KJGXKlFccPfT1F3ee/OzSqbuXTn1+6TSP+JeXAy+FqputVJtMgMaSuE6ryOWAXq5RLBPE - Uo1shspCLsW6l55ekZxcPWNG7ZgxdYMHN8bEbAsN3QUXEBCwJyAAT2DA4As2A2UoKvemr7C1naXoJh5l - qwXKFCIUuvCgNgdq8PQRZWL+I30SO+UlEitb23idLh/5McLfv44LhnVgYENgYGNg4GbwugXrbSEhO0JD - 92LTRlgYExMO8dMt1O4IaB50Ac0fgd7C9Df79mV2pV+/zyAvrq7ZCfNmHv7o0pGPLh39+NLRTy4d+/2l - 459eOvHppZVvrJYfsZFuspJWa2WVWlkFCzk+lmtkRRrpKo00SyNdrpFmqCXpLMRL1JZpaovFarMouZ3d - wJCQ4oCAUhRhdDoKJqEQT2CKJYpk09/fEPgMFBV/i7e+i8tKqTSmt0qVo3dkQBOg1EZC9Z36RsIGB3oc - KBbjgYYIenoqlY+z83Q/vyp//9qAAKDMB4Mbh1JgWzlH7S20fTE4eDt2IoWF7QsPP4zNMq3hbkO1TXW8 - TdxbNB2r6CuhoYfVNi4lBxoOfnj+4IcXDrG4aIg7F0NPDejRpO1RoelRrOlRqOlRpOlZyKLHGk33HI1Z - htosTW2WojZboO6WrBKE8gVbsZXVNDe3bDe3HC7yPDxWe3mt9/Yu9fau4MQTQAPibQEB2wMCdnAfEU2g - tq8vsg2YtA1q9WhvsSzFzU4EiNGjQ3cODQ7qbqCvgdI7dTGo+o6PeOCPqBdjwUQvytq6t4dHakBAHRcb - AwOBMgWjNoe1QUla4CaCN4Pg4eFHIiJ+CMHbW0sdHOYPT5x88IOzBz84Z4gPzx3kovB2rXy/Q/dalVmJ - ymy9ymydymwti25rlN1ylV2XKbqmKbouVHSdTyHn46U46W9/a+7ktMTZOd3FZamr6wp39xwPj3xPz3Xe - 3uV6faWv70Z//ybgC+kICtoTFLQXXoB7Ar+7HX/FsRtpR5WtbaKVmVjEQ4zuEZpGQBPVL7QqUHHHA0Vh - VNxRTafSOz6DKhr+Fvtq5XIre/shOt1KgjswEHC3hziEu0mA+C4O8YOcgrMF80klRYg4fk+VtXNhcy0H - tHHEnI4z26o026AwK1SYrVeYrVOYrWXRbbW8W5a8a5qsa6qs6wJZ1/nG8TtfsUzW18lpcQvQmW5uqzw9 - C3S6IkgwpxubAgO3cb52H9IILpM4wHnc/cHBe+DBOGoj26jGO8DRcb4ImkAsBmfR10BTA4Ci3I6N5Ci0 - 46wlqrLjI0rD+CPK8KjH4wUA5RcuXKhUOmOfvl6f28JuHnQjgpOe8HBDUsBxJikCxJ9YxIG4nd2cUbOm - tolyzVvb1QeczTYqzUo5oFtQNluj6JYr77aMA3phGyh3mSL9rdTc2nqak1Oas3OGi8tyV9csd3fQGbpR - BpLC1+KosMBAbDreFxICiJFAHOHiMAc02A1eY7M3pLxcp1vn5ZUnQo8OgoDuEXgK2gJi4AtYsV0f9XUU - 0VFZRyEYDzzBZ/B54A7QCXEoODy4SuXu5DRGr88LCIBwUzwR4jsFqsLrOHxh2+6bZzRoZePiWXa4sU2g - B59N6L5dZVapMCsyoXO2vOsSjs4pbQD9Ym+JuXmQk9MiSAd0w8VlBejMCXQhZBdrHdZAQd5wGF4WEHNx - ICQEAgLVRipX7eeHL4agF+p0a0QgJrQCmgB9QMcIrSBACXxx5CDK6lT2xQP7FPEcJXaU2wlxVCZBcBAf - /xCraGJiokrl4eg4xtt7lQDuxyMuVBWsnKGhewQ0N5Jy48XT2nrqpEVz2kR549s7tQddzeqVZmVt0Xl5 - u3SGjPyPnYVaPapFN5a5upJurNHpijl1RuoAMdwJC0sulsN3D+0+RgGd87vQFphgiAwcC4AuEEEu0KAj - IgM7QIwWBiAGuCii49wIqvPSA1sVUWgH4oAbHOfhBrshJpjN4OB2cXCAC1zRGm4DzVtLeXsrJxOW1qBj - /RQynaU/eBd7BYfUX9zVLp13tEPnHHnXdFnXRW3T+aXBUjMzL6KzszPoDN3IdnfP45ZBoMb8BvIGZGdc - ggaZRgWCFn/QHJ9vxLsZlszPDy9JuY9PCYDW69eJoMiACVKAjhyoCgQJYsCKQ3qx1RYndWCzHB54gk2K - 2OgM9PEF4DixG308iAleJ7xa+G5YXTGjhVOD7O0HeHgsbAtuIeimUm5kV8gjQtAhL3DlpOkMd6Vy2PzV - S9tEufLNJqbObdI5T95tRQudk9vQjRc8LeXygRyd01xcYDkA9EpYDk/PfJ1urbc3FsNSIAgcIQ6cu6Uc - gn4R/BHCUu3vj7+tQLRgXSTCex+KDLDAUCgDGkLAERADVuyOw2ZE7GmmB3Yl4o+EOODGAeD4YvwTdPDw - PsDrBNmB+EC4ofXwMChR4Q5Aa+twHK3n67uufcSZvAgcC35uY6a3XkUZ7o6OyVHDBu175+SBD87wcfCD - M1ycjTk9rPt2ZbeKttS5YzqPlPy2W08YMvgE/C8cHVOcnFKdnRe7uqa7uy/z8MjR6VaDoRAEDmusijX+ - /jWCXw3PWXBY428Z3L6+G3x9y0QgIxQAckEHoIDIoC3t98Secdpeiwee0IOHG1+GvhGJCaQGmk5KgjcH - CTcUCQssqlToOUG+cbqep2dah3C3Ky8t3txgz/F7yjW2OZvWH/jgtGmsfq1Uvs/OrE7erUzWbb2s21pD - dC2Qdc2VdV0h65Im7ZIq7ZIs7TKfQtJlniF+52cuFofa2U23s0u0t5+JKR/A7ey80NV1iZvbcg+PLPgH - b+81Pj7AuoTDugLkBawcvrwR4LE2UBtYs4O6oQDQAUBGR/qAyHSGI38yGN0mjwdd6oq/whfgKDt8MbiP - 14ZXErwt8ObAdAAZQQg3wY0kHnqCyVsrqxBn5wne3tmdQLxN98JyIo1mxNj50w98cKrNCD4ebbZF1q1C - 2q1I2m2dtNtaabc1LLqulnbNknZZIumySNJlwSNweZRfGiv+rUV3fHNb26nA2t4eWM92dJzr7LzA1XWx - m9tSd3f0Q1ZhZdPr13NAb+CAJpSFQOMnN6a2CCiDktABkgvauEwQA1n+PhE6qJJOzSeswXdSEug4ryS0 - TvLCbQQ3TCQqghhKQrJjYxPp4jLVxKLwpGj3ibNzil9kRMPlnQfeP2UaC64tNd+rMquVdSuRdlsvRFnS - dZWk63JJl8XiLgvFXeaLu8wzjhcCe1pY+NvYTLK1nUxYOzgkcUCnuLgwoMFonQ6MXtuiHgDalM7Cn9xA - bZ0uWwSU6cw1Xi5MUebPFCOshdRuU0lIuI3gpvQSCRHcJHJ9tBdw1zEQt7aOAMdxwmFnOI7f0EKqzqhY - 1SbK+KTrYV+zTdJu5dJuha3pnCfpminpkibukirusqANlF8ab/lbiZlKNdTGZqKNDYCeBkY7OMzCCJWL - C6QDGr3C05M0GnQuhuxydEbNx0g3HgGNXwq/GlYp/JoiXpSN5IIo3OYVmEZwg9q8kuAF412gEG6ICWk3 - lko4E+TxsJWooiAvBeI4XBSqotH4Qcfd3ef5+KxpD3S8r0fPndIeysPPT+i+S2ZWzYmGkM75HJ2XdUjn - oJ7m5n7W1kB5oq3tFE46QOc50A0Xl0UcnTO9vHIh0BydSTd4Oj/SDfzw+BXwi+DXwS+F6XocUYNaP7sr - SyjKQrno4HRMI6zpkmgoCb4VucA24aalEs6EjCCyJMg3CI7sH2UsdBtwjihGBhQKG0i5o+NID4/5Pj4F - POggV3Cf6PZEY/2tCtV+B7MGabey1nQukHbNlXRd2YJym3Qea0TnqRydZ3J0TsFK6O6+nKNzPhyxXs/T - 2QA0fkj8qPiB8WPjh+/duzfKnJgB52vOqNyJsKYJD0rp/O3VvGoLlaQDuPkcB5knDCV8N1ZL0hMiOBSc - CoRw4mhd4mhIuEO5XKXR+MKS29kNV9vYZTesaY/OgcejzLZKu1WarIGgc7akS4a4yyJxl5Q2RANi/YI/ - 1DlAQGfoBug828kpmaNzBkfnVd7ehmXQ2zvf3X2hs/Mke/v++PHwQ2I8E+9LOFq0SoSVZyRxVBw13NBp - tPR18qRXfFmbcJNwG7EbppuWShhB8t1UMyGCkz+BggsRR6kLlXE01ebMmePk5JS4IrH5nebmd/fve/fg - vvcO73/v6P73ju1//8SB909OvJTUfY/crEbarZQTDZgNg9OQMDrza2ByG0C/OMrit+ZmGk18izpjGZxB - dKZl0MVlnqPjNEfHBBubQVptuFLpLpOpgoKCsEEEd4+gA4VKPV/TJ2QJXNoRQsV9drnvD0ZZuEi2t07y - cMN0w9uQEYTv5ldLnuC8ggsRh6qA48jsR88aferzU4gTn5049vtjRz46cujOoQMfHNj33r7Cm0WafVZd - Npp1KTXrsq5HlzU9u64x71pggeiSa9El07LLEssuqZZdUixbOw38kcX/6MzMzfVqNdp1fVWqKKUSa1eg - TKaXSt0lEjtLSyV6pjqdDpzFLAYmLqEJoK1wUwi/74bfbkPg8rsXwBh2Lzgdz9bm0td5aneS3ZTBU5pD - JSoiONw3FBy5JSQFiPMch6pg61X00OhtL28788WZM/dYnL53+lF8fjrqYpS0WWpZb2m+wbxnSc8ehT3M - 1pmZrTXrmt+1S3aXlzJeejH1xd8t+N3v5v7ud7Nbx5zfvTDwhf966b9w/re1tTXeNJ6enjh1GvOMWCpg - iiBfmAbAQYt4V6FzjT4q7bvhd4RQNV+46Ybft0D7Qmi0Hsu+iET5x6PcMbt5Z0K+m9IcwA09QWmFEEey - Y4o49M470LtkX8nZL84iGNZ8cKBPvTlVcVwh3y6XbZTJqmWySpmsQibbIJOWSaXFUmmBVJIlkayQSJZK - JOksxOniR5Em7qnviZ132CIGTGfMmIHVGDKFHV3AF2dQwRFh+AKrNE7sQQsbnVVADP6SJhBnhchSc4oH - l3aE0L4F0dNFuQO4yZnACPIFE75ERYjzksIjjp/Sxt4mszrz3Ffnzn3J4uyXZ1lwoCPWvrvW6bSTYrdC - 3iiX18rlVfJHQJdKpeukkhwJA3q5AWXCmg+LIRbQBOgspAkQo7COsWC4MezLw0H2QBn1A6AMoQCR8ZIT - xLTdBnV8PIiz1PYDbYEsHvymENoOQpsWGNBPpA9P9MVGSyWfVdJqCcNDJSoQHArOSwohDu0GBMn5yee/ - Ps/iq/MMbgoO9MOfHw68GKg8oFQ0KRR1CkWNAkDLK+XyCrmsXCYrkrEx0WypFM3oZVJphnFIZkl6OveE - 7GILKVgMiHFIILYZYK8YGnWwPfyOUhAZSxz1VAlcIIvFg9/FRJuXQFtq+MFKEbh8iwpphOiJgPthX8zD - bZRV8gSnBZMkhUd8yZIl09OmX/jmAouvWRgQ50BHDH55sPqYWrVDpWxQKmuVimqFokqhqFTIN8jlpXL5 - WrksRybDAdfLZbKlMulSqSFaEMd4OW2ZgVDggbYc/o+40AFLAkSZJzKGA+hEf0AMfEFbUgMsHli0+S1M - wr02sFIwVPxeEGz4wHv05wC6PT0Rlk1IUnjEwSZM7WO62XD3wTcXDYi3gJ50O8nqjJV6t1q1WaWqU6lq - VcpqpbJKqaxUKsoVikKFPE8uz5Fjr4psmYzF0lYhGS8xV5lDLkBhyDH8LxQZRg2zcNjMi3UPs0TQCnSO - 0KujnjXhC84SYbFi0xYm1HOwhgNZ0JZ22WClIXBpCwhWILxHf1agCfE2Cc4XqoA4fsm4yXF7X9976dtL - CNwwYQi6cOKbiznv57icc9Hs06ib1NiTQkCrqlkAaGWJUrlGqchVKLINW1Tky+TCwNYgsa8YxVuoBPAF - iwExzgPEq4sLRmAtMFEEraDD5QExNBfkBb6kBgSrcPMS31lFtZnfWQNw4axgZ7ECQRV/AaDbJDifXuI3 - HDhmIMzco2tTOLh50Os/rfe97Ks9qNVs12gauQn+WrW6hoWqUqUqV6nWq9jmlBylMlOJvUAslrcKyUAJ - 5jcBLpY74AsWA2LSClgLpMuQY7oKixrWuAQK+AJcLBsgLLEVrpRgJc4iFyNksaoDWQIXzgp2Fms+VPGX - BNoUcahhvxH9Nl3YdPkPlxFGt9Tgj7hYrNe1XlbHrbQ7tZotOJpco9mo0dSyUFer1RVqdbFatVqlylUp - s5XKFW2EfIpcbCuGYkCIYSogFOTe8DaCQabjt2HRqJUKiCG4IC/wRTES4PJSQFuVaIcSYEUuxiOLlQbg - YtWhLiDWfKjiMwE0IQ4excbHNpxrIJSNgkAfdGOQ9Slrqz1W2iattlGrrddqN2q1dVqGdaVGXapWrVGp - 8lWqVSpVlkq10jhwOYI0UIorNoEvHhAK1NUw1AmtICLzt/ZCKIjFaBsBX9JZkgIeU9qbRLAKkcVKQ+BS - /48aVc8K0EixwOWG8w1Gl1oJ4R5za4z1WWurfVbaba1QZrfiVWs05RpcQqherVbnsms91JmtQpXJQJcP - lOOqeowm40EQQytAZBhk/i5ImgmgsQtIBA0EkBTwsFLPmm9bt4ks3wXEmo/HMwE0ftVBCYOYYgguaDN6 - PvWNqbhg2nq/NbsYDzfy0n3e3HVAWtxNj3uPizS4KJZdnpJjjDKBrpyklFpLYZChxQQxEZncG13WC0WG - naDrleAZwGLwl6QW4JIOEFuFhCXOGiHLV5Ao9/7lgcavHT8lHttaO0B5zltzHC84Wh/kUMZ1vHTHNI9y - pZZdBNTOdbx0KZB6gVrmI8PwMSDGMDidaoOFl64X41GGY4NLo0usoL901TfwpZI91ZOFmFLnmjhLbVW6 - CY0vbDy6h+WH5SBP5V/hF8CKNHbO2OY3mjtAGTfUszu8ceMxLhAzRblKq8XF9Dh0ha62yja+GI+AlkfL - sTEHEFPJgmZo6aJNpCEwcMiV+Qs0aSAAQkG3HRPEPKAdw9pepv2LMRrLCzKFxIzEYx8d6wDlRe8uMkYZ - okFcxr1W1Vp2K/1aJhptXkxPKCvjlVKplI5nosIQncNCt2wCZSR4dEcvz2WgTK1quhNBWEmmPOBJa0S/ - DNBY0B1cHFLXpHYAMf4KKLtddLM+LOCyKcq4hZdEw+RWekJZNUUlc5DBLPMVZEKZv5BQqMvCa++e7r2Z - vwDQcKn+4f659bkdo2xQDKCMux2bOF1uWQANXC7nruDtWJrnqeV6OeoY/BFZUAxCGYk1qkKoBMEs89cb - w8DxV07T4ia8S+XHCObPCjTegFiL+o/qX3mksmOUsfo9UozWKOPuQaYYG7TawsctgBlqRYQCtWYeZVr9 - 6IY8lN9Qu4BfRrECNQrhhd104URnbhbsPPQ/H9DIrFDnnZQyae+tvR2jPO2NacxjCFc/3swBZc7Msct3 - icsm18Lydw8q+7Fb6fl9UKjD0fV4VIcjaTa6QZruqnm6okEvxs8ENOoGOn9dRkkGsruOUU64lYBbpJmT - 4z3GD0JZFa+SKqXIrYXSDJtBtx+jPI/EBEWiNi8UfLqi8TMBDclDsot8ZMOhDR1DfOKbE4NfHYxL0Q1Z - CTm59lBu857Slns0VWNVMjvDAgigycwJpRnVZKR/dMcuakPI/R57RWbnVaLNr/xpGY23J9zFnMw5OJSk - Y5Qb7zZGXo+0OW1jvU+QlbR4DKbLQsXo0DKrpqnkrnKUQIULoJE0wzUb3RqNksVPJBoGRm8oXfFTRG52 - 8tDBvcP7h+Y0ZJ387HjHsex2uvspV9k+sXSzWFJnKam0lFRYSsotJWUsxCUW4kIL8VoL8SoLy5XmlsvN - LZeaWy4xt0xrI8wn9uju1DUyMiBh9MCxYwaOGzt4wrghkycOmzIpfsa0EbOSxsydPT5l/qRFC6dlLElc - sXR2Tub8/FULCvJT169JK1qfXlKYUVq0tKx4WXnJ8qcLy0/CaJQO3HRu87LnPZbIoDkMBi5Ctz5ibb3b - 2mqrSR2DshJ+9euQy2qYOX85+iY8l/kFEBkgSTNcM6SZbpunSVq6Q+xpXczdnsKIhK9bRdlKisryzJbI - qtqAyEZUVyByqitzaipXIWqrcg1RnVfHIn9jTX56WlJ0dPDAhP7rd609dfeEcXx+4pQgDn66v//lWOVx - uWynVNYokdVJZFUSWaVEViGRbWAhLRNLi8XSdWJpnliSJZasFEuWiyUZYkm6WEqR8SgksyzNfXr2iek1 - d87UeXOnzZ83IyU5KXXhrCVpc5dmLMhcsSg3J31NwcriotyK8jV1NUWbN23YvrV6z676/c1bDh/cfuzo - rhPH95w+2Xzm9IFzZw5cOHfowrnDF88fuXjhyKULRy9dPHb50vEriMsnrl4+ee3KqWtXT7189fTL185c - f/nsKy+fe+X6uRuvnH/1lQuv3rh488bF11699NrNy7duXrn12pXXb119/da1p8Zo1G3RrYgcGJlVm4VG - aseKjL8t/bgUJ9+1Icp8tYjPsPmspH0np16kVoQrMFrImzksgHyeTbkJFkDMsvKuGQUNFD+NpPlppSem - vH4KjF6dt3jUiP6u3s4zVyRuv7G1DSLz1G6h85QbkxxO2smaJbImiXSjRFrTQmSey6ViaZFYulYsybWU - ZFkauJzOuEwhZLRknqV5YM+IiOC5s6fMnQ06T0+en7hwQVLaojnpS5JXLFuYk52Wn7e8cH1WWUl+deW6 - ho2lTZsrdu2o27u74eD+piOHth/n6Xxq/9kzB86fPfhsMRqVARQ5PXw8Zi6fufXa1seyGF+w9fOtA24M - sDlvw5wycmsTUWYGA1xG5RM1OaoW0UXogivQhc/Vi9WKXoqEhAQUjHjLTGYOSwWfAZLNoKuhhQUNvmzU - yXnlH2zyfiCjczKTRw7vZ+9iO37+2MpjGzpisUCpZ91Mcj3tLN8vlW2VSOvF0hqxtFIirZBIOUVmUS6R - loilhWLparEkm+PyCkvJMkueyEaMlsxlXA4PC5g9a/Kc2VOhzkyaFyQuSoU0z1uWkZKVuTgvd+m6NStL - inIrNxTUQpoby7cxad64b++mQwe2Hj28A3Q+eXzPqVPNZ07tgzqfO3vwmWA0SjDoH/sE+cxeOXvLpS2d - YTG+BjYZRLY9b4vE2uAuNrfOR/iyJwwGVfE7rHyyWn4K02VMJROXhYkJVTNoUoBKoEKb8VPnJm0nLJ10 - HUXrMhKnjw4P8/Pv5Ts7a2bjpfpTd4+3hIm7aO03JrwyjinyPk6RDUQWSyvE0g1iKSiMgMGAKMNgrBVL - c2EwIMqWkuWWkqXgMsUjdTY8T7Q01/eIjAyZPXMy0Xn+3OkLkmcsTJkJaV4Gm7EydVV2+prVKwrXZ28o - y6+pWt9YX9K0uXLndibNB/ZtPnJo29HD208cY3SG2Th9qvns6f2/JKPhOtGWt7W3RcMpf1P+yd+f7CSL - 8WWrPlzFrMXZ1oosTKxRwheK8roWUW6/V8JKzDNV8MuY/xR6DJpAJC6jZkQNQPzwKIFSnk1b/IQ2g6qg - nd/k8IMFmhWV2mP0soyZSK78fT38wn2mp08pP1J68u5xYXTM6JL3iqIvRqmOKWS7JbItsBZiaTUUuYXI - jMssJLxTNhZlnsvGjBaPs+jp0j02NnJm0iTQmbMZUxfMn56aMnPxotkZ6fNXLIfNWLI6f+n6tbAZeVWV - a+s3FsM179hWvXvnxv3Nmzmnse3YkZ2g86kTe06d2At1PnN638/KaJQNYSQgfAERAdMWTSveW3z23tnO - UxhfuevertG3RrPOyDFr6+aWwgX1rQWtawOR0fEra6ksI+vLa7dRYmiXjGV1DMwkGnEZHsOIy1TOB5dR - aCbLTNtVhd2pn4fLj2od2ZnzUAeI7Rvm5mrvG+o9bl5C3uZV+99pNhQoWhOZJ7Upo7d93DTq2gjIMfMV - 2yTSRrG0ViytEhCZYzEjcqmlpMRSsl4sKWjtLh6JchuMthxg3kNlFh/Xf2bSxFkzJ0Ga586Zkjxv+sKU - RMblJfNWLk/Jzlycn7d03drM0uJVlVwGuKmhbFtT1c4ddc17IM1IArfCOB87suPk8d2I0yf3smzwZ2A0 - NsJ5+HrETYpLK0zbeGbjY+vFbbJ77xd7J92epLussznJFTlRSoZBFvqKlnzvUVO1vKV4/zinzAxGhhpV - fNSX0foT1jEo9yO/TAOfNCpnxGXTTuvPyWUDo1GUaH5rT0fVtQ4ZXfF++ZArgxxO2Mn2S2TbxYzFda1Z - 3CLHBiIXg8iWkgJLsdAmZxjxt9UfxTMszf17BAbop0waxXF54pxZk+cxLk9buCBxcSq4PHfFMuJyxlpY - 5uKcivKC2ur1jSwDrIQ0t7hmRmc4jeNHeXWG3/i5GP1E+iv84oI7BZiEY509aDGKyB2yuJUiUxeqE0Sm - Hja6q3zfjzbqoPWHphS1Syj3w9gnHTzSJpf5ytxT3Bn1pA5E9NhisZHZ2PHRtmmvTPE56y0/KpXuFku3 - iKX1ltJaS6bFZI0pWuSYERlyDCKvs5SsBpEtxJkW4hWWYuR7HRIZ9tkCoqwxGzQwOmnG+KTE8QYuz52S - PH86ShmLU2cxLi9Nyc5q4XJRzoay1bXVqGaUbNm8YXtT1a6dTJoP7t986ACchoHOYDTUmfMbzySj8+7k - DX11qMclD5tTzBezBG8bNzoER8FbY4EWG+QYnREqXNAABqxFh7ULwwQXsr5oBaZeeFGmm5747TqoL2Ns - ATU5dLJpyIg/eER4JMazwGWDRj+W0flv5Q7DxcGnXGRHJIzCTWJJvSX6INIqS2mFpXQDF+WI1iwmX1Fo - KVljKcmzZCxeCSJbiJdZiDMsxEssERKEIfFr9cRytHlPt+4RYQHTpiYkzRhn4PLsSfPAZYPHmJWRPo/p - ctai/NwMrpSRXVEOLq+tryvewgrNVbt21DbvbtjfvAl0PnyQjDMzG/DOXDb4bDD6zLdnVt9ZDTvsf8Wf - VdqOClTYlMKtWfxIjuErULXAVBw/F9DOMBFfjWPuYrBSZivDoDjvlIWijMEXMhjUxkZ9mT9zi06DotzP - dJrrSSe4nlSCH/v1rTS69L3i6TemRpwPtT9hKzvcwt8GS0mtpaS6pZW3gevmMQpzUdbyBIwu4+S4iJPj - fF6OLcTLLcRLwWJhtMFoy/HmPb17BAR4j00YNmN6QuL0sTOZLk+YM3vy/DlTFyQj90tasnj20vR5K1cs - XJW9eHUecr8VJUWrKjasrmG6DC7DMleCy3t31+/b23CA0RlOo+noYVbWOH4UhTrmN34ZRpd9Ujb3rbnw - D75XfNkA8nFrpr97uYwOXrhN/oLC7bEYtbeSljoyZXooJbcz4dmKyEOVmJDDcUBEZOE2YMr6+IMQ6axJ - MhiYMKJZcTpzy/R4l6e+L/ixzG23Zyg7LJbuEUthgdGBJvJWCcjbwl9isSG45jTjMp6UWhi0eC2nxQZT - 0cLidCMi8398xGjLBPOeuu5+vl6jRw6ePm0MuAxdnpk0fs6siVziNy1lwYzFqTOXpM1ZvjQ5c+XCVTlp - BfnLCtdxud+G/NoqA5e3bqnYuZ1Z5uY9aANuOrBv0+EDTVweuJXU+RdmdBvMpYqEaXDDsnywPgg5ChQr - YI1JizvNYiooI9+T2cjopj1TItO5qej4wSnTHjQ6CBGz4uhhYyKfihg0yGx65tZPuin4SaktkoCzbdLW - hMI0ZcGVKSwkRRaSdRaSAjZrwRwFAkJMjqJdFgvYnWZpMbhnD0ez4CCfcQnDGJGnjeFEedxsiPIsZjAW - zJ+WujAxbREzGCuXL8jOhMFIX1uwvGh9ZlkJ2iXMLzfWF29phC6jAQguo9BMBQ20TrYgjjA6Q50NfuOX - ZnSb5DVVYeqAEIVhJ3gh5h1F+209o3Yfkj1FiALnNGAzpZG14O/p5ImM8gV/bip/ECJEuTMnmz0p6X7S - rxe1El9iMTG3JdigULGFuIibFVptIc4xF2dyAVNMdqIzFOYsh+Vk854h3buLu8VEh06dMmra1NHgciJE - OXHcrMTxs2dOnDdncvL8qakpMxalzkyHKC9LzlqxMJeJcgZnMJD45VZXFtTVol1CHqNiJ6sy13BchjQz - OpNxZt75GWW0qQTTZEUFy+vYMDKvwjQs2wk78chXzOPk2F6GPX7Yd8bLsfA8dlgLOiycTrIWHgAsPDe1 - Y1F+pnRZ+BYRteJvqaWBvDTrlm9hucrcMtOcTbytMBcvNxcvMxdnmIvTzcVp5q19cXvuwsIy0dy8d4/u - Vt0CA71HjhwwdTKIPGr61NEzpo9J4pwyRHnunEnJ86YsTJ6+aGFSetrs5UvhlBesyl6Un7dkbcEyTpRz - KpjBQOJXuKmhuGlz+fat8BhI/2ogzc170DdBEth4YF8jV9Zg3vnZYzSJL09eWAjoL/Xu+NIE2eHH5XVG - WoxJOOUApcxZhjNzsLuPWCy8nJo/ZATJHgbjcEIDv72dTrLmiUzlC6NzU5/KaVA/qS63YrR4nYUY5iHP - wjKHYy5HXjaxSUObGeaW6YahTcZiYbTK9Fox2mJiz57h3buru/n7ecUN6ztl0oipk0dOmzJqBog8LSFx - BucuZk2YByLPn7pwwfRFqSDyrGUZczOXp+Rkpebnpq0pWFq4bmVpcVZFWW5V5eqNNej7FW5uQBubcXnH - tiroMknzvj1IAuvBZU6dmUA/o4w2MJfMAy++IO/j0rk2R4dUk1WYG5JZyXAAKXrnbbIYdWT0RIR3N/AX - C9D2a9rhzh9NKyQybakUdq+fWVE2eq+IGG155raQt83R4w4YbTnb3HxAj+7u3RwcrCPC/MeMHDR50nCe - yFDkRCjyjLGzZ46bM3vivLmTFoDIKTPSQOQls5dlcIqctTAvJ23t6qXr1y0vKcoqL82pgihXr9lYC7Nc - tKWxdOuW8u1N4DJKGQabwei8t37/XqgzzMazz+gfxFyezhivV/ZlQoxrnnDsE09hOrCMv+GFDtQiFtOt - AuiJ0GkjGCOioxroHAHyyGQt+NoFT2S0SJ6d8sUT6buoTfI+ltEWU3v27NO9u2u3bt26BAV6DxvaZ9L4 - +MkT4idPHDFl8ohpU0bCWsyYNjpxxphZSePmzBo/b/ak+XOnLFwwbdHCGUsWJ2UsYdYia0XyqmxekZcX - F2aWl6J8kVdTVVBXs7YRotxY0rSJuIypjMpd25k079lFrhk1DczPPUeMbmdKs00JhpHAbidFoEKmYefI - 4igiYWpHFKZ7oCDE8MX8PUX8PTp0szpqb5hTFsoxqha0yZ0/R0B4JPvzS2Se9Z1itMXEHoy/7t3MLLt6 - eTpHRwWPGTVw4vi4iRPiJk2IY3I8eThYPGMaY3FSYsKspLGzZ42fO3vi/LmTU5KnpKZMX7KIM8gZc1cu - n5+dmZKbvWh13pJ1azIK1yHfA5FzKjesqq5YXVe9pmHj+s0NRVs2FYPL25qIyxXg8q4dVXsYnVFrRvyK - GK1OVavGqZR9lHJPOXp3dA4ynckJ/SUJ5o+SpTMjicL8yXB0chnm7FE+RiuEtBiFNzIVqL1h3z3JMfkK - tEXoKIE297k/kSA+g1/citEWST3Nh3fvGWEG8TUTd3VysgkM0PXvFzF+7JAJ44ZOHD904oRhkybGTWmh - 8PSpjMUQ4pkzwGJOi+dMTJ43KSV56qKF09NSEzl3PHvl8nlZK5Hppa7OXbxmdfq6NUuL168oLc6sKAOR - c2sqV9fVrKmv40SZ4/LWzdDlsu1N5eDyTtB5R9Vu5jSqn29Gwzao4pj5ZcxVSR97DjJ/LCfPX8rroMLo - SROF6XA4OryMvw0KrRA6+cmIxXQJCX9DhtGBDc8gN3/YjySytVZ7ejiFhuj79wtPGDVwPLcxz0Be8HcC - +BsPCZ46efj0qSOmc14iCRROTIApxp69eXMmcBRmjmJxKuco0mcuXzoHLM5mLF64OndRQX4aJ8fLS4tW - lpdkbSjDHi9Yi3yOyOsaN8IpF25phFkuAZe3NTEub99aDi7v3A6nAeP8q2A06md0ayR/wjR/fSR/Wq/w - HGQ69pRO5qTDDenkSFJhnsK8EMMXo1JBh2uRNeav0hG6Y35O+XnJ9J6U16KJE4ZOmjAMe0snM/GNnzqJ - kXfaFJCX09/p4O9ojr9j58waN2/O+OR5ExfMIy8xLS11evriRFAYQrxi2dyslfNzshbk5izMz11csDpt - XUFG0bplJUWQ45UbSjF3AV+RV1sFRS6or2WivKl+/SaIcmNR02ZwmdGZuLxjK5zGhl8bo5GzQW07fw4y - HXuKiU3iL2psdP4emni8CmO+gg405C/covO1yFHwV+n86lncqno3Y9rIxOmIUTNxunsSErmEObPGzp09 - bh7pL6tLTF64APydmrZo+pLFM9KXJC1Ln7Vi6ZxM5iXm5WQlrwKFV6UW5IHCS9avzShav7S4cHlpCViM - 2hvkGNts2b7auurVIHJD3dqGjevA5c2NnC4zj1GydUvpNhYGdf51Mhpu94nOQUaNGEUJHPJE50eSBJOR - 4I/gEx4VKRTiX6uj6Ixei+bPhW2YsGD+xJTkSakLJi9aOGXxwhbypiUuTZ+1fOmsFctmZy6fmw3+ZoK/ - KXmrmJdYw1Q4bf2a9MJ18MXLSgpXlBGLyxmLq9l+cShy3sYaVJMLGurWwF1sqmdc3tSwnuNyURPSP1Ln - fwVGP+k5yMKjeukISTo/kr+TT6jC/8oUNq5HL12SuCwjaXnGzBVLZ61chiwO4suRF+KbvSA3OyU/d+Hq - vNQ1+YvWrl7MqfAS7DksXr+0tGh5WTF88coNZVmV5YgcdvZBRW4NTj2AItfk19fCXTAuI4jLmxsQqMmR - Ov+LMfpJz0EW6q/QRfAdvH8pL9EZdTbMR+OomLyc5LxVC3AQy+rchQV58A+pHHmhv0yCib/FhcvKikHh - FeXsxBqc6YEDPcBi7hwPw/EdhlM7DFyuM3C5cSOKGLDM//KMplt7O38OstGxp8IDTzv/8v4LfqVoHaNt - WuHaJYiidenF6zOKuXOFuGAsxulCTIhL6ViarMoNWZwWG86hYUfRCE6gYR6jFn65oP7fjDY6geZJz0H+ - xUfnn9N3g6ikcCmCKMyRlwU2iLecr0SHKzFf0Zkzlf7N6HbPVGrveOlfaxXtl3pDiHgKC1j8w08J+zej - f/JTwn4ppjwv/98feKZSe+fe/ZvR/2b0L0z9fzP65zrd4Bd+of9l/vf/ZvS/Gf3rIvu/Gf1vRv+6GP3/ - AZ+4Ui+mkTlKAAAAAElFTkSuQmCC - - - \ No newline at end of file diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/App.config b/Solution/SQLQueryStress/src/SQLQueryStress/App.config deleted file mode 100644 index 928896d2..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/BlockedBoundedBuffer.cs b/Solution/SQLQueryStress/src/SQLQueryStress/BlockedBoundedBuffer.cs deleted file mode 100644 index 5b8f5376..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/BlockedBoundedBuffer.cs +++ /dev/null @@ -1,91 +0,0 @@ -#region - -using System.Threading; - -#endregion - -namespace SQLQueryStress -{ - public class BlockedBoundedBuffer - { - private readonly T[] _buffer; - private int _count; - - private int _readNumber; - private int _writeNumber; - - public BlockedBoundedBuffer(int bufferSize) - { - _buffer = new T[bufferSize]; - _readNumber = -1; - _writeNumber = -1; - _count = 0; - } - - public T Dequeue() - { - while (_count == 0) - { - lock (_buffer) - { - Monitor.Wait(_buffer); - } - } - - int read; - - do - { - read = Interlocked.Increment(ref _readNumber); - - if (read >= _buffer.Length) - { - lock (_buffer) - { - if (read >= _buffer.Length) - { - Interlocked.Exchange(ref _readNumber, 0); - Interlocked.Exchange(ref _writeNumber, -1); - Monitor.PulseAll(_buffer); - } - } - } - else - break; - } while (true); - - Interlocked.Decrement(ref _count); - - return _buffer[read]; - } - - public void Enqueue(T input) - { - int write; - - do - { - write = Interlocked.Increment(ref _writeNumber); - if (write >= _buffer.Length) - { - lock (_buffer) - { - Monitor.Wait(_buffer); - } - } - else - break; - } while (true); - - _buffer[write] = input; - - if (Interlocked.Increment(ref _count) == 1) - { - lock (_buffer) - { - Monitor.PulseAll(_buffer); - } - } - } - } -} \ No newline at end of file diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/DataViewer.Designer.cs b/Solution/SQLQueryStress/src/SQLQueryStress/DataViewer.Designer.cs deleted file mode 100644 index 486469ec..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/DataViewer.Designer.cs +++ /dev/null @@ -1,71 +0,0 @@ -namespace SQLQueryStress -{ - partial class DataViewer - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.dataGridView1 = new System.Windows.Forms.DataGridView(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); - this.SuspendLayout(); - // - // dataGridView1 - // - this.dataGridView1.AllowUserToAddRows = false; - this.dataGridView1.AllowUserToDeleteRows = false; - this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView1.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; - this.dataGridView1.Location = new System.Drawing.Point(12, 12); - this.dataGridView1.Name = "dataGridView1"; - this.dataGridView1.ReadOnly = true; - this.dataGridView1.ShowEditingIcon = false; - this.dataGridView1.Size = new System.Drawing.Size(629, 331); - this.dataGridView1.TabIndex = 0; - // - // DataViewer - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(653, 355); - this.Controls.Add(this.dataGridView1); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "DataViewer"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.Text = "Form2"; - this.Load += new System.EventHandler(this.Form2_Load); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.DataGridView dataGridView1; - } -} \ No newline at end of file diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/DataViewer.cs b/Solution/SQLQueryStress/src/SQLQueryStress/DataViewer.cs deleted file mode 100644 index 63bbd70e..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/DataViewer.cs +++ /dev/null @@ -1,35 +0,0 @@ -#region - -using System; -using System.Data; -using System.Windows.Forms; - -#endregion - -namespace SQLQueryStress -{ - public partial class DataViewer : Form - { - public DataViewer() - { - InitializeComponent(); - } - - public DataTable DataView { get; set; } - - private void Form2_Load(object sender, EventArgs e) - { - dataGridView1.DataSource = DataView; - - var columnWidth = (dataGridView1.Width - 41) / DataView.Columns.Count; - - foreach (DataGridViewColumn col in dataGridView1.Columns) - col.Width = columnWidth; - } - - public void Repaint() - { - dataGridView1.Invalidate(); - } - } -} \ No newline at end of file diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/DataViewer.resx b/Solution/SQLQueryStress/src/SQLQueryStress/DataViewer.resx deleted file mode 100644 index 19dc0dd8..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/DataViewer.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/DatabaseSelect.Designer.cs b/Solution/SQLQueryStress/src/SQLQueryStress/DatabaseSelect.Designer.cs deleted file mode 100644 index 8b452de1..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/DatabaseSelect.Designer.cs +++ /dev/null @@ -1,406 +0,0 @@ -namespace SQLQueryStress -{ - partial class DatabaseSelect - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.label1 = new System.Windows.Forms.Label(); - this.server_textBox = new System.Windows.Forms.TextBox(); - this.authentication_comboBox = new System.Windows.Forms.ComboBox(); - this.login_textBox = new System.Windows.Forms.TextBox(); - this.password_textBox = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.cancel_button = new System.Windows.Forms.Button(); - this.test_button = new System.Windows.Forms.Button(); - this.ok_button = new System.Windows.Forms.Button(); - this.db_comboBox = new System.Windows.Forms.ComboBox(); - this.label5 = new System.Windows.Forms.Label(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.pm_test_button = new System.Windows.Forms.Button(); - this.shareSettings_checkBox = new System.Windows.Forms.CheckBox(); - this.pm_db_comboBox = new System.Windows.Forms.ComboBox(); - this.label6 = new System.Windows.Forms.Label(); - this.pm_password_textBox = new System.Windows.Forms.TextBox(); - this.label7 = new System.Windows.Forms.Label(); - this.pm_server_textBox = new System.Windows.Forms.TextBox(); - this.label8 = new System.Windows.Forms.Label(); - this.label9 = new System.Windows.Forms.Label(); - this.pm_login_textBox = new System.Windows.Forms.TextBox(); - this.pm_authentication_comboBox = new System.Windows.Forms.ComboBox(); - this.label10 = new System.Windows.Forms.Label(); - this.groupBox1.SuspendLayout(); - this.groupBox2.SuspendLayout(); - this.SuspendLayout(); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label1.Location = new System.Drawing.Point(6, 39); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(44, 13); - this.label1.TabIndex = 0; - this.label1.Text = "Server"; - // - // server_textBox - // - this.server_textBox.Location = new System.Drawing.Point(9, 55); - this.server_textBox.Name = "server_textBox"; - this.server_textBox.Size = new System.Drawing.Size(231, 20); - this.server_textBox.TabIndex = 1; - // - // authentication_comboBox - // - this.authentication_comboBox.FormattingEnabled = true; - this.authentication_comboBox.Items.AddRange(new object[] { - "Integrated Authentication", - "SQL Server Authentication"}); - this.authentication_comboBox.Location = new System.Drawing.Point(9, 94); - this.authentication_comboBox.Name = "authentication_comboBox"; - this.authentication_comboBox.Size = new System.Drawing.Size(231, 21); - this.authentication_comboBox.TabIndex = 2; - // - // login_textBox - // - this.login_textBox.Location = new System.Drawing.Point(9, 134); - this.login_textBox.Name = "login_textBox"; - this.login_textBox.Size = new System.Drawing.Size(231, 20); - this.login_textBox.TabIndex = 3; - // - // password_textBox - // - this.password_textBox.Location = new System.Drawing.Point(9, 173); - this.password_textBox.Name = "password_textBox"; - this.password_textBox.Size = new System.Drawing.Size(231, 20); - this.password_textBox.TabIndex = 4; - this.password_textBox.UseSystemPasswordChar = true; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label2.Location = new System.Drawing.Point(9, 157); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(61, 13); - this.label2.TabIndex = 5; - this.label2.Text = "Password"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label3.Location = new System.Drawing.Point(6, 118); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(38, 13); - this.label3.TabIndex = 6; - this.label3.Text = "Login"; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label4.Location = new System.Drawing.Point(6, 78); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(89, 13); - this.label4.TabIndex = 7; - this.label4.Text = "Authentication"; - // - // cancel_button - // - this.cancel_button.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancel_button.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.cancel_button.Location = new System.Drawing.Point(430, 286); - this.cancel_button.Name = "cancel_button"; - this.cancel_button.Size = new System.Drawing.Size(80, 23); - this.cancel_button.TabIndex = 8; - this.cancel_button.Text = "Cancel"; - this.cancel_button.UseVisualStyleBackColor = true; - this.cancel_button.Click += new System.EventHandler(this.cancel_button_Click); - // - // test_button - // - this.test_button.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.test_button.Location = new System.Drawing.Point(120, 239); - this.test_button.Name = "test_button"; - this.test_button.Size = new System.Drawing.Size(120, 23); - this.test_button.TabIndex = 9; - this.test_button.Text = "Test Connection"; - this.test_button.UseVisualStyleBackColor = true; - this.test_button.Click += new System.EventHandler(this.test_button_Click); - // - // ok_button - // - this.ok_button.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.ok_button.Location = new System.Drawing.Point(344, 286); - this.ok_button.Name = "ok_button"; - this.ok_button.Size = new System.Drawing.Size(80, 23); - this.ok_button.TabIndex = 10; - this.ok_button.Text = "OK"; - this.ok_button.UseVisualStyleBackColor = true; - this.ok_button.Click += new System.EventHandler(this.ok_button_Click); - // - // db_comboBox - // - this.db_comboBox.FormattingEnabled = true; - this.db_comboBox.Location = new System.Drawing.Point(9, 212); - this.db_comboBox.Name = "db_comboBox"; - this.db_comboBox.Size = new System.Drawing.Size(231, 21); - this.db_comboBox.TabIndex = 11; - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label5.Location = new System.Drawing.Point(6, 196); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(106, 13); - this.label5.TabIndex = 12; - this.label5.Text = "Default Database"; - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.db_comboBox); - this.groupBox1.Controls.Add(this.label5); - this.groupBox1.Controls.Add(this.password_textBox); - this.groupBox1.Controls.Add(this.test_button); - this.groupBox1.Controls.Add(this.label2); - this.groupBox1.Controls.Add(this.server_textBox); - this.groupBox1.Controls.Add(this.label1); - this.groupBox1.Controls.Add(this.label4); - this.groupBox1.Controls.Add(this.login_textBox); - this.groupBox1.Controls.Add(this.authentication_comboBox); - this.groupBox1.Controls.Add(this.label3); - this.groupBox1.Location = new System.Drawing.Point(12, 12); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(246, 268); - this.groupBox1.TabIndex = 13; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "Main Load Settings"; - // - // groupBox2 - // - this.groupBox2.Controls.Add(this.pm_test_button); - this.groupBox2.Controls.Add(this.shareSettings_checkBox); - this.groupBox2.Controls.Add(this.pm_db_comboBox); - this.groupBox2.Controls.Add(this.label6); - this.groupBox2.Controls.Add(this.pm_password_textBox); - this.groupBox2.Controls.Add(this.label7); - this.groupBox2.Controls.Add(this.pm_server_textBox); - this.groupBox2.Controls.Add(this.label8); - this.groupBox2.Controls.Add(this.label9); - this.groupBox2.Controls.Add(this.pm_login_textBox); - this.groupBox2.Controls.Add(this.pm_authentication_comboBox); - this.groupBox2.Controls.Add(this.label10); - this.groupBox2.Location = new System.Drawing.Point(264, 12); - this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(246, 268); - this.groupBox2.TabIndex = 14; - this.groupBox2.TabStop = false; - this.groupBox2.Text = "Parameterization Settings"; - // - // pm_test_button - // - this.pm_test_button.Enabled = false; - this.pm_test_button.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.pm_test_button.Location = new System.Drawing.Point(123, 239); - this.pm_test_button.Name = "pm_test_button"; - this.pm_test_button.Size = new System.Drawing.Size(120, 23); - this.pm_test_button.TabIndex = 15; - this.pm_test_button.Text = "Test Connection"; - this.pm_test_button.UseVisualStyleBackColor = true; - this.pm_test_button.Click += new System.EventHandler(this.pm_test_button_Click); - // - // shareSettings_checkBox - // - this.shareSettings_checkBox.AutoSize = true; - this.shareSettings_checkBox.Checked = true; - this.shareSettings_checkBox.CheckState = System.Windows.Forms.CheckState.Checked; - this.shareSettings_checkBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.shareSettings_checkBox.Location = new System.Drawing.Point(12, 19); - this.shareSettings_checkBox.Name = "shareSettings_checkBox"; - this.shareSettings_checkBox.Size = new System.Drawing.Size(177, 17); - this.shareSettings_checkBox.TabIndex = 13; - this.shareSettings_checkBox.Text = "Share Connection Settings"; - this.shareSettings_checkBox.UseVisualStyleBackColor = true; - this.shareSettings_checkBox.CheckedChanged += new System.EventHandler(this.shareSettings_checkBox_CheckedChanged); - // - // pm_db_comboBox - // - this.pm_db_comboBox.Enabled = false; - this.pm_db_comboBox.FormattingEnabled = true; - this.pm_db_comboBox.Location = new System.Drawing.Point(9, 212); - this.pm_db_comboBox.Name = "pm_db_comboBox"; - this.pm_db_comboBox.Size = new System.Drawing.Size(231, 21); - this.pm_db_comboBox.TabIndex = 11; - // - // label6 - // - this.label6.AutoSize = true; - this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label6.Location = new System.Drawing.Point(6, 196); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(106, 13); - this.label6.TabIndex = 12; - this.label6.Text = "Default Database"; - // - // pm_password_textBox - // - this.pm_password_textBox.Enabled = false; - this.pm_password_textBox.Location = new System.Drawing.Point(9, 173); - this.pm_password_textBox.Name = "pm_password_textBox"; - this.pm_password_textBox.Size = new System.Drawing.Size(231, 20); - this.pm_password_textBox.TabIndex = 4; - this.pm_password_textBox.UseSystemPasswordChar = true; - // - // label7 - // - this.label7.AutoSize = true; - this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label7.Location = new System.Drawing.Point(9, 157); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(61, 13); - this.label7.TabIndex = 5; - this.label7.Text = "Password"; - // - // pm_server_textBox - // - this.pm_server_textBox.Enabled = false; - this.pm_server_textBox.Location = new System.Drawing.Point(9, 55); - this.pm_server_textBox.Name = "pm_server_textBox"; - this.pm_server_textBox.Size = new System.Drawing.Size(231, 20); - this.pm_server_textBox.TabIndex = 1; - // - // label8 - // - this.label8.AutoSize = true; - this.label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label8.Location = new System.Drawing.Point(6, 39); - this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(44, 13); - this.label8.TabIndex = 0; - this.label8.Text = "Server"; - // - // label9 - // - this.label9.AutoSize = true; - this.label9.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label9.Location = new System.Drawing.Point(6, 78); - this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(89, 13); - this.label9.TabIndex = 7; - this.label9.Text = "Authentication"; - // - // pm_login_textBox - // - this.pm_login_textBox.Enabled = false; - this.pm_login_textBox.Location = new System.Drawing.Point(9, 134); - this.pm_login_textBox.Name = "pm_login_textBox"; - this.pm_login_textBox.Size = new System.Drawing.Size(231, 20); - this.pm_login_textBox.TabIndex = 3; - // - // pm_authentication_comboBox - // - this.pm_authentication_comboBox.Enabled = false; - this.pm_authentication_comboBox.FormattingEnabled = true; - this.pm_authentication_comboBox.Items.AddRange(new object[] { - "Integrated Authentication", - "SQL Server Authentication"}); - this.pm_authentication_comboBox.Location = new System.Drawing.Point(9, 94); - this.pm_authentication_comboBox.Name = "pm_authentication_comboBox"; - this.pm_authentication_comboBox.Size = new System.Drawing.Size(231, 21); - this.pm_authentication_comboBox.TabIndex = 2; - // - // label10 - // - this.label10.AutoSize = true; - this.label10.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label10.Location = new System.Drawing.Point(6, 118); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(38, 13); - this.label10.TabIndex = 6; - this.label10.Text = "Login"; - // - // DatabaseSelect - // - this.AcceptButton = this.ok_button; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.cancel_button; - this.ClientSize = new System.Drawing.Size(524, 320); - this.Controls.Add(this.groupBox2); - this.Controls.Add(this.groupBox1); - this.Controls.Add(this.ok_button); - this.Controls.Add(this.cancel_button); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "DatabaseSelect"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.Text = "Database Select"; - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); - this.groupBox2.ResumeLayout(false); - this.groupBox2.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Label label1; - private System.Windows.Forms.TextBox server_textBox; - private System.Windows.Forms.ComboBox authentication_comboBox; - private System.Windows.Forms.TextBox login_textBox; - private System.Windows.Forms.TextBox password_textBox; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.Button cancel_button; - private System.Windows.Forms.Button test_button; - private System.Windows.Forms.Button ok_button; - private System.Windows.Forms.ComboBox db_comboBox; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.GroupBox groupBox2; - private System.Windows.Forms.CheckBox shareSettings_checkBox; - private System.Windows.Forms.ComboBox pm_db_comboBox; - private System.Windows.Forms.Label label6; - private System.Windows.Forms.TextBox pm_password_textBox; - private System.Windows.Forms.Label label7; - private System.Windows.Forms.TextBox pm_server_textBox; - private System.Windows.Forms.Label label8; - private System.Windows.Forms.Label label9; - private System.Windows.Forms.TextBox pm_login_textBox; - private System.Windows.Forms.ComboBox pm_authentication_comboBox; - private System.Windows.Forms.Label label10; - private System.Windows.Forms.Button pm_test_button; - } -} \ No newline at end of file diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/DatabaseSelect.cs b/Solution/SQLQueryStress/src/SQLQueryStress/DatabaseSelect.cs deleted file mode 100644 index 20601b97..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/DatabaseSelect.cs +++ /dev/null @@ -1,406 +0,0 @@ -#region - -using System; -using System.Collections.Generic; -using System.Data.SqlClient; -using System.Windows.Forms; -using SQLQueryStress.Properties; - -#endregion - -namespace SQLQueryStress -{ - public partial class DatabaseSelect : Form - { - private readonly ConnectionInfo _localMainConnectionInfo; - private readonly Form1.QueryStressSettings _settings; - private ConnectionInfo _localParamConnectionInfo; - - public DatabaseSelect(Form1.QueryStressSettings settings) - { - _settings = settings; - _localMainConnectionInfo = (ConnectionInfo) settings.MainDbConnectionInfo.Clone(); - - if (settings.ShareDbSettings) - { - _localParamConnectionInfo = (ConnectionInfo) settings.MainDbConnectionInfo.Clone(); - } - else - { - _localParamConnectionInfo = (ConnectionInfo) settings.ParamDbConnectionInfo.Clone(); - } - - InitializeComponent(); - - server_textBox.Text = _localMainConnectionInfo.Server; - - if (_localMainConnectionInfo.IntegratedAuth) - { - authentication_comboBox.SelectedIndex = 0; - login_textBox.Enabled = false; - password_textBox.Enabled = false; - } - else - { - authentication_comboBox.SelectedIndex = 1; - login_textBox.Text = _localMainConnectionInfo.Login; - password_textBox.Text = _localMainConnectionInfo.Password; - } - - if (_localMainConnectionInfo.Database.Length > 0) - { - db_comboBox.Items.Add(_localMainConnectionInfo.Database); - db_comboBox.SelectedIndex = 0; - } - - if (!settings.ShareDbSettings) - { - pm_server_textBox.Text = _localParamConnectionInfo.Server; - - if (_localParamConnectionInfo.IntegratedAuth) - { - pm_authentication_comboBox.SelectedIndex = 0; - pm_login_textBox.Enabled = false; - pm_password_textBox.Enabled = false; - } - else - { - pm_authentication_comboBox.SelectedIndex = 1; - pm_login_textBox.Text = _localParamConnectionInfo.Login; - pm_password_textBox.Text = _localParamConnectionInfo.Password; - } - - if (_localParamConnectionInfo.Database.Length > 0) - { - pm_db_comboBox.Items.Add(_localParamConnectionInfo.Database); - pm_db_comboBox.SelectedIndex = 0; - } - } - else - pm_authentication_comboBox.SelectedIndex = 0; - - shareSettings_checkBox.Checked = settings.ShareDbSettings; - - authentication_comboBox.SelectedIndexChanged += authentication_comboBox_SelectedIndexChanged; - pm_authentication_comboBox.SelectedIndexChanged += pm_authentication_comboBox_SelectedIndexChanged; - - db_comboBox.Click += db_comboBox_Click; - pm_db_comboBox.Click += pm_db_comboBox_Click; - } - - private void authentication_comboBox_SelectedIndexChanged(object sender, EventArgs e) - { - if (authentication_comboBox.SelectedIndex == 0) - { - login_textBox.Enabled = false; - password_textBox.Enabled = false; - } - else - { - login_textBox.Enabled = true; - password_textBox.Enabled = true; - } - } - - private void cancel_button_Click(object sender, EventArgs e) - { - Dispose(); - } - - private void db_comboBox_Click(object sender, EventArgs e) - { - SaveLocalSettings(); - - var selectedItem = (string) db_comboBox.SelectedItem; - - var sql = "" + "SELECT name " + "FROM master..sysdatabases " + "ORDER BY name"; - - using (var conn = new SqlConnection(_localMainConnectionInfo.ConnectionString)) - { - var comm = new SqlCommand(sql, conn); - - var databases = new List(); - - try - { - conn.Open(); - - var reader = comm.ExecuteReader(); - - while (reader.Read()) - { - databases.Add((string) reader[0]); - } - } - catch (SqlException ex) - { - if (ex.Number != 4060) - MessageBox.Show(Resources.ConnFail); - else - { - //Clear the db, try again - db_comboBox.Items.Clear(); - db_comboBox_Click(null, null); - return; - } - } - - db_comboBox.DataSource = databases.ToArray(); - - if (selectedItem != null) - if (db_comboBox.Items.Contains(selectedItem)) - db_comboBox.SelectedItem = selectedItem; - } - } - - private void ok_button_Click(object sender, EventArgs e) - { - SaveLocalSettings(); - pm_saveLocalSettings(); - - _localMainConnectionInfo.CopyTo(_settings.MainDbConnectionInfo); - _localParamConnectionInfo.CopyTo(_settings.ParamDbConnectionInfo); - _settings.ShareDbSettings = shareSettings_checkBox.Checked; - - Dispose(); - } - - private void pm_authentication_comboBox_SelectedIndexChanged(object sender, EventArgs e) - { - if (pm_authentication_comboBox.SelectedIndex == 0) - { - pm_login_textBox.Enabled = false; - pm_password_textBox.Enabled = false; - } - else - { - pm_login_textBox.Enabled = true; - pm_password_textBox.Enabled = true; - } - } - - private void pm_db_comboBox_Click(object sender, EventArgs e) - { - pm_saveLocalSettings(); - - var selectedItem = (string) pm_db_comboBox.SelectedItem; - - var sql = "" + "SELECT name " + "FROM master..sysdatabases " + "ORDER BY name"; - - using (var conn = new SqlConnection(_localParamConnectionInfo.ConnectionString)) - { - var comm = new SqlCommand(sql, conn); - - var databases = new List(); - - try - { - conn.Open(); - - var reader = comm.ExecuteReader(); - - while (reader.Read()) - databases.Add((string) reader[0]); - } - catch (SqlException ex) - { - if (ex.Number != 4060) - MessageBox.Show(Resources.ConnFail); - else - { - //Clear the db, try again - pm_db_comboBox.Items.Clear(); - pm_db_comboBox_Click(null, null); - return; - } - } - - pm_db_comboBox.DataSource = databases.ToArray(); - - if (selectedItem != null) - if (pm_db_comboBox.Items.Contains(selectedItem)) - pm_db_comboBox.SelectedItem = selectedItem; - } - } - - private void pm_saveLocalSettings() - { - if (!shareSettings_checkBox.Checked) - { - _localParamConnectionInfo.Server = pm_server_textBox.Text; - _localParamConnectionInfo.IntegratedAuth = pm_authentication_comboBox.SelectedIndex == 0; - - if (_localParamConnectionInfo.IntegratedAuth) - { - _localParamConnectionInfo.Login = ""; - _localParamConnectionInfo.Password = ""; - } - else - { - _localParamConnectionInfo.Login = pm_login_textBox.Text; - _localParamConnectionInfo.Password = pm_password_textBox.Text; - } - - _localParamConnectionInfo.Database = pm_db_comboBox.SelectedItem != null ? pm_db_comboBox.SelectedItem.ToString() : ""; - } - else - _localParamConnectionInfo = new ConnectionInfo(); - } - - private void pm_test_button_Click(object sender, EventArgs e) - { - pm_saveLocalSettings(); - - MessageBox.Show(_localParamConnectionInfo.TestConnection() ? Resources.ConnSucc : Resources.ConnFail); - } - - private void SaveLocalSettings() - { - _localMainConnectionInfo.Server = server_textBox.Text; - _localMainConnectionInfo.IntegratedAuth = authentication_comboBox.SelectedIndex == 0; - - if (_localMainConnectionInfo.IntegratedAuth) - { - _localMainConnectionInfo.Login = ""; - _localMainConnectionInfo.Password = ""; - } - else - { - _localMainConnectionInfo.Login = login_textBox.Text; - _localMainConnectionInfo.Password = password_textBox.Text; - } - - _localMainConnectionInfo.Database = db_comboBox.SelectedItem != null ? db_comboBox.SelectedItem.ToString() : ""; - } - - private void shareSettings_checkBox_CheckedChanged(object sender, EventArgs e) - { - if (shareSettings_checkBox.Checked) - { - pm_server_textBox.Enabled = false; - pm_authentication_comboBox.Enabled = false; - pm_login_textBox.Enabled = false; - pm_password_textBox.Enabled = false; - pm_db_comboBox.Enabled = false; - pm_test_button.Enabled = false; - } - else - { - pm_server_textBox.Enabled = true; - pm_authentication_comboBox.Enabled = true; - - if (pm_authentication_comboBox.SelectedIndex == 1) - { - pm_login_textBox.Enabled = true; - pm_password_textBox.Enabled = true; - } - pm_db_comboBox.Enabled = true; - pm_test_button.Enabled = true; - } - } - - private void test_button_Click(object sender, EventArgs e) - { - SaveLocalSettings(); - - MessageBox.Show(_localMainConnectionInfo.TestConnection() ? Resources.ConnSucc : Resources.ConnFail); - } - - [Serializable] - public class ConnectionInfo : ICloneable - { - public string Database; - public bool IntegratedAuth; - public string Login; - public string Password; - - public string Server; - public Form1.QueryStressSettings Settings; - - public ConnectionInfo() - { - Server = ""; - IntegratedAuth = true; - Login = ""; - Password = ""; - Database = ""; - } - - public ConnectionInfo(Form1.QueryStressSettings settings) - { - Server = ""; - IntegratedAuth = true; - Login = ""; - Password = ""; - Database = ""; - Settings = settings; - } - - public string ConnectionString - { - get - { - var build = new SqlConnectionStringBuilder {DataSource = Server, IntegratedSecurity = IntegratedAuth}; - if (!IntegratedAuth) - { - build.UserID = Login; - build.Password = Password; - } - - if (Database.Length > 0) - build.InitialCatalog = Database; - - if (Settings != null) - { - build.ConnectTimeout = Settings.ConnectionTimeout; - build.Pooling = Settings.EnableConnectionPooling; - build.MaxPoolSize = Settings.NumThreads * 2; - } - - return build.ConnectionString; - } - } - - #region ICloneable Members - - public object Clone() - { - var newConnInfo = new ConnectionInfo(); - CopyTo(newConnInfo); - - return newConnInfo; - } - - #endregion - - public void CopyTo(ConnectionInfo to) - { - to.Server = Server; - to.IntegratedAuth = IntegratedAuth; - to.Login = Login; - to.Password = Password; - to.Database = Database; - } - - public bool TestConnection() - { - if ((Server == "") || ((IntegratedAuth == false) && (Login == "" || Password == ""))) - return false; - - using (var conn = new SqlConnection(ConnectionString)) - { - try - { - conn.Open(); - } - catch - { - return false; - } - } - - return true; - } - } - } -} \ No newline at end of file diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/DatabaseSelect.resx b/Solution/SQLQueryStress/src/SQLQueryStress/DatabaseSelect.resx deleted file mode 100644 index 19dc0dd8..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/DatabaseSelect.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/Form1.Designer.cs b/Solution/SQLQueryStress/src/SQLQueryStress/Form1.Designer.cs deleted file mode 100644 index 3619e38d..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/Form1.Designer.cs +++ /dev/null @@ -1,766 +0,0 @@ -using System.Windows.Forms; - -namespace SQLQueryStress -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (backgroundWorker1.CancellationPending) - System.Windows.Forms.MessageBox.Show("Please wait while background threads are cancelled."); - else if (backgroundWorker1.IsBusy) - { - if (System.Windows.Forms.MessageBox.Show( - "A test is currently running. Cancel and shut down?", - "Really Close?", - System.Windows.Forms.MessageBoxButtons.YesNo, - System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) - { - cancel_button_Click(new System.String(' ', 0), null); - } - } - else - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); - this.query_textBox = new System.Windows.Forms.RichTextBox(); - this.label1 = new System.Windows.Forms.Label(); - this.menuStrip1 = new System.Windows.Forms.MenuStrip(); - this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); - this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.saveSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.loadSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.go_button = new System.Windows.Forms.Button(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.iterations_numericUpDown = new System.Windows.Forms.NumericUpDown(); - this.threads_numericUpDown = new System.Windows.Forms.NumericUpDown(); - this.cancel_button = new System.Windows.Forms.Button(); - this.label4 = new System.Windows.Forms.Label(); - this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker(); - this.label5 = new System.Windows.Forms.Label(); - this.avgSeconds_textBox = new System.Windows.Forms.Label(); - this.progressBar1 = new System.Windows.Forms.ProgressBar(); - this.label6 = new System.Windows.Forms.Label(); - this.label7 = new System.Windows.Forms.Label(); - this.totalExceptions_textBox = new System.Windows.Forms.Label(); - this.mainUITimer = new System.Windows.Forms.Timer(this.components); - this.label8 = new System.Windows.Forms.Label(); - this.elapsedTime_textBox = new System.Windows.Forms.Label(); - this.perfCounterTimer = new System.Windows.Forms.Timer(this.components); - this.database_button = new System.Windows.Forms.Button(); - this.iterationsSecond_textBox = new System.Windows.Forms.Label(); - this.exceptions_button = new System.Windows.Forms.Button(); - this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.label9 = new System.Windows.Forms.Label(); - this.cpuTime_textBox = new System.Windows.Forms.Label(); - this.label10 = new System.Windows.Forms.Label(); - this.actualSeconds_textBox = new System.Windows.Forms.Label(); - this.label12 = new System.Windows.Forms.Label(); - this.logicalReads_textBox = new System.Windows.Forms.Label(); - this.db_label = new System.Windows.Forms.Label(); - this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); - this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); - this.param_button = new System.Windows.Forms.Button(); - this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel(); - this.btnFreeCache = new System.Windows.Forms.Button(); - this.btnCleanBuffer = new System.Windows.Forms.Button(); - this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); - this.menuStrip1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.iterations_numericUpDown)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.threads_numericUpDown)).BeginInit(); - this.tableLayoutPanel1.SuspendLayout(); - this.flowLayoutPanel1.SuspendLayout(); - this.tableLayoutPanel2.SuspendLayout(); - this.tableLayoutPanel4.SuspendLayout(); - this.tableLayoutPanel3.SuspendLayout(); - this.SuspendLayout(); - // - // query_textBox - // - this.query_textBox.AcceptsTab = true; - this.query_textBox.AllowDrop = true; - this.query_textBox.Dock = System.Windows.Forms.DockStyle.Fill; - this.query_textBox.Location = new System.Drawing.Point(3, 3); - this.query_textBox.Name = "query_textBox"; - this.query_textBox.Size = new System.Drawing.Size(317, 354); - this.query_textBox.TabIndex = 0; - this.query_textBox.Text = ""; - this.query_textBox.WordWrap = false; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label1.Location = new System.Drawing.Point(9, 32); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(40, 13); - this.label1.TabIndex = 1; - this.label1.Text = "Query"; - // - // menuStrip1 - // - this.menuStrip1.BackColor = System.Drawing.SystemColors.MenuBar; - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.fileToolStripMenuItem, - this.helpToolStripMenuItem}); - this.menuStrip1.Location = new System.Drawing.Point(0, 0); - this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(733, 24); - this.menuStrip1.TabIndex = 2; - this.menuStrip1.Text = "menuStrip1"; - // - // fileToolStripMenuItem - // - this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripSeparator1, - this.optionsToolStripMenuItem, - this.saveSettingsToolStripMenuItem, - this.loadSettingsToolStripMenuItem, - this.exitToolStripMenuItem}); - this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; - this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); - this.fileToolStripMenuItem.Text = "File"; - // - // toolStripSeparator1 - // - this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(142, 6); - // - // optionsToolStripMenuItem - // - this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; - this.optionsToolStripMenuItem.Size = new System.Drawing.Size(145, 22); - this.optionsToolStripMenuItem.Text = "Options"; - this.optionsToolStripMenuItem.Click += new System.EventHandler(this.optionsToolStripMenuItem_Click); - // - // saveSettingsToolStripMenuItem - // - this.saveSettingsToolStripMenuItem.Name = "saveSettingsToolStripMenuItem"; - this.saveSettingsToolStripMenuItem.Size = new System.Drawing.Size(145, 22); - this.saveSettingsToolStripMenuItem.Text = "Save Settings"; - this.saveSettingsToolStripMenuItem.Click += new System.EventHandler(this.saveSettingsToolStripMenuItem_Click); - // - // loadSettingsToolStripMenuItem - // - this.loadSettingsToolStripMenuItem.Name = "loadSettingsToolStripMenuItem"; - this.loadSettingsToolStripMenuItem.Size = new System.Drawing.Size(145, 22); - this.loadSettingsToolStripMenuItem.Text = "Load Settings"; - this.loadSettingsToolStripMenuItem.Click += new System.EventHandler(this.loadSettingsToolStripMenuItem_Click); - // - // exitToolStripMenuItem - // - this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; - this.exitToolStripMenuItem.Size = new System.Drawing.Size(145, 22); - this.exitToolStripMenuItem.Text = "Exit"; - this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); - // - // helpToolStripMenuItem - // - this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.aboutToolStripMenuItem}); - this.helpToolStripMenuItem.Name = "helpToolStripMenuItem"; - this.helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20); - this.helpToolStripMenuItem.Text = "Help"; - // - // aboutToolStripMenuItem - // - this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; - this.aboutToolStripMenuItem.Size = new System.Drawing.Size(107, 22); - this.aboutToolStripMenuItem.Text = "About"; - this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click); - // - // go_button - // - this.go_button.Dock = System.Windows.Forms.DockStyle.Fill; - this.go_button.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.go_button.Location = new System.Drawing.Point(3, 3); - this.go_button.Name = "go_button"; - this.go_button.Size = new System.Drawing.Size(92, 40); - this.go_button.TabIndex = 3; - this.go_button.Text = "GO"; - this.go_button.UseVisualStyleBackColor = true; - this.go_button.Click += new System.EventHandler(this.go_button_Click); - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Dock = System.Windows.Forms.DockStyle.Fill; - this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label2.Location = new System.Drawing.Point(3, 152); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(196, 14); - this.label2.TabIndex = 5; - this.label2.Text = "Number of Iterations"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Dock = System.Windows.Forms.DockStyle.Fill; - this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label3.Location = new System.Drawing.Point(3, 202); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(196, 14); - this.label3.TabIndex = 7; - this.label3.Text = "Number of Threads"; - // - // iterations_numericUpDown - // - this.iterations_numericUpDown.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.iterations_numericUpDown.Location = new System.Drawing.Point(3, 169); - this.iterations_numericUpDown.Maximum = new decimal(new int[] { - 100000, - 0, - 0, - 0}); - this.iterations_numericUpDown.Minimum = new decimal(new int[] { - 1, - 0, - 0, - 0}); - this.iterations_numericUpDown.Name = "iterations_numericUpDown"; - this.iterations_numericUpDown.Size = new System.Drawing.Size(196, 20); - this.iterations_numericUpDown.TabIndex = 8; - this.iterations_numericUpDown.Value = new decimal(new int[] { - 1, - 0, - 0, - 0}); - // - // threads_numericUpDown - // - this.threads_numericUpDown.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.threads_numericUpDown.Location = new System.Drawing.Point(3, 219); - this.threads_numericUpDown.Maximum = new decimal(new int[] { - 200, - 0, - 0, - 0}); - this.threads_numericUpDown.Minimum = new decimal(new int[] { - 1, - 0, - 0, - 0}); - this.threads_numericUpDown.Name = "threads_numericUpDown"; - this.threads_numericUpDown.Size = new System.Drawing.Size(196, 20); - this.threads_numericUpDown.TabIndex = 9; - this.threads_numericUpDown.Value = new decimal(new int[] { - 1, - 0, - 0, - 0}); - // - // cancel_button - // - this.cancel_button.Dock = System.Windows.Forms.DockStyle.Fill; - this.cancel_button.Enabled = false; - this.cancel_button.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.cancel_button.Location = new System.Drawing.Point(101, 3); - this.cancel_button.Name = "cancel_button"; - this.cancel_button.Size = new System.Drawing.Size(92, 40); - this.cancel_button.TabIndex = 11; - this.cancel_button.Text = "Cancel"; - this.cancel_button.UseVisualStyleBackColor = true; - this.cancel_button.Click += new System.EventHandler(this.cancel_button_Click); - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Dock = System.Windows.Forms.DockStyle.Fill; - this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label4.Location = new System.Drawing.Point(205, 152); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(196, 14); - this.label4.TabIndex = 12; - this.label4.Text = "Iterations Completed"; - // - // backgroundWorker1 - // - this.backgroundWorker1.WorkerReportsProgress = true; - this.backgroundWorker1.WorkerSupportsCancellation = true; - this.backgroundWorker1.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker1_DoWork); - this.backgroundWorker1.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.backgroundWorker1_ProgressChanged); - this.backgroundWorker1.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker1_RunWorkerCompleted); - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Dock = System.Windows.Forms.DockStyle.Fill; - this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label5.Location = new System.Drawing.Point(205, 202); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(196, 14); - this.label5.TabIndex = 14; - this.label5.Text = "Client Seconds/Iteration (Avg)"; - // - // avgSeconds_textBox - // - this.avgSeconds_textBox.BackColor = System.Drawing.Color.Black; - this.avgSeconds_textBox.Cursor = System.Windows.Forms.Cursors.Default; - this.avgSeconds_textBox.Dock = System.Windows.Forms.DockStyle.Fill; - this.avgSeconds_textBox.Font = new System.Drawing.Font("Courier New", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.avgSeconds_textBox.ForeColor = System.Drawing.Color.Lime; - this.avgSeconds_textBox.Location = new System.Drawing.Point(205, 219); - this.avgSeconds_textBox.Margin = new System.Windows.Forms.Padding(3); - this.avgSeconds_textBox.Name = "avgSeconds_textBox"; - this.avgSeconds_textBox.Size = new System.Drawing.Size(196, 30); - this.avgSeconds_textBox.TabIndex = 13; - this.avgSeconds_textBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // progressBar1 - // - this.progressBar1.BackColor = System.Drawing.SystemColors.Control; - this.progressBar1.Dock = System.Windows.Forms.DockStyle.Fill; - this.progressBar1.Location = new System.Drawing.Point(205, 69); - this.progressBar1.Name = "progressBar1"; - this.progressBar1.Size = new System.Drawing.Size(196, 30); - this.progressBar1.Style = System.Windows.Forms.ProgressBarStyle.Continuous; - this.progressBar1.TabIndex = 15; - // - // label6 - // - this.label6.AutoSize = true; - this.label6.Dock = System.Windows.Forms.DockStyle.Fill; - this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label6.Location = new System.Drawing.Point(205, 52); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(196, 14); - this.label6.TabIndex = 16; - this.label6.Text = "Progress"; - // - // label7 - // - this.label7.AutoSize = true; - this.label7.Dock = System.Windows.Forms.DockStyle.Fill; - this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label7.Location = new System.Drawing.Point(205, 252); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(196, 14); - this.label7.TabIndex = 18; - this.label7.Text = "Total Exceptions"; - // - // totalExceptions_textBox - // - this.totalExceptions_textBox.BackColor = System.Drawing.Color.Black; - this.totalExceptions_textBox.Cursor = System.Windows.Forms.Cursors.Default; - this.totalExceptions_textBox.Font = new System.Drawing.Font("Courier New", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.totalExceptions_textBox.ForeColor = System.Drawing.Color.Red; - this.totalExceptions_textBox.Location = new System.Drawing.Point(3, 3); - this.totalExceptions_textBox.Margin = new System.Windows.Forms.Padding(3); - this.totalExceptions_textBox.Name = "totalExceptions_textBox"; - this.totalExceptions_textBox.Size = new System.Drawing.Size(155, 30); - this.totalExceptions_textBox.TabIndex = 17; - this.totalExceptions_textBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.totalExceptions_textBox.Click += new System.EventHandler(this.totalExceptions_textBox_Click); - // - // mainUITimer - // - this.mainUITimer.Tick += new System.EventHandler(this.mainUITimer_Tick); - // - // label8 - // - this.label8.AutoSize = true; - this.label8.Dock = System.Windows.Forms.DockStyle.Fill; - this.label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label8.Location = new System.Drawing.Point(205, 102); - this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(196, 14); - this.label8.TabIndex = 20; - this.label8.Text = "Elapsed Time"; - // - // elapsedTime_textBox - // - this.elapsedTime_textBox.BackColor = System.Drawing.Color.Black; - this.elapsedTime_textBox.Cursor = System.Windows.Forms.Cursors.Default; - this.elapsedTime_textBox.Dock = System.Windows.Forms.DockStyle.Fill; - this.elapsedTime_textBox.Font = new System.Drawing.Font("Courier New", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.elapsedTime_textBox.ForeColor = System.Drawing.Color.Lime; - this.elapsedTime_textBox.Location = new System.Drawing.Point(205, 119); - this.elapsedTime_textBox.Margin = new System.Windows.Forms.Padding(3); - this.elapsedTime_textBox.Name = "elapsedTime_textBox"; - this.elapsedTime_textBox.Size = new System.Drawing.Size(196, 30); - this.elapsedTime_textBox.TabIndex = 19; - this.elapsedTime_textBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // perfCounterTimer - // - this.perfCounterTimer.Interval = 2500; - // - // database_button - // - this.database_button.Dock = System.Windows.Forms.DockStyle.Fill; - this.database_button.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.database_button.Location = new System.Drawing.Point(3, 69); - this.database_button.Name = "database_button"; - this.database_button.Size = new System.Drawing.Size(196, 30); - this.database_button.TabIndex = 22; - this.database_button.Text = "Database"; - this.database_button.UseVisualStyleBackColor = true; - this.database_button.Click += new System.EventHandler(this.database_button_Click); - // - // iterationsSecond_textBox - // - this.iterationsSecond_textBox.BackColor = System.Drawing.Color.Black; - this.iterationsSecond_textBox.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; - this.iterationsSecond_textBox.Dock = System.Windows.Forms.DockStyle.Fill; - this.iterationsSecond_textBox.Font = new System.Drawing.Font("Courier New", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.iterationsSecond_textBox.ForeColor = System.Drawing.Color.Lime; - this.iterationsSecond_textBox.Location = new System.Drawing.Point(205, 169); - this.iterationsSecond_textBox.Margin = new System.Windows.Forms.Padding(3); - this.iterationsSecond_textBox.Name = "iterationsSecond_textBox"; - this.iterationsSecond_textBox.Size = new System.Drawing.Size(196, 30); - this.iterationsSecond_textBox.TabIndex = 23; - this.iterationsSecond_textBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // exceptions_button - // - this.exceptions_button.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.exceptions_button.Location = new System.Drawing.Point(164, 3); - this.exceptions_button.Name = "exceptions_button"; - this.exceptions_button.Size = new System.Drawing.Size(27, 23); - this.exceptions_button.TabIndex = 24; - this.exceptions_button.Text = "..."; - this.exceptions_button.UseVisualStyleBackColor = true; - this.exceptions_button.Click += new System.EventHandler(this.exceptions_button_Click); - // - // label9 - // - this.label9.AutoSize = true; - this.label9.Dock = System.Windows.Forms.DockStyle.Fill; - this.label9.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label9.Location = new System.Drawing.Point(3, 252); - this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(196, 14); - this.label9.TabIndex = 26; - this.label9.Text = "CPU Seconds/Iteration (Avg)"; - // - // cpuTime_textBox - // - this.cpuTime_textBox.BackColor = System.Drawing.Color.Black; - this.cpuTime_textBox.Cursor = System.Windows.Forms.Cursors.Default; - this.cpuTime_textBox.Dock = System.Windows.Forms.DockStyle.Fill; - this.cpuTime_textBox.Font = new System.Drawing.Font("Courier New", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.cpuTime_textBox.ForeColor = System.Drawing.Color.Lime; - this.cpuTime_textBox.Location = new System.Drawing.Point(3, 269); - this.cpuTime_textBox.Margin = new System.Windows.Forms.Padding(3); - this.cpuTime_textBox.Name = "cpuTime_textBox"; - this.cpuTime_textBox.Size = new System.Drawing.Size(196, 30); - this.cpuTime_textBox.TabIndex = 25; - this.cpuTime_textBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // label10 - // - this.label10.AutoSize = true; - this.label10.Dock = System.Windows.Forms.DockStyle.Fill; - this.label10.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label10.Location = new System.Drawing.Point(3, 302); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(196, 14); - this.label10.TabIndex = 28; - this.label10.Text = "Actual Seconds/Iteration (Avg)"; - // - // actualSeconds_textBox - // - this.actualSeconds_textBox.BackColor = System.Drawing.Color.Black; - this.actualSeconds_textBox.Cursor = System.Windows.Forms.Cursors.Default; - this.actualSeconds_textBox.Dock = System.Windows.Forms.DockStyle.Fill; - this.actualSeconds_textBox.Font = new System.Drawing.Font("Courier New", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.actualSeconds_textBox.ForeColor = System.Drawing.Color.Lime; - this.actualSeconds_textBox.Location = new System.Drawing.Point(3, 319); - this.actualSeconds_textBox.Margin = new System.Windows.Forms.Padding(3); - this.actualSeconds_textBox.Name = "actualSeconds_textBox"; - this.actualSeconds_textBox.Size = new System.Drawing.Size(196, 30); - this.actualSeconds_textBox.TabIndex = 27; - this.actualSeconds_textBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // label12 - // - this.label12.AutoSize = true; - this.label12.Dock = System.Windows.Forms.DockStyle.Fill; - this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label12.Location = new System.Drawing.Point(205, 302); - this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(196, 14); - this.label12.TabIndex = 30; - this.label12.Text = "Logical Reads/Iteration (Avg)"; - // - // logicalReads_textBox - // - this.logicalReads_textBox.BackColor = System.Drawing.Color.Black; - this.logicalReads_textBox.Cursor = System.Windows.Forms.Cursors.Default; - this.logicalReads_textBox.Dock = System.Windows.Forms.DockStyle.Fill; - this.logicalReads_textBox.Font = new System.Drawing.Font("Courier New", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.logicalReads_textBox.ForeColor = System.Drawing.Color.Lime; - this.logicalReads_textBox.Location = new System.Drawing.Point(205, 319); - this.logicalReads_textBox.Margin = new System.Windows.Forms.Padding(3); - this.logicalReads_textBox.Name = "logicalReads_textBox"; - this.logicalReads_textBox.Size = new System.Drawing.Size(196, 30); - this.logicalReads_textBox.TabIndex = 29; - this.logicalReads_textBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // db_label - // - this.db_label.AutoSize = true; - this.db_label.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.db_label.Location = new System.Drawing.Point(55, 32); - this.db_label.Name = "db_label"; - this.db_label.Size = new System.Drawing.Size(0, 13); - this.db_label.TabIndex = 31; - // - // tableLayoutPanel1 - // - this.tableLayoutPanel1.ColumnCount = 2; - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 202F)); - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 202F)); - this.tableLayoutPanel1.Controls.Add(this.logicalReads_textBox, 1, 12); - this.tableLayoutPanel1.Controls.Add(this.label12, 1, 11); - this.tableLayoutPanel1.Controls.Add(this.label2, 0, 5); - this.tableLayoutPanel1.Controls.Add(this.iterations_numericUpDown, 0, 6); - this.tableLayoutPanel1.Controls.Add(this.threads_numericUpDown, 0, 8); - this.tableLayoutPanel1.Controls.Add(this.label3, 0, 7); - this.tableLayoutPanel1.Controls.Add(this.database_button, 0, 2); - this.tableLayoutPanel1.Controls.Add(this.label9, 0, 9); - this.tableLayoutPanel1.Controls.Add(this.label10, 0, 11); - this.tableLayoutPanel1.Controls.Add(this.cpuTime_textBox, 0, 10); - this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 1, 10); - this.tableLayoutPanel1.Controls.Add(this.actualSeconds_textBox, 0, 12); - this.tableLayoutPanel1.Controls.Add(this.label7, 1, 9); - this.tableLayoutPanel1.Controls.Add(this.avgSeconds_textBox, 1, 8); - this.tableLayoutPanel1.Controls.Add(this.label5, 1, 7); - this.tableLayoutPanel1.Controls.Add(this.iterationsSecond_textBox, 1, 6); - this.tableLayoutPanel1.Controls.Add(this.label4, 1, 5); - this.tableLayoutPanel1.Controls.Add(this.label6, 1, 1); - this.tableLayoutPanel1.Controls.Add(this.label8, 1, 3); - this.tableLayoutPanel1.Controls.Add(this.progressBar1, 1, 2); - this.tableLayoutPanel1.Controls.Add(this.elapsedTime_textBox, 1, 4); - this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel2, 1, 0); - this.tableLayoutPanel1.Controls.Add(this.param_button, 0, 4); - this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel4, 0, 0); - this.tableLayoutPanel1.Location = new System.Drawing.Point(326, 3); - this.tableLayoutPanel1.Name = "tableLayoutPanel1"; - this.tableLayoutPanel1.RowCount = 14; - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 52F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 14F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 36F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 14F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 36F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 14F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 36F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 14F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 36F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 14F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 36F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 14F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 36F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(404, 354); - this.tableLayoutPanel1.TabIndex = 32; - // - // flowLayoutPanel1 - // - this.flowLayoutPanel1.Controls.Add(this.totalExceptions_textBox); - this.flowLayoutPanel1.Controls.Add(this.exceptions_button); - this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.flowLayoutPanel1.Location = new System.Drawing.Point(205, 269); - this.flowLayoutPanel1.Name = "flowLayoutPanel1"; - this.flowLayoutPanel1.Size = new System.Drawing.Size(196, 30); - this.flowLayoutPanel1.TabIndex = 31; - // - // tableLayoutPanel2 - // - this.tableLayoutPanel2.ColumnCount = 2; - this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel2.Controls.Add(this.cancel_button, 1, 0); - this.tableLayoutPanel2.Controls.Add(this.go_button, 0, 0); - this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel2.Location = new System.Drawing.Point(205, 3); - this.tableLayoutPanel2.Name = "tableLayoutPanel2"; - this.tableLayoutPanel2.RowCount = 1; - this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel2.Size = new System.Drawing.Size(196, 46); - this.tableLayoutPanel2.TabIndex = 32; - // - // param_button - // - this.param_button.Dock = System.Windows.Forms.DockStyle.Fill; - this.param_button.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.param_button.Location = new System.Drawing.Point(3, 119); - this.param_button.Name = "param_button"; - this.param_button.Size = new System.Drawing.Size(196, 30); - this.param_button.TabIndex = 21; - this.param_button.Text = "Parameter Substitution"; - this.param_button.UseVisualStyleBackColor = true; - this.param_button.Click += new System.EventHandler(this.param_button_Click); - // - // tableLayoutPanel4 - // - this.tableLayoutPanel4.ColumnCount = 2; - this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel4.Controls.Add(this.btnFreeCache, 1, 0); - this.tableLayoutPanel4.Controls.Add(this.btnCleanBuffer, 0, 0); - this.tableLayoutPanel4.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel4.Location = new System.Drawing.Point(3, 3); - this.tableLayoutPanel4.Name = "tableLayoutPanel4"; - this.tableLayoutPanel4.RowCount = 2; - this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel4.Size = new System.Drawing.Size(196, 46); - this.tableLayoutPanel4.TabIndex = 33; - // - // btnFreeCache - // - this.btnFreeCache.Dock = System.Windows.Forms.DockStyle.Fill; - this.btnFreeCache.Location = new System.Drawing.Point(99, 1); - this.btnFreeCache.Margin = new System.Windows.Forms.Padding(1); - this.btnFreeCache.Name = "btnFreeCache"; - this.btnFreeCache.Size = new System.Drawing.Size(96, 21); - this.btnFreeCache.TabIndex = 1; - this.btnFreeCache.Text = "Free Cache"; - this.btnFreeCache.UseVisualStyleBackColor = true; - this.btnFreeCache.Click += new System.EventHandler(this.btnFreeCache_Click); - // - // btnCleanBuffer - // - this.btnCleanBuffer.Dock = System.Windows.Forms.DockStyle.Fill; - this.btnCleanBuffer.Location = new System.Drawing.Point(1, 1); - this.btnCleanBuffer.Margin = new System.Windows.Forms.Padding(1); - this.btnCleanBuffer.Name = "btnCleanBuffer"; - this.btnCleanBuffer.Size = new System.Drawing.Size(96, 21); - this.btnCleanBuffer.TabIndex = 0; - this.btnCleanBuffer.Text = "Clean Buffers"; - this.btnCleanBuffer.UseVisualStyleBackColor = true; - this.btnCleanBuffer.Click += new System.EventHandler(this.btnCleanBuffer_Click); - // - // tableLayoutPanel3 - // - this.tableLayoutPanel3.ColumnCount = 2; - this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); - this.tableLayoutPanel3.Controls.Add(this.query_textBox, 0, 0); - this.tableLayoutPanel3.Controls.Add(this.tableLayoutPanel1, 1, 0); - this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel3.Location = new System.Drawing.Point(0, 24); - this.tableLayoutPanel3.Name = "tableLayoutPanel3"; - this.tableLayoutPanel3.RowCount = 1; - this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel3.Size = new System.Drawing.Size(733, 360); - this.tableLayoutPanel3.TabIndex = 33; - // - // Form1 - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.AutoSize = true; - this.ClientSize = new System.Drawing.Size(733, 384); - this.Controls.Add(this.tableLayoutPanel3); - this.Controls.Add(this.db_label); - this.Controls.Add(this.label1); - this.Controls.Add(this.menuStrip1); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MainMenuStrip = this.menuStrip1; - this.MaximizeBox = false; - this.MinimumSize = new System.Drawing.Size(749, 423); - this.Name = "Form1"; - this.Text = "SQLQueryStress"; - this.menuStrip1.ResumeLayout(false); - this.menuStrip1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.iterations_numericUpDown)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.threads_numericUpDown)).EndInit(); - this.tableLayoutPanel1.ResumeLayout(false); - this.tableLayoutPanel1.PerformLayout(); - this.flowLayoutPanel1.ResumeLayout(false); - this.tableLayoutPanel2.ResumeLayout(false); - this.tableLayoutPanel4.ResumeLayout(false); - this.tableLayoutPanel3.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.RichTextBox query_textBox; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.MenuStrip menuStrip1; - private System.Windows.Forms.Button go_button; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.NumericUpDown iterations_numericUpDown; - private System.Windows.Forms.NumericUpDown threads_numericUpDown; - private System.Windows.Forms.Button cancel_button; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; - private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; - private System.ComponentModel.BackgroundWorker backgroundWorker1; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.Label avgSeconds_textBox; - private System.Windows.Forms.ProgressBar progressBar1; - private System.Windows.Forms.Label label6; - private System.Windows.Forms.Label label7; - private System.Windows.Forms.Label totalExceptions_textBox; - private System.Windows.Forms.Timer mainUITimer; - private System.Windows.Forms.Label label8; - private System.Windows.Forms.Label elapsedTime_textBox; - private System.Windows.Forms.Timer perfCounterTimer; - private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; - private System.Windows.Forms.Button database_button; - private System.Windows.Forms.Label iterationsSecond_textBox; - private System.Windows.Forms.ToolStripMenuItem saveSettingsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem loadSettingsToolStripMenuItem; - private System.Windows.Forms.Button exceptions_button; - private System.Windows.Forms.SaveFileDialog saveFileDialog1; - private System.Windows.Forms.OpenFileDialog openFileDialog1; - private System.Windows.Forms.Label label9; - private System.Windows.Forms.Label cpuTime_textBox; - private System.Windows.Forms.Label label10; - private System.Windows.Forms.Label actualSeconds_textBox; - private System.Windows.Forms.Label label12; - private System.Windows.Forms.Label logicalReads_textBox; - private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem; - private System.Windows.Forms.Label db_label; - private TableLayoutPanel tableLayoutPanel1; - private FlowLayoutPanel flowLayoutPanel1; - private TableLayoutPanel tableLayoutPanel2; - private Button param_button; - private TableLayoutPanel tableLayoutPanel3; - private TableLayoutPanel tableLayoutPanel4; - private Button btnFreeCache; - private Button btnCleanBuffer; - } -} - diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/Form1.cs b/Solution/SQLQueryStress/src/SQLQueryStress/Form1.cs deleted file mode 100644 index 7cf4959e..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/Form1.cs +++ /dev/null @@ -1,533 +0,0 @@ -#region - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.IO; -using System.Runtime.Serialization; -using System.Runtime.Serialization.Formatters.Binary; -using System.Windows.Forms; -using SQLQueryStress.Properties; - -#endregion - -/********************************************* -TODO, version 1.0:::: - * figure out how to capture change of selection in parameter definer - * Bug: Dotfuscated version crashes in some cases (need to verify this) - * Bug: Dotfuscated version can't load non-dotfuscated .sqlstress files - * - * Throw a message box if param database has not been selected, or if can't connect (if parameterization is on) - * repaint exception window when datatable is updated - * Bug w/ stats sometimes going blank ?? - *********************************************/ - -namespace SQLQueryStress -{ - public partial class Form1 : Form - { - private const string Dashes = "---"; - - //Has this run been cancelled? - private bool _cancelled; - //Exceptions that occurred - private Dictionary _exceptions; - - //The exception viewer window - private DataViewer _exceptionViewer; - //Exit as soon as cancellation is finished? - private bool _exitOnComplete; - - /* Configuration local */ - private QueryStressSettings _settings = new QueryStressSettings(); - - //start of the load - private TimeSpan _start; - //total CPU time in milliseconds - private double _totalCpuTime; - - //total elapsed time in milliseconds - private double _totalElapsedTime; - - //total exceptions - private int _totalExceptions; - - //threads * iterations - private int _totalExpectedIterations; - /* Runtime locals */ - - //total iterations that have run - private int _totalIterations; - - //Same comments as above for these two... - private double _totalLogicalReads; - private int _totalReadMessages; - - //This is the total time as reported by the client - private double _totalTime; - //Number of query requests that returned time messages - //Note:: Average times will be computed by: - // A) Add up all results from time messages returned by - // each query output - // B) If the query returned one or more time messages, - // increment the totalTimeMessages counter - // C) Add the TOTAL of all messages to the total counters - // D) Divide to find the actual time - //TODO: Find out why elapsed time is not accurate in - //some cases. For instance, look at time reported for - //WAITFOR DELAY '00:00:05' (1300 ms?? WTF??) - private int _totalTimeMessages; - - public Form1(string configFile) : this() - { - OpenConfigFile(configFile); - } - - public Form1() - { - InitializeComponent(); - - saveFileDialog1.DefaultExt = "sqlstress"; - saveFileDialog1.Filter = @"SQLQueryStress Configuration Files|*.sqlstress"; - saveFileDialog1.FileOk += saveFileDialog1_FileOk; - - openFileDialog1.DefaultExt = "sqlstress"; - openFileDialog1.Filter = @"SQLQueryStress Configuration Files|*.sqlstress"; - openFileDialog1.FileOk += openFileDialog1_FileOk; - } - - private void aboutToolStripMenuItem_Click(object sender, EventArgs e) - { - var a = new AboutBox(); - a.ShowDialog(); - } - - private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) - { - ((LoadEngine) e.Argument).StartLoad(backgroundWorker1); - } - - private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e) - { - var output = (LoadEngine.QueryOutput) e.UserState; - - _totalIterations++; - - if (output.LogicalReads > 0) - { - _totalReadMessages++; - _totalLogicalReads += output.LogicalReads; - } - - if (output.ElapsedTime > 0) - { - _totalTimeMessages++; - _totalCpuTime += output.CpuTime; - _totalElapsedTime += output.ElapsedTime; - } - - _totalTime += output.Time.TotalMilliseconds; - - if (output.E != null) - { - _totalExceptions++; - string theMessage; - - //strip the time stats, if they showed up as part - //of the exception - if (_settings.CollectTimeStats) - { - var matchPos = output.E.Message.IndexOf("SQL Server parse and compile time:", StringComparison.Ordinal); - - theMessage = matchPos > -1 ? output.E.Message.Substring(0, matchPos - 2) : output.E.Message; - } - else - { - theMessage = output.E.Message; - } - - if (!_exceptions.ContainsKey(theMessage)) - { - _exceptions.Add(theMessage, 1); - } - else - { - _exceptions[theMessage] += 1; - } - - //TODO: Get this working? -- Repaint exceptions as they occur? - /* - if ((exceptionViewer != null) && (exceptionViewer.WindowState == FormWindowState.Normal)) - { - exceptionViewer.Invoke(new System.Threading.ThreadStart(exceptionViewer.Repaint)); - } - */ - } - } - - private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) - { - mainUITimer.Stop(); - - UpdateUi(); - - go_button.Enabled = true; - cancel_button.Enabled = false; - threads_numericUpDown.Enabled = true; - iterations_numericUpDown.Enabled = true; - - if (!_cancelled) - progressBar1.Value = 100; - - ((BackgroundWorker) sender).Dispose(); - - db_label.Text = ""; - - if (_exitOnComplete) - { - Dispose(); - } - } - - private void cancel_button_Click(object sender, EventArgs e) - { - cancel_button.Enabled = false; - - backgroundWorker1.CancelAsync(); - - _cancelled = true; - - if (sender is string) - { - _exitOnComplete = true; - } - } - - private void database_button_Click(object sender, EventArgs e) - { - var dbselect = new DatabaseSelect(_settings) {StartPosition = FormStartPosition.CenterParent}; - dbselect.ShowDialog(); - } - - private void exceptions_button_Click(object sender, EventArgs e) - { - totalExceptions_textBox_Click(null, null); - } - - private void exitToolStripMenuItem_Click(object sender, EventArgs e) - { - Dispose(); - } - - private void go_button_Click(object sender, EventArgs e) - { - if (!_settings.MainDbConnectionInfo.TestConnection()) - { - MessageBox.Show(Resources.MustSetValidDbConnInfo); - return; - } - - _cancelled = false; - _exitOnComplete = false; - - _exceptions = new Dictionary(); - - _totalIterations = 0; - _totalTime = 0; - _totalCpuTime = 0; - _totalElapsedTime = 0; - _totalTimeMessages = 0; - _totalLogicalReads = 0; - _totalReadMessages = 0; - _totalExceptions = 0; - - iterationsSecond_textBox.Text = "0"; - avgSeconds_textBox.Text = "0.0"; - actualSeconds_textBox.Text = Dashes; - cpuTime_textBox.Text = Dashes; - logicalReads_textBox.Text = Dashes; - go_button.Enabled = false; - cancel_button.Enabled = true; - iterations_numericUpDown.Enabled = false; - threads_numericUpDown.Enabled = false; - - progressBar1.Value = 0; - - SaveSettingsFromForm1(); - - _totalExpectedIterations = _settings.NumThreads * _settings.NumIterations; - - var paramConnectionInfo = _settings.ShareDbSettings ? _settings.MainDbConnectionInfo : _settings.ParamDbConnectionInfo; - db_label.Text = "" + "Server: " + paramConnectionInfo.Server + - (paramConnectionInfo.Database.Length > 0 ? " // Database: " + paramConnectionInfo.Database : ""); - - var engine = new LoadEngine(_settings.MainDbConnectionInfo.ConnectionString, _settings.MainQuery, _settings.NumThreads, _settings.NumIterations, - _settings.ParamQuery, _settings.ParamMappings, paramConnectionInfo.ConnectionString, _settings.CommandTimeout, _settings.CollectIoStats, - _settings.CollectTimeStats, _settings.ForceDataRetrieval); - backgroundWorker1.RunWorkerAsync(engine); - - _start = new TimeSpan(DateTime.Now.Ticks); - - mainUITimer.Start(); - } - - private void loadSettingsToolStripMenuItem_Click(object sender, EventArgs e) - { - openFileDialog1.ShowDialog(); - } - - private void mainUITimer_Tick(object sender, EventArgs e) - { - UpdateUi(); - } - - private void OpenConfigFile(string fileName) - { - FileStream fs = null; - - try - { - fs = new FileStream(fileName, FileMode.Open); - var bf = new BinaryFormatter(); - - _settings = (QueryStressSettings) bf.Deserialize(fs); - } - catch - { - MessageBox.Show(Resources.ErrLoadingSettings); - } - finally - { - if (fs != null) - fs.Dispose(); - } - - query_textBox.Text = _settings.MainQuery; - threads_numericUpDown.Value = _settings.NumThreads; - iterations_numericUpDown.Value = _settings.NumIterations; - } - - private void openFileDialog1_FileOk(object sender, EventArgs e) - { - OpenConfigFile(openFileDialog1.FileName); - } - - private void optionsToolStripMenuItem_Click(object sender, EventArgs e) - { - var options = new Options(_settings); - options.ShowDialog(); - } - - private void param_button_Click(object sender, EventArgs e) - { - var p = new ParamWindow(_settings, query_textBox.Text) {StartPosition = FormStartPosition.CenterParent}; - p.ShowDialog(); - } - - private void saveFileDialog1_FileOk(object sender, EventArgs e) - { - FileStream fs = null; - - try - { - fs = new FileStream(saveFileDialog1.FileName, FileMode.Create); - var bf = new BinaryFormatter(); - - bf.Serialize(fs, _settings); - } - catch - { - MessageBox.Show(Resources.ErrorSavingSettings); - } - finally - { - if (fs != null) - fs.Dispose(); - } - } - - private void SaveSettingsFromForm1() - { - _settings.MainQuery = query_textBox.Text; - _settings.NumThreads = (int) threads_numericUpDown.Value; - _settings.NumIterations = (int) iterations_numericUpDown.Value; - } - - private void saveSettingsToolStripMenuItem_Click(object sender, EventArgs e) - { - SaveSettingsFromForm1(); - saveFileDialog1.ShowDialog(); - } - - private void totalExceptions_textBox_Click(object sender, EventArgs e) - { - _exceptionViewer = new DataViewer {StartPosition = FormStartPosition.CenterParent, Text = Resources.Exceptions}; - - - - var dt = new DataTable(); - dt.Columns.Add("Count"); - dt.Columns.Add("Exception"); - - if (_exceptions != null) - { - var values = _exceptions.Values.GetEnumerator(); - - foreach (var ex in _exceptions.Keys) - { - values.MoveNext(); - var count = values.Current; - dt.Rows.Add(count, ex); - } - } - - _exceptionViewer.DataView = dt; - - _exceptionViewer.ShowDialog(); - } - - private void UpdateUi() - { - iterationsSecond_textBox.Text = _totalIterations.ToString(); - var avgIterations = _totalIterations == 0 ? 0.0 : _totalTime / _totalIterations / 1000; - var avgCpu = _totalTimeMessages == 0 ? 0.0 : _totalCpuTime / _totalTimeMessages / 1000; - var avgActual = _totalTimeMessages == 0 ? 0.0 : _totalElapsedTime / _totalTimeMessages / 1000; - var avgReads = _totalReadMessages == 0 ? 0.0 : _totalLogicalReads / _totalReadMessages; - - avgSeconds_textBox.Text = avgIterations.ToString("0.0000"); - cpuTime_textBox.Text = _totalTimeMessages == 0 ? "---" : avgCpu.ToString("0.0000"); - actualSeconds_textBox.Text = _totalTimeMessages == 0 ? "---" : avgActual.ToString("0.0000"); - logicalReads_textBox.Text = _totalReadMessages == 0 ? "---" : avgReads.ToString("0.0000"); - - totalExceptions_textBox.Text = _totalExceptions.ToString(); - progressBar1.Value = (int) (_totalIterations / (decimal) _totalExpectedIterations * 100); - - var end = new TimeSpan(DateTime.Now.Ticks); - end = end.Subtract(_start); - - var theTime = end.ToString(); - - //Some systems return "hh:mm:ss" instead of "hh:mm:ss.0000" if - //there is no fractional part of the second. I'm not sure - //why, but this fixes it for now. - if (theTime.Length > 8) - elapsedTime_textBox.Text = theTime.Substring(0, 13); - else - elapsedTime_textBox.Text = theTime + ".0000"; - } - - [Serializable] - public class QueryStressSettings - { - /// - /// Collect I/O stats? - /// - public bool CollectIoStats; - - /// - /// Collect time stats? - /// - public bool CollectTimeStats; - - /// - /// command timeout - /// - public int CommandTimeout; - - /// - /// Connection Timeout - /// - public int ConnectionTimeout; - - /// - /// Enable pooling? - /// - public bool EnableConnectionPooling; - - /// - /// Force the client to retrieve all data? - /// - public bool ForceDataRetrieval; - - /// - /// Connection info for the DB in which to run the test - /// - public DatabaseSelect.ConnectionInfo MainDbConnectionInfo; - - /// - /// main query to test - /// - public string MainQuery; - - /// - /// Number of iterations to run per thread - /// - public int NumIterations; - - /// - /// Number of threads to test with - /// - public int NumThreads; - - /// - /// Connection info for the DB from which to get the paramaters - /// - public DatabaseSelect.ConnectionInfo ParamDbConnectionInfo; - - /// - /// mapped parameters - /// - public Dictionary ParamMappings; - - /// - /// query from which to take parameters - /// - public string ParamQuery; - - /// - /// Should the main db and param db share the same settings? - /// If so, use main db settings for the params - /// - public bool ShareDbSettings; - - public QueryStressSettings() - { - MainDbConnectionInfo = new DatabaseSelect.ConnectionInfo(this); - ShareDbSettings = true; - ParamDbConnectionInfo = new DatabaseSelect.ConnectionInfo(); - MainQuery = ""; - ParamQuery = ""; - NumThreads = 1; - NumIterations = 1; - ParamMappings = new Dictionary(); - ConnectionTimeout = 15; - CommandTimeout = 0; - EnableConnectionPooling = true; - CollectIoStats = true; - CollectTimeStats = true; - ForceDataRetrieval = false; - } - - [OnDeserialized] - private void FixSettings(StreamingContext context) - { - ConnectionTimeout = ConnectionTimeout == 0 ? 15 : ConnectionTimeout; - } - } - - private void btnCleanBuffer_Click(object sender, EventArgs e) - { - MessageBox.Show(LoadEngine.ExecuteCommand(_settings.MainDbConnectionInfo.ConnectionString, "DBCC DROPCLEANBUFFERS") - ? "Buffers cleared" - : "Errors encountered"); - } - - private void btnFreeCache_Click(object sender, EventArgs e) - { - MessageBox.Show(LoadEngine.ExecuteCommand(_settings.MainDbConnectionInfo.ConnectionString, "DBCC FREEPROCCACHE") - ? "Cache freed" - : "Errors encountered"); - } - } -} \ No newline at end of file diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/Form1.resx b/Solution/SQLQueryStress/src/SQLQueryStress/Form1.resx deleted file mode 100644 index 13c5ed92..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/Form1.resx +++ /dev/null @@ -1,305 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - 126, 17 - - - 278, 17 - - - 394, 17 - - - 533, 17 - - - 661, 17 - - - - - AAABAAEAMDAAAAEAIACoJQAAFgAAACgAAAAwAAAAYAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AACZMwABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAJkzAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAG61WEpszD9JWMxKSDbKckgb1ZVKDuGkSwzl - pUwN5aVLDuKkSxHgpUsV36lMG9+vTB3gsUwe4LJMHdmrSx3Mm0oiv4RINr5qR0zFVUhizEJIdtQySYLa - KkmJ3ydJjeMlSo7kJUqO5CVKjuQlSo7kJUqM4ydKg94tSnnRPEpytVhKAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcNA+SofrHvaP6Rn0ZdhJ8S/a - k/MR6sr5DPfe/gz43v4M+N7+DPfe/gz33v4M997+Dffe/g333/4N997+DPLa/AzozvkQ3Lz1INWg8jbU - hPJQ1WXxb9lE8ojgLfSc5xz1ru8P+Lj1Cfm++Qf6wfwG+8H8Bvu//Af7tvsK+qX2EPmL6iD3csZHSgAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABuw0tKkPQW+LX4 - CPms5xj2ZdNk8ineu/YP7+78Dfj6/w34+v8N+Pr/Dfj6/w34+v8N+Pr/Dfj6/w34+v8N+Pr/Dff4/g30 - 9f0O7+/8FOjh+R3izvct3bb2RdeS9F3Wc/N42FTzl9409a7lIPfB7RH50vYH/Nn6Av3c/QH+2v4C/dD9 - A/25/Aj7jO0d93PDSkoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAG2s - YkqC6CP2vvwG+83zB/qi3iv1StON8xvl2fkO9fr+Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74 - /v8O+P7/Dvj+/w74/v8O9/3+Dvb8/g70+f0R8PH8F+ri+iHj0Pgw3bf2SNiU9GHWc/R+11H0o+At9rzo - F/jO8Qr72/kD/d/8Af7a/QH9tfsJ+oXnJPZvrGFKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAG/IRkqa9hL40fsD/MXrDvmJ2EP0NNms9RLr6fsO9/3+Dvj+/w74/v8O+P7/Dvj+/w33 - /f4O+P7/Dff9/w33/f4O+P7/Dvj+/w74/v8O+P7/Dvj+/w73/f4O9/3+DvX7/g/y9v0T7u38G+ba+Sff - w/c61qP0W9F18nvUUfOc3DL1vegV+NDxCPva+AL9yvwE/Jz0FPhyyEVKAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAHTWN0qo+gz51PgE/LTlHfdt1GLzJeHJ+A/x9f0O+P7/Dvj+/w74 - /v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w73 - /f4O9/3+DvT5/hDw8vwW6eP6Jd/G9znWpPRU0HzyfdFL8qDaKvW95xT5yvUH+6f3Dfh21jZKAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHfbMUqu+wr5yu8J+ZjbNfVM04nzF+fh+Q72 - /P4O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dff+/w3t/f8L2/3/DfL+/w74 - /v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w73/f4O9vz+D/L2/RPt6/sd5db5Ntyv91XZhfZ52Ff1nN4r9ZHo - GvRu1DVJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHjcMEqt+gr5u+kV+H3X - UfQ32qv1EO7w/A73/f4O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dff9/w74/v8O+P7/DOb9/wR1 - /f8BSf3/BpH9/w30/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvf9/g72/P4P8/b9Ferm+yLh - y/g516T1XdRt82LZRfJVykdIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHjc - MEqp9gv4puAm9WDScPIl38b3DvP4/Q74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74 - /v8O+P7/DOP9/wNc/f8ANf3/BXv9/w3y/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74 - /v8O9/3+DvX7/hDx8/0X6OH6Kd239y/ahfQ1x2hJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAHfbMEqe7xH2idpC9ELWmfQY5+D5Dvf9/g74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74 - /v8O+P7/Dvj+/w74/v8O+P7/Dff+/w3q/f8L1v3/De79/w73/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74 - /v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w73/f4O9vv+EO/s/BDsv/oY1otLAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAHTZMUqN5hz0a9Ne8i7bt/YQ7e77Dvj+/w74/v8O+P7/Dvj+/w74 - /v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O9/7/Dvj+/w74/v8O+P7/Dvj+/w74 - /v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O9/3/Dff3/gv20P4N5ZhMAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAG7UM0l64CzyUdN/8iDi0PgO8/j9Dvj+/w74 - /v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dff+/wva/f8IrP3/DOj9/w74 - /v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dfj4/wv4 - 0v4J7ZpMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF/LPEhc1kfvNNen9BTp - 5/oO9/3+Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/DfH9/wV6 - /f8AMP3/B5z9/w73/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74 - /v8O+P7/Dfj4/wv40v4L5pdLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAE7E - SUhB0mTuI9/E9g/w8/wO9/3/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74 - /v8O+P7/De79/wRq/f8AL/3/Bov9/w73/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74 - /v8O+P7/Dvj+/w74/v8O+P7/Dfj4/wv30f4R35dLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAADvAXEgn04XvF+bb+Q71+v4O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74 - /v8O+P7/Dvj+/w74/v8O+P7/DOj9/wNe/f8AL/3/BX79/w31/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74 - /v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dfj4/wz30v4Z25tLAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAACjCeEgT3qv0D+7t+w73/f4O+P7/Dvj+/w74/v8O+P7/Dvj+/w74 - /v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/DOD9/wJM/f8AL/3/BGz9/w3z/v8O+P7/Dvj+/w74 - /v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dff3/gz20f4e2p5LAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACLOjkoN7ML5DvT2/Q74/v8O+P7/Dvj+/w74 - /v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/C9f9/wFE/f8AL/3/A2H9/w3u - /f8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/DfX1/gzx - yvsf05ZLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACDVmUsM9Mz9Dff6/g74 - /v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Csv9/wA5 - /f8AL/3/AlL9/wzn/f8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74 - /v8O9/3+Du/t/A7kufcixoNJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABzZ - mksM98/+Dvj6/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74 - /v8O+P7/Cb79/wA2/f8AL/3/AUn9/wzd/f8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74 - /v8O+P7/Dvj+/w74/v8O9vz+FObb+B3YmPEywWdIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAABbblksL98/+Dvj6/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74 - /v8O+P7/Dvj+/w74/v8O+P7/Ca79/wAx/f8AL/3/AT/9/wvP/f8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74 - /v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w73/f8O8/f9IN/E9jLRde5FwlFHAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/fkksL8Mj8De/y/A3y9/0N9Pr+Dvf9/g73/f8O+P7/Dvj+/w74 - /v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O9/7/CKb9/wAw/f8AL/3/AT39/wrL/f8O+P7/Dvj+/w74 - /v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w73/f4R7e/8Mdio803TVu5YyUFIAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAfVgUoJ1a30C8/Q8wvU2fUM3eL3DObr+Q3p - 7/oN6/H7De70/A3y+P0N9fv+Dvf9/g74/v8O+P7/Dvj+/w74/v8O9/7/B6H9/wAw/f8AL/3/ADz9/wrE - /f8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w71+v4Z5dv5TNOB8m/b - NvBq0TRIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAfbiEoJ2bT1C87Q8wvI - zfILyc7yC9HW9AzW2/UM2N31DNnf9gzf5fgN5uz6Dezy+w3x9/0N9fv+Dvf9/g74/v8O+P7/C9f9/wJZ - /f8ANf3/BHf9/wzp/f8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvf9/g/x - 9P0l3sb3Z9Jg8YXjI/Jz2DBJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAfo - lEsK6sL6DOPl+Qzd4vcM2N32C9TZ9QvU2fQL09j0C87T8wvP1PML1dr1DNrf9gzg5fgN5+36De/0/A3z - +f0N9vz+Dfb9/wze/f8Kvv3/DOb9/w73/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74 - /v8O+P7/Dvf8/hTr6fs32qv1hNhC85frFfV43C5KAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAvnlkwL9Mz9DfP2/Q3z+f0N8vj9De3z/A3p7voM5uz5DOPo+Aze4/cM2d72C9Xa9QvT - 2PQL1Nn0DNrf9Qzg5vgN5+35De/0/A3z+f0N9vz+Dvf9/w74/v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74 - /v8O+P7/Dvj+/w74/v8O+P7/DvP4/R7i0/hQ04TzouAm9abyDPd63i5KAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAABfZjUsQ7cD7D/Ly/Q72+/4O9/3+Dff9/g32/P4N9fv+DfL4/Q3u - 9PwN6e/7DOPp+Qzd4vcM1931C9PY9AvT2PQM19z1DN7j9wzk6vkN6/H7DfH3/Q31+/4O9/3+Dvj+/w74 - /v8O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O9/3+Ee/w/C3duvZs1GPzuOkW9674Cfl63i5KAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC7Kckok3ZX2HuPP+RTs6vsP8/f9Dvf9/g74 - /v8O+P7/Dvf9/g33/f4N9vz+DfP5/Q3v9fwN6e/6DOHn+Azc4fYM1931DNXa9AvW2/QM2t/1DOHm9w3o - 7voN7/X8DfX7/g73/f4O+P7/Dvj+/w74/v8O+P7/Dvj+/w74/v8O9/z+Fufh+j/WnPSH1UPzx+8K+bH7 - CPp63i5KAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFTKSUld10jxVNF68jfY - qfUh48/5E+7t/A7z9/0O9vz+Dvf9/w74/v8O+P7/Dvj+/w73/f4N9vz+DfT6/Q3v9fwN6vD6DOLn+Azc - 4fYM19z1DNbb9QzX3PUM3eL3Deft+g3v9fwN9Pr+Dvf9/g74/v8O+P7/Dvj+/w73/f8O9Pn9JOHJ913U - dfOo4Sj20/cD+7L8CPp63i5KAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAG3U - NUmP5xz1l9009XXYXfVQ14n1LNq49hrh1fgS6ur6DvP4/Q72/P4O9/3+Dvj+/w74/v8O+P7/Dvf9/g33 - /f4N9vz+DfL4/Q3t8/sM5ev5DNzh9wzW2/UM1dr1DNjd9gze5PgM5uz6DfD2/A31+/4O9/3+Dvj+/w73 - /f4Q7/D8NNmt9XjTU/O85xX42fsC/bL8CPp63i5KAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAHfbMEqp9wz4x+8N+rHiHveQ1jnzZM5m8UTPj/It2LX1GuTZ+BLs7PsO8vf9Dvb8/g73 - /f4O+P7/Dvj+/w74/v8O+P7/Dvf9/g32/P4N8/n9De3z+wzl6/kM3eP3C9PY9AvO0/ML0tf0DN/k+A3r - 8fsN8vj9Dvf9/g72/P4V6eP6StWO85TaOPTM7gr62v0B/bL8CPp63i5KAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAHjcMEqv/Ar63PwC/dv4A/3P8Qn7tuUc+JncNfV61lT0VNSA9DnY - pfUm38T3Geje+RLu7fsP8vb9Dvb8/g73/f4O+P7/Dvj+/w74/v8O9/3/Dff9/g31+/4N8ff9Dejt+gzf - 5PgL1dr2C9HW9AvY3fYM4uf4De/1/A/v8/wi38r3adJl8rHjHvfZ9gL82/4B/bL8CPp63i5KAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHjaM0qt+wv63f4B/uH9Af7f+wH+2PYE/Mzv - C/q65xn4m9419n3YU/Vg1nP0Q9ma9TDdt/Yh5ND4Fuvm+xDw8vwO9Pn9Dvf9/g74/v8O+P7/Dvj+/w73 - /f8O9/3+DfT6/g3u9PwM5er5DNjd9gvT1/QL09f1DN7j+BLh3/gy1631hdZG88TrEPnf+wH+2v4C/bD8 - Cfp43DBKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHXRPUql+A/52P4C/eH+ - Af7h/QH/4f0B/t/7Af7a9wP9zfAM+7zpGPmn4ir3idtH9W/YZPRV2IP0Otyp9ijhxPcc59r5E+3r+w/w - 9PwO8/n9Dvf9/g73/f8O+P7/Dvf9/g32/P4N8/n9Derw+wzf5PgL09j1DM7S9BjJvfJHyoXxod0t9dLx - Bvvh/QH+1f4C/af6Dflz1DlKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHC8 - UkqT8Bn3y/0E/N7+Af7h/gH+4v4B/+L+Af/h/QH+4PwB/t76Af7Y9gT8zO8L+rzoF/io4Sf2i9lD9HDW - YPNW1X/zPdag9C3ZtvUi4Mr3Gune+hTr6PsQ7e/7DvH3/Q71+/4O9/3+Dfb8/g3x9/0M5On5DszN9Ce9 - nfBlwljwuuQV+N35Af3g/gH+x/0F/JPyF/dtwE5KAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAG2dcUp83S/1sPoL+dH9A/ze/gH+4f4B/uL+Af/i/gH/4v4B/+H9Af/h/QH+4PwB/tz5 - Av3V9Ab8xu0Q+rTlHfif3zH2hdtL9XHYYvRc1nr0RtmX9TfZqvUq2rv2IeHO+B3o2/oZ6uL6FOjl+hLm - 5foS4d/5Hc699UTCgPKGyzjzzOwI+t/8Af7V/gL9qPoM+nnhLPZrn25KAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABut1dKiesg9675DPrG/QX80/4D/Nf+AvzY/gL82P4C/Nj+ - AvzY/gL82P4C/Nj9AvzX/QL81fsD+9D3BfrH8gr5uuwU96vmH/aZ3y70hNpD83LXVfJg02fxTtF88UTW - jvI92pz0M9mm8y7WqvMw1qj0Q9CJ82vNU/Kh2x/1yPQF+sf9BPuv+wr6f+oi92u6VEoAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAb7RaSnvXNfaO6h/3m/UT95z5 - D/eb+w32m/sN9pv7Dfab+w32m/sN9pv7Dfab+w32m/sN9pr7Dfaa+g32mPkO9Zb2D/WR8xH0iO0V84Dp - G/F35iPwauAt713YNO1S0zztS9RG7UrWTe9L1krvV9Y572/fJPGJ7RX0mPQT94/sHfd62jP2baxiSgAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAG6T - ekpuslxKb8lESW7TO0ls1zdJbNc3SWzXN0ls1zdJbNc3SWzXN0ls1zdJbNc3SWzXN0ls1zdJbNc3SWzX - N0ls1zdJa9Y3SWnUN0hn0zhIY9E6SF/NPEhZyD1IVMQ/SFLDQUhTxEBIWsk9SGPPOUhr0jpJb8dGSW2y - XElrlHpJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACZMwABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB///////5sAP///////2wA//////// - bAD///////9sAP///////2wA/wAAAAD/bAD+AAAAAH9sAPwAAAAAP2wA+AAAAAAfbAD4AAAAAB9sAPgA - AAAAH2wA+AAAAAAfbAD4AAAAAB9sAPgAAAAAH2wA+AAAAAAfbAD4AAAAAB9sAPgAAAAAH2wA+AAAAAAf - bAD4AAAAAB9sAPgAAAAAH2wA+AAAAAAfbAD4AAAAAB9sAPgAAAAAH2wA+AAAAAAfbAD4AAAAAB9sAPgA - AAAAH2wA+AAAAAAfbAD4AAAAAB9sAPgAAAAAH2wA+AAAAAAfbAD4AAAAAB9sAPgAAAAAH2wA+AAAAAAf - bAD4AAAAAB9sAPgAAAAAH2wA+AAAAAAfbAD4AAAAAB9sAPgAAAAAH2wA+AAAAAAfbAD4AAAAAB9sAPwA - AAAAP2wA/gAAAAB/bAD/AAAAAP9sAP///////2wA////////bAD///////9sAP///////2wAf/////// - bAA= - - - \ No newline at end of file diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/LoadEngine.cs b/Solution/SQLQueryStress/src/SQLQueryStress/LoadEngine.cs deleted file mode 100644 index 6bd991d5..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/LoadEngine.cs +++ /dev/null @@ -1,583 +0,0 @@ -#region - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Data.SqlClient; -using System.Diagnostics; -using System.Text.RegularExpressions; -using System.Threading; - -#endregion - -namespace SQLQueryStress -{ - internal class LoadEngine - { - private static readonly Queue QueryOutInfo = new Queue(); - private readonly bool _collectIoStats; - private readonly bool _collectTimeStats; - private readonly List _commandPool = new List(); - private readonly int _commandTimeout; - - private readonly string _connectionString; - private readonly bool _forceDataRetrieval; - private readonly int _iterations; - private readonly string _paramConnectionString; - private readonly Dictionary _paramMappings; - //private readonly List> queryOutInfoPool = new List>(); - private readonly string _paramQuery; - private readonly string _query; - private readonly List _threadPool = new List(); - private readonly int _threads; - - public LoadEngine(string connectionString, string query, int threads, int iterations, string paramQuery, Dictionary paramMappings, - string paramConnectionString, int commandTimeout, bool collectIoStats, bool collectTimeStats, bool forceDataRetrieval) - { - //Set the min pool size so that the pool does not have - //to get allocated in real-time - var builder = new SqlConnectionStringBuilder(connectionString) {MinPoolSize = threads}; - - _connectionString = builder.ConnectionString; - _query = query; - _threads = threads; - _iterations = iterations; - _paramQuery = paramQuery; - _paramMappings = paramMappings; - _paramConnectionString = paramConnectionString; - _commandTimeout = commandTimeout; - _collectIoStats = collectIoStats; - _collectTimeStats = collectTimeStats; - _forceDataRetrieval = forceDataRetrieval; - } - - public static bool ExecuteCommand(string connectionString, string sql) - { - using (var conn = new SqlConnection(connectionString)) - { - conn.Open(); - using (var cmd = new SqlCommand(sql, conn)) - { - cmd.ExecuteNonQuery(); - return true; - } - } - } - - public void StartLoad(BackgroundWorker worker) - { - var useParams = false; - - var badParams = new List(); - foreach (var theKey in _paramMappings.Keys) - { - if ((_paramMappings[theKey] == null) || (_paramMappings[theKey].Length == 0)) - { - badParams.Add(theKey); - } - } - - foreach (var theKey in badParams) - { - _paramMappings.Remove(theKey); - } - - //Need some parameters? - if (_paramMappings.Count > 0) - { - ParamServer.Initialize(_paramQuery, _paramConnectionString, _paramMappings); - useParams = true; - } - - //Initialize the connection pool - var conn = new SqlConnection(_connectionString); - //TODO: use this or not?? - SqlConnection.ClearPool(conn); - conn.Open(); - conn.Dispose(); - - //make sure the run cancelled flag is not set - QueryInput.RunCancelled = false; - - //Spin up the load threads - for (var i = 0; i < _threads; i++) - { - conn = new SqlConnection(_connectionString); - - //TODO: Figure out how to make this option work (maybe) - //conn.FireInfoMessageEventOnUserErrors = true; - - SqlCommand statsComm = null; - - var queryComm = new SqlCommand {CommandTimeout = _commandTimeout, Connection = conn, CommandText = _query}; - - if (useParams) - { - queryComm.Parameters.AddRange(ParamServer.GetParams()); - } - - var setStatistics = (_collectIoStats ? @"SET STATISTICS IO ON;" : "") + (_collectTimeStats ? @"SET STATISTICS TIME ON;" : ""); - - if (setStatistics.Length > 0) - { - statsComm = new SqlCommand {CommandTimeout = _commandTimeout, Connection = conn, CommandText = setStatistics}; - } - - //Queue queryOutInfo = new Queue(); - - var input = new QueryInput(statsComm, queryComm, -// this.queryOutInfo, - _iterations, _forceDataRetrieval); - - var theThread = new Thread(input.StartLoadThread) {Priority = ThreadPriority.BelowNormal}; - - _threadPool.Add(theThread); - _commandPool.Add(queryComm); - //queryOutInfoPool.Add(queryOutInfo); - } - - //Start the load threads - for (var i = 0; i < _threads; i++) - { - _threadPool[i].Start(); - } - - //Start reading the queue... - var finishedThreads = 0; - var cancelled = false; - - while (finishedThreads < _threads) - { -// for (int i = 0; i < threads; i++) -// { - // try - // { - QueryOutput theOut = null; - //lock (queryOutInfoPool[i]) - lock (QueryOutInfo) - { - //if (queryOutInfoPool[i].Count > 0) - //theOut = (queryOutput)queryOutInfoPool[i].Dequeue(); - if (QueryOutInfo.Count > 0) - theOut = QueryOutInfo.Dequeue(); - else - Monitor.Wait(QueryOutInfo); - } - - if (theOut != null) - { - //Report output to the UI - worker.ReportProgress((int) (finishedThreads / (decimal) _threads * 100), theOut); - - //TODO: Make this actually remove the queue from the pool so that it's not checked again -- maintain this with a bitmap, perhaps? - if (theOut.Finished) - finishedThreads++; - } - /* } - catch (InvalidOperationException e) - { - } - */ - - /* - if (theOut != null) - Thread.Sleep(200); - else - Thread.Sleep(10); - */ - // } - - //TODO: Remove this ? - GC.Collect(); - - if (worker.CancellationPending && !cancelled) - { - QueryInput.RunCancelled = true; - - //First, kill connections as fast as possible - SqlConnection.ClearAllPools(); - - //for each 20 threads, create a new thread dedicated - //to killing them - var threadNum = _threadPool.Count; - - var killerThreads = new List(); - while (threadNum > 0) - { - var i = threadNum <= 20 ? 0 : threadNum - 20; - - var killThreads = new Thread[threadNum - i < 1 ? threadNum : threadNum - i]; - var killCommands = new SqlCommand[threadNum - i < 1 ? threadNum : threadNum - i]; - - _threadPool.CopyTo(i, killThreads, 0, killThreads.Length); - _commandPool.CopyTo(i, killCommands, 0, killCommands.Length); - - for (var j = threadNum - 1; j >= i; j--) - { - _threadPool.RemoveAt(j); - _commandPool.RemoveAt(j); - } - - var kill = new ThreadKiller(killThreads, killCommands); - var killer = new Thread(kill.KillEm); - killer.Start(); - Thread.Sleep(0); - - killerThreads.Add(killer); - - threadNum = i; - } - - //wait for the kill threads to return - //before exiting... - foreach (var theThread in killerThreads) - { - theThread.Join(); - } - - cancelled = true; - } - } - - //clear any remaining messages -- these are almost certainly - //execeptions due to thread cancellation - //queryOutInfo.Clear(); - } - - - //TODO: Monostate pattern to be investigated (class is never instantiated) - private class ParamServer - { - private static int _currentRow; - private static int _numRows; - - //The actual params that will be filled - private static SqlParameter[] _outputParams; - //Map the param columns to ordinals in the data table - private static int[] _paramDtMappings; - private static DataTable _theParams; - - public static void GetNextRow_Values(SqlParameterCollection newParam) - { - var rowNum = Interlocked.Increment(ref _currentRow); - var dr = _theParams.Rows[rowNum % _numRows]; - - for (var i = 0; i < _outputParams.Length; i++) - { - newParam[i].Value = dr[_paramDtMappings[i]]; - } - } - - public static SqlParameter[] GetParams() - { - var newParam = new SqlParameter[_outputParams.Length]; - - for (var i = 0; i < _outputParams.Length; i++) - { - newParam[i] = (SqlParameter) ((ICloneable) _outputParams[i]).Clone(); - } - - return newParam; - } - - public static void Initialize(string paramQuery, string connString, Dictionary paramMappings) - { - var a = new SqlDataAdapter(paramQuery, connString); - _theParams = new DataTable(); - a.Fill(_theParams); - - _numRows = _theParams.Rows.Count; - - _outputParams = new SqlParameter[paramMappings.Keys.Count]; - _paramDtMappings = new int[paramMappings.Keys.Count]; - - //Populate the array of parameters that will be cloned and filled - //on each request - var i = 0; - foreach (var parameterName in paramMappings.Keys) - { - _outputParams[i] = new SqlParameter {ParameterName = parameterName}; - var paramColumn = paramMappings[parameterName]; - - //if there is a param mapped to this column - if (paramColumn != null) - _paramDtMappings[i] = _theParams.Columns[paramColumn].Ordinal; - - i++; - } - } - } - - private class QueryInput - { - [ThreadStatic] private static QueryOutput _outInfo; - - private static bool _runCancelled; - //This regex is used to find the number of logical reads - //in the messages collection returned in the queryOutput class - private static readonly Regex FindReads = new Regex(@"(?:Table \'\w{1,}\'. Scan count \d{1,}, logical reads )(\d{1,})", RegexOptions.Compiled); - - //This regex is used to find the CPU and elapsed time - //in the messages collection returned in the queryOutput class - private static readonly Regex FindTimes = - new Regex( - @"(?:SQL Server Execution Times:|SQL Server parse and compile time:)(?:\s{1,}CPU time = )(\d{1,})(?: ms,\s{1,}elapsed time = )(\d{1,})", - RegexOptions.Compiled); - - private readonly SqlCommand _queryComm; - - private readonly SqlCommand _statsComm; - - //private static Dictionary> theInfoMessages = new Dictionary>(); - - private readonly Stopwatch _sw = new Stopwatch(); - private readonly bool _forceDataRetrieval; - // private readonly Queue queryOutInfo; - private readonly int _iterations; - - public QueryInput(SqlCommand statsComm, SqlCommand queryComm, -// Queue queryOutInfo, - int iterations, bool forceDataRetrieval) - { - _statsComm = statsComm; - _queryComm = queryComm; -// this.queryOutInfo = queryOutInfo; - _iterations = iterations; - _forceDataRetrieval = forceDataRetrieval; - - //Prepare the infoMessages collection, if we are collecting statistics - //if (stats_comm != null) - // theInfoMessages.Add(stats_comm.Connection.GetHashCode(), new List()); - } - - public static bool RunCancelled - { - set { _runCancelled = value; } - } - - private static void GetInfoMessages(object sender, SqlInfoMessageEventArgs args) - { - foreach (SqlError err in args.Errors) - { - var matches = FindReads.Split(err.Message); - - //we have a read - if (matches.Length > 1) - { - _outInfo.LogicalReads += Convert.ToInt32(matches[1]); - continue; - } - - matches = FindTimes.Split(err.Message); - - //we have times - if (matches.Length > 1) - { - _outInfo.CpuTime += Convert.ToInt32(matches[1]); - _outInfo.ElapsedTime += Convert.ToInt32(matches[2]); - } - } - } - - public void StartLoadThread() - { - try - { - //do the work - using (var conn = _queryComm.Connection) - { - SqlInfoMessageEventHandler handler = GetInfoMessages; - - for (var i = 0; i < _iterations; i++) - { - if (_runCancelled) - throw new Exception(); - - Exception outException = null; - - try - { - //initialize the outInfo structure - _outInfo = new QueryOutput(); - - conn.Open(); - - //set up the statistics gathering - if (_statsComm != null) - { - _statsComm.ExecuteNonQuery(); - Thread.Sleep(0); - conn.InfoMessage += handler; - } - - //Params are assigned only once -- after that, their values are dynamically retrieved - if (_queryComm.Parameters.Count > 0) - { - ParamServer.GetNextRow_Values(_queryComm.Parameters); - } - - _sw.Start(); - - //TODO: This could be made better - if (_forceDataRetrieval) - { - var reader = _queryComm.ExecuteReader(); - Thread.Sleep(0); - - do - { - Thread.Sleep(0); - - while (reader.Read()) - { - //grab the first column to force the row down the pipe - var x = reader[0]; - Thread.Sleep(0); - } - } while (reader.NextResult()); - } - else - { - _queryComm.ExecuteNonQuery(); - Thread.Sleep(0); - } - - _sw.Stop(); - } - catch (Exception e) - { - if (_runCancelled) - throw; - else - outException = e; - - if (_sw.IsRunning) - { - _sw.Stop(); - } - } - finally - { - //Clean up the connection - if (_statsComm != null) - conn.InfoMessage -= handler; - } - - var finished = i == _iterations - 1; - - //List infoMessages = null; - - //infoMessages = (stats_comm != null) ? theInfoMessages[connectionHashCode] : null; - - /* - queryOutput theout = new queryOutput( - outException, - sw.Elapsed, - finished, - (infoMessages == null || infoMessages.Count == 0) ? null : infoMessages.ToArray()); - */ - - _outInfo.E = outException; - _outInfo.Time = _sw.Elapsed; - _outInfo.Finished = finished; - - lock (QueryOutInfo) - { - QueryOutInfo.Enqueue(_outInfo); - Monitor.Pulse(QueryOutInfo); - } - - //Prep the collection for the next round - //if (infoMessages != null && infoMessages.Count > 0) - // infoMessages.Clear(); - - _sw.Reset(); - } - } - } - catch - { - if (_runCancelled) - { - //queryOutput theout = new queryOutput(null, new TimeSpan(0), true, null); - _outInfo.Time = new TimeSpan(0); - _outInfo.Finished = true; - - lock (QueryOutInfo) - { - QueryOutInfo.Enqueue(_outInfo); - } - } - else - throw; - } - } - } - - public class QueryOutput - { - public int CpuTime; - public Exception E; - public int ElapsedTime; - public bool Finished; - public int LogicalReads; - public TimeSpan Time; - - /* - public queryOutput( - Exception e, - TimeSpan time, - bool finished, - string[] infoMessages) - { - this.e = e; - this.time = time; - this.finished = finished; - this.infoMessages = infoMessages; - } - */ - } - - private class ThreadKiller - { - private readonly SqlCommand[] _theCommands; - private readonly Thread[] _theThreads; - - public ThreadKiller(Thread[] theThreads, SqlCommand[] theCommands) - { - _theThreads = theThreads; - _theCommands = theCommands; - } - - public void KillEm() - { - foreach (var comm in _theCommands) - { - comm.Cancel(); - comm.Connection.Dispose(); - comm.Connection = null; - comm.Dispose(); - Thread.Sleep(0); - } - - var keepKilling = true; - - while (keepKilling) - { - keepKilling = false; - - foreach (var theThread in _theThreads) - { - if (theThread.IsAlive) - { - keepKilling = true; - theThread.Abort(); - Thread.Sleep(0); - } - } - } - } - } - } -} \ No newline at end of file diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/Options.Designer.cs b/Solution/SQLQueryStress/src/SQLQueryStress/Options.Designer.cs deleted file mode 100644 index 15cd0620..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/Options.Designer.cs +++ /dev/null @@ -1,241 +0,0 @@ -namespace SQLQueryStress -{ - partial class Options - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.IOStatistics_checkBox = new System.Windows.Forms.CheckBox(); - this.timeStatistics_checkBox = new System.Windows.Forms.CheckBox(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.connectionPooling_checkBox = new System.Windows.Forms.CheckBox(); - this.clientDataRetrieval_checkBox = new System.Windows.Forms.CheckBox(); - this.ok_button = new System.Windows.Forms.Button(); - this.cancel_button = new System.Windows.Forms.Button(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.connectionTimeout_numericUpDown = new System.Windows.Forms.NumericUpDown(); - this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.commandTimeout_numericUpDown = new System.Windows.Forms.NumericUpDown(); - this.groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.connectionTimeout_numericUpDown)).BeginInit(); - this.groupBox2.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.commandTimeout_numericUpDown)).BeginInit(); - this.SuspendLayout(); - // - // IOStatistics_checkBox - // - this.IOStatistics_checkBox.AutoSize = true; - this.IOStatistics_checkBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.IOStatistics_checkBox.Location = new System.Drawing.Point(6, 58); - this.IOStatistics_checkBox.Name = "IOStatistics_checkBox"; - this.IOStatistics_checkBox.Size = new System.Drawing.Size(144, 17); - this.IOStatistics_checkBox.TabIndex = 0; - this.IOStatistics_checkBox.Text = "Collect I/O Statistics"; - this.IOStatistics_checkBox.UseVisualStyleBackColor = true; - // - // timeStatistics_checkBox - // - this.timeStatistics_checkBox.AutoSize = true; - this.timeStatistics_checkBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.timeStatistics_checkBox.Location = new System.Drawing.Point(6, 81); - this.timeStatistics_checkBox.Name = "timeStatistics_checkBox"; - this.timeStatistics_checkBox.Size = new System.Drawing.Size(152, 17); - this.timeStatistics_checkBox.TabIndex = 1; - this.timeStatistics_checkBox.Text = "Collect Time Statistics"; - this.timeStatistics_checkBox.UseVisualStyleBackColor = true; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label1.Location = new System.Drawing.Point(3, 17); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(120, 13); - this.label1.TabIndex = 3; - this.label1.Text = "Connection Timeout"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label2.Location = new System.Drawing.Point(3, 17); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(196, 13); - this.label2.TabIndex = 5; - this.label2.Text = "Command Timeout (0 = Unlimited)"; - // - // connectionPooling_checkBox - // - this.connectionPooling_checkBox.AutoSize = true; - this.connectionPooling_checkBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.connectionPooling_checkBox.Location = new System.Drawing.Point(6, 58); - this.connectionPooling_checkBox.Name = "connectionPooling_checkBox"; - this.connectionPooling_checkBox.Size = new System.Drawing.Size(179, 17); - this.connectionPooling_checkBox.TabIndex = 6; - this.connectionPooling_checkBox.Text = "Enable Connection Pooling"; - this.connectionPooling_checkBox.UseVisualStyleBackColor = true; - // - // clientDataRetrieval_checkBox - // - this.clientDataRetrieval_checkBox.AutoSize = true; - this.clientDataRetrieval_checkBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.clientDataRetrieval_checkBox.Location = new System.Drawing.Point(6, 104); - this.clientDataRetrieval_checkBox.Name = "clientDataRetrieval_checkBox"; - this.clientDataRetrieval_checkBox.Size = new System.Drawing.Size(195, 17); - this.clientDataRetrieval_checkBox.TabIndex = 7; - this.clientDataRetrieval_checkBox.Text = "Force Client Retrieval of Data"; - this.clientDataRetrieval_checkBox.UseVisualStyleBackColor = true; - // - // ok_button - // - this.ok_button.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.ok_button.Location = new System.Drawing.Point(344, 145); - this.ok_button.Name = "ok_button"; - this.ok_button.Size = new System.Drawing.Size(75, 23); - this.ok_button.TabIndex = 8; - this.ok_button.Text = "OK"; - this.ok_button.UseVisualStyleBackColor = true; - this.ok_button.Click += new System.EventHandler(this.ok_button_Click); - // - // cancel_button - // - this.cancel_button.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancel_button.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.cancel_button.Location = new System.Drawing.Point(425, 145); - this.cancel_button.Name = "cancel_button"; - this.cancel_button.Size = new System.Drawing.Size(75, 23); - this.cancel_button.TabIndex = 9; - this.cancel_button.Text = "Cancel"; - this.cancel_button.UseVisualStyleBackColor = true; - this.cancel_button.Click += new System.EventHandler(this.cancel_button_Click); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.connectionTimeout_numericUpDown); - this.groupBox1.Controls.Add(this.label1); - this.groupBox1.Controls.Add(this.connectionPooling_checkBox); - this.groupBox1.Location = new System.Drawing.Point(12, 12); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(241, 127); - this.groupBox1.TabIndex = 10; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "Connection Options"; - // - // connectionTimeout_numericUpDown - // - this.connectionTimeout_numericUpDown.Location = new System.Drawing.Point(6, 33); - this.connectionTimeout_numericUpDown.Maximum = new decimal(new int[] { - 60, - 0, - 0, - 0}); - this.connectionTimeout_numericUpDown.Minimum = new decimal(new int[] { - 1, - 0, - 0, - 0}); - this.connectionTimeout_numericUpDown.Name = "connectionTimeout_numericUpDown"; - this.connectionTimeout_numericUpDown.Size = new System.Drawing.Size(120, 20); - this.connectionTimeout_numericUpDown.TabIndex = 7; - this.connectionTimeout_numericUpDown.Value = new decimal(new int[] { - 1, - 0, - 0, - 0}); - // - // groupBox2 - // - this.groupBox2.Controls.Add(this.commandTimeout_numericUpDown); - this.groupBox2.Controls.Add(this.label2); - this.groupBox2.Controls.Add(this.IOStatistics_checkBox); - this.groupBox2.Controls.Add(this.timeStatistics_checkBox); - this.groupBox2.Controls.Add(this.clientDataRetrieval_checkBox); - this.groupBox2.Location = new System.Drawing.Point(259, 12); - this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(241, 127); - this.groupBox2.TabIndex = 11; - this.groupBox2.TabStop = false; - this.groupBox2.Text = "Command Options"; - // - // commandTimeout_numericUpDown - // - this.commandTimeout_numericUpDown.Location = new System.Drawing.Point(6, 33); - this.commandTimeout_numericUpDown.Maximum = new decimal(new int[] { - 32767, - 0, - 0, - 0}); - this.commandTimeout_numericUpDown.Name = "commandTimeout_numericUpDown"; - this.commandTimeout_numericUpDown.Size = new System.Drawing.Size(120, 20); - this.commandTimeout_numericUpDown.TabIndex = 8; - this.commandTimeout_numericUpDown.Tag = ""; - // - // Options - // - this.AcceptButton = this.ok_button; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.cancel_button; - this.ClientSize = new System.Drawing.Size(514, 178); - this.Controls.Add(this.groupBox2); - this.Controls.Add(this.groupBox1); - this.Controls.Add(this.cancel_button); - this.Controls.Add(this.ok_button); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "Options"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Options"; - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.connectionTimeout_numericUpDown)).EndInit(); - this.groupBox2.ResumeLayout(false); - this.groupBox2.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.commandTimeout_numericUpDown)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.CheckBox IOStatistics_checkBox; - private System.Windows.Forms.CheckBox timeStatistics_checkBox; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.CheckBox connectionPooling_checkBox; - private System.Windows.Forms.CheckBox clientDataRetrieval_checkBox; - private System.Windows.Forms.Button ok_button; - private System.Windows.Forms.Button cancel_button; - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.GroupBox groupBox2; - private System.Windows.Forms.NumericUpDown connectionTimeout_numericUpDown; - private System.Windows.Forms.NumericUpDown commandTimeout_numericUpDown; - } -} \ No newline at end of file diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/Options.cs b/Solution/SQLQueryStress/src/SQLQueryStress/Options.cs deleted file mode 100644 index 1259f990..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/Options.cs +++ /dev/null @@ -1,45 +0,0 @@ -#region - -using System; -using System.Windows.Forms; - -#endregion - -namespace SQLQueryStress -{ - public partial class Options : Form - { - private readonly Form1.QueryStressSettings _settings; - - public Options(Form1.QueryStressSettings settings) - { - _settings = settings; - - InitializeComponent(); - - connectionTimeout_numericUpDown.Value = settings.ConnectionTimeout; - commandTimeout_numericUpDown.Value = settings.CommandTimeout; - connectionPooling_checkBox.Checked = settings.EnableConnectionPooling; - IOStatistics_checkBox.Checked = settings.CollectIoStats; - timeStatistics_checkBox.Checked = settings.CollectTimeStats; - clientDataRetrieval_checkBox.Checked = settings.ForceDataRetrieval; - } - - private void cancel_button_Click(object sender, EventArgs e) - { - Dispose(); - } - - private void ok_button_Click(object sender, EventArgs e) - { - _settings.ConnectionTimeout = (int) connectionTimeout_numericUpDown.Value; - _settings.CommandTimeout = (int) commandTimeout_numericUpDown.Value; - _settings.EnableConnectionPooling = connectionPooling_checkBox.Checked; - _settings.CollectIoStats = IOStatistics_checkBox.Checked; - _settings.CollectTimeStats = timeStatistics_checkBox.Checked; - _settings.ForceDataRetrieval = clientDataRetrieval_checkBox.Checked; - - Dispose(); - } - } -} \ No newline at end of file diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/Options.resx b/Solution/SQLQueryStress/src/SQLQueryStress/Options.resx deleted file mode 100644 index 19dc0dd8..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/Options.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/ParamWindow.Designer.cs b/Solution/SQLQueryStress/src/SQLQueryStress/ParamWindow.Designer.cs deleted file mode 100644 index e9163656..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/ParamWindow.Designer.cs +++ /dev/null @@ -1,197 +0,0 @@ -namespace SQLQueryStress -{ - partial class ParamWindow - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.columnMapGrid = new System.Windows.Forms.DataGridView(); - this.Column = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Datatype = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Parameter = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.paramQueryTextBox = new System.Windows.Forms.TextBox(); - this.label1 = new System.Windows.Forms.Label(); - this.getColumnsButton = new System.Windows.Forms.Button(); - this.okButton = new System.Windows.Forms.Button(); - this.cancelButton = new System.Windows.Forms.Button(); - this.label2 = new System.Windows.Forms.Label(); - this.database_button = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.columnMapGrid)).BeginInit(); - this.SuspendLayout(); - // - // columnMapGrid - // - this.columnMapGrid.AllowUserToAddRows = false; - this.columnMapGrid.AllowUserToDeleteRows = false; - this.columnMapGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.columnMapGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { - this.Column, - this.Datatype, - this.Parameter}); - this.columnMapGrid.Location = new System.Drawing.Point(12, 274); - this.columnMapGrid.Name = "columnMapGrid"; - this.columnMapGrid.ShowEditingIcon = false; - this.columnMapGrid.Size = new System.Drawing.Size(435, 185); - this.columnMapGrid.TabIndex = 0; - // - // Column - // - this.Column.HeaderText = "Parameter"; - this.Column.Name = "Column"; - this.Column.Width = 130; - // - // Datatype - // - this.Datatype.HeaderText = "Datatype"; - this.Datatype.Name = "Datatype"; - this.Datatype.Width = 130; - // - // Parameter - // - this.Parameter.HeaderText = "Column"; - this.Parameter.Name = "Parameter"; - this.Parameter.Width = 130; - // - // paramQueryTextBox - // - this.paramQueryTextBox.AcceptsReturn = true; - this.paramQueryTextBox.AcceptsTab = true; - this.paramQueryTextBox.AllowDrop = true; - this.paramQueryTextBox.Location = new System.Drawing.Point(12, 26); - this.paramQueryTextBox.Multiline = true; - this.paramQueryTextBox.Name = "paramQueryTextBox"; - this.paramQueryTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.paramQueryTextBox.Size = new System.Drawing.Size(435, 186); - this.paramQueryTextBox.TabIndex = 1; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label1.Location = new System.Drawing.Point(12, 10); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(101, 13); - this.label1.TabIndex = 2; - this.label1.Text = "Parameter Query"; - // - // getColumnsButton - // - this.getColumnsButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.getColumnsButton.Location = new System.Drawing.Point(15, 219); - this.getColumnsButton.Name = "getColumnsButton"; - this.getColumnsButton.Size = new System.Drawing.Size(98, 23); - this.getColumnsButton.TabIndex = 3; - this.getColumnsButton.Text = "Get Columns"; - this.getColumnsButton.UseVisualStyleBackColor = true; - this.getColumnsButton.Click += new System.EventHandler(this.getColumnsButton_Click); - // - // okButton - // - this.okButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.okButton.Location = new System.Drawing.Point(291, 465); - this.okButton.Name = "okButton"; - this.okButton.Size = new System.Drawing.Size(75, 23); - this.okButton.TabIndex = 4; - this.okButton.Text = "OK"; - this.okButton.UseVisualStyleBackColor = true; - this.okButton.Click += new System.EventHandler(this.okButton_Click); - // - // cancelButton - // - this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancelButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.cancelButton.Location = new System.Drawing.Point(372, 465); - this.cancelButton.Name = "cancelButton"; - this.cancelButton.Size = new System.Drawing.Size(75, 23); - this.cancelButton.TabIndex = 5; - this.cancelButton.Text = "Cancel"; - this.cancelButton.UseVisualStyleBackColor = true; - this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label2.Location = new System.Drawing.Point(12, 258); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(122, 13); - this.label2.TabIndex = 6; - this.label2.Text = "Parameter Mappings"; - // - // database_button - // - this.database_button.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.database_button.Location = new System.Drawing.Point(119, 219); - this.database_button.Name = "database_button"; - this.database_button.Size = new System.Drawing.Size(94, 23); - this.database_button.TabIndex = 7; - this.database_button.Text = "Database"; - this.database_button.UseVisualStyleBackColor = true; - this.database_button.Click += new System.EventHandler(this.database_button_Click); - // - // ParamWindow - // - this.AcceptButton = this.okButton; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.cancelButton; - this.ClientSize = new System.Drawing.Size(462, 500); - this.Controls.Add(this.database_button); - this.Controls.Add(this.label2); - this.Controls.Add(this.cancelButton); - this.Controls.Add(this.okButton); - this.Controls.Add(this.getColumnsButton); - this.Controls.Add(this.label1); - this.Controls.Add(this.paramQueryTextBox); - this.Controls.Add(this.columnMapGrid); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ParamWindow"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.Text = "Parameter Substitution"; - ((System.ComponentModel.ISupportInitialize)(this.columnMapGrid)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.TextBox paramQueryTextBox; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Button getColumnsButton; - private System.Windows.Forms.Button okButton; - private System.Windows.Forms.Button cancelButton; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Button database_button; - private System.Windows.Forms.DataGridView columnMapGrid; - private System.Windows.Forms.DataGridViewTextBoxColumn Column; - private System.Windows.Forms.DataGridViewTextBoxColumn Datatype; - private System.Windows.Forms.DataGridViewTextBoxColumn Parameter; - } -} \ No newline at end of file diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/ParamWindow.cs b/Solution/SQLQueryStress/src/SQLQueryStress/ParamWindow.cs deleted file mode 100644 index 3d4b89d0..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/ParamWindow.cs +++ /dev/null @@ -1,200 +0,0 @@ -#region - -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.SqlClient; -using System.Text.RegularExpressions; -using System.Windows.Forms; -using SQLQueryStress.Properties; - -#endregion - -namespace SQLQueryStress -{ - public partial class ParamWindow : Form - { - //load query defined in the main form - private readonly string _outerQuery; - - //parameter values from the parameter query defined in this form - private readonly Dictionary _paramValues = new Dictionary(); - - //Query Stress Settings - private readonly Form1.QueryStressSettings _settings; - - //Variables from the load query - private string[] _queryVariables; - - public ParamWindow(Form1.QueryStressSettings settings, string outerQuery) - { - InitializeComponent(); - - _settings = settings; - - _outerQuery = outerQuery; - - paramQueryTextBox.Text = (string) settings.ParamQuery.Clone(); - - columnMapGrid.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable; - columnMapGrid.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable; - columnMapGrid.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable; - - //TODO: Which event to handle?!?! - columnMapGrid.CellEndEdit += columnMapGrid_CellValueChanged; - - if ((outerQuery.Length > 0) && (paramQueryTextBox.Text.Length > 0)) - { - getColumnsButton_Click("constructor", null); - } - } - - private void cancelButton_Click(object sender, EventArgs e) - { - Dispose(); - } - - private void columnMapGrid_CellValueChanged(object sender, DataGridViewCellEventArgs e) - { - //handle changes to the parameter column - if (e.ColumnIndex == 2) - { - var theRow = columnMapGrid.Rows[e.RowIndex]; - var combo = (DataGridViewComboBoxCell) theRow.Cells[2]; - - if (combo.Value != null) - { - var colType = _paramValues[(string) combo.Value]; - theRow.Cells[1].Value = colType; - } - else - { - theRow.Cells[1].Value = ""; - } - } - } - - private void database_button_Click(object sender, EventArgs e) - { - var dbSelect = new DatabaseSelect(_settings) {StartPosition = FormStartPosition.CenterParent}; - dbSelect.ShowDialog(); - } - - private void getColumnsButton_Click(object sender, EventArgs e) - { - _queryVariables = GetParams(); - - SqlDataReader reader = null; - - var dbInfo = _settings.ShareDbSettings ? _settings.MainDbConnectionInfo : _settings.ParamDbConnectionInfo; - - if (!dbInfo.TestConnection()) - { - MessageBox.Show(Resources.MustSetValidDatabaseConn); - return; - } - - using (var conn = new SqlConnection(dbInfo.ConnectionString)) - { - try - { - var comm = new SqlCommand(paramQueryTextBox.Text, conn); - conn.Open(); - reader = comm.ExecuteReader(CommandBehavior.SchemaOnly); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message); - } - - if (reader != null) - { - columnMapGrid.Rows.Clear(); - _paramValues.Clear(); - - for (var i = 0; i < reader.FieldCount; i++) - { - _paramValues.Add(reader.GetName(i), reader.GetDataTypeName(i)); - } - - reader.Dispose(); - - foreach (var variable in _queryVariables) - { - var colOrdinal = columnMapGrid.Rows.Add(); - var row = columnMapGrid.Rows[colOrdinal]; - row.Cells[0].Value = variable; - row.Cells[0].ReadOnly = true; - - //placeholder for columntype - row.Cells[1].Value = ""; - row.Cells[1].ReadOnly = true; - - var combo = new DataGridViewComboBoxCell(); - - combo.Items.Add(""); - - string s = sender as string; - bool checkParam = s != null && s == "constructor" && _settings.ParamMappings.ContainsKey(variable); - - foreach (var paramName in _paramValues.Keys) - { - combo.Items.Add(paramName); - - if (checkParam) - { - if (_settings.ParamMappings[variable] == paramName) - { - combo.Value = paramName; - row.Cells[1].Value = _paramValues[paramName]; - } - } - } - - row.Cells[2] = combo; - } - } - } - } - - private string[] GetParams() - { - //Find all SQL variables: - //'@', preceeded by '=', ',', or any white space character - //then, any "word" character - //Finally, '=', ',', or any white space, repeated 0 or more times - //(in the case of end-of-string, will be 0 times) - var r = new Regex(@"(?<=[=,\s\(])@\w{1,}(?=[=,\s\)]?)"); - - var output = new List(); - - foreach (Match m in r.Matches(_outerQuery)) - { - var lowerVal = m.Value.ToLower(); - if (!output.Contains(lowerVal)) - output.Add(m.Value.ToLower()); - } - - if (output.Count == 0) - MessageBox.Show(Resources.NoVarsWereIdentified); - - return output.ToArray(); - } - - private void okButton_Click(object sender, EventArgs e) - { - _settings.ParamQuery = paramQueryTextBox.Text; - - var localParamMappings = new Dictionary(); - foreach (DataGridViewRow row in columnMapGrid.Rows) - { - if ((string) row.Cells[2].Value != "") - localParamMappings.Add((string) row.Cells[0].Value, (string) row.Cells[2].Value); - } - - _settings.ParamMappings = localParamMappings; - - Dispose(); - } - } -} \ No newline at end of file diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/ParamWindow.resx b/Solution/SQLQueryStress/src/SQLQueryStress/ParamWindow.resx deleted file mode 100644 index c3a0a497..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/ParamWindow.resx +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - True - - - True - - - True - - \ No newline at end of file diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/Program.cs b/Solution/SQLQueryStress/src/SQLQueryStress/Program.cs deleted file mode 100644 index 6740c613..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/Program.cs +++ /dev/null @@ -1,27 +0,0 @@ -#region - -using System; -using System.Windows.Forms; - -#endregion - -namespace SQLQueryStress -{ - internal static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - private static void Main(string[] args) - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - - Form1 f = args.Length > 0 ? new Form1(args[0]) : new Form1(); - - f.StartPosition = FormStartPosition.CenterScreen; - Application.Run(f); - } - } -} \ No newline at end of file diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/Properties/AssemblyInfo.cs b/Solution/SQLQueryStress/src/SQLQueryStress/Properties/AssemblyInfo.cs deleted file mode 100644 index b88b32a0..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,40 +0,0 @@ -#region - -using System.Reflection; -using System.Runtime.InteropServices; - -#endregion - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitle("SQLQueryStress")] -[assembly: AssemblyDescription("SQL Server Load Test Tool")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("amachanic@gmail.com")] -[assembly: AssemblyProduct("SQLQueryStress")] -[assembly: AssemblyCopyright("Copyright © 2006, 2007 Adam Machanic")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM - -[assembly: Guid("e4c26a22-8376-4ff3-aa7f-878ebd9f34b3")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// - -[assembly: AssemblyVersion("0.9.7.0")] -[assembly: AssemblyFileVersion("0.9.7.0")] \ No newline at end of file diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/Properties/Resources.Designer.cs b/Solution/SQLQueryStress/src/SQLQueryStress/Properties/Resources.Designer.cs deleted file mode 100644 index 95e2102a..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/Properties/Resources.Designer.cs +++ /dev/null @@ -1,145 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace SQLQueryStress.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SQLQueryStress.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Connection Failed. - /// - internal static string ConnFail { - get { - return ResourceManager.GetString("ConnFail", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Connection Succeeded. - /// - internal static string ConnSucc { - get { - return ResourceManager.GetString("ConnSucc", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Error loading settings.. - /// - internal static string ErrLoadingSettings { - get { - return ResourceManager.GetString("ErrLoadingSettings", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Error saving settings.. - /// - internal static string ErrorSavingSettings { - get { - return ResourceManager.GetString("ErrorSavingSettings", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Exceptions. - /// - internal static string Exceptions { - get { - return ResourceManager.GetString("Exceptions", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to You must set valid database connection information. Click the Database button to configure the settings.. - /// - internal static string MustSetValidDatabaseConn { - get { - return ResourceManager.GetString("MustSetValidDatabaseConn", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to You must set valid database connection information. Click the Database button to configure the settings.. - /// - internal static string MustSetValidDbConnInfo { - get { - return ResourceManager.GetString("MustSetValidDbConnInfo", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to No variables were identified in the main query. Variables must be used there before parameter substitution can be used.. - /// - internal static string NoVarsWereIdentified { - get { - return ResourceManager.GetString("NoVarsWereIdentified", resourceCulture); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). - /// - internal static System.Drawing.Icon QueryStressIcon { - get { - object obj = ResourceManager.GetObject("QueryStressIcon", resourceCulture); - return ((System.Drawing.Icon)(obj)); - } - } - } -} diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/Properties/Resources.resx b/Solution/SQLQueryStress/src/SQLQueryStress/Properties/Resources.resx deleted file mode 100644 index e5da1968..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/Properties/Resources.resx +++ /dev/null @@ -1,148 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - ..\Resources\QueryStressIcon.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - You must set valid database connection information. Click the Database button to configure the settings. - - - Error loading settings. - - - Error saving settings. - - - Exceptions - - - You must set valid database connection information. Click the Database button to configure the settings. - - - No variables were identified in the main query. Variables must be used there before parameter substitution can be used. - - - Connection Succeeded - - - Connection Failed - - \ No newline at end of file diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/Properties/Settings.Designer.cs b/Solution/SQLQueryStress/src/SQLQueryStress/Properties/Settings.Designer.cs deleted file mode 100644 index 4355cbf0..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/Properties/Settings.Designer.cs +++ /dev/null @@ -1,26 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace SQLQueryStress.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - } -} diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/Properties/Settings.settings b/Solution/SQLQueryStress/src/SQLQueryStress/Properties/Settings.settings deleted file mode 100644 index e04fc631..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/Properties/Settings.settings +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/Properties/app.manifest b/Solution/SQLQueryStress/src/SQLQueryStress/Properties/app.manifest deleted file mode 100644 index e58cc9e5..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/Properties/app.manifest +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/Resources/QueryStressIcon.ico b/Solution/SQLQueryStress/src/SQLQueryStress/Resources/QueryStressIcon.ico deleted file mode 100644 index e27f58b3..00000000 Binary files a/Solution/SQLQueryStress/src/SQLQueryStress/Resources/QueryStressIcon.ico and /dev/null differ diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/SQLQueryStress.csproj b/Solution/SQLQueryStress/src/SQLQueryStress/SQLQueryStress.csproj deleted file mode 100644 index 84b87475..00000000 --- a/Solution/SQLQueryStress/src/SQLQueryStress/SQLQueryStress.csproj +++ /dev/null @@ -1,193 +0,0 @@ - - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {02A166A4-EE64-432F-AA6E-08C7984BD7BC} - WinExe - Properties - SQLQueryStress - SQLQueryStress - false - false - sqlQueryStress.snk - Internet - false - 2546E8A9F11989C71B0CFBEF57D992392F75EA37 - SQLQueryStress_TemporaryKey.pfx - false - Resources\QueryStressIcon.ico - v4.0 - - - - - 2.0 - c:\testdeploy\querystress\ - true - Disk - false - Background - 7 - Days - true - false - true - SQLQueryStress - Adam Machanic - 0 - 0.9.0.0 - false - true - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - true - MinimumRecommendedRules.ruleset - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - false - - - - - - - - - - - - Form - - - AboutBox.cs - - - - Form - - - DatabaseSelect.cs - - - Form - - - Form1.cs - - - Form - - - DataViewer.cs - - - - Form - - - Options.cs - - - Form - - - ParamWindow.cs - - - - - Designer - AboutBox.cs - - - Designer - DatabaseSelect.cs - - - Designer - Form1.cs - - - Designer - DataViewer.cs - - - Designer - Options.cs - - - Designer - ParamWindow.cs - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - True - - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - True - Settings.settings - True - - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 2.0 - true - - - False - .NET Framework 3.5 SP1 - false - - - - - - - - \ No newline at end of file diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/SQLQueryStress_Documentation.doc b/Solution/SQLQueryStress/src/SQLQueryStress/SQLQueryStress_Documentation.doc deleted file mode 100644 index 6da499fe..00000000 Binary files a/Solution/SQLQueryStress/src/SQLQueryStress/SQLQueryStress_Documentation.doc and /dev/null differ diff --git a/Solution/SQLQueryStress/src/SQLQueryStress/sqlQueryStress.snk b/Solution/SQLQueryStress/src/SQLQueryStress/sqlQueryStress.snk deleted file mode 100644 index b114fbfe..00000000 Binary files a/Solution/SQLQueryStress/src/SQLQueryStress/sqlQueryStress.snk and /dev/null differ diff --git a/Stored_Procedure/README.md b/Stored_Procedure/README.md index 3a05b37b..e2ca3c3f 100644 --- a/Stored_Procedure/README.md +++ b/Stored_Procedure/README.md @@ -43,12 +43,6 @@ Original link: http://www.sqlshack.com/managing-untrusted-foreign-keys/
Tested on SQL Server version: 2008/2012/2014 -## [sp_SrvPermissions](sp_SrvPermissions.sql) -Author: Kenneth Fisher
-Original link: http://sqlstudies.com/free-scripts/sp_srvpermissions/
-Tested on SQL Server version: 2012 - - ## [sp_capture_login_auth](sp_capture_login_auth.sql) Author: Unknown
Original link: Unknown
diff --git a/Stored_Procedure/Recover_Deleted_Data_Proc.sql b/Stored_Procedure/Recover_Deleted_Data_Proc.sql new file mode 100644 index 00000000..6ca21da0 --- /dev/null +++ b/Stored_Procedure/Recover_Deleted_Data_Proc.sql @@ -0,0 +1,708 @@ +-- Script Name: Recover_Deleted_Data_Proc +-- Script Type : Recovery Procedure +-- Develop By: Muhammad Imran +-- Date Created: 15 Oct 2011 +-- Modify Date: 22 Aug 2012 +-- Version : 3.1 +-- Notes : Included BLOB data types for recovery.& Compatibile with Default , CS collation , Arabic_CI_AS. + +--DROP PROCEDURE Recover_Deleted_Data_Proc +--GO +Create PROCEDURE Recover_Deleted_Data_Proc +@Database_Name NVARCHAR(MAX), +@SchemaName_n_TableName NVARCHAR(Max), +@Date_From DATETIME='1900/01/01', +@Date_To DATETIME ='9999/12/31' +AS + +DECLARE @RowLogContents VARBINARY(8000) +DECLARE @TransactionID NVARCHAR(Max) +DECLARE @AllocUnitID BIGINT +DECLARE @AllocUnitName NVARCHAR(Max) +DECLARE @SQL NVARCHAR(Max) +DECLARE @Compatibility_Level INT + + +SELECT @Compatibility_Level=dtb.compatibility_level +FROM +master.sys.databases AS dtb WHERE dtb.name=@Database_Name + +IF ISNULL(@Compatibility_Level,0)<=80 +BEGIN + RAISERROR('The compatibility level should be equal to or greater SQL SERVER 2005 (90)',16,1) + RETURN +END + +IF (SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE [TABLE_SCHEMA]+'.'+[TABLE_NAME]=@SchemaName_n_TableName)=0 +BEGIN + RAISERROR('Could not found the table in the defined database',16,1) + RETURN +END + +DECLARE @bitTable TABLE +( + [ID] INT, + [Bitvalue] INT +) +--Create table to set the bit position of one byte. + +INSERT INTO @bitTable +SELECT 0,2 UNION ALL +SELECT 1,2 UNION ALL +SELECT 2,4 UNION ALL +SELECT 3,8 UNION ALL +SELECT 4,16 UNION ALL +SELECT 5,32 UNION ALL +SELECT 6,64 UNION ALL +SELECT 7,128 + +--Create table to collect the row data. +DECLARE @DeletedRecords TABLE +( + [Row ID] INT IDENTITY(1,1), + [RowLogContents] VARBINARY(8000), + [AllocUnitID] BIGINT, + [Transaction ID] NVARCHAR(Max), + [FixedLengthData] SMALLINT, + [TotalNoOfCols] SMALLINT, + [NullBitMapLength] SMALLINT, + [NullBytes] VARBINARY(8000), + [TotalNoofVarCols] SMALLINT, + [ColumnOffsetArray] VARBINARY(8000), + [VarColumnStart] SMALLINT, + [Slot ID] INT, + [NullBitMap] VARCHAR(MAX) + +) +--Create a common table expression to get all the row data plus how many bytes we have for each row. +;WITH RowData AS ( +SELECT + +[RowLog Contents 0] AS [RowLogContents] + +,[AllocUnitID] AS [AllocUnitID] + +,[Transaction ID] AS [Transaction ID] + +--[Fixed Length Data] = Substring (RowLog content 0, Status Bit A+ Status Bit B + 1,2 bytes) +,CONVERT(SMALLINT, CONVERT(BINARY(2), REVERSE(SUBSTRING([RowLog Contents 0], 2 + 1, 2)))) AS [FixedLengthData] --@FixedLengthData + +-- [TotalnoOfCols] = Substring (RowLog content 0, [Fixed Length Data] + 1,2 bytes) +,CONVERT(INT, CONVERT(BINARY(2), REVERSE(SUBSTRING([RowLog Contents 0], CONVERT(SMALLINT, CONVERT(BINARY(2) +,REVERSE(SUBSTRING([RowLog Contents 0], 2 + 1, 2)))) + 1, 2)))) as [TotalNoOfCols] + +--[NullBitMapLength]=ceiling([Total No of Columns] /8.0) +,CONVERT(INT, ceiling(CONVERT(INT, CONVERT(BINARY(2), REVERSE(SUBSTRING([RowLog Contents 0], CONVERT(SMALLINT, CONVERT(BINARY(2) +,REVERSE(SUBSTRING([RowLog Contents 0], 2 + 1, 2)))) + 1, 2))))/8.0)) as [NullBitMapLength] + +--[Null Bytes] = Substring (RowLog content 0, Status Bit A+ Status Bit B + [Fixed Length Data] +1, [NullBitMapLength] ) +,SUBSTRING([RowLog Contents 0], CONVERT(SMALLINT, CONVERT(BINARY(2), REVERSE(SUBSTRING([RowLog Contents 0], 2 + 1, 2)))) + 3, +CONVERT(INT, ceiling(CONVERT(INT, CONVERT(BINARY(2), REVERSE(SUBSTRING([RowLog Contents 0], CONVERT(SMALLINT, CONVERT(BINARY(2) +,REVERSE(SUBSTRING([RowLog Contents 0], 2 + 1, 2)))) + 1, 2))))/8.0))) as [NullBytes] + +--[TotalNoofVarCols] = Substring (RowLog content 0, Status Bit A+ Status Bit B + [Fixed Length Data] +1, [Null Bitmap length] + 2 ) +,(CASE WHEN SUBSTRING([RowLog Contents 0], 1, 1) In (0x10,0x30,0x70) THEN +CONVERT(INT, CONVERT(BINARY(2), REVERSE(SUBSTRING([RowLog Contents 0], +CONVERT(SMALLINT, CONVERT(BINARY(2), REVERSE(SUBSTRING([RowLog Contents 0], 2 + 1, 2)))) + 3 ++ CONVERT(INT, ceiling(CONVERT(INT, CONVERT(BINARY(2), REVERSE(SUBSTRING([RowLog Contents 0], CONVERT(SMALLINT, CONVERT(BINARY(2) +,REVERSE(SUBSTRING([RowLog Contents 0], 2 + 1, 2)))) + 1, 2))))/8.0)), 2)))) ELSE null END) AS [TotalNoofVarCols] + +--[ColumnOffsetArray]= Substring (RowLog content 0, Status Bit A+ Status Bit B + [Fixed Length Data] +1, [Null Bitmap length] + 2 , [TotalNoofVarCols]*2 ) +,(CASE WHEN SUBSTRING([RowLog Contents 0], 1, 1) In (0x10,0x30,0x70) THEN +SUBSTRING([RowLog Contents 0] +, CONVERT(SMALLINT, CONVERT(BINARY(2), REVERSE(SUBSTRING([RowLog Contents 0], 2 + 1, 2)))) + 3 ++ CONVERT(INT, ceiling(CONVERT(INT, CONVERT(BINARY(2), REVERSE(SUBSTRING([RowLog Contents 0], CONVERT(SMALLINT, CONVERT(BINARY(2) +,REVERSE(SUBSTRING([RowLog Contents 0], 2 + 1, 2)))) + 1, 2))))/8.0)) + 2 +, (CASE WHEN SUBSTRING([RowLog Contents 0], 1, 1) In (0x10,0x30,0x70) THEN +CONVERT(INT, CONVERT(BINARY(2), REVERSE(SUBSTRING([RowLog Contents 0], +CONVERT(SMALLINT, CONVERT(BINARY(2), REVERSE(SUBSTRING([RowLog Contents 0], 2 + 1, 2)))) + 3 ++ CONVERT(INT, ceiling(CONVERT(INT, CONVERT(BINARY(2), REVERSE(SUBSTRING([RowLog Contents 0], CONVERT(SMALLINT, CONVERT(BINARY(2) +,REVERSE(SUBSTRING([RowLog Contents 0], 2 + 1, 2)))) + 1, 2))))/8.0)), 2)))) ELSE null END) +* 2) ELSE null END) AS [ColumnOffsetArray] + +-- Variable column Start = Status Bit A+ Status Bit B + [Fixed Length Data] + [Null Bitmap length] + 2+([TotalNoofVarCols]*2) +,CASE WHEN SUBSTRING([RowLog Contents 0], 1, 1)In (0x10,0x30,0x70) +THEN ( +CONVERT(SMALLINT, CONVERT(BINARY(2), REVERSE(SUBSTRING([RowLog Contents 0], 2 + 1, 2)))) + 4 + ++ CONVERT(INT, ceiling(CONVERT(INT, CONVERT(BINARY(2), REVERSE(SUBSTRING([RowLog Contents 0], CONVERT(SMALLINT, CONVERT(BINARY(2) +,REVERSE(SUBSTRING([RowLog Contents 0], 2 + 1, 2)))) + 1, 2))))/8.0)) + ++ ((CASE WHEN SUBSTRING([RowLog Contents 0], 1, 1) In (0x10,0x30,0x70) THEN +CONVERT(INT, CONVERT(BINARY(2), REVERSE(SUBSTRING([RowLog Contents 0], +CONVERT(SMALLINT, CONVERT(BINARY(2), REVERSE(SUBSTRING([RowLog Contents 0], 2 + 1, 2)))) + 3 ++ CONVERT(INT, ceiling(CONVERT(INT, CONVERT(BINARY(2), REVERSE(SUBSTRING([RowLog Contents 0], CONVERT(SMALLINT, CONVERT(BINARY(2) +,REVERSE(SUBSTRING([RowLog Contents 0], 2 + 1, 2)))) + 1, 2))))/8.0)), 2)))) ELSE null END) * 2)) + +ELSE null End AS [VarColumnStart] +,[Slot ID] +FROM sys.fn_dblog(NULL, NULL) +WHERE +AllocUnitId IN +(SELECT [Allocation_unit_id] FROM sys.allocation_units allocunits +INNER JOIN sys.partitions partitions ON (allocunits.type IN (1, 3) +AND partitions.hobt_id = allocunits.container_id) OR (allocunits.type = 2 +AND partitions.partition_id = allocunits.container_id) +WHERE object_id=object_ID('' + @SchemaName_n_TableName + '')) + +AND Context IN ('LCX_MARK_AS_GHOST', 'LCX_HEAP') AND Operation in ('LOP_DELETE_ROWS') +And SUBSTRING([RowLog Contents 0], 1, 1)In (0x10,0x30,0x70) + +/*Use this subquery to filter the date*/ +AND [TRANSACTION ID] IN (SELECT DISTINCT [TRANSACTION ID] FROM sys.fn_dblog(NULL, NULL) +WHERE Context IN ('LCX_NULL') AND Operation in ('LOP_BEGIN_XACT') +And [Transaction Name] In ('DELETE','user_transaction') +And CONVERT(NVARCHAR(11),[Begin Time]) BETWEEN @Date_From AND @Date_To)), + +--Use this technique to repeate the row till the no of bytes of the row. +N1 (n) AS (SELECT 1 UNION ALL SELECT 1), +N2 (n) AS (SELECT 1 FROM N1 AS X, N1 AS Y), +N3 (n) AS (SELECT 1 FROM N2 AS X, N2 AS Y), +N4 (n) AS (SELECT ROW_NUMBER() OVER(ORDER BY X.n) + FROM N3 AS X, N3 AS Y) + + + +INSERT INTO @DeletedRecords +SELECT RowLogContents + ,[AllocUnitID] + ,[Transaction ID] + ,[FixedLengthData] + ,[TotalNoOfCols] + ,[NullBitMapLength] + ,[NullBytes] + ,[TotalNoofVarCols] + ,[ColumnOffsetArray] + ,[VarColumnStart] + ,[Slot ID] + ---Get the Null value against each column (1 means null zero means not null) + ,[NullBitMap]=(REPLACE(STUFF((SELECT ',' + + (CASE WHEN [ID]=0 THEN CONVERT(NVARCHAR(1),(SUBSTRING(NullBytes, n, 1) % 2)) ELSE CONVERT(NVARCHAR(1),((SUBSTRING(NullBytes, n, 1) / [Bitvalue]) % 2)) END) --as [nullBitMap] + +FROM +N4 AS Nums +Join RowData AS C ON n<=NullBitMapLength +Cross Join @bitTable WHERE C.[RowLogContents]=D.[RowLogContents] ORDER BY [RowLogContents],n ASC FOR XML PATH('')),1,1,''),',','')) +FROM RowData D + +IF (SELECT COUNT(*) FROM @DeletedRecords)=0 +BEGIN + RAISERROR('There is no data in the log as per the search criteria',16,1) + RETURN +END + +DECLARE @ColumnNameAndData TABLE +( + [Row ID] int, + [Rowlogcontents] varbinary(Max), + [NAME] sysname, + [nullbit] smallint, + [leaf_offset] smallint, + [length] smallint, + [system_type_id] tinyint, + [bitpos] tinyint, + [xprec] tinyint, + [xscale] tinyint, + [is_null] int, + [Column value Size]int, + [Column Length] int, + [hex_Value] varbinary(max), + [Slot ID] int, + [Update] int +) + +--Create common table expression and join it with the rowdata table +-- to get each column details +/*This part is for variable data columns*/ +--@RowLogContents, +--(col.columnOffValue - col.columnLength) + 1, +--col.columnLength +--) +INSERT INTO @ColumnNameAndData +SELECT +[Row ID], +Rowlogcontents, +NAME , +cols.leaf_null_bit AS nullbit, +leaf_offset, +ISNULL(syscolumns.length, cols.max_length) AS [length], +cols.system_type_id, +cols.leaf_bit_position AS bitpos, +ISNULL(syscolumns.xprec, cols.precision) AS xprec, +ISNULL(syscolumns.xscale, cols.scale) AS xscale, +SUBSTRING([nullBitMap], cols.leaf_null_bit, 1) AS is_null, +(CASE WHEN leaf_offset<1 and SUBSTRING([nullBitMap], cols.leaf_null_bit, 1)=0 +THEN +(Case When CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * leaf_offset*-1) - 1, 2)))) >30000 +THEN +CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * leaf_offset*-1) - 1, 2)))) - POWER(2, 15) +ELSE +CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * leaf_offset*-1) - 1, 2)))) +END) +END) AS [Column value Size], + +(CASE WHEN leaf_offset<1 and SUBSTRING([nullBitMap], cols.leaf_null_bit, 1)=0 THEN +(Case + +When CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * leaf_offset*-1) - 1, 2)))) >30000 And +ISNULL(NULLIF(CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * ((leaf_offset*-1) - 1)) - 1, 2)))), 0), [varColumnStart])<30000 +THEN (Case When [System_type_id]In (35,34,99) Then 16 else 24 end) + +When CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * leaf_offset*-1) - 1, 2)))) >30000 And +ISNULL(NULLIF(CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * ((leaf_offset*-1) - 1)) - 1, 2)))), 0), [varColumnStart])>30000 +THEN (Case When [System_type_id]In (35,34,99) Then 16 else 24 end) --24 + +When CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * leaf_offset*-1) - 1, 2)))) <30000 And +ISNULL(NULLIF(CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * ((leaf_offset*-1) - 1)) - 1, 2)))), 0), [varColumnStart])<30000 +THEN (CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * leaf_offset*-1) - 1, 2)))) +- ISNULL(NULLIF(CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * ((leaf_offset*-1) - 1)) - 1, 2)))), 0), [varColumnStart])) + +When CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * leaf_offset*-1) - 1, 2)))) <30000 And +ISNULL(NULLIF(CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * ((leaf_offset*-1) - 1)) - 1, 2)))), 0), [varColumnStart])>30000 + +THEN POWER(2, 15) +CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * leaf_offset*-1) - 1, 2)))) +- ISNULL(NULLIF(CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * ((leaf_offset*-1) - 1)) - 1, 2)))), 0), [varColumnStart]) + +END) + +END) AS [Column Length] + +,(CASE WHEN SUBSTRING([nullBitMap], cols.leaf_null_bit, 1)=1 THEN NULL ELSE + SUBSTRING + ( + Rowlogcontents, + ( + +(Case When CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * leaf_offset*-1) - 1, 2)))) >30000 +THEN +CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * leaf_offset*-1) - 1, 2)))) - POWER(2, 15) +ELSE +CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * leaf_offset*-1) - 1, 2)))) +END) + + - +(Case When CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * leaf_offset*-1) - 1, 2)))) >30000 And +ISNULL(NULLIF(CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * ((leaf_offset*-1) - 1)) - 1, 2)))), 0), [varColumnStart])<30000 + +THEN (Case When [System_type_id]In (35,34,99) Then 16 else 24 end) --24 +When CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * leaf_offset*-1) - 1, 2)))) >30000 And +ISNULL(NULLIF(CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * ((leaf_offset*-1) - 1)) - 1, 2)))), 0), [varColumnStart])>30000 + +THEN (Case When [System_type_id]In (35,34,99) Then 16 else 24 end) --24 +When CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * leaf_offset*-1) - 1, 2)))) <30000 And +ISNULL(NULLIF(CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * ((leaf_offset*-1) - 1)) - 1, 2)))), 0), [varColumnStart])<30000 + +THEN CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * leaf_offset*-1) - 1, 2)))) +- ISNULL(NULLIF(CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * ((leaf_offset*-1) - 1)) - 1, 2)))), 0), [varColumnStart]) + +When CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * leaf_offset*-1) - 1, 2)))) <30000 And +ISNULL(NULLIF(CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * ((leaf_offset*-1) - 1)) - 1, 2)))), 0), [varColumnStart])>30000 + +THEN POWER(2, 15) +CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * leaf_offset*-1) - 1, 2)))) +- ISNULL(NULLIF(CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * ((leaf_offset*-1) - 1)) - 1, 2)))), 0), [varColumnStart]) + +END) + +) + 1, +(Case When CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * leaf_offset*-1) - 1, 2)))) >30000 And +ISNULL(NULLIF(CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * ((leaf_offset*-1) - 1)) - 1, 2)))), 0), [varColumnStart])<30000 + +THEN (Case When [System_type_id] In (35,34,99) Then 16 else 24 end) --24 +When CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * leaf_offset*-1) - 1, 2)))) >30000 And +ISNULL(NULLIF(CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * ((leaf_offset*-1) - 1)) - 1, 2)))), 0), [varColumnStart])>30000 + +THEN (Case When [System_type_id] In (35,34,99) Then 16 else 24 end) --24 +When CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * leaf_offset*-1) - 1, 2)))) <30000 And +ISNULL(NULLIF(CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * ((leaf_offset*-1) - 1)) - 1, 2)))), 0), [varColumnStart])<30000 + +THEN ABS(CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * leaf_offset*-1) - 1, 2)))) +- ISNULL(NULLIF(CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * ((leaf_offset*-1) - 1)) - 1, 2)))), 0), [varColumnStart])) + +When CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * leaf_offset*-1) - 1, 2)))) <30000 And +ISNULL(NULLIF(CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * ((leaf_offset*-1) - 1)) - 1, 2)))), 0), [varColumnStart])>30000 + +THEN POWER(2, 15) +CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * leaf_offset*-1) - 1, 2)))) +- ISNULL(NULLIF(CONVERT(INT, CONVERT(BINARY(2), REVERSE (SUBSTRING ([ColumnOffsetArray], (2 * ((leaf_offset*-1) - 1)) - 1, 2)))), 0), [varColumnStart]) + +END) +) + +END) AS hex_Value +,[Slot ID] +,0 +FROM @DeletedRecords A +Inner Join sys.allocation_units allocunits On A.[AllocUnitId]=allocunits.[Allocation_Unit_Id] +INNER JOIN sys.partitions partitions ON (allocunits.type IN (1, 3) +AND partitions.hobt_id = allocunits.container_id) OR (allocunits.type = 2 AND partitions.partition_id = allocunits.container_id) +INNER JOIN sys.system_internals_partition_columns cols ON cols.partition_id = partitions.partition_id +LEFT OUTER JOIN syscolumns ON syscolumns.id = partitions.object_id AND syscolumns.colid = cols.partition_column_id +WHERE leaf_offset<0 +UNION +/*This part is for fixed data columns*/ +SELECT +[Row ID], +Rowlogcontents, +NAME , +cols.leaf_null_bit AS nullbit, +leaf_offset, +ISNULL(syscolumns.length, cols.max_length) AS [length], +cols.system_type_id, +cols.leaf_bit_position AS bitpos, +ISNULL(syscolumns.xprec, cols.precision) AS xprec, +ISNULL(syscolumns.xscale, cols.scale) AS xscale, +SUBSTRING([nullBitMap], cols.leaf_null_bit, 1) AS is_null, +(SELECT TOP 1 ISNULL(SUM(CASE WHEN C.leaf_offset >1 THEN max_length ELSE 0 END),0) FROM +sys.system_internals_partition_columns C WHERE cols.partition_id =C.partition_id And C.leaf_null_bit1 And C.leaf_bit_position=0 THEN max_length ELSE 0 END),0) FROM +sys.system_internals_partition_columns C where cols.partition_id =C.partition_id And C.leaf_null_bit0 +Order By nullbit + +Declare @BitColumnByte as int +Select @BitColumnByte=CONVERT(INT, ceiling( Count(*)/8.0)) from @ColumnNameAndData Where [System_Type_id]=104 + +;With N1 (n) AS (SELECT 1 UNION ALL SELECT 1), +N2 (n) AS (SELECT 1 FROM N1 AS X, N1 AS Y), +N3 (n) AS (SELECT 1 FROM N2 AS X, N2 AS Y), +N4 (n) AS (SELECT ROW_NUMBER() OVER(ORDER BY X.n) + FROM N3 AS X, N3 AS Y), +CTE As( +Select RowLogContents,[nullbit] + ,[BitMap]=Convert(varbinary(1),Convert(int,Substring((REPLACE(STUFF((SELECT ',' + + (CASE WHEN [ID]=0 THEN CONVERT(NVARCHAR(1),(SUBSTRING(hex_Value, n, 1) % 2)) ELSE CONVERT(NVARCHAR(1),((SUBSTRING(hex_Value, n, 1) / [Bitvalue]) % 2)) END) --as [nullBitMap] + +from N4 AS Nums +Join @ColumnNameAndData AS C ON n<=@BitColumnByte And [System_Type_id]=104 And bitpos=0 +Cross Join @bitTable WHERE C.[RowLogContents]=D.[RowLogContents] ORDER BY [RowLogContents],n ASC FOR XML PATH('')),1,1,''),',','')),bitpos+1,1))) +FROM @ColumnNameAndData D Where [System_Type_id]=104) + +Update A Set [hex_Value]=[BitMap] +from @ColumnNameAndData A +Inner Join CTE B On A.[RowLogContents]=B.[RowLogContents] +And A.[nullbit]=B.[nullbit] + + +/**************Check for BLOB DATA TYPES******************************/ +DECLARE @Fileid INT +DECLARE @Pageid INT +DECLARE @Slotid INT +DECLARE @CurrentLSN INT +DECLARE @LinkID INT +DECLARE @Context VARCHAR(50) +DECLARE @ConsolidatedPageID VARCHAR(MAX) +DECLARE @LCX_TEXT_MIX VARBINARY(MAX) + +declare @temppagedata table +( +[ParentObject] sysname, +[Object] sysname, +[Field] sysname, +[Value] sysname) + +declare @pagedata table +( +[Page ID] sysname, +[File IDS] int, +[Page IDS] int, +[AllocUnitId] bigint, +[ParentObject] sysname, +[Object] sysname, +[Field] sysname, +[Value] sysname) + +DECLARE @ModifiedRawData TABLE +( + [ID] INT IDENTITY(1,1), + [PAGE ID] VARCHAR(MAX), + [FILE IDS] INT, + [PAGE IDS] INT, + [Slot ID] INT, + [AllocUnitId] BIGINT, + [RowLog Contents 0_var] VARCHAR(Max), + [RowLog Length] VARCHAR(50), + [RowLog Len] INT, + [RowLog Contents 0] VARBINARY(Max), + [Link ID] INT default (0), + [Update] INT +) + + DECLARE Page_Data_Cursor CURSOR FOR + /*We need to filter LOP_MODIFY_ROW,LOP_MODIFY_COLUMNS from log for deleted records of BLOB data type& Get its Slot No, Page ID & AllocUnit ID*/ + SELECT LTRIM(RTRIM(Replace([Description],'Deallocated',''))) AS [PAGE ID] + ,[Slot ID],[AllocUnitId],NULL AS [RowLog Contents 0],NULL AS [RowLog Contents 0],Context + FROM sys.fn_dblog(NULL, NULL) + WHERE + AllocUnitId IN + (SELECT [Allocation_unit_id] FROM sys.allocation_units allocunits + INNER JOIN sys.partitions partitions ON (allocunits.type IN (1, 3) + AND partitions.hobt_id = allocunits.container_id) OR (allocunits.type = 2 + AND partitions.partition_id = allocunits.container_id) + WHERE object_id=object_ID('' + @SchemaName_n_TableName + '')) + AND Operation IN ('LOP_MODIFY_ROW') AND [Context] IN ('LCX_PFS') + AND Description Like '%Deallocated%' + /*Use this subquery to filter the date*/ + AND [TRANSACTION ID] IN (SELECT DISTINCT [TRANSACTION ID] FROM sys.fn_dblog(NULL, NULL) + WHERE Context IN ('LCX_NULL') AND Operation in ('LOP_BEGIN_XACT') + AND [Transaction Name]='DELETE' + AND CONVERT(NVARCHAR(11),[Begin Time]) BETWEEN @Date_From AND @Date_To) + GROUP BY [Description],[Slot ID],[AllocUnitId],Context + + UNION + + SELECT [PAGE ID],[Slot ID],[AllocUnitId] + ,Substring([RowLog Contents 0],15,LEN([RowLog Contents 0])) AS [RowLog Contents 0] + ,CONVERT(INT,Substring([RowLog Contents 0],7,2)),Context --,CAST(RIGHT([Current LSN],4) AS INT) AS [Current LSN] + FROM sys.fn_dblog(NULL, NULL) + WHERE + AllocUnitId IN + (SELECT [Allocation_unit_id] FROM sys.allocation_units allocunits + INNER JOIN sys.partitions partitions ON (allocunits.type IN (1, 3) + AND partitions.hobt_id = allocunits.container_id) OR (allocunits.type = 2 + AND partitions.partition_id = allocunits.container_id) + WHERE object_id=object_ID('' + @SchemaName_n_TableName + '')) + AND Context IN ('LCX_TEXT_MIX') AND Operation in ('LOP_DELETE_ROWS') + /*Use this subquery to filter the date*/ + AND [TRANSACTION ID] IN (SELECT DISTINCT [TRANSACTION ID] FROM sys.fn_dblog(NULL, NULL) + WHERE Context IN ('LCX_NULL') AND Operation in ('LOP_BEGIN_XACT') + And [Transaction Name]='DELETE' + And CONVERT(NVARCHAR(11),[Begin Time]) BETWEEN @Date_From AND @Date_To) + + /****************************************/ + + OPEN Page_Data_Cursor + + FETCH NEXT FROM Page_Data_Cursor INTO @ConsolidatedPageID, @Slotid,@AllocUnitID,@LCX_TEXT_MIX,@LinkID,@Context + + WHILE @@FETCH_STATUS = 0 + BEGIN + DECLARE @hex_pageid AS VARCHAR(Max) + /*Page ID contains File Number and page number It looks like 0001:00000130. + In this example 0001 is file Number & 00000130 is Page Number & These numbers are in Hex format*/ + SET @Fileid=SUBSTRING(@ConsolidatedPageID,0,CHARINDEX(':',@ConsolidatedPageID)) -- Seperate File ID from Page ID + + SET @hex_pageid ='0x'+ SUBSTRING(@ConsolidatedPageID,CHARINDEX(':',@ConsolidatedPageID)+1,Len(@ConsolidatedPageID)) ---Seperate the page ID + SELECT @Pageid=Convert(INT,cast('' AS XML).value('xs:hexBinary(substring(sql:variable("@hex_pageid"),sql:column("t.pos")) )', 'varbinary(max)')) -- Convert Page ID from hex to integer + FROM (SELECT CASE substring(@hex_pageid, 1, 2) WHEN '0x' THEN 3 ELSE 0 END) AS t(pos) + + IF @Context='LCX_PFS' + BEGIN + DELETE @temppagedata + INSERT INTO @temppagedata EXEC( 'DBCC PAGE(' + @DataBase_Name + ', ' + @fileid + ', ' + @pageid + ', 1) with tableresults,no_infomsgs;'); + INSERT INTO @pagedata SELECT @ConsolidatedPageID,@fileid,@pageid,@AllocUnitID,[ParentObject],[Object],[Field] ,[Value] FROM @temppagedata + END + ELSE IF @Context='LCX_TEXT_MIX' + BEGIN + INSERT INTO @ModifiedRawData SELECT @ConsolidatedPageID,@fileid,@pageid,@Slotid,@AllocUnitID,NULL,0,CONVERT(INT,CONVERT(VARBINARY,REVERSE(SUBSTRING(@LCX_TEXT_MIX,11,2)))),@LCX_TEXT_MIX,@LinkID,0 + END + FETCH NEXT FROM Page_Data_Cursor INTO @ConsolidatedPageID, @Slotid,@AllocUnitID,@LCX_TEXT_MIX,@LinkID,@Context + END + + CLOSE Page_Data_Cursor + DEALLOCATE Page_Data_Cursor + + DECLARE @Newhexstring VARCHAR(MAX); + + --The data is in multiple rows in the page, so we need to convert it into one row as a single hex value. + --This hex value is in string format + INSERT INTO @ModifiedRawData ([PAGE ID],[FILE IDS],[PAGE IDS],[Slot ID],[AllocUnitId] + ,[RowLog Contents 0_var] + , [RowLog Length]) + SELECT [Page ID],[FILE IDS],[PAGE IDS],Substring([ParentObject],CHARINDEX('Slot', [ParentObject])+4, (CHARINDEX('Offset', [ParentObject])-(CHARINDEX('Slot', [ParentObject])+4))-2 ) as [Slot ID] + ,[AllocUnitId] + ,Substring(( + SELECT + REPLACE(STUFF((SELECT REPLACE(SUBSTRING([Value],CHARINDEX(':',[Value])+1,CHARINDEX('',[Value])-CHARINDEX(':',[Value])),'','') + FROM @pagedata C WHERE B.[Page ID]= C.[Page ID] And Substring(B.[ParentObject],CHARINDEX('Slot', B.[ParentObject])+4, (CHARINDEX('Offset', B.[ParentObject])-(CHARINDEX('Slot', B.[ParentObject])+4)) )=Substring(C.[ParentObject],CHARINDEX('Slot', C.[ParentObject])+4, (CHARINDEX('Offset', C.[ParentObject])-(CHARINDEX('Slot', C.[ParentObject])+4)) ) And + [Object] Like '%Memory Dump%' Order By '0x'+ LEFT([Value],CHARINDEX(':',[Value])-1) + FOR XML PATH('') ),1,1,'') ,' ','') + ),1,20000) AS [Value] + + , + Substring(( + SELECT '0x' +REPLACE(STUFF((SELECT REPLACE(SUBSTRING([Value],CHARINDEX(':',[Value])+1,CHARINDEX('',[Value])-CHARINDEX(':',[Value])),'','') + FROM @pagedata C WHERE B.[Page ID]= C.[Page ID] And Substring(B.[ParentObject],CHARINDEX('Slot', B.[ParentObject])+4, (CHARINDEX('Offset', B.[ParentObject])-(CHARINDEX('Slot', B.[ParentObject])+4)) )=Substring(C.[ParentObject],CHARINDEX('Slot', C.[ParentObject])+4, (CHARINDEX('Offset', C.[ParentObject])-(CHARINDEX('Slot', C.[ParentObject])+4)) ) And + [Object] Like '%Memory Dump%' Order By '0x'+ LEFT([Value],CHARINDEX(':',[Value])-1) + FOR XML PATH('') ),1,1,'') ,' ','') + ),7,4) AS [Length] + + From @pagedata B + Where [Object] Like '%Memory Dump%' + Group By [Page ID],[FILE IDS],[PAGE IDS],[ParentObject],[AllocUnitId]--,[Current LSN] + Order By [Slot ID] + + UPDATE @ModifiedRawData SET [RowLog Len] = CONVERT(VARBINARY(8000),REVERSE(cast('' AS XML).value('xs:hexBinary(substring(sql:column("[RowLog Length]"),0))', 'varbinary(Max)'))) + FROM @ModifiedRawData Where [LINK ID]=0 + + UPDATE @ModifiedRawData SET [RowLog Contents 0] =cast('' AS XML).value('xs:hexBinary(substring(sql:column("[RowLog Contents 0_var]"),0))', 'varbinary(Max)') + FROM @ModifiedRawData Where [LINK ID]=0 + + Update B Set B.[RowLog Contents 0] = + (CASE WHEN A.[RowLog Contents 0] IS NOT NULL AND C.[RowLog Contents 0] IS NOT NULL THEN A.[RowLog Contents 0]+C.[RowLog Contents 0] + WHEN A.[RowLog Contents 0] IS NULL AND C.[RowLog Contents 0] IS NOT NULL THEN C.[RowLog Contents 0] + WHEN A.[RowLog Contents 0] IS NOT NULL AND C.[RowLog Contents 0] IS NULL THEN A.[RowLog Contents 0] + END) + ,B.[Update]=ISNULL(B.[Update],0)+1 + from @ModifiedRawData B + LEFT Join @ModifiedRawData A On A.[Page IDS]=Convert(int,Convert(Varbinary(Max),Reverse(Substring(B.[RowLog Contents 0],15+14,2)))) + And A.[File IDS]=Convert(int,Convert(Varbinary(Max),Reverse(Substring(B.[RowLog Contents 0],19+14,2)))) + And A.[Link ID]=B.[Link ID] + LEFT Join @ModifiedRawData C On C.[Page IDS]=Convert(int,Convert(Varbinary(Max),Reverse(Substring(B.[RowLog Contents 0],27+14,2)))) + And C.[File IDS]=Convert(int,Convert(Varbinary(Max),Reverse(Substring(B.[RowLog Contents 0],31+14,2)))) + And C.[Link ID]=B.[Link ID] + Where (A.[RowLog Contents 0] IS NOT NULL OR C.[RowLog Contents 0] IS NOT NULL) + + + Update B Set B.[RowLog Contents 0] = + (CASE WHEN A.[RowLog Contents 0] IS NOT NULL AND C.[RowLog Contents 0] IS NOT NULL THEN A.[RowLog Contents 0]+C.[RowLog Contents 0] + WHEN A.[RowLog Contents 0] IS NULL AND C.[RowLog Contents 0] IS NOT NULL THEN C.[RowLog Contents 0] + WHEN A.[RowLog Contents 0] IS NOT NULL AND C.[RowLog Contents 0] IS NULL THEN A.[RowLog Contents 0] + END) + --,B.[Update]=ISNULL(B.[Update],0)+1 + from @ModifiedRawData B + LEFT Join @ModifiedRawData A On A.[Page IDS]=Convert(int,Convert(Varbinary(Max),Reverse(Substring(B.[RowLog Contents 0],15+14,2)))) + And A.[File IDS]=Convert(int,Convert(Varbinary(Max),Reverse(Substring(B.[RowLog Contents 0],19+14,2)))) + And A.[Link ID]<>B.[Link ID] And B.[Update]=0 + LEFT Join @ModifiedRawData C On C.[Page IDS]=Convert(int,Convert(Varbinary(Max),Reverse(Substring(B.[RowLog Contents 0],27+14,2)))) + And C.[File IDS]=Convert(int,Convert(Varbinary(Max),Reverse(Substring(B.[RowLog Contents 0],31+14,2)))) + And C.[Link ID]<>B.[Link ID] And B.[Update]=0 + Where (A.[RowLog Contents 0] IS NOT NULL OR C.[RowLog Contents 0] IS NOT NULL) + + UPDATE @ModifiedRawData SET [RowLog Contents 0] = + (Case When [RowLog Len]>=8000 Then + Substring([RowLog Contents 0] ,15,[RowLog Len]) + When [RowLog Len]<8000 Then + SUBSTRING([RowLog Contents 0],15+6,Convert(int,Convert(varbinary(max),REVERSE(Substring([RowLog Contents 0],15,6))))) + End) + FROM @ModifiedRawData Where [LINK ID]=0 + + UPDATE @ColumnNameAndData SET [hex_Value]=[RowLog Contents 0] + --,A.[Update]=A.[Update]+1 + FROM @ColumnNameAndData A + INNER JOIN @ModifiedRawData B ON + Convert(int,Convert(Varbinary(Max),Reverse(Substring([hex_value],17,4))))=[PAGE IDS] + AND Convert(int,Substring([hex_value],9,2)) =B.[Link ID] + Where [System_Type_Id] In (99,167,175,231,239,241,165,98) And [Link ID] <>0 + + UPDATE @ColumnNameAndData SET [hex_Value]= + (CASE WHEN B.[RowLog Contents 0] IS NOT NULL AND C.[RowLog Contents 0] IS NOT NULL THEN B.[RowLog Contents 0]+C.[RowLog Contents 0] + WHEN B.[RowLog Contents 0] IS NULL AND C.[RowLog Contents 0] IS NOT NULL THEN C.[RowLog Contents 0] + WHEN B.[RowLog Contents 0] IS NOT NULL AND C.[RowLog Contents 0] IS NULL THEN B.[RowLog Contents 0] + END) + --,A.[Update]=A.[Update]+1 + FROM @ColumnNameAndData A + LEFT JOIN @ModifiedRawData B ON + Convert(int,Convert(Varbinary(Max),Reverse(Substring([hex_value],5,4))))=B.[PAGE IDS] And B.[Link ID] =0 + LEFT JOIN @ModifiedRawData C ON + Convert(int,Convert(Varbinary(Max),Reverse(Substring([hex_value],17,4))))=C.[PAGE IDS] And C.[Link ID] =0 + Where [System_Type_Id] In (99,167,175,231,239,241,165,98) And (B.[RowLog Contents 0] IS NOT NULL OR C.[RowLog Contents 0] IS NOT NULL) + + UPDATE @ColumnNameAndData SET [hex_Value]=[RowLog Contents 0] + --,A.[Update]=A.[Update]+1 + FROM @ColumnNameAndData A + INNER JOIN @ModifiedRawData B ON + Convert(int,Convert(Varbinary(Max),Reverse(Substring([hex_value],9,4))))=[PAGE IDS] + And Convert(int,Substring([hex_value],3,2))=[Link ID] + Where [System_Type_Id] In (35,34,99) And [Link ID] <>0 + + UPDATE @ColumnNameAndData SET [hex_Value]=[RowLog Contents 0] + --,A.[Update]=A.[Update]+10 + FROM @ColumnNameAndData A + INNER JOIN @ModifiedRawData B ON + Convert(int,Convert(Varbinary(Max),Reverse(Substring([hex_value],9,4))))=[PAGE IDS] + Where [System_Type_Id] In (35,34,99) And [Link ID] =0 + + UPDATE @ColumnNameAndData SET [hex_Value]=[RowLog Contents 0] + --,A.[Update]=A.[Update]+1 + FROM @ColumnNameAndData A + INNER JOIN @ModifiedRawData B ON + Convert(int,Convert(Varbinary(Max),Reverse(Substring([hex_value],15,4))))=[PAGE IDS] + Where [System_Type_Id] In (35,34,99) And [Link ID] =0 + + Update @ColumnNameAndData set [hex_value]= 0xFFFE + Substring([hex_value],9,LEN([hex_value])) + --,[Update]=[Update]+1 + Where [system_type_id]=241 + +CREATE TABLE [#temp_Data] +( + [FieldName] VARCHAR(MAX), + [FieldValue] NVARCHAR(MAX), + [Rowlogcontents] VARBINARY(8000), + [Row ID] int +) + +INSERT INTO #temp_Data +SELECT NAME, +CASE + WHEN system_type_id IN (231, 239) THEN LTRIM(RTRIM(CONVERT(NVARCHAR(max),hex_Value))) --NVARCHAR ,NCHAR + WHEN system_type_id IN (167,175) THEN LTRIM(RTRIM(CONVERT(VARCHAR(max),hex_Value))) --VARCHAR,CHAR + WHEN system_type_id IN (35) THEN LTRIM(RTRIM(CONVERT(VARCHAR(max),hex_Value))) --Text + WHEN system_type_id IN (99) THEN LTRIM(RTRIM(CONVERT(NVARCHAR(max),hex_Value))) --nText + WHEN system_type_id = 48 THEN CONVERT(VARCHAR(MAX), CONVERT(TINYINT, CONVERT(BINARY(1), REVERSE (hex_Value)))) --TINY INTEGER + WHEN system_type_id = 52 THEN CONVERT(VARCHAR(MAX), CONVERT(SMALLINT, CONVERT(BINARY(2), REVERSE (hex_Value)))) --SMALL INTEGER + WHEN system_type_id = 56 THEN CONVERT(VARCHAR(MAX), CONVERT(INT, CONVERT(BINARY(4), REVERSE(hex_Value)))) -- INTEGER + WHEN system_type_id = 127 THEN CONVERT(VARCHAR(MAX), CONVERT(BIGINT, CONVERT(BINARY(8), REVERSE(hex_Value))))-- BIG INTEGER + WHEN system_type_id = 61 Then CONVERT(VARCHAR(MAX),CONVERT(DATETIME,CONVERT(VARBINARY(8000),REVERSE (hex_Value))),100) --DATETIME + WHEN system_type_id =58 Then CONVERT(VARCHAR(MAX),CONVERT(SMALLDATETIME,CONVERT(VARBINARY(8000),REVERSE(hex_Value))),100) --SMALL DATETIME + WHEN system_type_id = 108 THEN CONVERT(VARCHAR(MAX),CONVERT(NUMERIC(38,20), CONVERT(VARBINARY,CONVERT(VARBINARY(1),xprec)+CONVERT(VARBINARY(1),xscale))+CONVERT(VARBINARY(1),0) + hex_Value)) --- NUMERIC + WHEN system_type_id =106 THEN CONVERT(VARCHAR(MAX), CONVERT(DECIMAL(38,20), CONVERT(VARBINARY,Convert(VARBINARY(1),xprec)+CONVERT(VARBINARY(1),xscale))+CONVERT(VARBINARY(1),0) + hex_Value)) --- DECIMAL + WHEN system_type_id In(60,122) THEN CONVERT(VARCHAR(MAX),Convert(MONEY,Convert(VARBINARY(8000),Reverse(hex_Value))),2) --MONEY,SMALLMONEY + WHEN system_type_id = 104 THEN CONVERT(VARCHAR(MAX),CONVERT (BIT,CONVERT(BINARY(1), hex_Value)%2)) -- BIT + WHEN system_type_id =62 THEN RTRIM(LTRIM(STR(CONVERT(FLOAT,SIGN(CAST(CONVERT(VARBINARY(8000),Reverse(hex_Value)) AS BIGINT)) * (1.0 + (CAST(CONVERT(VARBINARY(8000),Reverse(hex_Value)) AS BIGINT) & 0x000FFFFFFFFFFFFF) * POWER(CAST(2 AS FLOAT), -52)) * POWER(CAST(2 AS FLOAT),((CAST(CONVERT(VARBINARY(8000),Reverse(hex_Value)) AS BIGINT) & 0x7ff0000000000000) / EXP(52 * LOG(2))-1023))),53,LEN(hex_Value)))) --- FLOAT + When system_type_id =59 THEN Left(LTRIM(STR(CAST(SIGN(CAST(Convert(VARBINARY(8000),REVERSE(hex_Value)) AS BIGINT))* (1.0 + (CAST(CONVERT(VARBINARY(8000),Reverse(hex_Value)) AS BIGINT) & 0x007FFFFF) * POWER(CAST(2 AS Real), -23)) * POWER(CAST(2 AS Real),(((CAST(CONVERT(VARBINARY(8000),Reverse(hex_Value)) AS INT) )& 0x7f800000)/ EXP(23 * LOG(2))-127))AS REAL),23,23)),8) --Real + WHEN system_type_id In (165,173) THEN (CASE WHEN CHARINDEX(0x,cast('' AS XML).value('xs:hexBinary(sql:column("hex_Value"))', 'VARBINARY(8000)')) = 0 THEN '0x' ELSE '' END) +cast('' AS XML).value('xs:hexBinary(sql:column("hex_Value"))', 'varchar(max)') -- BINARY,VARBINARY + WHEN system_type_id =34 THEN (CASE WHEN CHARINDEX(0x,cast('' AS XML).value('xs:hexBinary(sql:column("hex_Value"))', 'VARBINARY(8000)')) = 0 THEN '0x' ELSE '' END) +cast('' AS XML).value('xs:hexBinary(sql:column("hex_Value"))', 'varchar(max)') --IMAGE + WHEN system_type_id =36 THEN CONVERT(VARCHAR(MAX),CONVERT(UNIQUEIDENTIFIER,hex_Value)) --UNIQUEIDENTIFIER + WHEN system_type_id =231 THEN CONVERT(VARCHAR(MAX),CONVERT(sysname,hex_Value)) --SYSNAME + WHEN system_type_id =241 THEN CONVERT(VARCHAR(MAX),CONVERT(xml,hex_Value)) --XML + + WHEN system_type_id =189 THEN (CASE WHEN CHARINDEX(0x,cast('' AS XML).value('xs:hexBinary(sql:column("hex_Value"))', 'VARBINARY(8000)')) = 0 THEN '0x' ELSE '' END) +cast('' AS XML).value('xs:hexBinary(sql:column("hex_Value"))', 'varchar(max)') --TIMESTAMP + WHEN system_type_id=98 THEN (CASE + WHEN CONVERT(INT,SUBSTRING(hex_Value,1,1))=56 THEN CONVERT(VARCHAR(MAX), CONVERT(INT, CONVERT(BINARY(4), REVERSE(Substring(hex_Value,3,Len(hex_Value)))))) -- INTEGER + WHEN CONVERT(INT,SUBSTRING(hex_Value,1,1))=108 THEN CONVERT(VARCHAR(MAX),CONVERT(numeric(38,20),CONVERT(VARBINARY(1),Substring(hex_Value,3,1)) +CONVERT(VARBINARY(1),Substring(hex_Value,4,1))+CONVERT(VARBINARY(1),0) + Substring(hex_Value,5,Len(hex_Value)))) --- NUMERIC + WHEN CONVERT(INT,SUBSTRING(hex_Value,1,1))=167 THEN LTRIM(RTRIM(CONVERT(VARCHAR(max),Substring(hex_Value,9,Len(hex_Value))))) --VARCHAR,CHAR + WHEN CONVERT(INT,SUBSTRING(hex_Value,1,1))=36 THEN CONVERT(VARCHAR(MAX),CONVERT(UNIQUEIDENTIFIER,Substring((hex_Value),3,20))) --UNIQUEIDENTIFIER + WHEN CONVERT(INT,SUBSTRING(hex_Value,1,1))=61 THEN CONVERT(VARCHAR(MAX),CONVERT(DATETIME,CONVERT(VARBINARY(8000),REVERSE (Substring(hex_Value,3,LEN(hex_Value)) ))),100) --DATETIME + WHEN CONVERT(INT,SUBSTRING(hex_Value,1,1))=165 THEN '0x'+ SUBSTRING((CASE WHEN CHARINDEX(0x,cast('' AS XML).value('xs:hexBinary(sql:column("hex_Value"))', 'VARBINARY(8000)')) = 0 THEN '0x' ELSE '' END) +cast('' AS XML).value('xs:hexBinary(sql:column("hex_Value"))', 'varchar(max)'),11,LEN(hex_Value)) -- BINARY,VARBINARY + END) + +END AS FieldValue +,[Rowlogcontents] +,[Row ID] +FROM @ColumnNameAndData ORDER BY nullbit + +--Create the column name in the same order to do pivot table. + +DECLARE @FieldName VARCHAR(max) +SET @FieldName = STUFF( +( + SELECT ',' + CAST(QUOTENAME([Name]) AS VARCHAR(MAX)) FROM syscolumns WHERE id=object_id('' + @SchemaName_n_TableName + '') + FOR XML PATH('')), 1, 1, '') + +--Finally did pivot table and get the data back in the same format. + +SET @sql = 'SELECT ' + @FieldName + ' FROM #temp_Data PIVOT (Min([FieldValue]) FOR FieldName IN (' + @FieldName + ')) AS pvt' +EXEC sp_executesql @sql + +GO +--Execute the procedure like +--Recover_Deleted_Data_Proc 'Database Name','Schema.table name' +--EXAMPLE #1 : FOR ALL DELETED RECORDS +EXEC Recover_Deleted_Data_Proc 'test','dbo.Test_table' +GO +--EXAMPLE #2 : FOR ANY SPECIFIC DATE RANGE +EXEC Recover_Deleted_Data_Proc 'test','dbo.Test_Table' ,'2011/12/01','2012/01/30' +--It will give you the result of all deleted records. \ No newline at end of file diff --git a/Stored_Procedure/dbo.PerformanceGraph.sql b/Stored_Procedure/dbo.PerformanceGraph.sql new file mode 100644 index 00000000..1e8890f0 --- /dev/null +++ b/Stored_Procedure/dbo.PerformanceGraph.sql @@ -0,0 +1,256 @@ +IF OBJECT_ID('dbo.PerformanceGraph', 'P') IS NULL +BEGIN + EXEC ('CREATE PROCEDURE dbo.PerformanceGraph AS BEGIN SELECT 1 END'); +END; +GO + + +ALTER PROCEDURE PerformanceGraph + @ShowCPUAsLines BIT = 1, + @ShowDeadlock BIT = 1, + @DeadlockBlobRadius TINYINT = 1, + @OutputDeadlockTable BIT = 1, + @ShowEndBar BIT = 1, + @EndBarWidth TINYINT = 1 +AS +/* +https://thelonedba.wordpress.com/2019/09/27/wrapping-up-cpu-load-graphs-in-a-stored-procedure/ + +EXEC dbo.PerformanceGraph; +*/ +BEGIN + SET NOCOUNT ON; + + DECLARE @ts_now BIGINT = + ( + SELECT TOP (1) + cpu_ticks / (cpu_ticks / ms_ticks) + FROM sys.dm_os_sys_info WITH (NOLOCK) + ORDER BY cpu_ticks DESC + ); + DECLARE @CPUSQLOut AS VARCHAR(8000), + @CPUIdleOut AS VARCHAR(8000), + @CPUOtherOut AS VARCHAR(8000); + DECLARE @CPURecords AS INT; + DECLARE @DeadlockPoints AS VARCHAR(8000), + @DeadlockBlobs AS VARCHAR(8000), + @DeadlockRecords AS INT; + + DECLARE @OutputGeometry TABLE (ShapeInfo GEOMETRY, Caption VARCHAR(20)); + + WITH + CPULoad AS + ( + SELECT TOP (256) + y.SQLProcessUtilization AS [SQL Server Process CPU Utilization], + y.SystemIdle AS [System Idle Process], + 100 - (y.SystemIdle + y.SQLProcessUtilization) AS [Other Process CPU Utilization], + DATEADD(ms, -1 * (@ts_now - y.timestamp), GETDATE()) AS [Event Time] + FROM + ( + SELECT x.record.value('(./Record/@id)[1]', 'int') AS record_id, + x.record.value('(./Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int') AS SystemIdle, + x.record.value('(./Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]', 'int') AS SQLProcessUtilization, + x.timestamp + FROM + ( + SELECT timestamp, + CONVERT(XML, record) AS record + FROM sys.dm_os_ring_buffers WITH (NOLOCK) + WHERE + ring_buffer_type = N'RING_BUFFER_SCHEDULER_MONITOR' + AND record LIKE N'%%' + ) AS x + ) AS y + ORDER BY y.timestamp DESC + ) + SELECT @CPUSQLOut + = STUFF( + ( + SELECT ',' + + CAST(ROW_NUMBER() OVER (ORDER BY CPULoad.[Event Time]) - COUNT(*) OVER (PARTITION BY 1) AS VARCHAR(10)) + + ' ' + CAST(CPULoad.[SQL Server Process CPU Utilization] AS VARCHAR(20)) + FROM CPULoad + ORDER BY CPULoad.[Event Time] + FOR XML PATH('') + ), + 1, + 1, + '' + ), + @CPUIdleOut + = STUFF( + ( + SELECT ',' + + CAST(ROW_NUMBER() OVER (ORDER BY CPULoad.[Event Time]) - COUNT(*) OVER (PARTITION BY 1) AS VARCHAR(10)) + + ' ' + CAST(CPULoad.[System Idle Process] AS VARCHAR(20)) + FROM CPULoad + ORDER BY CPULoad.[Event Time] + FOR XML PATH('') + ), + 1, + 1, + '' + ), + @CPUOtherOut + = STUFF( + ( + SELECT ',' + + CAST(ROW_NUMBER() OVER (ORDER BY CPULoad.[Event Time]) + - COUNT(*) OVER (PARTITION BY 1) AS VARCHAR(10)) + ' ' + + CAST(CPULoad.[Other Process CPU Utilization] AS VARCHAR(20)) + FROM CPULoad + ORDER BY CPULoad.[Event Time] + FOR XML PATH('') + ), + 1, + 1, + '' + ), + @CPURecords = (SELECT COUNT(*) FROM CPULoad); + + IF @ShowCPUAsLines = 1 + BEGIN + INSERT INTO @OutputGeometry (ShapeInfo, Caption) + VALUES + (geometry::Parse('LINESTRING(' + @CPUSQLOut + ')'), 'CPU-SQL'), + (geometry::Parse('LINESTRING(' + @CPUOtherOut + ')'), 'CPU-Other'), + (geometry::Parse('LINESTRING(' + @CPUIdleOut + ')'), 'CPU-Idle'); + END; + ELSE + BEGIN + INSERT INTO @OutputGeometry (ShapeInfo, Caption) + VALUES + (geometry::STGeomFromText( + 'POLYGON((' + CAST(0 - @CPURecords AS CHAR(5)) + ' 0, ' + @CPUSQLOut + ', ' + + '0 0, ' + CAST(0 - @CPURecords AS CHAR(5)) + ' 0 ))', + 0 + ), 'CPU-SQL'), + (geometry::STGeomFromText( + 'POLYGON((' + CAST(0 - @CPURecords AS CHAR(5)) + ' 0, ' + @CPUOtherOut + ', ' + + '0 0, ' + CAST(0 - @CPURecords AS CHAR(5)) + ' 0 ))', + 0 + ), 'CPU-Other'), + (geometry::STGeomFromText( + 'POLYGON((' + CAST(0 - @CPURecords AS CHAR(5)) + ' 0, ' + @CPUIdleOut + ', ' + + '0 0, ' + CAST(0 - @CPURecords AS CHAR(5)) + ' 0 ))', + 0 + ), 'CPU-Idle'); + END; + + DECLARE @XMLDeadlocks TABLE ([XML] XML, UTCTime DATETIME, LocalTime DATETIME, MinutesAgo INT); + + IF @ShowDeadlock = 1 + BEGIN; + WITH + xmlsource AS + ( + SELECT CONVERT(XML, event_data) AS deadlock_xml + FROM sys.fn_xe_file_target_read_file('system_health*.xel', NULL, NULL, NULL) + ), + xmldates AS + ( + SELECT xmlsource.deadlock_xml, + xmlsource.deadlock_xml.value('(/event/@timestamp)[1]', 'datetime') AS deadlock_UTCtime, -- this is UTC. + DATEADD( + mi, + DATEDIFF(mi, GETUTCDATE(), GETDATE()), + xmlsource.deadlock_xml.value('(/event/@timestamp)[1]', 'datetime') + ) AS deadlock_LocalTime + FROM xmlsource + WHERE xmlsource.deadlock_xml.value('(/event/@name)[1]', 'VARCHAR(256)') = 'xml_deadlock_report' + ) + INSERT INTO @XMLDeadlocks ([XML], UTCTime, LocalTime, MinutesAgo) + SELECT xmldates.deadlock_xml, + xmldates.deadlock_UTCtime, + xmldates.deadlock_LocalTime, + DATEDIFF(MINUTE, xmldates.deadlock_LocalTime, GETDATE()) AS MinutesAgo + FROM xmldates; + + SELECT @DeadlockPoints = STUFF( + ( + SELECT DISTINCT + ', (' + CAST((0 - xml.MinutesAgo) AS CHAR(5)) + ' 0)' + FROM @XMLDeadlocks xml + WHERE xml.MinutesAgo <= @CPURecords + FOR XML PATH('') + ), + 1, + 2, + '' + ), + @DeadlockBlobs + = STUFF( + ( +-- SQL Prompt formatting off + SELECT DISTINCT ', CURVEPOLYGON(CIRCULARSTRING(' + + CAST((0-xml.MinutesAgo) + @DeadlockBlobRadius AS CHAR(5)) + ' 0, ' + + CAST((0-xml.MinutesAgo) AS CHAR(5)) + ' ' + CAST(@DeadlockBlobRadius AS CHAR(5)) + ', ' + + CAST((0-xml.MinutesAgo) - @DeadlockBlobRadius AS CHAR(5)) + ' 0, ' + + CAST((0-xml.MinutesAgo) AS CHAR(5)) + ' ' + CAST((0 - @DeadlockBlobRadius) AS CHAR(5)) + ', ' + + CAST((0-xml.MinutesAgo) + @DeadlockBlobRadius AS CHAR(5)) + ' 0' + + '))' +-- SQL Prompt formatting on + FROM @XMLDeadlocks xml + WHERE xml.MinutesAgo <= @CPURecords + FOR XML PATH('') + ), + 1, + 2, + '' + ), + @DeadlockRecords = + ( + SELECT COUNT(*) FROM @XMLDeadlocks xml WHERE xml.MinutesAgo <= @CPURecords + ); + + IF @DeadlockBlobRadius = 0 + BEGIN -- show points + INSERT INTO @OutputGeometry (ShapeInfo, Caption) + VALUES + ( geometry::Parse('MULTIPOINT(' + @DeadlockPoints + ')'), -- ShapeInfo - geometry + 'Deadlocks' -- Caption - varchar(20) + ); + END; + ELSE + BEGIN -- show blobs + INSERT INTO @OutputGeometry (ShapeInfo, Caption) + VALUES + ( geometry::Parse('GEOMETRYCOLLECTION(' + @DeadlockBlobs + ')'), -- ShapeInfo - geometry + 'Deadlocks' -- Caption - varchar(20) + ); + END; + + IF @OutputDeadlockTable = 1 + BEGIN + SELECT UTCTime, LocalTime, MinutesAgo, XML FROM @XMLDeadlocks xd ORDER BY xd.MinutesAgo; + END; + END; + + --End Bar + IF @ShowEndBar = 1 + BEGIN + IF @EndBarWidth = 0 + BEGIN + INSERT INTO @OutputGeometry (ShapeInfo, Caption) + VALUES + ( geometry::Parse('LINESTRING(0 0,0 100)'), -- ShapeInfo - geometry + 'Now' -- Caption - varchar(100) + ); + END; + ELSE + BEGIN + INSERT INTO @OutputGeometry (ShapeInfo, Caption) + VALUES + ( geometry::Parse('POLYGON((0 0,0 100, ' + CAST(@EndBarWidth AS CHAR(3)) + ' 100, ' + + CAST(@EndBarWidth AS CHAR(3)) + ' 0, 0 0))' + ), -- ShapeInfo - geometry + 'Now' -- Caption - varchar(100) + ); + END; + END; + + -- Final Output + SELECT ShapeInfo, Caption FROM @OutputGeometry; +END; +GO diff --git a/Stored_Procedure/sp_AllocationMetadata.sql b/Stored_Procedure/dbo.sp_AllocationMetadata.sql similarity index 100% rename from Stored_Procedure/sp_AllocationMetadata.sql rename to Stored_Procedure/dbo.sp_AllocationMetadata.sql diff --git a/Stored_Procedure/dbo.sp_BenchmarkTSQL.sql b/Stored_Procedure/dbo.sp_BenchmarkTSQL.sql new file mode 100644 index 00000000..4315c75d --- /dev/null +++ b/Stored_Procedure/dbo.sp_BenchmarkTSQL.sql @@ -0,0 +1,669 @@ +USE master; +GO + +IF OBJECT_ID('dbo.sp_BenchmarkTSQL', 'P') IS NULL EXEC('CREATE PROC dbo.sp_BenchmarkTSQL AS SELECT 1;'); +GO + + +ALTER PROCEDURE dbo.sp_BenchmarkTSQL( + @tsqlStatementBefore nvarchar(max) = NULL + , @tsqlStatement nvarchar(max) + , @tsqlStatementAfter nvarchar(max) = NULL + , @numberOfExecution int = 10 + , @saveResults bit = 0 + , @skipTSQLCheck bit = 1 + , @clearCache bit = 0 + , @calcMedian bit = 0 + , @printStepInfo bit = 0 + , @durationAccuracy varchar(5) = 'ss' + , @dateTimeFunction varchar(16) = 'SYSDATETIME' + , @additionalInfo bit = 0 +) +/* +.SYNOPSIS + Run TSQL statement @numberOfExecution times and calculate each execution time, save results if needed or print it. + +.DESCRIPTION + Run TSQL statement specified times with sp_executesql, print step results, insert execution details into log table master.dbo.BenchmarkTSQL. + +.PARAMETER @tsqlStatementBefore + TSQL statement that executed before tested main TSQL statement - not taken into account when measuring @tsqlStatement. + Possible values: any TSQL statements. + Default value: NULL. + +.PARAMETER @tsqlStatement + TSQL statement for benchmarking. + Mandatory parameter. + Possible values: any TSQL statements. + No defaults. + +.PARAMETER @tsqlStatementAfter + TSQL statement that executed after tested TSQL statement - not taken into account when measuring @tsqlStatement. + Possible values: any TSQL statements. + Default value: NULL. + +.PARAMETER @numberOfExecution + Number of execution TSQL statement. + Possible values: 1 or 32000. + Default value: 10. + +.PARAMETER @saveResults + Save benchmark details to master.dbo.BenchmarkTSQL table if @saveResults = 1. + Create table if not exists (see 335 line: CREATE TABLE master.dbo.BenchmarkTSQL …). + Possible values: 0 or 1. + Default value: 0 - not saved. + +.PARAMETER @skipTSQLCheck + Checking for valid TSQL statement using sys.dm_exec_describe_first_result_set. + Possible values: 0 or 1. + Default value: 1 - skip checking. + See https://docs.microsoft.com/sql/relational-databases/system-dynamic-management-views/sys-dm-exec-describe-first-result-set-transact-sql + +.PARAMETER @clearCache + Clear cached plan for TSQL statement before each run using DBCC FREEPROCCACHE(@planHandle). + Possible values: 0 or 1. + Default value: 0 - not clear. + +.PARAMETER @calcMedian + Calculate pseudo median of all execution times. + Possible values: 0 or 1. + Default value: 0 - not calculated. + +.PARAMETER @printStepInfo + PRINT detailed step information: step count, start step time, end step time, duration. + Default value: 0 - not printed. + +.PARAMETER @durationAccuracy + Duration accuracy calculation. + Possible values: ns, mcs, ms, ss, mi, hh, dd, wk. + Default value: ss - seconds. + See DATEDIFF https://docs.microsoft.com/sql/t-sql/functions/datediff-transact-sql + +.PARAMETER @dateTimeFunction + Define using datetime function. + Possible values: SYSDATETIME, SYSUTCDATETIME. + Default value: SYSDATETIME. + See https://docs.microsoft.com/sql/t-sql/functions/date-and-time-data-types-and-functions-transact-sql + +.PARAMETER @additionalInfo + Save additional session parameteres (ANSI_WARNINGS, XACT_ABORT and etc) to XML column AdditionalInfo in log table master.dbo.BenchmarkTSQL. + Possible values: 0 or 1. + Default value: 0 - not saved. + +.EXAMPLE + EXEC sp_BenchmarkTSQL + @tsqlStatement = 'SELECT * FROM , sys.databases;' + , @skipTSQLCheck = 0; + /* RETURN: Incorrect syntax near ','. */ + +.EXAMPLE + EXEC sp_BenchmarkTSQL + @tsqlStatement = 'SELECT * FROM sys.databases;' + , @skipTSQLCheck = 0; + +.EXAMPLE + EXEC sp_BenchmarkTSQL + @tsqlStatement = 'SELECT TOP(100000) * FROM sys.objects AS o1 CROSS JOIN sys.objects AS o2 CROSS JOIN sys.objects AS o3;' + , @numberOfExecution = 10 + , @saveResults = 1 + , @calcMedian = 1 + , @clearCache = 1 + , @printStepInfo = 1 + , @durationAccuracy = 'ms'; + +.EXAMPLE + EXEC sp_BenchmarkTSQL + @tsqlStatementBefore = 'WAITFOR DELAY ''00:00:01'';' + , @tsqlStatement = 'BACKUP DATABASE [master] TO DISK = N''C:\master.bak'' WITH NOFORMAT, NOINIT;' + , @tsqlStatementAfter = 'WAITFOR DELAY ''00:00:02'';' + , @numberOfExecution = 5 + , @saveResults = 1 + , @calcMedian = 1 + , @clearCache = 1 + , @printStepInfo = 1 + , @durationAccuracy = 'ss' + , @dateTimeFunction = 'SYSUTCDATETIME'; + +.EXAMPLE + EXEC sp_BenchmarkTSQL + @tsqlStatement = 'SET NOCOUNT OFF; SELECT TOP(100000) * FROM sys.objects AS o1 CROSS JOIN sys.objects AS o2 CROSS JOIN sys.objects AS o3;' + , @numberOfExecution = 5 + , @saveResults = 1 + , @calcMedian = 1 + , @clearCache = 1 + , @printStepInfo = 1 + , @durationAccuracy = 'ss' + , @additionalInfo = 1; + +.EXAMPLE + DECLARE @tsql nvarchar(max) = N'SET NOCOUNT OFF; DECLARE @tsql nvarchar(max) = N''BACKUP DATABASE [master] TO DISK = N''''C:\master'' + + REPLACE(CAST(CAST(GETDATE() AS datetime2(7)) AS nvarchar(max)), '':'', '' '') + + ''.bak'''' WITH NOFORMAT, NOINIT;'' + EXEC sp_executesql @tsql;'; + EXEC sp_BenchmarkTSQL + @tsqlStatement = @tsql + , @numberOfExecution = 3 + , @saveResults = 1 + , @calcMedian = 1 + , @clearCache = 1 + , @printStepInfo = 1 + , @durationAccuracy = 'ms' + , @dateTimeFunction = 'SYSUTCDATETIME' + , @additionalInfo = 1; + +.EXAMPLE + WITH CTE AS ( + SELECT TSQLStatementGUID + , StartBenchmark + , EndBenchmark + , ClearCache + , PrintStepInfo + , DurationAccuracy + , CASE WHEN DurationAccuracy = 'ns' THEN DATEDIFF(ns, StartBenchmark, EndBenchmark) + WHEN DurationAccuracy = 'mcs' THEN DATEDIFF(mcs, StartBenchmark, EndBenchmark) + WHEN DurationAccuracy = 'ms' THEN DATEDIFF(ms, StartBenchmark, EndBenchmark) + WHEN DurationAccuracy = 'ss' THEN DATEDIFF(ss, StartBenchmark, EndBenchmark) + WHEN DurationAccuracy = 'mi' THEN DATEDIFF(mi, StartBenchmark, EndBenchmark) + WHEN DurationAccuracy = 'hh' THEN DATEDIFF(hh, StartBenchmark, EndBenchmark) + WHEN DurationAccuracy = 'dd' THEN DATEDIFF(dd, StartBenchmark, EndBenchmark) + WHEN DurationAccuracy = 'wk' THEN DATEDIFF(wk, StartBenchmark, EndBenchmark) + ELSE 0 + END AS BenchmarkDuration + , CASE WHEN DurationAccuracy = 'ns' THEN DATEDIFF(ns, StartStep, EndStep) + WHEN DurationAccuracy = 'mcs' THEN DATEDIFF(mcs, StartStep, EndStep) + WHEN DurationAccuracy = 'ms' THEN DATEDIFF(ms, StartStep, EndStep) + WHEN DurationAccuracy = 'ss' THEN DATEDIFF(ss, StartStep, EndStep) + WHEN DurationAccuracy = 'mi' THEN DATEDIFF(mi, StartStep, EndStep) + WHEN DurationAccuracy = 'hh' THEN DATEDIFF(hh, StartStep, EndStep) + WHEN DurationAccuracy = 'dd' THEN DATEDIFF(dd, StartStep, EndStep) + WHEN DurationAccuracy = 'wk' THEN DATEDIFF(wk, StartStep, EndStep) + ELSE 0 + END AS StepDuration + , StepRowNumber + , StartStep + , EndStep + , TsqlStatementBefore + , TsqlStatement + , TsqlStatementAfter + , OriginalLogin + , AdditionalInfo + FROM master.dbo.BenchmarkTSQL + WHERE TSQLStatementGUID IN ('D34C4BD6-01B8-4C9C-B627-E3C26F84D9FA', '02DF082C-7D3D-450E-B125-C738F015B35A') + ) + SELECT TSQLStatementGUID + , StartBenchmark + , EndBenchmark + , ClearCache + , PrintStepInfo + , MAX(StepRowNumber) AS StepCount + , DurationAccuracy + , BenchmarkDuration + , MIN(StepDuration) AS StepDurationMIN + , MAX(StepDuration) AS StepDurationMAX + , AVG(StepDuration) AS StepDurationAVG + , TsqlStatement + FROM CTE + GROUP BY TSQLStatementGUID + , StartBenchmark + , EndBenchmark + , ClearCache + , PrintStepInfo + , DurationAccuracy + , BenchmarkDuration + , TsqlStatement; + +.LICENSE MIT +Permission is here by granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +.NOTE + Version: 5.9 + Created: 2017-12-14 by Konstantin Taranov + Modified: 2019-08-26 by Konstantin Taranov + Main contributors: Konstantin Taranov, Aleksei Nagorskii + Source: https://rebrand.ly/sp_BenchmarkTSQL +*/ +AS +BEGIN TRY + + SET NOCOUNT ON; + + DECLARE @startBenchmark datetime2(7) = CASE WHEN @dateTimeFunction = 'SYSDATETIME' THEN SYSDATETIME() + WHEN @dateTimeFunction = 'SYSUTCDATETIME' THEN SYSUTCDATETIME() + END; + + DECLARE @originalLogin sysname = QUOTENAME(ORIGINAL_LOGIN()); /* https://sqlstudies.com/2015/06/24/which-user-function-do-i-use/ */ + DECLARE @err_msg nvarchar(max); + DECLARE @raiseError nvarchar(2000); + + /* Using RAISEEROR for interactive step printing http://sqlity.net/en/984/print-vs-raiserror/ */ + SET @raiseError = 'Benchmark started at ' + CONVERT(varchar(27), @startBenchmark, 121) + ' by ' + @originalLogin; + RAISERROR(@raiseError, 0, 1) WITH NOWAIT; + + DECLARE @productMajorVersion sql_variant = SERVERPROPERTY('ProductMajorVersion'); + IF CAST(@productMajorVersion AS int) < 10 + BEGIN + DECLARE @MsgError varchar(2000) = 'Stored procedure sp_BenchmarkTSQL works only for SQL Server 2008 and higher. Yor ProductMajorVersion is ' + + CAST(@productMajorVersion AS varchar(30)) + + '. You can try to replace datetime2 data type on datetime, perhaps it will be enough.'; + THROW 55001, @MsgError, 1; + END; + + IF @tsqlStatement IS NULL + THROW 55002, '@tsqlStatement is NULL, please specify TSQL statement.', 1; + IF @tsqlStatement = N'' + THROW 55003, '@tsqlStatement is empty, please specify TSQL statement.', 1; + + IF @durationAccuracy NOT IN ( + 'ns' /* nanosecond */ + , 'mcs' /* microsecond */ + , 'ms' /* millisecond */ + , 'ss' /* second */ + , 'mi' /* minute */ + , 'hh' /* hour */ + , 'dd' /* day */ + , 'wk' /* week */ + ) + THROW 55004, '@durationAccuracy accept only this values: ns, mcs, ms, ss, mi, hh, wk, dd. Default value is ss. See DATEDIFF https://docs.microsoft.com/sql/t-sql/functions/datediff-transact-sql' , 1; + + IF @dateTimeFunction NOT IN ('SYSDATETIME', 'SYSUTCDATETIME') + THROW 55005, '@dateTimeFunction accept only SYSDATETIME and SYSUTCDATETIME. Default value is SYSDATETIME. See https://docs.microsoft.com/sql/t-sql/functions/date-and-time-data-types-and-functions-transact-sql', 1; + + IF @numberOfExecution <= 0 OR @numberOfExecution > 32000 + THROW 55006, '@numberOfExecution must be > 0 and <= 32000. If you want more execution then comment 273 and 274 lines.', 1; + + IF @skipTSQLCheck = 0 + BEGIN + IF @tsqlStatementBefore IS NOT NULL AND @tsqlStatementBefore <> '' AND EXISTS ( + SELECT 1 + FROM sys.dm_exec_describe_first_result_set(@tsqlStatementBefore, NULL, 0) + WHERE error_message IS NOT NULL + AND error_number IS NOT NULL + AND error_severity IS NOT NULL + AND error_state IS NOT NULL + AND error_type IS NOT NULL + AND error_type_desc IS NOT NULL + ) + BEGIN + SELECT @err_msg = [error_message] + FROM sys.dm_exec_describe_first_result_set(@tsqlStatementBefore, NULL, 0) + WHERE column_ordinal = 0; + + THROW 55007, @err_msg, 1; + END; + + IF @tsqlStatement IS NOT NULL AND @tsqlStatement <> N'' AND EXISTS ( + SELECT 1 + FROM sys.dm_exec_describe_first_result_set(@tsqlStatement, NULL, 0) + WHERE error_message IS NOT NULL + AND error_number IS NOT NULL + AND error_severity IS NOT NULL + AND error_state IS NOT NULL + AND error_type IS NOT NULL + AND error_type_desc IS NOT NULL + ) + BEGIN + SELECT @err_msg = [error_message] + FROM sys.dm_exec_describe_first_result_set(@tsqlStatement, NULL, 0) + WHERE column_ordinal = 0; + + THROW 55008, @err_msg, 1; + END; + + IF @tsqlStatementAfter IS NOT NULL AND @tsqlStatementAfter <> N'' AND EXISTS ( + SELECT 1 + FROM sys.dm_exec_describe_first_result_set(@tsqlStatementAfter, NULL, 0) + WHERE error_message IS NOT NULL + AND error_number IS NOT NULL + AND error_severity IS NOT NULL + AND error_state IS NOT NULL + AND error_type IS NOT NULL + AND error_type_desc IS NOT NULL + ) + BEGIN + SELECT @err_msg = [error_message] + FROM sys.dm_exec_describe_first_result_set(@tsqlStatementAfter, NULL, 0) + WHERE column_ordinal = 0; + + THROW 55009, @err_msg, 1; + END; + END; + + IF @saveResults = 1 AND OBJECT_ID(N'master.dbo.BenchmarkTSQL', 'U') IS NULL + THROW 55010, 'Please create master.dbo.BenchmarkTSQL log table before run procedure with @saveResults = 1. + CREATE TABLE master.dbo.BenchmarkTSQL( + BenchmarkTSQLID int IDENTITY NOT NULL + , TSQLStatementGUID varchar(36) NOT NULL + , StepRowNumber int NOT NULL + , StartBenchmark datetime2(7) NOT NULL + , EndBenchmark datetime2(7) NOT NULL + , StartStep datetime2(7) NOT NULL + , EndStep datetime2(7) NOT NULL + , StepDuration bigint NOT NULL + , DurationAccuracy varchar(10) NOT NULL + , TsqlStatementBefore nvarchar(max) NULL + , TsqlStatement nvarchar(max) NOT NULL + , TsqlStatementAfter nvarchar(max) NULL + , ClearCache bit NOT NULL + , PrintStepInfo bit NOT NULL + , OriginalLogin sysname NOT NULL + , AdditionalInfo xml NULL + );', 1; + + DECLARE @crlf nvarchar(10) = CHAR(13) + CHAR(10); + DECLARE @stepNumber int = 0; + DECLARE @min bigint; + DECLARE @avg bigint; + DECLARE @max bigint; + DECLARE @median real; + DECLARE @planHandle varbinary(64); + DECLARE @startStep datetime2(7); + DECLARE @endStep datetime2(7); + DECLARE @stepDuration int; + DECLARE @additionalXML xml; + + DECLARE @BenchmarkTSQL TABLE( + StepNumber int NOT NULL + , StartBenchmark datetime2(7) NOT NULL + , EndBenchmark datetime2(7) NOT NULL + , StartStep datetime2(7) NOT NULL + , EndStep datetime2(7) NOT NULL + , StepDuration bigint NOT NULL + , ClearCache bit NOT NULL + , PrintStepInfo bit NOT NULL + , DurationAccuracy varchar(10) NOT NULL + , AdditionalInfo xml NULL + ); + + IF @additionalInfo = 1 + SET @tsqlStatement = @tsqlStatement + @crlf + N' + SET @additionalXMLOUT = ( + SELECT [Option], [Enabled] + FROM ( + SELECT ''DISABLE_DEF_CNST_CHK'' AS "Option", CASE @@options & 1 WHEN 0 THEN 0 ELSE 1 END AS "Enabled" UNION ALL + SELECT ''IMPLICIT_TRANSACTIONS'' , CASE @@options & 2 WHEN 0 THEN 0 ELSE 1 END UNION ALL + SELECT ''CURSOR_CLOSE_ON_COMMIT'' , CASE @@options & 4 WHEN 0 THEN 0 ELSE 1 END UNION ALL + SELECT ''ANSI_WARNINGS'' , CASE @@options & 8 WHEN 0 THEN 0 ELSE 1 END UNION ALL + SELECT ''ANSI_PADDING'' , CASE @@options & 16 WHEN 0 THEN 0 ELSE 1 END UNION ALL + SELECT ''ANSI_NULLS'' , CASE @@options & 32 WHEN 0 THEN 0 ELSE 1 END UNION ALL + SELECT ''ARITHABORT'' , CASE @@options & 64 WHEN 0 THEN 0 ELSE 1 END UNION ALL + SELECT ''ARITHIGNORE'' , CASE @@options & 128 WHEN 0 THEN 0 ELSE 1 END UNION ALL + SELECT ''QUOTED_IDENTIFIER'' , CASE @@options & 256 WHEN 0 THEN 0 ELSE 1 END UNION ALL + SELECT ''NOCOUNT'' , CASE @@options & 512 WHEN 0 THEN 0 ELSE 1 END UNION ALL + SELECT ''ANSI_NULL_DFLT_ON'' , CASE @@options & 1024 WHEN 0 THEN 0 ELSE 1 END UNION ALL + SELECT ''ANSI_NULL_DFLT_OFF'' , CASE @@options & 2048 WHEN 0 THEN 0 ELSE 1 END UNION ALL + SELECT ''CONCAT_NULL_YIELDS_NULL'' , CASE @@options & 4096 WHEN 0 THEN 0 ELSE 1 END UNION ALL + SELECT ''NUMERIC_ROUNDABORT'' , CASE @@options & 8192 WHEN 0 THEN 0 ELSE 1 END UNION ALL + SELECT ''XACT_ABORT'' , CASE @@options & 16384 WHEN 0 THEN 0 ELSE 1 END + ) AS s + FOR XML RAW + );'; + + IF @saveResults = 1 + BEGIN + DECLARE @TSQLStatementGUID varchar(36) = NEWID(); + PRINT(N'TSQLStatementGUID in log table is: ' + @TSQLStatementGUID + @crlf + @crlf); + END; + + WHILE @stepNumber < @numberOfExecution + BEGIN + SET @stepNumber = @stepNumber + 1; + + IF @clearCache = 1 + BEGIN + SELECT @planHandle = plan_handle + FROM sys.dm_exec_cached_plans + CROSS APPLY sys.dm_exec_sql_text(plan_handle) + WHERE [text] LIKE @tsqlStatement; /* LIKE instead = (equal) because = (equal) ignore trailing spaces */ + + IF @planHandle IS NOT NULL DBCC FREEPROCCACHE(@planHandle); + END; + + IF @tsqlStatementBefore IS NOT NULL AND @tsqlStatementBefore <> '' + EXEC sp_executesql @tsqlStatementBefore; + + BEGIN /* Run bencmark step and calculate it duration */ + SET @startStep = CASE WHEN @dateTimeFunction = 'SYSDATETIME' THEN SYSDATETIME() + WHEN @dateTimeFunction = 'SYSUTCDATETIME' THEN SYSUTCDATETIME() + END; + + IF @dateTimeFunction = 'SYSDATETIME' + BEGIN + IF @additionalInfo = 0 + BEGIN + EXEC sp_executesql @tsqlStatement; + SET @endStep = SYSDATETIME(); + END; + + IF @additionalInfo = 1 + BEGIN + EXEC sp_executesql @tsqlStatement, N'@additionalXMLOUT XML OUTPUT', @additionalXMLOUT = @additionalXML OUTPUT SELECT @additionalXML; + SET @endStep = SYSDATETIME(); + END; + END; + + IF @dateTimeFunction = 'SYSUTCDATETIME' + BEGIN + IF @additionalInfo = 0 + BEGIN + EXEC sp_executesql @tsqlStatement; + SET @endStep = SYSUTCDATETIME(); + END; + + IF @additionalInfo = 1 + BEGIN + EXEC sp_executesql @tsqlStatement, N'@additionalXMLOUT XML OUTPUT', @additionalXMLOUT = @additionalXML OUTPUT SELECT @additionalXML; + SET @endStep = SYSUTCDATETIME(); + END; + END; + + END; + + SET @stepDuration = CASE WHEN @durationAccuracy = 'ns' THEN DATEDIFF(ns, @startStep, @endStep) + WHEN @durationAccuracy = 'mcs' THEN DATEDIFF(mcs, @startStep, @endStep) + WHEN @durationAccuracy = 'ms' THEN DATEDIFF(ms, @startStep, @endStep) + WHEN @durationAccuracy = 'ss' THEN DATEDIFF(ss, @startStep, @endStep) + WHEN @durationAccuracy = 'mi' THEN DATEDIFF(mi, @startStep, @endStep) + WHEN @durationAccuracy = 'hh' THEN DATEDIFF(hh, @startStep, @endStep) + WHEN @durationAccuracy = 'dd' THEN DATEDIFF(dd, @startStep, @endStep) + WHEN @durationAccuracy = 'wk' THEN DATEDIFF(wk, @startStep, @endStep) + ELSE 0 + END; + + INSERT @BenchmarkTSQL ( + StepNumber + , StartBenchmark + , EndBenchmark + , StartStep + , EndStep + , StepDuration + , DurationAccuracy + , ClearCache + , PrintStepInfo + , AdditionalInfo + ) + VALUES ( + @stepNumber + , @startBenchmark + , /* it does not matter which function use (this is NOT NULL column) + becasue we update this column later with correct values */ + SYSDATETIME() + , @startStep + , @endStep + , @stepDuration + , @durationAccuracy + , @clearCache + , @printStepInfo + , @additionalXML + ); + + IF @saveResults = 1 + BEGIN + INSERT INTO master.dbo.BenchmarkTSQL( + TSQLStatementGUID + , StepRowNumber + , StartBenchmark + , EndBenchmark + , StartStep + , EndStep + , StepDuration + , DurationAccuracy + , TsqlStatementBefore + , TsqlStatement + , TsqlStatementAfter + , ClearCache + , PrintStepInfo + , OriginalLogin + , AdditionalInfo + ) + SELECT @TSQLStatementGUID AS TSQLStatementGUID + , @stepNumber AS StepRowNumber + , StartBenchmark + , EndBenchmark + , StartStep + , EndStep + , StepDuration + , DurationAccuracy + , @tsqlStatementBefore + , @tsqlStatement + , @tsqlStatementAfter + , ClearCache + , PrintStepInfo + , @originalLogin AS OriginalLogin + , @additionalXML AS AdditionalInfo + FROM @BenchmarkTSQL + WHERE StepNumber = @stepNumber; + END; + + IF @printStepInfo = 1 + BEGIN + /* Using RAISEEROR for interactive step printing http://sqlity.net/en/984/print-vs-raiserror/ */ + SET @raiseError = 'Run ' + CASE WHEN @stepNumber < 10 THEN ' ' + CAST(@stepNumber AS varchar(30)) + WHEN @stepNumber < 100 THEN ' ' + CAST(@stepNumber AS varchar(30)) + WHEN @stepNumber < 1000 THEN ' ' + CAST(@stepNumber AS varchar(30)) + WHEN @stepNumber < 10000 THEN ' ' + CAST(@stepNumber AS varchar(30)) + ELSE CAST(@stepNumber AS varchar(30)) + END + + ', start: ' + CONVERT(varchar(27), @startStep, 121) + + ', finish: ' + CONVERT(varchar(27), CASE WHEN @dateTimeFunction = 'SYSDATETIME' THEN SYSDATETIME() + WHEN @dateTimeFunction = 'SYSUTCDATETIME' THEN SYSUTCDATETIME() + END, 121) + + ', step duration: ' + REPLACE(CONVERT(varchar(30), CONVERT(money, @stepDuration), 1), '.00', '') + ' ' + @durationAccuracy + @crlf; + RAISERROR(@raiseError, 0, 1) WITH NOWAIT; + END; + + IF @tsqlStatementAfter IS NOT NULL AND @tsqlStatementAfter <> '' + EXEC sp_executesql @tsqlStatementAfter; + + END; + + SELECT @min = MIN(StepDuration), @avg = AVG(StepDuration), @max = MAX(StepDuration) + FROM @BenchmarkTSQL; + + DECLARE @endBenchmark datetime2(7) = CASE WHEN @dateTimeFunction = 'SYSDATETIME' THEN SYSDATETIME() + WHEN @dateTimeFunction = 'SYSUTCDATETIME' THEN SYSUTCDATETIME() + END; + + IF @saveResults = 1 + BEGIN + UPDATE master.dbo.BenchmarkTSQL + SET EndBenchmark = @endBenchmark + WHERE TSQLStatementGUID = @TSQLStatementGUID; + END; + + IF @calcMedian = 1 + BEGIN + SELECT @median = + ( + (SELECT MAX(TMIN) FROM + (SELECT TOP(50) PERCENT + CASE WHEN @durationAccuracy = 'ns' THEN DATEDIFF(ns, StartStep, EndStep) + WHEN @durationAccuracy = 'mcs' THEN DATEDIFF(mcs, StartStep, EndStep) + WHEN @durationAccuracy = 'ms' THEN DATEDIFF(ms, StartStep, EndStep) + WHEN @durationAccuracy = 'ss' THEN DATEDIFF(ss, StartStep, EndStep) + WHEN @durationAccuracy = 'mi' THEN DATEDIFF(mi, StartStep, EndStep) + WHEN @durationAccuracy = 'hh' THEN DATEDIFF(hh, StartStep, EndStep) + WHEN @durationAccuracy = 'dd' THEN DATEDIFF(dd, StartStep, EndStep) + WHEN @durationAccuracy = 'wk' THEN DATEDIFF(wk, StartStep, EndStep) + ELSE 0 + END AS TMIN + FROM @BenchmarkTSQL + ORDER BY TMIN + ) AS BottomHalf + ) + + + (SELECT MIN(TMAX) FROM + (SELECT TOP 50 PERCENT + CASE WHEN @durationAccuracy = 'ns' THEN DATEDIFF(ns, StartStep, EndStep) + WHEN @durationAccuracy = 'mcs' THEN DATEDIFF(mcs, StartStep, EndStep) + WHEN @durationAccuracy = 'ms' THEN DATEDIFF(ms, StartStep, EndStep) + WHEN @durationAccuracy = 'ss' THEN DATEDIFF(ss, StartStep, EndStep) + WHEN @durationAccuracy = 'mi' THEN DATEDIFF(mi, StartStep, EndStep) + WHEN @durationAccuracy = 'hh' THEN DATEDIFF(hh, StartStep, EndStep) + WHEN @durationAccuracy = 'dd' THEN DATEDIFF(dd, StartStep, EndStep) + WHEN @durationAccuracy = 'wk' THEN DATEDIFF(wk, StartStep, EndStep) + ELSE 0 + END AS TMAX + FROM @BenchmarkTSQL + ORDER BY TMAX DESC + ) AS TopHalf + ) + ) / 2.0; + END; + + DECLARE @endTime datetime2(7) = CASE WHEN @dateTimeFunction = 'SYSDATETIME' THEN SYSDATETIME() + WHEN @dateTimeFunction = 'SYSUTCDATETIME' THEN SYSUTCDATETIME() + END; + + /* Using RAISEEROR for interactive step printing http://sqlity.net/en/984/print-vs-raiserror/ */ + SET @raiseError = @crlf + + 'Min: ' + REPLACE(CONVERT(varchar(30), CONVERT(money, @min), 1), '.00', '') + ' ' + @durationAccuracy + @crlf + + 'Average: ' + REPLACE(CONVERT(varchar(30), CONVERT(money, @avg), 1), '.00', '') + ' ' + @durationAccuracy + @crlf + + CASE WHEN @calcMedian = 1 THEN + 'Median: ' + REPLACE(CONVERT(varchar(30), CONVERT(money, @median) ,1), '.00', '') + ' ' + @durationAccuracy + ELSE '' + END + @crlf + + 'Max: ' + REPLACE(CONVERT(varchar(30), CONVERT(money, @max), 1), '.00', '') + ' ' + @durationAccuracy + @crlf + @crlf + + 'Benchmark ended at ' + CONVERT(varchar(23), @endTime, 121) + ' by ' + @originalLogin; + RAISERROR(@raiseError, 0, 1) WITH NOWAIT; + + DECLARE @benchmarkDuration bigint = CASE WHEN @durationAccuracy = 'ns' THEN DATEDIFF(ns, @startBenchmark, @endBenchmark) + WHEN @durationAccuracy = 'mcs' THEN DATEDIFF(mcs, @startBenchmark, @endBenchmark) + WHEN @durationAccuracy = 'ms' THEN DATEDIFF(ms, @startBenchmark, @endBenchmark) + WHEN @durationAccuracy = 'ss' THEN DATEDIFF(ss, @startBenchmark, @endBenchmark) + WHEN @durationAccuracy = 'mi' THEN DATEDIFF(mi, @startBenchmark, @endBenchmark) + WHEN @durationAccuracy = 'hh' THEN DATEDIFF(hh, @startBenchmark, @endBenchmark) + WHEN @durationAccuracy = 'dd' THEN DATEDIFF(dd, @startBenchmark, @endBenchmark) + WHEN @durationAccuracy = 'wk' THEN DATEDIFF(wk, @startBenchmark, @endBenchmark) + ELSE 0 + END; + + /* Using RAISEEROR for interactive step printing http://sqlity.net/en/984/print-vs-raiserror/ */ + SET @raiseError = @crlf + 'Duration of benchmark: ' + REPLACE(CONVERT(varchar(30), CONVERT(money, @benchmarkDuration), 1), '.00', '') + ' ' + @durationAccuracy + @crlf; + RAISERROR(@raiseError, 0, 1) WITH NOWAIT; + +END TRY + +BEGIN CATCH + PRINT(@crlf + + 'Error: ' + CONVERT(varchar(50), ERROR_NUMBER()) + + ', Severity: ' + CONVERT(varchar(5), ERROR_SEVERITY()) + + ', State: ' + CONVERT(varchar(5), ERROR_STATE()) + + ', Procedure: ' + ISNULL(ERROR_PROCEDURE(), '-') + + ', Line: ' + CONVERT(varchar(5), ERROR_LINE()) + + ', User name: ' + CONVERT(sysname, ORIGINAL_LOGIN()) + ); + PRINT(ERROR_MESSAGE() + @crlf + @crlf); + + IF ERROR_NUMBER() = 535 + PRINT('Your @durationAccuracy = ' + @durationAccuracy + + '. Try to use @durationAccuracy with a less precise datepart - seconds (ss) or minutes (mm) or hours (hh).' + @crlf + + 'But in log table master.dbo.BenchmarkTSQL (if you run stored procedure with @saveResult = 1) all times saving with datetime2(7) precise!' + @crlf + + 'You can manualy calculate difference after decreasing precise datepart.' + @crlf + + 'For analyze log table see latest example in document section.') + @crlf + @crlf; +END CATCH; +GO + +EXEC master.sys.sp_MS_marksystemobject @objname = N'dbo.sp_BenchmarkTSQL'; +GO diff --git a/Stored_Procedure/sp_BlitzInMemoryOLTP.sql b/Stored_Procedure/dbo.sp_BlitzInMemoryOLTP.sql similarity index 57% rename from Stored_Procedure/sp_BlitzInMemoryOLTP.sql rename to Stored_Procedure/dbo.sp_BlitzInMemoryOLTP.sql index 88b0b41b..9771fac6 100644 --- a/Stored_Procedure/sp_BlitzInMemoryOLTP.sql +++ b/Stored_Procedure/dbo.sp_BlitzInMemoryOLTP.sql @@ -1,5 +1,20 @@ -USE master; -GO +DECLARE @msg NVARCHAR(MAX) = N''; + + -- Must be a compatible, on-prem version of SQL (2014+) +IF ( (SELECT SERVERPROPERTY ('EDITION')) <> 'SQL Azure' + AND (SELECT PARSENAME(CONVERT(NVARCHAR(128), SERVERPROPERTY ('PRODUCTVERSION')), 4)) < 12 + ) + -- or Azure Database (not Azure Data Warehouse), running at database compat level 120+ +OR ( (SELECT SERVERPROPERTY ('EDITION')) = 'SQL Azure' + AND (SELECT SERVERPROPERTY ('ENGINEEDITION')) = 5 + AND (SELECT [compatibility_level] FROM sys.databases WHERE [name] = DB_NAME()) < 120 + ) +BEGIN + SELECT @msg = N'Sorry, sp_BlitzInMemoryOLTP doesn''t work on versions of SQL prior to 2014.' + REPLICATE(CHAR(13), 7933); + PRINT @msg; + RETURN; +END; + IF OBJECT_ID('dbo.sp_BlitzInMemoryOLTP', 'P') IS NULL EXECUTE ('CREATE PROCEDURE dbo.sp_BlitzInMemoryOLTP AS SELECT 1;'); @@ -10,6 +25,7 @@ ALTER PROCEDURE dbo.sp_BlitzInMemoryOLTP( , @dbName NVARCHAR(4000) = N'ALL' , @tableName NVARCHAR(4000) = NULL , @debug BIT = 0 + , @VersionDate DATETIME = NULL OUTPUT ) /* .SYNOPSIS @@ -18,7 +34,8 @@ ALTER PROCEDURE dbo.sp_BlitzInMemoryOLTP( .DESCRIPTION Get detailed information about In-Memory SQL Server objects Tested on SQL Server: 2014, 2016, 2017 - NOT tested on Azure SQL Database + tested on Azure SQL Database + NOT tested on Azure Managed Instances .PARAMETER @instanceLevelOnly Only check instance In-Memory related information @@ -36,6 +53,10 @@ ALTER PROCEDURE dbo.sp_BlitzInMemoryOLTP( EXEC sp_BlitzInMemoryOLTP; -- Get all In-memory information +.EXAMPLE + EXEC sp_BlitzInMemoryOLTP @dbName = N'ಠ ಠ'; + -- Get In-memory information for database with name ಠ ಠ + .EXAMPLE EXEC sp_BlitzInMemoryOLTP @instanceLevelOnly = 1; -- Get only instance In-Memory information @@ -51,74 +72,82 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI .NOTE Author: Ned Otter + Version: 2.0 Original link: http://nedotter.com/archive/2017/10/in-memory-oltp-diagnostic-script/ - Version: 1.0 - - Modified: 2017-12-06 - Author: Aleksey Nagorskiy - Version: 1.1 - - Modified: 2017-12-13 - Author: Konstantin Taranov - Version: 1.2 - - Modified: 2017-12-14 - Author: Konstantin Taranov - Version: 1.3 - - Modified: 2017-12-14 - Author: Aleksey Nagorskiy - Version: 1.4 - - Modified: 2017-12-18 - Author: Konstantin Taranov - Version: 1.5 - - Modified: 2017-12-19 - Author: Ned Otter - Version: 1.6 - - Modified: 2017-12-23 - Author: Ned Otter - Version: 1.7 - - Modified: 2017-12-25 - Author: Ned Otter - Version: 1.8 + Release Link: https://github.com/ktaranov/sqlserver-kit/blob/master/Stored_Procedure/sp_BlitzInMemoryOLTP.sql + Main Contributors: Ned Otter, Konstantin Taranov, Aleksey Nagorskiy */ AS +DECLARE @ScriptVersion VARCHAR(30); +SET @ScriptVersion = '1.8'; +SET @VersionDate = '20180801'; + BEGIN TRY SET NOCOUNT ON; + DECLARE @RunningOnAzureSQLDB BIT = 0; + DECLARE @crlf VARCHAR(10) = CHAR(10); - DECLARE @VersionString NVARCHAR(MAX) = CAST(SERVERPROPERTY('ProductVersion') AS NVARCHAR(128)) - , @Edition NVARCHAR(MAX) = CAST(SERVERPROPERTY('Edition') AS NVARCHAR(128)) + DECLARE @Edition NVARCHAR(MAX) = CAST(SERVERPROPERTY('Edition') AS NVARCHAR(128)) , @errorMessage NVARCHAR(512); - DECLARE @Version INT = CONVERT(INT, SUBSTRING(@VersionString, 1, CHARINDEX('.', @VersionString) - 1)); + DECLARE @Version INT = CONVERT(INT, SERVERPROPERTY('ProductMajorVersion')); IF @debug = 1 PRINT('--@Version = ' + CAST(@Version AS VARCHAR(30))); - IF @Version < 12 - BEGIN - SET @errorMessage = CONCAT('In-Memory OLTP is not supported if SQL Server version is less than 2014. You are running SQL Server version: ', @Version); - THROW 55000, @errorMessage, 1; - END; - /* ################################################### if we get here, we are running at least SQL 2014, but that version only runs In-Memory if we are using Enterprise Edition + + NOTE: Azure SQL database changes this equation ################################################### */ - IF @Version = 12 AND (@Edition NOT LIKE 'Enterprise%' AND @Edition NOT LIKE 'Developer%') + /* + SERVERPROPERTY('EngineEdition') + 1 = Personal or Desktop Engine (Not available in SQL Server 2005 and later versions.) + ,2 = Standard (This is returned for Standard, Web, and Business Intelligence.) + ,3 = Enterprise (This is returned for Evaluation, Developer, and both Enterprise editions.) + ,4 = Express (This is returned for Express, Express with Tools and Express with Advanced Services) + ,5 = SQL Database + ,6 = SQL Data Warehouse + ,8 = Managed Instance + */ + + SELECT @RunningOnAzureSQLDB = + CASE + WHEN SERVERPROPERTY('EngineEdition') IN (5, 6, 8) THEN 1 + ELSE 0 + END; + + -- Database level: we are running SQL Database or SQL Data Warehouse, but this specific database does not support XTP + IF (@RunningOnAzureSQLDB = 1 AND DatabasePropertyEx(DB_NAME(), 'IsXTPSupported') = 0) + BEGIN + SET @errorMessage = 'For Azure SQL Database, In-Memory OLTP is only suppported on the Premium tier'; + THROW 55001, @errorMessage, 1; + END; + + -- not on Azure, so we need to check versions/Editions + -- SQL 2014 only supports XTP on Enterprise edition + IF (SERVERPROPERTY('EngineEdition') IN (2, 4)) AND @Version = 12 AND (@Edition NOT LIKE 'Enterprise%' AND @Edition NOT LIKE 'Developer%') BEGIN SET @errorMessage = CONCAT('For SQL 2014, In-Memory OLTP is only suppported on Enterprise Edition. You are running SQL Server edition: ', @Edition); - THROW 55000, @errorMessage, 1; + THROW 55002, @errorMessage, 1; + END; + + -- We're not running on Azure, so we need to check versions/Editions + -- SQL 2016 non-Enterprise only supports XTP after SP1 + DECLARE @BuildString VARCHAR(4) = CONVERT(VARCHAR(4), SERVERPROPERTY('ProductBuild')); + + IF (SERVERPROPERTY('EngineEdition') IN (2, 4)) AND @Version = 13 AND (@BuildString < 4001) + -- 13.0.4001.0 is the minimum build for XTP support + BEGIN + SET @errorMessage = 'For SQL 2016, In-Memory OLTP is only suppported on non-Enterprise Edition as of SP1'; + THROW 55003, @errorMessage, 1; END; /* @@ -127,89 +156,344 @@ BEGIN TRY ###################################################################################################################### */ + DECLARE @resultsDatabaseLayout TABLE + ( + [object] NVARCHAR(MAX) + ,databaseName NVARCHAR(MAX) + ,fileGroupName NVARCHAR(MAX) + ,fileName NVARCHAR(MAX) + ,[containerName/fileType] NVARCHAR(MAX) + ,Name NVARCHAR(MAX) + ,IsContainer NVARCHAR(MAX) + ,fileGroupDescription NVARCHAR(MAX) + ,fileGroupState NVARCHAR(MAX) + ,sizeKB NVARCHAR(MAX) + ,sizeMB NVARCHAR(MAX) + ,sizeGB NVARCHAR(MAX) + ,totalSizeMB NVARCHAR(MAX) + ); + + DECLARE @resultsNativeModuleCount TABLE + ( + [object] NVARCHAR(MAX) + ,databaseName NVARCHAR(MAX) + ,[Number of modules] INT + ); + + DECLARE @resultsInMemTables TABLE + ( + [object] NVARCHAR(MAX) + ,databaseName NVARCHAR(MAX) + ,tableName NVARCHAR(MAX) + ,[rowCount] INT + ,durability_desc NVARCHAR(MAX) + ,temporal_type_desc NVARCHAR(MAX) + ,memoryAllocatedForTableKB NVARCHAR(MAX) + ,memoryUsedByTableKB NVARCHAR(MAX) + ,memoryAllocatedForIndexesKB NVARCHAR(MAX) + ,memoryUsedByIndexesKB NVARCHAR(MAX) + ); + + DECLARE @resultsIndexes TABLE + ( + [object] NVARCHAR(MAX) + ,databaseName NVARCHAR(MAX) + ,tableName NVARCHAR(MAX) + ,indexName NVARCHAR(MAX) + ,memory_consumer_id INT + ,consumerType NVARCHAR(MAX) + ,description NVARCHAR(MAX) + ,allocations INT + ,allocatedBytesMB NVARCHAR(MAX) + ,usedBytesMB NVARCHAR(MAX) + ); + + DECLARE @resultsHashBuckets TABLE + ( + [object] NVARCHAR(MAX) + ,databaseName NVARCHAR(MAX) + ,[Schema] NVARCHAR(MAX) + ,TableName NVARCHAR(MAX) + ,indexName NVARCHAR(MAX) + ,totalBucketCount BIGINT + ,emptyBucketCount BIGINT + ,emptyBucketPercent INT + ,avg_ChainLength INT + ,max_ChainLength BIGINT + ,[Free buckets status] NVARCHAR(MAX) + ,[avg_chain_length status] BIGINT + ); + + DECLARE @resultsIndexCount TABLE + ( + [object] NVARCHAR(MAX) + ,databaseName NVARCHAR(MAX) + ,tableName NVARCHAR(MAX) + ,indexCount INT + ); + + DECLARE @resultsNativeModules TABLE + ( + [object] NVARCHAR(MAX) + ,Name NVARCHAR(MAX) + ,databaseName NVARCHAR(MAX) + ,[type] NVARCHAR(MAX) + ,[definition] NVARCHAR(MAX) + ); + + DECLARE @resultsNativeLoaded TABLE + ( + [object] NVARCHAR(MAX) + ,databaseName NVARCHAR(MAX) + ,moduleName NVARCHAR(MAX) + ,object_id INT + ); + + DECLARE @resultsTemporal TABLE + ( + [object] NVARCHAR(256) + ,databaseName NVARCHAR(MAX) + ,temporalTableSchema NVARCHAR(MAX) + ,temporalTableName NVARCHAR(MAX) + ,internalHistoryTableName NVARCHAR(MAX) + ,allocatedBytesForInternalHistoryTable BIGINT + ,usedBytesForInternalHistoryTable BIGINT + ); + + DECLARE @resultsMemoryConsumerForLOBs TABLE + ( + [object] NVARCHAR(MAX) + ,databaseName NVARCHAR(MAX) + ,tableName NVARCHAR(MAX) + ,columnName NVARCHAR(MAX) + ,typeDescription NVARCHAR(MAX) + ,memoryConsumerTypeDescription NVARCHAR(MAX) + ,memoryConsumerDescription NVARCHAR(MAX) + ,allocatedBytes INT + ,usedBytes INT + ); + + DECLARE @resultsTableTypes TABLE + ( + [object] NVARCHAR(MAX) + ,databaseName NVARCHAR(MAX) + ,[Schema] NVARCHAR(MAX) + ,[Name] NVARCHAR(MAX) + ); + + DECLARE @resultsNativeModuleStats TABLE + ( + [object] NVARCHAR(MAX) + ,databaseName NVARCHAR(MAX) + ,object_id INT + ,object_name NVARCHAR(MAX) + ,cached_time DATETIME + ,last_execution_time DATETIME + ,execution_count INT + ,total_worker_time INT + ,last_worker_time INT + ,min_worker_time INT + ,max_worker_time INT + ,total_elapsed_time INT + ,last_elapsed_time INT + ,min_elapsed_time INT + ,max_elapsed_time INT + + ); + + DECLARE @resultsxtp_storage_percent TABLE + ( + databaseName NVARCHAR(MAX) + ,end_time DATETIME + ,xtp_storage_percent DECIMAL(5, 2) + + ); + + CREATE TABLE #resultsContainerDetails + ( + [object] NVARCHAR(256) + ,databaseName NVARCHAR(256) + ,containerName NVARCHAR(256) + ,container_id BIGINT + ,sizeMB NVARCHAR(256) + ,fileCount INT + ); + + CREATE TABLE #resultsContainerFileDetails + ( + [object] NVARCHAR(256) + ,databaseName NVARCHAR(256) + ,containerName NVARCHAR(256) + ,container_id BIGINT + ,fileType NVARCHAR(256) + ,fileState NVARCHAR(256) + ,sizeBytes NVARCHAR(256) + ,sizeGB NVARCHAR(256) + ,fileCount INT + ,fileGroupState NVARCHAR(256) + ); + + CREATE TABLE #resultsContainerFileSummary + ( + [object] NVARCHAR(256) + ,databaseName NVARCHAR(256) + ,fileType NVARCHAR(256) + ,fileState NVARCHAR(256) + ,sizeBytes NVARCHAR(256) + ,sizeMB NVARCHAR(256) + ,fileCount INT + ,fileGroupState NVARCHAR(256) + ); + IF OBJECT_ID('tempdb..#inmemDatabases') IS NOT NULL DROP TABLE #inmemDatabases; + + /* + -- IF we are searching for a specific @tablename, it could exist in >1 database. + -- This is the point at which we should filter, but it might require dynamic SQL, + -- or deleting database names that don't have an object where the name matches. + + */ + SELECT QUOTENAME(name) AS name , database_id , ROW_NUMBER() OVER (ORDER BY name ASC) AS rowNumber INTO #inmemDatabases FROM sys.databases WHERE name NOT IN ( 'master', 'model', 'tempdb', 'distribution', 'msdb', 'SSISDB') - AND (name = @dbName OR @dbName = 'ALL') - AND state_desc = 'ONLINE'; + AND 1 = + CASE + WHEN @RunningOnAzureSQLDB = 1 THEN 1 + WHEN @RunningOnAzureSQLDB = 0 AND name = @dbName THEN 1 + WHEN @RunningOnAzureSQLDB = 0 AND @dbName = N'ALL' THEN 1 + ELSE 0 + END + AND state_desc = 'ONLINE'; + + DECLARE @sql NVARCHAR(MAX) = '' + + DECLARE @counter INT = 1 + , @MaxRows INT = (SELECT COUNT(*) FROM #inmemDatabases); + + WHILE @counter <= @MaxRows + BEGIN + + --IF @debug = 1 PRINT('--@counter = ' + CAST(@counter AS VARCHAR(30)) + ';' + @crlf); + + IF @tableName IS NOT NULL + SELECT @sql = + CONCAT + ( + 'DELETE #inmemDatabases ' + ,'WHERE UPPER(name) = ' + ,'''' + ,UPPER(name) + ,'''' + ,' AND NOT EXISTS (' + ,'SELECT * + FROM ' + ,name + ,'.sys.objects + WHERE UPPER(name) = ' + ,'''' + ,UPPER(@tableName) + ,'''' + ,' AND UPPER(type) = ''U'')' + ) + FROM #inmemDatabases + WHERE rowNumber = @counter; + + IF @debug = 1 PRINT(@sql); + EXEC (@sql) + + SELECT @counter += 1; + END; - IF @debug = 1 SELECT 'All ONLINE user databases' AS AllDatabases, * FROM #inmemDatabases; + ALTER TABLE #inmemDatabases + ADD newRowNumber INT IDENTITY + + IF @debug = 1 + SELECT 'All ONLINE user databases' AS AllDatabases + ,name + ,database_id + FROM #inmemDatabases; IF @dbName IS NULL AND @instanceLevelOnly = 0 BEGIN SET @errorMessage = '@dbName IS NULL, please specify database name or ALL'; - THROW 55001, @errorMessage, 1; + THROW 55004, @errorMessage, 1; RETURN; END; - IF (@dbName IS NOT NULL AND @dbName <> 'ALL') + IF (@dbName IS NOT NULL AND @dbName <> N'ALL') AND (NOT EXISTS (SELECT 1 FROM #inmemDatabases WHERE name = QUOTENAME(@dbName)) AND @instanceLevelOnly = 0) BEGIN - SET @errorMessage = '@dbName not found in sys.databases'; - THROW 55002, @errorMessage, 1; + SET @errorMessage = N'Database [' + @dbName + N'] not found in sys.databases!!!' + @crlf + + N'Did you add N if your database has a unicode name?' + @crlf + + N'Try to exec this: EXEC sp_BlitzInMemoryOLTP @dbName = N''ಠ ಠ_Your_Unicode_DB_Name_ಠ ಠ'''; + THROW 55005, @errorMessage, 1; RETURN; END; IF @dbName = 'ALL' AND NOT EXISTS (SELECT 1 FROM #inmemDatabases) BEGIN SET @errorMessage = 'ALL was specified, but no memory-optimized databases were found'; - THROW 55002, @errorMessage, 1; + THROW 55006, @errorMessage, 1; RETURN; END; - IF OBJECT_ID('tempdb..#moduleSplit') IS NOT NULL DROP TABLE #moduleSplit; + -- we can't reference sys.dm_os_loaded_modules if we're on Azure SQL DB + IF @RunningOnAzureSQLDB = 0 + BEGIN + IF OBJECT_ID('tempdb..#moduleSplit') IS NOT NULL DROP TABLE #moduleSplit; - CREATE TABLE #moduleSplit - ( - rowNumber INT IDENTITY PRIMARY KEY - ,value NVARCHAR(MAX) NULL - ); + CREATE TABLE #moduleSplit + ( + rowNumber INT IDENTITY PRIMARY KEY + ,value NVARCHAR(MAX) NULL + ); - DECLARE @loadedModules TABLE - ( - rowNumber INT IDENTITY PRIMARY KEY - ,name NVARCHAR(MAX) NULL - ); + DECLARE @loadedModules TABLE + ( + rowNumber INT IDENTITY PRIMARY KEY + ,name NVARCHAR(MAX) NULL + ); - INSERT @loadedModules - ( - name - ) - SELECT name - FROM sys.dm_os_loaded_modules AS a - WHERE description = 'XTP Native DLL' - AND PATINDEX('%[_]p[_]%', name) > 0; + INSERT @loadedModules + ( + name + ) + SELECT name + FROM sys.dm_os_loaded_modules AS a + WHERE description = 'XTP Native DLL' + AND PATINDEX('%[_]p[_]%', name) > 0; - DECLARE @maxLoadedModules INT = (SELECT COUNT(*) FROM @loadedModules); - DECLARE @moduleCounter INT = 1; - DECLARE @loadedModuleName NVARCHAR(MAX) = ''; + DECLARE @maxLoadedModules INT = (SELECT COUNT(*) FROM @loadedModules); + DECLARE @moduleCounter INT = 1; + DECLARE @loadedModuleName NVARCHAR(MAX) = ''; - SET @moduleCounter = 1; + SET @moduleCounter = 1; - WHILE @moduleCounter <= @maxLoadedModules - BEGIN + WHILE @moduleCounter <= @maxLoadedModules + BEGIN - SELECT @loadedModuleName = name - FROM @loadedModules - WHERE rowNumber = @moduleCounter; + SELECT @loadedModuleName = name + FROM @loadedModules + WHERE rowNumber = @moduleCounter; - DECLARE @xml XML - , @delimiter NVARCHAR(10); - SET @delimiter = '_'; - SET @xml = CAST((''+REPLACE(@loadedModuleName, @delimiter, '')+'') AS XML); + DECLARE @xml XML + , @delimiter NVARCHAR(10); + SET @delimiter = '_'; + SET @xml = CAST((''+REPLACE(@loadedModuleName, @delimiter, '')+'') AS XML); - INSERT #moduleSplit - ( - value - ) - SELECT C.value('.', 'NVARCHAR(1000)') AS value FROM @xml.nodes('X') as X(C); + INSERT #moduleSplit + ( + value + ) + SELECT C.value('.', 'NVARCHAR(1000)') AS value FROM @xml.nodes('X') as X(C); - SELECT @moduleCounter += 1; + SELECT @moduleCounter += 1; + END; END; IF @instanceLevelOnly = 0 @@ -218,16 +502,20 @@ BEGIN TRY /* #################################################### Determine which databases are memory-optimized + NOTE: if we are running on Azure SQL DB, we need + to verify in-memory capability without joining to + sys.filegroups #################################################### */ - DECLARE @sql NVARCHAR(MAX) = '' - , @counter INT = 1 - , @MaxRows INT = (SELECT COUNT(*) FROM #inmemDatabases); + SELECT @MaxRows = (SELECT COUNT(*) FROM #inmemDatabases); + SELECT @counter = 1 + + SELECT @sql = '' WHILE @counter <= @MaxRows BEGIN - IF @debug = 1 PRINT('--@counter = ' + CAST(@counter AS VARCHAR(30)) + ';' + @crlf); + --IF @debug = 1 PRINT('--@counter = ' + CAST(@counter AS VARCHAR(30)) + ';' + @crlf); IF @counter = 1 BEGIN @@ -241,9 +529,10 @@ BEGIN TRY END; SELECT @sql += + CASE WHEN @RunningOnAzureSQLDB = 0 THEN CONCAT ( - @crlf + @crlf ,'SELECT DISTINCT ' , 'N''' , name @@ -253,16 +542,34 @@ BEGIN TRY , name , '.sys.database_files' + @crlf + ' INNER JOIN ' , name - , '.sys.filegroups ON database_files.data_space_id = filegroups.data_space_id WHERE filegroups.type = ''FX''' + , '.sys.filegroups ON database_files.data_space_id = filegroups.data_space_id ' + , 'WHERE filegroups.type = ' + ,'''' + ,'FX' + ,'''' ) + ELSE + -- if we arrive here and we're running on Azure SQL DB, then the database inherently supports In-Memory OLTP + CONCAT + ( + @crlf + ,'SELECT ' + , 'N''' + , name + , ''' AS databaseName,' + @crlf + , database_id + , ' AS database_id' + @crlf + ) + END FROM #inmemDatabases - WHERE rowNumber = @counter; - - --IF @debug = 1 PRINT(@sql); + WHERE newRowNumber = @counter; SELECT @counter += 1; END; + --IF @debug = 1 PRINT(@sql); + + -- post-processing SELECT @sql += CONCAT @@ -303,16 +610,16 @@ BEGIN TRY ) EXECUTE sp_executesql @sql; - IF @debug = 1 PRINT(@sql + @crlf); - ELSE - BEGIN + --IF @debug = 1 PRINT(@sql + @crlf); + --ELSE + --BEGIN SELECT 'Memory-optimized database(s)' AS databases ,dbName ,database_id ,log_reuse_wait_desc FROM #MemoryOptimizedDatabases ORDER BY dbName; - END; + --END; END; IF OBJECT_ID('tempdb..#NativeModules') IS NOT NULL DROP TABLE #NativeModules; @@ -339,7 +646,11 @@ BEGIN TRY WHILE @dbCounter <= @MaxRows BEGIN - + + SELECT 'now processing database: ' + dbName AS Status + FROM #MemoryOptimizedDatabases + WHERE rowNumber = @dbCounter; + /* ################################################### List memory-optimized tables in this database @@ -348,7 +659,7 @@ BEGIN TRY SELECT @sql = CONCAT ( - 'SELECT TOP 1' + 'SELECT ' ,'''Memory optimized tables''' , ' AS [object],' , ' N''' @@ -356,9 +667,9 @@ BEGIN TRY ,''' AS databaseName' ,', b.name AS tableName , p.rows AS [rowCount] - ,durability_desc - , temporal_type_desc - ,FORMAT(memory_allocated_for_table_kb, ''###,###,###'') AS memoryAllocatedForTableKB + ,durability_desc ' + ,CASE WHEN @Version >= 13 THEN ', temporal_type_desc ' ELSE ',NULL AS temporal_type_desc' END + ,', FORMAT(memory_allocated_for_table_kb, ''###,###,###'') AS memoryAllocatedForTableKB ,FORMAT(memory_used_by_table_kb, ''###,###,###'') AS memoryUsedByTableKB ,FORMAT(memory_allocated_for_indexes_kb, ''###,###,###'') AS memoryAllocatedForIndexesKB ,FORMAT(memory_used_by_indexes_kb, ''###,###,###'') AS memoryUsedByIndexesKB @@ -390,20 +701,8 @@ BEGIN TRY PRINT('--List memory-optimized tables in this database' + @crlf + @sql + @crlf); ELSE BEGIN - DECLARE @resultsInMemTables TABLE - ( - [object] NVARCHAR(MAX) - ,databaseName NVARCHAR(MAX) - ,tableName NVARCHAR(MAX) - ,[rowCount] INT - ,durability_desc NVARCHAR(MAX) - ,temporal_type_desc NVARCHAR(MAX) - ,memoryAllocatedForTableKB NVARCHAR(MAX) - ,memoryUsedByTableKB NVARCHAR(MAX) - ,memoryAllocatedForIndexesKB NVARCHAR(MAX) - ,memoryUsedByIndexesKB NVARCHAR(MAX) - ); + DELETE @resultsInMemTables INSERT @resultsInMemTables EXECUTE sp_executesql @sql; @@ -467,20 +766,7 @@ BEGIN TRY PRINT('--List indexes on memory-optimized tables in this database' + @crlf + @sql + @crlf); ELSE BEGIN - DECLARE @resultsIndexes TABLE - ( - [object] NVARCHAR(MAX) - ,databaseName NVARCHAR(MAX) - ,tableName NVARCHAR(MAX) - ,indexName INT - ,memory_consumer_id INT - ,consumerType NVARCHAR(MAX) - ,description NVARCHAR(MAX) - ,allocations INT - ,allocatedBytesMB NVARCHAR(MAX) - ,usedBytesMB NVARCHAR(MAX) - ); - + DELETE @resultsIndexes INSERT @resultsIndexes EXECUTE sp_executesql @sql; @@ -560,22 +846,7 @@ BEGIN TRY ELSE BEGIN - DECLARE @resultsHashBuckets TABLE - ( - [object] NVARCHAR(MAX) - ,databaseName NVARCHAR(MAX) - ,[Schema] NVARCHAR(MAX) - ,TableName NVARCHAR(MAX) - ,indexName NVARCHAR(MAX) - ,totalBucketCount BIGINT - ,emptyBucketCount BIGINT - ,emptyBucketPercent INT - ,avg_ChainLength INT - ,max_ChainLength BIGINT - ,[Free buckets status] NVARCHAR(MAX) - ,[avg_chain_length status] BIGINT - ); - + DELETE @resultsHashBuckets INSERT @resultsHashBuckets EXECUTE sp_executesql @sql; ; @@ -639,14 +910,8 @@ BEGIN TRY PRINT('--Count of indexes per table in this database' + @crlf + @sql + @crlf); ELSE BEGIN - DECLARE @resultsIndexCount TABLE - ( - [object] NVARCHAR(MAX) - ,databaseName NVARCHAR(MAX) - ,tableName NVARCHAR(MAX) - ,indexCount INT - ); + DELETE @resultsIndexCount INSERT @resultsIndexCount EXECUTE sp_executesql @sql; @@ -694,6 +959,7 @@ BEGIN TRY ,dbName ,'.sys.sql_modules AS B ON B.object_id = A.object_id WHERE UPPER(B.definition) LIKE ''%NATIVE_COMPILATION%'' + AND UPPER(A.name) <> ''SP_BLITZINMEMORYOLTP'' ORDER BY A.type, A.name' ) FROM #MemoryOptimizedDatabases @@ -703,15 +969,8 @@ BEGIN TRY PRINT('--List natively compiled modules in this database' + @crlf + @sql + @crlf); ELSE BEGIN - DECLARE @resultsNativeModules TABLE - ( - [object] NVARCHAR(MAX) - ,Name NVARCHAR(MAX) - ,databaseName NVARCHAR(MAX) - ,[type] NVARCHAR(MAX) - ,[definition] NVARCHAR(MAX) - ); + DELETE @resultsNativeModules INSERT @resultsNativeModules EXECUTE sp_executesql @sql; @@ -744,7 +1003,9 @@ BEGIN TRY the following code should handle all versions */ - IF @tableName IS NULL + + -- NOTE: disabling this for Azure SQL DB + IF @tableName IS NULL AND @RunningOnAzureSQLDB = 0 BEGIN SELECT @sql = CONCAT @@ -785,14 +1046,8 @@ BEGIN TRY PRINT('--List loaded natively compiled modules in this database (@Version >= 13)' + @crlf + @sql + @crlf); ELSE BEGIN - DECLARE @resultsNativeLoaded TABLE - ( - [object] NVARCHAR(MAX) - ,databaseName NVARCHAR(MAX) - ,moduleName NVARCHAR(MAX) - ,object_id INT - ); + DELETE @resultsNativeLoaded INSERT @resultsNativeLoaded EXECUTE sp_executesql @sql; @@ -818,7 +1073,6 @@ BEGIN TRY ,' ''' ,' AS databaseName , COUNT(*) AS [Number of modules] - FROM ' , dbName ,'.sys.all_sql_modules @@ -835,13 +1089,8 @@ BEGIN TRY PRINT('--Count of natively compiled modules in this database' + @crlf + @sql + @crlf); ELSE BEGIN - DECLARE @resultsNativeModuleCount TABLE - ( - [object] NVARCHAR(MAX) - ,databaseName NVARCHAR(MAX) - ,[Number of modules] INT - ); + DELETE @resultsNativeModuleCount INSERT @resultsNativeModuleCount EXECUTE sp_executesql @sql; @@ -868,6 +1117,10 @@ BEGIN TRY AS ( SELECT ' + ,'''' + ,'In-Memory Temporal Tables' + ,'''' + ,'AS object,' ,'N''' ,dbName ,'''' @@ -892,7 +1145,8 @@ BEGIN TRY ,DetailedConsumption AS ( - SELECT databaseName + SELECT object + ,databaseName ,temporalTableSchema ,T.temporalTableName ,T.internalHistoryTableName @@ -911,7 +1165,8 @@ BEGIN TRY WHERE C.allocated_bytes > 0 AND C.object_id <> T.temporalTableObjectId ) - SELECT DISTINCT databaseName + SELECT DISTINCT object + ,databaseName ,temporalTableSchema ,temporalTableName ,internalHistoryTableName @@ -931,16 +1186,8 @@ BEGIN TRY PRINT('--Display memory consumption for temporal/internal tables' + @crlf + @sql + @crlf); ELSE BEGIN - DECLARE @resultsTemporal TABLE - ( - databaseName NVARCHAR(MAX) - ,temporalTableSchema NVARCHAR(MAX) - ,temporalTableName NVARCHAR(MAX) - ,internalHistoryTableName NVARCHAR(MAX) - ,allocatedBytesForInternalHistoryTable BIGINT - ,usedBytesForInternalHistoryTable BIGINT - ); + DELETE @resultsTemporal INSERT @resultsTemporal EXECUTE sp_executesql @sql; @@ -1009,19 +1256,8 @@ BEGIN TRY PRINT('--Display memory structures for LOB columns (off-row)' + @crlf + @sql + @crlf); ELSE BEGIN - DECLARE @resultsMemoryConsumerForLOBs TABLE - ( - [object] NVARCHAR(MAX) - ,databaseName NVARCHAR(MAX) - ,tableName NVARCHAR(MAX) - ,columnName NVARCHAR(MAX) - ,typeDescription NVARCHAR(MAX) - ,memoryConsumerTypeDescription NVARCHAR(MAX) - ,memoryConsumerDescription NVARCHAR(MAX) - ,allocatedBytes INT - ,usedBytes INT - ); + DELETE @resultsMemoryConsumerForLOBs INSERT @resultsMemoryConsumerForLOBs EXECUTE sp_executesql @sql; @@ -1066,14 +1302,8 @@ BEGIN TRY PRINT('--Display memory-optimized table types' + @crlf + @sql + @crlf); ELSE BEGIN - DECLARE @resultsTableTypes TABLE - ( - [object] NVARCHAR(MAX) - ,databaseName NVARCHAR(MAX) - ,[Schema] NVARCHAR(MAX) - ,[Name] NVARCHAR(MAX) - ); + DELETE @resultsTableTypes INSERT @resultsTableTypes EXECUTE sp_executesql @sql; @@ -1090,66 +1320,52 @@ BEGIN TRY ################################################################## */ - SELECT @sql = - CONCAT - ( - 'SELECT ' - ,'''Database layout'' AS [object],' - ,' N''' - ,dbName - ,'''' - ,' AS databaseName' - ,',filegroups.name AS fileGroupName - ,physical_name AS fileName - ,database_files.name AS [Name] - ,filegroups.type AS fileGroupType - ,IsContainer = IIF(filegroups.type = ''FX'', ''Yes'', ''No'') - ,filegroups.type_desc AS fileGroupDescription - ,database_files.state_desc AS fileGroupState - ,FORMAT(database_files.size * CONVERT(BIGINT, 8192) / 1024, ''###,###,###,###'') AS sizeKB - ,FORMAT(database_files.size * CONVERT(BIGINT, 8192) / 1048576.0, ''###,###,###,###'') AS sizeMB - ,FORMAT(database_files.size * CONVERT(BIGINT, 8192) / 1073741824.0, ''###,###,###,###.##'') AS sizeGB - ,FORMAT(SUM(database_files.size / 128.0) OVER(), ''###,###,###,###'') AS totalSizeMB - FROM ' - ,dbName - ,'.sys.database_files - LEFT JOIN ' - ,dbName - ,'.sys.filegroups ON database_files.data_space_id = filegroups.data_space_id - ORDER BY filegroups.type, filegroups.name, database_files.name' - ) - FROM #MemoryOptimizedDatabases - WHERE rowNumber = @dbCounter; + IF @tableName IS NULL + BEGIN + SELECT @sql = + CONCAT + ( + 'SELECT ' + ,'''Database layout'' AS [object],' + ,' N''' + ,dbName + ,'''' + ,' AS databaseName' + ,',filegroups.name AS fileGroupName + ,physical_name AS fileName + ,database_files.name AS [Name] + ,filegroups.type AS fileGroupType + ,IsContainer = IIF(filegroups.type = ''FX'', ''Yes'', ''No'') + ,filegroups.type_desc AS fileGroupDescription + ,database_files.state_desc AS fileGroupState + ,FORMAT(database_files.size * CONVERT(BIGINT, 8192) / 1024, ''###,###,###,###'') AS sizeKB + ,FORMAT(database_files.size * CONVERT(BIGINT, 8192) / 1048576.0, ''###,###,###,###'') AS sizeMB + ,FORMAT(database_files.size * CONVERT(BIGINT, 8192) / 1073741824.0, ''###,###,###,###.##'') AS sizeGB + ,FORMAT(SUM(database_files.size / 128.0) OVER(), ''###,###,###,###'') AS totalSizeMB + FROM ' + ,dbName + ,'.sys.database_files + LEFT JOIN ' + ,dbName + ,'.sys.filegroups ON database_files.data_space_id = filegroups.data_space_id + ORDER BY filegroups.type, filegroups.name, database_files.name' + ) + FROM #MemoryOptimizedDatabases + WHERE rowNumber = @dbCounter; - IF @debug = 1 - PRINT('--ALL database files, including container name, size, location' + @crlf + @sql + @crlf); - ELSE - BEGIN - DECLARE @resultsDatabaseLayout TABLE - ( - [object] NVARCHAR(MAX) - ,databaseName NVARCHAR(MAX) - ,fileGroupName NVARCHAR(MAX) - ,fileName NVARCHAR(MAX) - ,[containerName/fileType] NVARCHAR(MAX) - ,Name NVARCHAR(MAX) - ,IsContainer NVARCHAR(MAX) - ,fileGroupDescription NVARCHAR(MAX) - ,fileGroupState NVARCHAR(MAX) - ,sizeKB NVARCHAR(MAX) - ,sizeMB NVARCHAR(MAX) - ,sizeGB NVARCHAR(MAX) - ,totalSizeMB NVARCHAR(MAX) - ); - - INSERT @resultsDatabaseLayout - EXECUTE sp_executesql @sql; + IF @debug = 1 + PRINT('--ALL database files, including container name, size, location' + @crlf + @sql + @crlf); + ELSE + BEGIN + DELETE @resultsDatabaseLayout - IF EXISTS(SELECT 1 FROM @resultsDatabaseLayout) - SELECT * FROM @resultsDatabaseLayout; + INSERT @resultsDatabaseLayout + EXECUTE sp_executesql @sql; - END; + IF EXISTS(SELECT 1 FROM @resultsDatabaseLayout) + SELECT * FROM @resultsDatabaseLayout; + END; /* ################################################################## @@ -1157,141 +1373,164 @@ BEGIN TRY ################################################################## */ - SELECT @sql = - CONCAT - ( - ';WITH ContainerDetails AS - ( - SELECT ' - ,' container_id - ,SUM(ISNULL(file_size_in_bytes, 0)) AS sizeinBytes - ,COUNT(*) AS fileCount - ,MAX(container_guid) AS container_guid - FROM ' - ,dbName - ,'.sys.dm_db_xtp_checkpoint_files - GROUP BY container_id - ) - SELECT - ''Container details by container name'' AS [object],' - ,' N''' + DELETE #resultsContainerDetails; + + SELECT @sql = + CONCAT + ( + ';WITH ContainerDetails AS + ( + SELECT ' + ,' container_id + ,SUM(ISNULL(file_size_in_bytes, 0)) AS sizeinBytes + ,COUNT(*) AS fileCount + ,MAX(container_guid) AS container_guid + FROM ' + ,dbName + ,'.sys.dm_db_xtp_checkpoint_files + GROUP BY container_id + ) + INSERT #resultsContainerDetails + SELECT + ''Container details by container name'' AS [object],' + ,' N''' + ,dbName + ,'''' + ,' AS databaseName + ,database_files.name AS containerName + ,ContainerDetails.container_id + ,FORMAT(ContainerDetails.sizeinBytes / 1048576., ''###,###,###'') AS sizeMB + ,ContainerDetails.fileCount + FROM ContainerDetails + INNER JOIN ' ,dbName - ,'''' - ,' AS databaseName - ,database_files.name AS containerName - ,ContainerDetails.container_id - ,FORMAT(ContainerDetails.sizeinBytes / 1048576., ''###,###,###'') AS sizeMB - ,ContainerDetails.fileCount - FROM ContainerDetails - INNER JOIN ' - ,dbName - ,'.sys.database_files ON ContainerDetails.container_guid = database_files.file_guid' - ) - FROM #MemoryOptimizedDatabases - WHERE rowNumber = @dbCounter; + ,'.sys.database_files ON ContainerDetails.container_guid = database_files.file_guid' + ) + FROM #MemoryOptimizedDatabases + WHERE rowNumber = @dbCounter; - IF @debug = 1 - PRINT('--container name, size, number of files' + @crlf + @sql + @crlf); - ELSE EXECUTE sp_executesql @sql; + IF @debug = 1 + PRINT('--container name, size, number of files' + @crlf + @sql + @crlf); + ELSE + BEGIN + EXECUTE sp_executesql @sql; + IF EXISTS (SELECT 1 FROM #resultsContainerDetails) + SELECT * FROM #resultsContainerDetails + END - /* - ################################################################## - container file summary - ################################################################## - */ + /* + ################################################################## + container file summary + ################################################################## + */ - SELECT @sql = - CONCAT - ( - ';WITH ContainerFileSummary AS + DELETE #resultsContainerFileSummary; + + SELECT @sql = + CONCAT ( - SELECT ' - ,' + ';WITH ContainerFileSummary AS + ( + SELECT ' + ,' SUM(ISNULL(file_size_in_bytes, 0)) AS sizeinBytes ,MAX(ISNULL(file_type_desc, '''')) AS fileType - ,COUNT(*) AS fileCount - ,MAX(state_desc) AS fileState - ,MAX(container_guid) AS container_guid - FROM ' - ,dbName - ,'.sys.dm_db_xtp_checkpoint_files - GROUP BY file_type_desc, state_desc + ,COUNT(*) AS fileCount + ,MAX(state_desc) AS fileState + ,MAX(container_guid) AS container_guid + FROM ' + ,dbName + ,'.sys.dm_db_xtp_checkpoint_files + GROUP BY file_type_desc, state_desc + ) + INSERT #resultsContainerFileSummary + SELECT + ''Container details by fileType and fileState'' AS [object],' + ,' N''' + ,dbName + ,'''' + ,' AS databaseName + ,ContainerFileSummary.fileType + ,ContainerFileSummary.fileState + ,FORMAT(ContainerFileSummary.sizeinBytes, ''###,###,###'') AS sizeBytes + ,FORMAT(ContainerFileSummary.sizeinBytes / 1048576., ''###,###,###'') AS sizeMB + ,ContainerFileSummary.fileCount + ,database_files.state_desc AS fileGroupState + FROM ContainerFileSummary + INNER JOIN ' + ,dbName + ,'.sys.database_files ON ContainerFileSummary.container_guid = database_files.file_guid' + ,' ORDER BY ContainerFileSummary.fileType, ContainerFileSummary.fileState;' ) - SELECT - ''Container details by fileType and fileState'' AS [object],' + FROM #MemoryOptimizedDatabases + WHERE rowNumber = @dbCounter; + + IF @debug = 1 + PRINT('--container file summary' + @crlf + @sql + @crlf); + ELSE + BEGIN + EXECUTE sp_executesql @sql; + IF EXISTS (SELECT 1 FROM #resultsContainerFileSummary) + SELECT * FROM #resultsContainerFileSummary; + END; + + /* + ################################################################## + container file details + ################################################################## + */ + + DELETE #resultsContainerFileDetails; + + SELECT @sql = + CONCAT + ( + ';WITH ContainerFileDetails AS + ( + SELECT + container_id + ,SUM(ISNULL(file_size_in_bytes, 0)) AS sizeinBytes + ,MAX(ISNULL(file_type_desc, '''')) AS fileType + ,COUNT(*) AS fileCount + ,MAX(state_desc) AS fileState + ,MAX(container_guid) AS container_guid + FROM ' + ,dbName + ,'.sys.dm_db_xtp_checkpoint_files + GROUP BY container_id, file_type_desc, state_desc + ) + INSERT #resultsContainerFileDetails + SELECT ' + ,'''Container file details by container_id, fileType and fileState'' AS [object],' ,' N''' ,dbName ,'''' ,' AS databaseName - ,ContainerFileSummary.fileType - ,ContainerFileSummary.fileState - ,FORMAT(ContainerFileSummary.sizeinBytes, ''###,###,###'') AS sizeBytes - ,FORMAT(ContainerFileSummary.sizeinBytes / 1048576., ''###,###,###'') AS sizeMB - ,ContainerFileSummary.fileCount + ,database_files.name AS containerName + ,ContainerFileDetails.container_id + ,ContainerFileDetails.fileType + ,ContainerFileDetails.fileState + ,FORMAT(ContainerFileDetails.sizeinBytes, ''###,###,###'') AS sizeBytes + ,FORMAT(ContainerFileDetails.sizeinBytes / 1048576., ''###,###,###'') AS sizeGB + ,ContainerFileDetails.fileCount ,database_files.state_desc AS fileGroupState - FROM ContainerFileSummary - INNER JOIN ' - ,dbName - ,'.sys.database_files ON ContainerFileSummary.container_guid = database_files.file_guid' - ,' ORDER BY ContainerFileSummary.fileType, ContainerFileSummary.fileState;' - ) - FROM #MemoryOptimizedDatabases - WHERE rowNumber = @dbCounter; - - IF @debug = 1 - PRINT('--container file summary' + @crlf + @sql + @crlf); - ELSE EXECUTE sp_executesql @sql; - - /* - ################################################################## - container details - ################################################################## - */ - - SELECT @sql = - CONCAT - ( - ';WITH ContainerFileDetails AS - ( - SELECT - container_id - ,SUM(ISNULL(file_size_in_bytes, 0)) AS sizeinBytes - ,MAX(ISNULL(file_type_desc, '''')) AS fileType - ,COUNT(*) AS fileCount - ,MAX(state_desc) AS fileState - ,MAX(container_guid) AS container_guid - FROM ' + FROM ContainerFileDetails + INNER JOIN ' ,dbName - ,'.sys.dm_db_xtp_checkpoint_files - GROUP BY container_id, file_type_desc, state_desc + ,'.sys.database_files ON ContainerFileDetails.container_guid = database_files.file_guid' ) - SELECT ' - ,'''Container file details by container_id, fileType and fileState'' AS [object],' - ,' N''' - ,dbName - ,'''' - ,' AS databaseName - ,database_files.name AS containerName - ,ContainerFileDetails.container_id - ,ContainerFileDetails.fileType - ,ContainerFileDetails.fileState - ,FORMAT(ContainerFileDetails.sizeinBytes, ''###,###,###'') AS sizeBytes - ,FORMAT(ContainerFileDetails.sizeinBytes / 1048576., ''###,###,###'') AS sizeGB - ,ContainerFileDetails.fileCount - ,database_files.state_desc AS fileGroupState - FROM ContainerFileDetails - INNER JOIN ' - ,dbName - ,'.sys.database_files ON ContainerFileDetails.container_guid = database_files.file_guid' - ) - FROM #MemoryOptimizedDatabases - WHERE rowNumber = @dbCounter; - - IF @debug = 1 - - PRINT('--container details' + @crlf + @sql + @crlf); - ELSE EXECUTE sp_executesql @sql; + FROM #MemoryOptimizedDatabases + WHERE rowNumber = @dbCounter; + IF @debug = 1 + PRINT('--container details' + @crlf + @sql + @crlf); + ELSE + BEGIN + EXECUTE sp_executesql @sql; + IF EXISTS (SELECT 1 FROM #resultsContainerFileDetails) + SELECT * FROM #resultsContainerFileDetails; + END; + END; /* ########################################################### @@ -1299,113 +1538,127 @@ BEGIN TRY for natively compiled procedures is enabled ########################################################### */ - SELECT @sql = - CONCAT - ( - 'INSERT #NativeModules + + IF EXISTS (SELECT 1 FROM #NativeModules) + BEGIN + SELECT @sql = + CONCAT ( - moduleID - ,moduleName + 'INSERT #NativeModules + ( + moduleID + ,moduleName + ) + SELECT ' + ,dbName + ,'.sys.all_sql_modules.Object_ID AS ObjectID + ,name AS moduleName + FROM ' + ,dbName + ,'.sys.all_sql_modules + INNER JOIN ' + ,dbName + ,'.sys.procedures ON procedures.object_id = all_sql_modules.object_id' + ,' WHERE uses_native_compilation = 1' ) - SELECT ' - ,dbName - ,'.sys.all_sql_modules.Object_ID AS ObjectID - ,name AS moduleName - FROM ' - ,dbName - ,'.sys.all_sql_modules - INNER JOIN ' - ,dbName - ,'.sys.procedures ON procedures.object_id = all_sql_modules.object_id' - ,' WHERE uses_native_compilation = 1' - ) - FROM #MemoryOptimizedDatabases - WHERE rowNumber = @dbCounter; + FROM #MemoryOptimizedDatabases + WHERE rowNumber = @dbCounter; - EXECUTE sp_executesql @sql; + EXECUTE sp_executesql @sql; - IF EXISTS (SELECT 1 FROM #NativeModules) - BEGIN - DECLARE @procCounter INT = 1; - DECLARE @MaxModules INT = (SELECT COUNT(*) FROM #NativeModules); - DECLARE @dbID INT = (SELECT database_id FROM #MemoryOptimizedDatabases WHERE rowNumber = @dbCounter); - DECLARE @moduleID INT; - DECLARE @ModuleStatus BIT; - DECLARE @moduleName NVARCHAR(256); + DELETE @resultsNativeModuleStats; - /* - ######################################################## - This is the loop that processes each native module - ######################################################## - */ - WHILE @procCounter <= @MaxModules - BEGIN - - SELECT @moduleID = moduleID - ,@moduleName = moduleName - FROM #NativeModules - WHERE moduleKey = @procCounter; - - PRINT CONCAT('Verifying collection stats of ', @moduleName); - - SELECT @ModuleStatus = 0; - - /*############################################################################################# - - If the module we are verifying collection status for has not been executed at least once, - error 41377 will be returned, and will terminate the WHILE loop (so we trap it in a CATCH block, - in order to determine the correct status for this specific proc). - - Msg 41377, Level 16, State 2, Procedure sp_xtp_control_query_exec_stats_internal, Line 1 [Batch Start Line 0] - The natively compiled module with database ID 27 and object ID 1973582069 has not been executed. - Query execution statistics collection can only be enabled if the module has been executed at least once since creation or last database restart. - ############################################################################################# - */ - - BEGIN TRY - EXEC sys.sp_xtp_control_query_exec_stats - @database_id = @dbID - ,@xtp_object_id = @moduleID - ,@old_collection_value = @ModuleStatus OUTPUT; - END TRY - BEGIN CATCH - SELECT - @ModuleStatus = 0; - END CATCH; - - IF @ModuleStatus = 1 - BEGIN - UPDATE #NativeModules - SET collectionStatus = 1 - WHERE moduleKey = @procCounter; - END; - - SELECT @procCounter += 1; - END; -- -- This is the loop that processes each native module - - IF EXISTS(SELECT * FROM #NativeModules WHERE collectionStatus = 1) - SELECT 'Native execution statistics' AS [object] - ,moduleName - ,moduleID - ,CASE - WHEN collectionStatus = 1 THEN 'YES' - WHEN collectionStatus IS NULL THEN 'NO' - ELSE 'NO' - END AS CollectionStatsEnabled - FROM #NativeModules - WHERE collectionStatus = 1 - ORDER BY moduleName; - ELSE - BEGIN - PRINT '--No modules found that have collection stats enabled'; - END; + SELECT @sql = + CONCAT + ( + 'SELECT ''Native modules that have exec stats enabled'' AS object' + ,',' + ,' N''' + ,dbName + ,''' AS databaseName + ,object_id + ,OBJECT_NAME(object_id) AS ''object name'' + ,cached_time + ,last_execution_time + ,execution_count + ,total_worker_time + ,last_worker_time + ,min_worker_time + ,max_worker_time + ,total_elapsed_time + ,last_elapsed_time + ,min_elapsed_time + ,max_elapsed_time + FROM ' + ,'sys.dm_exec_procedure_stats + WHERE database_id = DB_ID() + AND object_id IN (SELECT object_id FROM sys.sql_modules WHERE uses_native_compilation = 1) + ORDER BY total_worker_time DESC;' + ) + FROM #MemoryOptimizedDatabases + WHERE rowNumber = @dbCounter; + INSERT @resultsNativeModuleStats + EXECUTE sp_executesql @sql; + + IF @debug = 1 + PRINT('--Native modules with execution status' + @crlf + @sql + @crlf); + ELSE + IF EXISTS(SELECT 1 FROM @resultsNativeModuleStats) + SELECT * FROM @resultsNativeModuleStats; + END; --IF EXISTS (SELECT 1 FROM #NativeModules) + ELSE + BEGIN + PRINT '--No modules found that have collection stats enabled'; + END; + + IF @RunningOnAzureSQLDB = 1 + BEGIN + + DELETE @resultsxtp_storage_percent; + + INSERT @resultsxtp_storage_percent + ( + databaseName + ,end_time + ,xtp_storage_percent + ) + SELECT DB_NAME() AS databaseName + ,end_time + ,xtp_storage_percent + FROM sys.dm_db_resource_stats + WHERE xtp_storage_percent > 0; + + IF EXISTS(SELECT 1 FROM @resultsxtp_storage_percent) + BEGIN + SELECT databaseName + ,'xtp_storage_percent in descending order' AS object + ,end_time + ,xtp_storage_percent + FROM @resultsxtp_storage_percent + ORDER BY end_time DESC; + END; + + SELECT DB_NAME() AS databaseName + ,DBScopedConfig = 'XTP_PROCEDURE_EXECUTION_STATISTICS enabled:' + ,Status = CASE WHEN value = 1 THEN 'Yes' ELSE 'No' END + FROM sys.database_scoped_configurations + WHERE UPPER(name) = 'XTP_PROCEDURE_EXECUTION_STATISTICS'; + + SELECT DB_NAME() AS databaseName + ,DBScopedConfig = 'XTP_QUERY_EXECUTION_STATISTICS enabled:' + ,Status = CASE WHEN value = 1 THEN 'Yes' ELSE 'No' END + FROM sys.database_scoped_configurations + WHERE UPPER(name) = 'XTP_QUERY_EXECUTION_STATISTICS'; + END; + SELECT @dbCounter += 1; END; -- This is the loop that processes each database - END; + + END; -- IF @instanceLevelOnly = 0 IF OBJECT_ID('#NativeModules', 'U') IS NOT NULL DROP TABLE #NativeModules; @@ -1434,7 +1687,7 @@ BEGIN TRY ,value AS configValue ,value_in_use AS runValue FROM sys.configurations - WHERE name like 'max server memory%' + WHERE UPPER(name) LIKE 'MAX SERVER MEMORY%' ORDER BY name OPTION (RECOMPILE); -- from Mark Wilkinson @@ -1449,33 +1702,61 @@ BEGIN TRY SELECT * FROM sys.dm_db_xtp_memory_consumers */ - SELECT * FROM sys.dm_os_memory_clerks; - SELECT type AS object_type + SELECT 'dm_os_memory_clerks, DETAILS' AS Object + ,type + ,name + ,pages_kb + ,virtual_memory_reserved_kb + ,virtual_memory_committed_kb + ,awe_allocated_kb + ,shared_memory_reserved_kb + ,shared_memory_committed_kb + FROM sys.dm_os_memory_clerks; + + SELECT 'dm_os_memory_clerks, SUMMARY by XTP type' AS Object + ,type AS object_type ,SUM(pages_kb) /1024.0 /1024.0 AS pages_mb FROM sys.dm_os_memory_clerks WHERE type LIKE '%XTP%' GROUP BY type; - SELECT memory_consumer_type_desc AS object_type, - SUM(allocated_bytes) /1024.0 /1024.0 AS pagesAllocatedMB - ,SUM(allocated_bytes) /1024.0 /1024.0 AS pagesUsedMB - FROM sys.dm_xtp_system_memory_consumers - GROUP BY memory_consumer_type_desc - ORDER BY memory_consumer_type_desc; + DECLARE @xtp_system_memory_consumers TABLE + ( + object_type nvarchar(64) + ,pagesAllocatedMB BIGINT + ,pagesUsedMB BIGINT + ); + INSERT @xtp_system_memory_consumers + ( + object_type + ,pagesAllocatedMB + ,pagesUsedMB + ) SELECT memory_consumer_type_desc AS object_type, SUM(allocated_bytes) /1024.0 /1024.0 AS pagesAllocatedMB ,SUM(allocated_bytes) /1024.0 /1024.0 AS pagesUsedMB - FROM sys.dm_db_xtp_memory_consumers + FROM sys.dm_xtp_system_memory_consumers GROUP BY memory_consumer_type_desc ORDER BY memory_consumer_type_desc; + IF EXISTS (SELECT 1 FROM @xtp_system_memory_consumers) + SELECT 'xtp_system_memory_consumers' AS Object + ,object_type + ,pagesAllocatedMB + ,pagesUsedMB + FROM @xtp_system_memory_consumers; - SELECT FORMAT(committed_target_kb, '###,###,###,###,###') AS committedTargetKB - ,FORMAT(committed_target_kb / 1024, '###,###,###,###,###') AS committedTargetMB - ,FORMAT(committed_target_kb / 1048576, '###,###,###,###,###') AS committedTargetGB - FROM sys.dm_os_sys_info; + -- sys.dm_os_sys_info not supported on Azure SQL Database + IF @RunningOnAzureSQLDB = 0 + BEGIN + SELECT 'Committed Target memory' AS Object + ,FORMAT(committed_target_kb, '###,###,###,###,###') AS committedTargetKB + ,FORMAT(committed_target_kb / 1024, '###,###,###,###,###') AS committedTargetMB + ,FORMAT(committed_target_kb / 1048576, '###,###,###,###,###') AS committedTargetGB + FROM sys.dm_os_sys_info; + END IF OBJECT_ID('#TraceFlags', 'U') IS NOT NULL DROP TABLE #TraceFlags; @@ -1527,14 +1808,58 @@ BEGIN TRY -- instance level DECLARE @InstancecollectionStatus BIT; - EXEC sys.sp_xtp_control_query_exec_stats - @old_collection_value = @InstancecollectionStatus OUTPUT; + IF @RunningOnAzureSQLDB = 0 + BEGIN - SELECT - CASE - WHEN @InstancecollectionStatus = 1 THEN 'YES' - ELSE 'NO' - END AS [instance-level collection of execution statistics for Native Modules enabled]; + EXEC sys.sp_xtp_control_query_exec_stats + @old_collection_value = @InstancecollectionStatus OUTPUT; + + SELECT + CASE + WHEN @InstancecollectionStatus = 1 THEN 'YES' + ELSE 'NO' + END AS [instance-level collection of execution statistics for Native Modules enabled]; + END; + ELSE + BEGIN + -- repeating this from the database section if we are running @instanceLevelOnly = 1 + + DELETE @resultsxtp_storage_percent; + + INSERT @resultsxtp_storage_percent + ( + databaseName + ,end_time + ,xtp_storage_percent + ) + SELECT DB_NAME() AS databaseName + ,end_time + ,xtp_storage_percent + FROM sys.dm_db_resource_stats + WHERE xtp_storage_percent > 0; + + IF EXISTS(SELECT 1 FROM @resultsxtp_storage_percent) + BEGIN + SELECT databaseName + ,'xtp_storage_percent in descending order' AS object + ,end_time + ,xtp_storage_percent + FROM @resultsxtp_storage_percent + ORDER BY end_time DESC; + END; + + SELECT DB_NAME() AS databaseName + ,DBScopedConfig = 'XTP_PROCEDURE_EXECUTION_STATISTICS enabled:' + ,Status = CASE WHEN value = 1 THEN 'Yes' ELSE 'No' END + FROM sys.database_scoped_configurations + WHERE UPPER(name) = 'XTP_PROCEDURE_EXECUTION_STATISTICS'; + + SELECT DB_NAME() AS databaseName + ,DBScopedConfig = 'XTP_QUERY_EXECUTION_STATISTICS enabled:' + ,Status = CASE WHEN value = 1 THEN 'Yes' ELSE 'No' END + FROM sys.database_scoped_configurations + WHERE UPPER(name) = 'XTP_QUERY_EXECUTION_STATISTICS'; + END; /* #################################################################################### @@ -1605,14 +1930,33 @@ BEGIN TRY END FROM clerksAggregatedString; + DECLARE @dm_os_memory_clerks TABLE + ( + clerk_type NVARCHAR(60) + ,name NVARCHAR(256) + ,memory_node_id SMALLINT + ,pages_mb BIGINT + ); + + INSERT @dm_os_memory_clerks + ( + clerk_type + ,name + ,memory_node_id + ,pages_mb + ) -- total memory allocated for in-memory engine - SELECT type clerk_type - , name - , memory_node_id - , pages_kb/1024 pages_mb + SELECT type AS clerk_type + ,name + ,memory_node_id + ,pages_kb/1024 AS pages_mb FROM sys.dm_os_memory_clerks WHERE type LIKE '%xtp%'; + IF EXISTS (SELECT 1 FROM @dm_os_memory_clerks) + SELECT * + FROM @dm_os_memory_clerks; + /* ################################################################# @@ -1621,6 +1965,29 @@ BEGIN TRY ################################################################# */ + DECLARE @dm_db_xtp_transactions TABLE + ( + [object] NVARCHAR(256) + ,xtp_transaction_id BIGINT + ,transaction_id BIGINT + ,session_id SMALLINT + ,begin_tsn BIGINT + ,end_tsn BIGINT + ,state_desc NVARCHAR(64) + ,result_desc NVARCHAR(64) + ); + + INSERT @dm_db_xtp_transactions + ( + object + ,xtp_transaction_id + ,transaction_id + ,session_id + ,begin_tsn + ,end_tsn + ,state_desc + ,result_desc + ) SELECT TOP 10 'Oldest xtp transactions' AS [object] ,xtp_transaction_id ,transaction_id @@ -1632,6 +1999,10 @@ BEGIN TRY FROM sys.dm_db_xtp_transactions ORDER BY begin_tsn DESC; + IF EXISTS (SELECT 1 FROM @dm_db_xtp_transactions) + SELECT * + FROM @dm_db_xtp_transactions; + /* ################################################################# Is event notification defined at the serverdb level? @@ -1650,6 +2021,15 @@ BEGIN TRY FROM sys.event_notifications; END; END; -- @instanceLevelOnly = 1 AND @Version >= 12 + + SELECT + 'Thanks for using sp_BlitzInMemoryOLTP!' AS [Thanks], + 'From Your Community Volunteers' AS [From], + 'http://FirstResponderKit.org' AS [At], + 'We hope you found this tool useful. Current version: ' + + @ScriptVersion + ' released on ' + CONVERT(NVARCHAR(30), @VersionDate) + '.' AS [Version]; + + END TRY BEGIN CATCH @@ -1663,3 +2043,4 @@ BEGIN CATCH PRINT ERROR_MESSAGE(); END CATCH; GO + diff --git a/Stored_Procedure/sp_Blocked_Process_Report_Viewer.sql b/Stored_Procedure/dbo.sp_Blocked_Process_Report_Viewer.sql similarity index 100% rename from Stored_Procedure/sp_Blocked_Process_Report_Viewer.sql rename to Stored_Procedure/dbo.sp_Blocked_Process_Report_Viewer.sql diff --git a/Stored_Procedure/sp_ChangeDatabaseOwnerShip.sql b/Stored_Procedure/dbo.sp_ChangeDatabaseOwnerShip.sql similarity index 100% rename from Stored_Procedure/sp_ChangeDatabaseOwnerShip.sql rename to Stored_Procedure/dbo.sp_ChangeDatabaseOwnerShip.sql diff --git a/Stored_Procedure/sp_DBA_job_notification.sql b/Stored_Procedure/dbo.sp_DBA_job_notification.sql similarity index 100% rename from Stored_Procedure/sp_DBA_job_notification.sql rename to Stored_Procedure/dbo.sp_DBA_job_notification.sql diff --git a/Stored_Procedure/sp_Defrag_Indexes.sql b/Stored_Procedure/dbo.sp_Defrag_Indexes.sql similarity index 100% rename from Stored_Procedure/sp_Defrag_Indexes.sql rename to Stored_Procedure/dbo.sp_Defrag_Indexes.sql diff --git a/Stored_Procedure/dbo.sp_Depends.sql b/Stored_Procedure/dbo.sp_Depends.sql new file mode 100644 index 00000000..239dcdd0 --- /dev/null +++ b/Stored_Procedure/dbo.sp_Depends.sql @@ -0,0 +1,153 @@ +IF OBJECT_ID('dbo.sp_Depends', 'P') IS NULL +EXECUTE ('CREATE PROCEDURE dbo.sp_Depends AS SELECT 1'); +GO + +ALTER PROCEDURE dbo.sp_Depends( + @objectName SYSNAME = N'' + , @objectClass NVARCHAR(60) = N'OBJECT' + , @debug BIT = 0 +) +AS +/* + Program: dbo.sp_depends_v2 + Developer: Manjuke Fernando + Date: 06.07.2018 +*/ +BEGIN + SET NOCOUNT ON; + + DECLARE @Sql AS NVARCHAR(MAX) = N''; + + IF OBJECT_ID(@objectName) IS NULL + THROW 50001, 'Object with @objectName is not exists in current database!', 1 + ELSE + IF @debug = 1 PRINT('-- OBJECT_ID = ' + CAST(OBJECT_ID(@objectName) AS NVARCHAR(50))); + + BEGIN TRY + IF @debug = 1 + SET @Sql = N'DECLARE @RefObjectName SYSNAME = N''' + @objectName + ''';' + CHAR(13) + + N'DECLARE @objectClass NVARCHAR(60) = N''' + @objectClass + ''';' + CHAR(13); + + SET @Sql = @Sql + + N'SELECT CONCAT(sch.[name], ''.'', Obj.[name]) AS [name] + ,(CASE Obj.type + WHEN ''C'' THEN ''CHECK constraint'' + WHEN ''D'' THEN ''DEFAULT (constraint or stand-alone)'' + WHEN ''F'' THEN ''FOREIGN KEY constraint'' + WHEN ''PK'' THEN ''PRIMARY KEY constraint'' + WHEN ''R'' THEN ''Rule (old-style, stand-alone)'' + WHEN ''TA'' THEN ''Assembly (CLR-integration) trigger'' + WHEN ''TR'' THEN ''SQL trigger'' + WHEN ''UQ'' THEN ''UNIQUE constraint'' + WHEN ''AF'' THEN ''Aggregate function (CLR)'' + WHEN ''C'' THEN ''CHECK constraint'' + WHEN ''D'' THEN ''DEFAULT (constraint or stand-alone)'' + WHEN ''F'' THEN ''FOREIGN KEY constraint'' + WHEN ''FN'' THEN ''SQL scalar function'' + WHEN ''FS'' THEN ''Assembly (CLR) scalar-function'' + WHEN ''FT'' THEN ''Assembly (CLR) table-valued function'' + WHEN ''IF'' THEN ''SQL inline table-valued function'' + WHEN ''IT'' THEN ''Internal table'' + WHEN ''P'' THEN ''SQL Stored Procedure'' + WHEN ''PC'' THEN ''Assembly (CLR) stored-procedure'' + WHEN ''PG'' THEN ''Plan guide'' + WHEN ''PK'' THEN ''PRIMARY KEY constraint'' + WHEN ''R'' THEN ''Rule (old-style, stand-alone)'' + WHEN ''RF'' THEN ''Replication-filter-procedure'' + WHEN ''S'' THEN ''System base TABLE'' + WHEN ''SN'' THEN ''Synonym'' + WHEN ''SO'' THEN ''Sequence OBJECT'' + WHEN ''U'' THEN ''Table (user-defined)'' + WHEN ''V'' THEN ''VIEW'' + WHEN ''SQ'' THEN ''Service queue'' + WHEN ''TA'' THEN ''Assembly (CLR) DML trigger'' + WHEN ''TF'' THEN ''SQL table-valued-function'' + WHEN ''TR'' THEN ''SQL DML trigger'' + WHEN ''TT'' THEN ''Table type'' + WHEN ''UQ'' THEN ''UNIQUE CONSTRAINT'' + WHEN ''X'' THEN ''Extended stored procedure'' + ELSE ''Undefined'' + END) AS [type] + , Obj.create_date + , Obj.modify_date + , src.referenced_minor_name AS [column] + , IIF(src.is_selected = 1, ''yes'', ''no'') AS is_selected + , IIF(src.is_updated = 1, ''yes'', ''no'') AS is_updated + , IIF(src.is_select_all = 1, ''yes'', ''no'') AS is_select_all + --, IIF(src.is_insert_all = 1, ''yes'', ''no'') AS is_insert_all + FROM + sys.dm_sql_referenced_entities (@RefObjectName, @objectClass) AS src + JOIN sys.objects AS Obj ON src.referenced_id = Obj.[object_id] + JOIN sys.schemas AS sch ON sch.[schema_id] = Obj.[schema_id] + -- WHERE 1=1 + -- AND src.referenced_minor_name IS NOT NULL + ; + + SELECT CONCAT(Src.referencing_schema_name, ''.'', Src.referencing_entity_name) AS [name] + , (CASE Obj.type + WHEN ''C'' THEN ''CHECK constraint'' + WHEN ''D'' THEN ''DEFAULT (constraint or stand-alone)'' + WHEN ''F'' THEN ''FOREIGN KEY constraint'' + WHEN ''PK'' THEN ''PRIMARY KEY constraint'' + WHEN ''R'' THEN ''Rule (old-style, stand-alone)'' + WHEN ''TA'' THEN ''Assembly (CLR-integration) trigger'' + WHEN ''TR'' THEN ''SQL trigger'' + WHEN ''UQ'' THEN ''UNIQUE constraint'' + WHEN ''AF'' THEN ''Aggregate function (CLR)'' + WHEN ''C'' THEN ''CHECK constraint'' + WHEN ''D'' THEN ''DEFAULT (constraint or stand-alone)'' + WHEN ''F'' THEN ''FOREIGN KEY constraint'' + WHEN ''FN'' THEN ''SQL scalar function'' + WHEN ''FS'' THEN ''Assembly (CLR) scalar-function'' + WHEN ''FT'' THEN ''Assembly (CLR) table-valued function'' + WHEN ''IF'' THEN ''SQL inline table-valued function'' + WHEN ''IT'' THEN ''Internal table'' + WHEN ''P'' THEN ''SQL Stored Procedure'' + WHEN ''PC'' THEN ''Assembly (CLR) stored-procedure'' + WHEN ''PG'' THEN ''Plan guide'' + WHEN ''PK'' THEN ''PRIMARY KEY constraint'' + WHEN ''R'' THEN ''Rule (old-style, stand-alone)'' + WHEN ''RF'' THEN ''Replication-filter-procedure'' + WHEN ''S'' THEN ''System base TABLE'' + WHEN ''SN'' THEN ''Synonym'' + WHEN ''SO'' THEN ''Sequence OBJECT'' + WHEN ''U'' THEN ''Table (user-defined)'' + WHEN ''V'' THEN ''VIEW'' + WHEN ''SQ'' THEN ''Service queue'' + WHEN ''TA'' THEN ''Assembly (CLR) DML trigger'' + WHEN ''TF'' THEN ''SQL table-valued-function'' + WHEN ''TR'' THEN ''SQL DML trigger'' + WHEN ''TT'' THEN ''Table type'' + WHEN ''UQ'' THEN ''UNIQUE CONSTRAINT'' + WHEN ''X'' THEN ''Extended stored procedure'' + ELSE ''Undefined'' + END) AS [type] + , Obj.create_date + , Obj.modify_date + FROM sys.dm_sql_referencing_entities (@RefObjectName, @objectClass) AS Src + INNER JOIN sys.objects AS Obj ON Obj.[object_id] = Src.referencing_id;'; + + IF @debug = 1 + BEGIN + PRINT(SUBSTRING(@Sql, 1, 4000)); + PRINT(SUBSTRING(@Sql, 4001, 8000)); + END + ELSE + EXEC sp_executesql @Sql + , N'@RefObjectName AS SYSNAME, @objectClass AS NVARCHAR(60)' + , @RefObjectName = @objectName + , @objectClass = @objectClass; + + END TRY + + BEGIN CATCH + PRINT 'Error: ' + CONVERT(varchar(50), ERROR_NUMBER()) + + ', Severity: ' + CONVERT(varchar(5), ERROR_SEVERITY()) + + ', State: ' + CONVERT(varchar(5), ERROR_STATE()) + + ', Procedure: ' + ISNULL(ERROR_PROCEDURE(), '-') + + ', Line: ' + CONVERT(varchar(5), ERROR_LINE()) + + ', User name: ' + CONVERT(sysname, CURRENT_USER); + END CATCH + +END; +GO diff --git a/Stored_Procedure/sp_DropIndexes.sql b/Stored_Procedure/dbo.sp_DropIndexes.sql similarity index 100% rename from Stored_Procedure/sp_DropIndexes.sql rename to Stored_Procedure/dbo.sp_DropIndexes.sql diff --git a/Stored_Procedure/sp_Example_RegisterAssembly_PDFCLR.sql b/Stored_Procedure/dbo.sp_Example_RegisterAssembly_PDFCLR.sql similarity index 100% rename from Stored_Procedure/sp_Example_RegisterAssembly_PDFCLR.sql rename to Stored_Procedure/dbo.sp_Example_RegisterAssembly_PDFCLR.sql diff --git a/Stored_Procedure/sp_FailedJobs.sql b/Stored_Procedure/dbo.sp_FailedJobs.sql similarity index 100% rename from Stored_Procedure/sp_FailedJobs.sql rename to Stored_Procedure/dbo.sp_FailedJobs.sql diff --git a/Stored_Procedure/sp_FailedLogins.sql b/Stored_Procedure/dbo.sp_FailedLogins.sql similarity index 100% rename from Stored_Procedure/sp_FailedLogins.sql rename to Stored_Procedure/dbo.sp_FailedLogins.sql diff --git a/Stored_Procedure/dbo.sp_GenerateMerge.sql b/Stored_Procedure/dbo.sp_GenerateMerge.sql new file mode 100644 index 00000000..eceacb81 --- /dev/null +++ b/Stored_Procedure/dbo.sp_GenerateMerge.sql @@ -0,0 +1,670 @@ +--https://github.com/readyroll/generate-sql-merge/blob/master/master.dbo.sp_generate_merge.sql +SET NOCOUNT ON +GO + +PRINT 'Using Master database' +USE master +GO + +PRINT 'Checking for the existence of this procedure' +IF (SELECT OBJECT_ID('sp_generate_merge','P')) IS NOT NULL --means, the procedure already exists + BEGIN + PRINT 'Procedure already exists. So, dropping it' + DROP PROC sp_generate_merge + END +GO + +--Turn system object marking on + +CREATE PROC [sp_generate_merge] +( + @table_name varchar(776), -- The table/view for which the MERGE statement will be generated using the existing data + @target_table varchar(776) = NULL, -- Use this parameter to specify a different table name into which the data will be inserted/updated/deleted + @from nvarchar(max) = NULL, -- Use this parameter to filter the rows based on a filter condition (using WHERE) + @include_timestamp bit = 0, -- Specify 1 for this parameter, if you want to include the TIMESTAMP/ROWVERSION column's data in the MERGE statement + @debug_mode bit = 0, -- If @debug_mode is set to 1, the SQL statements constructed by this procedure will be printed for later examination + @schema varchar(64) = NULL, -- Use this parameter if you are not the owner of the table + @ommit_images bit = 0, -- Use this parameter to generate MERGE statement by omitting the 'image' columns + @ommit_identity bit = 0, -- Use this parameter to ommit the identity columns + @top int = NULL, -- Use this parameter to generate a MERGE statement only for the TOP n rows + @cols_to_include varchar(8000) = NULL, -- List of columns to be included in the MERGE statement + @cols_to_exclude varchar(8000) = NULL, -- List of columns to be excluded from the MERGE statement + @update_only_if_changed bit = 1, -- When 1, only performs an UPDATE operation if an included column in a matched row has changed. + @delete_if_not_matched bit = 1, -- When 1, deletes unmatched source rows from target, when 0 source rows will only be used to update existing rows or insert new. + @disable_constraints bit = 0, -- When 1, disables foreign key constraints and enables them after the MERGE statement + @ommit_computed_cols bit = 0, -- When 1, computed columns will not be included in the MERGE statement + @include_use_db bit = 1, -- When 1, includes a USE [DatabaseName] statement at the beginning of the generated batch + @results_to_text bit = 0, -- When 1, outputs results to grid/messages window. When 0, outputs MERGE statement in an XML fragment. + @include_rowsaffected bit = 1, -- When 1, a section is added to the end of the batch which outputs rows affected by the MERGE + @nologo bit = 0, -- When 1, the "About" comment is suppressed from output + @batch_separator VARCHAR(50) = 'GO' -- Batch separator to use +) +AS +BEGIN + +/*********************************************************************************************************** +Procedure: sp_generate_merge (Version 0.93) + (Adapted by Daniel Nolan for SQL Server 2008/2012) + +Adapted from: sp_generate_inserts (Build 22) + (Copyright 2002 Narayana Vyas Kondreddi. All rights reserved.) + +Purpose: To generate a MERGE statement from existing data, which will INSERT/UPDATE/DELETE data based + on matching primary key values in the source/target table. + + The generated statements can be executed to replicate the data in some other location. + + Typical use cases: + * Generate statements for static data tables, store the .SQL file in source control and use + it as part of your Dev/Test/Prod deployment. The generated statements are re-runnable, so + you can make changes to the file and migrate those changes between environments. + + * Generate statements from your Production tables and then run those statements in your + Dev/Test environments. Schedule this as part of a SQL Job to keep all of your environments + in-sync. + + * Enter test data into your Dev environment, and then generate statements from the Dev + tables so that you can always reproduce your test database with valid sample data. + + +Written by: Narayana Vyas Kondreddi + http://vyaskn.tripod.com + + Daniel Nolan + http://danere.com + @dan3r3 + +Acknowledgements (sp_generate_merge): + Nathan Skerl -- StackOverflow answer that provided a workaround for the output truncation problem + http://stackoverflow.com/a/10489767/266882 + + Bill Gibson -- Blog that detailed the static data table use case; the inspiration for this proc + http://blogs.msdn.com/b/ssdt/archive/2012/02/02/including-data-in-an-sql-server-database-project.aspx + + Bill Graziano -- Blog that provided the groundwork for MERGE statement generation + http://weblogs.sqlteam.com/billg/archive/2011/02/15/generate-merge-statements-from-a-table.aspx + +Acknowledgements (sp_generate_inserts): + Divya Kalra -- For beta testing + Mark Charsley -- For reporting a problem with scripting uniqueidentifier columns with NULL values + Artur Zeygman -- For helping me simplify a bit of code for handling non-dbo owned tables + Joris Laperre -- For reporting a regression bug in handling text/ntext columns + +Tested on: SQL Server 2008 (10.50.1600), SQL Server 2012 (11.0.2100) + +Date created: January 17th 2001 21:52 GMT +Modified: May 1st 2002 19:50 GMT +Last Modified: September 27th 2012 10:00 AEDT + +Email: dan@danere.com, vyaskn@hotmail.com + +NOTE: This procedure may not work with tables with a large number of columns (> 500). + Results can be unpredictable with huge text columns or SQL Server 2000's sql_variant data types + IMPORTANT: This procedure has not been extensively tested with international data (Extended characters or Unicode). If needed + you might want to convert the datatypes of character variables in this procedure to their respective unicode counterparts + like nchar and nvarchar + +Get Started: Ensure that your SQL client is configured to send results to grid (default SSMS behaviour). +This ensures that the generated MERGE statement can be output in full, getting around SSMS's 4000 nchar limit. +After running this proc, click the hyperlink within the single row returned to copy the generated MERGE statement. + +Example 1: To generate a MERGE statement for table 'titles': + + EXEC sp_generate_merge 'titles' + +Example 2: To generate a MERGE statement for 'titlesCopy' table from 'titles' table: + + EXEC sp_generate_merge 'titles', 'titlesCopy' + +Example 3: To generate a MERGE statement for table 'titles' that will unconditionally UPDATE matching rows + (ie. not perform a "has data changed?" check prior to going ahead with an UPDATE): + + EXEC sp_generate_merge 'titles', @update_only_if_changed = 0 + +Example 4: To generate a MERGE statement for 'titles' table for only those titles + which contain the word 'Computer' in them: + NOTE: Do not complicate the FROM or WHERE clause here. It's assumed that you are good with T-SQL if you are using this parameter + + EXEC sp_generate_merge 'titles', @from = "from titles where title like '%Computer%'" + +Example 5: To specify that you want to include TIMESTAMP column's data as well in the MERGE statement: + (By default TIMESTAMP column's data is not scripted) + + EXEC sp_generate_merge 'titles', @include_timestamp = 1 + +Example 6: To print the debug information: + + EXEC sp_generate_merge 'titles', @debug_mode = 1 + +Example 7: If the table is in a different schema to the default, use @schema parameter to specify the schema name + To use this option, you must have SELECT permissions on that table + + EXEC sp_generate_merge 'Nickstable', @schema = 'Nick' + +Example 8: To generate a MERGE statement for the rest of the columns excluding images + + EXEC sp_generate_merge 'imgtable', @ommit_images = 1 + +Example 9: To generate a MERGE statement excluding (omitting) IDENTITY columns: + (By default IDENTITY columns are included in the MERGE statement) + + EXEC sp_generate_merge 'mytable', @ommit_identity = 1 + +Example 10: To generate a MERGE statement for the TOP 10 rows in the table: + + EXEC sp_generate_merge 'mytable', @top = 10 + +Example 11: To generate a MERGE statement with only those columns you want: + + EXEC sp_generate_merge 'titles', @cols_to_include = "'title','title_id','au_id'" + +Example 12: To generate a MERGE statement by omitting certain columns: + + EXEC sp_generate_merge 'titles', @cols_to_exclude = "'title','title_id','au_id'" + +Example 13: To avoid checking the foreign key constraints while loading data with a MERGE statement: + + EXEC sp_generate_merge 'titles', @disable_constraints = 1 + +Example 14: To exclude computed columns from the MERGE statement: + + EXEC sp_generate_merge 'MyTable', @ommit_computed_cols = 1 + +***********************************************************************************************************/ + +SET NOCOUNT ON + + +--Making sure user only uses either @cols_to_include or @cols_to_exclude +IF ((@cols_to_include IS NOT NULL) AND (@cols_to_exclude IS NOT NULL)) + BEGIN + RAISERROR('Use either @cols_to_include or @cols_to_exclude. Do not use both the parameters at once',16,1) + RETURN -1 --Failure. Reason: Both @cols_to_include and @cols_to_exclude parameters are specified + END + + +--Making sure the @cols_to_include and @cols_to_exclude parameters are receiving values in proper format +IF ((@cols_to_include IS NOT NULL) AND (PATINDEX('''%''',@cols_to_include) = 0)) + BEGIN + RAISERROR('Invalid use of @cols_to_include property',16,1) + PRINT 'Specify column names surrounded by single quotes and separated by commas' + PRINT 'Eg: EXEC sp_generate_merge titles, @cols_to_include = "''title_id'',''title''"' + RETURN -1 --Failure. Reason: Invalid use of @cols_to_include property + END + +IF ((@cols_to_exclude IS NOT NULL) AND (PATINDEX('''%''',@cols_to_exclude) = 0)) + BEGIN + RAISERROR('Invalid use of @cols_to_exclude property',16,1) + PRINT 'Specify column names surrounded by single quotes and separated by commas' + PRINT 'Eg: EXEC sp_generate_merge titles, @cols_to_exclude = "''title_id'',''title''"' + RETURN -1 --Failure. Reason: Invalid use of @cols_to_exclude property + END + + +--Checking to see if the database name is specified along wih the table name +--Your database context should be local to the table for which you want to generate a MERGE statement +--specifying the database name is not allowed +IF (PARSENAME(@table_name,3)) IS NOT NULL + BEGIN + RAISERROR('Do not specify the database name. Be in the required database and just specify the table name.',16,1) + RETURN -1 --Failure. Reason: Database name is specified along with the table name, which is not allowed + END + + +--Checking for the existence of 'user table' or 'view' +--This procedure is not written to work on system tables +--To script the data in system tables, just create a view on the system tables and script the view instead +IF @schema IS NULL + BEGIN + IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = @table_name AND (TABLE_TYPE = 'BASE TABLE' OR TABLE_TYPE = 'VIEW') AND TABLE_SCHEMA = SCHEMA_NAME()) + BEGIN + RAISERROR('User table or view not found.',16,1) + PRINT 'You may see this error if the specified table is not in your default schema (' + SCHEMA_NAME() + '). In that case use @schema parameter to specify the schema name.' + PRINT 'Make sure you have SELECT permission on that table or view.' + RETURN -1 --Failure. Reason: There is no user table or view with this name + END + END +ELSE + BEGIN + IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = @table_name AND (TABLE_TYPE = 'BASE TABLE' OR TABLE_TYPE = 'VIEW') AND TABLE_SCHEMA = @schema) + BEGIN + RAISERROR('User table or view not found.',16,1) + PRINT 'Make sure you have SELECT permission on that table or view.' + RETURN -1 --Failure. Reason: There is no user table or view with this name + END + END + + +--Variable declarations +DECLARE @Column_ID int, + @Column_List varchar(8000), + @Column_List_For_Update varchar(8000), + @Column_List_For_Check varchar(8000), + @Column_Name varchar(128), + @Column_Name_Unquoted varchar(128), + @Data_Type varchar(128), + @Actual_Values nvarchar(max), --This is the string that will be finally executed to generate a MERGE statement + @IDN varchar(128), --Will contain the IDENTITY column's name in the table + @Target_Table_For_Output varchar(776), + @Source_Table_Qualified varchar(776) + + + +--Variable Initialization +SET @IDN = '' +SET @Column_ID = 0 +SET @Column_Name = '' +SET @Column_Name_Unquoted = '' +SET @Column_List = '' +SET @Column_List_For_Update = '' +SET @Column_List_For_Check = '' +SET @Actual_Values = '' + +--Variable Defaults +IF @schema IS NULL + BEGIN + SET @Target_Table_For_Output = QUOTENAME(COALESCE(@target_table, @table_name)) + END +ELSE + BEGIN + SET @Target_Table_For_Output = QUOTENAME(@schema) + '.' + QUOTENAME(COALESCE(@target_table, @table_name)) + END + +SET @Source_Table_Qualified = QUOTENAME(COALESCE(@schema,SCHEMA_NAME())) + '.' + QUOTENAME(@table_name) + +--To get the first column's ID +SELECT @Column_ID = MIN(ORDINAL_POSITION) +FROM INFORMATION_SCHEMA.COLUMNS (NOLOCK) +WHERE TABLE_NAME = @table_name +AND TABLE_SCHEMA = COALESCE(@schema, SCHEMA_NAME()) + + +--Loop through all the columns of the table, to get the column names and their data types +WHILE @Column_ID IS NOT NULL + BEGIN + SELECT @Column_Name = QUOTENAME(COLUMN_NAME), + @Column_Name_Unquoted = COLUMN_NAME, + @Data_Type = DATA_TYPE + FROM INFORMATION_SCHEMA.COLUMNS (NOLOCK) + WHERE ORDINAL_POSITION = @Column_ID + AND TABLE_NAME = @table_name + AND TABLE_SCHEMA = COALESCE(@schema, SCHEMA_NAME()) + + IF @cols_to_include IS NOT NULL --Selecting only user specified columns + BEGIN + IF CHARINDEX( '''' + SUBSTRING(@Column_Name,2,LEN(@Column_Name)-2) + '''',@cols_to_include) = 0 + BEGIN + GOTO SKIP_LOOP + END + END + + IF @cols_to_exclude IS NOT NULL --Selecting only user specified columns + BEGIN + IF CHARINDEX( '''' + SUBSTRING(@Column_Name,2,LEN(@Column_Name)-2) + '''',@cols_to_exclude) <> 0 + BEGIN + GOTO SKIP_LOOP + END + END + + --Making sure to output SET IDENTITY_INSERT ON/OFF in case the table has an IDENTITY column + IF (SELECT COLUMNPROPERTY( OBJECT_ID(@Source_Table_Qualified),SUBSTRING(@Column_Name,2,LEN(@Column_Name) - 2),'IsIdentity')) = 1 + BEGIN + IF @ommit_identity = 0 --Determing whether to include or exclude the IDENTITY column + SET @IDN = @Column_Name + ELSE + GOTO SKIP_LOOP + END + + --Making sure whether to output computed columns or not + IF @ommit_computed_cols = 1 + BEGIN + IF (SELECT COLUMNPROPERTY( OBJECT_ID(@Source_Table_Qualified),SUBSTRING(@Column_Name,2,LEN(@Column_Name) - 2),'IsComputed')) = 1 + BEGIN + GOTO SKIP_LOOP + END + END + + --Tables with columns of IMAGE data type are not supported for obvious reasons + IF(@Data_Type in ('image')) + BEGIN + IF (@ommit_images = 0) + BEGIN + RAISERROR('Tables with image columns are not supported.',16,1) + PRINT 'Use @ommit_images = 1 parameter to generate a MERGE for the rest of the columns.' + RETURN -1 --Failure. Reason: There is a column with image data type + END + ELSE + BEGIN + GOTO SKIP_LOOP + END + END + + --Determining the data type of the column and depending on the data type, the VALUES part of + --the MERGE statement is generated. Care is taken to handle columns with NULL values. Also + --making sure, not to lose any data from flot, real, money, smallmomey, datetime columns + SET @Actual_Values = @Actual_Values + + CASE + WHEN @Data_Type IN ('char','nchar') + THEN + 'COALESCE(''N'''''' + REPLACE(RTRIM(' + @Column_Name + '),'''''''','''''''''''')+'''''''',''NULL'')' + WHEN @Data_Type IN ('varchar','nvarchar') + THEN + 'COALESCE(''N'''''' + REPLACE(' + @Column_Name + ','''''''','''''''''''')+'''''''',''NULL'')' + WHEN @Data_Type IN ('datetime','smalldatetime','datetime2','date') + THEN + 'COALESCE('''''''' + RTRIM(CONVERT(char,' + @Column_Name + ',127))+'''''''',''NULL'')' + WHEN @Data_Type IN ('uniqueidentifier') + THEN + 'COALESCE(''N'''''' + REPLACE(CONVERT(char(36),RTRIM(' + @Column_Name + ')),'''''''','''''''''''')+'''''''',''NULL'')' + WHEN @Data_Type IN ('text') + THEN + 'COALESCE(''N'''''' + REPLACE(CONVERT(varchar(max),' + @Column_Name + '),'''''''','''''''''''')+'''''''',''NULL'')' + WHEN @Data_Type IN ('ntext') + THEN + 'COALESCE('''''''' + REPLACE(CONVERT(nvarchar(max),' + @Column_Name + '),'''''''','''''''''''')+'''''''',''NULL'')' + WHEN @Data_Type IN ('xml') + THEN + 'COALESCE('''''''' + REPLACE(CONVERT(nvarchar(max),' + @Column_Name + '),'''''''','''''''''''')+'''''''',''NULL'')' + WHEN @Data_Type IN ('binary','varbinary') + THEN + 'COALESCE(RTRIM(CONVERT(varchar(max),' + @Column_Name + ', 1)),''NULL'')' + WHEN @Data_Type IN ('timestamp','rowversion') + THEN + CASE + WHEN @include_timestamp = 0 + THEN + '''DEFAULT''' + ELSE + 'COALESCE(RTRIM(CONVERT(char,' + 'CONVERT(int,' + @Column_Name + '))),''NULL'')' + END + WHEN @Data_Type IN ('float','real','money','smallmoney') + THEN + 'COALESCE(LTRIM(RTRIM(' + 'CONVERT(char, ' + @Column_Name + ',2)' + ')),''NULL'')' + WHEN @Data_Type IN ('hierarchyid') + THEN + 'COALESCE(''hierarchyid::Parse(''+'''''''' + LTRIM(RTRIM(' + 'CONVERT(char, ' + @Column_Name + ')' + '))+''''''''+'')'',''NULL'')' + ELSE + 'COALESCE(LTRIM(RTRIM(' + 'CONVERT(char, ' + @Column_Name + ')' + ')),''NULL'')' + END + '+' + ''',''' + ' + ' + + --Generating the column list for the MERGE statement + SET @Column_List = @Column_List + @Column_Name + ',' + + --Don't update Primary Key or Identity columns + IF NOT EXISTS( + SELECT 1 + FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS pk , + INFORMATION_SCHEMA.KEY_COLUMN_USAGE c + WHERE pk.TABLE_NAME = @table_name + AND pk.TABLE_SCHEMA = COALESCE(@schema, SCHEMA_NAME()) + AND CONSTRAINT_TYPE = 'PRIMARY KEY' + AND c.TABLE_NAME = pk.TABLE_NAME + AND c.TABLE_SCHEMA = pk.TABLE_SCHEMA + AND c.CONSTRAINT_NAME = pk.CONSTRAINT_NAME + AND c.COLUMN_NAME = @Column_Name_Unquoted + ) + BEGIN + SET @Column_List_For_Update = @Column_List_For_Update + @Column_Name + ' = Source.' + @Column_Name + ', + ' + SET @Column_List_For_Check = @Column_List_For_Check + + CASE @Data_Type + WHEN 'text' THEN CHAR(10) + CHAR(9) + 'NULLIF(CAST(Source.' + @Column_Name + ' AS VARCHAR(MAX)), CAST(Target.' + @Column_Name + ' AS VARCHAR(MAX))) IS NOT NULL OR NULLIF(CAST(Target.' + @Column_Name + ' AS VARCHAR(MAX)), CAST(Source.' + @Column_Name + ' AS VARCHAR(MAX))) IS NOT NULL OR ' + WHEN 'ntext' THEN CHAR(10) + CHAR(9) + 'NULLIF(CAST(Source.' + @Column_Name + ' AS NVARCHAR(MAX)), CAST(Target.' + @Column_Name + ' AS NVARCHAR(MAX))) IS NOT NULL OR NULLIF(CAST(Target.' + @Column_Name + ' AS NVARCHAR(MAX)), CAST(Source.' + @Column_Name + ' AS NVARCHAR(MAX))) IS NOT NULL OR ' + ELSE CHAR(10) + CHAR(9) + 'NULLIF(Source.' + @Column_Name + ', Target.' + @Column_Name + ') IS NOT NULL OR NULLIF(Target.' + @Column_Name + ', Source.' + @Column_Name + ') IS NOT NULL OR ' + END + END + + SKIP_LOOP: --The label used in GOTO + + SELECT @Column_ID = MIN(ORDINAL_POSITION) + FROM INFORMATION_SCHEMA.COLUMNS (NOLOCK) + WHERE TABLE_NAME = @table_name + AND TABLE_SCHEMA = COALESCE(@schema, SCHEMA_NAME()) + AND ORDINAL_POSITION > @Column_ID + + END --Loop ends here! + + +--To get rid of the extra characters that got concatenated during the last run through the loop +IF LEN(@Column_List_For_Update) <> 0 + BEGIN + SET @Column_List_For_Update = ' ' + LEFT(@Column_List_For_Update,len(@Column_List_For_Update) - 4) + END + +IF LEN(@Column_List_For_Check) <> 0 + BEGIN + SET @Column_List_For_Check = LEFT(@Column_List_For_Check,len(@Column_List_For_Check) - 3) + END + +SET @Actual_Values = LEFT(@Actual_Values,len(@Actual_Values) - 6) + +SET @Column_List = LEFT(@Column_List,len(@Column_List) - 1) +IF LEN(LTRIM(@Column_List)) = 0 + BEGIN + RAISERROR('No columns to select. There should at least be one column to generate the output',16,1) + RETURN -1 --Failure. Reason: Looks like all the columns are ommitted using the @cols_to_exclude parameter + END + + +--Get the join columns ---------------------------------------------------------- +DECLARE @PK_column_list VARCHAR(8000) +DECLARE @PK_column_joins VARCHAR(8000) +SET @PK_column_list = '' +SET @PK_column_joins = '' + +SELECT @PK_column_list = @PK_column_list + '[' + c.COLUMN_NAME + '], ' +, @PK_column_joins = @PK_column_joins + 'Target.[' + c.COLUMN_NAME + '] = Source.[' + c.COLUMN_NAME + '] AND ' +FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS pk , +INFORMATION_SCHEMA.KEY_COLUMN_USAGE c +WHERE pk.TABLE_NAME = @table_name +AND pk.TABLE_SCHEMA = COALESCE(@schema, SCHEMA_NAME()) +AND CONSTRAINT_TYPE = 'PRIMARY KEY' +AND c.TABLE_NAME = pk.TABLE_NAME +AND c.TABLE_SCHEMA = pk.TABLE_SCHEMA +AND c.CONSTRAINT_NAME = pk.CONSTRAINT_NAME + +IF IsNull(@PK_column_list, '') = '' + BEGIN + RAISERROR('Table has no primary keys. There should at least be one column in order to have a valid join.',16,1) + RETURN -1 --Failure. Reason: looks like table doesn't have any primary keys + END + +SET @PK_column_list = LEFT(@PK_column_list, LEN(@PK_column_list) -1) +SET @PK_column_joins = LEFT(@PK_column_joins, LEN(@PK_column_joins) -4) + + +--Forming the final string that will be executed, to output the a MERGE statement +SET @Actual_Values = + 'SELECT ' + + CASE WHEN @top IS NULL OR @top < 0 THEN '' ELSE ' TOP ' + LTRIM(STR(@top)) + ' ' END + + '''' + + ' '' + CASE WHEN ROW_NUMBER() OVER (ORDER BY ' + @PK_column_list + ') = 1 THEN '' '' ELSE '','' END + ''(''+ ' + @Actual_Values + '+'')''' + ' ' + + COALESCE(@from,' FROM ' + @Source_Table_Qualified + ' (NOLOCK) ORDER BY ' + @PK_column_list) + + DECLARE @output VARCHAR(MAX) = '' + DECLARE @b CHAR(1) = CHAR(13) + +--Determining whether to ouput any debug information +IF @debug_mode =1 + BEGIN + SET @output += @b + '/*****START OF DEBUG INFORMATION*****' + SET @output += @b + '' + SET @output += @b + 'The primary key column list:' + SET @output += @b + @PK_column_list + SET @output += @b + '' + SET @output += @b + 'The INSERT column list:' + SET @output += @b + @Column_List + SET @output += @b + '' + SET @output += @b + 'The UPDATE column list:' + SET @output += @b + @Column_List_For_Update + SET @output += @b + '' + SET @output += @b + 'The SELECT statement executed to generate the MERGE:' + SET @output += @b + @Actual_Values + SET @output += @b + '' + SET @output += @b + '*****END OF DEBUG INFORMATION*****/' + SET @output += @b + '' + END + +IF (@include_use_db = 1) +BEGIN + SET @output += 'USE ' + DB_NAME() + SET @output += @b + @batch_separator + SET @output += @b + @b +END + +IF (@nologo = 0) +BEGIN + SET @output += @b + '--MERGE generated by ''sp_generate_merge'' stored procedure, Version 0.93' + SET @output += @b + '--Originally by Vyas (http://vyaskn.tripod.com): sp_generate_inserts (build 22)' + SET @output += @b + '--Adapted for SQL Server 2008/2012 by Daniel Nolan (http://danere.com)' + SET @output += @b + '' +END + +IF (@include_rowsaffected = 1) -- If the caller has elected not to include the "rows affected" section, let MERGE output the row count as it is executed. + SET @output += @b + 'SET NOCOUNT ON' + SET @output += @b + '' + + +--Determining whether to print IDENTITY_INSERT or not +IF (LEN(@IDN) <> 0) + BEGIN + SET @output += @b + 'SET IDENTITY_INSERT ' + @Target_Table_For_Output + ' ON' + SET @output += @b + '' + END + + +--Temporarily disable constraints on the target table +IF @disable_constraints = 1 AND (OBJECT_ID(@Source_Table_Qualified, 'U') IS NOT NULL) + BEGIN + SET @output += @b + 'ALTER TABLE ' + @Target_Table_For_Output + ' NOCHECK CONSTRAINT ALL' --Code to disable constraints temporarily + END + + +--Output the start of the MERGE statement, qualifying with the schema name only if the caller explicitly specified it +SET @output += @b + 'MERGE INTO ' + @Target_Table_For_Output + ' AS Target' +SET @output += @b + 'USING (VALUES' + + +--All the hard work pays off here!!! You'll get your MERGE statement, when the next line executes! +DECLARE @tab TABLE (ID INT NOT NULL PRIMARY KEY IDENTITY(1,1), val NVARCHAR(max)); +INSERT INTO @tab (val) +EXEC (@Actual_Values) + +IF (SELECT COUNT(*) FROM @tab) <> 0 -- Ensure that rows were returned, otherwise the MERGE statement will get nullified. +BEGIN + SET @output += CAST((SELECT @b + val FROM @tab ORDER BY ID FOR XML PATH('')) AS XML).value('.', 'VARCHAR(MAX)'); +END + +--Output the columns to correspond with each of the values above-------------------- +SET @output += @b + ') AS Source (' + @Column_List + ')' + + +--Output the join columns ---------------------------------------------------------- +SET @output += @b + 'ON (' + @PK_column_joins + ')' + + +--When matched, perform an UPDATE on any metadata columns only (ie. not on PK)------ +IF LEN(@Column_List_For_Update) <> 0 +BEGIN + SET @output += @b + 'WHEN MATCHED ' + CASE WHEN @update_only_if_changed = 1 THEN 'AND (' + @Column_List_For_Check + ') ' ELSE '' END + 'THEN' + SET @output += @b + ' UPDATE SET' + SET @output += @b + ' ' + LTRIM(@Column_List_For_Update) +END + + +--When NOT matched by target, perform an INSERT------------------------------------ +SET @output += @b + 'WHEN NOT MATCHED BY TARGET THEN'; +SET @output += @b + ' INSERT(' + @Column_List + ')' +SET @output += @b + ' VALUES(' + REPLACE(@Column_List, '[', 'Source.[') + ')' + + +--When NOT matched by source, DELETE the row +IF @delete_if_not_matched=1 BEGIN + SET @output += @b + 'WHEN NOT MATCHED BY SOURCE THEN ' + SET @output += @b + ' DELETE' +END; +SET @output += @b + ';' +SET @output += @b + @batch_separator + +--Display the number of affected rows to the user, or report if an error occurred--- +IF @include_rowsaffected = 1 +BEGIN + SET @output += @b + 'DECLARE @mergeError int' + SET @output += @b + ' , @mergeCount int' + SET @output += @b + 'SELECT @mergeError = @@ERROR, @mergeCount = @@ROWCOUNT' + SET @output += @b + 'IF @mergeError != 0' + SET @output += @b + ' BEGIN' + SET @output += @b + ' PRINT ''ERROR OCCURRED IN MERGE FOR ' + @Target_Table_For_Output + '. Rows affected: '' + CAST(@mergeCount AS VARCHAR(100)); -- SQL should always return zero rows affected'; + SET @output += @b + ' END' + SET @output += @b + 'ELSE' + SET @output += @b + ' BEGIN' + SET @output += @b + ' PRINT ''' + @Target_Table_For_Output + ' rows affected by MERGE: '' + CAST(@mergeCount AS VARCHAR(100));'; + SET @output += @b + ' END' + SET @output += @b + @batch_separator + SET @output += @b + @b +END + +--Re-enable the previously disabled constraints------------------------------------- +IF @disable_constraints = 1 AND (OBJECT_ID(@Source_Table_Qualified, 'U') IS NOT NULL) + BEGIN + SET @output += 'ALTER TABLE ' + @Target_Table_For_Output + ' CHECK CONSTRAINT ALL' --Code to enable the previously disabled constraints + SET @output += @b + @batch_separator + SET @output += @b + END + + +--Switch-off identity inserting------------------------------------------------------ +IF (LEN(@IDN) <> 0) + BEGIN + SET @output += 'SET IDENTITY_INSERT ' + @Target_Table_For_Output + ' OFF' + SET @output += @b + @batch_separator + SET @output += @b + END + +IF (@include_rowsaffected = 1) +BEGIN + SET @output += 'SET NOCOUNT OFF' + SET @output += @b + @batch_separator + SET @output += @b +END + +SET @output += @b + '' +SET @output += @b + '' + +IF @results_to_text = 1 +BEGIN + --output the statement to the Grid/Messages tab + SELECT @output; +END +ELSE +BEGIN + --output the statement as xml (to overcome SSMS 4000/8000 char limitation) + SELECT [processing-instruction(x)]=@output FOR XML PATH(''),TYPE; + PRINT 'MERGE statement has been wrapped in an XML fragment and output successfully.' + PRINT 'Ensure you have Results to Grid enabled and then click the hyperlink to copy the statement within the fragment.' + PRINT '' + PRINT 'If you would prefer to have results output directly (without XML) specify @results_to_text = 1, however please' + PRINT 'note that the results may be truncated by your SQL client to 4000 nchars.' +END + +SET NOCOUNT OFF +RETURN 0 --Success. We are done! +END + +GO + +PRINT 'Created the procedure' +GO + + +--Mark the proc as a system object to allow it to be called transparently from other databases +EXEC sp_MS_marksystemobject sp_generate_merge +GO + +PRINT 'Granting EXECUTE permission on sp_generate_merge to all users' +GRANT EXEC ON sp_generate_merge TO public + +SET NOCOUNT OFF +GO + +PRINT 'Done' diff --git a/Stored_Procedure/sp_IndexAnalysis-v11.sql b/Stored_Procedure/dbo.sp_IndexAnalysis-v11.sql similarity index 100% rename from Stored_Procedure/sp_IndexAnalysis-v11.sql rename to Stored_Procedure/dbo.sp_IndexAnalysis-v11.sql diff --git a/Stored_Procedure/dbo.sp_PerfSQ.sql b/Stored_Procedure/dbo.sp_PerfSQ.sql new file mode 100644 index 00000000..dab242ee --- /dev/null +++ b/Stored_Procedure/dbo.sp_PerfSQ.sql @@ -0,0 +1,529 @@ +IF OBJECT_ID('dbo.sp_PerfSQ', 'P') IS NULL EXECUTE('CREATE PROCEDURE dbo.sp_PerfSQ AS SELECT 1'); +GO + +ALTER PROCEDURE dbo.sp_PerfSQ( + @ParamSniff float = NULL + , @SessionLocks bit = NULL +) +AS +/* +----------------------------------------------------------------------------------------- +https://www.sqlservercentral.com/articles/query-performance-diagnostics-with-sp_perfsq +-- sp_PerfSQ: Query Shaping tool identifying Performance features of active SQL Queries +-- Copyright (C) 2018, 2019 Edward Haynes +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU Lesser General Public License as published +-- by the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public License +-- along with this program. If not, see . +-- +-- +-- Stored procedure designed to work with SQL Server 2008 R2 and higher +-- providing on-demand performance detail from DMVs for queries with executing requests +-- +-- Optional Parameters: +-- @ParamSniff = Parameter Sniffing sensitivity multiplier +-- < 1.0 (more hits); 1 or NULL (DEFAULT); > 1.0 (less hits) +-- Must be within the range of 0 to 2.0 otherwise will default to 1.0 +-- +-- @SessionLocks = 0 or NULL -- No locking detail (DEFAULT) +-- = 1 -- Detailed locking (performance overhead) +-- +-- Example Usage: +-- EXEC dbo.sp_PerfSQ +-- GO +-- +-- EXEC dbo.sp_PerfSQ @ParamSniff=0.75, @SessionLocks=1 +-- GO +-- +-- Email: QueryShape@gmail.com +-- +*/ +BEGIN +SET NOCOUNT ON; + +DECLARE @Version nvarchar(20); +SET @Version = N'4.5.17'; + +DECLARE @tmpSchedulers TABLE (RunnableCountAvg int NULL, PendingIOCountAvg int NULL, ThreadShortageAvg int NULL, CPUAllocation nvarchar(50) NULL); + +DECLARE @ProcessMemLow int, + @SystemMemLow int, + @MaxServerMemory int, + @PhysicalMemory bigint, + @PhysicalMemInUse bigint, + @KernelNonPaged bigint, + @RunnableCountAvg int, + @PendingIOCountAvg int, + @ThreadShortageAvg int, + @CPUAllocation nvarchar(50), + @VerCleanupRatio float, + @Runtime datetime, + @CmdLine nvarchar(100), + @SQLVersion nvarchar(500) ; + +SET @ParamSniff = (CASE WHEN @ParamSniff < CONVERT(float,0.0) OR @ParamSniff > CONVERT(float,2.0) THEN CONVERT(float,1.0) ELSE ISNULL(@ParamSniff,CONVERT(float,1.0)) END); +SET @SessionLocks = ISNULL(@SessionLocks,CONVERT(bit,0)) ; +SET @CmdLine = N'EXEC sp_PerfSQ ' + N'@ParamSniff=' + CONVERT(nvarchar(20),@ParamSniff) + N', @SessionLocks=' + CONVERT(nvarchar(1),@SessionLocks) + N' --v' + @Version; +SET @Runtime = GETDATE(); + +SET @SQLVersion = CONVERT(nvarchar(500),@@Version); +SET @SQLVersion = LEFT(@SQLVersion,CHARINDEX(N'COPY',UPPER(@SQLVersion)) - 1); + +SET @ProcessMemLow = + (SELECT COUNT(1) + FROM sys.dm_os_process_memory WITH (NOLOCK) + WHERE process_physical_memory_low = CONVERT(bit,1)) ; + +SET @SystemMemLow = + (SELECT COUNT(1) + FROM sys.dm_os_sys_memory WITH (NOLOCK) + WHERE system_high_memory_signal_state = CONVERT(bit,0) + AND system_low_memory_signal_state = CONVERT(bit,1)) ; + +SET @MaxServerMemory = + (SELECT top 1 CONVERT(int,value_in_use) + FROM sys.configurations WITH (NOLOCK) + WHERE [name] = 'max server memory (MB)') ; + +SET @PhysicalMemory = + (SELECT top 1 total_physical_memory_kb / 1024 + FROM sys.dm_os_sys_memory WITH (NOLOCK)) ; + +SET @PhysicalMemInUse = + (SELECT top 1 physical_memory_in_use_kb / 1024 + FROM sys.dm_os_process_memory WITH (NOLOCK)) ; + +SET @KernelNonPaged = + (SELECT top 1 kernel_nonpaged_pool_kb / 1024 + FROM sys.dm_os_sys_memory WITH (NOLOCK)) ; + +INSERT INTO @tmpSchedulers (RunnableCountAvg, PendingIOCountAvg, ThreadShortageAvg, CPUAllocation) +SELECT AVG(os.runnable_tasks_count) as RunnableCountAvg, + AVG(os.pending_disk_io_count) as PendingIOCountAvg, + AVG(os.work_queue_count) as ThreadShortageAvg, + CONVERT(nvarchar(20),COUNT(1)) + N' of ' + CONVERT(nvarchar(20),SUM(CONVERT(int,os.is_online))) + as CPUAllocation + FROM sys.dm_os_schedulers os WITH (NOLOCK) + WHERE os.scheduler_id < 1048576 ; + +SET @RunnableCountAvg = + (SELECT top 1 RunnableCountAvg + FROM @tmpSchedulers) ; + +SET @PendingIOCountAvg = + (SELECT top 1 PendingIOCountAvg + FROM @tmpSchedulers) ; + +SET @ThreadShortageAvg = + (SELECT top 1 ThreadShortageAvg + FROM @tmpSchedulers) ; + +SET @CPUAllocation = + (SELECT top 1 CPUAllocation + FROM @tmpSchedulers) ; + +SET @VerCleanupRatio = + (SELECT top 1 CONVERT(float,(cntr_value/1024.0) * 100.0) + FROM sys.dm_os_performance_counters WITH (NOLOCK) + WHERE counter_name = N'Version Cleanup rate (KB/s)' + AND 0 < CHARINDEX(N'Transactions',[object_name])) / (SELECT top 1 CONVERT(float,cntr_value/1024.0) + FROM sys.dm_os_performance_counters WITH (NOLOCK) + WHERE counter_name = N'Version Generation rate (KB/s)' + AND 0 < CONVERT(float,cntr_value/1024.0) + AND 0 < CHARINDEX(N'Transactions',[object_name])) ; + +PRINT @CmdLine ; +PRINT N'' +PRINT @SQLVersion +PRINT N'Memory' +PRINT N' Total Physical Memory : ' + CONVERT(nvarchar(20),@PhysicalMemory) + N' MB' +PRINT N' Max SQL Server Memory : ' + CONVERT(nvarchar(20),@MaxServerMemory) + N' MB' +PRINT N' Physical Memory In Use: ' + CONVERT(nvarchar(20),@PhysicalMemInUse) + N' MB' + (CASE WHEN (@ProcessMemLow + @SystemMemLow) > 0 THEN N' (memory pressure)' ELSE N'' END) +PRINT N' Kernel Non-Paged Pool : ' + CONVERT(nvarchar(20),@KernelNonPaged) + N' MB' +PRINT N'Schedulers' +PRINT N' Avg CPU Queue Length : ' + CONVERT(nvarchar(20),@RunnableCountAvg) +PRINT N' Avg IO Pending Count : ' + CONVERT(nvarchar(20),@PendingIOCountAvg) +PRINT N' Avg Thread Shortage : ' + CONVERT(nvarchar(20),@ThreadShortageAvg) +PRINT N' CPU Allocation : ' + @CPUAllocation +PRINT N'Version Store' +PRINT N' Version Cleanup Ratio : ' + ISNULL(CONVERT(nvarchar(20),CONVERT(numeric(16,2),@VerCleanupRatio)) + N'%',N'NA') +PRINT N'' + +;WITH XMLNAMESPACES(DEFAULT N'http://schemas.microsoft.com/sqlserver/2004/07/showplan'), + cteQRequests (SPID,DatabaseName,[Status],RuntimeSec,BlockedBy,DatabaseMaint,EstFinishTime,MemRequestMB,MemGrantMB,MemGrantWait,DOP,query_cost,PAGEIOLATCHms,PAGELATCHms,RunnableCount,SpinLoopFlag,ThreadShortageFlag,ProgramName,OriginalLogin,sql_handle,statement_start_offset,statement_end_offset,plan_handle) + AS (SELECT r.session_id as SPID, + DB_NAME(s.database_id) as DatabaseName, + (CASE UPPER(r.[status]) + WHEN N'BACKGROUND' THEN CONVERT(int,1) + WHEN N'RUNNING' THEN CONVERT(int,2) + WHEN N'RUNNABLE' THEN CONVERT(int,3) + WHEN N'SLEEPING' THEN CONVERT(int,4) + WHEN N'SUSPENDED' THEN CONVERT(int,5) + ELSE CONVERT(int,NULL) + END) as [Status], + CONVERT(int,r.total_elapsed_time / 1000) + as RuntimeSec, + (CASE WHEN r.blocking_session_id = 0 THEN CONVERT(smallint,NULL) ELSE r.blocking_session_id END) + as BlockedBy, + r.command as DatabaseMaint, + r.estimated_completion_time as EstFinishTime, + CONVERT(float,m.requested_memory_kb / 1024.0) + as MemRequestMB, + CONVERT(float,m.granted_memory_kb / 1024.0) + as MemGrantMB, + (CASE WHEN m.session_id = r.session_id AND m.request_id = r.request_id AND m.grant_time IS NULL THEN CONVERT(int,1) ELSE CONVERT(int,0) END) + as MemGrantWait, + m.dop as DOP, + m.query_cost as query_cost, + (CASE WHEN r.wait_type LIKE N'PAGEIOLATCH_%' THEN r.wait_time ELSE CONVERT(int,NULL) END) + as PAGEIOLATCHms, + (CASE WHEN r.wait_type LIKE N'PAGELATCH_%' THEN r.wait_time ELSE CONVERT(int,NULL) END) + as PAGELATCHms, + st.RunnableCount as RunnableCount, + st.SpinLoopFlag as SpinLoopFlag, + st.ThreadShortageFlag as ThreadShortageFlag, + s.[program_name] as ProgramName, + s.original_login_name as OriginalLogin, + r.sql_handle, + r.statement_start_offset, + r.statement_end_offset, + r.plan_handle + FROM sys.dm_exec_requests r + LEFT JOIN sys.dm_exec_sessions s WITH (NOLOCK) + ON s.session_id = r.session_id + LEFT JOIN sys.dm_exec_query_memory_grants m WITH (NOLOCK) + ON m.session_id = r.session_id + AND m.request_id = r.request_id + LEFT JOIN (SELECT ot.session_id, + MAX((CASE WHEN ot.task_state = N'RUNNABLE' + THEN os.runnable_tasks_count + ELSE CONVERT(int,0) + END)) as RunnableCount, + MAX((CASE WHEN ot.task_state = N'SPINLOOP' + THEN CONVERT(int,1) + ELSE CONVERT(int,0) + END)) as SpinLoopFlag, + MAX((CASE WHEN ot.task_state = N'PENDING' + THEN CONVERT(int,1) + ELSE CONVERT(int,0) + END)) as ThreadShortageFlag + FROM sys.dm_os_schedulers os WITH (NOLOCK) + INNER JOIN sys.dm_os_tasks ot WITH (NOLOCK) + ON ot.scheduler_id = os.scheduler_id + AND ot.task_state IN (N'RUNNABLE',N'SPINLOOP',N'PENDING') + AND ot.scheduler_id < 1048576 + GROUP BY ot.session_id) st + ON st.session_id = r.session_id + WHERE r.database_id <> 32767 + AND r.session_id > 0 + AND r.session_id <> @@SPID + AND r.sql_handle = (SELECT top 1 r2.sql_handle + FROM sys.dm_exec_requests r2 WITH (NOLOCK) + WHERE r2.session_id = r.session_id + ORDER BY r2.start_time DESC) + AND r.statement_start_offset = (SELECT top 1 r3.statement_start_offset + FROM sys.dm_exec_requests r3 WITH (NOLOCK) + WHERE r3.session_id = r.session_id + AND r3.sql_handle = r.sql_handle + ORDER BY r3.start_time DESC) + ), + cteSLocks (SPID,SessionLocks) + AS (SELECT qr.SPID, + CONVERT(nvarchar(max),ISNULL( + STUFF((SELECT N',' + ISNULL(CONVERT(nvarchar(200),tl.request_mode + N' (' + tl.request_status + N':' + tl.resource_type + + (CASE tl.resource_type + WHEN N'DATABASE' THEN N':' + ISNULL(DB_NAME(tl.resource_database_id),N'') + WHEN N'OBJECT' THEN N':' + ISNULL(OBJECT_NAME(tl.resource_associated_entity_id,tl.resource_database_id),N'') + ISNULL(N'[' + CONVERT(nvarchar(10),i.UnusedIndexCount) + N']',N'') + ELSE N'' + END) + N')') + N'x' + CONVERT(nvarchar(10),COUNT(1)),N'') + FROM sys.dm_tran_locks tl WITH (NOLOCK) + OUTER APPLY (SELECT ius.database_id, + ius.[object_id], + COUNT(1) as UnusedIndexCount + FROM sys.dm_db_index_usage_stats ius WITH (NOLOCK) + WHERE ius.database_id = tl.resource_database_id + AND ius.[object_id] = tl.resource_associated_entity_id + AND ius.user_updates > (ius.user_seeks + ius.user_lookups + ius.user_scans) + AND tl.resource_type = N'OBJECT' + GROUP BY ius.database_id, + ius.[object_id]) i + WHERE tl.request_session_id = qr.SPID + AND N'NULL' <> ISNULL(tl.request_mode,N'NULL') + GROUP BY CONVERT(nvarchar(200),tl.request_mode + N' (' + tl.request_status + N':' + tl.resource_type + + (CASE tl.resource_type + WHEN N'DATABASE' THEN N':' + ISNULL(DB_NAME(tl.resource_database_id),N'') + WHEN N'OBJECT' THEN N':' + ISNULL(OBJECT_NAME(tl.resource_associated_entity_id,tl.resource_database_id),N'') + ISNULL(N'[' + CONVERT(nvarchar(10),i.UnusedIndexCount) + N']',N'') + ELSE N'' + END) + N')') + FOR XML PATH('')),1,1,N''),N'')) + as SessionLocks + FROM (SELECT SPID FROM cteQRequests WHERE @SessionLocks = CONVERT(bit,1) GROUP BY SPID) qr + ), + cteTempdb (SPID,TempdbWaitms,CursorOpen,CursorDormantms,TempdbDeallocMB,TempdbAllocMB,VerActive,VerDuration) + AS (SELECT qr.SPID, + (SELECT MAX(wt.wait_duration_ms) + FROM sys.dm_os_waiting_tasks wt WITH (NOLOCK) + WHERE wt.session_id = qr.SPID + AND wt.wait_type LIKE 'PAGE%LATCH_%' + AND wt.resource_description LIKE CONVERT(nvarchar(10),DB_ID(N'tempdb')) + N':%') + as TempdbWaitms, + (SELECT COUNT(1) + FROM sys.dm_exec_cursors (qr.SPID) + WHERE is_open = CONVERT(bit,1)) + as CursorOpen, + (SELECT MAX(dormant_duration) + FROM sys.dm_exec_cursors (qr.SPID) + WHERE is_open = CONVERT(bit,1)) + as CursorDormantms, + (SELECT CONVERT(float,SUM(tsu.internal_objects_dealloc_page_count + tsu.user_objects_dealloc_page_count) / 128.0) + FROM tempdb.sys.dm_db_task_space_usage tsu WITH (NOLOCK) + WHERE tsu.session_id = qr.SPID) + as TempdbDeallocMB, + (SELECT CONVERT(float,SUM(tsu.internal_objects_alloc_page_count + tsu.user_objects_alloc_page_count) / 128.0) + FROM tempdb.sys.dm_db_task_space_usage tsu WITH (NOLOCK) + WHERE tsu.session_id = qr.SPID) + as TempdbAllocMB, + (SELECT COUNT(1) + FROM sys.dm_tran_active_snapshot_database_transactions v WITH (NOLOCK) + WHERE v.session_id = qr.SPID + AND v.commit_sequence_num IS NULL) + as VerActive, + (SELECT MAX(v.elapsed_time_seconds) + FROM sys.dm_tran_active_snapshot_database_transactions v WITH (NOLOCK) + WHERE v.session_id = qr.SPID + AND v.commit_sequence_num IS NULL) + as VerDuration + FROM cteQRequests qr + GROUP BY qr.SPID + ), + cteQPlan (plan_handle,PlanType,ObjectName,ParameterList,Cardinality,[AvgMissingIndex%],SortRows,TableScanRows,MissingJoin) + AS (SELECT qr.plan_handle, + (SELECT top 1 RTRIM(cp.objtype) + FROM sys.dm_exec_cached_plans cp WITH (NOLOCK) + WHERE cp.plan_handle = qr.plan_handle) + as PlanType, + CONVERT(nvarchar(129),ISNULL(N':' + OBJECT_NAME(qp.objectid,qp.dbid),N'')) + as ObjectName, + CONVERT(nvarchar(max), + STUFF((SELECT N',' + l.value('@Column', 'nvarchar(128)') + N'=' + l.value('@ParameterCompiledValue', 'nvarchar(4000)') + FROM qp.query_plan.nodes('//ParameterList/ColumnReference') AS prm(l) + FOR XML PATH('')),1,1,N'')) + as ParameterList, + (SELECT CONVERT(float,MAX(s.value('@StatementEstRows', 'float'))) + FROM qp.query_plan.nodes('//StmtSimple') stmt(s)) + as Cardinality, + (SELECT CONVERT(float,AVG(i.value('@Impact', 'float'))) + FROM qp.query_plan.nodes('.//MissingIndexGroup') midx(i)) + as [AvgMissingIndex%], + (SELECT CONVERT(float,SUM(op.value('@EstimateRows', 'float'))) + FROM qp.query_plan.nodes('//RelOp') rel(op) + WHERE N'Sort' = op.value('@PhysicalOp','nvarchar(60)')) + as SortRows, + (SELECT CONVERT(float,SUM(op.value('@EstimateRows', 'float'))) + FROM qp.query_plan.nodes('//RelOp') rel(op) + WHERE N'Table Scan' = op.value('@PhysicalOp','nvarchar(60)')) + as TableScanRows, + (SELECT COUNT(1) + FROM qp.query_plan.nodes('//Warnings[(@NoJoinPredicate[.="1"])]') nojoin(p)) + as MissingJoin + FROM (SELECT plan_handle FROM cteQRequests WHERE plan_handle IS NOT NULL GROUP BY plan_handle) qr + CROSS APPLY sys.dm_exec_query_plan(qr.plan_handle) qp + ), + cteQStats (sql_handle,plan_handle,RunCount,MinTimeSec,MaxTimeSec,MinRows,MaxRows,AvgCpuLowms,CpuHighms,AvgLogicalReadsMB,[PhyReads%]) + AS (SELECT qr.sql_handle, + qr.plan_handle, + MAX(qs.execution_count) as RunCount, + CONVERT(bigint,(MIN(qs.min_elapsed_time) / 1000) / 1000) + as MinTimeSec, + CONVERT(bigint,(MAX(qs.max_elapsed_time) / 1000) / 1000) + as MaxTimeSec, + MIN(qs.min_rows) as MinRows, + MAX(qs.max_rows) as MaxRows, + CONVERT(bigint,AVG(qs.min_worker_time) / 1000) + as AvgCpuLowms, + CONVERT(bigint,MAX(qs.max_worker_time) / 1000) + as CpuHighms, + CONVERT(float,(MAX(qs.total_logical_reads) / MAX(qs.execution_count)) / 128.0) + as AvgLogicalReadsMB, + (CASE WHEN MAX(qs.total_logical_reads) >= CONVERT(bigint,1) + THEN CONVERT(float,MAX(qs.total_physical_reads) * 100.0) / CONVERT(float,MAX(qs.total_logical_reads)) + ELSE CONVERT(float,0.0) + END) as [PhyReads%] + FROM (SELECT sql_handle, plan_handle FROM cteQRequests GROUP BY sql_handle, plan_handle) qr + LEFT JOIN sys.dm_exec_query_stats qs WITH (NOLOCK) + ON qs.sql_handle = qr.sql_handle + AND qs.plan_handle = qr.plan_handle + GROUP BY qr.sql_handle, + qr.plan_handle + ) +SELECT qr.SPID, + MAX(qr.DatabaseName) as DatabaseName, + (CASE MIN(qr.[Status]) + WHEN 1 THEN CONVERT(nvarchar(10),N'Background') + WHEN 2 THEN CONVERT(nvarchar(10),N'Running') + WHEN 3 THEN CONVERT(nvarchar(10),N'Runnable') + WHEN 4 THEN CONVERT(nvarchar(10),N'Sleeping') + WHEN 5 THEN CONVERT(nvarchar(10),N'Suspended') + ELSE CONVERT(nvarchar(10),NULL) + END) as [Status], + (CASE WHEN UPPER(MAX(qp.PlanType)) = N'PROC' + THEN CONVERT(nvarchar(133),N'Proc' + MAX(qp.ObjectName)) + ELSE CONVERT(nvarchar(133),MAX(qp.PlanType)) + END) as PlanType, + (CASE WHEN MAX(qr.query_cost) < 10 THEN CONVERT(nvarchar(10),N'Low') + WHEN MAX(qr.query_cost) < 100 THEN CONVERT(nvarchar(10),N'Medium') + WHEN MAX(qr.query_cost) < 1000 THEN CONVERT(nvarchar(10),N'Med-High') + WHEN MAX(qr.query_cost) < 10000 THEN CONVERT(nvarchar(10),N'High') + WHEN MAX(qr.query_cost) >= 10000 THEN CONVERT(nvarchar(10),N'VHigh') + ELSE CONVERT(nvarchar(10),NULL) + END) as QueryCost, + CONVERT(nvarchar(200),REPLACE(REPLACE(RTRIM( + (CASE WHEN MIN(qr.[Status]) <> 2 AND MAX(qr.RunnableCount) > 2 AND @RunnableCountAvg > 1 + THEN CONVERT(nvarchar(8),N'CPUWait ') + ELSE N'' END + + CASE WHEN MAX(t.CursorOpen) > 0 AND MAX(t.CursorDormantms) >= 1 + THEN CONVERT(nvarchar(27),N'Cursor(' + CONVERT(nvarchar(16),MAX(t.CursorDormantms)) + N'ms) ') + ELSE N'' END + + CASE WHEN MAX(qr.EstFinishTime) >= 1 + THEN CONVERT(nvarchar(41),REPLACE(MAX(qr.DatabaseMaint),N' ',N'~')) + N'(' + + (CASE WHEN (MAX(qr.EstFinishTime) / 60000) > 600 + THEN N'>10hr) ' + ELSE CONVERT(nvarchar(3),MAX(qr.EstFinishTime) / 60000) + N'min) ' + END) + ELSE N'' END + + CASE WHEN MAX(qr.query_cost) >= 10 AND MAX(qp.[AvgMissingIndex%]) > 20 + THEN CONVERT(nvarchar(7),N'IdxGap ') + ELSE N'' END + + CASE WHEN CHARINDEX(N'[',MAX(sl.SessionLocks)) > 0 + THEN CONVERT(nvarchar(8),N'IdxIdle ') + ELSE N'' END + + CASE WHEN SUM(qr.MemGrantMB) > CONVERT(float,SUM(qr.MemRequestMB) + 0.00001) + THEN CONVERT(nvarchar(32),N'InitialMem(') + CONVERT(nvarchar(17),CONVERT(numeric(16,2),SUM(qr.MemRequestMB))) + N'MB) ' + ELSE N'' END + + CASE WHEN MAX([PhyReads%]) > CONVERT(float,20.0) + OR (MAX(qr.query_cost) >= 10 AND @PendingIOCountAvg > 1 AND (MAX([PhyReads%]) > CONVERT(float,5.0) OR MAX(qr.PAGEIOLATCHms) > 50)) + THEN (CASE WHEN (@ProcessMemLow + @SystemMemLow) > 0 + THEN CONVERT(nvarchar(9),N'IO(MemP) ') + ELSE CONVERT(nvarchar(9),N'IO ') + END) + ELSE N'' END + + CASE WHEN 0 < CHARINDEX(N'(WAIT',MAX(sl.SessionLocks)) + THEN CONVERT(nvarchar(9),N'LockWait ') + ELSE N'' END + + CASE WHEN MAX(qr.MemGrantWait) = 1 + THEN CONVERT(nvarchar(8),N'MemWait ') + ELSE N'' END + + CASE WHEN MAX(qp.MissingJoin) > 0 + THEN CONVERT(nvarchar(9),N'MissJoin ') + ELSE N'' END + + CASE WHEN MAX(qr.PAGELATCHms) >= 1 + THEN CONVERT(nvarchar(23),N'PageWait(' + CONVERT(nvarchar(10),MAX(qr.PAGELATCHms)) + N'ms) ') + ELSE N'' END + + CASE WHEN MAX(qp.ParameterList) <> N'' AND UPPER(MAX(qp.PlanType)) IN (N'PROC',N'ADHOC') AND MAX(qs.RunCount) > 1 + AND ( CONVERT(float,MAX(qs.MaxRows) / 10.0) > CONVERT(float,((MAX(qs.MinRows) / 10.0) * (4.0 * @ParamSniff)) + POWER(CONVERT(float,10.0),@ParamSniff)) + OR (MAX([PhyReads%]) > CONVERT(float,20.0) + OR (MAX(qr.query_cost) >= 10 AND @PendingIOCountAvg > 1 AND (MAX([PhyReads%]) > CONVERT(float,5.0) OR MAX(qr.PAGEIOLATCHms) > 50))) + OR ((MAX(t.TempdbAllocMB) - MAX(t.TempdbDeallocMB)) + > (CASE WHEN CONVERT(int,(SUM(qr.MemGrantMB) / 10) * ((100 - ISNULL(MAX(qp.[AvgMissingIndex%]),0)) / 100)) > 49 + THEN CONVERT(int,50) + ELSE 1 + CONVERT(int,(SUM(qr.MemGrantMB) / 10) * ((100 - ISNULL(MAX(qp.[AvgMissingIndex%]),0)) / 100)) + END))) + AND CONVERT(float,MAX(qs.CpuHighms) / 10.0) > CONVERT(float,((MAX(qs.AvgCpuLowms) / 10.0) * (4.0 * @ParamSniff)) + POWER(CONVERT(float,10.0),@ParamSniff)) + AND ((CASE WHEN MAX(qr.RuntimeSec) > MAX(qs.MaxTimeSec) THEN MAX(qr.RuntimeSec) ELSE MAX(qs.MaxTimeSec) END) - MAX(qs.MinTimeSec)) + > ((MAX(qs.MinTimeSec) / 10) + POWER(CONVERT(bigint,10),@ParamSniff)) + THEN CONVERT(nvarchar(37),N'ParamSniff(') + CONVERT(nvarchar(10),MAX(qs.MinTimeSec)) + N'-' + + CONVERT(nvarchar(10),(CASE WHEN MAX(qr.RuntimeSec) > MAX(qs.MaxTimeSec) THEN MAX(qr.RuntimeSec) ELSE MAX(qs.MaxTimeSec) END)) + N'Sec) ' + ELSE N'' END + + CASE WHEN MAX(qr.SpinLoopFlag) = 1 + THEN CONVERT(nvarchar(9),N'SpinLoop ') + ELSE N'' END + + CASE WHEN (MAX(t.TempdbAllocMB) - MAX(t.TempdbDeallocMB)) + > (CASE WHEN CONVERT(int,(SUM(qr.MemGrantMB) / 10) * ((100 - ISNULL(MAX(qp.[AvgMissingIndex%]),0)) / 100)) > 49 + THEN CONVERT(int,50) + ELSE 1 + CONVERT(int,(SUM(qr.MemGrantMB) / 10) * ((100 - ISNULL(MAX(qp.[AvgMissingIndex%]),0)) / 100)) + END) + THEN CONVERT(nvarchar(27),N'Tempdb') + + (CASE WHEN MAX(t.TempdbWaitms) >= 1 THEN N'(' + CONVERT(nvarchar(16),MAX(t.TempdbWaitms)) + N'ms) ' ELSE N' ' END) + ELSE N'' END + + CASE WHEN MAX(qr.ThreadShortageFlag) = 1 AND @ThreadShortageAvg > 0 + THEN CONVERT(nvarchar(15),N'ThreadShortage ') + ELSE N'' END + + CASE WHEN @VerCleanupRatio < CONVERT(float,80.0) AND MAX(t.VerDuration) >= 1 + THEN CONVERT(nvarchar(25),N'Ver(') + CONVERT(nvarchar(16),MAX(t.VerDuration)) + N'sec) ' + ELSE N'' END + )),N' ',N','),N'~',N' ')) as ThrottlePotential, + MAX(qr.RuntimeSec) as RuntimeSec, + CONVERT(nvarchar(50), + STUFF((SELECT N',' + CONVERT(nvarchar(50),qr2.BlockedBy) + FROM cteQRequests qr2 + WHERE qr2.SPID = qr.SPID + AND qr2.BlockedBy IS NOT NULL + GROUP BY CONVERT(nvarchar(50),qr2.BlockedBy) + FOR XML PATH('')),1,1,N'')) + as BlockedBy, + (SELECT CONVERT(nvarchar(max), + SUBSTRING(qt.text+' ',(MAX(qr.statement_start_offset) / 2) + 1, + ((CASE WHEN MAX(qr.statement_end_offset) = -1 + THEN DATALENGTH(qt.text) + ELSE MAX(qr.statement_end_offset) + END - MAX(qr.statement_start_offset)) / 2) + 1)) + FROM sys.dm_exec_sql_text(qr.sql_handle) qt) + as Query, + MAX(qr.MemGrantMB) as MemGrantMB, + MAX(qs.RunCount) as RunCount, + MAX(qs.MinRows) as MinRows, + MAX(qs.MaxRows) as MaxRows, + MAX(qs.AvgCpuLowms) as AvgCpuLowms, + MAX(qs.CpuHighms) as CpuHighms, + MAX(qr.DOP) as DOP, + MAX(qs.AvgLogicalReadsMB) as AvgLogicalReadsMB, + (CASE WHEN MAX(qs.RunCount) IS NOT NULL THEN MAX(qs.[PhyReads%]) ELSE CONVERT(float,NULL) END) + as [PhyReads%], + MAX(qr.PAGEIOLATCHms) as PAGEIOLATCHms, + MAX(sl.SessionLocks) as SessionLocks, + MAX(t.VerActive) as VerActive, + MAX(t.TempdbAllocMB) as TempdbAllocMB, + MAX(t.TempdbDeallocMB) as TempdbDeallocMB, + MAX(qp.Cardinality) as Cardinality, + MAX(qp.[AvgMissingIndex%]) as [AvgMissingIndex%], + MAX(qp.SortRows) as SortRows, + MAX(qp.TableScanRows) as TableScanRows, + MAX(qp.ParameterList) as CachedParam, + (SELECT top 1 query_plan FROM sys.dm_exec_query_plan(qr.plan_handle)) + as CachedPlan, + MAX(qr.ProgramName) as ProgramName, + MAX(qr.OriginalLogin) as OriginalLogin, + @Runtime as LogDateTime + FROM cteQRequests qr + LEFT JOIN cteQPlan qp + ON qp.plan_handle = qr.plan_handle + LEFT JOIN cteQStats qs + ON qs.sql_handle = qr.sql_handle + AND qs.plan_handle = qr.plan_handle + LEFT JOIN cteSLocks sl + ON sl.SPID = qr.SPID + LEFT JOIN cteTempdb t + ON t.SPID = qr.SPID + GROUP BY qr.SPID, + qr.sql_handle, + qr.plan_handle +HAVING (SELECT CONVERT(nvarchar(max), + SUBSTRING(qt.text+' ',(MAX(qr.statement_start_offset) / 2) + 1, + ((CASE WHEN MAX(qr.statement_end_offset) = -1 + THEN DATALENGTH(qt.text) + ELSE MAX(qr.statement_end_offset) + END - MAX(qr.statement_start_offset)) / 2) + 1)) + FROM sys.dm_exec_sql_text(qr.sql_handle) qt) IS NOT NULL + ORDER BY qr.SPID +END; + +GO \ No newline at end of file diff --git a/Stored_Procedure/dbo.sp_PrintString.sql b/Stored_Procedure/dbo.sp_PrintString.sql new file mode 100644 index 00000000..6633031c --- /dev/null +++ b/Stored_Procedure/dbo.sp_PrintString.sql @@ -0,0 +1,70 @@ +IF OBJECT_ID('dbo.sp_PrintString', 'P') IS NULL + EXEC ('CREATE PROCEDURE dbo.sp_PrintString AS SELECT 1'); +GO + +ALTER PROCEDURE dbo.sp_PrintString ( + @str NVARCHAR(MAX) +) +AS +BEGIN + DECLARE @line NVARCHAR(MAX), + @startLocation INT = 1, + @length INT = 0, + @totalLength INT = DATALENGTH(@str), + @current INT = 1; + + DECLARE @PrintLine NVARCHAR(MAX) = + N' + DECLARE @pos INT = 1 + WHILE @pos <= LEN(@line) + BEGIN + PRINT SUBSTRING(@line, @pos, 4000); + SET @pos = @pos + 4000; + END;'; + + WHILE @current <= @totalLength + BEGIN + IF SUBSTRING(@str, @current, 2) IN ( + CHAR(0x0D) + CHAR(0x0A), + CHAR(0x0A) + CHAR(0x0D) + ) + BEGIN + IF @length <= 0 + PRINT ''; + ELSE + BEGIN + SELECT @line = SUBSTRING(@str, @startLocation, @length); + EXEC sp_executesql @PrintLine, N'@line NVARCHAR(MAX)', @line; + END + + SELECT @startLocation = @current + 2, + @current = @current + 2, + @length = 0; + + CONTINUE; + END + ELSE IF SUBSTRING(@str, @current, 1) IN (CHAR(0x0D), CHAR(0x0A)) + BEGIN + IF @length <= 0 + PRINT ''; + ELSE + BEGIN + SELECT @line = SUBSTRING(@str, @startLocation, @length); + EXEC sp_executesql @PrintLine, N'@line NVARCHAR(MAX)', @line; + END + + SELECT @startLocation = @current + 1, + @current = @current + 1, + @length = 0; + + CONTINUE; + END + + SELECT @current = @current + 1, + @length = @length + 1; + END + + IF @startLocation <= DATALENGTH(@str) + PRINT SUBSTRING(@str, @startLocation, DATALENGTH(@str)); +END; +GO diff --git a/Stored_Procedure/dbo.sp_RestoreGene.sql b/Stored_Procedure/dbo.sp_RestoreGene.sql new file mode 100644 index 00000000..f9a3051e --- /dev/null +++ b/Stored_Procedure/dbo.sp_RestoreGene.sql @@ -0,0 +1,1732 @@ +USE [master] +GO +IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_RestoreGene') +EXEC ('CREATE PROC dbo.sp_RestoreGene AS SELECT ''stub version, to be replaced''') +GO + +/********************************************************************************************* +Restore Generator v8.3 (2022-04-11) +(C) 2012, Paul Brewer + +Feedback: paulbrewer@yahoo.co.uk +User Guide: https://restoregene.com + +This procedure queries msdb database backup history and database file details in master. +It builds and returns RESTORE DATABASE commands as its result set, it does not execute the commands. + +---------------------------------------------------------------------------------------------- +PARAMETERS: + +@Database - Default NULL, Restore a specific database or a list of comma seperated database names, NULL which restores all user databases. +@TargetDatabase - Defaults to NULL, override restored database name, only possible if restoring one specific database, if supplied will rename database files and log file too. +@WithMoveDataFiles - Defaults to the actual data file paths, overrides WITH MOVE for data file folder +@WithMoveLogFile - Defaults to the actual log file path, overrides WITH MOVE for log file folder +@WithMoveFileStreamFile - Defaults to the actual file stream file path, overrides WITH MOVE for file stream file folder +@FromFileFullUNC - Defaults to actual backup file drive and folder, UNC path to full backup file +@FromFileDiffUNC - Defaults to actual drive and folder, UNC path to differential backup file +@FromFileLogUNC - Defaults to actual drive and folder, UNC path to log backup files +@StopAt - Defaults to current (datetime2), Stop At a specific date time +@StandbyMode - Defaults to 0, Leave database in standby mode +@IncludeSystemDBs - Defaults to 0, include master, model and msdb database restores +@WithRecovery - Defaults to 0, Recover database(s) after restore +@WithCHECKDB - Defaults to 0, Include a CHECKDB after recovery +@WithReplace - Defaults to 0, replace existing database when no tail log backup exists +@LogShippingStartTime - Only used by ps_RestoreGene +@LogShippingLastLSN - Only used by ps_RestoreGene +@BlobCredential - Defaults to NULL, SQL Credential for Azure Blog Storage Account +@RestoreScriptReplaceThis - Defaults to NULL, Restore Script String Find +@RestoreScriptWithThis - Defaults to NULL, Restore Script String Replace +@SuppressWithMove - Default 1, Exclude WITH MOVE statements from the Restore Script +@PivotWithMove - Default 0, If SuppressWithMove = 0, pivot secondary files to new rows in the result set +@RestoreScriptOnly - Default 0, Return just the RESTORE DATABASE commands +@DropDatabaseAfterRestore - Default 0, Drops the database after the restore, use with check db +@SetSingleUser - Default 0, Adds ALTER DATABASE @database SET SINGLE_USER WITH ROLLBACK IMMEDIATE +@ExcludeDiffAndLogBackups - Default 0, 0=full+diff+ log, 1=full only, 2-full+diff, 3=full+log, 4=diff+log +@IncludeDeviceType7 - Defaults to 1, Include device type 7 backups in restore script +@IncludeDeviceType102 - Defaults to 1, Include device type 102 backups in restore script +@IncludeDeviceType2 - Defaults to 1, Include device type 2 backups in restore script +@IncludeDeviceType9 - Defaults to 1, Include device type 9 backups in restore script + +---------------------------------------------------------------------------------------------- +CHANGE LOG: + +December 23, 2012 - V1.01 - Release +January 4, 2013 - V1.02 - LSN Checks + Bug fix to STOPAT date format +January 11, 2013 - V1.03 - SQL Server 2005 compatibility (backup compression problem) & @StandbyMode +January 14, 2013 - V1.04 - WITH COPY and up to 10 striped backup files +January 15, 2013 - V1.05 - Format of constructed restore script, enclose database name in [ ] +February 7, 2013 - V1.06 - Modified WHERE device_type IN (7,102,2,9) +May 26, 2013 - V1.07 - Various changes for PoSh Driver Script compatibility +October 14, 2013 - V1.08 - Rename parameters, more meaningful names +October 15, 2013 - V2.00 - Add 2nd CTE for striped backup files and remove repeating calls to CTE +November 5, 2013 - V2.01 - Secondary .ndf files only included if @WithMoveDataFiles NOT NULL + - Extended artificial LSN used for sequencing WITH RECOVERY/CHECKDB to 21 characters + - Include database name in results for logging in PoSh +May 23, 2014 - V3.0 - Improved logging and error handling, add 'LogShippingVariableDeclare' parameter + Default is Yes when called from query analyser, set to No when called by PoSh +May 30, 2014 - V3.1 - Restructured CTE, all predicates moved to the CTE +June 6, 2014 - V3.2 - Add 'LogShippingStartTime' parameter for PowerShell script. + To skip subsequent full and diff backups when restoring Logs in PoSh log shipping mode + - Add 'Target Restore Database Name' parameter + If restoring a specific database, allows overriding restored name + Probably used in conjunction with a @WithMove override of data and log files to a different folder. + - Add LogShippingLastLSN parameter, used to filter results sent to ps_LogShippingLight +June 10, 2014 - V3.3 - Standardize Log Shipping Parameter Names & make &msg variable declare unique +June 27, 2014 - V3.31 - Diff restore bug fix +July 13, 2014 - V3.32 - Feedback from Tony Davis + Rename framework to memorable name 'RestoreGene' + Paramater for WITH REPLACE +August 5, 2014 - V3.4 - Remove TRY CATCH blocks from log restores and checkdb + - Remove CTE's,use #temp tables, suggested by S.Stresser +August 25, 2014 - V3.5 - goestock suggestion - Include device type 7 for AWS EC2 backups +August 29th, 2014 - V3.6 - Richard found and fixed a problem with variable declare where database name has a space or full stop. +July 28, 2015 - V3.7 - Luke Sarro, modifications for case sensitivity & parameter sniffing, a massive amount of work done. +August 28, 2015 - V3.8 - Luke Sarro modifications, recovery fork management. supports forking in recovery plans when constructing a restore script. + Only tested where a single fork exists, IE a restore was done to a historic point in time, with recovery, then subsequent log backups are taken. + When a fork exists the restore script will follow the new path for subsequent differential and log backups taken after the forking point. + If no rbackup forks exist, the procedure works as before. +September 02 2015 - V3.9 - SQLMongo modification to replace hyphens in database name +September 04, 2015 - V4.0 - Domingo modification, check for default backup path = '' +September 29, 2015 - V4.2 - Fixes bug identifying full backups taken after a recovery fork, has introduced code duplication to be removed later but fixes problem +October 3, 2015 - V4.3 - Remove code duplication introduced in V4.2 +* +June 3rd, 2016 - V5.0 - Feedback from Brent Ozar related viewing spike: + - V5.0 - Reintroduce SQL Server 2005 compatibility - Bob McLaren - Declaring and assigning variables on same line doesn't work with SQL Server 2005. + - V5.0 - Override data and log file paths if overriding restored database name + +June 11th, 2016 - V5.1 - Azure http url restore support, mick@sqlfairy.com + - V5.1 - Restore Script find and replacement variables, mick@sqlfairy.com + +June 17th, 2016 - V5.2 - Removed TRY CATCH block in log restore commands +June 26th, 2016 - V5.3 - Include FILESTREAM files in WITH MOVE, jgkiran +July 3rd, 2016 - V5.4 - New parameter for FILESTREAM files, for WITH MOVE parameter, jgkiran +July 14rd, 2016 - V5.5 - Rename rollback files when standby = 1 to allow multiple concurrent ps_RestoreGene invocations, jgkiran + +August 8th, 2016 - V5.6 - Accepts a comma separated variable list of databases to restore, suggested Stephen T + - Got permission to reuse the 'SELECT DATABASES' code snippet from ola hallengren - https://ola.hallengren.com/ +August 8th, 2016 - V5.7 - Make restore to new database, secondary file names, more meaningful +August 9th, 2016 - V5.8 - Include the WITH MOVE statements on the same results line as the corresponding RESTORE DATABASE statement, flatten the result set to simplify the PoSh driver +August 9th, 2016 - V5.9 - New Parameter, suppress WITH MOVE statements is default, parameter allows override to include them in the script. + +August 13th, 2016 - V6.0 + - Add parameter option to pivot WITH MOVE secondary files to a new result set line. Not compatible with PoSh driver, useful with large, complex databases. + - Add a parameter option to include just the restore script in the result set. Not compatible with PoSh driver, useful as SQL Agent Job step output. + +August 14th, 2016 - V6.1 - Remove parameter @UseDefaultDatabaseBackupPath , no longer used +August 15th, 2016 - V6.2 - @TargetDatabase parameter, file rename tidy +August 17th, 2016 - V6.3 - Edge case fix to fork point LSN +August 19th, 2016 - V6.4 - Publish SQL Server Central +September 4th, 2016 - V6.41 - PoSh Driver Last LSN minor fix. - Published SQL Server Central +September 9th, 2016 - V6.42 - Fix for multiple log files with move, J.Peablles +September 9th, 2016 - V6.43 - Fix for mirrored backups, C.Richardson +September 9th, 2016 - V6.44 - Mod to log file LSN selection, include if matches diff, R.Devries +September 30th, 2016 - V6.45 - Improvements to the output generated when @RestoreScriptOnly = 1, John Lee +September 30th, 2016 - V6.5 - New 'Drop Database After Restore' parameter for use with CHECKDB and automated backup verification, John Lee + +November 5th, 2016 - V6.51 - Increase length of @Database parameter to allow for more comma seperated database names +November 5th, 2016 - V6.52 - Edge case log exclusion criteria mod, R.Devries +November 5th, 2016 - V6.53 - New parameter option to include ALTER DATABASE @database SET SINGLE_USER WITH ROLLBACK IMMEDIATE, Hakan Ekman +November 5th, 2016 - V6.54 - New parameter option to exclude differential and log backups (presumaby for development environment refreshes), Mehedi Amin + +November 19th, 2016 - V6.55 - Remove semi colon from start of T-SQL restore command strings, serves no purpose +November 19th, 2016 - V6.56 - Remove variable declare, log reference and RAISERROR, serves no purpose and generates an error in edge cases ( my_database and my-database ), Lars Rasmussen +November 19th, 2016 - V6.57 - Parameters options for device types to include, Lars Rasmussen + +December 3rd, 2016 - V6.58 - Remove TIME function from STANDBY mode file name construct, for SQL Server 2005 compatibility, Erwin Louwerse +March 26th, 2017 - V6.59 - Significant performance improvements where an instance has many databases, Simone Bizzotto + +June 24th, 2017 - V6.70 - Case Sensitive Collation Database Compatibility - M.Pollock +September 9th, 2017 - V6.71 - Device Type filter fix, LostInEurope01 +November 11th, 2017 - V6.72 - Mod to log file selection, R.Devries + - Increase @Databases variable length, Bob +Febuary 14th, 2018 - V6.73 - Add escape characters to database name in SET SINGLE_USER, Rod +Febuary 16th, 2018 - V7.0 - Increase support for stripped backup files from 10 to 15, Mehedi +Febuary 17th, 2018 - V8.0 - Extensive changes to the backup fork handling, Mike +March 30th, 2018 - V8.04 - Code refactor +May 25th, 2018 - V8.05 - Missing exclusion of copy only backups reintroduced - Andy +August 25th, 2018 - V8.10 - Enhancements to the @ExcludeDiffAndLogBackups parameters, Bob and Chris F + - Change from parameter data type from bit to int + - 0 (default) = full, diff and logs, 1 = full only, 2 = full and diff, 3 = full and logs + - Existing BIT data type functionality retained and extended by new values 2 and 3. +November 8th, 2018 - V8.11 - Bug fix to last log file - Mike +December 6th, 2018 - V8.12 - Optimisation and environment setup fix - Adam +January 12th, 2019 - V8.13 - Sequence of FROM DISK = 'Stripe' files in RESTORE command +January 3rd, 2021 - V8.14 - Restore from Azure blog storage using FROM DISK instead of FROM URL for backup stripes - Aaron +January 9rd, 2021 - V8.15 - Change parameter @ExcludeDiffAndLogBackups, new option 4 to exclude full restore, return incremental diff & log restores - Mehedi Amin +July 11th, 2021 - V8.16 - Add support for an additional 5 stripes bring the total supported to 20, Steven Dannen +April 5th, 2023 - V8.2 - Masood : Bug fix restoring striped backups +April 11th, 2023 - V8.3 - Aaron : Result Set Columns fix + + +* +********************************************************************************************/ + +ALTER PROC [dbo].[sp_RestoreGene] +( + @Database VARCHAR(MAX) = NULL, + @TargetDatabase SYSNAME = NULL, + @WithMoveDataFiles VARCHAR(2000) = NULL, + @WithMoveLogFile VARCHAR(2000) = NULL, + @WithMoveFileStreamFile VARCHAR(2000) = NULL, + @FromFileFullUNC VARCHAR(2000) = NULL, + @FromFileDiffUNC VARCHAR(2000) = NULL, + @FromFileLogUNC VARCHAR(2000) = NULL, + @StopAt DATETIME = NULL, + @StandbyMode BIT = 0, + @IncludeSystemDBs BIT = 0, + @WithRecovery BIT = 0, + @WithCHECKDB BIT = 0, + @WithReplace BIT = 0, + + -- Parameters for PowerShell script use only + @LogShippingStartTime DATETIME = NULL, + @LogShippingLastLSN VARCHAR(25) = NULL, + -- Parameters for PowerShell script use only + + @BlobCredential VARCHAR(255) = NULL, --Credential used for Azure blob access + @RestoreScriptReplaceThis NVARCHAR(255) = NULL, + @RestoreScriptWithThis NVARCHAR(255) = NULL, + @SuppressWithMove BIT = 1, + @PivotWithMove BIT = 0, + @RestoreScriptOnly BIT = 0, + @DropDatabaseAfterRestore BIT = 0, + @SetSingleUser BIT = 0, + @ExcludeDiffAndLogBackups INT = 0, + + -- Options to exclude device types + @IncludeDeviceType7 BIT = 0, --virtual device + @IncludeDeviceType102 BIT = 1, + @IncludeDeviceType2 BIT = 1, + @IncludeDeviceType9 BIT = 1 +) +AS +BEGIN + + SET NOCOUNT ON; + + -- Avoid Parameter Sniffing Problems + DECLARE @Database_ VARCHAR(MAX); + SET @Database_ = @Database; + DECLARE @TargetDatabase_ SYSNAME; + SET @TargetDatabase_ = @TargetDatabase; + + -- Special handling for PoSh Driver + DECLARE @WithMoveDataFiles_ VARCHAR(2000); + IF @WithMoveDataFiles <> '' SET @WithMoveDataFiles_= @WithMoveDataFiles; + DECLARE @WithMoveLogFile_ VARCHAR(2000); + IF @WithMoveLogFile <> '' SET @WithMoveLogFile_= @WithMoveLogFile; + DECLARE @WithMoveFileStreamFile_ VARCHAR(2000); + IF @WithMoveFileStreamFile <> '' SET @WithMoveFileStreamFile_= @WithMoveFileStreamFile; + + DECLARE @FromFileFullUNC_ VARCHAR(2000); + SET @FromFileFullUNC_ = @FromFileFullUNC; + DECLARE @FromFileDiffUNC_ VARCHAR(2000); + SET @FromFileDiffUNC_ = @FromFileDiffUNC; + DECLARE @FromFileLogUNC_ VARCHAR(2000); + SET @FromFileLogUNC_ = @FromFileLogUNC; + DECLARE @StopAt_ DATETIME; + SET @StopAt_ = @StopAt; + DECLARE @StandbyMode_ BIT; + SET @StandbyMode_ = @StandbyMode; + DECLARE @IncludeSystemDBs_ BIT; + SET @IncludeSystemDBs_ = @IncludeSystemDBs; + DECLARE @WithRecovery_ BIT; + SET @WithRecovery_ = @WithRecovery; + DECLARE @WithCHECKDB_ BIT; + SET @WithCHECKDB_ = @WithCHECKDB; + DECLARE @WithReplace_ BIT; + SET @WithReplace_ = @WithReplace; + DECLARE @LogShippingStartTime_ DATETIME; + SET @LogShippingStartTime_ = @LogShippingStartTime; + DECLARE @LogShippingLastLSN_ VARCHAR(25); + SET @LogShippingLastLSN_ = @LogShippingLastLSN; + DECLARE @BlobCredential_ VARCHAR(255); + SET @BlobCredential_ = @BlobCredential; + DECLARE @RestoreScriptReplaceThis_ NVARCHAR(255); + SET @RestoreScriptReplaceThis_ = @RestoreScriptReplaceThis; + DECLARE @RestoreScriptWithThis_ NVARCHAR(255); + SET @RestoreScriptWithThis_ = @RestoreScriptWithThis; + DECLARE @SuppressWithMove_ BIT; + SET @SuppressWithMove_ = @SuppressWithMove; + DECLARE @PivotWithMove_ BIT + SET @PivotWithMove_ = @PivotWithMove; + DECLARE @RestoreScriptOnly_ BIT; + SET @RestoreScriptOnly_ = @RestoreScriptOnly; + DECLARE @DropDatabaseAfterRestore_ BIT; + SET @DropDatabaseAfterRestore_ = @DropDatabaseAfterRestore; + DECLARE @SetSingleUser_ BIT; + SET @SetSingleUser_ = @SetSingleUser; + DECLARE @ExcludeDiffAndLogBackups_ INT; + SET @ExcludeDiffAndLogBackups_ = @ExcludeDiffAndLogBackups; + + -- Defaults Recovery Point Times + IF ISNULL(@StopAt_,'') = '' + SET @StopAt_ = GETDATE(); + + IF ISNULL(@LogShippingStartTime_,'') = '' + SET @LogShippingStartTime_ = @StopAt_; + + -- Allow override of restored database name only if working with a specific database + IF @TargetDatabase_ IS NOT NULL AND @Database_ IS NULL + SET @TargetDatabase_ = NULL; + + IF CHARINDEX(',',@Database_, 1) > 0 + SET @TargetDatabase_ = NULL; + + -- ps_LogShippingLight - Filtered Results + IF ISNULL(@LogShippingLastLSN_,'') = '' + SET @LogShippingLastLSN_ = '-1'; + + -- Present WITH MOVE if override paths are supplied + IF ISNULL(@WithMoveDataFiles,'') <> '' OR ISNULL(@WithMoveLogFile_,'') <> '' OR ISNULL(@WithMoveFileStreamFile_,'') <> '' OR ISNULL(@TargetDatabase_,'') <> '' + SET @SuppressWithMove_ = 0 + + -- Backup file locations defaulted to '' by ps_RestoreGene + IF @FromFileFullUNC_ = '' + SET @FromFileFullUNC_ = NULL; + + IF @FromFileDiffUNC_ = '' + SET @FromFileDiffUNC_ = NULL; + + IF @FromFileLogUNC_ = '' + SET @FromFileLogUNC_ = NULL; + + -- Environment Preparation + IF OBJECT_ID('tempdb..#CTE') IS NOT NULL + DROP TABLE #CTE; + + IF OBJECT_ID('tempdb..#Stripes') IS NOT NULL + DROP TABLE #Stripes; + + IF OBJECT_ID('tempdb..#BackupFork') IS NOT NULL + DROP TABLE #BackupFork; + + IF OBJECT_ID('tempdb..#ForkPointsCount') IS NOT NULL + DROP TABLE #ForkPointsCount; + + IF OBJECT_ID('tempdb..#RestoreGeneResults') IS NOT NULL + DROP TABLE #RestoreGeneResults; + + IF OBJECT_ID('tempdb..#tmpDatabases') IS NOT NULL + DROP TABLE #tmpDatabases; + + IF OBJECT_ID('tempdb..#DeviceTypes') IS NOT NULL + DROP TABLE #DeviceTypes; + + IF OBJECT_ID('tempdb..#FullBackups') IS NOT NULL + DROP TABLE #FullBackups; + + CREATE TABLE #DeviceTypes (device_type tinyint); + IF @IncludeDeviceType7 = 1 INSERT INTO #DeviceTypes (device_type) SELECT 7; + IF @IncludeDeviceType102 = 1 INSERT INTO #DeviceTypes (device_type) SELECT 102; + IF @IncludeDeviceType2 = 1 INSERT INTO #DeviceTypes (device_type) SELECT 2; + IF @IncludeDeviceType9 = 1 INSERT INTO #DeviceTypes (device_type) SELECT 9; + + --======================================================================================================================================= + -- 'SELECT DATABASES' code snippet used below with permission from the ola hallengren - https://ola.hallengren.com/ + ----------------------------------------------------------------------------------------------------------------------------------------- + CREATE TABLE #tmpDatabases + ( + ID int IDENTITY, + DatabaseName nvarchar(450), + DatabaseNameFS nvarchar(max), + DatabaseType nvarchar(max), + Selected bit, + Completed bit + ); + CREATE CLUSTERED INDEX IDX_tmpDatabases ON #tmpDatabases(DatabaseName); + + IF CHARINDEX(',',@Database_,1) > 0 + BEGIN + + DECLARE @SelectedDatabases TABLE + ( + DatabaseName nvarchar(max), + DatabaseType nvarchar(max), + Selected bit + ); + + DECLARE @ErrorMessage nvarchar(max); + DECLARE @Error int; + + ---------------------------------------------------------------------------------------------------- + --// Select databases //-- + ---------------------------------------------------------------------------------------------------- + + SET @Database_ = REPLACE(@Database_, ', ', ','); + + WITH Databases1 (StartPosition, EndPosition, DatabaseItem) AS + ( + SELECT 1 AS StartPosition, + ISNULL(NULLIF(CHARINDEX(',', @Database_, 1), 0), LEN(@Database_) + 1) AS EndPosition, + SUBSTRING(@Database_, 1, ISNULL(NULLIF(CHARINDEX(',', @Database_, 1), 0), LEN(@Database_) + 1) - 1) AS DatabaseItem + WHERE @Database_ IS NOT NULL + UNION ALL + SELECT CAST(EndPosition AS int) + 1 AS StartPosition, + ISNULL(NULLIF(CHARINDEX(',', @Database_, EndPosition + 1), 0), LEN(@Database_) + 1) AS EndPosition, + SUBSTRING(@Database_, EndPosition + 1, ISNULL(NULLIF(CHARINDEX(',', @Database_, EndPosition + 1), 0), LEN(@Database_) + 1) - EndPosition - 1) AS DatabaseItem + FROM Databases1 + WHERE EndPosition < LEN(@Database_) + 1 + ), + Databases2 (DatabaseItem, Selected) AS + ( + SELECT CASE WHEN DatabaseItem LIKE '-%' THEN RIGHT(DatabaseItem,LEN(DatabaseItem) - 1) ELSE DatabaseItem END AS DatabaseItem, + CASE WHEN DatabaseItem LIKE '-%' THEN 0 ELSE 1 END AS Selected + FROM Databases1 + ), + Databases3 (DatabaseItem, DatabaseType, Selected) AS + ( + SELECT CASE WHEN DatabaseItem IN('ALL_DATABASES','SYSTEM_DATABASES','USER_DATABASES') THEN '%' ELSE DatabaseItem END AS DatabaseItem, + CASE WHEN DatabaseItem = 'SYSTEM_DATABASES' THEN 'S' WHEN DatabaseItem = 'USER_DATABASES' THEN 'U' ELSE NULL END AS DatabaseType, + Selected + FROM Databases2 + ), + Databases4 (DatabaseName, DatabaseType, Selected) AS + ( + SELECT CASE WHEN LEFT(DatabaseItem,1) = '[' AND RIGHT(DatabaseItem,1) = ']' THEN PARSENAME(DatabaseItem,1) ELSE DatabaseItem END AS DatabaseItem, + DatabaseType, + Selected + FROM Databases3 + ) + INSERT INTO @SelectedDatabases (DatabaseName, DatabaseType, Selected) + SELECT DatabaseName, + DatabaseType, + Selected + FROM Databases4 + OPTION (MAXRECURSION 0) + + INSERT INTO #tmpDatabases (DatabaseName, DatabaseNameFS, DatabaseType, Selected, Completed) + SELECT [name] AS DatabaseName, + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE([name],'\',''),'/',''),':',''),'*',''),'?',''),'"',''),'<',''),'>',''),'|',''),' ','') AS DatabaseNameFS, + CASE WHEN name IN('master','msdb','model') THEN 'S' ELSE 'U' END AS DatabaseType, + 0 AS Selected, + 0 AS Completed + FROM sys.databases + WHERE [name] <> 'tempdb' + AND source_database_id IS NULL + ORDER BY [name] ASC + + UPDATE tmpDatabases + SET tmpDatabases.Selected = SelectedDatabases.Selected + FROM #tmpDatabases tmpDatabases + INNER JOIN @SelectedDatabases SelectedDatabases + ON tmpDatabases.DatabaseName LIKE REPLACE(SelectedDatabases.DatabaseName,'_','[_]') + AND (tmpDatabases.DatabaseType = SelectedDatabases.DatabaseType OR SelectedDatabases.DatabaseType IS NULL) + WHERE SelectedDatabases.Selected = 1 + + UPDATE tmpDatabases + SET tmpDatabases.Selected = SelectedDatabases.Selected + FROM #tmpDatabases tmpDatabases + INNER JOIN @SelectedDatabases SelectedDatabases + ON tmpDatabases.DatabaseName LIKE REPLACE(SelectedDatabases.DatabaseName,'_','[_]') + AND (tmpDatabases.DatabaseType = SelectedDatabases.DatabaseType OR SelectedDatabases.DatabaseType IS NULL) + WHERE SelectedDatabases.Selected = 0 + + IF @Database_ IS NULL OR NOT EXISTS(SELECT * FROM @SelectedDatabases) OR EXISTS(SELECT * FROM @SelectedDatabases WHERE DatabaseName IS NULL OR DatabaseName = '') + BEGIN + SET @ErrorMessage = 'The value for the parameter @Databases is not supported.' + CHAR(13) + CHAR(10) + ' ' + RAISERROR(@ErrorMessage,16,1) WITH NOWAIT + SET @Error = @@ERROR + END + + END + + --======================================================================================================================================= + -- Full Backups - Last before stop at for each database + SELECT + a.database_name + ,MAX(a.backup_finish_date) AS backup_finish_date + INTO #FullBackups + FROM msdb.dbo.backupset a + JOIN msdb.dbo.backupmediafamily b + ON a.media_set_id = b.media_set_id + + WHERE a.[type] = 'D' + AND (a.database_name IN (SELECT DatabaseName FROM #tmpDatabases WHERE Selected = 1) OR @Database_ IS NULL OR a.database_name = @Database_) + AND device_type IN (SELECT device_type FROM #DeviceTypes) + AND a.is_copy_only = 0 + AND b.mirror = 0 + AND a.backup_start_date <= @LogShippingStartTime_ + GROUP BY a.database_name; + + CREATE INDEX IDX_FullBackups ON #FullBackups(database_name); + + --======================================================================================================================================= + -- Backup forking (suppress differential, log file select criteria) + SELECT bs.database_name, first_recovery_fork_guid, MIN(fork_point_lsn) AS fork_point_lsn + INTO #BackupFork + FROM msdb.dbo.backupset bs + JOIN msdb.dbo.backupmediafamily b + ON bs.media_set_id = b.media_set_id + JOIN #FullBackups fb + ON fb.database_name = bs.database_name + WHERE fb.backup_finish_date < bs.backup_start_date + AND bs.backup_finish_date < @LogShippingStartTime_ + AND bs.first_recovery_fork_guid <> bs.last_recovery_fork_guid + GROUP BY bs.database_name, first_recovery_fork_guid; + + -- Only one fork point between the selected full backup and the stop at time supported + SELECT database_name, COUNT(*) AS ForkPoints + INTO #ForkPointsCount + FROM #BackupFork rh + GROUP BY database_name; + + --======================================================================================================================================= + -------------------------------------------------------------- + -- CTE1 Full Backup + -------------------------------------------------------------- + WITH CTE + ( + database_name + ,current_compatibility_level + ,first_lsn + ,last_lsn + ,fork_point_lsn + ,current_is_read_only + ,current_state_desc + ,current_recovery_model_desc + ,has_backup_checksums + ,backup_size + ,[type] + ,backupmediasetid + ,family_sequence_number + ,backupfinishdate + ,physical_device_name + ,position + ,first_recovery_fork_guid + ,last_recovery_fork_guid + ) + AS + ( + -------------------------------------------------------------- + -- Full backup - Most recent before @LogShippingStartTime_ + SELECT + bs.database_name + ,d.[compatibility_level] AS current_compatibility_level + ,bs.first_lsn + ,bs.last_lsn + ,bs.fork_point_lsn + ,d.[is_read_only] AS current_is_read_only + ,d.[state_desc] AS current_state_desc + ,d.[recovery_model_desc] current_recovery_model_desc + ,bs.has_backup_checksums + ,bs.backup_size AS backup_size + ,'D' AS [type] + ,bs.media_set_id AS backupmediasetid + ,mf.family_sequence_number + ,bs.backup_finish_date AS backupfinishdate + ,mf.physical_device_name + ,bs.position + ,bs.first_recovery_fork_guid + ,bs.last_recovery_fork_guid + + FROM msdb.dbo.backupset bs + + INNER JOIN sys.databases d + ON bs.database_name = d.name + + INNER JOIN #FullBackups fb + ON fb.database_name = bs.database_name + AND fb.backup_finish_date = bs.backup_finish_date + + JOIN msdb.dbo.backupmediafamily mf + ON mf.media_set_id = bs.media_set_id + AND mf.family_sequence_number Between bs.first_family_number And bs.last_family_number + + WHERE bs.type = 'D' + AND mf.mirror = 0 + AND mf.physical_device_name NOT IN ('Nul', 'Nul:') + AND bs.is_copy_only = 0 + + UNION + + -------------------------------------------------------------- + -- Differential backup, most current immediately before @StopAt_, suppress if backup fork points exist + SELECT + bs.database_name + ,d.[compatibility_level] AS current_compatibility_level + ,bs.first_lsn + ,bs.last_lsn + ,bs.fork_point_lsn + ,d.[is_read_only] AS current_is_read_only + ,d.[state_desc] AS current_state_desc + ,d.[recovery_model_desc] current_recovery_model_desc + ,bs.has_backup_checksums + ,bs.backup_size AS backup_size + ,'I' AS [type] + ,bs.media_set_id AS backupmediasetid + ,mf.family_sequence_number + ,bs.backup_finish_date AS backupfinishdate + ,mf.physical_device_name + ,bs.position + ,bs.first_recovery_fork_guid + ,bs.last_recovery_fork_guid + FROM msdb.dbo.backupset bs + + INNER JOIN sys.databases d + ON bs.database_name = d.name + + INNER JOIN #FullBackups fb + ON fb.database_name = bs.database_name + AND fb.backup_finish_date < bs.backup_finish_date + + INNER JOIN -- Last Diff before STOPAT / Suppress if backup forkpoints exist + ( + SELECT + a.database_name + ,MAX(backup_start_date) backup_start_date + FROM msdb.dbo.backupset a + JOIN msdb.dbo.backupmediafamily b + ON a.media_set_id = b.media_set_id + + WHERE a.[type] = 'I' + AND (a.database_name IN (SELECT DatabaseName FROM #tmpDatabases WHERE Selected = 1) OR @Database_ IS NULL OR a.database_name = @Database_) + AND device_type IN (SELECT device_type FROM #DeviceTypes) + AND a.is_copy_only = 0 + AND b.mirror = 0 + AND a.backup_start_date <= ISNULL(@StopAt_,GETDATE()) + GROUP BY a.database_name + ) x + ON x.database_name = bs.database_name + AND x.backup_start_date = bs.backup_start_date + + INNER JOIN msdb.dbo.backupmediafamily mf + ON mf.media_set_id = bs.media_set_id + AND mf.family_sequence_number Between bs.first_family_number And bs.last_family_number + + LEFT OUTER JOIN #BackupFork bf + ON bf.database_name = bs.database_name + + WHERE bs.type = 'I' + AND mf.physical_device_name NOT IN ('Nul', 'Nul:') + AND mf.mirror = 0 + AND @StopAt_ = @LogShippingStartTime_ + AND bf.fork_point_lsn IS NULL + + UNION + + -------------------------------------------------------------- + -- Log file backups - after 1st full / before @StopAt_ + SELECT + bs.database_name + ,d.[compatibility_level] AS current_compatibility_level + ,bs.first_lsn + ,bs.last_lsn + ,bs.fork_point_lsn + ,d.[is_read_only] AS current_is_read_only + ,d.[state_desc] AS current_state_desc + ,d.[recovery_model_desc] current_recovery_model_desc + ,bs.has_backup_checksums + ,bs.backup_size AS backup_size + ,'L' AS [type] + ,bs.media_set_id AS backupmediasetid + ,mf.family_sequence_number + ,bs.backup_finish_date as backupfinishdate + ,mf.physical_device_name + ,bs.position + ,bs.first_recovery_fork_guid + ,bs.last_recovery_fork_guid + FROM msdb.dbo.backupset bs + + INNER JOIN sys.databases d + ON bs.database_name = d.name + + INNER JOIN msdb.dbo.backupmediafamily mf + ON mf.media_set_id = bs.media_set_id + AND mf.family_sequence_number Between bs.first_family_number And bs.last_family_number + + INNER JOIN #FullBackups fb + ON bs.database_name = fb.database_name + + LEFT OUTER JOIN -- Select the first log file after STOPAT + ( + SELECT DISTINCT x.database_name, CASE WHEN y.last_Log_After_StopAt IS NULL THEN CONVERT(datetime, '31 Dec 2050') ELSE y.last_Log_After_StopAt END AS last_Log_After_StopAt + FROM msdb.dbo.backupset x + LEFT JOIN + ( + SELECT + database_name + ,MIN(backup_start_date) last_Log_After_StopAt + FROM msdb.dbo.backupset a + JOIN msdb.dbo.backupmediafamily b + ON a.media_set_id = b.media_set_id + WHERE a.[type] = 'L' + AND (a.database_name IN (SELECT DatabaseName FROM #tmpDatabases WHERE Selected = 1) OR @Database_ IS NULL OR a.database_name = @Database_) + AND b.mirror = 0 + AND device_type IN (SELECT device_type FROM #DeviceTypes) + AND a.backup_start_date > ISNULL(@StopAt_,'1 Jan, 1900') + GROUP BY database_name + ) y + ON x.database_name = y.database_name + ) x + ON bs.database_name = x.database_name + + LEFT OUTER JOIN #BackupFork bf + ON bf.database_name = bs.database_name + AND bf.first_recovery_fork_guid = bs.first_recovery_fork_guid + + WHERE bs.backup_start_date <= x.last_Log_After_StopAt -- Include 1st log after stop at + AND bs.backup_start_date >= fb.backup_finish_date -- Full backup finish + --AND bs.backup_finish_date <= @StopAt_ + AND (bs.database_name IN (SELECT DatabaseName FROM #tmpDatabases WHERE Selected = 1) OR @Database_ IS NULL OR bs.database_name = @Database_) + AND mf.physical_device_name NOT IN ('Nul', 'Nul:') + AND mf.mirror = 0 + AND bs.type = 'L' + AND device_type IN (SELECT device_type FROM #DeviceTypes) + AND (bf.fork_point_lsn > bs.first_lsn OR bf.first_recovery_fork_guid IS NULL OR bs.first_recovery_fork_guid <> bs.last_recovery_fork_guid) + ) + + SELECT * INTO #CTE FROM CTE; + CREATE INDEX IDX_CTE ON #CTE(database_name); + + -------------------------------------------------------------- + -- CTE2 Optionally, striped backup file details + -------------------------------------------------------------- + WITH Stripes + ( + database_name, + backupmediasetid, + family_sequence_number, + last_lsn, + S2_pdn, + S3_pdn, + S4_pdn, + S5_pdn, + S6_pdn, + S7_pdn, + S8_pdn, + S9_pdn, + S10_pdn, + S11_pdn, + S12_pdn, + S13_pdn, + S14_pdn, + S15_pdn, + --************************ + S16_pdn, + S17_pdn, + S18_pdn, + S19_pdn, + S20_pdn + --************************ + ) + AS + ( + SELECT + Stripe1.database_name, + Stripe1.backupmediasetid, + Stripe1.family_sequence_number, + Stripe1.last_lsn, + Stripe2.physical_device_name AS S2_pdn, + Stripe3.physical_device_name AS S3_pdn, + Stripe4.physical_device_name AS S4_pdn, + Stripe5.physical_device_name AS S5_pdn, + Stripe6.physical_device_name AS S6_pdn, + Stripe7.physical_device_name AS S7_pdn, + Stripe8.physical_device_name AS S8_pdn, + Stripe9.physical_device_name AS S9_pdn, + Stripe10.physical_device_name AS S10_pdn, + Stripe11.physical_device_name AS S11_pdn, + Stripe12.physical_device_name AS S12_pdn, + Stripe13.physical_device_name AS S13_pdn, + Stripe14.physical_device_name AS S14_pdn, + Stripe15.physical_device_name AS S15_pdn + --************************ + ,Stripe16.physical_device_name AS S16_pdn + ,Stripe17.physical_device_name AS S17_pdn + ,Stripe18.physical_device_name AS S18_pdn + ,Stripe19.physical_device_name AS S19_pdn + ,Stripe20.physical_device_name AS S20_pdn + --************************ + FROM #CTE AS Stripe1 + + LEFT OUTER JOIN #CTE AS Stripe2 + ON Stripe2.database_name = Stripe1.database_name + AND Stripe2.backupmediasetid = Stripe1.backupmediasetid + AND Stripe2.family_sequence_number = 2 + + LEFT OUTER JOIN #CTE AS Stripe3 + ON Stripe3.database_name = Stripe1.database_name + AND Stripe3.backupmediasetid = Stripe1.backupmediasetid + AND Stripe3.family_sequence_number = 3 + + LEFT OUTER JOIN #CTE AS Stripe4 + ON Stripe4.database_name = Stripe1.database_name + AND Stripe4.backupmediasetid = Stripe1.backupmediasetid + AND Stripe4.family_sequence_number = 4 + + LEFT OUTER JOIN #CTE AS Stripe5 + ON Stripe5.database_name = Stripe1.database_name + AND Stripe5.backupmediasetid = Stripe1.backupmediasetid + AND Stripe5.family_sequence_number = 5 + + LEFT OUTER JOIN #CTE AS Stripe6 + ON Stripe6.database_name = Stripe1.database_name + AND Stripe6.backupmediasetid = Stripe1.backupmediasetid + AND Stripe6.family_sequence_number = 6 + + LEFT OUTER JOIN #CTE AS Stripe7 + ON Stripe7.database_name = Stripe1.database_name + AND Stripe7.backupmediasetid = Stripe1.backupmediasetid + AND Stripe7.family_sequence_number = 7 + + LEFT OUTER JOIN #CTE AS Stripe8 + ON Stripe8.database_name = Stripe1.database_name + AND Stripe8.backupmediasetid = Stripe1.backupmediasetid + AND Stripe8.family_sequence_number = 8 + + LEFT OUTER JOIN #CTE AS Stripe9 + ON Stripe9.database_name = Stripe1.database_name + AND Stripe9.backupmediasetid = Stripe1.backupmediasetid + AND Stripe9.family_sequence_number = 9 + + LEFT OUTER JOIN #CTE AS Stripe10 + ON Stripe10.database_name = Stripe1.database_name + AND Stripe10.backupmediasetid = Stripe1.backupmediasetid + AND Stripe10.family_sequence_number = 10 + + LEFT OUTER JOIN #CTE AS Stripe11 + ON Stripe11.database_name = Stripe1.database_name + AND Stripe11.backupmediasetid = Stripe1.backupmediasetid + AND Stripe11.family_sequence_number = 11 + + LEFT OUTER JOIN #CTE AS Stripe12 + ON Stripe12.database_name = Stripe1.database_name + AND Stripe12.backupmediasetid = Stripe1.backupmediasetid + AND Stripe12.family_sequence_number = 12 + + LEFT OUTER JOIN #CTE AS Stripe13 + ON Stripe13.database_name = Stripe1.database_name + AND Stripe13.backupmediasetid = Stripe1.backupmediasetid + AND Stripe13.family_sequence_number = 13 + + LEFT OUTER JOIN #CTE AS Stripe14 + ON Stripe14.database_name = Stripe1.database_name + AND Stripe14.backupmediasetid = Stripe1.backupmediasetid + AND Stripe14.family_sequence_number = 14 + + LEFT OUTER JOIN #CTE AS Stripe15 + ON Stripe15.database_name = Stripe1.database_name + AND Stripe15.backupmediasetid = Stripe1.backupmediasetid + AND Stripe15.family_sequence_number = 15 + + --************************ + LEFT OUTER JOIN #CTE AS Stripe16 + ON Stripe16.database_name = Stripe1.database_name + AND Stripe16.backupmediasetid = Stripe1.backupmediasetid + AND Stripe16.family_sequence_number = 16 + + LEFT OUTER JOIN #CTE AS Stripe17 + ON Stripe17.database_name = Stripe1.database_name + AND Stripe17.backupmediasetid = Stripe1.backupmediasetid + AND Stripe17.family_sequence_number = 17 + + LEFT OUTER JOIN #CTE AS Stripe18 + ON Stripe18.database_name = Stripe1.database_name + AND Stripe18.backupmediasetid = Stripe1.backupmediasetid + AND Stripe18.family_sequence_number = 18 + + LEFT OUTER JOIN #CTE AS Stripe19 + ON Stripe19.database_name = Stripe1.database_name + AND Stripe19.backupmediasetid = Stripe1.backupmediasetid + AND Stripe19.family_sequence_number = 19 + + LEFT OUTER JOIN #CTE AS Stripe20 + ON Stripe20.database_name = Stripe1.database_name + AND Stripe20.backupmediasetid = Stripe1.backupmediasetid + AND Stripe20.family_sequence_number = 20 +-- ************************ + + ) + + SELECT * INTO #Stripes FROM Stripes; + + CREATE INDEX IDX_Stripes ON #Stripes(database_name); + + -------------------------------------------------------------- + -- Results, T-SQL RESTORE commands, below are based on CTE's above + -------------------------------------------------------------- + + SELECT + CASE WHEN @RestoreScriptReplaceThis_ IS NOT NULL AND @RestoreScriptWithThis_ IS NOT NULL THEN REPLACE(a.Command, @RestoreScriptReplaceThis_, @RestoreScriptWithThis_) ELSE a.Command END AS TSQL, --Allow substitution of a path + CONVERT(nvarchar(30), a.backupfinishdate, 126) + AS BackupDate, + a.BackupDevice, + a.first_lsn, + a.last_lsn, + a.fork_point_lsn, + a.first_recovery_fork_guid, + a.last_recovery_fork_guid, + a.database_name , + ROW_NUMBER() OVER(ORDER BY database_name, Sequence, a.backupfinishdate) AS SortSequence + INTO #RestoreGeneResults + FROM + ( + + -------------------------------------------------------------- + -- Most recent full backup + -------------------------------------------------------------- + + SELECT + + 'RESTORE DATABASE [' + CASE ISNULL(@TargetDatabase_,'') WHEN '' THEN d.[name] ELSE @TargetDatabase_ END + ']' + SPACE(1) + CHAR(13) + + + CASE WHEN #CTE.physical_device_name LIKE 'http%' THEN ' FROM URL = N' ELSE ' FROM DISK = N' END + '''' + --Support restore from blob storage in Azure + + CASE ISNULL(@FromFileFullUNC_,'Actual') + WHEN 'Actual' THEN #CTE.physical_device_name + ELSE @FromFileFullUNC_ + SUBSTRING(#CTE.physical_device_name,LEN(#CTE.physical_device_name) - CHARINDEX('\',REVERSE(#CTE.physical_device_name),1) + 2,CHARINDEX('\',REVERSE(#CTE.physical_device_name),1) + 1) + END + '''' + SPACE(1) + CHAR(13) + + + -- Striped backup files + CASE ISNULL(#Stripes.S2_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S2_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S2_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S2_pdn,LEN(#Stripes.S2_pdn) - CHARINDEX('\',REVERSE(#Stripes.S2_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S2_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S3_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S3_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S3_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S3_pdn,LEN(#Stripes.S3_pdn) - CHARINDEX('\',REVERSE(#Stripes.S3_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S3_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S4_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S4_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S4_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S4_pdn,LEN(#Stripes.S4_pdn) - CHARINDEX('\',REVERSE(#Stripes.S4_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S4_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S5_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S5_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S5_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S5_pdn,LEN(#Stripes.S5_pdn) - CHARINDEX('\',REVERSE(#Stripes.S5_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S5_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S6_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S6_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S6_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S6_pdn,LEN(#Stripes.S6_pdn) - CHARINDEX('\',REVERSE(#Stripes.S6_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S6_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S7_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S7_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S7_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S7_pdn,LEN(#Stripes.S7_pdn) - CHARINDEX('\',REVERSE(#Stripes.S7_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S7_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S8_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S8_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S8_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S8_pdn,LEN(#Stripes.S8_pdn) - CHARINDEX('\',REVERSE(#Stripes.S8_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S8_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S9_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S9_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S9_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S9_pdn,LEN(#Stripes.S9_pdn) - CHARINDEX('\',REVERSE(#Stripes.S9_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S9_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S10_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S10_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S10_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S10_pdn,LEN(#Stripes.S10_pdn) - CHARINDEX('\',REVERSE(#Stripes.S10_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S10_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S11_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S11_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S11_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S11_pdn,LEN(#Stripes.S11_pdn) - CHARINDEX('\',REVERSE(#Stripes.S11_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S11_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S12_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S12_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S12_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S12_pdn,LEN(#Stripes.S12_pdn) - CHARINDEX('\',REVERSE(#Stripes.S12_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S12_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S13_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S13_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S13_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S13_pdn,LEN(#Stripes.S13_pdn) - CHARINDEX('\',REVERSE(#Stripes.S13_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S13_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S14_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S14_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S14_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S14_pdn,LEN(#Stripes.S14_pdn) - CHARINDEX('\',REVERSE(#Stripes.S14_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S14_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S15_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S15_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S15_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S15_pdn,LEN(#Stripes.S15_pdn) - CHARINDEX('\',REVERSE(#Stripes.S15_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S15_pdn),1) + 1) END + '''' + END + + + --******* + + CASE ISNULL(#Stripes.S16_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S16_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S16_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S16_pdn,LEN(#Stripes.S16_pdn) - CHARINDEX('\',REVERSE(#Stripes.S16_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S16_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S17_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S17_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S17_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S17_pdn,LEN(#Stripes.S17_pdn) - CHARINDEX('\',REVERSE(#Stripes.S17_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S17_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S18_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S18_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S18_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S18_pdn,LEN(#Stripes.S18_pdn) - CHARINDEX('\',REVERSE(#Stripes.S18_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S18_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S19_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S19_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S19_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S19_pdn,LEN(#Stripes.S19_pdn) - CHARINDEX('\',REVERSE(#Stripes.S19_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S19_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S20_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S20_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S20_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S20_pdn,LEN(#Stripes.S20_pdn) - CHARINDEX('\',REVERSE(#Stripes.S20_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S20_pdn),1) + 1) END + '''' + END + + + --****** + + ' WITH ' + + + CASE WHEN #CTE.physical_device_name LIKE 'http%' AND @BlobCredential_ IS NOT NULL THEN ' CREDENTIAL = ''' + @BlobCredential_ + ''', ' ELSE '' END + + + CASE ISNULL(@WithReplace_,0) WHEN 1 THEN 'REPLACE, ' ELSE '' END + 'FILE = ' + CAST(#CTE.position AS VARCHAR(5)) + ',' + + CASE #CTE.has_backup_checksums WHEN 1 THEN 'CHECKSUM, ' ELSE ' ' END + + + CASE @StandbyMode_ WHEN 0 THEN 'NORECOVERY,' ELSE 'STANDBY =N' + '''' + ISNULL(@FromFileFullUNC_,SUBSTRING(#CTE.physical_device_name,1,LEN(#CTE.physical_device_name) - CHARINDEX('\',REVERSE(#CTE.physical_device_name)))) + '\' + d.name + '_' + REPLACE(REPLACE(SUBSTRING(CONVERT(VARCHAR(24),GETDATE(),127),12,12),':',''),'.','') + '_ROLLBACK_UNDO.bak ' + '''' + ',' END + SPACE(1) + + + 'STATS=10' + SPACE(1) + + + CASE @SuppressWithMove_ WHEN 0 THEN + + ', MOVE N' + '''' + x.LogicalName + '''' + ' TO ' + + '''' + + CASE ISNULL(@WithMoveDataFiles_,'Actual') + WHEN 'Actual' THEN x.PhysicalName + ELSE @WithMoveDataFiles_ + SUBSTRING(x.PhysicalName,LEN(x.PhysicalName) - CHARINDEX('\',REVERSE(x.PhysicalName),1) + 2,CHARINDEX('\',REVERSE(x.PhysicalName),1) + 1) + END + '''' + SPACE(1) + + + ', MOVE N' + '''' + y.LogicalName + '''' + ' TO ' + + '''' + + CASE ISNULL(@WithMoveLogFile_ ,'Actual') + WHEN 'Actual' THEN y.PhysicalName + ELSE @WithMoveLogFile_ + SUBSTRING(y.PhysicalName,LEN(y.PhysicalName) - CHARINDEX('\',REVERSE(y.PhysicalName),1) + 2,CHARINDEX('\',REVERSE(y.PhysicalName),1) + 1) + END + '''' + ELSE ' ' + END + + AS Command, + 1 AS Sequence, + d.name AS database_name, + #CTE.physical_device_name AS BackupDevice, + #CTE.backupfinishdate, + #CTE.backup_size, + #CTE.first_lsn, + #CTE.last_lsn, + #CTE.fork_point_lsn, + #CTE.first_recovery_fork_guid, + #CTE.last_recovery_fork_guid + + FROM sys.databases d + + INNER JOIN + ( + SELECT + DB_NAME(mf.database_id) AS name + ,CASE ISNULL(@TargetDatabase_,'') WHEN '' THEN mf.Physical_Name ELSE SUBSTRING(mf.Physical_Name,1,CASE CHARINDEX('.',mf.Physical_Name) WHEN 0 THEN LEN(mf.Physical_Name) ELSE CHARINDEX('.',mf.Physical_Name) - 1 END) + '_' + @TargetDatabase_ + '.mdf' END AS PhysicalName + ,mf.Name AS LogicalName + FROM sys.master_files mf + WHERE type_desc = 'ROWS' + AND mf.file_id = 1 + ) x + ON d.name = x.name + + INNER JOIN + ( + SELECT + DB_NAME(mf.database_id) AS name, type_desc + ,CASE ISNULL(@TargetDatabase_,'') WHEN '' THEN mf.Physical_Name ELSE SUBSTRING(mf.Physical_Name,1,CASE CHARINDEX('.',mf.Physical_Name) WHEN 0 THEN LEN(mf.Physical_Name) ELSE CHARINDEX('.',mf.Physical_Name) - 1 END) + '_' + @TargetDatabase_ + '.ldf' END AS PhysicalName + ,mf.Name AS LogicalName + FROM sys.master_files mf + + -- Fix for multiple log files/with moves + INNER JOIN + ( + SELECT database_id, MIN(file_id) AS logfile_id + FROM sys.master_files + WHERE type_desc = 'LOG' + GROUP BY database_id + ) logfileid + on logfileid.database_id = mf.database_id + AND logfileid.logfile_id = mf.file_id + WHERE type_desc = 'LOG' + ) y + ON d.name = y.name + + LEFT OUTER JOIN #CTE + ON #CTE.database_name = d.name + AND #CTE.family_sequence_number = 1 + + INNER JOIN #Stripes + ON #Stripes.database_name = d.name + AND #Stripes.backupmediasetid = #CTE.backupmediasetid + AND #Stripes.last_lsn = #CTE.last_lsn + + LEFT OUTER JOIN #ForkPointsCount fpc + ON fpc.database_name = #CTE.database_name + + WHERE #CTE.[type] = 'D' + AND #CTE.family_sequence_number = 1 + AND ISNULL(fpc.ForkPoints,0) < 2 + AND @ExcludeDiffAndLogBackups_ IN (0,1,2,3) + + -------------------------------------------------------------- + -- Most recent differential backup + -------------------------------------------------------------- + UNION + + SELECT + + 'RESTORE DATABASE [' + CASE ISNULL(@TargetDatabase_,'') WHEN '' THEN d.[name] ELSE @TargetDatabase_ END + ']' + SPACE(1) + CHAR(13) + + CASE WHEN #CTE.physical_device_name LIKE 'http%' THEN ' FROM URL = N' ELSE ' FROM DISK = N' END + '''' + + + CASE ISNULL(@FromFileDiffUNC_,'Actual') + WHEN 'Actual' THEN #CTE.physical_device_name + ELSE @FromFileDiffUNC_ + SUBSTRING(#CTE.physical_device_name,LEN(#CTE.physical_device_name) - CHARINDEX('\',REVERSE(#CTE.physical_device_name),1) + 2,CHARINDEX('\',REVERSE(#CTE.physical_device_name),1) + 1) + END + '''' + SPACE(1) + CHAR(13) + + + -- Striped backup files + CASE ISNULL(#Stripes.S2_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S2_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S2_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S2_pdn,LEN(#Stripes.S2_pdn) - CHARINDEX('\',REVERSE(#Stripes.S2_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S2_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S3_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S3_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S3_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S3_pdn,LEN(#Stripes.S3_pdn) - CHARINDEX('\',REVERSE(#Stripes.S3_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S3_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S4_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S4_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S4_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S4_pdn,LEN(#Stripes.S4_pdn) - CHARINDEX('\',REVERSE(#Stripes.S4_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S4_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S5_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S5_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S5_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S5_pdn,LEN(#Stripes.S5_pdn) - CHARINDEX('\',REVERSE(#Stripes.S5_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S5_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S6_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S6_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S6_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S6_pdn,LEN(#Stripes.S6_pdn) - CHARINDEX('\',REVERSE(#Stripes.S6_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S6_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S7_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S7_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S7_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S7_pdn,LEN(#Stripes.S7_pdn) - CHARINDEX('\',REVERSE(#Stripes.S7_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S7_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S8_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S8_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S8_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S8_pdn,LEN(#Stripes.S8_pdn) - CHARINDEX('\',REVERSE(#Stripes.S8_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S8_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S9_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S9_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S9_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S9_pdn,LEN(#Stripes.S9_pdn) - CHARINDEX('\',REVERSE(#Stripes.S9_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S9_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S10_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S10_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S10_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S10_pdn,LEN(#Stripes.S10_pdn) - CHARINDEX('\',REVERSE(#Stripes.S10_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S10_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S11_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S11_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S11_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S11_pdn,LEN(#Stripes.S11_pdn) - CHARINDEX('\',REVERSE(#Stripes.S11_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S11_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S12_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S12_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S12_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S12_pdn,LEN(#Stripes.S12_pdn) - CHARINDEX('\',REVERSE(#Stripes.S12_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S12_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S13_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S13_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S13_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S13_pdn,LEN(#Stripes.S13_pdn) - CHARINDEX('\',REVERSE(#Stripes.S13_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S13_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S14_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S14_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S14_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S14_pdn,LEN(#Stripes.S14_pdn) - CHARINDEX('\',REVERSE(#Stripes.S14_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S14_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S15_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S15_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S15_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S15_pdn,LEN(#Stripes.S15_pdn) - CHARINDEX('\',REVERSE(#Stripes.S15_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S15_pdn),1) + 1) END + '''' + END + + + --************************** + + CASE ISNULL(#Stripes.S16_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S16_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S16_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S16_pdn,LEN(#Stripes.S16_pdn) - CHARINDEX('\',REVERSE(#Stripes.S16_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S16_pdn),1) + 1) END + '''' + END + + + + CASE ISNULL(#Stripes.S17_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S17_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S17_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S17_pdn,LEN(#Stripes.S17_pdn) - CHARINDEX('\',REVERSE(#Stripes.S17_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S17_pdn),1) + 1) END + '''' + END + + + + CASE ISNULL(#Stripes.S18_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S18_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S18_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S18_pdn,LEN(#Stripes.S18_pdn) - CHARINDEX('\',REVERSE(#Stripes.S18_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S18_pdn),1) + 1) END + '''' + END + + + + CASE ISNULL(#Stripes.S19_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S19_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S19_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S19_pdn,LEN(#Stripes.S19_pdn) - CHARINDEX('\',REVERSE(#Stripes.S19_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S19_pdn),1) + 1) END + '''' + END + + + + CASE ISNULL(#Stripes.S20_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S20_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S20_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S20_pdn,LEN(#Stripes.S20_pdn) - CHARINDEX('\',REVERSE(#Stripes.S20_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S20_pdn),1) + 1) END + '''' + END + + + --************************** + + ' WITH FILE = ' + CAST(#CTE.position AS VARCHAR(5)) + ',' + + CASE #CTE.has_backup_checksums WHEN 1 THEN 'CHECKSUM, ' ELSE ' ' END + + + CASE WHEN #CTE.physical_device_name LIKE 'http%' AND @BlobCredential_ IS NOT NULL THEN ' CREDENTIAL = ''' + @BlobCredential_ + ''', ' ELSE '' END + + + CASE @StandbyMode_ WHEN 0 THEN 'NORECOVERY,' ELSE 'STANDBY =N' + '''' + ISNULL(@FromFileFullUNC_,SUBSTRING(#CTE.physical_device_name,1,LEN(#CTE.physical_device_name) - CHARINDEX('\',REVERSE(#CTE.physical_device_name)))) + '\' + d.name + '_' + REPLACE(REPLACE(SUBSTRING(CONVERT(VARCHAR(24),GETDATE(),127),12,12),':',''),'.','') + '_ROLLBACK_UNDO.bak ' + '''' + ',' END + SPACE(1) + + + 'STATS=10' + SPACE(1) + + AS Command, + 750000 AS Sequence, + d.name AS database_name, + #CTE.physical_device_name AS BackupDevice, + #CTE.backupfinishdate, + #CTE.backup_size, + #CTE.first_lsn, + #CTE.last_lsn, + #CTE.fork_point_lsn, + #CTE.first_recovery_fork_guid, + #CTE.last_recovery_fork_guid + + + FROM sys.databases d + + INNER JOIN #CTE + ON #CTE.database_name = d.name + AND #CTE.family_sequence_number = 1 + + LEFT OUTER JOIN #Stripes + ON #Stripes.database_name = d.name + AND #Stripes.backupmediasetid = #CTE.backupmediasetid + AND #Stripes.last_lsn = #CTE.last_lsn + + LEFT OUTER JOIN #ForkPointsCount fpc + ON fpc.database_name = #CTE.database_name + + WHERE #CTE.[type] = 'I' + AND #CTE.family_sequence_number = 1 + AND @ExcludeDiffAndLogBackups_ IN (0,2,4) + AND ISNULL(fpc.ForkPoints,0) < 2 + + -------------------------------------------------------------- + UNION -- Log backups taken since most recent full or diff + -------------------------------------------------------------- + + SELECT + + 'RESTORE LOG [' + CASE ISNULL(@TargetDatabase_,'') WHEN '' THEN d.[name] ELSE @TargetDatabase_ END + ']' + SPACE(1) + CHAR(13) + + + CASE WHEN #CTE.physical_device_name LIKE 'http%' THEN ' FROM URL = N' ELSE ' FROM DISK = N' END + '''' + + + CASE ISNULL(@FromFileLogUNC_,'Actual') + WHEN 'Actual' THEN #CTE.physical_device_name + ELSE @FromFileLogUNC_ + SUBSTRING(#CTE.physical_device_name,LEN(#CTE.physical_device_name) - CHARINDEX('\',REVERSE(#CTE.physical_device_name),1) + 2,CHARINDEX('\',REVERSE(#CTE.physical_device_name),1) + 1) + END + '''' + CHAR(13) + + + -- Striped backup files + CASE ISNULL(#Stripes.S2_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S2_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S2_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S2_pdn,LEN(#Stripes.S2_pdn) - CHARINDEX('\',REVERSE(#Stripes.S2_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S2_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S3_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S3_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S3_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S3_pdn,LEN(#Stripes.S3_pdn) - CHARINDEX('\',REVERSE(#Stripes.S3_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S3_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S4_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S4_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S4_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S4_pdn,LEN(#Stripes.S4_pdn) - CHARINDEX('\',REVERSE(#Stripes.S4_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S4_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S5_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S5_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S5_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S5_pdn,LEN(#Stripes.S5_pdn) - CHARINDEX('\',REVERSE(#Stripes.S5_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S5_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S6_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S6_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S6_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S6_pdn,LEN(#Stripes.S6_pdn) - CHARINDEX('\',REVERSE(#Stripes.S6_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S6_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S7_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S7_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S7_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S7_pdn,LEN(#Stripes.S7_pdn) - CHARINDEX('\',REVERSE(#Stripes.S7_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S7_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S8_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S8_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S8_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S8_pdn,LEN(#Stripes.S8_pdn) - CHARINDEX('\',REVERSE(#Stripes.S8_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S8_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S9_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S9_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S9_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S9_pdn,LEN(#Stripes.S9_pdn) - CHARINDEX('\',REVERSE(#Stripes.S9_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S9_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S10_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S10_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S10_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S10_pdn,LEN(#Stripes.S10_pdn) - CHARINDEX('\',REVERSE(#Stripes.S10_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S10_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S11_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S11_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S11_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S11_pdn,LEN(#Stripes.S10_pdn) - CHARINDEX('\',REVERSE(#Stripes.S11_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S11_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S12_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S12_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S12_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S12_pdn,LEN(#Stripes.S12_pdn) - CHARINDEX('\',REVERSE(#Stripes.S12_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S12_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S13_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S13_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S13_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S13_pdn,LEN(#Stripes.S13_pdn) - CHARINDEX('\',REVERSE(#Stripes.S13_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S13_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S14_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S14_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S14_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S14_pdn,LEN(#Stripes.S14_pdn) - CHARINDEX('\',REVERSE(#Stripes.S14_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S14_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S15_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S15_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S15_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S15_pdn,LEN(#Stripes.S15_pdn) - CHARINDEX('\',REVERSE(#Stripes.S15_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S15_pdn),1) + 1) END + '''' + END + + + --*************** + CASE ISNULL(#Stripes.S16_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S16_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S16_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S16_pdn,LEN(#Stripes.S16_pdn) - CHARINDEX('\',REVERSE(#Stripes.S16_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S16_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S17_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S17_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S17_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S17_pdn,LEN(#Stripes.S17_pdn) - CHARINDEX('\',REVERSE(#Stripes.S17_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S17_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S18_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S18_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S18_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S18_pdn,LEN(#Stripes.S18_pdn) - CHARINDEX('\',REVERSE(#Stripes.S18_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S18_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S19_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S19_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S19_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S19_pdn,LEN(#Stripes.S19_pdn) - CHARINDEX('\',REVERSE(#Stripes.S19_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S19_pdn),1) + 1) END + '''' + END + + + CASE ISNULL(#Stripes.S20_pdn,'') + WHEN '' THEN '' + ELSE ',' + CASE WHEN #Stripes.S20_pdn LIKE 'http%' THEN ' URL = N' ELSE ' DISK = N' END + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S20_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S20_pdn,LEN(#Stripes.S20_pdn) - CHARINDEX('\',REVERSE(#Stripes.S20_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S20_pdn),1) + 1) END + '''' + END + + + --***************** + + CASE @StandbyMode_ WHEN 0 THEN ' WITH NORECOVERY,' ELSE ' WITH STANDBY =N' + '''' + ISNULL(@FromFileFullUNC_,SUBSTRING(#CTE.physical_device_name,1,LEN(#CTE.physical_device_name) - CHARINDEX('\',REVERSE(#CTE.physical_device_name)))) + '\' + d.name + '_' + REPLACE(REPLACE(SUBSTRING(CONVERT(VARCHAR(24),GETDATE(),127),12,12),':',''),'.','') + '_ROLLBACK_UNDO.bak ' + '''' + ',' END + SPACE(1) + + + CASE WHEN #CTE.physical_device_name LIKE 'http%' AND @BlobCredential_ IS NOT NULL THEN ' CREDENTIAL = ''' + @BlobCredential_ + ''', ' ELSE '' END + + + CASE #CTE.has_backup_checksums WHEN 1 THEN ' CHECKSUM, ' ELSE ' ' END + + + + 'FILE = ' + CAST(#CTE.position AS VARCHAR(5)) + + ' ,STOPAT = ' + '''' + CONVERT(VARCHAR(21),@StopAt_,120) + '''' + + AS Command, + 1000000 AS Sequence, + d.name AS database_name, + #CTE.physical_device_name AS BackupDevice, + #CTE.backupfinishdate, + #CTE.backup_size, + #CTE.first_lsn, + #CTE.last_lsn, + #CTE.fork_point_lsn, + #CTE.first_recovery_fork_guid, + #CTE.last_recovery_fork_guid + + + FROM sys.databases d + + INNER JOIN #CTE + ON #CTE.database_name = d.name + AND #CTE.family_sequence_number = 1 + + LEFT OUTER JOIN #Stripes + ON #Stripes.database_name = d.name + AND #Stripes.backupmediasetid = #CTE.backupmediasetid + AND #Stripes.last_lsn = #CTE.last_lsn + + LEFT OUTER JOIN + ( + SELECT database_name, MAX(last_lsn) last_lsn + FROM #CTE + WHERE [type] = 'I' + + GROUP BY database_name + ) after_diff + ON after_diff.database_name = #CTE.database_name + + LEFT OUTER JOIN #ForkPointsCount fpc + ON fpc.database_name = #CTE.database_name + + WHERE #CTE.[type] = 'L' + AND #CTE.family_sequence_number = 1 + AND #CTE.last_lsn >= CASE WHEN @ExcludeDiffAndLogBackups_ IN(0,4) THEN ISNULL(after_diff.last_lsn,'0') ELSE 0 END + AND @ExcludeDiffAndLogBackups_ IN (0,3,4) + + AND ISNULL(fpc.ForkPoints,0) < 2 + + -------------------------------------------------------------- + UNION -- SET SINGLE USER WITH ROLLBACK IMMEDIATE + -------------------------------------------------------------- + SELECT + + 'BEGIN TRY ALTER DATABASE [' + CASE ISNULL(@TargetDatabase_,'') WHEN '' THEN d.[name] ELSE @TargetDatabase_ END + ']' + ' SET SINGLE_USER WITH ROLLBACK IMMEDIATE END TRY BEGIN CATCH PRINT' + '''' + 'SET SINGLE USER FAILED' + '''' + ' END CATCH' AS Command, + 0 AS Sequence, + d.name AS database_name, + '' AS BackupDevice, + GETDATE() AS backupfinishdate, + #CTE.backup_size, + '0' AS first_lsn, + '0' AS last_lsn, + '0' AS fork_point_lsn , + '00000000-0000-0000-0000-000000000000' AS first_recovery_fork_guid, + '00000000-0000-0000-0000-000000000000' AS last_recovery_fork_guid + + FROM sys.databases d + + INNER JOIN #CTE + ON #CTE.database_name = d.name + + LEFT OUTER JOIN #ForkPointsCount fpc + ON fpc.database_name = #CTE.database_name + + WHERE #CTE.[type] = 'D' + AND @SetSingleUser_ = 1 + AND ISNULL(fpc.ForkPoints,0) < 2 + + -------------------------------------------------------------- + UNION -- Restore WITH RECOVERY + -------------------------------------------------------------- + SELECT + + 'RESTORE DATABASE [' + CASE ISNULL(@TargetDatabase_,'') WHEN '' THEN d.[name] ELSE @TargetDatabase_ END + ']' + SPACE(1) + 'WITH RECOVERY' AS Command, + 1000001 AS Sequence, + d.name AS database_name, + '' AS BackupDevice, + GETDATE() AS backupfinishdate, + #CTE.backup_size, + #CTE.first_lsn, + '999999999999999999997' AS last_lsn, + #CTE.fork_point_lsn , + '00000000-0000-0000-0000-000000000000' AS first_recovery_fork_guid, + '00000000-0000-0000-0000-000000000000' AS last_recovery_fork_guid + + FROM sys.databases d + + INNER JOIN #CTE + ON #CTE.database_name = d.name + + LEFT OUTER JOIN #ForkPointsCount fpc + ON fpc.database_name = #CTE.database_name + + WHERE #CTE.[type] = 'D' + AND @WithRecovery_ = 1 + AND ISNULL(fpc.ForkPoints,0) < 2 + + -------------------------------------------------------------- + UNION -- CHECKDB + -------------------------------------------------------------- + SELECT + + 'DBCC CHECKDB(' + '''' + CASE ISNULL(@TargetDatabase_,'') WHEN '' THEN d.[name] ELSE @TargetDatabase_ END + '''' + ') WITH NO_INFOMSGS, ALL_ERRORMSGS' AS Command, + 1000002 AS Sequence, + d.name AS database_name, + '' AS BackupDevice, + DATEADD(minute,1,GETDATE()) AS backupfinishdate, + #CTE.backup_size, + #CTE.first_lsn, + '999999999999999999998' AS last_lsn, + #CTE.fork_point_lsn, + '00000000-0000-0000-0000-000000000000' AS first_recovery_fork_guid, + '00000000-0000-0000-0000-000000000000' AS last_recovery_fork_guid + + FROM sys.databases d + + INNER JOIN #CTE + ON #CTE.database_name = d.name + + LEFT OUTER JOIN #ForkPointsCount fpc + ON fpc.database_name = #CTE.database_name + + WHERE #CTE.[type] = 'D' + AND @WithCHECKDB_ = 1 + AND @WithRecovery_ = 1 + AND ISNULL(fpc.ForkPoints,0) < 2 + + -------------------------------------------------------------- + UNION -- Drop database after restore + -------------------------------------------------------------- + SELECT + + -- Comment out all commands if multiple forking points exist + --CASE WHEN @CommentOut = 1 THEN ' -- Multipe backup fork points detected, command suppressed -- ' ELSE '' END + + + 'DROP DATABASE [' + CASE ISNULL(@TargetDatabase_,'') WHEN '' THEN d.[name] ELSE @TargetDatabase_ END + ']' + SPACE(1) AS Command, + 1000003 AS Sequence, + d.name AS database_name, + '' AS BackupDevice, + GETDATE() AS backupfinishdate, + #CTE.backup_size, + #CTE.first_lsn, + '999999999999999999999' AS last_lsn, + #CTE.fork_point_lsn, + '00000000-0000-0000-0000-000000000000' AS first_recovery_fork_guid, + '00000000-0000-0000-0000-000000000000' AS last_recovery_fork_guid + + + + FROM sys.databases d + + INNER JOIN #CTE + ON #CTE.database_name = d.name + + LEFT OUTER JOIN #ForkPointsCount fpc + ON fpc.database_name = #CTE.database_name + + WHERE #CTE.[type] = 'D' + AND @DropDatabaseAfterRestore_ = 1 + AND ISNULL(fpc.ForkPoints,0) < 2 + + -------------------------------------------------------------- + UNION -- RAISERROR suppress restore when multiple forkpoints exist + -------------------------------------------------------------- + SELECT + + 'RAISERROR (' + '''' + 'Multiple restores per performed between the selected full backup and stop at time for database ' + CASE ISNULL(@TargetDatabase_,'') WHEN '' THEN d.[name] ELSE @TargetDatabase_ END + ' - Restore Gene processing aborted.' + '''' + ',0,0);' + + SPACE(1) AS Command, + 1 AS Sequence, + d.name AS database_name, + '' AS BackupDevice, + GETDATE() AS backupfinishdate, + #CTE.backup_size, + '000000000000000000000' AS first_lsn, + '999999999999999999999' AS last_lsn, + #CTE.fork_point_lsn, + '00000000-0000-0000-0000-000000000000' AS first_recovery_fork_guid, + '00000000-0000-0000-0000-000000000000' AS last_recovery_fork_guid + + FROM sys.databases d + + INNER JOIN #CTE + ON #CTE.database_name = d.name + + LEFT OUTER JOIN #ForkPointsCount fpc + ON fpc.database_name = #CTE.database_name + + WHERE #CTE.[type] = 'D' + AND ISNULL(fpc.ForkPoints,0) > 1 + + -------------------------------------------------------------- + UNION -- WITH MOVE secondary data files, allows for up to 32769/2 file groups + -------------------------------------------------------------- + + SELECT + + -- Comment out all commands if multiple forking points exist + --CASE WHEN @CommentOut = 1 THEN ' -- Multipe backup fork points detected, command suppressed -- ' ELSE '' END + + + ' ,MOVE N' + '''' + b.name + '''' + ' TO N' + '''' + + + CASE b.type_desc + + WHEN 'ROWS' THEN + CASE ISNULL(@WithMoveDataFiles_,'Actual') + WHEN 'Actual' THEN CASE ISNULL(@TargetDatabase_,'') WHEN '' THEN b.Physical_Name ELSE SUBSTRING(b.Physical_Name,1,CASE CHARINDEX('.',b.Physical_Name) WHEN 0 THEN LEN(b.Physical_Name) ELSE CHARINDEX('.',b.Physical_Name) - 1 END) + '_' + @TargetDatabase_ + '.ndf' END + ELSE CASE ISNULL(@TargetDatabase_,'') WHEN '' THEN @WithMoveDataFiles_ + SUBSTRING(b.Physical_Name,LEN(b.Physical_Name) - CHARINDEX('\',REVERSE(b.Physical_Name),1) + 2,CHARINDEX('\',REVERSE(b.Physical_Name),1) + 1) + ELSE @WithMoveDataFiles_ + SUBSTRING (b.Physical_Name, (LEN(b.Physical_Name)-CHARINDEX('\',REVERSE(b.Physical_Name)) + 2),CHARINDEX('\',REVERSE(b.Physical_Name)) - 1 - CHARINDEX('.',REVERSE(b.Physical_Name))) + '_' + @TargetDatabase_ + '.ndf' END + END + + WHEN 'FILESTREAM' THEN + CASE ISNULL(@WithMoveFileStreamFile_,'Actual') + WHEN 'Actual' THEN CASE ISNULL(@TargetDatabase_,'') WHEN '' THEN b.Physical_Name ELSE SUBSTRING(b.Physical_Name,1,CASE CHARINDEX('.',b.Physical_Name) WHEN 0 THEN LEN(b.Physical_Name) ELSE CHARINDEX('.',b.Physical_Name) - 1 END) + '_' + @TargetDatabase_ END + ELSE CASE ISNULL(@TargetDatabase_,'') WHEN '' THEN @WithMoveFileStreamFile_ + SUBSTRING(b.Physical_Name,LEN(b.Physical_Name) - CHARINDEX('\',REVERSE(b.Physical_Name),1) + 2,CHARINDEX('\',REVERSE(b.Physical_Name),1) + 1) + ELSE @WithMoveFileStreamFile_ + SUBSTRING (b.Physical_Name, (LEN(b.Physical_Name)-CHARINDEX('\',REVERSE(b.Physical_Name)) + 2),CHARINDEX('\',REVERSE(b.Physical_Name)) - 1 - CHARINDEX('.',REVERSE(b.Physical_Name))) + '_' + @TargetDatabase_ END + END + + WHEN 'LOG' THEN + CASE ISNULL(@WithMoveLogFile_,'Actual') + WHEN 'Actual' THEN CASE ISNULL(@TargetDatabase_,'') WHEN '' THEN b.Physical_Name ELSE SUBSTRING(b.Physical_Name,1,CASE CHARINDEX('.',b.Physical_Name) WHEN 0 THEN LEN(b.Physical_Name) ELSE CHARINDEX('.',b.Physical_Name) - 1 END) + '_' + @TargetDatabase_ + '.ldf' END + ELSE CASE ISNULL(@TargetDatabase_,'') WHEN '' THEN @WithMoveLogFile_ + SUBSTRING(b.Physical_Name,LEN(b.Physical_Name) - CHARINDEX('\',REVERSE(b.Physical_Name),1) + 2,CHARINDEX('\',REVERSE(b.Physical_Name),1) + 1) + ELSE @WithMoveLogFile_ + SUBSTRING (b.Physical_Name, (LEN(b.Physical_Name)-CHARINDEX('\',REVERSE(b.Physical_Name)) + 2),CHARINDEX('\',REVERSE(b.Physical_Name)) - 1 - CHARINDEX('.',REVERSE(b.Physical_Name))) + '_' + @TargetDatabase_ + '.ldf' END + + END + + END + + + '''', + b.file_id AS Sequence, + DB_NAME(b.database_id) AS database_name, + 'SECONDARY FULL' AS BackupDevice, + #CTE.backupfinishdate, + #CTE.backup_size, + #CTE.first_lsn, + #CTE.last_lsn, + #CTE.fork_point_lsn, + #CTE.first_recovery_fork_guid, + #CTE.last_recovery_fork_guid + + FROM sys.master_files b + INNER JOIN #CTE + ON #CTE.database_name = DB_NAME(b.database_id) + + LEFT OUTER JOIN #ForkPointsCount fpc + ON fpc.database_name = #CTE.database_name + + WHERE #CTE.[type] = 'D' + AND b.type_desc IN ('ROWS','FILESTREAM','LOG') + AND b.file_id > 2 + AND ISNULL(fpc.ForkPoints,0) < 2 + + -------------------------------------------------------------- + ) a + LEFT OUTER JOIN #tmpDatabases b + ON a.database_name = b.DatabaseName + -------------------------------------------------------------- + + WHERE (@Database_ IS NULL OR b.Selected = 1 OR @Database_ = a.database_name) + AND (@IncludeSystemDBs_ = 1 OR a.database_name NOT IN('master','model','msdb')) + AND a.last_lsn >= @LogShippingLastLSN_; + + CREATE INDEX IDX_RestoreGeneResults ON #RestoreGeneResults (database_name,SortSequence,BackupDate); + + -------------------------------------------------------------- + -- Result Set + IF @SuppressWithMove_ = 1 + BEGIN + IF @RestoreScriptOnly_ = 0 + BEGIN + + SELECT x4.TSQL, x4.BackupDate, x4.BackupDevice, x4.first_lsn, x4.last_lsn, x4.fork_point_lsn, x4.first_recovery_fork_guid, x4.last_recovery_fork_guid, x4.database_name, x4.SortSequence + FROM #RestoreGeneResults x4 + WHERE ISNULL(x4.BackupDevice,'') <> 'SECONDARY FULL' + ORDER BY + x4.database_name, + x4.SortSequence, + x4.BackupDate + END + ELSE + BEGIN + SELECT x4.TSQL AS [--TSQL] + FROM #RestoreGeneResults x4 + WHERE ISNULL(x4.BackupDevice,'') <> 'SECONDARY FULL' + ORDER BY + x4.database_name, + x4.SortSequence, + x4.BackupDate + END + END + ELSE + BEGIN + IF @PivotWithMove_ = 1 + BEGIN + + IF @RestoreScriptOnly_ = 0 + BEGIN + SELECT + x4.TSQL, x4.BackupDate, x4.BackupDevice, x4.first_lsn, x4.last_lsn, x4.fork_point_lsn, x4.first_recovery_fork_guid, x4.last_recovery_fork_guid, x4.database_name, x4.SortSequence + FROM #RestoreGeneResults x4 + ORDER BY + x4.database_name, + x4.SortSequence, + x4.BackupDate + END + ELSE + BEGIN + SELECT + x4.TSQL AS [--TSQL] + FROM #RestoreGeneResults x4 + ORDER BY + x4.database_name, + x4.SortSequence, + x4.BackupDate + END + + END + ELSE + BEGIN + IF @RestoreScriptOnly_ = 0 + BEGIN + WITH WithMoves AS + ( + SELECT + last_lsn, + STUFF((SELECT ' ' + TSQL FROM #RestoreGeneResults x3 WHERE x3.last_lsn = x2.last_lsn AND ISNULL(x3.BackupDevice,'') = 'SECONDARY FULL' ORDER BY x3.SortSequence FOR XML PATH, TYPE).value('.[1]', 'nvarchar(max)'), 1,1,'') AS WithoveCmds + FROM #RestoreGeneResults x2 + GROUP BY last_lsn + ) + + SELECT + CASE @SuppressWithMove_ WHEN 0 THEN CASE ISNULL(x5.WithoveCmds,'') WHEN '' THEN x4.TSQL ELSE x4.TSQL + ' ' + x5.WithoveCmds END + ELSE x4.TSQL + END AS TSQL, + x4.BackupDate, x4.BackupDevice, x4.first_lsn, x4.last_lsn, x4.fork_point_lsn, x4.first_recovery_fork_guid, x4.last_recovery_fork_guid, x4.database_name, x4.SortSequence + FROM #RestoreGeneResults x4 + LEFT OUTER JOIN WithMoves x5 + ON x4.last_lsn = x5.last_lsn + WHERE ISNULL(x4.BackupDevice,'') <> 'SECONDARY FULL' + ORDER BY + x4.database_name, + x4.SortSequence, + x4.BackupDate + END + ELSE + BEGIN + WITH WithMoves AS + ( + SELECT + last_lsn, + STUFF((SELECT ' ' + TSQL FROM #RestoreGeneResults x3 WHERE x3.last_lsn = x2.last_lsn AND ISNULL(x3.BackupDevice,'') = 'SECONDARY FULL' ORDER BY x3.SortSequence FOR XML PATH, TYPE).value('.[1]', 'nvarchar(max)'), 1,1,'') AS WithoveCmds + FROM #RestoreGeneResults x2 + GROUP BY last_lsn + ) + + SELECT + CASE @SuppressWithMove_ WHEN 0 THEN CASE ISNULL(x5.WithoveCmds,'') WHEN '' THEN x4.TSQL ELSE x4.TSQL + ' ' + x5.WithoveCmds END + ELSE x4.TSQL + END AS [--TSQL] + FROM #RestoreGeneResults x4 + LEFT OUTER JOIN WithMoves x5 + ON x4.last_lsn = x5.last_lsn + WHERE ISNULL(x4.BackupDevice,'') <> 'SECONDARY FULL' + ORDER BY + x4.database_name, + x4.SortSequence, + x4.BackupDate + END + END + END +END +GO diff --git a/Stored_Procedure/sp_RestoreScript.sql b/Stored_Procedure/dbo.sp_RestoreScript.sql similarity index 100% rename from Stored_Procedure/sp_RestoreScript.sql rename to Stored_Procedure/dbo.sp_RestoreScript.sql diff --git a/Stored_Procedure/sp_SQLskills_ExposeColsInIndexLevels.sql b/Stored_Procedure/dbo.sp_SQLskills_ExposeColsInIndexLevels.sql similarity index 100% rename from Stored_Procedure/sp_SQLskills_ExposeColsInIndexLevels.sql rename to Stored_Procedure/dbo.sp_SQLskills_ExposeColsInIndexLevels.sql diff --git a/Stored_Procedure/dbo.sp_SQLskills_helpindex.sql b/Stored_Procedure/dbo.sp_SQLskills_helpindex.sql new file mode 100644 index 00000000..8bcc2d1e --- /dev/null +++ b/Stored_Procedure/dbo.sp_SQLskills_helpindex.sql @@ -0,0 +1,409 @@ +/*============================================================================ + File: sp_SQLskills_helpindex.sql + + Summary: So, what are the included columns?! Do you have a filter? + This is a MODIFIED sp_helpindex script that includes: + - Index IDs + - INCLUDEd columns + - Filtered index columns + - Leaf/tree details for rowstore indexes + - Columns defined for columnstore indexes + Additional details: + - whether or not the index is disabled + - Index usage stats + + Date: February 2016 + + Version: Works on 2008R2 - 2016 (requires: sp_SQLskills_ExposeColsInIndexLevels) +------------------------------------------------------------------------------ + Written by Kimberly L. Tripp, SYSolutions, Inc. + + For more scripts and sample code, check out + http://www.SQLskills.com + + This script is intended only as a supplement to demos and lectures + given by SQLskills instructors. + + THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF + ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED + TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A + PARTICULAR PURPOSE. +============================================================================*/ + +USE [master]; +GO + +IF OBJECTPROPERTY(OBJECT_ID(N'sp_SQLskills_helpindex') + , N'IsProcedure') = 1 + DROP PROCEDURE [dbo].[sp_SQLskills_helpindex]; +GO + +CREATE PROCEDURE dbo.sp_SQLskills_helpindex + @objname nvarchar(776) -- the table to check for indexes +as + +-- June 2016: Support for clustered columnstore as well as removing +-- errors around other index types (hekaton, XML, spatial, etc.) +--September 2013: Correct the output for columnstore indexes. +-- November 2010: Added a column to show if an index is disabled. +-- May 2010: Added tree/leaf columns to the output - this requires the +-- stored procedure: sp_SQLskills_ExposeColsInIndexLevels +-- March 2010: Added index_id to the output (ordered by index_id as well) +-- August 2008: Fixed a bug (missing begin/end block) AND I found +-- a few other issues that people hadn't noticed (yikes!)! +-- April 2008: Updated to add included columns to the output. + + +-- See my blog for updates and/or additional information +-- http://www.SQLskills.com/blogs/Kimberly (Kimberly L. Tripp) + + SET NOCOUNT ON; + + declare @objid int, -- the object id of the table + @indid smallint, -- the index id of an index + @type tinyint, -- the index type + @groupid int, -- the filegroup id of an index + @indname sysname, + @groupname sysname, + @status int, + @keys nvarchar(2126), --Length (16*max_identifierLength)+(15*2)+(16*3) + @inc_columns nvarchar(max), + @inc_Count smallint, + @loop_inc_Count smallint, + @dbname sysname, + @ignore_dup_key bit, + @is_unique bit, + @is_hypothetical bit, + @is_primary_key bit, + @is_unique_key bit, + @is_disabled bit, + @auto_created bit, + @no_recompute bit, + @filter_definition nvarchar(max), + @ColsInTree nvarchar(2126), + @ColsInLeaf nvarchar(max), + @ExecStr nvarchar(max) + + -- Check to see that the object names are local to the current database. + select @dbname = parsename(@objname,3) + if @dbname is null + select @dbname = db_name() + else if @dbname <> db_name() + begin + raiserror(15250,-1,-1) + return (1) + end + + -- Check to see the the table exists and initialize @objid. + select @objid = object_id(@objname) + if @objid is NULL + begin + raiserror(15009,-1,-1,@objname,@dbname) + return (1) + end + + -- OPEN CURSOR OVER INDEXES (skip stats: bug shiloh_51196) + declare ms_crs_ind cursor local static for + select i.index_id, i.[type], i.data_space_id, QUOTENAME(i.name, N']') AS name, + i.ignore_dup_key, i.is_unique, i.is_hypothetical, i.is_primary_key, i.is_unique_constraint, + s.auto_created, s.no_recompute, i.filter_definition, i.is_disabled + from sys.indexes as i + join sys.stats as s + on i.object_id = s.object_id + and i.index_id = s.stats_id + where i.object_id = @objid + open ms_crs_ind + fetch ms_crs_ind into @indid, @type, @groupid, @indname, @ignore_dup_key, @is_unique, @is_hypothetical, + @is_primary_key, @is_unique_key, @auto_created, @no_recompute, @filter_definition, @is_disabled + + -- IF NO INDEX, QUIT + if @@fetch_status < 0 + begin + deallocate ms_crs_ind + raiserror(15472,-1,-1,@objname) -- Object does not have any indexes. + return (0) + end + + -- create temp tables + CREATE TABLE #spindtab + ( + index_name sysname collate database_default NOT NULL, + index_id int, + [type] tinyint, + ignore_dup_key bit, + is_unique bit, + is_hypothetical bit, + is_primary_key bit, + is_unique_key bit, + is_disabled bit, + auto_created bit, + no_recompute bit, + groupname sysname collate database_default NULL, + index_keys nvarchar(2126) collate database_default NULL, -- see @keys above for length descr + filter_definition nvarchar(max), + inc_Count smallint, + inc_columns nvarchar(max), + cols_in_tree nvarchar(2126), + cols_in_leaf nvarchar(max) + ) + + CREATE TABLE #IncludedColumns + ( RowNumber smallint, + [Name] nvarchar(128) + ) + + -- Now check out each index, figure out its type and keys and + -- save the info in a temporary table that we'll print out at the end. + while @@fetch_status >= 0 + begin + -- First we'll figure out what the keys are. + declare @i int, @thiskey nvarchar(131) -- 128+3 + + select @keys = QUOTENAME(index_col(@objname, @indid, 1), N']'), @i = 2 + if (indexkey_property(@objid, @indid, 1, 'isdescending') = 1) + select @keys = @keys + '(-)' + + select @thiskey = QUOTENAME(index_col(@objname, @indid, @i), N']') + if ((@thiskey is not null) and (indexkey_property(@objid, @indid, @i, 'isdescending') = 1)) + select @thiskey = @thiskey + '(-)' + + while (@thiskey is not null ) + begin + select @keys = @keys + ', ' + @thiskey, @i = @i + 1 + select @thiskey = QUOTENAME(index_col(@objname, @indid, @i), N']') + if ((@thiskey is not null) and (indexkey_property(@objid, @indid, @i, 'isdescending') = 1)) + select @thiskey = @thiskey + '(-)' + end + + -- Second, we'll figure out what the included columns are. + select @inc_columns = NULL + + SELECT @inc_Count = count(*) + FROM sys.tables AS tbl + INNER JOIN sys.indexes AS si + ON (si.index_id > 0 + and si.is_hypothetical = 0) + AND (si.object_id=tbl.object_id) + INNER JOIN sys.index_columns AS ic + ON (ic.column_id > 0 + and (ic.key_ordinal > 0 or ic.partition_ordinal = 0 or ic.is_included_column != 0)) + AND (ic.index_id=CAST(si.index_id AS int) AND ic.object_id=si.object_id) + INNER JOIN sys.columns AS clmns + ON clmns.object_id = ic.object_id + and clmns.column_id = ic.column_id + WHERE ic.is_included_column = 1 and + (si.index_id = @indid) and + (tbl.object_id= @objid) + + IF @inc_Count > 0 + BEGIN + DELETE FROM #IncludedColumns + INSERT #IncludedColumns + SELECT ROW_NUMBER() OVER (ORDER BY clmns.column_id) + , clmns.name + FROM sys.tables AS tbl + INNER JOIN sys.indexes AS si + ON (si.index_id > 0 + AND si.is_hypothetical = 0) + AND (si.object_id=tbl.object_id) + INNER JOIN sys.index_columns AS ic + ON (ic.column_id > 0 + AND (ic.key_ordinal > 0 OR ic.partition_ordinal = 0 OR ic.is_included_column != 0)) + AND (ic.index_id=CAST(si.index_id AS int) AND ic.object_id=si.object_id) + INNER JOIN sys.columns AS clmns + ON clmns.object_id = ic.object_id + AND clmns.column_id = ic.column_id + WHERE ic.is_included_column = 1 AND + (si.index_id = @indid) AND + (tbl.object_id= @objid) + + SELECT @inc_columns = QUOTENAME([Name], N']') + FROM #IncludedColumns + WHERE RowNumber = 1 + + SET @loop_inc_Count = 1 + + WHILE @loop_inc_Count < @inc_Count + BEGIN + SELECT @inc_columns = @inc_columns + ', ' + QUOTENAME([Name], N']') + FROM #IncludedColumns WHERE RowNumber = @loop_inc_Count + 1 + SET @loop_inc_Count = @loop_inc_Count + 1 + END + END + + SELECT @groupname = null + + SELECT @groupname = name + FROM sys.data_spaces + WHERE data_space_id = @groupid + + -- Get the column list for the tree and leaf level, for all nonclustered indexes IF + -- the table has a clustered index + + -- Clustered index is non-unique + IF @indid = 1 AND + (SELECT is_unique + FROM sys.indexes + WHERE index_id = 1 + AND object_id = @objid) = 0 + SELECT @ColsInTree = @keys + N', UNIQUIFIER', @ColsInLeaf = N'All columns "included" - the leaf level IS the data row, plus the UNIQUIFIER' + + -- Clustered index AND is unique + IF @indid = 1 AND (SELECT is_unique FROM sys.indexes WHERE index_id = 1 AND object_id = @objid) = 1 + SELECT @ColsInTree = @keys, @ColsInLeaf = N'All columns "included" - the leaf level IS the data row.' + + -- Only run this for nonclustered indexes + IF @indid > 1 + EXEC [sp_SQLskills_ExposeColsInIndexLevels] @objid, @indid, @ColsInTree OUTPUT, @ColsInLeaf OUTPUT; + + -- Nonclustered, non-unique index with non-unique clustered ROWSTORE (type = 1) index + IF @indid > 1 AND @is_unique = 0 + AND (SELECT is_unique + FROM sys.indexes + WHERE index_id = 1 AND type = 1 + AND object_id = @objid) = 0 + SELECT @ColsInTree = @ColsInTree + N', UNIQUIFIER', @ColsInLeaf = @ColsInLeaf + N', UNIQUIFIER' + + -- Nonclustered, unique index with non-unique clustered ROWSTORE (type = 1) index + IF @indid > 1 AND @is_unique = 1 + AND (SELECT is_unique + FROM sys.indexes + WHERE index_id = 1 AND type = 1 + AND object_id = @objid) = 0 + SELECT @ColsInLeaf = @ColsInLeaf + N', UNIQUIFIER' + + -- Nonclustered rowstore on a heap + IF (@indid > 1 AND @type = 2) + AND (SELECT COUNT(*) + FROM sys.indexes + WHERE index_id = 1 + AND object_id = @objid) = 0 -- table is a HEAP + BEGIN + IF (@is_unique_key = 0) + SELECT @ColsInTree = @keys + N', RID' + , @ColsInLeaf = @keys + N', RID' + CASE WHEN @inc_columns IS NOT NULL THEN N', ' + @inc_columns ELSE N'' END + + IF (@is_unique_key = 1) + SELECT @ColsInTree = @keys + , @ColsInLeaf = @keys + N', RID' + CASE WHEN @inc_columns IS NOT NULL THEN N', ' + @inc_columns ELSE N'' END + END + + -- INSERT ROW FOR INDEX + + insert into #spindtab values (@indname, @indid, @type, @ignore_dup_key, @is_unique, @is_hypothetical, + @is_primary_key, @is_unique_key, @is_disabled, @auto_created, @no_recompute, @groupname, @keys, @filter_definition, @inc_Count, @inc_columns, @ColsInTree, @ColsInLeaf) + + -- Next index + fetch ms_crs_ind into @indid, @type, @groupid, @indname, @ignore_dup_key, @is_unique, @is_hypothetical, + @is_primary_key, @is_unique_key, @auto_created, @no_recompute, @filter_definition, @is_disabled + end + deallocate ms_crs_ind + + -- DISPLAY THE RESULTS + +-- Query by version + IF CONVERT(smallint, SUBSTRING(CONVERT(varchar(50), SERVERPROPERTY('ProductVersion')), 1, 2)) < 16 + + select @ExecStr = + + N'select ' + + N'''index_id'' = index_id, ' + + N'''is_disabled'' = is_disabled, ' + + N'''index_name'' = index_name, ' + + N'''index_description'' = ' + + N' convert(varchar(210), ' --bits 16 off, 1, 2, 16777216 on, located on group ' + + N' case when index_id = 1 and type = 1 then ''clustered'' ' + + N' when index_id = 1 and type = 5 then ''clustered, columnstore'' ' + + N' when index_id > 1 and type = 2 then ''nonclustered'' ' + + N' when index_id > 1 and type = 6 then ''nonclustered, columnstore'' ' + + N' when index_id > 1 and type = 7 then ''nonclustered, HASH'' ' + + N' else ''new index type'' end ' + + N' + case when ignore_dup_key <>0 then '', ignore duplicate keys'' else '''' end ' + + N' + case when is_unique=1 then '', unique'' else '''' end ' + + N' + case when is_hypothetical <>0 then '', hypothetical'' else '''' end ' + + N' + case when is_primary_key <>0 then '', primary key'' else '''' end ' + + N' + case when is_unique_key <>0 then '', unique key'' else '''' end ' + + N' + case when auto_created <>0 then '', auto create'' else '''' end ' + + N' + case when no_recompute <>0 then '', stats no recompute'' else '''' end ' + + N' + case when groupname IS NOT NULL then '' located on '' + groupname else '''' end), ' + + N'''index_keys'' = + case when type IN (5, 6) then ''n/a, see columns_in_leaf for details'' + else index_keys end, + ''included_columns'' = + case when type IN (5, 6) then ''n/a, columnstore index'' + when type = 7 then ''n/a, HASH'' + else inc_columns end, + ''filter_definition'' = + case when type IN (5, 6) then ''n/a, columnstore index'' + when type = 7 then ''n/a, HASH'' + else filter_definition end, + ''columns_in_tree'' = + case when type IN (5, 6) then ''n/a, columnstore index'' + when type = 7 then ''n/a, HASH'' + else cols_in_tree end, + ''columns_in_leaf'' = + case when type IN (5, 6) then ''Columns with columnstore index: '' + cols_in_leaf + when type = 7 then ''n/a, HASH'' + else cols_in_leaf end + + from #spindtab + order by index_id ' + + IF CONVERT(smallint, SUBSTRING(CONVERT(varchar(50), SERVERPROPERTY('ProductVersion')), 1, 2)) >= 16 + + select @ExecStr = + + N'select ' + + N'''index_id'' = index_id, ' + + N'''is_disabled'' = is_disabled, ' + + N'''index_name'' = index_name, ' + + N'''index_description'' = ' + + N' convert(varchar(210), ' --bits 16 off, 1, 2, 16777216 on, located on group ' + + N' case when index_id = 1 and type = 1 then ''clustered'' ' + + N' when index_id = 1 and type = 5 then ''clustered, columnstore'' ' + + N' when index_id > 1 and type = 2 then ''nonclustered'' ' + + N' when index_id > 1 and type = 6 then ''nonclustered, columnstore'' ' + + N' when index_id > 1 and type = 7 then ''nonclustered, HASH'' ' + + N' else ''new index type'' end ' + + N' + case when ignore_dup_key <>0 then '', ignore duplicate keys'' else '''' end ' + + N' + case when is_unique=1 then '', unique'' else '''' end ' + + N' + case when is_hypothetical <>0 then '', hypothetical'' else '''' end ' + + N' + case when is_primary_key <>0 then '', primary key'' else '''' end ' + + N' + case when is_unique_key <>0 then '', unique key'' else '''' end ' + + N' + case when auto_created <>0 then '', auto create'' else '''' end ' + + N' + case when no_recompute <>0 then '', stats no recompute'' else '''' end ' + + N' + case when memory_optimized = 1 then '' located in MEMORY '' else '''' end ' + + N' + case when groupname IS NOT NULL AND + (memory_optimized = 0 OR memory_optimized IS NULL) + then '' located on '' + groupname else '''' end), ' + + N'''index_keys'' = + case when type IN (5, 6) then ''n/a, see columns_in_leaf for details'' + else index_keys end, + ''included_columns'' = + case when type IN (5, 6) then ''n/a, columnstore index'' + when type = 7 then ''n/a, HASH'' + else inc_columns end, + ''filter_definition'' = + case when type IN (5, 6) then ''n/a, columnstore index'' + when type = 7 then ''n/a, HASH'' + else filter_definition end, + ''columns_in_tree'' = + case when type IN (5, 6) then ''n/a, columnstore index'' + when type = 7 then ''n/a, HASH'' + else cols_in_tree end, + ''columns_in_leaf'' = + case when type IN (5, 6) then ''Columns with columnstore index: '' + cols_in_leaf + when type = 7 then ''n/a, HASH'' + else cols_in_leaf end + + from #spindtab + order by index_id ' + + --SELECT (@ExecStr) + EXEC (@ExecStr); + + return (0) -- sp_SQLskills_helpindex +GO + +exec [sys].[sp_MS_marksystemobject] 'sp_SQLskills_helpindex' +GO diff --git a/Stored_Procedure/sp_WhatsupQueryStore.sql b/Stored_Procedure/dbo.sp_WhatsupQueryStore.sql similarity index 100% rename from Stored_Procedure/sp_WhatsupQueryStore.sql rename to Stored_Procedure/dbo.sp_WhatsupQueryStore.sql diff --git a/Stored_Procedure/sp_capture_login_auth.sql b/Stored_Procedure/dbo.sp_capture_login_auth.sql similarity index 100% rename from Stored_Procedure/sp_capture_login_auth.sql rename to Stored_Procedure/dbo.sp_capture_login_auth.sql diff --git a/Stored_Procedure/sp_ctrl3.sql b/Stored_Procedure/dbo.sp_ctrl3.sql similarity index 100% rename from Stored_Procedure/sp_ctrl3.sql rename to Stored_Procedure/dbo.sp_ctrl3.sql diff --git a/Stored_Procedure/dbo.sp_doc.sql b/Stored_Procedure/dbo.sp_doc.sql new file mode 100644 index 00000000..51f01222 --- /dev/null +++ b/Stored_Procedure/dbo.sp_doc.sql @@ -0,0 +1,1432 @@ +SET ANSI_NULLS ON; +GO + +SET QUOTED_IDENTIFIER ON; +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'Description' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_doc', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'Description' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_doc'; + END +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@SqlMinorVersion' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_doc', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@SqlMinorVersion' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_doc'; + END +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@SqlMajorVersion' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_doc', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@SqlMajorVersion' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_doc'; + END +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@ExtendedPropertyName' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_doc', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@ExtendedPropertyName' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_doc'; + END +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@DatabaseName' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_doc', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@DatabaseName' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_doc'; + END +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@LimitStoredProcLength' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_doc', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@LimitStoredProcLength' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_doc'; + END +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@Emojis' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_doc', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@Emojis' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_doc'; + END +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@Verbose' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_doc', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@Verbose' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_doc'; + END +GO + +/***************************/ +/* Create stored procedure */ +/***************************/ +IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_doc]') AND [type] IN (N'P', N'PC')) +BEGIN +EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[sp_doc] AS'; +END +GO + +ALTER PROCEDURE [dbo].[sp_doc] + @DatabaseName SYSNAME = NULL + ,@ExtendedPropertyName SYSNAME = 'Description' + ,@LimitStoredProcLength BIT = 1 + ,@Emojis BIT = 0 + ,@Verbose BIT = 1 + /* Parameters defined here for testing only */ + ,@SqlMajorVersion TINYINT = 0 + ,@SqlMinorVersion SMALLINT = 0 +WITH RECOMPILE +AS + +/* +sp_doc - Always have current documentation by generating it on the fly in markdown. + +Part of the DBA MultiTool http://dba-multitool.org + +Version: 20201221 + +MIT License + +Copyright (c) 2020 John McCall + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, +and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial +portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +========= + +Example: + + EXEC sp_doc @DatabaseName = 'WideWorldImporters'; + +*/ + +BEGIN + SET NOCOUNT ON; + + DECLARE @Sql NVARCHAR(MAX) + ,@ParmDefinition NVARCHAR(500) + ,@QuotedDatabaseName SYSNAME + ,@Msg NVARCHAR(MAX) + ,@SensitivityClassification BIT + -- Variables used for Emoji mode + ,@Yes VARCHAR(20) = 'yes' + ,@No VARCHAR(20) = 'no' + ,@PK VARCHAR(20) = NULL + ,@FK VARCHAR(20) = NULL + ,@Column VARCHAR(20) = NULL; + + -- Find Version + IF (@SqlMajorVersion = 0) + BEGIN; + SET @SqlMajorVersion = CAST(SERVERPROPERTY('ProductMajorVersion') AS TINYINT); + END; + IF (@SqlMinorVersion = 0) + BEGIN; + SET @SqlMinorVersion = CAST(SERVERPROPERTY('ProductMinorVersion') AS TINYINT); + END; + + -- Validate Version + IF (@SqlMajorVersion < 11) + BEGIN; + SET @Msg = 'SQL Server versions below 2012 are not supported, sorry!'; + RAISERROR(@Msg, 16, 1); + END; + + -- Check database name + IF (@DatabaseName IS NULL) + BEGIN + SET @DatabaseName = DB_NAME(); + IF (@Verbose = 1) + BEGIN; + SET @Msg = 'No database provided, assuming current database.'; + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + END + ELSE IF (DB_ID(@DatabaseName) IS NULL) + BEGIN; + SET @Msg = 'Database not available.'; + RAISERROR(@Msg, 16, 1); + END; + + SET @QuotedDatabaseName = QUOTENAME(@DatabaseName); --Avoid injections + + -- Check Emoji Mode + IF (@Emojis = 1) + BEGIN; + SET @Yes = ':heavy_check_mark:'; + SET @No = ':x:'; + SET @PK = ':key: '; + SET @FK = ':old_key: '; + SET @Column = ':page_facing_up: '; + END; + + -- Check for Sensitivity Classifications + IF EXISTS (SELECT 1 FROM [sys].[system_views] WHERE [name] = 'sensitivity_classifications') + BEGIN + SET @Sql = N'USE ' + @QuotedDatabaseName + '; + IF EXISTS (SELECT 1 FROM [sys].[sensitivity_classifications]) + BEGIN + SET @SensitivityClassification = 1; + END; + ELSE + BEGIN + SET @SensitivityClassification = 0; + END;'; + SET @ParmDefinition = N'@SensitivityClassification BIT OUTPUT'; + EXEC sp_executesql @Sql + ,@ParmDefinition + ,@SensitivityClassification OUTPUT; + END; + + --Create table to hold EP data + SET @Sql = N'USE ' + @QuotedDatabaseName + '; + CREATE TABLE #markdown ( + [id] INT IDENTITY(1,1), + [value] NVARCHAR(MAX));'; + + /****************************** + Generate markdown for database + ******************************/ + --Database Name + SET @Sql = @Sql + N' + INSERT INTO #markdown (value) + VALUES (CONCAT(''# '', @DatabaseName) COLLATE DATABASE_DEFAULT);' + + + --Database extended properties + + N'INSERT INTO #markdown (value) + SELECT CONCAT(CHAR(13), CHAR(10), CAST([value] AS VARCHAR(8000))) + FROM [sys].[extended_properties] AS [ep] + WHERE [ep].[class] = 0 + AND [ep].[name] = @ExtendedPropertyName;' + + + --Database metadata + + N'INSERT INTO #markdown (value) + VALUES (CONCAT(CHAR(13), CHAR(10), ''| Property | Value |'')) + ,(''| --- | --- |''); + + INSERT INTO #markdown + SELECT CONCAT(''| '', ''SQL Server Version'', '' | '', CAST(SERVERPROPERTY(''ProductVersion'') AS SYSNAME), '' |'') + UNION ALL + SELECT CONCAT(''| '', ''Compatibility Level'', '' | '', [compatibility_level], '' |'') + FROM [sys].[databases] + WHERE [name] = DB_NAME() + UNION ALL + SELECT CONCAT(''| '', ''Collation'', '' | '', [collation_name], '' |'') + FROM [sys].[databases] + WHERE [name] = DB_NAME(); + ' + + + /**************************** + Generate markdown for tables + ****************************/ + --Variables + + N'DECLARE @objectid INT, + @indexobjectid INT, + @TrigObjectId INT, + @CheckConstObjectId INT, + @DefaultConstObjectId INT; + + DECLARE @key_columns NVARCHAR(MAX), + @include_columns NVARCHAR(MAX);'; + + --Build table of contents + SET @Sql = @Sql + N' + IF EXISTS (SELECT 1 FROM [sys].[tables] WHERE [type] = ''U'' AND [is_ms_shipped] = 0) + BEGIN + INSERT INTO #markdown (value) + VALUES (''----'') + ,(CONCAT(CHAR(13), CHAR(10), ''## Tables'')) + ,(CONCAT(CHAR(13), CHAR(10), ''
Click to expand'', CHAR(13), CHAR(10))); + ' + + + + N'INSERT INTO #markdown (value) + SELECT CONCAT(''* ['', OBJECT_SCHEMA_NAME(object_id), ''.'', OBJECT_NAME(object_id), ''](#'', REPLACE(LOWER(OBJECT_SCHEMA_NAME(object_id)), '' '', ''-''), REPLACE(LOWER(OBJECT_NAME(object_id)), '' '', ''-''), '')'') + FROM [sys].[tables] + WHERE [type] = ''U'' + AND [is_ms_shipped] = 0 + ORDER BY OBJECT_SCHEMA_NAME([object_id]), [name] ASC;' + + + --Object details + + N'DECLARE obj_cursor CURSOR + LOCAL STATIC READ_ONLY FORWARD_ONLY + FOR + SELECT [object_id] + FROM [sys].[tables] + WHERE [type] = ''U'' + AND [is_ms_shipped] = 0 + ORDER BY OBJECT_SCHEMA_NAME([object_id]), [name] ASC; + + OPEN obj_cursor + FETCH NEXT FROM obj_cursor INTO @objectid + WHILE @@FETCH_STATUS = 0 + BEGIN + + INSERT INTO #markdown + SELECT CONCAT(CHAR(13), CHAR(10), ''### '', OBJECT_SCHEMA_NAME(@objectid), ''.'', OBJECT_NAME(@objectid));' + + + --Extended Properties + + N'INSERT INTO #markdown + SELECT CONCAT(CHAR(13), CHAR(10), CAST([ep].[value] AS NVARCHAR(4000))) + FROM [sys].[tables] AS [t] WITH(NOLOCK) + INNER JOIN [sys].[extended_properties] AS [ep] WITH(NOLOCK) ON [t].[object_id] = [ep].[major_id] + WHERE [t].[object_id] = @objectid + AND [ep].[minor_id] = 0 --On the table + AND [ep].[name] = @ExtendedPropertyName;'; + + + IF @SensitivityClassification = 1 + BEGIN + SET @Sql = @Sql + N' + INSERT INTO #markdown (value) + VALUES (CONCAT(CHAR(13), CHAR(10), ''| Column | Type | Null | Foreign Key | Default | '', @ExtendedPropertyName COLLATE DATABASE_DEFAULT, '' | Classification |'')) + ,(''| --- | --- | --- | --- | --- | --- | --- |'');'; + END + ELSE + BEGIN + SET @Sql = @Sql + N' + INSERT INTO #markdown (value) + VALUES (CONCAT(CHAR(13), CHAR(10), ''| Column | Type | Null | Foreign Key | Default | '', @ExtendedPropertyName COLLATE DATABASE_DEFAULT, '' |'')) + ,(''| --- | --- | --- | --- | --- | --- |'');'; + END; + + --Columns + SET @Sql = @Sql + N' + INSERT INTO #markdown + SELECT CONCAT(''| '' + ,CASE + WHEN [ic].[object_id] IS NOT NULL + THEN CONCAT(@PK, ''**'',[c].[name],''**'') + WHEN [fk].[parent_object_id] IS NOT NULL + THEN CONCAT(@FK, [c].[name]) + ELSE CONCAT(@Column, [c].[name]) + END + ,'' | '' + ,CONCAT(UPPER(TYPE_NAME([user_type_id])) + ,CASE + WHEN TYPE_NAME([user_type_id]) IN (N''decimal'',N''numeric'') + THEN CONCAT(N''('',CAST(precision AS varchar(5)), N'','',CAST(scale AS varchar(5)), N'')'') + WHEN TYPE_NAME([user_type_id]) IN (''varchar'', ''char'', ''varbinary'') + THEN CASE + WHEN [max_length] = -1 + THEN N''(MAX)'' + ELSE QUOTENAME(CAST([max_length] AS VARCHAR(10)), ''('') + END + WHEN TYPE_NAME([user_type_id]) IN (N''time'',N''datetime2'',N''datetimeoffset'') + THEN QUOTENAME(CAST(scale AS varchar(5)), ''('') + WHEN TYPE_NAME([user_type_id]) in (N''float'') + THEN CASE + WHEN [c].precision = 53 + THEN N'''' + ELSE CONCAT(N''('',CAST([c].precision AS varchar(5)),N'')'') + END + WHEN TYPE_NAME([c].user_type_id) IN (N''int'',N''bigint'',N''smallint'',N''tinyint'',N''money'',N''smallmoney'', + N''real'',N''datetime'',N''smalldatetime'',N''bit'',N''image'',N''text'',N''uniqueidentifier'', + N''date'',N''ntext'',N''sql_variant'',N''hierarchyid'',''geography'',N''timestamp'',N''xml'') + THEN N'''' + WHEN TYPE_NAME([user_type_id]) IN (N''nvarchar'',N''nchar'', N''sysname'') + THEN CASE + WHEN [max_length] = -1 + THEN N''(MAX)'' + ELSE QUOTENAME(CAST([max_length]/2 AS VARCHAR(10)), ''('') + END + ELSE QUOTENAME(CAST([max_length] AS VARCHAR(10)), ''('') + END) + ,'' | '' + ,CASE [c].[is_nullable] + WHEN 1 + THEN @Yes + ELSE @No + END + ,'' | '' + ,CASE + WHEN [fk].[parent_object_id] IS NOT NULL + THEN CONCAT(''['',QUOTENAME(OBJECT_SCHEMA_NAME([fk].[referenced_object_id])), ''.'', QUOTENAME(OBJECT_NAME([fk].[referenced_object_id])), ''.'', QUOTENAME(COL_NAME([fk].[referenced_object_id], [fk].[referenced_column_id])),'']'',''(#'',LOWER(OBJECT_SCHEMA_NAME([fk].[referenced_object_id])), LOWER(OBJECT_NAME([fk].[referenced_object_id])), '')'') + ELSE '''' + END + ,'' | '' + ,OBJECT_DEFINITION([dc].[object_id]) + ,'' | '' + ,CAST([ep].[value] AS NVARCHAR(4000)) + ,'' |'''; + IF @SensitivityClassification = 1 + BEGIN + SET @Sql = @Sql + N' + ,CASE + WHEN [sc].[label] IS NOT NULL + THEN CONCAT('' Label: '', CAST([sc].[Label] AS SYSNAME), ''
'', ''Type: '', CAST([sc].[Information_Type] AS SYSNAME), ''
'', ''Rank: '', CAST([Rank_Desc] AS SYSNAME), ''
'') + ELSE '' '' + END + ,'' |'''; + END + SET @Sql = @Sql + N')'; + SET @Sql = @Sql + N' + FROM [sys].[tables] AS [t] WITH(NOLOCK) + INNER JOIN [sys].[columns] AS [c] WITH(NOLOCK) ON [t].[object_id] = [c].[object_id] + LEFT JOIN [sys].[extended_properties] AS [ep] WITH(NOLOCK) ON [t].[object_id] = [ep].[major_id] + AND [ep].[minor_id] > 0 + AND [ep].[minor_id] = [c].[column_id] + AND [ep].[class] = 1 --Object/col + AND [ep].[name] = @ExtendedPropertyName + LEFT JOIN [sys].[foreign_key_columns] AS [fk] WITH(NOLOCK) ON [fk].[parent_object_id] = [c].[object_id] + AND [fk].[parent_column_id] = [c].[column_id] + LEFT JOIN [sys].[default_constraints] AS [dc] WITH(NOLOCK) ON [dc].[parent_object_id] = [c].[object_id] + AND [dc].[parent_column_id] = [c].[column_id] + LEFT JOIN [sys].[indexes] AS [pk] WITH(NOLOCK) ON [pk].[object_id] = [t].[object_id] + AND [pk].[is_primary_key] = 1 + LEFT JOIN [sys].[index_columns] AS [ic] WITH(NOLOCK) ON [ic].[index_id] = [pk].[index_id] + AND [ic].[object_id] = [t].[object_id] + AND [ic].[column_id] = [c].[column_id]'; + + IF @SensitivityClassification = 1 + BEGIN + SET @Sql = @Sql + N' + LEFT JOIN [sys].[sensitivity_classifications] AS [sc] WITH(NOLOCK) ON [sc].[major_id] = [t].[object_id] + AND [sc].[minor_id] = [c].[column_id]'; + END; + + SET @Sql = @Sql + N' + WHERE [t].[object_id] = @objectid;' + + + --Indexes + + N'IF EXISTS (SELECT 1 FROM [sys].[indexes] WHERE [object_id] = @objectid AND [type] > 0) + BEGIN + INSERT INTO #markdown + SELECT CONCAT(CHAR(13), CHAR(10), ''#### '', ''Indexes'') + DECLARE [index_cursor] CURSOR + LOCAL STATIC READ_ONLY FORWARD_ONLY + FOR + SELECT [ind].[index_id] + FROM [sys].[indexes] AS [ind] + WHERE [ind].[object_id] = @objectId + AND [ind].[type] > 0 -- Not heap + ORDER BY [ind].[is_primary_key] DESC, [ind].[is_unique_constraint] DESC, [ind].[name] DESC + + INSERT INTO #markdown (value) + VALUES (CONCAT(CHAR(13), CHAR(10), ''| Name | Type | Key Columns | Include Columns | '', @ExtendedPropertyName COLLATE DATABASE_DEFAULT, '' |'')) + ,(''| --- | --- | --- | --- | --- |''); + + OPEN [index_cursor] + FETCH NEXT FROM [index_cursor] INTO @indexobjectid + WHILE @@FETCH_STATUS = 0 + BEGIN + ' + + + -- Get key columns as a csv list + + N'SELECT @key_columns = STUFF(( + SELECT CONCAT('', '', QUOTENAME([col].[name])) + FROM [sys].[indexes] AS [ind] + INNER JOIN [sys].[index_columns] AS [ic] ON [ind].[object_id] = [ic].[object_id] + AND [ic].[index_id] = [ind].[index_id] + INNER JOIN [sys].[columns] AS [col] ON [ic].[object_id] = [col].[object_id] + AND [ic].[column_id] = [col].[column_id] + WHERE [ind].[object_id] = @objectid + AND [ind].[index_id] = @indexobjectid + AND [ic].[is_included_column] = 0 + FOR XML PATH('''') + ), 1, 2, ''''); ' + + + -- Get included columns as a csv list + + N'SELECT @include_columns = STUFF(( + SELECT CONCAT('', '', QUOTENAME([col].[name])) + FROM [sys].[indexes] AS [ind] + INNER JOIN [sys].[index_columns] AS [ic] ON [ind].[object_id] = [ic].[object_id] + AND [ic].[index_id] = [ind].[index_id] + INNER JOIN [sys].[columns] AS [col] ON [ic].[object_id] = [col].[object_id] + AND [ic].[column_id] = [col].[column_id] + WHERE [ind].[object_id] = @objectid + AND [ind].[index_id] = @indexobjectid + AND [ic].[is_included_column] = 1 + FOR XML PATH('''') + ), 1, 2, ''''); + + INSERT INTO #markdown (value) + SELECT CONCAT(''| '' + ,CASE + WHEN [ind].[is_primary_key] = 1 + THEN CONCAT(@PK, ''**'',[ind].[name],''**'') + ELSE [ind].[name] + END + , '' | '' + , LOWER([ind].[type_desc]) COLLATE DATABASE_DEFAULT + , '' | '' + , @key_columns COLLATE DATABASE_DEFAULT + , '' | '' + , @include_columns COLLATE DATABASE_DEFAULT + , '' | '' + , CAST([ep].[value] AS NVARCHAR(4000)) COLLATE DATABASE_DEFAULT + , '' |'') + FROM [sys].[indexes] AS [ind] + LEFT JOIN [sys].[extended_properties] AS [ep] ON [ind].[object_id] = [ep].[major_id] + AND [ep].[minor_id] = [ind].[index_id] + AND [ep].[class] = 7 -- Index + AND [ep].[name] = @ExtendedPropertyName + WHERE [ind].[object_id] = @objectid + AND [ind].[index_id] = @indexobjectid; + + FETCH NEXT FROM [index_cursor] INTO @indexobjectid; + END; + + CLOSE [index_cursor]; + DEALLOCATE [index_cursor]; + END; + ' + + + --Triggers + + N'IF EXISTS (SELECT * FROM [sys].[triggers] WHERE [parent_id] = @objectid) + BEGIN + INSERT INTO #markdown + SELECT CONCAT(CHAR(13), CHAR(10), ''#### '', ''Triggers'') + DECLARE [trig_cursor] CURSOR + LOCAL STATIC READ_ONLY FORWARD_ONLY + FOR + SELECT [object_id] + FROM [sys].[triggers] + WHERE [parent_id] = @objectId + ORDER BY OBJECT_SCHEMA_NAME([object_id]), [name] ASC; + + OPEN [trig_cursor] + FETCH NEXT FROM [trig_cursor] INTO @TrigObjectId + WHILE @@FETCH_STATUS = 0 + BEGIN + INSERT INTO #markdown (value) + VALUES (CONCAT(''##### '', OBJECT_SCHEMA_NAME(@TrigObjectId), ''.'', OBJECT_NAME(@TrigObjectId))) + ,(CONCAT(''###### '', ''Definition'')) + ,(CONCAT(''
Click to expand'', CHAR(13), CHAR(10)));' + + + --Object definition + + N'INSERT INTO #markdown (value) + VALUES (CONCAT(CHAR(13), CHAR(10), ''```sql'', + CHAR(13), CHAR(10), OBJECT_DEFINITION(@CheckConstObjectId))) + ,(''```''); + + INSERT INTO #markdown (value) + VALUES (CONCAT(CHAR(13), CHAR(10), ''
'')) + + FETCH NEXT FROM [trig_cursor] INTO @TrigObjectId; + END; + + CLOSE [trig_cursor]; + DEALLOCATE [trig_cursor]; + END;' + + + --Check Constraints + + N'IF EXISTS (SELECT 1 FROM [sys].[check_constraints] WHERE [parent_object_id] = @objectid) + BEGIN + INSERT INTO #markdown + SELECT CONCAT(CHAR(13), CHAR(10), ''#### '', ''Check Constraints'') + DECLARE [check_cursor] CURSOR + LOCAL STATIC READ_ONLY FORWARD_ONLY + FOR + SELECT [object_id] + FROM [sys].[check_constraints] + WHERE [parent_object_id] = @objectid + ORDER BY OBJECT_SCHEMA_NAME(object_id), [name] ASC; + + OPEN [check_cursor] + FETCH NEXT FROM [check_cursor] INTO @CheckConstObjectId + WHILE @@FETCH_STATUS = 0 + BEGIN + INSERT INTO #markdown + VALUES (CONCAT(CHAR(13), CHAR(10),''##### '', OBJECT_SCHEMA_NAME(@CheckConstObjectId), ''.'', OBJECT_NAME(@CheckConstObjectId))) + ,(CONCAT(CHAR(13), CHAR(10),''###### '', ''Definition'')) + ,(CONCAT(CHAR(13), CHAR(10),''
Click to expand''));' + + + --Object definition + + N'INSERT INTO #markdown (value) + VALUES (CONCAT(CHAR(13), CHAR(10), ''```sql'', + CHAR(13), CHAR(10), OBJECT_DEFINITION(@CheckConstObjectId))) + ,(''```''); + + INSERT INTO #markdown + VALUES (CONCAT(CHAR(13), CHAR(10), ''
'')) + + FETCH NEXT FROM [check_cursor] INTO @CheckConstObjectId; + END; + + CLOSE [check_cursor]; + DEALLOCATE [check_cursor]; + END;' + + + --Back to top + + N'INSERT INTO #markdown + VALUES (CONCAT(CHAR(13), CHAR(10), ''[Back to top](#'', LOWER(@DatabaseName COLLATE DATABASE_DEFAULT), '')'')) + + FETCH NEXT FROM obj_cursor INTO @objectid; + + END; + CLOSE obj_cursor; + DEALLOCATE obj_cursor;' + + + --End collapsible table section + + N'INSERT INTO #markdown + VALUES (CONCAT(CHAR(13), CHAR(10), ''
'')); + END;'; --End markdown for tables + + /*************************** + Generate markdown for views + ***************************/ + --Build table of contents + SET @Sql = @Sql + N' + IF EXISTS (SELECT 1 FROM [sys].[views] WHERE [is_ms_shipped] = 0) + BEGIN; + INSERT INTO #markdown (value) + VALUES (CONCAT(CHAR(13), CHAR(10), ''## Views'')) ,(CONCAT(CHAR(13), CHAR(10), ''
Click to expand'', CHAR(13), CHAR(10))); + ' + + + + N'INSERT INTO #markdown (value) + SELECT CONCAT(''* ['', OBJECT_SCHEMA_NAME(object_id), ''.'', OBJECT_NAME(object_id), ''](#'', REPLACE(LOWER(OBJECT_SCHEMA_NAME(object_id)), '' '', ''-''), REPLACE(LOWER(OBJECT_NAME(object_id)), '' '', ''-''), '')'') + FROM [sys].[views] + WHERE [is_ms_shipped] = 0 + ORDER BY OBJECT_SCHEMA_NAME([object_id]), [name] ASC;' + + + --Object details + + N'DECLARE obj_cursor CURSOR + LOCAL STATIC READ_ONLY FORWARD_ONLY + FOR + SELECT [object_id] + FROM [sys].[views] + WHERE [is_ms_shipped] = 0 + ORDER BY OBJECT_SCHEMA_NAME([object_id]), [name] ASC; + + OPEN obj_cursor + FETCH NEXT FROM obj_cursor INTO @objectid + WHILE @@FETCH_STATUS = 0 + BEGIN + + INSERT INTO #markdown + SELECT CONCAT(CHAR(13), CHAR(10), ''### '', OBJECT_SCHEMA_NAME(@objectid), ''.'', OBJECT_NAME(@objectid));' + + + --Extended Properties + + N'INSERT INTO #markdown + SELECT CAST([ep].[value] AS NVARCHAR(4000)) + FROM [sys].[views] AS [v] + INNER JOIN [sys].[extended_properties] AS [ep] ON [v].[object_id] = [ep].[major_id] + WHERE [v].[object_id] = @objectid + AND [ep].[minor_id] = 0 + AND [ep].[name] = @ExtendedPropertyName; + + INSERT INTO #markdown (value) + VALUES (CONCAT(CHAR(13), CHAR(10), ''| Column | Type | Null | '', @ExtendedPropertyName COLLATE DATABASE_DEFAULT, '' |'')) + ,(''| --- | ---| --- | --- |'');' + + + --Projected columns + + N'INSERT INTO #markdown + SELECT CONCAT(''| '', [c].[name] + ,'' | '' + ,CONCAT(UPPER(TYPE_NAME([user_type_id])) + ,CASE + WHEN TYPE_NAME([user_type_id]) IN (N''decimal'',N''numeric'') + THEN CONCAT(N''('',CAST(precision AS varchar(5)), N'','',CAST(scale AS varchar(5)), N'')'') + WHEN TYPE_NAME([user_type_id]) IN (''varchar'', ''char'', ''varbinary'') + THEN CASE + WHEN [max_length] = -1 + THEN N''(MAX)'' + ELSE QUOTENAME(CAST([max_length] AS VARCHAR(10)), ''('') + END + WHEN TYPE_NAME([user_type_id]) IN (N''time'',N''datetime2'',N''datetimeoffset'') + THEN QUOTENAME(CAST(scale AS varchar(5)), ''('') + WHEN TYPE_NAME([user_type_id]) in (N''float'') + THEN CASE + WHEN [c].precision = 53 + THEN N'''' + ELSE CONCAT(N''('',CAST([c].precision AS varchar(5)),N'')'') + END + WHEN TYPE_NAME([c].user_type_id) IN (N''int'',N''bigint'',N''smallint'',N''tinyint'',N''money'',N''smallmoney'', + N''real'',N''datetime'',N''smalldatetime'',N''bit'',N''image'',N''text'',N''uniqueidentifier'', + N''date'',N''ntext'',N''sql_variant'',N''hierarchyid'',''geography'',N''timestamp'',N''xml'') + THEN N'''' + WHEN TYPE_NAME([user_type_id]) IN (N''nvarchar'',N''nchar'', N''sysname'') + THEN CASE + WHEN [max_length] = -1 + THEN N''(MAX)'' + ELSE QUOTENAME(CAST([max_length]/2 AS VARCHAR(10)), ''('') + END + ELSE QUOTENAME(CAST([max_length] AS VARCHAR(10)), ''('') + END) + ,'' | '' + ,CASE [c].[is_nullable] + WHEN 1 + THEN @Yes + ELSE @No + END + ,'' | '' + ,CAST([ep].[value] AS NVARCHAR(4000)) + ,'' |'') + FROM [sys].[views] AS [o] + INNER JOIN [sys].[columns] AS [c] ON [o].[object_id] = [c].[object_id] + LEFT JOIN [sys].[extended_properties] AS [ep] ON [o].[object_id] = [ep].[major_id] + AND [ep].[minor_id] = [c].[column_id] + AND [ep].[name] = @ExtendedPropertyName + WHERE [o].[is_ms_shipped] = 0 -- User objects only + AND [o].[type] = ''V'' -- VIEW + AND [o].[object_id] = @objectid + ORDER BY SCHEMA_NAME([o].[schema_id]), [o].[type_desc], OBJECT_NAME([ep].major_id); + + INSERT INTO #markdown (value) + VALUES(CONCAT(CHAR(13), CHAR(10), ''#### Definition'')) + ,(CONCAT(CHAR(13), CHAR(10), ''
Click to expand''));' + + + --Object definition + + N'INSERT INTO #markdown (value) + VALUES (CONCAT(CHAR(13), CHAR(10), ''```sql'', + CHAR(13), CHAR(10), OBJECT_DEFINITION(@objectid))) + ,(''```'');' + + + --Indexes + + N'IF EXISTS (SELECT 1 FROM [sys].[indexes] WHERE [object_id] = @objectid) + BEGIN + INSERT INTO #markdown + SELECT CONCAT(CHAR(13), CHAR(10), ''#### '', ''Indexes'') + DECLARE [index_cursor] CURSOR + LOCAL STATIC READ_ONLY FORWARD_ONLY + FOR + SELECT [ind].[index_id] + FROM [sys].[indexes] AS [ind] + WHERE [ind].[object_id] = @objectId + AND [ind].[type] > 0 -- Not heap + ORDER BY [ind].[is_primary_key] DESC, [ind].[is_unique_constraint] DESC, [ind].[name] DESC + + INSERT INTO #markdown (value) + VALUES (CONCAT(CHAR(13), CHAR(10), ''| Name | Type | Key Columns | Include Columns | '', @ExtendedPropertyName COLLATE DATABASE_DEFAULT, '' |'')) + ,(''| --- | --- | --- | --- | --- |''); + + OPEN [index_cursor] + FETCH NEXT FROM [index_cursor] INTO @indexobjectid + WHILE @@FETCH_STATUS = 0 + BEGIN + ' + + -- Get key columns as a csv list + + N'SELECT @key_columns = STUFF(( + SELECT CONCAT('', '', QUOTENAME([col].[name])) + FROM [sys].[indexes] AS [ind] + INNER JOIN [sys].[index_columns] AS [ic] ON [ind].[object_id] = [ic].[object_id] + AND [ic].[index_id] = [ind].[index_id] + INNER JOIN [sys].[columns] AS [col] ON [ic].[object_id] = [col].[object_id] + AND [ic].[column_id] = [col].[column_id] + WHERE [ind].[object_id] = @objectid + AND [ind].[index_id] = @indexobjectid + AND [ic].[is_included_column] = 0 + FOR XML PATH('''') + ), 1, 2, ''''); ' + + + -- Get included columns as a csv list + + N'SELECT @include_columns = STUFF(( + SELECT CONCAT('', '', QUOTENAME([col].[name])) + FROM [sys].[indexes] AS [ind] + INNER JOIN [sys].[index_columns] AS [ic] ON [ind].[object_id] = [ic].[object_id] + AND [ic].[index_id] = [ind].[index_id] + INNER JOIN [sys].[columns] AS [col] ON [ic].[object_id] = [col].[object_id] + AND [ic].[column_id] = [col].[column_id] + WHERE [ind].[object_id] = @objectid + AND [ind].[index_id] = @indexobjectid + AND [ic].[is_included_column] = 1 + FOR XML PATH('''') + ), 1, 2, ''''); + + INSERT INTO #markdown (value) + SELECT CONCAT(''| '' + ,CASE + WHEN [ind].[is_primary_key] = 1 + THEN CONCAT(@PK, ''**'',[ind].[name],''**'') + ELSE [ind].[name] + END + , '' | '' + , LOWER([ind].[type_desc]) COLLATE DATABASE_DEFAULT + , '' | '' + , @key_columns COLLATE DATABASE_DEFAULT + , '' | '' + , @include_columns COLLATE DATABASE_DEFAULT + , '' | '' + , CAST([ep].[value] AS NVARCHAR(4000)) COLLATE DATABASE_DEFAULT + , '' |'') + FROM [sys].[indexes] AS [ind] + LEFT JOIN [sys].[extended_properties] AS [ep] ON [ind].[object_id] = [ep].[major_id] + AND [ep].[minor_id] = [ind].[index_id] + AND [ep].[class] = 7 -- Index + AND [ep].[name] = @ExtendedPropertyName + WHERE [ind].[object_id] = @objectid + AND [ind].[index_id] = @indexobjectid; + + FETCH NEXT FROM [index_cursor] INTO @indexobjectid; + END; + + CLOSE [index_cursor]; + DEALLOCATE [index_cursor]; + END; + ' + + + --Back to top + + N'INSERT INTO #markdown + VALUES (CONCAT(CHAR(13), CHAR(10), ''
'')) + ,(CONCAT(CHAR(13), CHAR(10), ''[Back to top](#'', LOWER(@DatabaseName COLLATE DATABASE_DEFAULT), '')'')); + + FETCH NEXT FROM obj_cursor INTO @objectid; + + END; + CLOSE obj_cursor; + DEALLOCATE obj_cursor;' + + + --End collapsible view section + + N'INSERT INTO #markdown + VALUES (CONCAT(CHAR(13), CHAR(10), ''
'')); + END;'; --End markdown for views + + /************************************** + Generate markdown for stored procedures + **************************************/ + --Build table of contents + SET @Sql = @Sql + N' + IF EXISTS (SELECT 1 FROM [sys].[procedures] WHERE [is_ms_shipped] = 0) + BEGIN; + INSERT INTO #markdown + VALUES (CONCAT(CHAR(13), CHAR(10), ''## Stored Procedures'')) ,(CONCAT(CHAR(13), CHAR(10), ''
Click to expand'', CHAR(13), CHAR(10))); + ' + + + + N'INSERT INTO #markdown + SELECT CONCAT(''* ['', OBJECT_SCHEMA_NAME(object_id), ''.'', OBJECT_NAME(object_id), ''](#'', REPLACE(LOWER(OBJECT_SCHEMA_NAME(object_id)), '' '', ''-''), REPLACE(LOWER(OBJECT_NAME(object_id)), '' '', ''-''), '')'') + FROM [sys].[procedures] + WHERE [is_ms_shipped] = 0 + ORDER BY OBJECT_SCHEMA_NAME(object_id), [name] ASC;' + + + --Object details + + N'DECLARE obj_cursor CURSOR + LOCAL STATIC READ_ONLY FORWARD_ONLY + FOR + SELECT [object_id] + FROM [sys].[procedures] + WHERE [is_ms_shipped] = 0 + ORDER BY OBJECT_SCHEMA_NAME([object_id]), [name] ASC; + + OPEN obj_cursor + FETCH NEXT FROM obj_cursor INTO @objectid + WHILE @@FETCH_STATUS = 0 + BEGIN + + INSERT INTO #markdown + SELECT CONCAT(CHAR(13), CHAR(10), ''### '', OBJECT_SCHEMA_NAME(@objectid), ''.'', OBJECT_NAME(@objectid));' + + + --Extended properties + + N'INSERT INTO #markdown + SELECT CAST([ep].[value] AS NVARCHAR(4000)) + FROM [sys].[procedures] AS [p] + INNER JOIN [sys].[extended_properties] AS [ep] ON [p].[object_id] = [ep].[major_id] + WHERE [p].[object_id] = @objectid + AND [ep].[minor_id] = 0 + AND [ep].[name] = @ExtendedPropertyName;' + + + --Check for parameters + + N'IF EXISTS (SELECT * FROM [sys].[parameters] AS [param] WHERE [param].[object_id] = @objectid) + BEGIN + INSERT INTO #markdown (value) + VALUES (CONCAT(CHAR(13), CHAR(10), ''| Parameter | Type | Output | Description |'')) + ,(''| --- | --- | --- | --- |''); + + INSERT INTO #markdown + select CONCAT(''| '', CASE WHEN LEN([param].[name]) = 0 THEN ''*Output*'' ELSE [param].[name] END + ,'' | '' + ,CONCAT(UPPER(TYPE_NAME([user_type_id])) + ,CASE + WHEN TYPE_NAME([user_type_id]) IN (N''decimal'',N''numeric'') + THEN CONCAT(N''('',CAST(precision AS varchar(5)), N'','',CAST(scale AS varchar(5)), N'')'') + WHEN TYPE_NAME([user_type_id]) IN (''varchar'', ''char'', ''varbinary'') + THEN CASE + WHEN [max_length] = -1 + THEN N''(MAX)'' + ELSE QUOTENAME(CAST([max_length] AS VARCHAR(10)), ''('') + END + WHEN TYPE_NAME([user_type_id]) IN (N''time'',N''datetime2'',N''datetimeoffset'') + THEN QUOTENAME(CAST(scale AS varchar(5)), ''('') + WHEN TYPE_NAME([user_type_id]) in (N''float'') + THEN CASE + WHEN [param].precision = 53 + THEN N'''' + ELSE CONCAT(N''('',CAST([param].precision AS varchar(5)),N'')'') + END + WHEN TYPE_NAME([param].user_type_id) IN (N''int'',N''bigint'',N''smallint'',N''tinyint'',N''money'',N''smallmoney'', + N''real'',N''datetime'',N''smalldatetime'',N''bit'',N''image'',N''text'',N''uniqueidentifier'', + N''date'',N''ntext'',N''sql_variant'',N''hierarchyid'',''geography'',N''timestamp'',N''xml'') OR [is_readonly] = 1 + THEN N'''' + WHEN TYPE_NAME([user_type_id]) IN (N''nvarchar'',N''nchar'', N''sysname'') + THEN CASE + WHEN [max_length] = -1 + THEN N''(MAX)'' + ELSE QUOTENAME(CAST([max_length]/2 AS VARCHAR(10)), ''('') + END + ELSE QUOTENAME(CAST([max_length] AS VARCHAR(10)), ''('') + END) + ,'' | '' + ,CASE [is_output] + WHEN 1 + THEN @Yes + ELSE @No + END + ,'' | '' + ,CAST([ep].[value] AS NVARCHAR(4000)) + , '' |'') + FROM [sys].[procedures] AS [proc] + INNER JOIN [sys].[parameters] AS [param] ON [param].[object_id] = [proc].[object_id] + LEFT JOIN [sys].[extended_properties] AS [ep] ON [proc].[object_id] = [ep].[major_id] + AND [ep].[name] = [param].[name] + WHERE [proc].[object_id] = @objectid + ORDER BY [param].[parameter_id] ASC; + END + + INSERT INTO #markdown (value) + VALUES(CONCAT(CHAR(13), CHAR(10), ''#### Definition'')) + ,(CONCAT(CHAR(13), CHAR(10), ''
Click to expand''));' + + + --Object definition + + N' + IF (@LimitStoredProcLength = 1 AND LEN(OBJECT_DEFINITION(@objectid)) > 8000) + BEGIN; + INSERT INTO #markdown (value) + VALUES (CONCAT(CHAR(13), CHAR(10), ''```sql'', + CHAR(13), CHAR(10), CAST(OBJECT_DEFINITION(@objectid) AS VARCHAR(8000)))) + ,(''/************************************************************************************************/'') + ,(''/* sp_doc: Max 8000 characters reached. Set @LimitStoredProcLength = 0 to show full definition. */'') + ,(''/************************************************************************************************/'') + ,(''```''); + END; + ELSE + BEGIN; + INSERT INTO #markdown (value) + VALUES (CONCAT(CHAR(13), CHAR(10), ''```sql'', + CHAR(13), CHAR(10), OBJECT_DEFINITION(@objectid))) + ,(''```''); + END;' + + + --Back to top + + N'INSERT INTO #markdown + VALUES (CONCAT(CHAR(13), CHAR(10), ''
'')) + ,(CONCAT(CHAR(13), CHAR(10), ''[Back to top](#'', LOWER(@DatabaseName COLLATE DATABASE_DEFAULT), '')'')); + + FETCH NEXT FROM obj_cursor INTO @objectid + + END; + CLOSE obj_cursor; + DEALLOCATE obj_cursor;' + + + --End collapsible stored procedure section + + N'INSERT INTO #markdown + VALUES (CONCAT(CHAR(13), CHAR(10), ''
'')); + END;'; --End markdown for stored procedures + + /************************************* + Generate markdown for scalar functions + *************************************/ + --Build table of contents + SET @Sql = @Sql + N' + IF EXISTS (SELECT 1 FROM [sys].[objects] WHERE [is_ms_shipped] = 0 AND [type] = ''FN'') + BEGIN; + INSERT INTO #markdown (value) + VALUES (CONCAT(CHAR(13), CHAR(10), ''## Scalar Functions'')) ,(CONCAT(CHAR(13), CHAR(10), ''
Click to expand'', CHAR(13), CHAR(10))); + ' + + + + N'INSERT INTO #markdown + SELECT CONCAT(''* ['', OBJECT_SCHEMA_NAME(object_id), ''.'', OBJECT_NAME(object_id), ''](#'', REPLACE(LOWER(OBJECT_SCHEMA_NAME(object_id)), '' '', ''-''), REPLACE(LOWER(OBJECT_NAME(object_id)), '' '', ''-''), '')'') + FROM [sys].[objects] + WHERE [is_ms_shipped] = 0 + AND [type] = ''FN'' --SQL_SCALAR_FUNCTION + ORDER BY OBJECT_SCHEMA_NAME([object_id]), [name] ASC;' + + + --Object details + + N'DECLARE obj_cursor CURSOR + LOCAL STATIC READ_ONLY FORWARD_ONLY + FOR + SELECT [object_id] + FROM [sys].[objects] + WHERE [is_ms_shipped] = 0 + AND [type] = ''FN'' --SQL_SCALAR_FUNCTION + ORDER BY OBJECT_SCHEMA_NAME([object_id]), [name] ASC; + + OPEN obj_cursor + FETCH NEXT FROM obj_cursor INTO @objectid + WHILE @@FETCH_STATUS = 0 + BEGIN + + INSERT INTO #markdown + SELECT CONCAT(CHAR(13), CHAR(10), ''### '', OBJECT_SCHEMA_NAME(@objectid), ''.'', OBJECT_NAME(@objectid));' + + + --Extended properties + + N'INSERT INTO #markdown + SELECT CAST([ep].[value] AS NVARCHAR(4000)) + FROM [sys].[objects] AS [o] + INNER JOIN [sys].[extended_properties] AS [ep] ON [o].[object_id] = [ep].[major_id] + WHERE [o].[object_id] = @objectid + AND [ep].[minor_id] = 0 + AND [ep].[name] = @ExtendedPropertyName;' + + + --Check for parameters + + N'IF EXISTS (SELECT * FROM [sys].[parameters] AS [param] WHERE [param].[object_id] = @objectid) + BEGIN + INSERT INTO #markdown (value) + VALUES (CONCAT(CHAR(13), CHAR(10), ''| Parameter | Type | Output | Description |'')) + ,(''| --- | --- | --- | --- |''); + + INSERT INTO #markdown + select CONCAT(''| '', CASE WHEN LEN([param].[name]) = 0 THEN ''*Output*'' ELSE [param].[name] END + ,'' | '' + ,CONCAT(UPPER(TYPE_NAME([user_type_id])) + ,CASE + WHEN TYPE_NAME([user_type_id]) IN (N''decimal'',N''numeric'') + THEN CONCAT(N''('',CAST(precision AS varchar(5)), N'','',CAST(scale AS varchar(5)), N'')'') + WHEN TYPE_NAME([user_type_id]) IN (''varchar'', ''char'', ''varbinary'') + THEN CASE + WHEN [max_length] = -1 + THEN N''(MAX)'' + ELSE QUOTENAME(CAST([max_length] AS VARCHAR(10)), ''('') + END + WHEN TYPE_NAME([user_type_id]) IN (N''time'',N''datetime2'',N''datetimeoffset'') + THEN QUOTENAME(CAST(scale AS varchar(5)), ''('') + WHEN TYPE_NAME([user_type_id]) in (N''float'') + THEN CASE + WHEN [param].precision = 53 + THEN N'''' + ELSE CONCAT(N''('',CAST([param].precision AS varchar(5)),N'')'') + END + WHEN TYPE_NAME([param].user_type_id) IN (N''int'',N''bigint'',N''smallint'',N''tinyint'',N''money'',N''smallmoney'', + N''real'',N''datetime'',N''smalldatetime'',N''bit'',N''image'',N''text'',N''uniqueidentifier'', + N''date'',N''ntext'',N''sql_variant'',N''hierarchyid'',''geography'',N''timestamp'',N''xml'') OR [is_readonly] = 1 + THEN N'''' + WHEN TYPE_NAME([user_type_id]) IN (N''nvarchar'',N''nchar'', N''sysname'') + THEN CASE + WHEN [max_length] = -1 + THEN N''(MAX)'' + ELSE QUOTENAME(CAST([max_length]/2 AS VARCHAR(10)), ''('') + END + ELSE QUOTENAME(CAST([max_length] AS VARCHAR(10)), ''('') + END) + ,'' | '' + ,CASE [is_output] + WHEN 1 + THEN @Yes + ELSE @No + END + ,'' | '' + ,CAST([ep].[value] AS NVARCHAR(4000)) + , '' |'') + FROM [sys].[objects] AS [o] + INNER JOIN [sys].[parameters] AS [param] ON [param].[object_id] = [o].[object_id] + LEFT JOIN [sys].[extended_properties] AS [ep] ON [o].[object_id] = [ep].[major_id] + AND [ep].[name] = [param].[name] + WHERE [o].[object_id] = @objectid + ORDER BY [param].[parameter_id] ASC; + END; + + INSERT INTO #markdown (value) + VALUES(CONCAT(CHAR(13), CHAR(10), ''#### Definition'')) + ,(CONCAT(CHAR(13), CHAR(10), ''
Click to expand''));' + + + --Object definition + + N'INSERT INTO #markdown (value) + VALUES (CONCAT(CHAR(13), CHAR(10), ''```sql'', + CHAR(13), CHAR(10), OBJECT_DEFINITION(@objectid))) + ,(''```'');' + + + --Back to top + + N'INSERT INTO #markdown + VALUES (CONCAT(CHAR(13), CHAR(10), ''
'')) + ,(CONCAT(CHAR(13), CHAR(10), ''[Back to top](#'', LOWER(@DatabaseName COLLATE DATABASE_DEFAULT), '')'')); + + FETCH NEXT FROM obj_cursor INTO @objectid; + + END; + CLOSE obj_cursor; + DEALLOCATE obj_cursor;' + + + --End collapsible scalar functions section + + N'INSERT INTO #markdown + VALUES (CONCAT(CHAR(13), CHAR(10), ''
'')); + END;'; --End markdown for scalar functions + + /************************************ + Generate markdown for table functions + ************************************/ + --Build table of contents + SET @Sql = @Sql + N' + IF EXISTS (SELECT 1 FROM [sys].[objects] WHERE [is_ms_shipped] = 0 AND [type] = ''IF'') + BEGIN; + INSERT INTO #markdown + VALUES (CONCAT(CHAR(13), CHAR(10), ''## Table Functions'')) ,(CONCAT(CHAR(13), CHAR(10), ''
Click to expand'', CHAR(13), CHAR(10))); + ' + + + + N'INSERT INTO #markdown + SELECT CONCAT(''* ['', OBJECT_SCHEMA_NAME(object_id), ''.'', OBJECT_NAME(object_id), ''](#'', REPLACE(LOWER(OBJECT_SCHEMA_NAME(object_id)), '' '', ''-''), REPLACE(LOWER(OBJECT_NAME(object_id)), '' '', ''-''), '')'') + FROM [sys].[objects] + WHERE [is_ms_shipped] = 0 + AND [type] = ''IF'' --SQL_INLINE_TABLE_VALUED_FUNCTION + ORDER BY OBJECT_SCHEMA_NAME(object_id), [name] ASC;' + + + --Object details + + N'DECLARE obj_cursor CURSOR + LOCAL STATIC READ_ONLY FORWARD_ONLY + FOR + SELECT [object_id] + FROM [sys].[objects] + WHERE [is_ms_shipped] = 0 + AND [type] = ''IF'' --SQL_INLINE_TABLE_VALUED_FUNCTION + ORDER BY OBJECT_SCHEMA_NAME([object_id]), [name] ASC; + + OPEN obj_cursor + FETCH NEXT FROM obj_cursor INTO @objectid + WHILE @@FETCH_STATUS = 0 + BEGIN + + INSERT INTO #markdown + SELECT CONCAT(CHAR(13), CHAR(10), ''### '', OBJECT_SCHEMA_NAME(@objectid), ''.'', OBJECT_NAME(@objectid));' + + + --Extended properties + + N'INSERT INTO #markdown + SELECT CAST([ep].[value] AS NVARCHAR(4000)) + FROM [sys].[objects] AS [o] + INNER JOIN [sys].[extended_properties] AS [ep] ON [o].[object_id] = [ep].[major_id] + WHERE [o].[object_id] = @objectid + AND [ep].[minor_id] = 0 + AND [ep].[name] = @ExtendedPropertyName;' + + + --Check for parameters + + N'IF EXISTS (SELECT * FROM [sys].[parameters] AS [param] WHERE [param].[object_id] = @objectid) + BEGIN + INSERT INTO #markdown (value) + VALUES (CONCAT(CHAR(13), CHAR(10), ''| Parameter | Type | Output | Description |'')) + ,(''| --- | --- | --- | --- |''); + + INSERT INTO #markdown + select CONCAT(''| '', CASE WHEN LEN([param].[name]) = 0 THEN ''*Output*'' ELSE [param].[name] END + ,'' | '' + ,CONCAT(UPPER(TYPE_NAME([user_type_id])) + ,CASE + WHEN TYPE_NAME([user_type_id]) IN (N''decimal'',N''numeric'') + THEN CONCAT(N''('',CAST(precision AS varchar(5)), N'','',CAST(scale AS varchar(5)), N'')'') + WHEN TYPE_NAME([user_type_id]) IN (''varchar'', ''char'') + THEN QUOTENAME(CAST([max_length] AS VARCHAR(10)), ''('') + WHEN TYPE_NAME([user_type_id]) IN (N''time'',N''datetime2'',N''datetimeoffset'') + THEN QUOTENAME(CAST(scale AS varchar(5)), ''('') + WHEN TYPE_NAME([user_type_id]) in (N''float'') + THEN CASE + WHEN precision = 53 + THEN N'''' + ELSE QUOTENAME(CAST(precision AS varchar(5)),''('') END + WHEN TYPE_NAME([user_type_id]) IN (N''int'',N''bigint'',N''smallint'',N''tinyint'',N''money'',N''smallmoney'', + N''real'',N''datetime'',N''smalldatetime'',N''bit'',N''image'',N''text'',N''uniqueidentifier'', + N''date'',N''ntext'',N''sql_variant'',N''hierarchyid'',''geography'',N''timestamp'',N''xml'') + THEN N'''' + ELSE CASE + WHEN [is_readonly] = 1 --User defined table type + THEN N'''' + WHEN [max_length] = -1 + THEN N''(MAX)'' + WHEN TYPE_NAME([user_type_id]) IN (N''nvarchar'',N''nchar'', N''sysname'') + THEN QUOTENAME(CAST([max_length]/2 AS VARCHAR(10)), ''('') + ELSE QUOTENAME(CAST([max_length] AS VARCHAR(10)), ''('') + END + END) + ,'' | '' + ,CASE [is_output] + WHEN 1 + THEN @Yes + ELSE @No + END + ,'' | '' + ,CAST([ep].[value] AS NVARCHAR(4000)) + , '' |'') + FROM [sys].[objects] AS [o] + INNER JOIN [sys].[parameters] AS [param] ON [param].[object_id] = [o].[object_id] + LEFT JOIN [sys].[extended_properties] AS [ep] ON [o].[object_id] = [ep].[major_id] + AND [ep].[name] = [param].[name] + WHERE [o].[object_id] = @objectid + ORDER BY [param].[parameter_id] ASC; + END; + + INSERT INTO #markdown (value) + VALUES(CONCAT(CHAR(13), CHAR(10), ''#### Definition'')) + ,(CONCAT(CHAR(13), CHAR(10), ''
Click to expand''));' + + + --Object definition + + N'INSERT INTO #markdown (value) + VALUES (CONCAT(CHAR(13), CHAR(10), ''```sql'', + CHAR(13), CHAR(10), OBJECT_DEFINITION(@objectid))) + ,(''```'');' + + + --Back to top + + N'INSERT INTO #markdown + VALUES (CONCAT(CHAR(13), CHAR(10), ''
'')) + ,(CONCAT(CHAR(13), CHAR(10),''[Back to top](#'', LOWER(@DatabaseName COLLATE DATABASE_DEFAULT), '')'')); + + FETCH NEXT FROM obj_cursor INTO @objectid; + + END; + CLOSE obj_cursor; + DEALLOCATE obj_cursor;' + + + --End collapsible table functions section + + N'INSERT INTO #markdown + VALUES (CONCAT(CHAR(13), CHAR(10), ''
'')); + END;'; --End markdown for table functions + + /****************************** + Generate markdown for synonyms + ******************************/ + --Build table of contents + SET @Sql = @Sql + N' + IF EXISTS (SELECT 1 FROM [sys].[synonyms] WHERE [is_ms_shipped] = 0) + BEGIN; + INSERT INTO #markdown ([value]) + VALUES (CONCAT(CHAR(13), CHAR(10), ''## Synonyms'')) ,(CONCAT(CHAR(13), CHAR(10), ''
Click to expand'')); + ' + + + + N'INSERT INTO #markdown + SELECT CONCAT(''* ['', OBJECT_SCHEMA_NAME(object_id), ''.'', OBJECT_NAME(object_id), ''](#'', REPLACE(LOWER(OBJECT_SCHEMA_NAME(object_id)), '' '', ''-''), REPLACE(LOWER(OBJECT_NAME(object_id)), '' '', ''-''), '')'') + FROM [sys].[synonyms] + WHERE [is_ms_shipped] = 0 + ORDER BY OBJECT_SCHEMA_NAME([object_id]), [name] ASC;' + + + --Object details + + N'DECLARE obj_cursor CURSOR + LOCAL STATIC READ_ONLY FORWARD_ONLY + FOR + SELECT [object_id] + FROM [sys].[synonyms] + WHERE [is_ms_shipped] = 0 + ORDER BY OBJECT_SCHEMA_NAME([object_id]), [name] ASC; + + OPEN obj_cursor + FETCH NEXT FROM obj_cursor INTO @objectid + WHILE @@FETCH_STATUS = 0 + BEGIN + + INSERT INTO #markdown + SELECT CONCAT(CHAR(13), CHAR(10), ''### '', OBJECT_SCHEMA_NAME(@objectid), ''.'', OBJECT_NAME(@objectid), CHAR(13), CHAR(10)); ' + + + --Extended properties + + N'INSERT INTO #markdown + SELECT CAST([ep].[value] AS NVARCHAR(4000)) + FROM [sys].[synonyms] AS [s] + INNER JOIN [sys].[extended_properties] AS [ep] ON [s].[object_id] = [ep].[major_id] + WHERE [s].[object_id] = @objectid + AND [ep].[minor_id] = 0 + AND [ep].[name] = @ExtendedPropertyName; + + INSERT INTO #markdown (value) + VALUES (CONCAT(CHAR(13), CHAR(10), ''| Synonym | Base Object |'')) + ,(''| --- | --- |'');' + + + --Object mapping + + N'INSERT INTO #markdown + SELECT CONCAT(''| '', OBJECT_SCHEMA_NAME([syn].[object_id]), ''.'', OBJECT_NAME([syn].[object_id]) + ,'' | '' + ,CASE WHEN PARSENAME([base_object_name], 3) = DB_NAME() + THEN CONCAT(''['', PARSENAME([base_object_name], 3), ''.'', PARSENAME([base_object_name], 2), ''.'', PARSENAME([base_object_name], 1), '']'', ''(#'', PARSENAME([base_object_name], 2), ''.'', PARSENAME([base_object_name], 1), '')'') + ELSE CONCAT(PARSENAME([base_object_name], 3), PARSENAME([base_object_name], 2), PARSENAME([base_object_name], 1)) + END + ,'' |'') + FROM [sys].[synonyms] AS [syn] + WHERE [syn].[object_id] = @objectid;' + + + --Back to top + + N'INSERT INTO #markdown + VALUES (CONCAT(CHAR(13), CHAR(10),''[Back to top](#'', LOWER(@DatabaseName COLLATE DATABASE_DEFAULT), '')'')); + + FETCH NEXT FROM obj_cursor INTO @objectid + + END + CLOSE obj_cursor + DEALLOCATE obj_cursor;' + + + --End collapsible synonyms section + + N'INSERT INTO #markdown + VALUES (CONCAT(CHAR(13), CHAR(10), ''
'')); + END;'; --End markdown for synonyms + + /*********************************************** + Generate markdown for user defined table types + ***********************************************/ + --Build table of contents + SET @Sql = @Sql + N' + IF EXISTS (SELECT 1 FROM [sys].[table_types] WHERE [is_user_defined] = 1) + BEGIN + INSERT INTO #markdown (value) + VALUES (CONCAT(CHAR(13), CHAR(10), ''## User Defined Table Types'')) + ,(CONCAT(CHAR(13), CHAR(10), ''
Click to expand'', CHAR(13), CHAR(10))); + ' + + + + N'INSERT INTO #markdown (value) + SELECT CONCAT(''* ['', SCHEMA_NAME([schema_id]), ''.'', [name], ''](#'', REPLACE(LOWER(SCHEMA_NAME([schema_id])), '' '', ''-''), REPLACE(LOWER([name]), '' '', ''-''), '')'') + FROM [sys].[table_types] + WHERE [is_user_defined] = 1 + ORDER BY OBJECT_SCHEMA_NAME([type_table_object_id]), [name] ASC;' + + + --Object details + + N'DECLARE obj_cursor CURSOR + LOCAL STATIC READ_ONLY FORWARD_ONLY + FOR + SELECT [type_table_object_id] + FROM [sys].[table_types] + WHERE [is_user_defined] = 1 + ORDER BY OBJECT_SCHEMA_NAME([type_table_object_id]), [name] ASC; + + OPEN obj_cursor + FETCH NEXT FROM obj_cursor INTO @objectid + WHILE @@FETCH_STATUS = 0 + BEGIN + + INSERT INTO #markdown + SELECT CONCAT(CHAR(13), CHAR(10), ''### '', SCHEMA_NAME([schema_id]), ''.'', [name]) + FROM [sys].[table_types] + WHERE [type_table_object_id] = @objectid + AND [is_user_defined] = 1;' + + + --Extended Properties + + N'INSERT INTO #markdown + SELECT CONCAT(CHAR(13), CHAR(10), CAST([ep].[value] AS NVARCHAR(4000))) + FROM [sys].[table_types] AS [tt] + INNER JOIN [sys].[extended_properties] AS [ep] ON [tt].[type_table_object_id] = [ep].[major_id] + WHERE [tt].[type_table_object_id] = @objectid + AND [ep].[minor_id] = 0 --On the table + AND [ep].[name] = @ExtendedPropertyName + AND [tt].[is_user_defined] = 1; + + INSERT INTO #markdown (value) + VALUES (CONCAT(CHAR(13), CHAR(10), ''| Column | Type | Null | Default | '', @ExtendedPropertyName COLLATE DATABASE_DEFAULT, '' |'')) + ,(''| --- | ---| --- | --- | --- |'');' + + + --Columns + + N'INSERT INTO #markdown + SELECT CONCAT(''| '' + ,CASE + WHEN [ic].[object_id] IS NOT NULL + THEN ISNULL(CONCAT(''**'',[c].[name],''**''), ''N/A'') + ELSE ISNULL([c].[name], ''N/A'') + END + ,'' | '' + ,CONCAT(UPPER(TYPE_NAME([c].[user_type_id])) + ,CASE + WHEN TYPE_NAME([c].[user_type_id]) IN (N''decimal'',N''numeric'') + THEN CONCAT(N''('',CAST([c].[precision] AS VARCHAR(5)), N'','',CAST([c].[scale] AS varchar(5)), N'')'') + WHEN TYPE_NAME([c].[user_type_id]) IN (''varchar'', ''char'', ''varbinary'') + THEN CASE + WHEN [c].[max_length] = -1 + THEN N''(MAX)'' + ELSE QUOTENAME(CAST([c].[max_length] AS VARCHAR(10)), ''('') + END + WHEN TYPE_NAME([c].[user_type_id]) IN (N''time'',N''datetime2'',N''datetimeoffset'') + THEN QUOTENAME(CAST([c].[scale] AS VARCHAR(5)), ''('') + WHEN TYPE_NAME([c].[user_type_id]) in (N''float'') + THEN CASE + WHEN [c].precision = 53 + THEN N'''' + ELSE CONCAT(N''('',CAST([c].[precision] AS VARCHAR(5)),N'')'') + END + WHEN TYPE_NAME([c].[user_type_id]) IN (N''int'',N''bigint'',N''smallint'',N''tinyint'',N''money'',N''smallmoney'', + N''real'',N''datetime'',N''smalldatetime'',N''bit'',N''image'',N''text'',N''uniqueidentifier'', + N''date'',N''ntext'',N''sql_variant'',N''hierarchyid'',''geography'',N''timestamp'',N''xml'') + THEN N'''' + WHEN TYPE_NAME([c].[user_type_id]) IN (N''nvarchar'',N''nchar'', N''sysname'') + THEN CASE + WHEN [c].[max_length] = -1 + THEN N''(MAX)'' + ELSE QUOTENAME(CAST([c].[max_length]/2 AS VARCHAR(10)), ''('') + END + ELSE QUOTENAME(CAST([c].[max_length] AS VARCHAR(10)), ''('') + END) + ,'' | '' + ,CASE [c].[is_nullable] + WHEN 1 + THEN @Yes + ELSE @No + END + ,'' | '' + ,OBJECT_DEFINITION([dc].[object_id]) + ,'' | '' + ,CAST([ep].[value] AS NVARCHAR(4000)) + ,'' |'') + FROM [sys].[table_types] AS [tt] + INNER JOIN [sys].[columns] AS [c] ON [tt].[type_table_object_id] = [c].[object_id] + LEFT JOIN [sys].[extended_properties] AS [ep] ON [tt].[type_table_object_id] = [ep].[major_id] + AND [ep].[minor_id] > 0 + AND [ep].[minor_id] = [c].[column_id] + AND [ep].[class] = 1 --Object/col + -- AND [ep].[name] = @ExtendedPropertyName + LEFT JOIN [sys].[foreign_key_columns] AS [fk] ON [fk].[parent_object_id] = [c].[object_id] + AND [fk].[parent_column_id] = [c].[column_id] + LEFT JOIN [sys].[default_constraints] [dc] ON [dc].[parent_object_id] = [c].[object_id] + AND [dc].[parent_column_id] = [c].[column_id] + LEFT JOIN [sys].[indexes] AS [pk] ON [pk].[object_id] = [tt].[type_table_object_id] + AND [pk].[is_primary_key] = 1 + LEFT JOIN [sys].[index_columns] AS [ic] ON [ic].[index_id] = [pk].[index_id] + AND [ic].[object_id] = [tt].[type_table_object_id] + AND [ic].[column_id] = [c].[column_id] + WHERE [tt].[type_table_object_id] = @objectid + AND [tt].[is_user_defined] = 1;' + + + --Back to top + + N'INSERT INTO #markdown + VALUES (CONCAT(CHAR(13), CHAR(10), ''[Back to top](#'', LOWER(@DatabaseName COLLATE DATABASE_DEFAULT), '')'')) + + FETCH NEXT FROM obj_cursor INTO @objectid; + + END; + CLOSE obj_cursor; + DEALLOCATE obj_cursor;' + + + --End collapsible table section + + N'INSERT INTO #markdown + VALUES (CONCAT(CHAR(13), CHAR(10), ''
'')); + END;'; --End markdown for user defined table types + + --Attribution + SET @Sql = @Sql + N'INSERT INTO #markdown + VALUES (CONCAT(CHAR(13), CHAR(10), ''----'')) + ,(CONCAT(CHAR(13), CHAR(10), ''*Markdown generated by [sp_doc](http://dba-multitool.org)'')) + ,(CONCAT('' at '', SYSDATETIMEOFFSET(), ''.*''));'; + + --Return all data + SET @Sql = @Sql + N' + SELECT [value] + FROM #markdown + ORDER BY [ID] ASC;'; + + SET @ParmDefinition = N'@ExtendedPropertyName SYSNAME, @DatabaseName SYSNAME, @LimitStoredProcLength BIT, @Yes VARCHAR(20), @No VARCHAR(20), @PK VARCHAR(20), @FK VARCHAR(20), @Column VARCHAR(20)'; + EXEC sp_executesql @Sql + ,@ParmDefinition + ,@ExtendedPropertyName + ,@DatabaseName + ,@LimitStoredProcLength + ,@Yes + ,@No + ,@PK + ,@FK + ,@Column; +END; +GO + +EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Generate on the fly database documentation in markdown. Documentation at https://expresssql.lowlydba.com' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_doc'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@DatabaseName', @value=N'Target database to document. Default is the stored procedure''s database.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_doc'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@ExtendedPropertyName', @value=N'Key for extended properties on objects. Default is ''Description''.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_doc'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@SqlMajorVersion', @value=N'Used for unit testing purposes only.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_doc'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@SqlMinorVersion', @value=N'Used for unit testing purposes only.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_doc'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@LimitStoredProcLength', @value=N'Limit stored procedure contents to 8000 characters, to avoid memory issues with some IDEs. Default is 1.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_doc'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@Emojis', @value=N'Use emojis when generating documentation. Default is 0.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_doc'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@Verbose', @value=N'Whether or not to print additional information during the script run. Default is 0.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_doc'; +GO + diff --git a/Stored_Procedure/dbo.sp_estindex.sql b/Stored_Procedure/dbo.sp_estindex.sql new file mode 100644 index 00000000..7a35fddb --- /dev/null +++ b/Stored_Procedure/dbo.sp_estindex.sql @@ -0,0 +1,877 @@ +SET ANSI_NULLS ON; +GO + +SET QUOTED_IDENTIFIER ON; +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'Description' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_estindex', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'Description' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex'; + END; +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@TableName' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_estindex', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@TableName' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex'; + END; +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@SqlMajorVersion' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_estindex', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@SqlMajorVersion' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex'; + END; +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@SchemaName' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_estindex', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@SchemaName' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex'; + END; +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@IsUnique' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_estindex', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@IsUnique' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex'; + END; +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@IndexColumns' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_estindex', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@IndexColumns' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex'; + END; +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@IncludeColumns' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_estindex', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@IncludeColumns' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex'; + END; +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@Filter' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_estindex', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@Filter' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex'; + END; +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@FillFactor' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_estindex', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@FillFactor' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex'; + END; +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@DatabaseName' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_estindex', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@DatabaseName' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex'; + END; +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@Verbose' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_estindex', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@Verbose' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex'; + END; +GO + +/***************************/ +/* Create stored procedure */ +/***************************/ +IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_estindex]') AND [type] IN (N'P', N'PC')) + BEGIN; + EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[sp_estindex] AS'; + END +GO + +ALTER PROCEDURE [dbo].[sp_estindex] + @SchemaName SYSNAME = NULL + ,@TableName SYSNAME + ,@DatabaseName SYSNAME = NULL + ,@IndexColumns NVARCHAR(2048) + ,@IncludeColumns NVARCHAR(2048) = NULL + ,@IsUnique BIT = 0 + ,@Filter NVARCHAR(2048) = '' + ,@FillFactor TINYINT = 100 + ,@Verbose BIT = 0 + -- Unit testing only + ,@SqlMajorVersion TINYINT = 0 +AS +BEGIN + +SET NOCOUNT ON; + +/* +sp_estindex - Estimate a new index's size and statistics. + +Part of the DBA MultiTool http://dba-multitool.org + +Version: 2020121 + +MIT License + +Copyright (c) 2020 John McCall + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, +and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial +portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +-- TODO: + -- Handle clustered indexes - https://docs.microsoft.com/en-us/sql/relational-databases/databases/estimate-the-size-of-a-clustered-index?view=sql-server-ver15 + +========= + +Example: + + EXEC dbo.sp_estindex @SchemaName = 'dbo', @tableName = 'Marathon', @IndexColumns = 'racer_id, finish_time, is_disqualified'; + + EXEC dbo.sp_estindex @tableName = 'Marathon', @IndexColumns = 'racer_id, finish_time, is_disqualified', @Filter = 'WHERE racer_id IS NOT NULL', @FillFactor = 90; + +*/ + +DECLARE @Sql NVARCHAR(MAX) = N'' + ,@QualifiedTable NVARCHAR(257) + ,@IndexName SYSNAME = CONCAT('sp_estindex_hypothetical_idx_', DATEDIFF(SECOND,'1970-01-01 00:08:46', GETUTCDATE())) + ,@DropIndexSql NVARCHAR(MAX) + ,@Msg NVARCHAR(MAX) = N'' + ,@IndexType SYSNAME = 'NONCLUSTERED' + ,@IsHeap BIT + ,@IsClusterUnique BIT + ,@ObjectID INT + ,@IndexID INT + ,@ParmDefinition NVARCHAR(MAX) = N'' + ,@NumRows BIGINT + ,@UseDatabase NVARCHAR(200) + ,@UniqueSql VARCHAR(10) + ,@IncludeSql VARCHAR(2048) + ,@PageSize BIGINT = 8192 + ,@FreeBytesPerPage BIGINT = 8096; + +BEGIN TRY + -- Find Version + IF (@SqlMajorVersion = 0) + BEGIN; + SET @SqlMajorVersion = CAST(SERVERPROPERTY('ProductMajorVersion') AS TINYINT); + END; + + /* Validate Version */ + IF (@SqlMajorVersion < 11) + BEGIN; + SET @Msg = 'SQL Server versions below 2012 are not supported, sorry!'; + RAISERROR(@Msg, 16, 1); + END; + + /* Validate Fill Factor */ + IF (@FillFactor > 100 OR @FillFactor < 1) + BEGIN; + SET @Msg = 'Fill factor must be between 1 and 100.'; + THROW 51000, @Msg, 1; + END; + + /* Validate Database */ + IF (@DatabaseName IS NULL) + BEGIN; + SET @DatabaseName = DB_NAME(); + IF (@Verbose = 1) + BEGIN; + SET @Msg = 'No database provided, assuming current database.'; + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + END; + ELSE IF (DB_ID(@DatabaseName) IS NULL) + BEGIN; + SET @DatabaseName = DB_NAME(); + SET @Msg = 'Database does not exist.'; + RAISERROR(@Msg, 16, 1); + END; + + /* Validate Schema */ + IF (@SchemaName IS NULL) + BEGIN; + SET @SchemaName = 'dbo'; + IF (@Verbose = 1) + BEGIN; + SET @Msg = 'No schema provided, assuming dbo.'; + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + END; + + -- Set variables with validated params + SET @QualifiedTable = CONCAT(QUOTENAME(@SchemaName), '.', QUOTENAME(@TableName)); + SET @UseDatabase = N'USE ' + QUOTENAME(@DatabaseName) + '; '; + IF (@IsUnique = 1) + BEGIN; + SET @UniqueSql = ' UNIQUE '; + END; + IF (@IncludeColumns IS NOT NULL) + BEGIN; + SET @IncludeSql = CONCAT(' INCLUDE(', @IncludeColumns, ') '); + END; + + -- Find object id + SET @Sql = CONCAT(@UseDatabase, + N'SELECT @ObjectID = [object_id] + FROM [sys].[all_objects] + WHERE [object_id] = OBJECT_ID(@QualifiedTable)'); + SET @ParmDefinition = N'@QualifiedTable NVARCHAR(257) + ,@ObjectID INT OUTPUT'; + EXEC sp_executesql @Sql + ,@ParmDefinition + ,@QualifiedTable + ,@ObjectID OUTPUT; + + -- Determine Heap or Clustered + SET @Sql = CONCAT(@UseDatabase, + N'SELECT @IsHeap = CASE [type] WHEN 0 THEN 1 ELSE 0 END + ,@IsClusterUnique = [is_unique] + FROM [sys].[indexes] + WHERE [object_id] = OBJECT_ID(@QualifiedTable) + AND [type] IN (1, 0)'); + SET @ParmDefinition = N'@QualifiedTable NVARCHAR(257), @IsHeap BIT OUTPUT, @IsClusterUnique BIT OUTPUT'; + EXEC sp_executesql @Sql + ,@ParmDefinition + ,@QualifiedTable + ,@IsHeap OUTPUT + ,@IsClusterUnique OUTPUT; + + -- Safety check for leftover index from previous run + SET @DropIndexSql = CONCAT(@UseDatabase, + N'IF EXISTS (SELECT 1 FROM [sys].[indexes] WHERE [object_id] = OBJECT_ID(''',@QualifiedTable,''') AND [name] = ''',@IndexName,''') + DROP INDEX ', QUOTENAME(@IndexName), ' ON ', @QualifiedTable); + EXEC sp_executesql @DropIndexSql; + + -- Fetch missing index stats before creation + IF OBJECT_ID('tempdb..##TempMissingIndex') IS NOT NULL + BEGIN; + DROP TABLE ##TempMissingIndex; + END; + + SET @Sql = CONCAT(@UseDatabase, + N'SELECT [id].[statement] + ,[id].[equality_columns] + ,[id].[inequality_columns] + ,[id].[included_columns] + ,[gs].[unique_compiles] + ,[gs].[user_seeks] + ,[gs].[user_scans] + ,[gs].[avg_total_user_cost] -- Average cost of the user queries that could be reduced + ,[gs].[avg_user_impact] -- % + INTO ##TempMissingIndex + FROM [sys].[dm_db_missing_index_group_stats] [gs] + INNER JOIN [sys].[dm_db_missing_index_groups] [ig] ON [gs].[group_handle] = [ig].[index_group_handle] + INNER JOIN [sys].[dm_db_missing_index_details] [id] ON [ig].[index_handle] = [id].[index_handle] + WHERE [id].[database_id] = DB_ID() + AND [id].[object_id] = @ObjectID + OPTION (RECOMPILE);'); + SET @ParmDefinition = N'@ObjectID INT'; + EXEC sp_executesql @Sql + ,@ParmDefinition + ,@ObjectID; + + -- Create the hypothetical index + SET @Sql = CONCAT(@UseDatabase, 'CREATE ', @UniqueSql, @IndexType, ' INDEX ', QUOTENAME(@IndexName), ' ON ', @QualifiedTable, ' (', @IndexColumns, ') ',@IncludeSql, @Filter, ' WITH (STATISTICS_ONLY = -1)'); + EXEC sp_executesql @Sql; + + /*******************/ + /* Get index stats */ + /*******************/ + -- Use DBCC to avoid various inconsistencies + -- in equivalent DMVs between 2012-2016 + SET @Sql = CONCAT(@UseDatabase, 'DBCC SHOW_STATISTICS ("', @QualifiedTable,'", ', QUOTENAME(@IndexName), ')'); + EXEC sp_executesql @Sql; + + /***************************/ + /* Get missing index stats */ + /***************************/ + DECLARE @QuotedKeyColumns NVARCHAR(2048) + ,@QuotedInclColumns NVARCHAR(2048); + + --Get index columns in same format as dmv table + SET @Sql = CONCAT(@UseDatabase, + N'SELECT @QuotedKeyColumns = CASE WHEN [ic].[is_included_column] = 0 + THEN CONCAT(COALESCE(@QuotedKeyColumns COLLATE DATABASE_DEFAULT + '', '', ''''), QUOTENAME([ac].[name])) + ELSE @QuotedKeyColumns + END, + @QuotedInclColumns = CASE WHEN [ic].[is_included_column] = 1 + THEN CONCAT(COALESCE(@QuotedInclColumns COLLATE DATABASE_DEFAULT + '', '', ''''), QUOTENAME([ac].[name])) + ELSE @QuotedInclColumns + END + FROM [sys].[indexes] AS [i] + INNER JOIN [sys].[index_columns] AS [ic] ON [i].[index_id] = [ic].[index_id] + AND [ic].object_id = [i].object_id + INNER JOIN [sys].[all_columns] AS [ac] ON [ac].[object_id] = [ic].[object_id] + AND [ac].[column_id] = [ic].[column_id] + WHERE [i].[name] = @IndexName + AND [i].[object_id] = @ObjectID + AND [i].[is_hypothetical] = 1;'); + SET @ParmDefinition = N'@IndexName SYSNAME, @ObjectID INT, @QuotedKeyColumns NVARCHAR(2048) OUTPUT, @QuotedInclColumns NVARCHAR(2048) OUTPUT'; + EXEC sp_executesql @Sql + ,@ParmDefinition + ,@IndexName + ,@ObjectID + ,@QuotedKeyColumns OUTPUT + ,@QuotedInclColumns OUTPUT; + + -- Search missing index dmv for a match + SELECT 'Missing index stats' AS [description] + ,[statement] + ,[equality_columns] + ,[inequality_columns] + ,[included_columns] + ,[unique_compiles] + ,[user_seeks] + ,[user_scans] + ,[avg_total_user_cost] + ,[avg_user_impact] + FROM ##TempMissingIndex + WHERE COALESCE([equality_columns] + ', ', '') + [inequality_columns] = @QuotedKeyColumns + AND ([included_columns] = @QuotedInclColumns OR [included_columns] IS NULL); + + IF (SELECT COUNT(*) FROM ##TempMissingIndex) = 0 AND (@Verbose = 1) + BEGIN; + SET @Msg = 'No matching missing index statistics found.'; + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + + DROP TABLE ##TempMissingIndex; + + /************************************************/ + /* Estimate index size - does NOT consider: */ + /* Partitioning, allocation pages, LOB values, */ + /* compression, or sparse columns */ + /************************************************/ + IF (@IndexType = 'NONCLUSTERED') -- http://dba-multitool.org/est-nonclustered-index-size + BEGIN; + DECLARE @NumVariableKeyCols INT = 0 + ,@MaxVarKeySize BIGINT = 0 + ,@NumFixedKeyCols INT = 0 + ,@FixedKeySize BIGINT = 0 + ,@NumKeyCols INT = 0 + ,@NullCols INT = 0 + ,@IndexNullBitmap BIGINT = 0 + ,@VariableKeySize BIGINT = 0 + ,@TotalFixedKeySize BIGINT = 0 + ,@IndexRowSize BIGINT = 0 + ,@IndexRowsPerPage BIGINT = 0 + ,@ClusterNumVarKeyCols INT = 0 + ,@MaxClusterVarKeySize BIGINT = 0 + ,@ClusterNumFixedKeyCols INT = 0 + ,@MaxClusterFixedKeySize BIGINT = 0 + ,@ClusterNullCols INT = 0; + + /**************************/ + /* 1. Calculate variables */ + /**************************/ + -- Row count + SET @Sql = CONCAT(@UseDatabase, + N'SELECT @NumRows = [sp].[rows] -- Accounts for index filter if in use + FROM [sys].[objects] AS [o] + INNER JOIN [sys].[stats] AS [stat] ON [stat].[object_id] = [o].[object_id] + CROSS APPLY [sys].[dm_db_stats_properties]([stat].[object_id], [stat].[stats_id]) AS [sp] + WHERE [o].[object_id] = @ObjectID + AND [stat].[name] = @IndexName;'); + SET @ParmDefinition = N'@ObjectID INT, @IndexName SYSNAME, @NumRows BIGINT OUTPUT'; + EXEC sp_executesql @Sql + ,@ParmDefinition + ,@ObjectID + ,@IndexName + ,@NumRows OUTPUT; + + IF (@Verbose = 1) + BEGIN + SET @Msg = CONCAT('NumRows: ', @NumRows); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + + --Key types and sizes + SET @Sql = CONCAT(@UseDatabase, + N'SELECT @NumVariableKeyCols = ISNULL(SUM(CASE + WHEN TYPE_NAME([ac].[user_type_id]) IN(''varchar'', ''nvarchar'', ''text'', ''ntext'', ''image'', ''varbinary'', ''xml'') + THEN 1 + ELSE 0 + END), 0), + @MaxVarKeySize = ISNULL(SUM(CASE + WHEN TYPE_NAME([ac].[user_type_id]) IN(''varchar'', ''nvarchar'', ''text'', ''ntext'', ''image'', ''varbinary'', ''xml'') + THEN CASE [ac].[max_length] + WHEN -1 + THEN(4000 + 2) -- use same estimation as the query engine for max lenths + ELSE COL_LENGTH(OBJECT_NAME([i].object_id), [ac].[name]) + END + ELSE 0 + END), 0), + @NumFixedKeyCols = ISNULL(SUM(CASE + WHEN TYPE_NAME([ac].[user_type_id]) NOT IN(''varchar'', ''nvarchar'', ''text'', ''ntext'', ''image'', ''varbinary'', ''xml'') + THEN 1 + ELSE 0 + END), 0), + @FixedKeySize = ISNULL(SUM(CASE + WHEN TYPE_NAME([ac].[user_type_id]) NOT IN(''varchar'', ''nvarchar'', ''text'', ''ntext'', ''image'', ''varbinary'', ''xml'') + THEN COL_LENGTH(OBJECT_NAME([i].object_id), [ac].[name]) + ELSE 0 + END), 0), + @NullCols = ISNULL(SUM(CAST([ac].[is_nullable] AS TINYINT)),0) + FROM [sys].[indexes] AS [i] + INNER JOIN [sys].[index_columns] AS [ic] ON [i].[index_id] = [ic].[index_id] + AND [ic].object_id = [i].object_id + INNER JOIN [sys].[all_columns] AS [ac] ON [ac].object_id = [ic].object_id + AND [ac].[column_id] = [ic].[column_id] + WHERE [i].[name] = @IndexName + AND [i].[object_id] = @ObjectID + AND [i].[is_hypothetical] = 1 + AND [ic].[is_included_column] = 0'); + SET @ParmDefinition = N'@IndexName SYSNAME, @ObjectID INT, @NumVariableKeyCols INT OUTPUT, + @MaxVarKeySize BIGINT OUTPUT, @NumFixedKeyCols INT OUTPUT, @FixedKeySize BIGINT OUTPUT, + @NullCols INT OUTPUT'; + EXEC sp_executesql @Sql + ,@ParmDefinition + ,@IndexName + ,@ObjectID + ,@NumVariableKeyCols OUTPUT + ,@MaxVarKeySize OUTPUT + ,@NumFixedKeyCols OUTPUT + ,@FixedKeySize OUTPUT + ,@NullCols OUTPUT; + + SET @NumKeyCols = @NumVariableKeyCols + @NumFixedKeyCols; + + IF (@Verbose = 1) + BEGIN + SET @Msg = CONCAT('NumVariableKeyCols: ', @NumVariableKeyCols); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + SET @Msg = CONCAT('MaxVarKeySize: ', @MaxVarKeySize); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + SET @Msg = CONCAT('NumFixedKeyCols: ', @NumFixedKeyCols); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + SET @Msg = CONCAT('FixedKeySize: ', @FixedKeySize); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + SET @Msg = CONCAT('NullCols: ', @NullCols); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + SET @Msg = CONCAT('NumKeyCols: ', @NumKeyCols); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + + -- Account for data row locator for non-unique + IF (@IsHeap = 1 AND @IsUnique = 0) + BEGIN; + SET @NumKeyCols = @NumKeyCols + 1; + SET @NumVariableKeyCols = @NumVariableKeyCols + 1; + SET @MaxVarKeySize = @MaxVarKeySize + 8; --heap RID + END; + ELSE IF (@IsHeap = 0 AND @IsUnique = 0) + BEGIN; + --Clustered keys and sizes not included in the new index + SET @Sql = CONCAT(@UseDatabase, + N'WITH NewIndexCol AS ( + SELECT [ac].[name] + FROM [sys].[indexes] AS [i] + INNER JOIN [sys].[index_columns] AS [ic] ON [i].[index_id] = [ic].[index_id] + AND [ic].object_id = [i].object_id + INNER JOIN [sys].[all_columns] AS [ac] ON [ac].object_id = [ic].object_id + AND [ac].[column_id] = [ic].[column_id] + WHERE [i].[name] = @IndexName + AND [i].[object_id] = @ObjectID + AND [i].[is_hypothetical] = 1 + AND [ic].[is_included_column] = 0 + ) + SELECT @ClusterNumVarKeyCols = ISNULL(SUM(CASE + WHEN TYPE_NAME([ac].[user_type_id]) IN(''varchar'', ''nvarchar'', ''text'', ''ntext'', ''image'', ''varbinary'', ''xml'') + THEN 1 + ELSE 0 + END), 0), + @MaxClusterVarKeySize = ISNULL(SUM(CASE + WHEN TYPE_NAME([ac].[user_type_id]) IN(''varchar'', ''nvarchar'', ''text'', ''ntext'', ''image'', ''varbinary'', ''xml'') + THEN CASE [ac].[max_length] + WHEN -1 + THEN(4000 + 2) -- use same estimation as the query engine for max lenths + ELSE COL_LENGTH(OBJECT_NAME([i].object_id), [ac].[name]) + END + ELSE 0 + END), 0), + @ClusterNumFixedKeyCols = ISNULL(SUM(CASE + WHEN TYPE_NAME([ac].[user_type_id]) NOT IN(''varchar'', ''nvarchar'', ''text'', ''ntext'', ''image'', ''varbinary'', ''xml'') + THEN 1 + ELSE 0 + END), 0), + @MaxClusterFixedKeySize = ISNULL(SUM(CASE + WHEN TYPE_NAME([ac].[user_type_id]) NOT IN(''varchar'', ''nvarchar'', ''text'', ''ntext'', ''image'', ''varbinary'', ''xml'') + THEN COL_LENGTH(OBJECT_NAME([i].object_id), [ac].[name]) + ELSE 0 + END), 0), + @ClusterNullCols = ISNULL(SUM(CAST([ac].[is_nullable] AS TINYINT)),0) + FROM [sys].[indexes] AS [i] + INNER JOIN [sys].[index_columns] AS [ic] ON [i].[index_id] = [ic].[index_id] + AND [ic].object_id = [i].object_id + INNER JOIN [sys].[all_columns] AS [ac] ON [ac].object_id = [ic].object_id + AND [ac].[column_id] = [ic].[column_id] + WHERE [i].[type] = 1 --Clustered + AND [i].[object_id] = @ObjectID + AND [ac].[name] NOT IN (SELECT [name] FROM [NewIndexCol]);'); + SET @ParmDefinition = N'@IndexName SYSNAME, @ObjectID INT, @ClusterNumVarKeyCols INT OUTPUT, + @MaxClusterVarKeySize BIGINT OUTPUT, @ClusterNumFixedKeyCols INT OUTPUT, + @MaxClusterFixedKeySize BIGINT OUTPUT, @ClusterNullCols INT OUTPUT'; + EXEC sp_executesql @Sql + ,@ParmDefinition + ,@IndexName + ,@ObjectID + ,@ClusterNumVarKeyCols OUTPUT + ,@MaxClusterVarKeySize OUTPUT + ,@ClusterNumFixedKeyCols OUTPUT + ,@MaxClusterFixedKeySize OUTPUT + ,@ClusterNullCols OUTPUT; + + IF (@Verbose = 1) + BEGIN + SET @Msg = CONCAT('ClusterNumVarKeyCols: ', @ClusterNumVarKeyCols); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + SET @Msg = CONCAT('ClusterNumFixedKeyCols: ', @ClusterNumFixedKeyCols); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + SET @Msg = CONCAT('MaxClusterVarKeySize: ', @MaxClusterVarKeySize); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + SET @Msg = CONCAT('MaxClusterFixedKeySize: ', @MaxClusterFixedKeySize); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + SET @Msg = CONCAT('ClusterNullCols: ', @ClusterNullCols); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + + -- Add counts from clustered index cols + SET @NumKeyCols = @NumKeyCols + (@ClusterNumVarKeyCols + @ClusterNumFixedKeyCols); + SET @FixedKeySize = @FixedKeySize + @MaxClusterFixedKeySize; + SET @NumVariableKeyCols = @NumVariableKeyCols + @ClusterNumVarKeyCols; + SET @MaxVarKeySize = @MaxVarKeySize + @MaxClusterVarKeySize; + SET @NullCols = @NullCols + @ClusterNullCols; + + IF (@IsClusterUnique = 0) + BEGIN; + SET @MaxVarKeySize = @MaxVarKeySize + 4; + SET @NumVariableKeyCols = @NumVariableKeyCols + 1; + SET @NumKeyCols = @NumKeyCols + 1; + END; + END; + + IF (@Verbose = 1) + BEGIN + SET @Msg = CONCAT('FixedKeySize: ', @FixedKeySize); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + SET @Msg = CONCAT('NumVariableKeyCols: ', @NumVariableKeyCols); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + SET @Msg = CONCAT('NumKeyCols: ', @NumKeyCols); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + SET @Msg = CONCAT('MaxVarKeySize: ', @MaxVarKeySize); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + SET @Msg = CONCAT('NullCols: ', @NullCols); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + + -- Account for index null bitmap + IF (@NullCols > 0) + BEGIN; + SET @IndexNullBitmap = 2 + ((@NullCols + 7) / 8); + END; + + -- Calculate variable length data size + -- Assumes each col is 100% full + IF (@NumVariableKeyCols > 0) + BEGIN; + SET @VariableKeySize = 2 + (@NumVariableKeyCols * 2) + @MaxVarKeySize; --The bytes added to @MaxVarKeySize are for tracking each variable column. + END; + + -- Calculate index row size + SET @IndexRowSize = @FixedKeySize + @VariableKeySize + @IndexNullBitmap + 1 + 6; -- + 1 (for row header overhead of an index row) + 6 (for the child page ID pointer) + + IF (@Verbose = 1) + BEGIN + SET @Msg = CONCAT('IndexRowSize: ', @IndexRowSize); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + + --Calculate number of index rows / page + SET @IndexRowsPerPage = FLOOR(@FreeBytesPerPage / (@IndexRowSize + 2)); -- + 2 for the row's entry in the page's slot array. + + IF (@Verbose = 1) + BEGIN + SET @Msg = CONCAT('IndexRowsPerPage: ', @IndexRowsPerPage); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + + /****************************************************************************/ + /* 2. Calculate the Space Used to Store Index Information in the Leaf Level */ + /****************************************************************************/ + -- Specify the number of fixed-length and variable-length columns at the leaf level + -- and calculate the space that is required for their storage + DECLARE @NumLeafCols INT = @NumKeyCols + ,@FixedLeafSize BIGINT = @FixedKeySize + ,@NumVariableLeafCols INT = @NumVariableKeyCols + ,@MaxVarLeafSize BIGINT = @MaxVarKeySize + ,@LeafNullBitmap BIGINT = 0 + ,@VariableLeafSize BIGINT = 0 + ,@LeafRowSize BIGINT = 0 + ,@LeafRowsPerPage BIGINT = 0 + ,@FreeRowsPerPage BIGINT = 0 + ,@NumLeafPages BIGINT = 0 + ,@LeafSpaceUsed BIGINT = 0; + + IF (@IncludeColumns IS NOT NULL) + BEGIN; + DECLARE @NumVariableInclCols INT = 0 + ,@MaxVarInclSize BIGINT = 0 + ,@NumFixedInclCols INT = 0 + ,@FixedInclSize BIGINT = 0; + + --Incl types and sizes + SET @Sql = CONCAT(@UseDatabase, + N'SELECT @NumVariableInclCols = ISNULL(SUM(CASE + WHEN TYPE_NAME([ac].[user_type_id]) IN(''varchar'', ''nvarchar'', ''text'', ''ntext'', ''image'', ''varbinary'', ''xml'') + THEN 1 + ELSE 0 + END), 0), + @MaxVarInclSize = ISNULL(SUM(CASE + WHEN TYPE_NAME([ac].[user_type_id]) IN(''varchar'', ''nvarchar'', ''text'', ''ntext'', ''image'', ''varbinary'', ''xml'') + THEN CASE [ac].[max_length] + WHEN -1 + THEN (4000 + 2) -- use same estimation as the query engine for max lenths + ELSE COL_LENGTH(OBJECT_NAME([i].object_id), [ac].[name]) + END + ELSE 0 + END), 0), + @NumFixedInclCols = ISNULL(SUM(CASE + WHEN TYPE_NAME([ac].[user_type_id]) NOT IN(''varchar'', ''nvarchar'', ''text'', ''ntext'', ''image'', ''varbinary'', ''xml'') + THEN 1 + ELSE 0 + END), 0), + @FixedInclSize = ISNULL(SUM(CASE + WHEN TYPE_NAME([ac].[user_type_id]) NOT IN(''varchar'', ''nvarchar'', ''text'', ''ntext'', ''image'', ''varbinary'', ''xml'') + THEN COL_LENGTH(OBJECT_NAME([i].object_id), [ac].[name]) + ELSE 0 + END), 0) + FROM [sys].[indexes] AS [i] + INNER JOIN [sys].[index_columns] AS [ic] ON [i].[index_id] = [ic].[index_id] + AND [ic].object_id = [i].object_id + INNER JOIN [sys].[all_columns] AS [ac] ON [ac].object_id = [ic].object_id + AND [ac].[column_id] = [ic].[column_id] + WHERE [i].[name] = @IndexName + AND [i].[object_id] = @ObjectID + AND [i].[is_hypothetical] = 1 + AND [ic].[is_included_column] = 1;'); + SET @ParmDefinition = N'@IndexName SYSNAME, @ObjectID INT, @NumVariableInclCols INT OUTPUT, + @MaxVarInclSize BIGINT OUTPUT, @NumFixedInclCols INT OUTPUT, @FixedInclSize BIGINT OUTPUT'; + EXEC sp_executesql @Sql + ,@ParmDefinition + ,@IndexName + ,@ObjectID + ,@NumVariableInclCols OUTPUT + ,@MaxVarInclSize OUTPUT + ,@NumFixedInclCols OUTPUT + ,@FixedInclSize OUTPUT; + + -- Add included columns to rolling totals + SET @NumLeafCols = @NumLeafCols + (@NumVariableInclCols + @NumFixedInclCols); + SET @FixedLeafSize = @FixedLeafSize + @FixedInclSize; + SET @NumVariableLeafCols = @NumVariableLeafCols + @NumVariableInclCols; + SET @MaxVarLeafSize = @MaxVarLeafSize + @MaxVarInclSize; + END; + + -- Account for data row locator for unique indexes + -- If non-unique, already accounted for above + IF (@IsUnique = 1) + BEGIN; + IF (@IsHeap = 1) + BEGIN; + SET @NumLeafCols = @NumLeafCols + 1; + SET @NumVariableLeafCols = @NumVariableLeafCols + 1; + SET @MaxVarLeafSize = @MaxVarLeafSize + 8; -- the data row locator is the heap RID (size 8 bytes). + END; + ELSE -- Clustered + BEGIN; + SET @NumLeafCols = @NumLeafCols + (@ClusterNumVarKeyCols + @ClusterNumFixedKeyCols); + SET @FixedLeafSize = @FixedLeafSize + @ClusterNumFixedKeyCols; + SET @NumVariableLeafCols = @NumVariableLeafCols + @ClusterNumVarKeyCols; + SET @MaxVarLeafSize = @MaxVarLeafSize + @MaxClusterVarKeySize; + + IF (@IsClusterUnique = 0) + BEGIN; + SET @NumLeafCols = @NumLeafCols + 1; + SET @NumVariableLeafCols = @NumVariableLeafCols + 1; + SET @MaxVarLeafSize = @MaxVarLeafSize + 4; + END; + END; + END; + + IF (@Verbose = 1) + BEGIN + SET @Msg = CONCAT('NumLeafCols: ', @NumLeafCols); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + SET @Msg = CONCAT('FixedLeafSize: ', @FixedLeafSize); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + SET @Msg = CONCAT('NumVariableLeafCols: ', @NumVariableLeafCols); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + SET @Msg = CONCAT('MaxVarLeafSize: ', @MaxVarLeafSize); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + + -- Account for index null bitmap + SET @LeafNullBitmap = 2 + ((@NumLeafCols + 7) / 8); + + IF (@Verbose = 1) + BEGIN + SET @Msg = CONCAT('LeafNullBitmap: ', @LeafNullBitmap); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + + -- Calculate variable length data size + -- Assumes each col is 100% full + IF (@NumVariableLeafCols > 0) + BEGIN; + SET @VariableLeafSize = 2 + (@NumVariableLeafCols * 2) + @MaxVarLeafSize; + END; + + IF (@Verbose = 1) + BEGIN + SET @Msg = CONCAT('VariableLeafSize: ', @VariableLeafSize); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + + -- Calculate index row size + SET @LeafRowSize = @FixedLeafSize + @VariableLeafSize + @LeafNullBitmap + 1; -- +1 for row header overhead of an index row) + + IF (@Verbose = 1) + BEGIN + SET @Msg = CONCAT('LeafRowSize: ', @LeafRowSize); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + + -- Calculate number of index rows / page + SET @LeafRowsPerPage = FLOOR(@FreeBytesPerPage / (@LeafRowSize + 2)); -- + 2 for the row's entry in the page's slot array. + + IF (@Verbose = 1) + BEGIN + SET @Msg = CONCAT('LeafRowsPerPage: ', @LeafRowsPerPage); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + + -- Calculate free rows / page + SET @FreeRowsPerPage = @FreeBytesPerPage * (( 100 - @FillFactor) / 100) / (@LeafRowSize + 2); -- + 2 for the row's entry in the page's slot array. + + IF (@Verbose = 1) + BEGIN + SET @Msg = CONCAT('FreeRowsPerPage: ', @FreeRowsPerPage); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + + -- Calculate pages for all rows + SET @NumLeafPages = CEILING(@NumRows / (@LeafRowsPerPage - @FreeRowsPerPage)); + + IF (@Verbose = 1) + BEGIN + SET @Msg = CONCAT('NumLeafPages: ', @NumLeafPages); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + + -- Calculate size of index at leaf level + SET @LeafSpaceUsed = @PageSize * @NumLeafPages; + + /*********************************************************************************/ + /* 3. Calculate the Space Used to Store Index Information in the Non-leaf Levels */ + /*********************************************************************************/ + DECLARE @NonLeafLevels BIGINT = 0, + @NumIndexPages BIGINT = 0, + @IndexSpaceUsed BIGINT = 0; + + -- Calculate the number of non-leaf levels in the index + SET @NonLeafLevels = CEILING(1 + LOG(@IndexRowsPerPage) * (@NumLeafPages / @IndexRowsPerPage)); + + IF (@Verbose = 1) + BEGIN + SET @Msg = CONCAT('NonLeafLevels: ', @NonLeafLevels); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + + --Formula: IndexPages = Summation (Num_Leaf_Pages/Index_Rows_Per_Page^Level)where 1 <= Level <= Levels + WHILE (@NonLeafLevels > 1) + BEGIN + DECLARE @TempIndexPages FLOAT(30); + + -- TempIndexPages may be exceedingly small, so catch any arith overflows and call it 0 + BEGIN TRY; + SET @TempIndexPages = @NumLeafPages / POWER(@IndexRowsPerPage, @NonLeafLevels); + SET @NumIndexPages = @NumIndexPages + @TempIndexPages; + SET @NonLeafLevels = @NonLeafLevels - 1; + END TRY + BEGIN CATCH; + SET @NonLeafLevels = @NonLeafLevels - 1; + END CATCH; + END; + + -- Calculate size of the index + SET @IndexSpaceUsed = @PageSize * @NumIndexPages; + + /**************************************/ + /* 4. Total index and leaf space used */ + /**************************************/ + DECLARE @Total BIGINT = 0; + + SET @Total = @LeafSpaceUsed + @IndexSpaceUsed; + + SELECT @Total/1024 AS [Est. KB] + ,CAST(ROUND(@Total/1024.0/1024.0,2,1) AS DECIMAL(30,2)) AS [Est. MB] + ,CAST(ROUND(@Total/1024.0/1024.0/1024.0,2,1) AS DECIMAL(30,4)) AS [Est. GB]; + END; + + --Cleanup + EXEC sp_executesql @DropIndexSql; + +END TRY +BEGIN CATCH; + BEGIN; + DECLARE @ErrorNumber INT = ERROR_NUMBER(); + DECLARE @ErrorLine INT = ERROR_LINE(); + DECLARE @ErrorMessage NVARCHAR(4000) = ERROR_MESSAGE(); + DECLARE @ErrorSeverity INT = ERROR_SEVERITY(); + DECLARE @ErrorState INT = ERROR_STATE(); + + EXEC sp_executesql @DropIndexSql; + + SET @ErrorMessage = CONCAT(QUOTENAME(OBJECT_NAME(@@PROCID)), ': ', @ErrorMessage); + RAISERROR(@ErrorMessage, @ErrorSeverity, @ErrorState) WITH NOWAIT; + END; +END CATCH; + +END; +GO + +EXEC sys.sp_addextendedproperty @name=N'@DatabaseName', @value=N'Target database of the index''s table.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@FillFactor', @value=N'Optional fill factor for the index. Default is 100.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@Filter', @value=N'Optional filter for the index.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@IncludeColumns', @value=N'Optional comma separated list of include columns.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@IndexColumns', @value=N'Comma separated list of key columns.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@IsUnique', @value=N'Whether or not the index is UNIQUE. Default is 0.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@SchemaName', @value=N'Target schema of the index''s table. Default is ''dbo''.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@SqlMajorVersion', @value=N'For unit testing only.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@TableName', @value=N'Target table for the index. Default is current database.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex'; +GO + +EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Estimate a new index''s size and statistics.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@Verbose', @value=N'Show intermediate variables used in size calculations. Default is 0.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_estindex'; +GO diff --git a/Stored_Procedure/sp_foreign_key$batch_drop_and_recreate.sql b/Stored_Procedure/dbo.sp_foreign_key$batch_drop_and_recreate.sql similarity index 100% rename from Stored_Procedure/sp_foreign_key$batch_drop_and_recreate.sql rename to Stored_Procedure/dbo.sp_foreign_key$batch_drop_and_recreate.sql diff --git a/Stored_Procedure/sp_generate_merge.sql b/Stored_Procedure/dbo.sp_generate_merge.sql similarity index 100% rename from Stored_Procedure/sp_generate_merge.sql rename to Stored_Procedure/dbo.sp_generate_merge.sql diff --git a/Stored_Procedure/sp_helpExpandView.sql b/Stored_Procedure/dbo.sp_helpExpandView.sql similarity index 100% rename from Stored_Procedure/sp_helpExpandView.sql rename to Stored_Procedure/dbo.sp_helpExpandView.sql diff --git a/Stored_Procedure/sp_help_permissions.sql b/Stored_Procedure/dbo.sp_help_permissions.sql similarity index 100% rename from Stored_Procedure/sp_help_permissions.sql rename to Stored_Procedure/dbo.sp_help_permissions.sql diff --git a/Stored_Procedure/dbo.sp_helpme.sql b/Stored_Procedure/dbo.sp_helpme.sql new file mode 100644 index 00000000..8493b30a --- /dev/null +++ b/Stored_Procedure/dbo.sp_helpme.sql @@ -0,0 +1,477 @@ +SET ANSI_NULLS ON; +GO + +SET QUOTED_IDENTIFIER ON; +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'Description' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_helpme', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'Description' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_helpme'; + END +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@SqlMinorVersion' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_helpme', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@SqlMinorVersion' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_helpme'; + END +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@SqlMajorVersion' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_helpme', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@SqlMajorVersion' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_helpme'; + END +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@ExtendedPropertyName' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_helpme', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@ExtendedPropertyName' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_helpme'; + END +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@ObjectName' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_helpme', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@ObjectName' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_helpme'; + END +GO + +/***************************/ +/* Create stored procedure */ +/***************************/ +IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_helpme]') AND [type] IN (N'P', N'PC')) + BEGIN; + EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[sp_helpme] AS'; + END +GO + +ALTER PROCEDURE [dbo].[sp_helpme] + @ObjectName SYSNAME = NULL + ,@ExtendedPropertyName SYSNAME = 'Description' + /* Parameters defined here for testing only */ + ,@SqlMajorVersion TINYINT = 0 + ,@SqlMinorVersion SMALLINT = 0 +AS + +/* +sp_helpme - A drop-in modern alternative to sp_help. + +Part of the DBA MultiTool http://dba-multitool.org + +Version: Version: 20201008 + +MIT License + +Copyright (c) 2020 John McCall + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, +and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial +portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +========= + +Example: + + EXEC sp_helpme 'dbo.Sales'; + +*/ + +BEGIN + SET NOCOUNT ON; + + DECLARE @DbName SYSNAME + ,@ObjShortName SYSNAME = N'' + ,@No VARCHAR(5) = 'no' + ,@Yes VARCHAR(5) = 'yes' + ,@None VARCHAR(5) = 'none' + ,@SysObj_Type CHAR(2) + ,@ObjID INT + ,@HasParam INT = 0 + ,@HasDepen BIT = 0 + ,@HasHidden BIT = 0 + ,@HasMasked BIT = 0 + ,@SQLString NVARCHAR(MAX) = N'' + ,@Msg NVARCHAR(MAX) = N'' + ,@ParmDefinition NVARCHAR(500); + + /* Find Version */ + IF (@SqlMajorVersion = 0) + BEGIN; + SET @SqlMajorVersion = CAST(SERVERPROPERTY('ProductMajorVersion') AS TINYINT); + END; + IF (@SqlMinorVersion = 0) + BEGIN; + SET @SqlMinorVersion = CAST(SERVERPROPERTY('ProductMinorVersion') AS TINYINT); + END; + + /* Validate Version */ + IF (@SqlMajorVersion < 11) + BEGIN; + SET @Msg = 'SQL Server versions below 2012 are not supported, sorry!'; + RAISERROR(@Msg, 16, 1); + END; + + /* Check for Hidden Columns feature */ + IF 1 = (SELECT COUNT(*) FROM sys.all_columns AS ac WHERE ac.name = 'is_hidden' AND OBJECT_NAME(ac.object_id) = 'all_columns') + BEGIN + SET @HasHidden = 1; + END; + + /* Check for Masked Columns feature */ + IF 1 = (SELECT COUNT(*) FROM sys.all_columns AS ac WHERE ac.name = 'is_masked' AND OBJECT_NAME(ac.object_id) = 'all_columns') + BEGIN + SET @HasMasked = 1; + END; + + -- If no @ObjectName given, give a little info about all objects. + IF (@ObjectName IS NULL) + BEGIN; + SET @SQLString = N'SELECT + [Name] = [o].[name], + [Owner] = USER_NAME(OBJECTPROPERTY([object_id], ''ownerid'')), + [Object_type] = LOWER(REPLACE([o].[type_desc], ''_'', '' '')), + [Create_datetime] = [o].[create_date], + [Modify_datetime] = [o].[modify_date], + [ExtendedProperty] = [ep].[value] + FROM [sys].[all_objects] [o] + LEFT JOIN [sys].[extended_properties] [ep] ON [ep].[major_id] = [o].[object_id] + and [ep].[name] = @ExtendedPropertyName + AND [ep].[minor_id] = 0 + AND [ep].[class] = 1 + ORDER BY [Owner] ASC, [Object_type] DESC, [name] ASC;'; + SET @ParmDefinition = N'@ExtendedPropertyName SYSNAME'; + + EXEC sp_executesql @SQLString + ,@ParmDefinition + ,@ExtendedPropertyName; + + -- Display all user types + SET @SQLString = N'SELECT + [User_type] = [name], + [Storage_type] = TYPE_NAME(system_type_id), + [Length] = max_length, + [Prec] = [precision], + [Scale] = [scale], + [Nullable] = CASE WHEN is_nullable = 1 THEN @Yes ELSE @No END, + [Default_name] = ISNULL(OBJECT_NAME(default_object_id), @None), + [Rule_name] = ISNULL(OBJECT_NAME(rule_object_id), @None), + [Collation] = collation_name + FROM sys.types + WHERE user_type_id > 256 + ORDER BY [name];'; + SET @ParmDefinition = N'@Yes VARCHAR(5), @No VARCHAR(5), @None VARCHAR(5)'; + + EXEC sp_executesql @SQLString + ,@ParmDefinition + ,@Yes + ,@No + ,@None; + + RETURN(0); + END -- End all Sysobjects + + -- Make sure the @ObjectName is local to the current database. + SELECT @ObjShortName = PARSENAME(@ObjectName,1); + SELECT @DbName = PARSENAME(@ObjectName,3); + IF @DbName IS NULL + SELECT @DbName = DB_NAME(); + ELSE IF @DbName <> DB_NAME() + BEGIN + RAISERROR(15250,-1,-1); + END + + -- @ObjectName must be either sysobjects or systypes: first look in sysobjects + SET @SQLString = N'SELECT @ObjID = object_id + , @SysObj_Type = type + FROM sys.all_objects + WHERE object_id = OBJECT_ID(@ObjectName);'; + SET @ParmDefinition = N'@ObjectName SYSNAME + ,@ObjID INT OUTPUT + ,@SysObj_Type VARCHAR(5) OUTPUT'; + + EXEC sp_executesql @SQLString + ,@ParmDefinition + ,@ObjectName + ,@ObjID OUTPUT + ,@SysObj_Type OUTPUT; + + -- If @ObjectName not in sysobjects, try systypes + IF @ObjID IS NULL + BEGIN + SET @SQLSTring = N'SELECT @ObjID = user_type_id + FROM sys.types + WHERE name = PARSENAME(@ObjectName,1);'; + SET @ParmDefinition = N'@ObjectName SYSNAME + ,@ObjID INT OUTPUT'; + + EXEC sp_executesql @SQLString + ,@ParmDefinition + ,@ObjectName + ,@ObjID OUTPUT; + + -- If not in systypes, return + IF @ObjID IS NULL + BEGIN + RAISERROR(15009,-1,-1,@ObjectName,@DbName); + END + + -- Data Type help (prec/scale only valid for numerics) + SET @SQLString = N'SELECT + [Type_name] = t.name, + [Storage_type] = type_name(system_type_id), + [Length] = max_length, + [Prec] = [precision], + [Scale] = [scale], + [Nullable] = case when is_nullable=1 then @Yes else @No end, + [Default_name] = isnull(object_name(default_object_id), @None), + [Rule_name] = isnull(object_name(rule_object_id), @None), + [Collation] = collation_name, + [ExtendedProperty] = ep.[value] + FROM [sys].[types] AS [t] + LEFT JOIN [sys].[extended_properties] AS [ep] ON [ep].[major_id] = [t].[user_type_id] + AND [ep].[name] = @ExtendedPropertyName + AND [ep].[minor_id] = 0 + AND [ep].[class] = 6 + WHERE [user_type_id] = @ObjID'; + SET @ParmDefinition = N'@ObjID INT, @Yes VARCHAR(5), @No VARCHAR(5), @None VARCHAR(5), @ExtendedPropertyName SYSNAME'; + + EXECUTE sp_executesql @SQLString + ,@ParmDefinition + ,@ObjID + ,@Yes + ,@No + ,@None + ,@ExtendedPropertyName; + + RETURN(0); + END --Systypes + + -- FOUND IT IN SYSOBJECT, SO GIVE OBJECT INFO + SET @SQLString = N'SELECT + [Name] = [o].[name], + [Owner] = USER_NAME(ObjectProperty([o].[object_id], ''ownerid'')), + [Type] = LOWER(REPLACE([o].[type_desc], ''_'', '' '')), + [Created_datetime] = [o].[create_date], + [Modify_datetime] = [o].[modify_date], + [ExtendedProperty] = [ep].[value] + FROM [sys].[all_objects] [o] + LEFT JOIN [sys].[extended_properties] [ep] ON [ep].[major_id] = [o].[object_id] + AND [ep].[name] = @ExtendedPropertyName + AND [ep].[minor_id] = 0 + AND [ep].[class] = 1 + WHERE [o].[object_id] = @ObjID;'; + + SET @ParmDefinition = N'@ObjID INT, @ExtendedPropertyName SYSNAME'; + + EXEC sp_executesql @SQLString + ,@ParmDefinition + ,@ObjID + ,@ExtendedPropertyName; + + -- Display column metadata if table / view + SET @SQLString = N' + IF EXISTS (select * from sys.all_columns where object_id = @ObjID) + BEGIN; + + -- SET UP NUMERIC TYPES: THESE WILL HAVE NON-BLANK PREC/SCALE + -- There must be a '','' immediately after each type name (including last one), + -- because that''s what we''ll search for in charindex later. + DECLARE @precscaletypes NVARCHAR(150); + SELECT @precscaletypes = N''tinyint,smallint,decimal,int,bigint,real,money,float,numeric,smallmoney,date,time,datetime2,datetimeoffset,'' + + -- INFO FOR EACH COLUMN + select + [Column_name] = ac.name, + [Type] = type_name([ac].[user_type_id]), + [Computed] = case when ColumnProperty(object_id, [ac].[name], ''IsComputed'') = 0 then ''no'' else ''yes'' end, + [Length] = convert(int, [ac].[max_length]), + -- for prec/scale, only show for those types that have valid precision/scale + -- Search for type name + '','', because ''datetime'' is actually a substring of ''datetime2'' and ''datetimeoffset'' + [Prec] = case when charindex(type_name([ac].[system_type_id]) + '','', '''') > 0 + then convert(char(5),ColumnProperty(object_id, ac.name, ''precision'')) + else '' '' end, + [Scale] = case when charindex(type_name([ac].[system_type_id]) + '','', '''') > 0 + then convert(char(5),OdbcScale([ac].[system_type_id],[ac].[scale])) + else '' '' end, + [Nullable] = case when [ac].[is_nullable] = 0 then ''no'' else ''yes'' end, '; + + --Only include if they exist on the current version + IF @HasMasked = 1 + BEGIN + SET @SQLString = @SQLString + N'[Masked] = case when is_masked = 0 then ''no'' else ''yes'' end, '; + END + + SET @SQLString = @SQLString + N'[Sparse] = case when is_sparse = 0 then ''no'' else ''yes'' end, '; + + IF @HasHidden = 1 + BEGIN + SET @SQLString = @SQLString + N'[Hidden] = case when is_hidden = 0 then ''no'' else ''yes'' end, '; + END + + SET @SQLString = @SQLString + N' + [Identity] = case when is_identity = 0 then ''no'' else ''yes'' end, + [TrimTrailingBlanks] = case ColumnProperty(object_id, ac.name, ''UsesAnsiTrim'') + when 1 then ''no'' + when 0 then ''yes'' + else ''(n/a)'' end, + [FixedLenNullInSource] = case + when type_name([ac].[system_type_id]) not in (''varbinary'',''varchar'',''binary'',''char'') + then ''(n/a)'' + when [ac].[is_nullable] = 0 then ''no'' else ''yes'' end, + [Collation] = [ac].[collation_name], + [ExtendedProperty] = [ep].[value] + FROM [sys].[all_columns] AS [ac] + INNER JOIN [sys].[types] AS [typ] ON [typ].[system_type_id] = [ac].[system_type_id] + LEFT JOIN sys.extended_properties ep ON ep.minor_id = ac.column_id + AND ep.major_id = ac.[object_id] + AND ep.[name] = @ExtendedPropertyName + AND ep.class = 1 + WHERE [object_id] = @ObjID + END'; + SET @ParmDefinition = N'@ObjID INT, @ExtendedPropertyName SYSNAME'; + EXEC sp_executesql @SQLString, @ParmDefinition, @ObjID = @ObjID, @ExtendedPropertyName = @ExtendedPropertyName; + + -- Identity & rowguid columns + IF @SysObj_Type IN ('S ','U ','V ','TF') + BEGIN + DECLARE @colname SYSNAME = NULL; + SET @SQLString = N'SELECT @colname = COL_NAME(@ObjID, column_id) + FROM sys.identity_columns + WHERE object_id = @ObjID;'; + SET @ParmDefinition = N'@ObjID INT, @colname SYSNAME OUTPUT'; + + EXEC sp_executesql @SQLString + ,@ParmDefinition + ,@ObjID + ,@colname OUTPUT; + + --Identity + IF (@colname IS NOT NULL) + SELECT + 'Identity' = @colname, + 'Seed' = IDENT_SEED(@ObjectName), + 'Increment' = IDENT_INCR(@ObjectName), + 'Not For Replication' = COLUMNPROPERTY(@ObjID, @colname, 'IsIDNotForRepl'); + ELSE + BEGIN + SET @Msg = 'No identity is defined on object %ls.'; + RAISERROR(@Msg, 10, 1, @ObjectName) WITH NOWAIT; + END + + -- Rowguid + SET @colname = NULL; + SET @SQLString = N'SELECT @colname = [name] + FROM sys.all_columns + WHERE [object_id] = @ObjID AND is_rowguidcol = 1;'; + SET @ParmDefinition = N'@ObjID INT, @colname SYSNAME OUTPUT'; + + EXEC sp_executesql @SQLString + ,@ParmDefinition + ,@ObjID + ,@colname OUTPUT; + + IF (@colname IS NOT NULL) + SELECT 'RowGuidCol' = @colname; + ELSE + BEGIN + SET @Msg = 'No rowguid is defined on object %ls.'; + RAISERROR(@Msg, 10, 1, @ObjectName) WITH NOWAIT; + END + END + + -- Display any procedure parameters + SET @SQLString = N'SELECT TOP (1) @HasParam = 1 FROM sys.all_parameters WHERE object_id = @ObjID'; + SET @ParmDefinition = N'@ObjID INT, @HasParam BIT OUTPUT'; + + EXEC sp_executesql @SQLString + ,@ParmDefinition + ,@ObjID + ,@HasParam OUTPUT; + + --If parameters exist, show them + IF @HasParam = 1 + BEGIN + SET @SQLString = N'SELECT + [Parameter_name] = [name], + [Type] = TYPE_NAME(user_type_id), + [Length] = max_length, + [Prec] = CASE WHEN TYPE_NAME(system_type_id) = ''uniqueidentifier'' THEN [precision] + ELSE OdbcPrec(system_type_id, max_length, [precision]) END, + [Scale] = ODBCSCALE(system_type_id, scale), + [Param_order] = parameter_id, + [Collation] = CONVERT([sysname], CASE WHEN system_type_id in (35, 99, 167, 175, 231, 239) + THEN SERVERPROPERTY(''collation'') END) + FROM sys.all_parameters + WHERE [object_id] = @ObjID;'; + SET @ParmDefinition = N'@ObjID INT'; + + EXEC sp_executesql @SQLString + ,@ParmDefinition + ,@ObjID; + END + + -- DISPLAY TABLE INDEXES & CONSTRAINTS + IF @SysObj_Type IN ('S ','U ') + BEGIN + EXEC sys.sp_objectfilegroup @ObjID; + EXEC sys.sp_helpindex @ObjectName; + EXEC sys.sp_helpconstraint @ObjectName,'nomsg'; + + SET @SQLString = N'SELECT @HasDepen = COUNT(*) + FROM sys.objects obj, sysdepends deps + WHERE obj.[type] =''V'' + AND obj.[object_id] = deps.id + AND deps.depid = @ObjID + AND deps.deptype = 1;'; + SET @ParmDefinition = N'@ObjID INT, @HasDepen INT OUTPUT'; + + EXEC sp_executeSQL @SQLString + ,@ParmDefinition + ,@ObjID + ,@HasDepen OUTPUT; + + IF @HasDepen = 0 + BEGIN + RAISERROR(15647,-1,-1,@ObjectName); -- No views with schemabinding for reference table '%ls'. + END + ELSE + BEGIN + SET @SQLString = N'SELECT DISTINCT [Table is referenced by views] = OBJECT_SCHEMA_NAME(obj.object_id) + ''.'' + obj.[name] + FROM sys.objects obj + INNER JOIN sysdepends deps ON obj.object_id = deps.id + WHERE obj.[type] =''V'' + AND deps.depid = @ObjID + AND deps.deptype = 1 + GROUP BY obj.[name], obj.object_id;'; + SET @ParmDefinition = N'@ObjID INT'; + + EXEC sp_executesql @SQLString + ,@ParmDefinition + ,@ObjID; + END + END +END; +GO + +EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Drop-in alternative to sp_help. Documentation at https://expresssql.lowlydba.com' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_helpme'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@ObjectName', @value=N'Target object. Default is all objects.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_helpme'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@ExtendedPropertyName', @value=N'Key for extended properties on objects. Default is ''Description''.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_helpme'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@SqlMajorVersion', @value=N'Used for unit testing purposes only.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_helpme'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@SqlMinorVersion', @value=N'Used for unit testing purposes only.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_helpme'; +GO diff --git a/Stored_Procedure/sp_ns_shrink_db_log.sql b/Stored_Procedure/dbo.sp_ns_shrink_db_log.sql similarity index 100% rename from Stored_Procedure/sp_ns_shrink_db_log.sql rename to Stored_Procedure/dbo.sp_ns_shrink_db_log.sql diff --git a/Stored_Procedure/dbo.sp_sizeoptimiser.sql b/Stored_Procedure/dbo.sp_sizeoptimiser.sql new file mode 100644 index 00000000..b090bd54 --- /dev/null +++ b/Stored_Procedure/dbo.sp_sizeoptimiser.sql @@ -0,0 +1,1367 @@ +SET ANSI_NULLS ON; +GO + +SET QUOTED_IDENTIFIER ON; +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'Description' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_sizeoptimiser', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'Description' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_sizeoptimiser'; + END +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'Description' , N'SCHEMA',N'dbo', N'TYPE',N'SizeOptimiserTableType', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'Description' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TYPE',@level1name=N'SizeOptimiserTableType'; + END +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@SqlMinorVersion' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_sizeoptimiser', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@SqlMinorVersion' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_sizeoptimiser'; + END +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@SqlMajorVersion' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_sizeoptimiser', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@SqlMajorVersion' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_sizeoptimiser'; + END +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@IndexNumThreshold' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_sizeoptimiser', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@IndexNumThreshold' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_sizeoptimiser'; + END +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@IncludeDatabases' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_sizeoptimiser', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@IncludeDatabases' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_sizeoptimiser'; + END +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@ExcludeDatabases' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_sizeoptimiser', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@ExcludeDatabases' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_sizeoptimiser'; + END +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@IncludeSysDatabases' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_sizeoptimiser', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@IncludeSysDatabases' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_sizeoptimiser'; + END +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@IncludeSSRSDatabases' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_sizeoptimiser', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@IncludeSSRSDatabases' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_sizeoptimiser'; + END +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@Verbose' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_sizeoptimiser', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@Verbose' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_sizeoptimiser'; + END +GO + +IF EXISTS (SELECT * FROM sys.fn_listextendedproperty(N'@IsExpress' , N'SCHEMA',N'dbo', N'PROCEDURE',N'sp_sizeoptimiser', NULL,NULL)) + BEGIN; + EXEC sys.sp_dropextendedproperty @name=N'@IsExpress' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_sizeoptimiser'; + END +GO + +/******************************/ +/* Cleanup existing versions */ +/******************************/ +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_sizeoptimiser]')) + BEGIN + DROP PROCEDURE [dbo].[sp_sizeoptimiser]; + END; + +IF EXISTS (SELECT * FROM sys.types st JOIN sys.schemas ss ON st.schema_id = ss.schema_id WHERE st.name = N'SizeOptimiserTableType' AND ss.name = N'dbo') + BEGIN + DROP TYPE [dbo].[SizeOptimiserTableType]; + END; +GO + +/**************************************************************/ +/* Create user defined table type for database list parameter */ +/**************************************************************/ +IF NOT EXISTS (SELECT * FROM sys.types st JOIN sys.schemas ss ON st.schema_id = ss.schema_id WHERE st.name = N'SizeOptimiserTableType' AND ss.name = N'dbo') + BEGIN + CREATE TYPE [dbo].[SizeOptimiserTableType] AS TABLE( + [database_name] [sysname] NOT NULL, + PRIMARY KEY CLUSTERED ([database_name] ASC) WITH (IGNORE_DUP_KEY = OFF)); + END; +GO + +/***************************/ +/* Create stored procedure */ +/***************************/ +IF NOT EXISTS(SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_sizeoptimiser]')) + BEGIN + EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[sp_sizeoptimiser] AS'; + END; +GO + +ALTER PROCEDURE [dbo].[sp_sizeoptimiser] + @IndexNumThreshold SMALLINT = 10 + ,@IncludeDatabases [dbo].[SizeOptimiserTableType] READONLY + ,@ExcludeDatabases [dbo].[SizeOptimiserTableType] READONLY + ,@IncludeSysDatabases BIT = 0 + ,@IncludeSSRSDatabases BIT = 0 + ,@Verbose BIT = 1 + /* Parameters defined here for testing only */ + ,@IsExpress BIT = NULL + ,@SqlMajorVersion TINYINT = NULL + ,@SqlMinorVersion SMALLINT = NULL + +WITH RECOMPILE +AS + +/* +sp_sizeoptimiser - Recommends space saving measures for data footprints. + +Part of the DBA MultiTool http://dba-multitool.org + +Version: 20201110 + +MIT License + +Copyright (c) 2020 John McCall + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, +and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial +portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +========= + +Example: + + DECLARE @include SizeOptimiserTableType; + + INSERT INTO @include ([database_name]) + VALUES (N'WideWorldImporters'); + + EXEC [dbo].[sp_sizeoptimiser] @IncludeDatabases = @include +*/ + +BEGIN + SET NOCOUNT ON; + + BEGIN TRY + + DECLARE @HasTempStat BIT = 0 + ,@HasPersistedSamplePercent BIT = 0 + ,@CheckNumber TINYINT = 0 + ,@EngineEdition TINYINT + ,@CheckSQL NVARCHAR(MAX) = N'' + ,@Msg NVARCHAR(MAX) = N'' + ,@DbName SYSNAME = N'' + ,@TempCheckSQL NVARCHAR(MAX) = N'' + ,@BaseURL VARCHAR(1000) = 'http://dba-multitool.org/'; + + /* Validate @IndexNumThreshold */ + IF (@IndexNumThreshold < 1 OR @IndexNumThreshold > 999) + BEGIN + SET @Msg = '@IndexNumThreshold must be between 1 and 999.'; + RAISERROR(@Msg, 16, 1); + END + + /* Validate database list */ + IF (SELECT COUNT(*) FROM @IncludeDatabases) >= 1 AND (SELECT COUNT(*) FROM @ExcludeDatabases) >= 1 + BEGIN + SET @Msg = 'Both @IncludeDatabases and @ExcludeDatabases cannot be specified.'; + RAISERROR(@Msg, 16, 1); + END + + CREATE TABLE #Databases ( + [database_name] SYSNAME NOT NULL); + + /* Build database list if no parameters set */ + IF (SELECT COUNT(*) FROM @IncludeDatabases) = 0 AND (SELECT COUNT(*) FROM @ExcludeDatabases) = 0 + BEGIN + INSERT INTO #Databases + SELECT [sd].[name] + FROM [sys].[databases] AS [sd] + WHERE ([sd].[database_id] > 4 OR @IncludeSysDatabases = 1) + AND ([sd].[name] NOT IN ('ReportServer', 'ReportServerTempDB') OR @IncludeSSRSDatabases = 1) + AND DATABASEPROPERTYEX([sd].[name], 'UPDATEABILITY') = N'READ_WRITE' + AND DATABASEPROPERTYEX([sd].[name], 'USERACCESS') = N'MULTI_USER' + AND DATABASEPROPERTYEX([sd].[name], 'STATUS') = N'ONLINE'; + END; + /* Build database list from @IncludeDatabases */ + ELSE IF (SELECT COUNT(*) FROM @IncludeDatabases) >= 1 + BEGIN + INSERT INTO #Databases + SELECT [sd].[name] + FROM @IncludeDatabases AS [d] + INNER JOIN [sys].[databases] AS [sd] ON [sd].[name] COLLATE database_default = REPLACE(REPLACE([d].[database_name], '[', ''), ']', '') + WHERE DATABASEPROPERTYEX([sd].[name], 'UPDATEABILITY') = N'READ_WRITE' + AND DATABASEPROPERTYEX([sd].[name], 'USERACCESS') = N'MULTI_USER' + AND DATABASEPROPERTYEX([sd].[name], 'STATUS') = N'ONLINE'; + + IF (SELECT COUNT(*) FROM @IncludeDatabases) > (SELECT COUNT(*) FROM #Databases) + BEGIN + DECLARE @ErrorDatabaseList NVARCHAR(MAX); + + WITH ErrorDatabase AS( + SELECT [database_name] + FROM @IncludeDatabases + EXCEPT + SELECT [database_name] + FROM #Databases) + + SELECT @ErrorDatabaseList = ISNULL(@ErrorDatabaseList + N', ' + [database_name], [database_name]) + FROM ErrorDatabase; + + SET @Msg = 'Supplied databases do not exist or are not accessible: ' + @ErrorDatabaseList + '.'; + RAISERROR(@Msg, 16, 1); + END; + END; + /* Build database list from @ExcludeDatabases */ + ELSE IF (SELECT COUNT(*) FROM @ExcludeDatabases) >= 1 + BEGIN + INSERT INTO #Databases + SELECT [sd].[name] + FROM [sys].[databases] AS [sd] + WHERE NOT EXISTS (SELECT [d].[database_name] + FROM @IncludeDatabases AS [d] + WHERE [sd].[name] COLLATE database_default = REPLACE(REPLACE([d].[database_name], '[', ''), ']', '')) + AND DATABASEPROPERTYEX([sd].[name], 'UPDATEABILITY') = N'READ_WRITE' + AND DATABASEPROPERTYEX([sd].[name], 'USERACCESS') = N'MULTI_USER' + AND DATABASEPROPERTYEX([sd].[name], 'STATUS') = N'ONLINE' + AND [sd].[name] <> 'tempdb'; + END + + /* Find edition */ + IF (@IsExpress IS NULL AND CAST(SERVERPROPERTY('Edition') AS VARCHAR(50)) LIKE 'Express%') + BEGIN + SET @IsExpress = 1; + END; + ELSE IF (@IsExpress IS NULL) + BEGIN; + SET @IsExpress = 0; + END; + + /* Find engine edition */ + IF (@EngineEdition IS NULL) + BEGIN + SET @EngineEdition = CAST(SERVERPROPERTY('EditionEdition') AS TINYINT); + END; + + /* Find Version */ + IF (@SqlMajorVersion IS NULL) + BEGIN; + SET @SqlMajorVersion = CAST(SERVERPROPERTY('ProductMajorVersion') AS TINYINT); + END; + IF (@SqlMinorVersion IS NULL) + BEGIN; + SET @SqlMinorVersion = CAST(SERVERPROPERTY('ProductMinorVersion') AS SMALLINT); + END; + + /* Validate Version */ + IF (@SqlMajorVersion < 11) + BEGIN; + SET @Msg = 'SQL Server versions below 2012 are not supported, sorry!'; + RAISERROR(@Msg, 16, 1); + END; + + /* Check for is_temp value on statistics */ + IF 1 = (SELECT 1 FROM [sys].[all_columns] AS [ac] WHERE [ac].[name] = 'is_temporary' AND OBJECT_NAME([ac].[object_id]) = 'all_columns') + BEGIN; + SET @HasTempStat = 1; + END; + + /* Check for Persisted Sample Percent update */ + IF 1 = (SELECT 1 FROM [sys].[all_columns] AS [ac] WHERE [ac].[name] = 'persisted_sample_percent' AND OBJECT_NAME([ac].[object_id]) = 'dm_db_stats_properties') + BEGIN; + SET @HasPersistedSamplePercent = 1; + END; + + IF (@Verbose = 1) + BEGIN; + /* Print info */ + SET @Msg = 'sp_sizeoptimiser'; + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + SET @Msg = '------------'; + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + SET @Msg = CONCAT('Time: ', GETDATE()); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + SET @Msg = CONCAT('SQL Major Version: ', @SqlMajorVersion); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + SET @Msg = CONCAT('SQL Minor Version: ', @SqlMinorVersion); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + SET @Msg = CONCAT('Is Express Edition: ', @IsExpress); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + SET @Msg = CONCAT('Is feature "persisted sample percent" available: ', @HasPersistedSamplePercent); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + SET @Msg = CONCAT(CHAR(13), CHAR(10)); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + + /* Build temp tables */ + IF OBJECT_ID(N'tempdb..#results') IS NOT NULL + BEGIN; + DROP TABLE #results; + END; + + CREATE TABLE #results + ([check_num] INT NOT NULL, + [check_type] NVARCHAR(50) NOT NULL, + [db_name] SYSNAME NOT NULL, + [obj_type] SYSNAME NOT NULL, + [obj_name] NVARCHAR(400) NOT NULL, + [col_name] SYSNAME NULL, + [message] NVARCHAR(500) NULL, + [ref_link] NVARCHAR(500) NULL); + + IF OBJECT_ID('tempdb..#DuplicateIndex') IS NOT NULL + BEGIN; + DROP TABLE #DuplicateIndex; + END; + + CREATE TABLE #DuplicateIndex + ([check_type] NVARCHAR(50) NOT NULL + ,[obj_type] SYSNAME NOT NULL + ,[db_name] SYSNAME NOT NULL + ,[obj_name] SYSNAME NOT NULL + ,[col_name] SYSNAME NULL + ,[message] NVARCHAR(500) NULL + ,[object_id] INT NOT NULL + ,[index_id] INT NOT NULL); + + IF OBJECT_ID('tempdb..#OverlappingIndex') IS NOT NULL + BEGIN; + DROP TABLE #OverlappingIndex; + END; + + CREATE TABLE #OverlappingIndex + ([check_type] NVARCHAR(50) NOT NULL + ,[obj_type] SYSNAME NOT NULL + ,[db_name] SYSNAME NOT NULL + ,[obj_name] SYSNAME NOT NULL + ,[col_name] SYSNAME NULL + ,[message] NVARCHAR(500) NULL + ,[object_id] INT NOT NULL + ,[index_id] INT NOT NULL); + + /* Header row */ + INSERT INTO #results ([check_num], [check_type], [obj_type], [db_name], [obj_name], [col_name], [message], [ref_link]) + SELECT @CheckNumber + ,N'Lets do this' + ,N'Vroom vroom' + ,N'beep boop' + ,N'Off to the races' + ,N'Ready set go' + ,N'Thanks for using' + ,@BaseURL; + + /* Date & Time Data Type Usage */ + SET @CheckNumber = @CheckNumber + 1; + IF (@Verbose = 1) + BEGIN; + SET @Msg = CONCAT(N'Check ', @CheckNumber, ' - Date and Time Data Types'); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + BEGIN; + SET @CheckSQL = N''; + SELECT @CheckSQL = @CheckSQL + + N'USE ' + QUOTENAME([database_name]) + N'; + INSERT INTO #results ([check_num], [check_type], [obj_type], [db_name], [obj_name], [col_name], [message], [ref_link]) + SELECT @CheckNumber + ,N''Data Types'' + ,N''USER_TABLE'' + ,QUOTENAME(DB_NAME()) + ,QUOTENAME(SCHEMA_NAME([t].[schema_id])) + ''.'' + QUOTENAME([t].[name]) + ,QUOTENAME([c].[name]) + ,N''Columns storing date or time should use a temporal specific data type, but this column is using '' + ty.name + ''.'' + ,CONCAT(@BaseURL COLLATE database_default, ''time-based-formats'') + FROM [sys].[columns] AS [c] + INNER JOIN [sys].[tables] AS [t] on [t].[object_id] = [c].[object_id] + INNER JOIN [sys].[types] AS [ty] on [ty].[user_type_id] = [c].[user_type_id] + WHERE [c].[is_identity] = 0 --exclude identity cols + AND [t].[is_ms_shipped] = 0 --exclude sys table + AND ([c].[name] LIKE ''%date%'' OR [c].[name] LIKE ''%time%'') + AND [c].[name] NOT LIKE ''%UpdatedBy%'' + AND [c].[name] NOT LIKE ''%days%'' + AND [ty].[name] NOT IN (''datetime'', ''datetime2'', ''datetimeoffset'', ''date'', ''smalldatetime'', ''time'');' + FROM #Databases; + EXEC sp_executesql @CheckSQL, N'@CheckNumber TINYINT, @BaseURL VARCHAR(1000)', @CheckNumber = @CheckNumber, @BaseURL = @BaseURL; + END; --Date and Time Data Type Check + + /* Archaic varchar Lengths (255/256) */ + SET @CheckNumber = @CheckNumber + 1; + IF (@Verbose = 1) + BEGIN; + SET @Msg = CONCAT(N'Check ', @CheckNumber, ' - Archaic varchar Lengths'); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + BEGIN; + SET @CheckSQL = N''; + SELECT @CheckSQL = @CheckSQL + + N'USE ' + QUOTENAME([database_name]) + N'; WITH archaic AS ( + SELECT QUOTENAME(SCHEMA_NAME(t.schema_id)) + ''.'' + QUOTENAME(t.name) AS [obj_name] + ,QUOTENAME(c.name) AS [col_name] + ,N''Possible arbitrary variable length column in use. Is the '' + ty.name + N'' length of '' + CAST (c.max_length / 2 AS varchar(MAX)) + N'' based on requirements?'' AS [message] + ,CONCAT(@BaseURL COLLATE database_default, ''arbitrary-varchar-length'') AS [ref_link] + FROM sys.columns c + INNER JOIN sys.tables as t on t.object_id = c.object_id + INNER JOIN sys.types as ty on ty.user_type_id = c.user_type_id + WHERE c.is_identity = 0 --exclude identity cols + AND t.is_ms_shipped = 0 --exclude sys table + AND ty.name = ''NVARCHAR'' + AND c.max_length IN (510, 512) + UNION + SELECT QUOTENAME(SCHEMA_NAME(t.schema_id)) + ''.'' + QUOTENAME(t.name) + ,QUOTENAME(c.name) + ,N''Possible arbitrary variable length column in use. Is the '' + ty.name + N'' length of '' + CAST (c.max_length AS varchar(MAX)) + N'' based on requirements'' + ,CONCAT(@BaseURL COLLATE database_default, ''arbitrary-varchar-length'') + FROM sys.columns as c + INNER JOIN sys.tables as t on t.object_id = c.object_id + INNER JOIN sys.types as ty on ty.user_type_id = c.user_type_id + WHERE c.is_identity = 0 --exclude identity cols + AND t.is_ms_shipped = 0 --exclude sys table + AND ty.name = ''VARCHAR'' + AND c.max_length IN (255, 256)) + + INSERT INTO #results ([check_num], [check_type], [obj_type], [db_name], [obj_name], [col_name], [message], [ref_link]) + SELECT @CheckNumber + ,N''Data Types'' + ,N''USER_TABLE'' + ,QUOTENAME(DB_NAME()) + ,[obj_name] + ,[col_name] + ,[message] + ,[ref_link] + FROM [archaic];' + FROM #Databases; + EXEC sp_executesql @CheckSQL, N'@CheckNumber TINYINT, @BaseURL VARCHAR(1000)', @CheckNumber = @CheckNumber, @BaseURL = @BaseURL; + END; --Archaic varchar Lengths + + /* Unspecified VARCHAR Length */ + SET @CheckNumber = @CheckNumber + 1; + IF (@Verbose = 1) + BEGIN; + SET @Msg = CONCAT(N'Check ', @CheckNumber,' - Unspecified VARCHAR Length'); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + BEGIN; + SET @CheckSQL = N''; + SELECT @CheckSQL = @CheckSQL + + N'USE ' + QUOTENAME([database_name]) + '; + WITH UnspecifiedVarChar AS ( + SELECT QUOTENAME(SCHEMA_NAME(t.schema_id)) + ''.'' + QUOTENAME(t.name) AS [obj_name] + ,QUOTENAME(c.name) AS [col_name] + ,N''VARCHAR column without specified length, it should not have a length of '' + CAST (c.max_length AS varchar(10)) + '''' AS [message] + ,CONCAT(@BaseURL COLLATE database_default, ''unspecified-varchar-length'') AS [ref_link] + FROM sys.columns as c + INNER JOIN sys.tables as t on t.object_id = c.object_id + INNER JOIN sys.types as ty on ty.user_type_id = c.user_type_id + WHERE c.is_identity = 0 --exclude identity cols + AND t.is_ms_shipped = 0 --exclude sys table + AND ty.name IN (''VARCHAR'', ''NVARCHAR'') + AND c.max_length = 1) + + INSERT INTO #results ([check_num], [check_type], [obj_type], [db_name], [obj_name], [col_name], [message], [ref_link]) + SELECT @CheckNumber + ,N''Data Types'' + ,N''USER_TABLE'' + ,QUOTENAME(DB_NAME()) + ,[obj_name] + ,[col_name] + ,[message] + ,[ref_link] + FROM [UnspecifiedVarChar];' + FROM #Databases; + EXEC sp_executesql @CheckSQL, N'@CheckNumber TINYINT, @BaseURL VARCHAR(1000)', @CheckNumber = @CheckNumber, @BaseURL = @BaseURL; + END; --Unspecified VARCHAR Length + + /* Mad MAX - Varchar(MAX) */ + SET @CheckNumber = @CheckNumber + 1; + IF (@Verbose = 1) + BEGIN; + SET @Msg = CONCAT(N'Check ', @CheckNumber, ' - Mad MAX VARCHAR'); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + BEGIN; + SET @CheckSQL = N''; + SELECT @CheckSQL = @CheckSQL + + N'USE ' + QUOTENAME([database_name]) + N'; + INSERT INTO #results ([check_num], [check_type], [obj_type], [db_name], [obj_name], [col_name], [message], [ref_link]) + SELECT @CheckNumber + ,N''Data Types'' + ,N''USER_TABLE'' + ,QUOTENAME(DB_NAME()) + ,QUOTENAME(SCHEMA_NAME(t.schema_id)) + ''.'' + QUOTENAME(t.name) + ,QUOTENAME(c.name) + ,N''Column is NVARCHAR(MAX) which allows very large row sizes. Consider a character limit.'' + ,CONCAT(@BaseURL COLLATE database_default, ''mad-varchar-max'') + FROM sys.columns as c + INNER JOIN sys.tables as t on t.object_id = c.object_id + INNER JOIN sys.types as ty on ty.user_type_id = c.user_type_id + WHERE t.is_ms_shipped = 0 --exclude sys table + AND ty.[name] = ''nvarchar'' + AND c.max_length = -1;' + FROM #Databases; + EXEC sp_executesql @CheckSQL, N'@CheckNumber TINYINT, @BaseURL VARCHAR(1000)', @CheckNumber = @CheckNumber, @BaseURL = @BaseURL; + END; --NVARCHAR MAX Check + + /* NVARCHAR data type in Express */ + SET @CheckNumber = @CheckNumber + 1; + IF (@Verbose = 1) + BEGIN; + SET @Msg = CONCAT(N'Check ', @CheckNumber, ' - Use of NVARCHAR (EXPRESS)'); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + BEGIN; + IF (@IsExpress = 1) + BEGIN; + SET @CheckSQL = N''; + SELECT @CheckSQL = @CheckSQL + + N'USE ' + QUOTENAME([database_name]) + N'; + INSERT INTO #results ([check_num], [check_type], [obj_type], [db_name], [obj_name], [col_name], [message], [ref_link]) + SELECT @CheckNumber + ,N''Data Types'' + ,N''USER_TABLE'' + ,QUOTENAME(DB_NAME()) + ,QUOTENAME(SCHEMA_NAME([o].schema_id)) + ''.'' + QUOTENAME(OBJECT_NAME([o].object_id)) + ,QUOTENAME([ac].[name]) + ,N''nvarchar columns take 2x the space per char of varchar. Only use if you need Unicode characters.'' + ,CONCAT(@BaseURL COLLATE database_default, ''nvarchar-in-express'') + FROM [sys].[all_columns] AS [ac] + INNER JOIN [sys].[types] AS [t] ON [t].[user_type_id] = [ac].[user_type_id] + INNER JOIN [sys].[objects] AS [o] ON [o].object_id = [ac].object_id + WHERE [t].[name] = ''NVARCHAR'' + AND [o].[is_ms_shipped] = 0' + FROM #Databases; + EXEC sp_executesql @CheckSQL, N'@CheckNumber TINYINT, @BaseURL VARCHAR(1000)', @CheckNumber = @CheckNumber, @BaseURL = @BaseURL; + END; --NVARCHAR Use Check + ELSE IF (@Verbose = 1) --Skip check + BEGIN; + RAISERROR(' Skipping check, not Express...', 10, 1) WITH NOWAIT; + END; -- Skip check + END; --NVARCHAR Use Check + + /* FLOAT and REAL data types */ + SET @CheckNumber = @CheckNumber + 1; + IF (@Verbose = 1) + BEGIN; + SET @Msg =CONCAT(N'Check ', @CheckNumber, ' - Use of FLOAT/REAL data types'); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + BEGIN; + SET @CheckSQL = N''; + SELECT @CheckSQL = @CheckSQL + + N'USE ' + QUOTENAME([database_name]) + N'; + INSERT INTO #results ([check_num], [check_type], [obj_type], [db_name], [obj_name], [col_name], [message], [ref_link]) + SELECT @CheckNumber + ,N''Data Types'' + ,[o].[type_desc] + ,QUOTENAME(DB_NAME()) + ,QUOTENAME(SCHEMA_NAME([o].[schema_id])) + ''.'' + QUOTENAME([o].[name]) + ,QUOTENAME([ac].[name]) + ,N''Best practice is to use DECIMAL/NUMERIC instead of '' + UPPER([st].[name]) + '' for non floating point math.'' + ,CONCAT(@BaseURL COLLATE database_default, ''float-and-real-data-types'') + FROM [sys].[all_columns] AS [ac] + INNER JOIN [sys].[objects] AS [o] ON [o].[object_id] = [ac].[object_id] + INNER JOIN [sys].[systypes] AS [st] ON [st].[xtype] = [ac].[system_type_id] + WHERE [st].[name] IN (''FLOAT'', ''REAL'') + AND [o].[type_desc] = ''USER_TABLE'';' + FROM #Databases; + EXEC sp_executesql @CheckSQL, N'@CheckNumber TINYINT, @BaseURL VARCHAR(1000)', @CheckNumber = @CheckNumber, @BaseURL = @BaseURL; + END; -- FLOAT/REAL Check + + /* Deprecated data types (NTEXT, TEXT, IMAGE) */ + SET @CheckNumber = @CheckNumber + 1; + IF (@Verbose = 1) + BEGIN; + SET @Msg = CONCAT(N'Check ', @CheckNumber, ' - Deprecated data types'); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + BEGIN; + SET @CheckSQL = N''; + SELECT @CheckSQL = @CheckSQL + + N'USE ' + QUOTENAME([database_name]) + N'; + INSERT INTO #results ([check_num], [check_type], [obj_type], [db_name], [obj_name], [col_name], [message], [ref_link]) + SELECT @CheckNumber + ,N''Data Types'' + ,[o].[type_desc] + ,QUOTENAME(DB_NAME()) + ,QUOTENAME(SCHEMA_NAME(o.schema_id)) + ''.'' + QUOTENAME(o.name) + ,QUOTENAME(ac.name) + ,N''Deprecated data type in use: '' + st.name + ''.'' + ,CONCAT(@BaseURL COLLATE database_default, ''deprecated-data-types'') + FROM sys.all_columns AS ac + INNER JOIN sys.objects AS o ON o.object_id = ac.object_id + INNER JOIN sys.systypes AS st ON st.xtype = ac.system_type_id + WHERE st.name IN(''NEXT'', ''TEXT'', ''IMAGE'') + AND o.type_desc = ''USER_TABLE'';' + FROM #Databases; + EXEC sp_executesql @CheckSQL, N'@CheckNumber TINYINT, @BaseURL VARCHAR(1000)', @CheckNumber = @CheckNumber, @BaseURL = @BaseURL; + END; --Don't use deprecated data types check + + /* BIGINT for identity values in Express */ + SET @CheckNumber = @CheckNumber + 1; + IF (@Verbose = 1) + BEGIN; + SET @Msg = CONCAT(N'Check ', @CheckNumber, ' - BIGINT used for identity columns (EXPRESS)'); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + BEGIN; + IF (@IsExpress = 1) + BEGIN; + SET @CheckSQL = N''; + SELECT @CheckSQL = @CheckSQL + + N'USE ' + QUOTENAME([database_name]) + N'; + INSERT INTO #results ([check_num], [check_type], [obj_type], [db_name], [obj_name], [col_name], [message], [ref_link]) + SELECT @CheckNumber + ,N''Data Types'' + ,N''USER_TABLE'' + ,QUOTENAME(DB_NAME()) + ,QUOTENAME(SCHEMA_NAME(t.schema_id)) + ''.'' + QUOTENAME(t.name) + ,QUOTENAME(c.name) + ,N''BIGINT used on IDENTITY column in SQL Express. If values will never exceed 2,147,483,647 use INT instead.'' + ,CONCAT(@BaseURL COLLATE database_default, ''bigint-as-identity'') + FROM sys.columns as c + INNER JOIN sys.tables as t on t.object_id = c.object_id + INNER JOIN sys.types as ty on ty.user_type_id = c.user_type_id + WHERE t.is_ms_shipped = 0 --exclude sys table + AND ty.name = ''BIGINT'' + AND c.is_identity = 1;' + FROM #Databases; + EXEC sp_executesql @CheckSQL, N'@CheckNumber TINYINT, @BaseURL VARCHAR(1000)', @CheckNumber = @CheckNumber, @BaseURL = @BaseURL; + END; -- BIGINT for identity Check + ELSE IF (@Verbose = 1) --Skip check + BEGIN + RAISERROR(' Skipping check, not Express...', 10, 1) WITH NOWAIT; + END; ----Skip check + END; -- BIGINT for identity Check + + /* Numeric or decimal with 0 scale */ + SET @CheckNumber = @CheckNumber + 1; + IF (@Verbose = 1) + BEGIN; + SET @Msg = CONCAT(N'Check ', @CheckNumber, ' - NUMERIC or DECIMAL with scale of 0'); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + BEGIN; + SET @CheckSQL = N''; + SELECT @CheckSQL = @CheckSQL + + N'USE ' + QUOTENAME([database_name]) + N'; + INSERT INTO #results ([check_num], [check_type], [obj_type], [db_name], [obj_name], [col_name], [message], [ref_link]) + SELECT @CheckNumber + ,N''Data Types'' + ,[o].[type_desc] + ,QUOTENAME(DB_NAME()) + ,QUOTENAME(SCHEMA_NAME(o.schema_id)) + ''.'' + QUOTENAME(o.name) + ,QUOTENAME(ac.name) + ,N''Column is '' + UPPER(st.name) + ''('' + CAST(ac.precision AS VARCHAR) + '','' + CAST(ac.scale AS VARCHAR) + '')'' + + '' . Consider using an INT variety for space reduction since the scale is 0.'' + ,CONCAT(@BaseURL COLLATE database_default, ''numeric-or-decimal-0-scale'') + FROM sys.objects AS o + INNER JOIN sys.all_columns AS ac ON ac.object_id = o.object_id + INNER JOIN sys.systypes AS st ON st.xtype = ac.system_type_id + WHERE ac.scale = 0 + AND ac.precision < 19 + AND st.name IN(''DECIMAL'', ''NUMERIC'') + AND o.is_ms_shipped = 0;' + FROM #Databases; + EXEC sp_executesql @CheckSQL, N'@CheckNumber TINYINT, @BaseURL VARCHAR(1000)', @CheckNumber = @CheckNumber, @BaseURL = @BaseURL; + END; -- Numeric or decimal with 0 scale check + + /* Enum columns not implemented as foreign key */ + SET @CheckNumber = @CheckNumber + 1; + IF (@Verbose = 1) + BEGIN; + SET @Msg = CONCAT(N'Check ', @CheckNumber, ' - Enum columns not implemented as foreign key.'); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + BEGIN; + SET @CheckSQL = N''; + SELECT @CheckSQL = @CheckSQL + + N'USE ' + QUOTENAME([database_name]) + N'; + INSERT INTO #results ([check_num], [check_type], [obj_type], [db_name], [obj_name], [col_name], [message], [ref_link]) + SELECT @CheckNumber + ,N''Data Types'' + ,[o].[type_desc] + ,QUOTENAME(DB_NAME()) + ,QUOTENAME(SCHEMA_NAME(o.schema_id)) + ''.'' + QUOTENAME(o.name) + ,QUOTENAME(ac.name) + ,N''Column is potentially an enum that should be a foreign key to a normalized table for data integrity, space savings, and performance.'' + ,CONCAT(@BaseURL COLLATE database_default, ''enum-column-not-implemented-as-foreign-key'') + FROM sys.objects AS o + INNER JOIN sys.all_columns AS ac ON ac.object_id = o.object_id + INNER JOIN sys.systypes AS st ON st.xtype = ac.system_type_id + WHERE (ac.[name] LIKE ''%Type'' OR ac.[name] LIKE ''%Status'') + AND o.is_ms_shipped = 0 + AND [o].[type] = ''U'' + AND st.[name] IN (''nvarchar'', ''varchar'', ''char'');' + FROM #Databases; + EXEC sp_executesql @CheckSQL, N'@CheckNumber TINYINT, @BaseURL VARCHAR(1000)', @CheckNumber = @CheckNumber, @BaseURL = @BaseURL; + END; -- Enum columns not implemented as foreign key + + /* User DB or model db Growth set past 10GB - ONLY IF EXPRESS */ + SET @CheckNumber = @CheckNumber + 1; + IF (@Verbose = 1) + BEGIN; + SET @Msg = CONCAT(N'Check ', @CheckNumber, ' - Data file growth set past 10GB (EXPRESS)'); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + BEGIN; + IF (@IsExpress = 1) + BEGIN; + SET @CheckSQL = N''; + SELECT @CheckSQL = @CheckSQL + + N'USE ' + QUOTENAME([database_name]) + N'; + INSERT INTO #results ([check_num], [check_type], [obj_type], [db_name], [obj_name], [col_name], [message], [ref_link]) + SELECT @CheckNumber + ,N''File Growth'' + ,N''DATABASE'' + ,QUOTENAME(DB_NAME()) + ,QUOTENAME(DB_NAME(database_id)) + ,NULL + ,N''Database file '' + name + '' has a maximum growth set to '' + + CASE + WHEN max_size = -1 + THEN ''Unlimited'' + WHEN max_size > 0 + THEN CAST((max_size / 1024) * 8 AS VARCHAR(MAX)) + END + '', which is over the user database maximum file size of 10GB.'' + ,CONCAT(@BaseURL COLLATE database_default, ''database-growth-past-10GB'') + FROM sys.master_files mf + WHERE (max_size > 1280000 OR max_size = -1) -- greater than 10GB or unlimited + AND [mf].[database_id] > 5 + AND [mf].[data_space_id] > 0 -- limit doesn''t apply to log files;' + FROM #Databases; + EXEC sp_executesql @CheckSQL, N'@CheckNumber TINYINT, @BaseURL VARCHAR(1000)', @CheckNumber = @CheckNumber, @BaseURL = @BaseURL; + END; -- User DB or model db Growth check + ELSE IF (@Verbose = 1) --Skip check + BEGIN; + RAISERROR(' Skipping check, not Express...', 10, 1) WITH NOWAIT; + END; + END; -- User DB or model db Growth check + + /* User DB or model db growth set to % */ + SET @CheckNumber = @CheckNumber + 1; + IF (@Verbose = 1) + BEGIN; + SET @Msg = CONCAT(N'Check ', @CheckNumber, ' - Data file growth set to percentage.'); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + BEGIN; + IF (@EngineEdition <> 5) --Not Azure SQL + BEGIN + INSERT INTO #results ([check_num], [check_type], [obj_type], [db_name], [obj_name], [col_name], [message], [ref_link]) + SELECT @CheckNumber + ,N'File Growth' + ,N'DATABASE' + ,QUOTENAME(DB_NAME([sd].[database_id])) + ,[mf].[name] + ,NULL + ,N'Database file '+[mf].[name]+' has growth set to % instead of a fixed amount. This may grow quickly.' + ,CONCAT(@BaseURL, 'database-growth-type') + FROM [sys].[master_files] AS [mf] + INNER JOIN [sys].[databases] AS [sd] ON [sd].[database_id] = [mf].[database_id] + INNER JOIN #Databases AS [d] ON [d].[database_name] = [sd].[name] + WHERE [mf].[is_percent_growth] = 1 + AND [mf].[data_space_id] = 1; --ignore log files + END; + END; -- User DB or model db growth set to % Check + + /* Default fill factor (EXPRESS ONLY) */ + SET @CheckNumber = @CheckNumber + 1; + IF (@Verbose = 1) + BEGIN; + SET @Msg = CONCAT(N'Check ', @CheckNumber, ' - Non-default fill factor (EXPRESS)'); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + BEGIN; + IF(@IsExpress = 1) + BEGIN; + SET @CheckSQL = N''; + SELECT @CheckSQL = @CheckSQL + + N'USE ' + QUOTENAME([database_name]) + N'; + INSERT INTO #results ([check_num], [check_type], [obj_type], [db_name], [obj_name], [col_name], [message], [ref_link]) + SELECT @CheckNumber + ,N''Architecture'' + ,N''INDEX'' + ,QUOTENAME(DB_NAME()) + ,QUOTENAME(SCHEMA_NAME([o].[schema_id])) + ''.'' + QUOTENAME([o].[name]) + ''.'' + QUOTENAME([i].[name]) + ,NULL + ,N''Non-default fill factor on this index. Not inherently bad, but will increase table size more quickly.'' + ,CONCAT(@BaseURL COLLATE database_default, ''default-fill-factor'') + FROM [sys].[indexes] AS [i] + INNER JOIN [sys].[objects] AS [o] ON [o].[object_id] = [i].[object_id] + WHERE [i].[fill_factor] NOT IN(0, 100);' + FROM #Databases; + EXEC sp_executesql @CheckSQL, N'@CheckNumber TINYINT, @BaseURL VARCHAR(1000)', @CheckNumber = @CheckNumber, @BaseURL = @BaseURL; + END; -- Non-default fill factor check + ELSE IF (@Verbose = 1) --Skip check + BEGIN; + RAISERROR(' Skipping check, not Express...', 10, 1) WITH NOWAIT; + END; + END; --Default fill factor + + /* Number of indexes */ + SET @CheckNumber = @CheckNumber + 1; + IF (@Verbose = 1) + BEGIN; + SET @Msg = CONCAT('Check ', @CheckNumber, ' - Questionable number of indexes'); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + BEGIN; + SET @CheckSQL = N''; + SELECT @CheckSQL = @CheckSQL + + N'USE ' + QUOTENAME([database_name]) + N'; + INSERT INTO #results ([check_num], [check_type], [obj_type], [db_name], [obj_name], [col_name], [message], [ref_link]) + SELECT @CheckNumber + ,N''Architecture'' + ,N''INDEX'' + ,QUOTENAME(DB_NAME()) + ,QUOTENAME(SCHEMA_NAME(t.schema_id)) + ''.'' + QUOTENAME(t.name) + ,NULL + ,''There are '' + CAST(COUNT(DISTINCT(i.index_id)) AS VARCHAR) + '' indexes on this table taking up '' + CAST(CAST(SUM(s.[used_page_count]) * 8 / 1024.00 AS DECIMAL(10, 2)) AS VARCHAR) + '' MB of space.'' + ,CONCAT(@BaseURL COLLATE database_default, ''number-of-indexes'') + FROM sys.indexes AS i + INNER JOIN sys.tables AS t ON i.object_id = t.object_id + INNER JOIN sys.dm_db_partition_stats AS s ON s.object_id = i.object_id + AND s.index_id = i.index_id + WHERE t.is_ms_shipped = 0 --exclude sys table + AND i.type_desc = ''NONCLUSTERED'' --exclude clustered indexes from count + GROUP BY t.name, + t.schema_id + HAVING COUNT(DISTINCT(i.index_id)) > @IndexNumThreshold;' + FROM #Databases; + EXEC sp_executesql @CheckSQL, N'@IndexNumThreshold TINYINT, @CheckNumber TINYINT, @BaseURL VARCHAR(1000)', @IndexNumThreshold = @IndexNumThreshold, @CheckNumber = @CheckNumber, @BaseURL = @BaseURL; + END; -- Questionable number of indexes check + + /* Inefficient Indexes */ + SET @CheckNumber = @CheckNumber + 1; + IF (@Verbose = 1) + BEGIN; + SET @Msg = CONCAT(N'Check ', @CheckNumber, ' - Inefficient indexes'); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + BEGIN; + SET @CheckSQL = N''; + SELECT @CheckSQL = @CheckSQL + + N' USE ? ; + BEGIN + IF OBJECT_ID(''tempdb..#Indexes'') IS NOT NULL + BEGIN; + DROP TABLE [#Indexes]; + END; + IF OBJECT_ID(''tempdb..#IdxChecksum'') IS NOT NULL + BEGIN; + DROP TABLE [#IdxChecksum]; + END; + IF OBJECT_ID(''tempdb..#MatchingIdxInclChecksum'') IS NOT NULL + BEGIN; + DROP TABLE [#MatchingIdxInclChecksum]; + END; + IF OBJECT_ID(''tempdb..#MatchingIdxChecksum'') IS NOT NULL + BEGIN; + DROP TABLE [#MatchingIdxChecksum]; + END; ' + + + /* Retrieve all indexes */ + + N'SELECT ac.[name] AS [col_name] + ,row_number () OVER (PARTITION BY ind.[object_id], ind.index_id ORDER BY indc.index_column_id ) AS row_num + ,ind.index_id + ,ind.[object_id] + ,DENSE_RANK() OVER (ORDER BY ind.[object_id], ind.index_id) AS [index_num] + ,indc.is_included_column + ,NULL AS [ix_checksum] + ,NULL AS [ix_incl_checksum] + ,ao.[schema_id] + INTO #Indexes + FROM sys.indexes as [ind] + INNER JOIN sys.index_columns AS [indc] ON [ind].[object_id] = [indc].[object_id] AND ind.index_id = indc.index_id + INNER JOIN sys.all_columns as [ac] ON [ac].[column_id] = [indc].[column_id] and indc.[object_id] = ac.[object_id] + INNER JOIN sys.all_objects AS [ao] ON [ao].[object_id] = [ac].[object_id] + WHERE ao.is_ms_shipped = 0 + ORDER BY ind.[object_id]; + + DECLARE @Counter BIGINT = (SELECT 1); + DECLARE @MaxNumIndex BIGINT = (SELECT MAX(index_num) FROM #Indexes); ' + + + /* Iterate through each index, adding together columns for each */ + + N'WHILE @Counter <= @MaxNumIndex + BEGIN + DECLARE @IndexedColumns NVARCHAR(MAX) = N''''; + DECLARE @IndexedColumnsInclude NVARCHAR(MAX) = N''''; ' + + + /* Add together index columns */ + + N'SELECT @IndexedColumns += CAST([col_name] AS SYSNAME) + FROM #Indexes + WHERE is_included_column = 0 + AND index_num = @Counter + ORDER BY row_num; ' + + + /* Add together index + included columns */ + + N'SELECT @IndexedColumnsInclude += CAST([col_name] AS SYSNAME) + FROM #Indexes + WHERE index_num = @Counter + ORDER BY row_num; ' + + + /* Generate a checksum for index columns and index + included columns for each index */ + + N'UPDATE #Indexes + SET [ix_checksum] = CHECKSUM(@IndexedColumns), [ix_incl_checksum] = CHECKSUM(@IndexedColumnsInclude) + WHERE index_num = @Counter; + + SET @Counter += 1; + END; ' + + + /* Narrow down to one row per index */ + + N'SELECT DISTINCT [object_id], index_id, [ix_checksum], [ix_incl_checksum], [schema_id] + INTO #IdxChecksum + FROM #Indexes; ' + + + /* Find duplicate indexes */ + + N'SELECT COUNT(*) AS [num_dup_indexes], [ix_incl_checksum], [object_id] + INTO #MatchingIdxInclChecksum + FROM #IdxChecksum + GROUP BY [ix_incl_checksum], [object_id] + HAVING COUNT(*) > 1; ' + + + /* Find overlapping indexes with same indexed columns */ + + N'SELECT COUNT(*) AS [num_dup_indexes], [ix_checksum], [object_id] + INTO #MatchingIdxChecksum + FROM #IdxChecksum + GROUP BY [ix_checksum], [object_id] + HAVING COUNT(*) > 1 + + INSERT INTO #DuplicateIndex + SELECT N''Inefficient Indexes - Duplicate'' AS [check_type] + ,N''INDEX'' AS [obj_type] + ,QUOTENAME(DB_NAME()) AS [db_name] + ,QUOTENAME(SCHEMA_NAME([schema_id])) + ''.'' + QUOTENAME(OBJECT_NAME(ic.[object_id])) + ''.'' + QUOTENAME(i.[name]) AS [obj_name] + ,NULL AS [col_name] + ,''Indexes in group '' + CAST(DENSE_RANK() over (order by miic.[ix_incl_checksum]) AS VARCHAR(5)) + '' share the same indexed and any included columns.'' AS [message] + ,ic.[object_id] + ,ic.[index_id] + FROM #MatchingIdxInclChecksum AS miic + INNER JOIN #IdxChecksum AS ic ON ic.[object_id] = miic.[object_id] AND ic.[ix_incl_checksum] = miic.[ix_incl_checksum] + INNER JOIN sys.indexes AS [i] ON [i].[index_id] = ic.index_id AND i.[object_id] = ic.[object_id] + + INSERT INTO #OverlappingIndex + SELECT N''Inefficient Indexes - Overlapping'' AS [check_type] + ,N''INDEX'' AS [obj_type] + ,QUOTENAME(DB_NAME()) AS [db_name] + ,QUOTENAME(SCHEMA_NAME([schema_id])) + ''.'' + QUOTENAME(OBJECT_NAME(ic.[object_id])) + ''.'' + QUOTENAME(i.[name]) AS [obj_name] + ,NULL AS [col_name] + ,''Indexes in group '' + CAST(DENSE_RANK() OVER (order by mic.[ix_checksum]) AS VARCHAR(5)) + '' share the same indexed columns.'' AS [message] + ,ic.[object_id] + ,ic.[index_id] + FROM #MatchingIdxChecksum AS mic + INNER JOIN #IdxChecksum AS ic ON ic.[object_id] = mic.[object_id] AND ic.[ix_checksum] = mic.[ix_checksum] + INNER JOIN sys.indexes AS [i] ON [i].[index_id] = ic.index_id AND i.[object_id] = ic.[object_id] ' + + /* Dont include any indexes that are already identified as 100% duplicates */ + + N'WHERE NOT EXISTS (SELECT * FROM #DuplicateIndex AS [di] WHERE [di].[object_id] = ic.[object_id] AND di.index_id = ic.index_id); + END'; + + DECLARE [DB_Cursor] CURSOR LOCAL FAST_FORWARD + FOR SELECT QUOTENAME([database_name]) + FROM #Databases; + + OPEN [DB_Cursor]; + + FETCH NEXT FROM [DB_Cursor] + INTO @DbName; + + /* Run index query for each database */ + WHILE @@FETCH_STATUS = 0 + BEGIN; + SET @TempCheckSQL = REPLACE(@CheckSQL, N'?', @DbName); + EXEC sp_executesql @TempCheckSQL; + FETCH NEXT FROM [DB_Cursor] + INTO @DbName; + END; + CLOSE [DB_Cursor]; + DEALLOCATE [DB_Cursor]; + + /* Duplicate Indexes */ + INSERT INTO #results ([check_num], [check_type], [obj_type], [db_name], [obj_name], [col_name], [message], [ref_link]) + SELECT @CheckNumber + ,[check_type] + ,[obj_type] + ,[db_name] + ,[obj_name] + ,[col_name] + ,[message] + ,CONCAT(@BaseURL,'inefficient-indexes') + FROM #DuplicateIndex; + + /* Overlapping Indexes */ + INSERT INTO #results ([check_num], [check_type], [obj_type], [db_name], [obj_name], [col_name], [message], [ref_link]) + SELECT @CheckNumber + ,[check_type] + ,[obj_type] + ,[db_name] + ,[obj_name] + ,[col_name] + ,[message] + ,CONCAT(@BaseURL,'inefficient-indexes') + FROM #OverlappingIndex; + + END; -- Inefficient indexes check + + /* Sparse columns */ + SET @CheckNumber = @CheckNumber + 1; + IF (@Verbose = 1) + BEGIN; + SET @Msg = CONCAT(N'Check ', @CheckNumber, ' - Sparse column eligibility'); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + BEGIN; + IF OBJECT_ID('tempdb..#SparseTypes') IS NOT NULL + BEGIN; + DROP TABLE [#SparseTypes]; + END; + IF OBJECT_ID('tempdb..#Stats') IS NOT NULL + BEGIN; + DROP TABLE [#Stats]; + END; + IF OBJECT_ID('tempdb..#StatsHeaderStaging') IS NOT NULL + BEGIN; + DROP TABLE [#StatsHeaderStaging]; + END; + IF OBJECT_ID('tempdb..#StatHistogramStaging') IS NOT NULL + BEGIN; + DROP TABLE [#StatHistogramStaging]; + END; + + CREATE TABLE #SparseTypes ( + [ID] INT IDENTITY(1,1) NOT NULL, + [name] VARCHAR(20), + [user_type_id] INT, + [scale] TINYINT NULL, + [precision] TINYINT NOT NULL, + [threshold_null_perc] TINYINT NOT NULL); + + CREATE CLUSTERED INDEX cidx_#sparsetypes ON #SparseTypes([ID]); + + /* Reference values for when it makes sense to use the sparse feature based on 40% minimum space savings + including if those recommendations change based on scale / precision. Conservative estimates are used + when a column is in between the high and low values in the table. + https://docs.microsoft.com/en-us/sql/relational-databases/tables/use-sparse-columns?view=sql-server-2017#estimated-space-savings-by-data-type */ + INSERT INTO #SparseTypes ([name], [user_type_id], [scale], [precision], [threshold_null_perc]) + VALUES ('BIT',104, 0,0, 98), + ('TINYINT',48, 0,0, 86), + ('SMALLINT',52, 0,0, 76), + ('INT',56, 0,0, 64), + ('BIGINT',127, 0,0, 52), + ('REAL',59, 0,0, 64), + ('FLOAT',62, 0,0, 52), + ('SMALLMONEY',122, 0,0, 64), + ('MONEY',60, 0,0, 52), + ('SMALLDATETIME',58, 0,0, 64), + ('DATETIME',61, 0,0, 52), + ('UNIQUEIDENTIFIER',36, 0,0, 43), + ('DATE',40, 0,0, 69), + ('DATETIME2',42, 0,0, 57), + ('DATETIME2',42, 7,0, 52), + ('TIME',41, 0,0, 69), + ('TIME',41, 7,0, 60), + ('DATETIMEOFFSET',43, 0,0, 52), + ('DATETIMEOFFSET',43, 7,0, 49), + ('VARCHAR',167, 0,0, 60), + ('CHAR',175, 0,0, 60), + ('NVARCHAR',231, 0,0, 60), + ('NCHAR',239, 0,0, 60), + ('VARBINARY',165, 0,0, 60), + ('BINARY',173, 0,0, 60), + ('XML',241, 0,0, 60), + ('HIERARCHYID',128, 0,0, 60), + ('DECIMAL', 106, NULL, 1, 60), + ('DECIMAL', 106, NULL, 38, 42), + ('NUMERIC', 108, NULL, 1, 60), + ('NUMERIC', 108, NULL, 38, 42); + + --For STAT_HEADER data + CREATE TABLE #StatsHeaderStaging ( + [name] SYSNAME + ,[updated] DATETIME2(0) + ,[rows] BIGINT + ,[rows_sampled] BIGINT + ,[steps] INT + ,[density] DECIMAL(6,3) + ,[average_key_length] REAL + ,[string_index] VARCHAR(10) + ,[filter_expression] NVARCHAR(MAX) + ,[unfiltered_rows] BIGINT); + + --Check for extra persisted sample percent column + IF @HasPersistedSamplePercent = 1 + BEGIN; + ALTER TABLE #StatsHeaderStaging ADD [persisted_sample_percent] INT; + END; + + --For HISTOGRAM data + CREATE TABLE #StatHistogramStaging ( + [range_hi_key] NVARCHAR(MAX) + ,[range_rows] BIGINT + ,[eq_rows] DECIMAL(38,2) + ,[distinct_range_rows] BIGINT + ,[avg_range_rows] BIGINT); + + --For combined DBCC stat data (SHOW_STAT + HISTOGRAM) + CREATE TABLE #Stats ( + [stats_id] INT IDENTITY(1,1) + ,[db_name] SYSNAME + ,[stat_name] SYSNAME + ,[stat_updated] DATETIME2(0) + ,[rows] BIGINT + ,[rows_sampled] BIGINT + ,[schema_name] SYSNAME + ,[table_name] SYSNAME NULL + ,[col_name] SYSNAME NULL + ,[eq_rows] BIGINT NULL + ,[null_perc] AS CAST([eq_rows] AS DECIMAL (38,2)) / NULLIF([rows], 0) * 100 + ,[threshold_null_perc] SMALLINT); + + CREATE CLUSTERED INDEX cidx_#stats ON #Stats([stats_id]); + + SET @CheckSQL = + N' USE ?; + BEGIN + DECLARE @schemaName SYSNAME + ,@tableName SYSNAME + ,@statName SYSNAME + ,@colName SYSNAME + ,@threshold_null_perc SMALLINT; + + DECLARE @DBCCSQL NVARCHAR(MAX) = N''''; + DECLARE @DBCCStatSQL NVARCHAR(MAX) = N''''; + DECLARE @DBCCHistSQL NVARCHAR(MAX) = N''''; + + DECLARE [DBCC_Cursor] CURSOR LOCAL FAST_FORWARD + FOR + SELECT DISTINCT sch.name AS [schema_name] + ,t.name AS [table_name] + ,s.name AS [stat_name] + ,ac.name AS [col_name] + ,threshold_null_perc + FROM [sys].[stats] AS [s] + INNER JOIN [sys].[stats_columns] AS [sc] on sc.stats_id = s.stats_id + INNER JOIN [sys].[tables] AS [t] on t.object_id = s.object_id + INNER JOIN [sys].[schemas] AS [sch] on sch.schema_id = t.schema_id + INNER JOIN [sys].[all_columns] AS [ac] on ac.column_id = sc.column_id + AND [ac].[object_id] = [t].[object_id] + AND [ac].[object_id] = [sc].[object_id] + INNER JOIN [sys].[types] AS [typ] ON [typ].[user_type_id] = [ac].[user_type_id] + INNER JOIN [sys].[indexes] AS [i] ON [i].[object_id] = [t].[object_id] ' + + /* Special considerations for variable length data types */ + + N'INNER JOIN [#SparseTypes] AS [st] ON [st].[user_type_id] = [typ].[user_type_id] + AND (typ.name NOT IN (''DECIMAL'', ''NUMERIC'', ''DATETIME2'', ''TIME'', ''DATETIMEOFFSET'')) + OR (typ.name IN (''DECIMAL'', ''NUMERIC'') AND st.precision = ac.precision AND st.precision = 1) + OR (typ.name IN (''DECIMAL'', ''NUMERIC'') AND ac.precision > 1 AND st.precision = 38) + OR (typ.name IN (''DATETIME2'', ''TIME'', ''DATETIMEOFFSET'') AND st.scale = ac.scale AND st.scale = 0) + OR (typ.name IN (''DATETIME2'', ''TIME'', ''DATETIMEOFFSET'') AND ac.scale > 0 AND st.scale = 7) + WHERE [sc].[stats_column_id] = 1 + AND [s].[has_filter] = 0 + AND [s].[no_recompute] = 0 + AND [ac].[is_nullable] = 1 + AND NOT EXISTS (SELECT 1 -- Compressed tables not compatible with sparse cols + FROM [sys].[partitions] AS [p] + WHERE [p].[object_id] = [i].[object_id] + AND [p].[data_compression] > 0) '; + IF @HasTempStat = 1 + BEGIN; + SET @CheckSQL = @CheckSQL + N'AND [s].[is_temporary] = 0; '; + END; + + SET @CheckSQL = @CheckSQL + N' + OPEN [DBCC_Cursor]; + + FETCH NEXT FROM [DBCC_Cursor] + INTO @schemaName, @tableName, @statName, @colName, @threshold_null_perc; + + WHILE @@FETCH_STATUS = 0 + BEGIN; + DECLARE @SchemaTableName SYSNAME = QUOTENAME(@schemaName) + ''.'' + QUOTENAME(@tableName); ' + + + /* Build DBCC statistics queries */ + + N'SET @DBCCSQL = N''DBCC SHOW_STATISTICS(@SchemaTableName, @statName)''; + SET @DBCCStatSQL = @DBCCSQL + '' WITH STAT_HEADER, NO_INFOMSGS;''; + SET @DBCCHistSQL = @DBCCSQL + '' WITH HISTOGRAM, NO_INFOMSGS;''; ' + + + /* Stat Header temp table */ + + N'INSERT INTO #StatsHeaderStaging + EXEC sp_executesql @DBCCStatSQL + ,N''@SchemaTableName SYSNAME, @statName SYSNAME'' + ,@SchemaTableName = @SchemaTableName + ,@statName = @statName; ' + + + /* Histogram temp table */ + + N'INSERT INTO #StatHistogramStaging + EXEC sp_executesql @DBCCHistSQL + ,N''@SchemaTableName SYSNAME, @statName SYSNAME'' + ,@SchemaTableName = @SchemaTableName + ,@statName = @statName; + + INSERT INTO #Stats + SELECT DB_NAME() + ,[head].[name] + ,[head].[updated] + ,[head].[rows] + ,[head].[rows_sampled] + ,@schemaName + ,@tableName + ,@colName + ,[hist].[eq_rows] + ,@threshold_null_perc + FROM #StatsHeaderStaging head + CROSS APPLY #StatHistogramStaging hist + WHERE hist.range_hi_key IS NULL + AND hist.eq_rows > 0 + AND head.unfiltered_rows > 0 + AND head.rows > 1000; + + TRUNCATE TABLE #StatsHeaderStaging; + TRUNCATE TABLE #StatHistogramStaging; + + FETCH NEXT FROM DBCC_Cursor + INTO @schemaName, @tableName, @statName, @colName, @threshold_null_perc; + END; + CLOSE [DBCC_Cursor]; + DEALLOCATE [DBCC_Cursor]; + END;'; + + DECLARE [DB_Cursor] CURSOR LOCAL FAST_FORWARD + FOR SELECT QUOTENAME([database_name]) + FROM #Databases; + + OPEN [DB_Cursor]; + + FETCH NEXT FROM [DB_Cursor] + INTO @DbName; + + /* Run stat query for each database */ + WHILE @@FETCH_STATUS = 0 + BEGIN; + SET @TempCheckSQL = REPLACE(@CheckSQL, N'?', @DbName); + EXEC sp_executesql @TempCheckSQL; + FETCH NEXT FROM [DB_Cursor] + INTO @DbName; + END; + CLOSE [DB_Cursor]; + DEALLOCATE [DB_Cursor]; + + INSERT INTO #results ([check_num], [check_type], [obj_type], [db_name], [obj_name], [col_name], [message], [ref_link]) + SELECT @CheckNumber + ,N'Architecture' + ,N'USER_TABLE' + ,QUOTENAME([db_name]) + ,QUOTENAME([schema_name]) + '.' + QUOTENAME([table_name]) + ,QUOTENAME([col_name]) + ,N'Candidate for converting to a space-saving sparse column based on NULL distribution of more than ' + CAST([threshold_null_perc] AS VARCHAR(3))+ ' percent.' + ,CONCAT(@BaseURL, 'sparse-columns') + FROM #Stats + WHERE [null_perc] >= [threshold_null_perc]; + END; -- Sparse column check + + /* Heap Tables */ + SET @CheckNumber = @CheckNumber + 1; + IF (@Verbose = 1) + BEGIN; + SET @Msg = CONCAT(N'Check ', @CheckNumber, ' - Heap Tables'); + RAISERROR(@Msg, 10, 1) WITH NOWAIT; + END; + BEGIN + SET @CheckSQL = N''; + SELECT @CheckSQL = @CheckSQL + + N'USE ' + QUOTENAME([database_name]) + N'; + INSERT INTO #results ([check_num], [check_type], [obj_type], [db_name], [obj_name], [col_name], [message], [ref_link]) + SELECT @CheckNumber + ,N''Architecture'' + ,N''INDEX'' + ,QUOTENAME(DB_NAME()) + ,QUOTENAME(SCHEMA_NAME([t].[schema_id])) + ''.'' + QUOTENAME([t].[name]) + ,NULL + ,N''Heap tables can result in massive fragmentation and have additional indexing overhead.'' + ,CONCAT(@BaseURL COLLATE database_default, ''heap-tables'') + FROM [sys].[tables] AS [t] + INNER JOIN [sys].[indexes] AS [i] ON [i].[object_id] = [t].[object_id] + WHERE [i].[type] = 0' + FROM #Databases; + EXEC sp_executesql @CheckSQL, N'@CheckNumber TINYINT, @BaseURL VARCHAR(1000)', @CheckNumber = @CheckNumber, @BaseURL = @BaseURL; + END; --Heap Tables + + /* Wrap it up */ + SELECT [check_num] + ,[check_type] + ,[db_name] + ,[obj_type] + ,[obj_name] + ,[col_name] + ,[message] + ,[ref_link] + FROM #results + ORDER BY [check_num], [check_type], [db_name], [obj_type], [obj_name], [col_name], [message]; + + END TRY + + BEGIN CATCH; + BEGIN; + DECLARE @ErrorNumber INT = ERROR_NUMBER(); + DECLARE @ErrorLine INT = ERROR_LINE(); + DECLARE @ErrorMessage NVARCHAR(4000) = ERROR_MESSAGE(); + DECLARE @ErrorSeverity INT = ERROR_SEVERITY(); + DECLARE @ErrorState INT = ERROR_STATE(); + + RAISERROR(@ErrorMessage, @ErrorSeverity, @ErrorState) WITH NOWAIT; + SET @msg = CONCAT('Actual error number: ', @ErrorNumber); + RAISERROR(@msg, 16, 1); + SET @msg = CONCAT('Actual line number: ', @ErrorLine); + RAISERROR(@msg, 16, 1); + SET @msg = CONCAT('Check number: ', @CheckNumber); + RAISERROR(@msg, 16, 1); + END; + END CATCH; +END; +GO + +EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Recommends space saving and corrective data type measures based on SQL Server database schemas. Documentation at https://expresssql.lowlydba.com' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_sizeoptimiser'; +GO + +EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Required table type for sp_sizeoptimiser.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TYPE',@level1name=N'SizeOptimiserTableType'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@SqlMajorVersion', @value=N'Used for unit testing purposes only.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_sizeoptimiser'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@SqlMinorVersion', @value=N'Used for unit testing purposes only.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_sizeoptimiser'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@IndexNumThreshold', @value=N'Number of indexes to classify a table as having too many indexes on it. Default value is 10.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_sizeoptimiser'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@IncludeDatabases', @value=N'Which databases to run the script on in the form of a user defined table type. If not supplied, all accessible user databases are targeted. Cannot be used in conjunction with @ExcludeDatabases.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_sizeoptimiser'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@ExcludeDatabases', @value=N'Which databases to exclude in the form of a user defined table type. Cannot be used in conjunction with @IncludeDatabases.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_sizeoptimiser'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@IncludeSysDatabases', @value=N'Whether or not to include system databases in the script''s analysis. Default is 0.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_sizeoptimiser'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@IncludeSSRSDatabases', @value=N'Whether or not to include SQL Server Reporting Services databases in the script''s analysis. Default is 0.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_sizeoptimiser'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@Verbose', @value=N'Whether or not to print additional information during the script run. Default is 0.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_sizeoptimiser'; +GO + +EXEC sys.sp_addextendedproperty @name=N'@IsExpress', @value=N'Used for unit testing purposes only.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_sizeoptimiser'; +GO diff --git a/Stored_Procedure/sp_sizing.sql b/Stored_Procedure/dbo.sp_sizing.sql similarity index 100% rename from Stored_Procedure/sp_sizing.sql rename to Stored_Procedure/dbo.sp_sizing.sql diff --git a/Stored_Procedure/sp_sqltrace.sql b/Stored_Procedure/dbo.sp_sqltrace.sql similarity index 100% rename from Stored_Procedure/sp_sqltrace.sql rename to Stored_Procedure/dbo.sp_sqltrace.sql diff --git a/Stored_Procedure/sqlg_ParseDiskskpXml.sql b/Stored_Procedure/dbo.sqlg_ParseDiskskpXml.sql similarity index 100% rename from Stored_Procedure/sqlg_ParseDiskskpXml.sql rename to Stored_Procedure/dbo.sqlg_ParseDiskskpXml.sql diff --git a/Stored_Procedure/udp_IntegerListfromRanges.sql b/Stored_Procedure/dbo.udp_IntegerListfromRanges.sql similarity index 100% rename from Stored_Procedure/udp_IntegerListfromRanges.sql rename to Stored_Procedure/dbo.udp_IntegerListfromRanges.sql diff --git a/Stored_Procedure/usp_Breadth_First.sql b/Stored_Procedure/dbo.usp_Breadth_First.sql similarity index 100% rename from Stored_Procedure/usp_Breadth_First.sql rename to Stored_Procedure/dbo.usp_Breadth_First.sql diff --git a/Stored_Procedure/usp_BulkUpload.sql b/Stored_Procedure/dbo.usp_BulkUpload.sql similarity index 81% rename from Stored_Procedure/usp_BulkUpload.sql rename to Stored_Procedure/dbo.usp_BulkUpload.sql index de91f276..0199ecc9 100644 --- a/Stored_Procedure/usp_BulkUpload.sql +++ b/Stored_Procedure/dbo.usp_BulkUpload.sql @@ -1,38 +1,38 @@ -IF OBJECT_ID('dbo.usp_BulkUpload', 'P') IS NULL EXECUTE ('CREATE PROCEDURE dbo.usp_BulkUpload AS SELECT 1'); +IF OBJECT_ID(N'dbo.usp_BulkUpload', N'P') IS NULL EXEC (N'CREATE PROCEDURE dbo.usp_BulkUpload AS SELECT 1'); GO ALTER PROCEDURE dbo.usp_BulkUpload ( - @path NVARCHAR(900) -- add a slash (\) at the end of a variable @path - , @fileName NVARCHAR(200) = '' - , @fileExtension NVARCHAR(10) = N'txt' - , @databaseName SYSNAME - , @schemaName SYSNAME = N'dbo' - , @tableName SYSNAME - , @useIdentity TINYINT = 1 -- 1 - table with identity and identity column exists in file; 2 - table with identity and identity column not exists in file; 0 - table without identity - , @identityColumnName SYSNAME = '' - , @BATCHSIZE INTEGER = 0 -- 0 - skip parameter value (by default, all data in the specified data file is one batch) - , @CHECK_CONSTRAINTS BIT = 0 -- 0 - skip parameter value (any CHECK and FOREIGN KEY constraints are ignored, after the operation, the constraints market as not-trusted) - , @CODEPAGE NVARCHAR(30) = N'65001' - , @DATAFILETYPE NVARCHAR(30) = N'char' - , @FIELDTERMINATOR NVARCHAR(10) = N'\t' - , @FIRSTROW INTEGER = 1 - , @FIRE_TRIGGERS BIT = 0 -- 0 - skip parameter value (no insert triggers execute) - , @KEEPNULLS BIT = 0 - , @KILOBYTES_PER_BATCH INTEGER = 0 -- 0 - skip parameter value (unknown by default) - , @LASTROW INTEGER = 0 - , @ROWTERMINATOR NVARCHAR(10) = N'\n' - , @ROWS_PER_BATCH INTEGER = 0 - , @TABLOCK BIT = 1 - , @ERRORFILE NVARCHAR(300) = N'' - , @MAXERRORS INTEGER = 0 -- 0 - skip parameter value (used 10 by default) - , @FORMATFILE VARCHAR(4) = '' - , @excludeColumns NVARCHAR(MAX) = N'''''' - , @rowOrderByColumn NVARCHAR(MAX) = N'' - , @skipTempDB BIT = 0 - , @columnTypeSort BIT = 1 -- 0 - physical column order; 1 - alphabetical - , @databaseRecoveryMode NVARCHAR(15) = N'' -- FULL; BULK_LOGGED; SIMPLE - , @debug BIT = 0 -- 0 - only print tsql statement; 1 - exec tsql statement + @path nvarchar(900) -- add a slash (\) at the end of a variable @path + , @fileName nvarchar(200) = '' + , @fileExtension nvarchar(10) = N'txt' + , @databaseName sysname + , @schemaName sysname = N'dbo' + , @tableName sysname + , @useIdentity tinyint = 1 -- 1 - table with identity and identity column exists in file; 2 - table with identity and identity column not exists in file; 0 - table without identity + , @identityColumnName sysname = '' + , @BATCHSIZE integer = 0 -- 0 - skip parameter value (by default, all data in the specified data file is one batch) + , @CHECK_CONSTRAINTS bit = 0 -- 0 - skip parameter value (any CHECK and FOREIGN KEY constraints are ignored, after the operation, the constraints market as not-trusted) + , @CODEPAGE nvarchar(30) = N'65001' + , @DATAFILETYPE nvarchar(30) = N'char' + , @FIELDTERMINATOR nvarchar(10) = N'\t' + , @FIRSTROW integer = 1 + , @FIRE_TRIGGERS bit = 0 -- 0 - skip parameter value (no insert triggers execute) + , @KEEPNULLS bit = 0 + , @KILOBYTES_PER_BATCH integer = 0 -- 0 - skip parameter value (unknown by default) + , @LASTROW integer = 0 + , @ROWTERMINATOR nvarchar(10) = N'\n' + , @ROWS_PER_BATCH integer = 0 + , @TABLOCK bit = 1 + , @ERRORFILE nvarchar(300) = N'' + , @MAXERRORS integer = 0 -- 0 - skip parameter value (used 10 by default) + , @FORMATFILE varchar(4) = '' + , @excludeColumns nvarchar(max) = N'''''' + , @rowOrderByColumn nvarchar(max) = N'' + , @skipTempDB bit = 0 + , @columnTypeSort bit = 1 -- 0 - physical column order; 1 - alphabetical + , @databaseRecoveryMode nvarchar(15) = N'' -- FULL; BULK_LOGGED; SIMPLE + , @debug bit = 0 -- 0 - only print tsql statement; 1 - exec tsql statement ) AS /* @@ -87,17 +87,17 @@ EXECUTE [dbo].[usp_BulkUpload] @path = N'd:\', */ BEGIN BEGIN TRY - DECLARE @databaseRecoveryModeCurrent NVARCHAR(15); - DECLARE @schemaTableName NVARCHAR(600) = QUOTENAME(@schemaName) + '.' + QUOTENAME(@tableName); - DECLARE @tsqlCommand NVARCHAR(MAX) = ''; - DECLARE @ParamDefinitionIndentity NVARCHAR(500) = N'@identityColumnNameIN NVARCHAR(200), @ColumnsOUT VARCHAR(MAX) OUTPUT'; - DECLARE @tableFullName NVARCHAR(600) = CASE WHEN @databaseName <> '' THEN QUOTENAME(@databaseName) + '.' ELSE '' END + @schemaTableName; - DECLARE @#tableName NVARCHAR(600) = QUOTENAME('#' + @tableName); - DECLARE @OBJECT_ID INTEGER = OBJECT_ID(@tableFullName); - DECLARE @Columns NVARCHAR(MAX) = N''; - DECLARE @filePath NVARCHAR(MAX) = @path + CASE WHEN @fileName = '' THEN @tableFullName ELSE @fileName END + '.' + @fileExtension; - DECLARE @crlf NVARCHAR(10) = CHAR(13); - DECLARE @TROW50000 NVARCHAR(1000) = N''; + DECLARE @databaseRecoveryModeCurrent nvarchar(15); + DECLARE @schemaTableName nvarchar(600) = QUOTENAME(@schemaName) + '.' + QUOTENAME(@tableName); + DECLARE @tsqlCommand nvarchar(max) = ''; + DECLARE @ParamDefinitionIndentity nvarchar(500) = N'@identityColumnNameIN NVARCHAR(200), @ColumnsOUT VARCHAR(MAX) OUTPUT'; + DECLARE @tableFullName nvarchar(600) = CASE WHEN @databaseName <> '' THEN QUOTENAME(@databaseName) + '.' ELSE '' END + @schemaTableName; + DECLARE @#tableName nvarchar(600) = QUOTENAME('#' + @tableName); + DECLARE @OBJECT_ID integer = OBJECT_ID(@tableFullName); + DECLARE @Columns nvarchar(max) = N''; + DECLARE @filePath nvarchar(max) = @path + CASE WHEN @fileName = '' THEN @tableFullName ELSE @fileName END + '.' + @fileExtension; + DECLARE @crlf nvarchar(10) = CHAR(13); + DECLARE @TROW50000 nvarchar(1000) = N''; IF @debug = 0 SET NOCOUNT ON ELSE PRINT '/******* Start Debug' + @crlf; @@ -110,7 +110,7 @@ BEGIN IF RIGHT(@path, 1) <> '\' THROW 50001, 'Please add a slash (\) at the end of a variable @path!!!', 1; IF LEFT(@databaseName, 1) =N'[' OR LEFT(@tableName, 1) = N'[' OR LEFT(@schemaName, 1) = N'[' - THROW 50002, 'Please do not use quotes in Databse, Table or Schema names! In the procedure it is alredy done with QUOTENAME function.', 1; + THROW 50002, 'Please do not use quotes in Database, Table or Schema names! In the procedure it is alredy done with QUOTENAME function.', 1; SET @tableFullName = CASE WHEN @databaseName <> '' THEN QUOTENAME(@databaseName) + '.' ELSE '' END + @schemaTableName; @@ -276,7 +276,7 @@ WITH ( IF @debug = 0 EXECUTE sp_executesql @tsqlCommand; END - IF @debug = 0 SET NOCOUNT OFF ELSE PRINT @crlf + '--End Deubg*********/'; + IF @debug = 1 PRINT @crlf + '--End Deubg*********/'; END TRY BEGIN CATCH diff --git a/Stored_Procedure/usp_CopyLogins.sql b/Stored_Procedure/dbo.usp_CopyLogins.sql similarity index 100% rename from Stored_Procedure/usp_CopyLogins.sql rename to Stored_Procedure/dbo.usp_CopyLogins.sql diff --git a/Stored_Procedure/usp_CreatePlantUMLCode.sql b/Stored_Procedure/dbo.usp_CreatePlantUMLCode.sql similarity index 100% rename from Stored_Procedure/usp_CreatePlantUMLCode.sql rename to Stored_Procedure/dbo.usp_CreatePlantUMLCode.sql diff --git a/Stored_Procedure/usp_DBA_Rename_Database.sql b/Stored_Procedure/dbo.usp_DBA_Rename_Database.sql similarity index 100% rename from Stored_Procedure/usp_DBA_Rename_Database.sql rename to Stored_Procedure/dbo.usp_DBA_Rename_Database.sql diff --git a/Stored_Procedure/usp_Dijkstra.sql b/Stored_Procedure/dbo.usp_Dijkstra.sql similarity index 100% rename from Stored_Procedure/usp_Dijkstra.sql rename to Stored_Procedure/dbo.usp_Dijkstra.sql diff --git a/Stored_Procedure/usp_EnableAndAddFileStreamForDatabase.sql b/Stored_Procedure/dbo.usp_EnableAndAddFileStreamForDatabase.sql similarity index 100% rename from Stored_Procedure/usp_EnableAndAddFileStreamForDatabase.sql rename to Stored_Procedure/dbo.usp_EnableAndAddFileStreamForDatabase.sql diff --git a/Stored_Procedure/usp_FindDbObjects.sql b/Stored_Procedure/dbo.usp_FindDbObjects.sql similarity index 100% rename from Stored_Procedure/usp_FindDbObjects.sql rename to Stored_Procedure/dbo.usp_FindDbObjects.sql diff --git a/Stored_Procedure/dbo.usp_GenerateRandomPassword.sql b/Stored_Procedure/dbo.usp_GenerateRandomPassword.sql new file mode 100644 index 00000000..5d862ec0 --- /dev/null +++ b/Stored_Procedure/dbo.usp_GenerateRandomPassword.sql @@ -0,0 +1,104 @@ +IF OBJECT_ID('dbo.usp_GenerateRandomPassword') IS NULL + EXEC('CREATE PROCEDURE dbo.usp_GenerateRandomPassword AS SELECT 1;'); +GO + + +ALTER PROCEDURE dbo.usp_GenerateRandomPassword( + @length int = 20, + @allowAtoZ BIT = 1, + @allow0to9 BIT = 1, + @allowSpecials1 BIT = 1, + @allowSpecials2 BIT = 1, + @avoidAmbiguousCharacters BIT = 1) +AS +/* +summary: > + This procedure generate random passwords with some customization + result. + Source link: https://github.com/ktaranov/sqlserver-kit/blob/master/Stored_Procedure/dbo.usp_GenerateRandomPassword.sql +Revisions: + - Author: Pinal Dave + Original link: https://blog.sqlauthority.com/2018/08/15/sql-server-how-to-generate-random-password-enhanced-version-part-2/?utm_source=DBW&utm_medium=pubemail + Version: 1.0 + Modification: First version + date: 2018-08-15 + - version: 1.1 + modification: add CREATE and ALTER logic, add documentation, format code + date: 2019-01-29 by Konstantin Taranov +Example: + - code: EXEC dbo.usp_GenerateRandomPassword @avoidAmbiguousCharacters = 0; + EXEC dbo.usp_GenerateRandomPassword @length = 30, @allow0to9 = 0, @allowSpecials1 = 0, @allowSpecials2 = 0, @avoidAmbiguousCharacters = 0; + EXEC dbo.usp_GenerateRandomPassword @length = 40, @allow0to9 = 0, @allowSpecials1 = 0, @allowSpecials2 = 1, @avoidAmbiguousCharacters = 1; + EXEC dbo.usp_GenerateRandomPassword @length = 90, @allowAtoZ = 0, @allow0to9 = 0, @allowSpecials1 = 1, @allowSpecials2 = 1; + + IF OBJECT_ID(N't', 'U') IS NULL + BEGIN + CREATE TABLE t( + [Password] NVARCHAR(4000), + PasswordLength INT, + AllowAtoZ BIT, + Allow0to9 BIT, + AllowSpecials1 BIT, + AllowSpecials2 BIT, + AvoidAmbiguousCharacters BIT); + END; + DECLARE @i INT = 1; + WHILE @i <= 50 + BEGIN + INSERT INTO t EXEC dbo.usp_GenerateRandomPassword; + SET @i = @i + 1; + END; + SELECT * FROM t; + DROP TABLE t; +returns: > + single row with new random password and all input parameters. +*/ +BEGIN + DECLARE @range Varchar(90) = '' + -- Start by assuming @avoidAmbiguousCharacters is true + IF @allowAtoZ = 1 +BEGIN + SET @range = @range +'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'; + END + IF @allow0to9 = 1 +BEGIN + SET @range = @range +'23456789'; + END + IF @allowSpecials1 = 1 +BEGIN + SET @range = @range +'!"#$%&''()*+,-./'; + END + IF @allowSpecials2 = 1 +BEGIN + SET @range = @range +':;<=>?@'; + END + IF @avoidAmbiguousCharacters = 0 +BEGIN + -- put back capital i, lowercase l, capital o, the number(s) 0, 1 + IF @allowAtoZ = 1 +BEGIN + SET @range = @range +'IOl'; + END + IF @allow0to9 = 1 +BEGIN + SET @range = @range +'01'; + END + END + DECLARE @pwd VARCHAR(512) = ''; + --use master.dbo.spt_values as a pseudo tally(numbers) table + + SELECT TOP(@length) + @pwd += SUBSTRING(@range,fn.rnd,1) + FROM master.dbo.spt_values sv + CROSS APPLY ( + SELECT [rnd] = (ABS(CHECKSUM(NEWID())) % (LEN(@range))) + ) AS fn + SELECT @pwd AS [Password], + @length AS PasswordLength, + @allowAtoZ, + @allow0to9 AS Allow0to9, + @allowSpecials1 AS AllowSpecials1, + @allowSpecials2 AS AllowSpecials2, + @avoidAmbiguousCharacters AS AvoidAmbiguousCharacters; +END; +GO diff --git a/Stored_Procedure/usp_Generate_Merge.sql b/Stored_Procedure/dbo.usp_Generate_Merge.sql similarity index 100% rename from Stored_Procedure/usp_Generate_Merge.sql rename to Stored_Procedure/dbo.usp_Generate_Merge.sql diff --git a/Stored_Procedure/usp_GetPackageDetails.sql b/Stored_Procedure/dbo.usp_GetPackageDetails.sql similarity index 100% rename from Stored_Procedure/usp_GetPackageDetails.sql rename to Stored_Procedure/dbo.usp_GetPackageDetails.sql diff --git a/Stored_Procedure/usp_GetUntrustedForeignKeys.sql b/Stored_Procedure/dbo.usp_GetUntrustedForeignKeys.sql similarity index 100% rename from Stored_Procedure/usp_GetUntrustedForeignKeys.sql rename to Stored_Procedure/dbo.usp_GetUntrustedForeignKeys.sql diff --git a/Stored_Procedure/usp_Kruskal.sql b/Stored_Procedure/dbo.usp_Kruskal.sql similarity index 100% rename from Stored_Procedure/usp_Kruskal.sql rename to Stored_Procedure/dbo.usp_Kruskal.sql diff --git a/Stored_Procedure/usp_LoadTableBlobs.sql b/Stored_Procedure/dbo.usp_LoadTableBlobs.sql similarity index 100% rename from Stored_Procedure/usp_LoadTableBlobs.sql rename to Stored_Procedure/dbo.usp_LoadTableBlobs.sql diff --git a/Stored_Procedure/usp_LogError.sql b/Stored_Procedure/dbo.usp_LogError.sql similarity index 100% rename from Stored_Procedure/usp_LogError.sql rename to Stored_Procedure/dbo.usp_LogError.sql diff --git a/Stored_Procedure/usp_Object_Search.sql b/Stored_Procedure/dbo.usp_Object_Search.sql similarity index 100% rename from Stored_Procedure/usp_Object_Search.sql rename to Stored_Procedure/dbo.usp_Object_Search.sql diff --git a/Stored_Procedure/usp_Prim.sql b/Stored_Procedure/dbo.usp_Prim.sql similarity index 100% rename from Stored_Procedure/usp_Prim.sql rename to Stored_Procedure/dbo.usp_Prim.sql diff --git a/Stored_Procedure/usp_PrintDebug.sql b/Stored_Procedure/dbo.usp_PrintDebug.sql similarity index 100% rename from Stored_Procedure/usp_PrintDebug.sql rename to Stored_Procedure/dbo.usp_PrintDebug.sql diff --git a/Stored_Procedure/usp_PrintError.sql b/Stored_Procedure/dbo.usp_PrintError.sql similarity index 100% rename from Stored_Procedure/usp_PrintError.sql rename to Stored_Procedure/dbo.usp_PrintError.sql diff --git a/Stored_Procedure/usp_RandomWait.sql b/Stored_Procedure/dbo.usp_RandomWait.sql similarity index 100% rename from Stored_Procedure/usp_RandomWait.sql rename to Stored_Procedure/dbo.usp_RandomWait.sql diff --git a/Stored_Procedure/usp_RunCheckAllUntrustedForeignKeys.sql b/Stored_Procedure/dbo.usp_RunCheckAllUntrustedForeignKeys.sql similarity index 100% rename from Stored_Procedure/usp_RunCheckAllUntrustedForeignKeys.sql rename to Stored_Procedure/dbo.usp_RunCheckAllUntrustedForeignKeys.sql diff --git a/Stored_Procedure/usp_SQL_Server_System_Report.sql b/Stored_Procedure/dbo.usp_SQL_Server_System_Report.sql similarity index 100% rename from Stored_Procedure/usp_SQL_Server_System_Report.sql rename to Stored_Procedure/dbo.usp_SQL_Server_System_Report.sql diff --git a/Stored_Procedure/usp_SQLskillsAnalyzeLog.sql b/Stored_Procedure/dbo.usp_SQLskillsAnalyzeLog.sql similarity index 100% rename from Stored_Procedure/usp_SQLskillsAnalyzeLog.sql rename to Stored_Procedure/dbo.usp_SQLskillsAnalyzeLog.sql diff --git a/Stored_Procedure/usp_SSIS_ScriptEnvironment.sql b/Stored_Procedure/dbo.usp_SSIS_ScriptEnvironment.sql similarity index 100% rename from Stored_Procedure/usp_SSIS_ScriptEnvironment.sql rename to Stored_Procedure/dbo.usp_SSIS_ScriptEnvironment.sql diff --git a/Stored_Procedure/dbo.usp_SearchOnAllDB.sql b/Stored_Procedure/dbo.usp_SearchOnAllDB.sql new file mode 100644 index 00000000..d7a786ff --- /dev/null +++ b/Stored_Procedure/dbo.usp_SearchOnAllDB.sql @@ -0,0 +1,189 @@ +IF Object_id('dbo.usp_SearchOnAllDB', 'P') IS NULL + EXECUTE ('CREATE PROCEDURE dbo.usp_SearchOnAllDB AS SELECT 1'); +GO + +ALTER PROCEDURE dbo.usp_SearchOnAllDB(@phrase VARCHAR(8000), + @OutFullRecords BIT = 0) +AS + /* + To apply so: + exec sp_SearchOnAllDB 'Arme%' + exec sp_SearchOnAllDB '%soft%' + exec sp_SearchOnAllDB '_5234_57%', 1 + exec sp_SearchOnAllDB M_cro_oft + */ + DECLARE @sql NVARCHAR(max); + DECLARE @schema SYSNAME; + DECLARE @tbl SYSNAME; + DECLARE @col SYSNAME; + DECLARE @id_present BIT + DECLARE @is_char_phrase BIT + DECLARE @min_len INT + DECLARE @loop_idx INT + DECLARE @loop_chr CHAR(1) + + SET nocount ON + + IF Isnull(@phrase, '') = '' + BEGIN + RAISERROR('Phrase is absent',16,-1) + + RETURN + END + + -- Handle Quotes passed in the search string + SET @phrase = Replace(@phrase, '''', '''''') + + SELECT @loop_idx = 1, + @is_char_phrase = 0, + @min_len = 0 + + WHILE @loop_idx <= Len(@phrase) + BEGIN + SET @loop_chr = Substring(@phrase, @loop_idx, 1) + + IF @loop_chr NOT IN ( '%', '_' ) + SET @min_len = @min_len + 1 + + IF @is_char_phrase = 0 + AND @loop_chr NOT IN ( '%', '_', '0', '1', + '2', '3', '4', '5', + '6', '7', '8', '9', '.' ) + SET @is_char_phrase = 1 + + SET @loop_idx = @loop_idx + 1 + END + + CREATE TABLE #tbl_res + ( + SchemaName SYSNAME NOT NULL, + TableName SYSNAME NOT NULL, + ColumnName SYSNAME NOT NULL, + Id INT NULL, + ColumnValue NVARCHAR(max) NOT NULL + ); + + CREATE TABLE #tbl_res2 + ( + SchemaName SYSNAME NOT NULL, + TableName SYSNAME NOT NULL, + ColumnName SYSNAME NOT NULL, + Id INT NULL, + ColumnValue NVARCHAR(max) NOT NULL + ); + + DECLARE crr CURSOR local fast_forward FOR + SELECT s.NAME AS SchemaName, + t.NAME AS TableName, + c.NAME AS ColumnName, + 1 AS id_present + FROM sys.objects t + INNER JOIN sys.syscolumns c + ON c.id = t.object_id + INNER JOIN sys.schemas AS s + ON t.schema_id = s.schema_id + WHERE t.type = 'U' + AND c.status&0x80 = 0 -- Not IDENTITY + AND EXISTS (SELECT * + FROM syscolumns c2 + WHERE t.object_id = c2.id + AND c2.status&0x80 = 0x80 + AND c2.xtype IN ( 48, 52, 56 )) + AND ( ( @is_char_phrase = 1 + AND c.xtype IN ( 175, 239, 99, 231, + 35, 167 ) + AND c.length >= @min_len ) -- char only + OR ( @is_char_phrase = 0 + AND c.xtype NOT IN ( 34, 165, 173, 189, + 61, 58, 36 ) ) ) + -- char and numeric + UNION + SELECT s.name, + t.name, + c.name, + 0 + FROM sys.objects t + INNER JOIN sys.syscolumns c + ON c.id = t.object_id + INNER JOIN sys.schemas AS s + ON t.schema_id = s.schema_id + WHERE t.type = 'U' + AND NOT EXISTS (SELECT * + FROM syscolumns c2 + WHERE t.object_id = c2.id + AND c2.status&0x80 = 0x80 + AND c2.xtype IN ( 48, 52, 56 )) + AND ( ( @is_char_phrase = 1 + AND c.xtype IN ( 175, 239, 99, 231, + 35, 167 ) + AND c.length >= @min_len ) -- char only + OR ( @is_char_phrase = 0 + AND c.xtype NOT IN ( 34, 165, 173, 189, + 61, 58, 36 ) ) ) + -- char and numeric + ORDER BY 1, + 2; + + OPEN crr + FETCH crr INTO @schema, @tbl, @col, @id_present + WHILE @@FETCH_STATUS = 0 + BEGIN + IF @OutFullRecords = 0 + BEGIN + SET @sql = + 'insert into #tbl_res (SchemaName, TableName, ColumnName, Id, ColumnValue) ' + + 'select ''[' + @schema + ']'', ''[' + @tbl + + ']'', ''[' + @col + ']'', ' + + IF @id_present = 1 + SET @sql = @sql + 'IDENTITYCOL, ' + ELSE + SET @sql = @sql + 'NULL, ' + + SET @sql = @sql + 'convert(NVARCHAR(MAX), [' + @col + ']) ' + + 'from [' + @schema + '].[' + @tbl + '] (nolock) ' + + 'where convert(varchar(8000), [' + @col + + ']) like ''' + @phrase + ''' ' + END + + IF @OutFullRecords = 1 + BEGIN + SET @sql = 'if exists (select * from [' + @tbl + + '] (nolock) ' + + 'where convert(varchar(8000), [' + @col + + ']) like ''' + @phrase + ''') ' + 'select ''[' + + @tbl + ']'' TableName, ''[' + @col + + ']'' ColumnName, * ' + 'from [' + @tbl + + '] (nolock) where convert(varchar(8000), [' + + @col + ']) like ''' + @phrase + ''';' + END + EXEC(@sql); + + FETCH crr INTO @schema, @tbl, @col, @id_present; + END + + CLOSE crr; + DEALLOCATE crr; + + IF @OutFullRecords = 0 + BEGIN + INSERT #tbl_res2 + SELECT SchemaName, + TableName, + ColumnName, + Id, + CONVERT(VARCHAR(255), ColumnValue) ColumnValue + FROM #tbl_res; + END + SELECT SchemaName, + TableName, + ColumnName, + ColumnValue + FROM #tbl_res2 + GROUP BY SchemaName, + TableName, + ColumnName, + ColumnValue + ORDER BY SchemaName, + TableName; +GO \ No newline at end of file diff --git a/Stored_Procedure/dbo.usp_SearchStoredProcedureText.sql b/Stored_Procedure/dbo.usp_SearchStoredProcedureText.sql new file mode 100644 index 00000000..4f9b534e --- /dev/null +++ b/Stored_Procedure/dbo.usp_SearchStoredProcedureText.sql @@ -0,0 +1,91 @@ +SET NOEXEC OFF; + +IF OBJECT_ID('dbo.sp_foreachdb', 'P') IS NULL +RAISERROR('Please install before awesome stored procedure https://github.com/ktaranov/SQL-Server-First-Responder-Kit/blob/master/sp_foreachdb.sql', 16, 1); +SET NOEXEC ON; +GO + + +IF OBJECT_ID('dbo.usp_SearchStoredProcedureText', 'P') IS NULL +EXECUTE ('CREATE PROCEDURE dbo.usp_SearchStoredProcedureText AS RETURN'); +GO + + +ALTER PROCEDURE dbo.usp_SearchStoredProcedureText( + @searchforthis NVARCHAR(512) + , @object_type VARCHAR(2) = NULL + , @is_ms_shipped BIT = 0 +) +AS +/* +.DESCRIPTION +Search text in stored procedures + +.EXAMPLE +EXEC dbo.usp_SearchStoredProcedureText @searchforthis = 'sp_foreachdb'; + +.NOTE + Author: Tim Ford + Original link: https://www.itprotoday.com/microsoft-sql-server/using-sqlmodules-system-catalog-view-search-function-and-stored-procedure + + +*/ +SET NOCOUNT ON; + +DECLARE @search_text NVARCHAR(MAX); + +CREATE TABLE #search_results + ( + the__database sysname NOT NULL, + the__schema sysname NOT NULL, + object__name sysname NOT NULL, + object__type NVARCHAR(120) NOT NULL, + is_ms_shipped BIT NOT NULL, + sql__text NVARCHAR(MAX) NOT NULL + ); + +IF @object_type IS NULL + BEGIN + SELECT @search_text = + 'USE ?; + INSERT INTO #search_results (the__database, the__schema, object__name, object__type, is_ms_shipped, sql__text) + SELECT db_name() AS the__database + , OBJECT_SCHEMA_NAME(O.object_id) AS the__schema + , O.name AS object__name + , O.type_desc AS object__type + , O.is_ms_shipped + , M.definition AS sql__text + FROM sys.objects O WITH(NOLOCK) + LEFT JOIN sys.sql_modules M ON O.object_id = M.object_id + WHERE O.is_ms_shipped = ' + CAST(@is_ms_shipped AS VARCHAR(1)) + ' AND M.definition LIKE ''%' + @searchforthis + '%''' + ';'; + END; +ELSE + BEGIN + SELECT @search_text = + 'USE ?; + INSERT INTO #search_results (the__database, the__schema, object__name, object__type, is_ms_shipped, sql__text) + SELECT db_name() AS the__database + , OBJECT_SCHEMA_NAME(O.object_id) AS the__schema + , O.name AS object__name + , O.type_desc AS object__type + , O.is_ms_shipped + , M.definition AS sql__text + FROM sys.objects O WITH(NOLOCK) + LEFT JOIN sys.sql_modules M ON O.object_id = M.object_id + WHERE O.is_ms_shipped = ' + CAST(@is_ms_shipped AS VARCHAR(1)) + ' AND O.type = ''' + @object_type + '''' + + 'AND M.definition LIKE ''%' + @searchforthis + '%''' + ';'; + END; + +EXEC dbo.sp_foreachdb @command = @search_text; + +SELECT the__database + , the__schema + , object__name + , object__type + , is_ms_shipped + , sql__text +FROM #search_results +ORDER BY the__database + , the__schema + , object__name; +GO diff --git a/Stored_Procedure/usp_SetFileGrowth.sql b/Stored_Procedure/dbo.usp_SetFileGrowth.sql similarity index 100% rename from Stored_Procedure/usp_SetFileGrowth.sql rename to Stored_Procedure/dbo.usp_SetFileGrowth.sql diff --git a/Stored_Procedure/dbo.usp_String_Search.sql b/Stored_Procedure/dbo.usp_String_Search.sql new file mode 100644 index 00000000..c850b0a6 --- /dev/null +++ b/Stored_Procedure/dbo.usp_String_Search.sql @@ -0,0 +1,460 @@ +IF OBJECT_ID (N'dbo.usp_String_Search', N'P') IS NULL +EXECUTE ('CREATE PROCEDURE dbo.usp_String_Search AS SELECT 1 AS shell') +GO + + +----------------------------------------------------------------------------------------------------------------------------- +-- Stored Procedure Details: Listing Of Standard Details Related To The Stored Procedure +----------------------------------------------------------------------------------------------------------------------------- + +-- Purpose: Search For A String Value Within Columns Of Data Types CHAR, NCHAR, NTEXT, NVARCHAR, TEXT, VARCHAR, XML +-- Create Date (MM/DD/YYYY): 03/20/2012 +-- Developer: Sean Smith (s.smith.sql AT gmail DOT com) +-- Additional Notes: N/A + + +----------------------------------------------------------------------------------------------------------------------------- +-- Modification History: Listing Of All Modifications Since Original Implementation +----------------------------------------------------------------------------------------------------------------------------- + +-- Description: Added "is_ms_shipped" Field +-- : Added Option To Include System Objects In Search +-- Date (MM/DD/YYYY): 12/06/2015 +-- Developer: Sean Smith (s.smith.sql AT gmail DOT com) +-- Additional Notes: N/A + + +----------------------------------------------------------------------------------------------------------------------------- +-- Main Query: Create Procedure +----------------------------------------------------------------------------------------------------------------------------- + +ALTER PROCEDURE dbo.usp_String_Search( + @Search_String AS NVARCHAR (500) + ,@Database_Name AS NVARCHAR (300) + ,@Object_Types AS NVARCHAR (10) = NULL + ,@Data_Types AS NVARCHAR (100) = NULL + ,@Table_Max_Rows AS BIGINT = NULL + ,@Column_Max_Length AS SMALLINT = NULL + ,@Creation_Source AS NVARCHAR (1) = N'U' +) +AS + +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SET NOCOUNT ON; +SET ANSI_WARNINGS OFF; +SET ARITHABORT OFF; +SET ARITHIGNORE ON; +SET TEXTSIZE 2147483647; + +DECLARE + @Creation_Filter AS NVARCHAR (30) + ,@Loop_Column_Number AS BIGINT + ,@Loop_Column_Number_First AS BIGINT + ,@Loop_Object_Number AS BIGINT + ,@Object_Name AS SYSNAME + ,@Object_Prefix AS NVARCHAR (4) + ,@Schema_Name AS SYSNAME + ,@SQL_String_Full AS NVARCHAR (MAX) + ,@SQL_String_IN_Column_Name AS NVARCHAR (MAX) + ,@SQL_String_SELECT AS NVARCHAR (MAX) + ,@SQL_String_WHERE AS NVARCHAR (MAX); + +SET @Creation_Filter = (CASE @Creation_Source + WHEN N'S' THEN N'AND O.is_ms_shipped = 1' + WHEN N'U' THEN N'AND O.is_ms_shipped = 0' + ELSE N'' + END); + +SET @Object_Prefix = (CASE + WHEN @Creation_Source IN (N'B', N'S') THEN N'all_' + ELSE N'' + END); + +SET @Object_Types = N'''' + REPLACE (REPLACE (NULLIF (@Object_Types, N''), N' ', N''), N',', N''',''') + N'''' +SET @Data_Types = N'''' + REPLACE (REPLACE (NULLIF (@Data_Types, N''), N' ', N''), N',', N''',''') + N'''' + +----------------------------------------------------------------------------------------------------------------------------- +-- Error Trapping I: Validate "@Creation_Source", "@Database_Name", And "@Search_String" Input Parameter Values +----------------------------------------------------------------------------------------------------------------------------- + +IF @Creation_Source NOT IN (N'B', N'S', N'U') +BEGIN + + RAISERROR( + 'ERROR: ''%s'' is not a valid creation source. + +Valid Creation Sources: + +B : Both (User and System created objects) +S : System created objects only +U : User created objects only' + ,16 + ,1 + ,@Creation_Source + ); + RETURN +END + + +IF EXISTS (SELECT * FROM master.sys.databases DB WHERE DB.name = @Database_Name) +BEGIN + + SET @Database_Name = QUOTENAME (@Database_Name) + +END +ELSE IF EXISTS (SELECT * FROM master.sys.databases DB WHERE QUOTENAME (DB.name) = @Database_Name + N']') +BEGIN + + SET @Database_Name = @Database_Name + N']' + +END +ELSE IF NOT EXISTS (SELECT * FROM master.sys.databases DB WHERE QUOTENAME (DB.name) = @Database_Name) +BEGIN + + RAISERROR + + ( + N'ERROR: Database (''%s'') does not exist. Make sure that the name is entered correctly.' + ,16 + ,1 + ,@Database_Name + ); + RETURN +END + + +IF NULLIF (@Search_String, N'') IS NOT NULL +BEGIN + SET @Search_String = REPLACE (REPLACE (REPLACE (REPLACE (@Search_String, N'[', N'[[]'), N'%', N'[%]'), N'_', N'[_]'), N'''', N'''''') +END +ELSE BEGIN + + RAISERROR + ( + N'ERROR: @Search_String input parameter cannot be blank or NULL.' + ,16 + ,1 + ); + RETURN; +END; + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Creation: Create Temp Tables To Temporarily Store Searchable Objects / Columns And Output Results +----------------------------------------------------------------------------------------------------------------------------- + +CREATE TABLE dbo.#temp_string_search_objects_columns + + ( + object_type VARCHAR (2) NOT NULL + ,is_ms_shipped BIT NOT NULL + ,data_type SYSNAME NOT NULL + ,data_length SMALLINT NOT NULL + ,[schema_name] SYSNAME NOT NULL + ,[object_name] SYSNAME NOT NULL + ,column_name SYSNAME NOT NULL + ,schema_object_dense_rank BIGINT NOT NULL + ,column_row_number BIGINT UNIQUE NOT NULL + ,PRIMARY KEY CLUSTERED + ( + schema_object_dense_rank + ,column_row_number + ) + ); + +CREATE TABLE dbo.#temp_string_search_results + + ( + [schema_name] SYSNAME NOT NULL + ,[object_name] SYSNAME NOT NULL + ,column_name SYSNAME NOT NULL + ,column_data NVARCHAR (MAX) NOT NULL + ,occurrences INT NOT NULL + ); + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Update I: Insert Searchable Objects / Columns Into Temp Table +----------------------------------------------------------------------------------------------------------------------------- + SET @SQL_String_Full = + N' + SELECT + O.[type] AS object_type + ,O.is_ms_shipped + ,LOWER (TYPE_NAME (C.user_type_id) + ISNULL ((N'': [ '' + (CASE + WHEN C.system_type_id <> C.user_type_id THEN TYPE_NAME (C.system_type_id) + END) + N'' ]''), N'''')) AS data_type + ,(CASE + WHEN LOWER (TYPE_NAME (C.system_type_id)) IN (N''nchar'', N''ntext'', N''nvarchar'') THEN CONVERT (VARCHAR (6), C.max_length / 2) + WHEN LOWER (TYPE_NAME (C.system_type_id)) NOT IN (N''bigint'', N''bit'', N''date'', N''datetime'', N''datetime2'', N''datetimeoffset'', N''decimal'', N''float'', N''int'', N''money'', N''numeric'', N''real'', N''smalldatetime'', N''smallint'', N''smallmoney'', N''time'', N''tinyint'') THEN CONVERT (VARCHAR (6), C.max_length) + ELSE CONVERT (VARCHAR (6), C.max_length) + '' ('' + CONVERT (VARCHAR (11), COLUMNPROPERTY (C.[object_id], C.name, ''Precision'')) + '','' + ISNULL (CONVERT (VARCHAR (11), COLUMNPROPERTY (C.[object_id], C.name, ''Scale'')), 0) + '')'' + END) AS data_length + ,S.name AS [schema_name] + ,O.name AS [object_name] + ,C.name AS column_name + ,DENSE_RANK () OVER + ( + ORDER BY + S.name + ,O.name + ) AS schema_object_dense_rank + ,ROW_NUMBER () OVER + ( + ORDER BY + C.name + ) AS column_row_number + FROM + ' + @Database_Name + N'.sys.schemas S + INNER JOIN ' + @Database_Name + N'.sys.' + @Object_Prefix + N'objects O ON O.[schema_id] = S.[schema_id] + AND O.[type] IN (' + (CASE + WHEN @Object_Types IS NOT NULL THEN @Object_Types + ELSE N'''U'', ''V''' + END) + N') + ' + + @Creation_Filter + + N' + INNER JOIN ' + @Database_Name + N'.sys.' + @Object_Prefix + N'columns C ON C.[object_id] = O.[object_id] + ' + +IF @Column_Max_Length > 0 +BEGIN + SET @SQL_String_Full = @SQL_String_Full + + N' + ' + NCHAR (9) + N'AND C.system_type_id IN (167, 175, 231, 239) + ' + NCHAR (9) + N'AND (CASE + WHEN TYPE_NAME (C.system_type_id) IN (N''nchar'', N''ntext'', N''nvarchar'') THEN C.max_length / 2 + ELSE C.max_length + END) BETWEEN 1 AND ' + CONVERT (NVARCHAR (6), @Column_Max_Length) + N' + '; +END +ELSE BEGIN + SET @SQL_String_Full = @SQL_String_Full + + N' + ' + NCHAR (9) + N'AND C.system_type_id IN (35, 99, 167, 175, 231, 239, 241) + '; +END + +SET @SQL_String_Full = @SQL_String_Full + + N' + INNER JOIN ' + @Database_Name + N'.sys.types T ON T.system_type_id = C.system_type_id + AND T.user_type_id = C.user_type_id + ' + (CASE + WHEN @Data_Types IS NOT NULL THEN REPLICATE (NCHAR (9), 3) + N'AND T.name IN (' + @Data_Types + N')' + ELSE N'' + END) + +IF @Table_Max_Rows > 0 +BEGIN + SET @SQL_String_Full = @SQL_String_Full + + N' + INNER JOIN + ( + SELECT + DDPS.[object_id] + FROM + ' + @Database_Name + N'.sys.dm_db_partition_stats DDPS + WHERE + DDPS.index_id < 2 + GROUP BY + DDPS.[object_id] + HAVING + SUM (DDPS.row_count) <= ' + CONVERT (NVARCHAR (20), @Table_Max_Rows) + N' + ) sqTMR ON sqTMR.[object_id] = O.[object_id] + ' +END + + +INSERT INTO dbo.#temp_string_search_objects_columns( + object_type + ,is_ms_shipped + ,data_type + ,data_length + ,[schema_name] + ,[object_name] + ,column_name + ,schema_object_dense_rank + ,column_row_number + ) +EXECUTE (@SQL_String_Full); + + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Update II: Insert Matched Results Into Temp Table +----------------------------------------------------------------------------------------------------------------------------- +SELECT TOP (1) + @Loop_Object_Number = X.schema_object_dense_rank + ,@Schema_Name = X.[schema_name] + ,@Object_Name = X.[object_name] +FROM + dbo.#temp_string_search_objects_columns X +ORDER BY + X.schema_object_dense_rank; + +WHILE @Loop_Object_Number IS NOT NULL +BEGIN + + SET @SQL_String_SELECT = N''; + SET @SQL_String_IN_Column_Name = N''; + SET @SQL_String_WHERE = N''; + SET @Loop_Column_Number = (SELECT MIN (X.column_row_number) FROM dbo.#temp_string_search_objects_columns X WHERE X.schema_object_dense_rank = @Loop_Object_Number); + SET @Loop_Column_Number_First = @Loop_Column_Number; + WHILE @Loop_Column_Number IS NOT NULL + BEGIN + SELECT + @SQL_String_SELECT = @SQL_String_SELECT + (CASE + WHEN @Loop_Column_Number = @Loop_Column_Number_First THEN N'SELECT' + NCHAR (13) + REPLICATE (NCHAR (9), 7) + N' ' + ELSE NCHAR (13) + REPLICATE (NCHAR (9), 7) + N',' + END) + N'CONVERT (NVARCHAR (MAX), (CASE + WHEN ' + (CASE + WHEN X.data_type = N'XML' THEN N'CONVERT (NVARCHAR (MAX), ' + ELSE N'' + END) + QUOTENAME (X.column_name) + (CASE + WHEN X.data_type = N'XML' THEN N')' + ELSE N'' + END) + N' LIKE ''%' + @Search_String + N'%'' THEN ' + QUOTENAME (X.column_name) + N' + ELSE NULL + END)) AS ' + QUOTENAME (X.column_name) + ,@SQL_String_IN_Column_Name = @SQL_String_IN_Column_Name + (CASE + WHEN @Loop_Column_Number = @Loop_Column_Number_First THEN N'' + ELSE N', ' + END) + QUOTENAME (X.column_name) + ,@SQL_String_WHERE = @SQL_String_WHERE + (CASE + WHEN @Loop_Column_Number = @Loop_Column_Number_First THEN NCHAR (13) + REPLICATE (NCHAR (9), 6) + N'WHERE' + NCHAR (13) + REPLICATE (NCHAR (9), 7) + ELSE NCHAR (13) + REPLICATE (NCHAR (9), 7) + N'OR ' + END) + (CASE + WHEN X.data_type = N'XML' THEN N'CONVERT (NVARCHAR (MAX), ' + ELSE N'' + END) + QUOTENAME (X.column_name) + (CASE + WHEN X.data_type = N'XML' THEN N')' + ELSE N'' + END) + N' LIKE ''%' + @Search_String + N'%''' + FROM + dbo.#temp_string_search_objects_columns X + WHERE + X.schema_object_dense_rank = @Loop_Object_Number + AND X.column_row_number = @Loop_Column_Number; + + + SET @Loop_Column_Number = (SELECT MIN (X.column_row_number) FROM dbo.#temp_string_search_objects_columns X WHERE X.schema_object_dense_rank = @Loop_Object_Number AND X.column_row_number > @Loop_Column_Number) + + END + + + SET @SQL_String_Full = + + ( + N' + SELECT + ''' + @Schema_Name + N''' AS [schema_name] + ,''' + @Object_Name + N''' AS [object_name] + ,UNPV.column_name + ,UNPV.column_data + ,COUNT (*) AS occurrences + FROM + + ( + ' + + @SQL_String_SELECT + + NCHAR (13) + REPLICATE (NCHAR (9), 6) + N'FROM' + NCHAR (13) + + REPLICATE (NCHAR (9), 7) + @Database_Name + + N'.' + + QUOTENAME (@Schema_Name) + + N'.' + + QUOTENAME (@Object_Name) + + @SQL_String_WHERE + + N' + ) sqMAT + + UNPIVOT + + ( + column_data FOR column_name IN + + ( + ' + @SQL_String_IN_Column_Name + N' + ) + + ) UNPV + + GROUP BY + UNPV.column_name + ,UNPV.column_data + ' + ) + + + BEGIN TRY + + INSERT INTO dbo.#temp_string_search_results + + ( + [schema_name] + ,[object_name] + ,column_name + ,column_data + ,occurrences + ) + + EXECUTE (@SQL_String_Full) + + END TRY + BEGIN CATCH + + END CATCH + + + SELECT TOP (1) + @Loop_Object_Number = X.schema_object_dense_rank + ,@Schema_Name = X.[schema_name] + ,@Object_Name = X.[object_name] + FROM + dbo.#temp_string_search_objects_columns X + WHERE + X.schema_object_dense_rank = @Loop_Object_Number + 1 + ORDER BY + X.schema_object_dense_rank + + IF @@ROWCOUNT = 0 + BEGIN + SET @Loop_Object_Number = NULL + END +END + + +----------------------------------------------------------------------------------------------------------------------------- +-- Main Query: Final Display / Output +----------------------------------------------------------------------------------------------------------------------------- + +SELECT + (CASE Y.object_type + WHEN 'U' THEN 'Table' + WHEN 'V' THEN 'View' + ELSE 'ERROR' + END) AS object_type + ,(CASE + WHEN Y.is_ms_shipped = 1 THEN 'Yes' + ELSE 'No' + END) AS is_ms_shipped + ,Y.data_type + ,Y.data_length + ,DB_NAME (DB_ID (SUBSTRING (@Database_Name, 2, LEN (@Database_Name) - 2))) AS database_name + ,Y.[schema_name] + ,Y.[object_name] + ,Y.column_name + ,Z.column_data + ,CONVERT (XML, (CASE + WHEN Y.data_type = N'XML' THEN Z.column_data + ELSE N'' + END)) AS column_data_xml + ,Z.occurrences +FROM + dbo.#temp_string_search_objects_columns Y + INNER JOIN dbo.#temp_string_search_results Z ON Z.[schema_name] = Y.[schema_name] + AND Z.[object_name] = Y.[object_name] + AND Z.column_name = Y.column_name +ORDER BY + Y.object_type + ,Y.is_ms_shipped + ,Y.[schema_name] + ,Y.[object_name] + ,Y.column_name + ,Z.column_data; +GO diff --git a/Stored_Procedure/dbo.usp_TableUnpivot.sql b/Stored_Procedure/dbo.usp_TableUnpivot.sql new file mode 100644 index 00000000..4e1b6357 --- /dev/null +++ b/Stored_Procedure/dbo.usp_TableUnpivot.sql @@ -0,0 +1,108 @@ +IF OBJECT_ID('dbo.usp_TableUnpivot', 'P') IS NULL +EXEC ('CREATE PROCEDURE dbo.usp_TableUnpivot AS SELECT 1'); +go + +ALTER PROCEDURE dbo.usp_TableUnpivot ( + @databaseName sysname = '', + @schemaName sysname = 'dbo', + @tableName sysname, + @unpivotColumns nvarchar(max) = '', + @constantColumns nvarchar(max) = '', + @excludeColumns nvarchar(max) = '', + @orderBYColumns nvarchar(max) = '', + @debug bit = 0 +) +AS + +/* +CREATE TABLE dbo.CustomerPhones +( + CustomerID INT PRIMARY KEY, -- FK + Phone1 VARCHAR(32), + PhoneType1 CHAR(4), + Phone2 VARCHAR(32), + PhoneType2 CHAR(4), + Phone3 VARCHAR(32), + PhoneType3 CHAR(4) +); +INSERT INTO dbo.CustomerPhones (CustomerID, Phone1, PhoneType1, Phone2, PhoneType2, Phone3, PhoneType3) +VALUES + (1,'705-491-1111', 'cell', '705-491-1110', 'home', NULL,NULL), + (2,'613-492-2222', 'home', NULL, NULL, NULL, NULL), + (3,'416-493-3333', 'work', '416-493-3330', 'cell', '416-493-3339', 'home'); + +EXECUTE [usp_TableUnpivot] @databaseName = '', + @schemaName = 'dbo', + @tableName = 'CustomerPhones', + @unpivotColumns = 'CustomerID', /*!!! table columns list for unpivot with comma separator without spaces !!!*/ + @excludeColumns = 'TableNameID', /*!!! table columns list for excluding with comma separator without spaces !!!*/ + @constantColumns = ', ''Constant1'' AS ConstantColumnName1, ''Constant2'' AS ConstantColumnName2', /*!!! constant values !!!*/ + @oderByColumns = '', + @debug = 1; /*!!! only generate sql statement without executing it !!!*/ +*/ + +BEGIN + +BEGIN TRY + + DECLARE @tableColumns nvarchar(max) = ''; + DECLARE @tableNameFull nvarchar(400) = CASE WHEN @databaseName = '' THEN '' ELSE QUOTENAME(@databaseName) + '.' END + QUOTENAME(@schemaName) + '.' + QUOTENAME(@tableName); + DECLARE @object_id integer = OBJECT_ID(@tableNameFull); + DECLARE @sqlCommand nvarchar(max) = ''; + DECLARE @ParmDefinition nvarchar(500) = '@object_idIN INTEGER, @ColumnsOUT VARCHAR(MAX) OUTPUT'; + DECLARE @crlf nvarchar(5) = CHAR(13); + + IF @debug = 0 SET NOCOUNT ON ELSE PRINT '/******* Start Debug' + @crlf; + + IF @debug = 1 PRINT ISNULL('@tableNameFull = {' + CAST(@tableNameFull AS VARCHAR) + '}', '@tableNameFull = Null'); + IF @debug = 1 PRINT ISNULL('@object_id = {' + CAST(@object_id AS VARCHAR) + '}', '@object_id = Null'); + + SET @sqlCommand = CASE WHEN @databaseName = '' THEN '' ELSE N'USE ' + QUOTENAME(@databaseName) + N';' END + @crlf + + N'SELECT @ColumnsOUT = @ColumnsOUT + QUOTENAME(Name) + '',''' + @crlf + + N'FROM sys.columns sac ' + @crlf + + N'WHERE sac.object_id = @object_idIN' + @crlf + + N' AND Name NOT IN (''' + REPLACE(@unpivotColumns, N',', N''',''') + N''',''' + + REPLACE(@excludeColumns, N',', N''',''') + N''')' + @crlf + + N'ORDER BY Name;'; + + IF @debug = 1 PRINT ISNULL(N'@sqlCommand = {' + @crlf + @sqlCommand + @crlf + N'}', N'@sqlCommand = Null'); + + EXECUTE sp_executesql @sqlCommand, @ParmDefinition, @object_idIN = @object_id, @ColumnsOUT = @tableColumns OUTPUT SELECT @tableColumns; + + IF @debug = 1 PRINT ISNULL('@tableColumns = {' + @crlf + @tableColumns + @crlf + '}', '@tableColumns = Null'); + + SET @tableColumns = CASE WHEN LEN(@tableColumns) > 0 THEN LEFT(@tableColumns, LEN(@tableColumns) - 1) END; + + SET @sqlCommand = N'SELECT ' + @unpivotColumns + N', val, columns' + @constantColumns + @crlf + + N' FROM ' + @crlf + + N' (' + @crlf + + N' SELECT *' + @crlf + + N' FROM ' + @schemaName + '.' + @tableName + @crlf + + N') s' + @crlf + + N'UNPIVOT' + @crlf + + N' (' + @crlf + + N' val FOR columns IN (' + @tableColumns + ' )' + @crlf + + N' ) p' + @crlf + + CASE WHEN @orderBYColumns != '' THEN N'ORDER BY ' + @orderBYColumns ELSE '' END; + + IF @debug = 1 PRINT CAST(ISNULL('@sqlCommand = {' + @crlf + @sqlCommand + @crlf + '}' + @crlf, '@sqlCommand = Null' + @crlf) AS TEXT); + + IF @debug = 0 EXECUTE sp_executesql @sqlCommand; + + IF @debug = 0 SET NOCOUNT OFF ELSE PRINT 'End Debug *******/'; + END TRY + + BEGIN CATCH + PRINT(@crlf + + 'Error: ' + CONVERT(varchar(50), ERROR_NUMBER()) + + ', Severity: ' + CONVERT(varchar(5), ERROR_SEVERITY()) + + ', State: ' + CONVERT(varchar(5), ERROR_STATE()) + + ', Procedure: ' + ISNULL(ERROR_PROCEDURE(), '-') + + ', Line: ' + CONVERT(varchar(5), ERROR_LINE()) + + ', User name: ' + CONVERT(sysname, ORIGINAL_LOGIN()) + ); + PRINT(ERROR_MESSAGE() + @crlf + @crlf); + END CATCH; + +END +GO diff --git a/Stored_Procedure/usp_TopologicalSort.sql b/Stored_Procedure/dbo.usp_TopologicalSort.sql similarity index 100% rename from Stored_Procedure/usp_TopologicalSort.sql rename to Stored_Procedure/dbo.usp_TopologicalSort.sql diff --git a/Stored_Procedure/dbo.usp_TransliterationEN2RU.sql b/Stored_Procedure/dbo.usp_TransliterationEN2RU.sql new file mode 100644 index 00000000..e75ebf92 --- /dev/null +++ b/Stored_Procedure/dbo.usp_TransliterationEN2RU.sql @@ -0,0 +1,317 @@ +IF OBJECT_ID('dbo.usp_TransliterationEN2RU', 'P') IS NULL + EXECUTE ('CREATE PROCEDURE dbo.usp_TransliterationEN2RU AS SELECT 1;'); +GO + +ALTER PROCEDURE usp_TransliterationEN2RU ( + @inputString NVARCHAR(MAX) + , @transid INT = NULL + ) +/* +.SYNOPSIS + Процедура транслитерации кирилицы в латинский и французский алфавиты. + +.DESCRIPTION + По умолчанию процедура возвращает все 3 типа разных транслитераций, но с помощью параметра @transid можно вернуть только один необходимый. + +.PARAMETER @inputString + Текст кириллицей со знаками препинания, тип данных NVARCHAR(MAX) + +.PARAMETER @transid + Варианты транслитерации: + 1 - в соответствии с приложением 6 приказа МВД России от 26 мая 1997 г. N 310 http://legalacts.ru/doc/prikaz-mvd-rf-ot-26051997-n-310/ ОБРАЗЦЫ НАПИСАНИЯ ФАМИЛИЙ, ИМЕН И ДРУГИХ ДАННЫХ НА ФРАНЦУЗСКОМ ЯЗЫКЕ + 2 - в соответствии с ГОСТ Р 52535.1-2006 http://docs.cntd.ru/document/1200045268 Приложение А (обязательное). Транслитерация кириллицы для русского алфавита + 3 - в соответствии с п. 97 приказа ФМС России N 320 от 15 октября 2012 г.[10] в соответствии с рекомендованным ИКАО международным стандартом (Doc 9303, часть 1, добавлении 9 к разделу IV) http://www.icao.int/publications/Documents/9303_p1_v1_cons_ru.pdf + +.EXAMPLE + EXEC usp_TransliterationEN2RU @inputString = 'Шрамко Александр'; + +.EXAMPLE + EXEC usp_TransliterationEN2RU @inputString = 'ВаСиньин еГЕпа. ксения чьё ю вася мясо шняжка !!!' , @transid = 1; + +.NOTE + Version: 3.0 + Modified: 218-04-02 23:05:21 UTC+3 by Konstantin Taranov + Author: Shramko Aleksandr https://github.com/shramko/mssql/blob/master/transliteration.sql + Link: https://github.com/ktaranov/sqlserver-kit/blob/master/Stored_Procedure/usp_TransliterationEN2RU.sql +*/ +AS +BEGIN TRY + + DECLARE @outputstring NVARCHAR(MAX) + , @counter INT + , @ch1 NVARCHAR(10) + , @ch2 NVARCHAR(10) + , @ch3 NVARCHAR(10); + DECLARE @result_table TABLE ( + id INT + ,translate NVARCHAR(MAX) + ) + + ------------------------------------------------------------------ + ------- 1 - в соответствии с приложением 6 приказа МВД России от 26 мая 1997 г. N 310 ------------------ + SELECT @counter = 1 + ,@outputstring = ''; + + --подготовка случаев: С - между двумя гласными выражается - ss - Goussev. + DECLARE @t1 TABLE (ch NCHAR(1)); + + INSERT INTO @t1 + SELECT N'А' + UNION ALL + SELECT N'Е' + UNION ALL + SELECT N'Ё' + UNION ALL + SELECT N'И' + UNION ALL + SELECT N'О' + UNION ALL + SELECT N'У' + UNION ALL + SELECT N'Ы' + UNION ALL + SELECT N'Э' + UNION ALL + SELECT N'Ю' + UNION ALL + SELECT N'Я'; + + DECLARE @t2 TABLE (ch NCHAR(1)); + + INSERT INTO @t2 + SELECT N'С'; + + DECLARE @str NVARCHAR(4000) = N''; + + SELECT @str = @str + t1.ch + t2.ch + t3.ch + N'|' + FROM @t1 t1 + , @t2 t2 + , @t1 t3; + + WHILE (@counter <= LEN(@inputString)) + BEGIN + SET @ch1 = SUBSTRING(@inputString, @counter, 1); + SET @ch2 = SUBSTRING(@inputString, @counter, 2); + + PRINT (@counter); + + SELECT @outputstring = @outputstring + CASE + WHEN J8 > 0 + THEN CASE + WHEN @ch2 COLLATE Cyrillic_General_CS_AS = upper(@ch2) + THEN 'INE' + ELSE 'ine' + END + WHEN J7 > 0 + THEN CASE + WHEN @ch2 COLLATE Cyrillic_General_CS_AS = upper(@ch2) + THEN 'IE' + ELSE 'ie' + END + WHEN J6 > 0 + THEN CASE + WHEN @ch1 COLLATE Cyrillic_General_CS_AS = upper(@ch1) + THEN 'X' + ELSE 'x' + END + WHEN J5 > 0 + THEN CASE + WHEN @ch1 COLLATE Cyrillic_General_CS_AS = upper(@ch1) + THEN 'SS' + ELSE 'ss' + END + WHEN J4 > 0 + THEN CASE + WHEN @ch2 COLLATE Cyrillic_General_CS_AS = upper(@ch2) + THEN 'GUIA' + WHEN @ch1 COLLATE Cyrillic_General_CS_AS = upper(@ch1) + THEN 'Guia' + ELSE 'guia' + END + WHEN J3 > 0 + THEN CASE + WHEN @ch2 COLLATE Cyrillic_General_CS_AS = upper(@ch2) + THEN 'GUIOU' + WHEN @ch1 COLLATE Cyrillic_General_CS_AS = upper(@ch1) + THEN 'Guiou' + ELSE 'guiou' + END + WHEN J2 > 0 + THEN REPLACE(SUBSTRING(CASE + WHEN @ch2 COLLATE Cyrillic_General_CS_AS = upper(@ch2) + THEN '|GUE|GUE|GUI|GUI|GUY' + WHEN @ch1 COLLATE Cyrillic_General_CS_AS = upper(@ch1) + THEN '|Gue|Gue|Gui|Gui|Guy' + ELSE '|gue|gue|gui|gui|guy' + END, J2 + 1, 3), '|', '') + WHEN J1 > 0 + THEN SUBSTRING(CASE + WHEN @ch2 COLLATE Cyrillic_General_CS_AS = upper(@ch2) + THEN 'OUKHTSCHIA' + WHEN @ch1 COLLATE Cyrillic_General_CS_AS = upper(@ch1) + THEN 'OuKhTsChIa' + ELSE 'oukhtschia' + END, J1 * 2 - 1, 2) + WHEN J11 > 0 + THEN SUBSTRING(CASE + WHEN @ch2 COLLATE Cyrillic_General_CS_AS = upper(@ch2) + THEN 'TCHIOU' + WHEN @ch1 COLLATE Cyrillic_General_CS_AS = upper(@ch1) + THEN 'TchIou' + ELSE 'tchiou' + END, J11 * J11, 3) + WHEN J0 > 0 + THEN SUBSTRING(CASE + WHEN @ch1 COLLATE Cyrillic_General_CS_AS = upper(@ch1) + THEN 'ABVGDEEJZIYKLMNOPRSTFYE' + ELSE 'abvgdeejziyklmnoprstfye' + END, J0, 1) + ELSE CASE + WHEN @ch2 COLLATE Cyrillic_General_CS_AS = upper(@ch2) + THEN REPLACE(@ch1, 'Щ', 'SHTCH') + WHEN @ch1 COLLATE Cyrillic_General_CS_AS = upper(@ch1) + THEN REPLACE(@ch1, 'Щ', 'Shtch') + ELSE REPLACE(@ch1, 'щ', 'shtch') + END + END + ,@counter = @counter + CASE + WHEN J2 + J3 + J4 + J6 + J7 + J8 > 0 + THEN 2 + ELSE 1 + END + FROM ( + SELECT PATINDEX('%|' + SUBSTRING(UPPER(@inputString), @counter, 3 ) + '|%', '|ИН |ИН,|ИН.|ИН;|ИН:|') AS J8 -- Фамилия на "ин" пишутся с "e" - Vassine - Васин. + , PATINDEX('%|' + SUBSTRING(UPPER(@inputString), @counter, 2 ) + '|%', '|ЬЕ|ЬЁ|') AS J7 -- Если в фамилии после "ь" следует "e", то пишется "ie" + , PATINDEX('%|' + SUBSTRING(UPPER(@inputString), @counter, 2 ) + '|%', '|КС|') AS J6 -- Сочетание "кс" во французском тексте пишется как "х" + , PATINDEX('%|' + SUBSTRING(UPPER(@inputString), @counter - 1, 3) + '|%', '|' + @str) AS J5 -- С - между двумя гласными выражается - ss + , PATINDEX('%|' + SUBSTRING(UPPER(@inputString), @counter, 2) + '|%', '|ГЯ|') AS J4 --G,g перед e, i, у пишется с "u" (gue, gui, guy) + , PATINDEX('%|' + SUBSTRING(UPPER(@inputString), @counter, 2) + '|%', '|ГЮ|') AS J3 --G,g перед e, i, у пишется с "u" (gue, gui, guy) + , PATINDEX('%|' + SUBSTRING(UPPER(@inputString), @counter, 2) + '|%', '|ГЕ||ГЭ||ГИ||ГЙ||ГЫ|') AS J2 --G,g перед e, i, у пишется с "u" (gue, gui, guy) + , PATINDEX('%' + SUBSTRING(UPPER(@inputString), @counter, 1) + '%', 'УХЦШЯ') AS J1 + , PATINDEX('%' + SUBSTRING(UPPER(@inputString), @counter, 1) + '%', 'ЧЮ') AS J11 + , PATINDEX('%' + SUBSTRING(UPPER(@inputString), @counter, 1) + '%', 'АБВГДЕЁЖЗИЙКЛМНОПРСТФЫЭЪЬ') AS J0 + ) J + END; + + INSERT INTO @result_table + SELECT 1 + ,@outputstring; + + /*------ 2 - в соответствии с ГОСТ Р 52535.1-2006 -----------------*/ + SELECT @counter = 1 + ,@outputstring = ''; + + WHILE (@counter <= len(@inputString)) + BEGIN + SELECT @ch1 = SUBSTRING(@inputString, @counter, 1) + + SELECT @ch2 = SUBSTRING(@inputString, @counter, 2) + + SELECT @outputstring = @outputstring + CASE + WHEN J1 > 0 + THEN SUBSTRING(CASE + WHEN @ch2 COLLATE Cyrillic_General_CS_AS = upper(@ch2) + THEN 'ZHKHTCCHSHIAIU' + WHEN @ch1 COLLATE Cyrillic_General_CS_AS = upper(@ch1) + THEN 'ZhKhTcChShIaIu' + ELSE 'zhkhtcchshiaiu' + END, J1 * 2 - 1, 2) + WHEN J0 > 0 + THEN SUBSTRING(CASE + WHEN @ch1 COLLATE Cyrillic_General_CS_AS = upper(@ch1) + THEN 'ABVGDEEZIIKLMNOPRSTUFYE' + ELSE 'abvgdeeziiklmnoprstufye' + END, J0, 1) + ELSE CASE + WHEN @ch2 COLLATE Cyrillic_General_CS_AS = UPPER(@ch2) + THEN REPLACE(@ch1, 'Щ', 'SHCH') + WHEN @ch1 COLLATE Cyrillic_General_CS_AS = UPPER(@ch1) + THEN REPLACE(@ch1, 'Щ', 'Shch') + ELSE REPLACE(@ch1, 'щ', 'shch') + END + END + ,@counter = @counter + 1 + FROM ( + SELECT PATINDEX('%' + UPPER(@ch1) + '%', 'ЖХЦЧШЯЮ') AS J1 + ,PATINDEX('%' + UPPER(@ch1) + '%', 'АБВГДЕЁЗИЙКЛМНОПРСТУФЫЭЪЬ') AS J0 + ) J + END; + + INSERT INTO @result_table ( + id + ,translate + ) + SELECT 2 + ,@outputstring + + /* 3 - в соответствии с п. 97 приказа ФМС России N 320 от 15 октября 2012 г.[10] + в соответствии с рекомендованным ИКАО международным стандартом (Doc 9303, часть 1, добавлении 9 к разделу IV) */ + SELECT @counter = 1 + ,@outputstring = ''; + + WHILE (@counter <= len(@inputString)) + BEGIN + SELECT @ch1 = SUBSTRING(@inputString, @counter, 1); + + SELECT @ch2 = SUBSTRING(@inputString, @counter, 2); + + SELECT @outputstring = @outputstring + CASE + WHEN J1 > 0 + THEN SUBSTRING(CASE + WHEN @ch1 COLLATE Cyrillic_General_CS_AS = upper(@ch1) + THEN 'ZHKHTSCHSHIAIUIE' + ELSE 'zhkhtschshiaiuie' + END, J1 * 2 - 1, 2) + WHEN J0 > 0 + THEN SUBSTRING(CASE + WHEN @ch1 COLLATE Cyrillic_General_CS_AS = upper(@ch1) + THEN 'ABVGDEEZIYKLMNOPRSTUFYE' + ELSE 'abvgdeeziyklmnoprstufye' + END, J0, 1) + ELSE CASE + WHEN @ch2 COLLATE Cyrillic_General_CS_AS = upper(@ch2) + THEN REPLACE(@ch1, 'Щ', 'SHCH') + WHEN @ch1 COLLATE Cyrillic_General_CS_AS = upper(@ch1) + THEN REPLACE(@ch1, 'Щ', 'Shch') + ELSE REPLACE(@ch1, 'щ', 'shch') + END + END + ,@counter = @counter + 1 + FROM ( + SELECT PATINDEX('%' + UPPER(@ch1) + '%', 'ЖХЦЧШЯЮЪ') AS J1 + ,PATINDEX('%' + UPPER(@ch1) + '%', 'АБВГДЕЁЗИЙКЛМНОПРСТУФЫЭЬ') AS J0 + ) J + END; + + INSERT INTO @result_table ( + id + ,translate + ) + SELECT 3 + ,@outputstring; + + -------- вывод результата ------------------------ + SELECT * + FROM @result_table + WHERE ( + @transid IS NOT NULL + AND id = @transid + ) + OR ( + id IS NOT NULL + AND @transid IS NULL + ); +END TRY + +BEGIN CATCH + THROW + + PRINT 'Error: ' + CONVERT(VARCHAR(50), ERROR_NUMBER()) + + ', Severity: ' + CONVERT(VARCHAR(5), ERROR_SEVERITY()) + + ', State: ' + CONVERT(VARCHAR(5), ERROR_STATE()) + + ', Procedure: ' + ISNULL(ERROR_PROCEDURE(), '-') + + ', Line: ' + CONVERT(VARCHAR(5), ERROR_LINE()) + + ', User name: ' + CONVERT(SYSNAME, ORIGINAL_LOGIN()); + PRINT ERROR_MESSAGE(); +END CATCH; +GO diff --git a/Stored_Procedure/usp_UnusedInputParameters.sql b/Stored_Procedure/dbo.usp_UnusedInputParameters.sql similarity index 100% rename from Stored_Procedure/usp_UnusedInputParameters.sql rename to Stored_Procedure/dbo.usp_UnusedInputParameters.sql diff --git a/Stored_Procedure/usp_bcpTableUnload.sql b/Stored_Procedure/dbo.usp_bcpTableUnload.sql similarity index 100% rename from Stored_Procedure/usp_bcpTableUnload.sql rename to Stored_Procedure/dbo.usp_bcpTableUnload.sql diff --git a/Stored_Procedure/usp_bcpTableUnloadBatchMode.sql b/Stored_Procedure/dbo.usp_bcpTableUnloadBatchMode.sql similarity index 100% rename from Stored_Procedure/usp_bcpTableUnloadBatchMode.sql rename to Stored_Procedure/dbo.usp_bcpTableUnloadBatchMode.sql diff --git a/Stored_Procedure/dbo.usp_bcpUnloadSelect.sql b/Stored_Procedure/dbo.usp_bcpUnloadSelect.sql new file mode 100644 index 00000000..f5a6a107 --- /dev/null +++ b/Stored_Procedure/dbo.usp_bcpUnloadSelect.sql @@ -0,0 +1,78 @@ +IF OBJECT_ID('dbo.usp_bcpUnloadSelect', 'P') IS NULL EXECUTE('CREATE PROCEDURE dbo.usp_bcpUnloadSelect AS SELECT 1'); +GO + +ALTER PROCEDURE dbo.usp_bcpUnloadSelect( + @outputFilePath varchar(255) /* The path can have from 1 through 255 characters, see documentation */ + , @serverName sysname = @@SERVERNAME + , @sqlCommand varchar(MAX) + , @fileName varchar(300) = '' + , @field_term varchar( 10) = '|' + , @fileExtension varchar( 10) = 'txt' + , @codePage varchar( 10) = 'C65001' /* C1251 - Cyrillic */ + , @row_term VARCHAR( 10) = '\n' + , @debug BIT = 0 +) +AS +/*-- +Official bcp documentation: https://docs.microsoft.com/en-us/sql/tools/bcp-utility +In select statement use full table names: DATABASENAME.SCHEMANAME.TABLENAME +EXECUTE dbo.usp_bcpUnloadSelect + @outputFilePath = 'd:\' + , @serverName = '' + , @sqlCommand = 'SELECT TOP(1000) CHECKSUM(NEWID()) % 10000 FROM master.sys.objects AS s1 CROSS JOIN master.sys.objects AS s2' + , @fileName = 'file_name' + , @field_term = '|' + , @row_term = '\n' + , @fileExtension = 'txt' + , @debug = 0; +--*/ +BEGIN + BEGIN TRY + + SET NOCOUNT ON; + + IF @debug = 1 PRINT '/******* Start Debug'; + + DECLARE @filePath VARCHAR(1000) = @outputFilePath + + CASE WHEN @fileName = '' THEN 'bcp_export_' + QUOTENAME(REPLACE(CONVERT(VARCHAR, GETDATE(), 126 ), ':', '_')) + ELSE @fileName END + + '.' + @fileExtension; + DECLARE @tsqlCommand VARCHAR(8000) = ''; + DECLARE @crlf VARCHAR(10) = CHAR(13) + CHAR(10); + + /* remove break lines from select statement */ + SET @sqlCommand = REPLACE(REPLACE(@sqlCommand, CHAR(13), ' '), CHAR(10), ' '); + /* remove duplicate spaces from select statement */ + SET @sqlCommand = REPLACE(REPLACE(REPLACE(@sqlCommand,' ','<>'), '><', ''), '<>', ' '); + + IF @debug = 1 + BEGIN + PRINT ISNULL('@filePath = {' + @crlf + @filePath + @crlf + '}', '@filePath = {Null}' + @crlf); + PRINT'@sqlCommand = {' + @crlf + @sqlCommand + @crlf + '}'; + END + + SET @tsqlCommand = 'bcp "' + REPLACE(@sqlCommand, @crlf, ' ') + '" queryout "' + @filePath + + '" -T -S ' + @serverName + ' -c -' + @codePage + ' -t"' + @field_term + '"' + + ' -r"' + @row_term + '"' + @crlf; + + IF @debug = 1 + PRINT ISNULL( '@tsqlCommand = {' + @crlf + @tsqlCommand + '}' + @crlf, '@tsqlCommand = {Null}'); + ELSE + EXECUTE xp_cmdshell @tsqlCommand; + + IF @debug = 1 PRINT @crlf + '--End Deubg*********/'; + END TRY + + BEGIN CATCH + PRINT(@crlf + + 'Error: ' + CONVERT(varchar(50), ERROR_NUMBER()) + + ', Severity: ' + CONVERT(varchar(5), ERROR_SEVERITY()) + + ', State: ' + CONVERT(varchar(5), ERROR_STATE()) + + ', Procedure: ' + ISNULL(ERROR_PROCEDURE(), '-') + + ', Line: ' + CONVERT(varchar(5), ERROR_LINE()) + + ', User name: ' + CONVERT(sysname, ORIGINAL_LOGIN()) + ); + PRINT(ERROR_MESSAGE() + @crlf + @crlf); + END CATCH; +END; +GO diff --git a/Stored_Procedure/usp_checkAllDatabases.sql b/Stored_Procedure/dbo.usp_checkAllDatabases.sql similarity index 100% rename from Stored_Procedure/usp_checkAllDatabases.sql rename to Stored_Procedure/dbo.usp_checkAllDatabases.sql diff --git a/Stored_Procedure/usp_generateIdentifier.sql b/Stored_Procedure/dbo.usp_generateIdentifier.sql similarity index 100% rename from Stored_Procedure/usp_generateIdentifier.sql rename to Stored_Procedure/dbo.usp_generateIdentifier.sql diff --git a/Stored_Procedure/dbo.usp_who5.sql b/Stored_Procedure/dbo.usp_who5.sql new file mode 100644 index 00000000..0be7071b --- /dev/null +++ b/Stored_Procedure/dbo.usp_who5.sql @@ -0,0 +1,1651 @@ +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED +SET NOCOUNT ON + + +----------------------------------------------------------------------------------------------------------------------------- +-- Error Trapping: Check If Procedure Already Exists And Create Shell If Applicable +----------------------------------------------------------------------------------------------------------------------------- + +IF OBJECT_ID (N'dbo.usp_who5', N'P') IS NULL +BEGIN + + EXECUTE (N'CREATE PROCEDURE dbo.usp_who5 AS SELECT 1 AS shell') + +END +GO + + +----------------------------------------------------------------------------------------------------------------------------- +-- Stored Procedure Details: Listing Of Standard Details Related To The Stored Procedure +----------------------------------------------------------------------------------------------------------------------------- + +-- Purpose: Return Information Regarding Current Users / Sessions / Processes On A SQL Server Instance +-- Create Date (MM/DD/YYYY): 10/27/2009 +-- Developer: Sean Smith (s.smith.sql AT gmail DOT com) +-- Latest Release: http://www.sqlservercentral.com/scripts/sp_who/68607/ +-- Script Library: http://www.sqlservercentral.com/Authors/Scripts/Sean_Smith/776614/ +-- LinkedIn Profile: https://www.linkedin.com/in/seanmsmith/ + + +----------------------------------------------------------------------------------------------------------------------------- +-- Modification History: Listing Of All Modifications Since Original Implementation +----------------------------------------------------------------------------------------------------------------------------- + +-- Description: Added "@Database_Name" Filter Variable +-- : Added "Last_Wait_Type", "Query_Plan", And "Wait_Type" Fields To Output +-- : Changed Code Formatting +-- : Converted Script To Dynamic-SQL +-- Date (MM/DD/YYYY): 08/08/2011 + + +-- Description: Added "C" Type "@Filter" Option +-- : Added "Plan_Cache_Object_Type", "Plan_Object_Type", "Plan_Times_Used", And "Plan_Size_MB" Fields To Output +-- : Changed Help Output From RAISERROR To PRINT +-- : Merged "I?" And "O?" Help Parameters Into "?" +-- : Renamed Input Parameters +-- : Rewrote Time Calculation Logic +-- Date (MM/DD/YYYY): 11/09/2011 + + +-- Description: Added "SQL_Statement_Current" And "End_Of_Batch" Fields To Output +-- : Added System Process Indicator To "SPID" +-- : Expanded "Running" Type Indicators +-- Date (MM/DD/YYYY): 02/01/2012 + + +-- Description: Bug Fixes +-- : Changed Code Formatting +-- : Changed Date Calculation Method +-- Date (MM/DD/YYYY): 08/19/2013 + + +-- Description: Added "Batch_Pct", "Command_Completion", "Command_Pct", "Command_Time_Left", "Deadlock_Priority", "Isolation_Level", "Last_Row_Count", "Lock_Details", "Lock_Timeout_Seconds", And "Previous_Error" Fields To Output +-- Date (MM/DD/YYYY): 11/24/2013 + + +-- Description: Massive Rewrite Of Entire Stored Procedure +-- Date (MM/DD/YYYY): 11/28/2015 + + +-- Description: Added "Log_Database_Count", "Log_Details", "Log_Records_All", "Log_Reserved_MB_All", "Log_Used_MB_All", "TempDB_Session_Current_MB", "TempDB_Session_Total_MB", "TempDB_Task_Current_MB", "TempDB_Task_Total_MB", "Threads", "Transaction_ID", "Transaction_State", "Transaction_Time", "Transaction_Type" Fields To Output +-- : Added Deadlock Detection To "Blocking" Output Field +-- : No Longer Displays Results At The Execution Context ID (ECID) Level +-- : Removed "@SQL_Text" Filter Variable +-- : Removed "Batch_Pct", "End_Of_Batch", "Plan_Cache_Object_Type", "Plan_Object_Type", "Plan_Size_MB", "Plan_Times_Used", "Previous_Error" Fields From Output +-- : Renamed "SPECID" To "SPID", "Open_Trans" To "Transactions" Output Fields +-- Date (MM/DD/YYYY): 05/07/2016 + + +-- Description: Another Massive Rewrite Of Entire Stored Procedure To Improve Performance +-- Date (MM/DD/YYYY): 01/20/2018 + + +----------------------------------------------------------------------------------------------------------------------------- +-- Main Query: Create Procedure +----------------------------------------------------------------------------------------------------------------------------- + +ALTER PROCEDURE dbo.usp_who5 + + @Filter AS NVARCHAR (5) = NULL + ,@Database_Name AS NVARCHAR (512) = NULL + ,@Exclude_Lock AS BIT = 1 + ,@Exclude_Log AS BIT = 1 + ,@Exclude_Plan AS BIT = 1 + ,@Exclude_SQL AS BIT = 0 + ,@Exclude_SQL_XML AS BIT = 1 + ,@Exclude_TXN AS BIT = 1 + ,@Login AS NVARCHAR (128) = NULL + ,@SPID AS SMALLINT = NULL + +AS + +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED +SET NOCOUNT ON +SET ANSI_WARNINGS OFF +SET ARITHABORT OFF +SET ARITHIGNORE ON +SET TEXTSIZE 2147483647 + + +----------------------------------------------------------------------------------------------------------------------------- +-- Declarations / Sets: Declare And Set Variables +----------------------------------------------------------------------------------------------------------------------------- + +DECLARE + @Ampersand AS NVARCHAR (1) + ,@CR_LF AS NCHAR (2) + ,@CR_LF_Tab AS NCHAR (3) + ,@Database_ID AS INT + ,@Date_Now AS DATETIME + ,@Filter_Active AS BIT + ,@Filter_Blocked AS BIT + ,@Filter_Sleeping AS BIT + ,@Filter_System AS BIT + ,@Plan_Handle AS VARBINARY (64) + ,@Print AS NVARCHAR (MAX) + ,@SQL_Handle AS VARBINARY (64) + ,@SQL_String AS NVARCHAR (MAX) + + +SET @Ampersand = N'&' + + +SET @CR_LF = NCHAR (13) + NCHAR (10) + + +SET @CR_LF_Tab = @CR_LF + NCHAR (9) + + +SET @Database_Name = NULLIF (@Database_Name, N'') + + +SET @Date_Now = GETDATE () + + +SET @Filter_Active = (CASE + WHEN @Filter LIKE N'%A%' THEN 1 + ELSE 0 + END) + + +SET @Filter_Blocked = (CASE + WHEN @Filter LIKE N'%B%' THEN 1 + ELSE 0 + END) + + +SET @Filter_Sleeping = (CASE + WHEN @Filter LIKE N'%S%' THEN 1 + ELSE 0 + END) + + +SET @Filter_System = (CASE + WHEN @Filter LIKE N'%X%' THEN 1 + ELSE 0 + END) + + +SET @Login = NULLIF (@Login, N'') + + +----------------------------------------------------------------------------------------------------------------------------- +-- Error Trapping: Check If "@Filter" Parameter Is An Input / Output Help Request +----------------------------------------------------------------------------------------------------------------------------- + +IF @Filter = N'?' +BEGIN + + SET @Print = + + N' +Optional input parameters: + + @Filter : Limit the result set by passing one or more values listed below (can be combined in any order) + + A - Active sessions only (includes sleeping SPIDs with open transactions) + B - Blocking / blocked sessions only + S - Exclude sleeping SPIDs with open transactions + X - Exclude system processes + + @Database_Name : Limit the result set to a specific database (use ---------- for NULL database names) + @Exclude_Lock : Suppress lock details from the output (can increases procedure performance on busy servers; defaulted to 1) + @Exclude_Log : Suppress log details from the output (can increases procedure performance on busy servers; defaulted to 1) + @Exclude_Plan : Suppress execution plan details from the output (can increases procedure performance on busy servers; defaulted to 1) + @Exclude_SQL : Suppress SQL statement details from the output (can increases procedure performance on busy servers; defaulted to 0) + @Exclude_SQL_XML : Suppress SQL statement XML details from the output (can increases procedure performance on busy servers; defaulted to 1) + @Exclude_TXN : Suppress transaction details from the output (also suppresses log details due to an interdependency; can increases procedure performance on busy servers; defaulted to 1) + @Login : Limit the result set to a specific Windows user name (if populated, otherwise by SQL Server login name) + @SPID : Limit the result set to a specific session + + +Notes: + + Blocking / blocked sessions will always be displayed first in the result set (when applicable) + + +Output: + + SPID : System Process ID + Database_Name : Database context of the session + Running : Indicates if the session is executing (X), waiting ([]), inactive (blank), inactive with open transactions (•), a background task (--), or not defined (N/A) + Blocking : Blocking indicator (includes type of block, SPID list, and deadlock detection when applicable) + Status : Status of the session -> request + Object_Name : Object being referenced (blank for ad hoc and prepared statements) + Command : Command executed + Threads : Process thread count + SQL_Statement_Batch : Batch statement of the session + SQL_Statement_Current : Current statement of the session + Isolation_Level : Isolation level of the session + Wait_Time : Current wait time (DAYS HH:MM:SS) + Wait_Type : Current wait type + Last_Wait_Type : Previous wait type + Elapsed_Time : Elapsed time since the request began (DAYS HH:MM:SS) + CPU_Total : CPU time used since login (DAYS HH:MM:SS) + CPU_Current : CPU time used for the current process (DAYS HH:MM:SS) + Logical_Reads_Total : Logical reads performed since login + Logical_Reads_Current : Logical reads performed by the current process + Physical_Reads_Total : Physical reads performed since login + Physical_Reads_Current : Physical reads performed by the current process + Writes_Total : Writes performed since login + Writes_Current : Writes performed by the current process + Last_Row_Count : Row count produced by the last statement executed + Allocated_Memory_MB : Memory allocated to the query in megabytes + Pages_Used : Pages in the procedure cache allocated to the process + Transactions : Open transactions for the process + Transaction_ID : Transaction ID + Transaction_Time : Elapsed time since the transaction began (DAYS HH:MM:SS) + Transaction_Type : Type of transaction + Transaction_State : State of the transaction + Nesting_Level : Nesting level of the statement executing + TempDB_Session_Total_MB : Temp DB space used since login for the session in megabytes + TempDB_Session_Current_MB : Temp DB space currently used by the session in megabytes + TempDB_Task_Total_MB : Temp DB space used by the entire task in megabytes + TempDB_Task_Current_MB : Temp DB space currently used by the task in megabytes + Log_Database_Count : Databases involved in the transaction + Log_Records_All : Log records generated for the transaction (all databases) + Log_Reserved_MB_All : Log space reserved for the transaction in megabytes (all databases) + Log_Used_MB_All : Log space used for the transaction in megabytes (all databases) + Log_Details : Log usage details for the transaction per database (in XML format) + Lock_Timeout_Seconds : Lock timeout of the session + Lock_Details : Lock details of the session (in XML format) + Deadlock_Priority : Deadlock priority of the session + SQL_Statement_Batch_XML : Same as "SQL_Statement_Batch" but in XML format + SQL_Statement_Current_XML : Same as "SQL_Statement_Current" but in XML format + SQL_Handle : Identifier for the executing batch or object + Query_Plan : Execution plan of the session (in XML format) + Plan_Handle : Identifier for the in-memory plan + Since_SPID_Login : Elapsed time since the client logged in (DAYS HH:MM:SS) + Since_Last_Batch_Start : Elapsed time since the last request began (DAYS HH:MM:SS) + Since_Last_Batch_End : Elapsed time since the last completion of a request (DAYS HH:MM:SS) + Command_Pct : Percentage of work completed (applies to a limited set of commands) + Command_Completion : Estimated completion time for the command + Command_Time_Left : Time left before the command completes (DAYS HH:MM:SS) + Host_Name : Name of the client workstation specific to a session + Login_ID : Windows user name (or "Login_Name" if user name is unavailable) + Login_Name : Full name of the user associated to the "Login_ID" + Application_Description : Application accessing SQL Server + System_Process : Indicates if the session is a system process + SPID : System Process ID + ' + + + PRINT SUBSTRING (@Print, 1, 3931) + + + PRINT SUBSTRING (@Print, 3934, 4000) + + + RETURN + +END + + +----------------------------------------------------------------------------------------------------------------------------- +-- Error Trapping: Check If Temp Table(s) Already Exist(s) And Drop If Applicable +----------------------------------------------------------------------------------------------------------------------------- + +IF OBJECT_ID (N'tempdb.dbo.#temp_core_data', N'U') IS NOT NULL +BEGIN + + DROP TABLE dbo.#temp_core_data + +END + + +IF OBJECT_ID (N'tempdb.dbo.#temp_databases', N'U') IS NOT NULL +BEGIN + + DROP TABLE dbo.#temp_databases + +END + + +IF OBJECT_ID (N'tempdb.dbo.#temp_deadlocking', N'U') IS NOT NULL +BEGIN + + DROP TABLE dbo.#temp_deadlocking + +END + + +IF OBJECT_ID (N'tempdb.dbo.#temp_false_positive_blocking', N'U') IS NOT NULL +BEGIN + + DROP TABLE dbo.#temp_false_positive_blocking + +END + + +IF OBJECT_ID (N'tempdb.dbo.#temp_lock_details', N'U') IS NOT NULL +BEGIN + + DROP TABLE dbo.#temp_lock_details + +END + + +IF OBJECT_ID (N'tempdb.dbo.#temp_log_details', N'U') IS NOT NULL +BEGIN + + DROP TABLE dbo.#temp_log_details + +END + + +IF OBJECT_ID (N'tempdb.dbo.#temp_parallelism', N'U') IS NOT NULL +BEGIN + + DROP TABLE dbo.#temp_parallelism + +END + + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Creation: Create Various Temp Tables +----------------------------------------------------------------------------------------------------------------------------- + +CREATE TABLE dbo.#temp_databases + + ( + database_id INT NULL + ,database_name NVARCHAR (128) NULL + ) + + +CREATE TABLE dbo.#temp_lock_details + + ( + req_spid INT NULL + ,rsc_dbid SMALLINT NULL + ,rsc_objid INT NULL + ,rsc_indid SMALLINT NULL + ,[object_name] NVARCHAR (275) NULL + ,index_name NVARCHAR (128) NULL + ,rsc_type TINYINT NULL + ,req_mode TINYINT NULL + ,req_status TINYINT NULL + ,req_ownertype SMALLINT NULL + ,req_ecid INT NULL + ,req_refcnt INT NULL + ) + + +CREATE TABLE dbo.#temp_log_details + + ( + transaction_id BIGINT NULL + ,database_id INT NULL + ,database_transaction_begin_time DATETIME NULL + ,database_transaction_type INT NULL + ,database_transaction_state INT NULL + ,database_transaction_log_record_count BIGINT NULL + ,database_transaction_log_bytes_reserved BIGINT NULL + ,database_transaction_log_bytes_used BIGINT NULL + ,database_transaction_log_bytes_reserved_system INT NULL + ,database_transaction_log_bytes_used_system INT NULL + ) + + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Insert: Databases +----------------------------------------------------------------------------------------------------------------------------- + +SET @Database_ID = -2147483648 + + +SET LOCK_TIMEOUT 5 + + +WHILE @Database_ID IS NOT NULL +BEGIN + + BEGIN TRY + + INSERT INTO dbo.#temp_databases + + ( + database_id + ,database_name + ) + + SELECT TOP (1) + DB.database_id + ,DB.name AS database_name + FROM + master.sys.databases DB + WHERE + DB.database_id = @Database_ID + + END TRY + BEGIN CATCH + + END CATCH + + + BEGIN TRY + + SET @Database_ID = (SELECT TOP (1) DB.database_id FROM master.sys.databases DB WHERE DB.database_id > @Database_ID ORDER BY DB.database_id) + + END TRY + BEGIN CATCH + + SET @Database_ID = @Database_ID + 1 + + END CATCH + +END + + +SET LOCK_TIMEOUT -1 + + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Insert: Core Data +----------------------------------------------------------------------------------------------------------------------------- + +SELECT + DXS.session_id + ,ttDB.database_name + ,DER.blocking_session_id + ,DXS.[status] AS status_session + ,DER.[status] AS status_request + ,CONVERT (INT, NULL) AS [dbid] + ,CONVERT (INT, NULL) AS objectid + ,CONVERT (NVARCHAR (275), NULL) AS [object_name] + ,DER.command + ,sqSP.threads + ,CONVERT (NVARCHAR (MAX), NULL) AS [text] + ,sqSP.stmt_start + ,sqSP.stmt_end + ,DXS.transaction_isolation_level + ,DER.wait_time + ,DER.wait_type + ,DER.last_wait_type + ,DER.total_elapsed_time + ,DXS.cpu_time AS cpu_time_total + ,DER.cpu_time AS cpu_time_current + ,DXS.logical_reads AS logical_reads_total + ,DER.logical_reads AS logical_reads_current + ,DXS.reads AS reads_total + ,DER.reads AS reads_current + ,DXS.writes AS writes_total + ,DER.writes AS writes_current + ,DXS.row_count + ,DER.granted_query_memory + ,DXS.memory_usage + ,sqSP.open_tran + ,CONVERT (BIGINT, NULL) AS transaction_id + ,CONVERT (DATETIME, NULL) AS transaction_begin_time + ,CONVERT (INT, NULL) AS transaction_type + ,CONVERT (INT, NULL) AS transaction_state + ,DER.nest_level + ,sqTS.tempdb_page_allocation_session + ,sqTS.tempdb_page_deallocation_session + ,sqTT.tempdb_page_allocation_task + ,sqTT.tempdb_page_deallocation_task + ,DXS.[lock_timeout] + ,DXS.[deadlock_priority] + ,sqSP.[sql_handle] + ,CONVERT (XML, NULL) AS query_plan + ,DER.plan_handle + ,DXS.login_time AS login_time_sessions + ,sqSP.login_time AS login_time_processes + ,DXS.last_request_start_time + ,DXS.last_request_end_time + ,sqSP.last_batch + ,DER.percent_complete + ,DER.estimated_completion_time + ,DXS.[host_name] + ,DXS.nt_user_name + ,DXS.login_name + ,DXS.[program_name] + ,DXS.is_user_process +INTO + dbo.#temp_core_data +FROM + master.sys.dm_exec_sessions DXS + INNER JOIN + + ( + SELECT + SP.spid + ,SUM (CASE + WHEN SP.kpid = 0 THEN 0 + ELSE 1 + END) AS threads + ,MAX (SP.stmt_start) AS stmt_start + ,MAX (SP.stmt_end) AS stmt_end + ,MAX (SP.open_tran) AS open_tran + ,MAX (NULLIF (SP.[sql_handle], 0x0000000000000000000000000000000000000000)) AS [sql_handle] + ,MAX (SP.login_time) AS login_time + ,MAX (SP.last_batch) AS last_batch + ,MAX (SP.[dbid]) AS [dbid] + FROM + master.sys.sysprocesses SP + GROUP BY + SP.spid + ) sqSP ON sqSP.spid = DXS.session_id + + LEFT JOIN master.sys.dm_exec_requests DER ON DER.session_id = DXS.session_id + LEFT JOIN dbo.#temp_databases ttDB ON ttDB.database_id = sqSP.[dbid] + LEFT JOIN + + ( + SELECT + DDSSU.session_id + ,SUM (DDSSU.user_objects_alloc_page_count + DDSSU.internal_objects_alloc_page_count) AS tempdb_page_allocation_session + ,SUM (DDSSU.user_objects_dealloc_page_count + DDSSU.internal_objects_dealloc_page_count) AS tempdb_page_deallocation_session + FROM + master.sys.dm_db_session_space_usage DDSSU + GROUP BY + DDSSU.session_id + ) sqTS ON sqTS.session_id = DXS.session_id + + LEFT JOIN + + ( + SELECT + DDTSU.session_id + ,SUM (DDTSU.user_objects_alloc_page_count + DDTSU.internal_objects_alloc_page_count) AS tempdb_page_allocation_task + ,SUM (DDTSU.user_objects_dealloc_page_count + DDTSU.internal_objects_dealloc_page_count) AS tempdb_page_deallocation_task + FROM + master.sys.dm_db_task_space_usage DDTSU + GROUP BY + DDTSU.session_id + ) sqTT ON sqTT.session_id = DXS.session_id + +WHERE + ( + ( + ( + @Database_Name IS NULL + OR ISNULL (ttDB.database_name, N'----------') = @Database_Name + ) + AND + ( + @Filter_Active = 0 + OR (CASE + WHEN @Filter_Sleeping = 0 AND sqSP.open_tran > 0 THEN N'' + ELSE DXS.[status] + END) NOT IN (N'dormant', N'sleeping') + ) + AND + ( + @Filter_Blocked = 0 + OR DER.blocking_session_id <> 0 + ) + AND + ( + @Filter_System = 0 + OR DXS.is_user_process = 1 + ) + AND + ( + @Login IS NULL + OR DXS.nt_user_name = @Login + OR DXS.login_name = @Login + ) + AND + ( + @SPID IS NULL + OR DXS.session_id = @SPID + ) + ) + OR + ( + NULLIF (DER.blocking_session_id, 0) IS NOT NULL + OR EXISTS + + ( + SELECT + * + FROM + master.sys.dm_exec_requests XDER + WHERE + XDER.blocking_session_id <> 0 + AND XDER.blocking_session_id = DXS.session_id + ) + + ) + ) + + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Update: Populate Transaction Details +----------------------------------------------------------------------------------------------------------------------------- + +IF @Exclude_TXN = 0 +BEGIN + + UPDATE + ttCD + SET + ttCD.transaction_id = DTST.transaction_id + ,ttCD.transaction_begin_time = DTAT.transaction_begin_time + ,ttCD.transaction_type = DTAT.transaction_type + ,ttCD.transaction_state = DTAT.transaction_state + FROM + dbo.#temp_core_data ttCD + INNER JOIN master.sys.dm_tran_session_transactions DTST ON DTST.session_id = ttCD.session_id + LEFT JOIN master.sys.dm_tran_active_transactions DTAT ON DTAT.transaction_id = DTST.transaction_id + +END + + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Insert: Transaction Log Details +----------------------------------------------------------------------------------------------------------------------------- + +IF @Exclude_Log = 0 AND @Exclude_TXN = 0 +BEGIN + + INSERT INTO dbo.#temp_log_details + + ( + transaction_id + ,database_id + ,database_transaction_begin_time + ,database_transaction_type + ,database_transaction_state + ,database_transaction_log_record_count + ,database_transaction_log_bytes_reserved + ,database_transaction_log_bytes_used + ,database_transaction_log_bytes_reserved_system + ,database_transaction_log_bytes_used_system + ) + + SELECT + DTDT.transaction_id + ,DTDT.database_id + ,DTDT.database_transaction_begin_time + ,DTDT.database_transaction_type + ,DTDT.database_transaction_state + ,DTDT.database_transaction_log_record_count + ,DTDT.database_transaction_log_bytes_reserved + ,DTDT.database_transaction_log_bytes_used + ,DTDT.database_transaction_log_bytes_reserved_system + ,DTDT.database_transaction_log_bytes_used_system + FROM + master.sys.dm_tran_database_transactions DTDT + WHERE + EXISTS + + ( + SELECT + * + FROM + dbo.#temp_core_data ttCD + WHERE + ttCD.transaction_id = DTDT.transaction_id + ) + +END + + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Insert: Lock Request Details +----------------------------------------------------------------------------------------------------------------------------- + +IF @Exclude_Lock = 0 +BEGIN + + INSERT INTO dbo.#temp_lock_details + + ( + req_spid + ,rsc_dbid + ,rsc_objid + ,rsc_indid + ,[object_name] + ,index_name + ,rsc_type + ,req_mode + ,req_status + ,req_ownertype + ,req_ecid + ,req_refcnt + ) + + SELECT + SLI.req_spid + ,SLI.rsc_dbid + ,SLI.rsc_objid + ,SLI.rsc_indid + ,CONVERT (NVARCHAR (275), NULL) AS [object_name] + ,CONVERT (NVARCHAR (128), NULL) AS index_name + ,SLI.rsc_type + ,SLI.req_mode + ,SLI.req_status + ,SLI.req_ownertype + ,SLI.req_ecid + ,SUM (SLI.req_refcnt) AS req_refcnt + FROM + master.sys.syslockinfo SLI + WHERE + EXISTS + + ( + SELECT + * + FROM + dbo.#temp_core_data ttCD + WHERE + ttCD.session_id = SLI.req_spid + ) + + GROUP BY + SLI.req_spid + ,SLI.rsc_dbid + ,SLI.rsc_objid + ,SLI.rsc_indid + ,SLI.rsc_type + ,SLI.req_mode + ,SLI.req_status + ,SLI.req_ownertype + ,SLI.req_ecid + +END + + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Update: Attempt To Populate SQL Text Data And Object Details +----------------------------------------------------------------------------------------------------------------------------- + +IF @Exclude_SQL = 0 +BEGIN + + SET @SQL_Handle = (SELECT TOP (1) ttCD.[sql_handle] FROM dbo.#temp_core_data ttCD WHERE ttCD.[sql_handle] IS NOT NULL ORDER BY ttCD.[sql_handle]) + + + WHILE @SQL_Handle IS NOT NULL + BEGIN + + SET LOCK_TIMEOUT 5 + + + BEGIN TRY + + UPDATE + ttCD + SET + ttCD.[dbid] = (CASE + WHEN ttCD.[dbid] IS NULL AND ttCD.objectid IS NULL THEN DEST.[dbid] + ELSE ttCD.[dbid] + END) + ,ttCD.objectid = (CASE + WHEN ttCD.[dbid] IS NULL AND ttCD.objectid IS NULL THEN DEST.objectid + ELSE ttCD.objectid + END) + ,ttCD.[text] = DEST.[text] + FROM + dbo.#temp_core_data ttCD + CROSS APPLY master.sys.dm_exec_sql_text (ttCD.[sql_handle]) DEST + WHERE + ttCD.[sql_handle] = @SQL_Handle + + END TRY + BEGIN CATCH + + END CATCH + + + SET LOCK_TIMEOUT -1 + + + SET @SQL_Handle = (SELECT TOP (1) ttCD.[sql_handle] FROM dbo.#temp_core_data ttCD WHERE ttCD.[sql_handle] IS NOT NULL AND ttCD.[sql_handle] > @SQL_Handle ORDER BY ttCD.[sql_handle]) + + END + +END + + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Update: Attempt To Populate Query Plan Data And Object Details +----------------------------------------------------------------------------------------------------------------------------- + +IF @Exclude_Plan = 0 +BEGIN + + SET @Plan_Handle = (SELECT TOP (1) ttCD.plan_handle FROM dbo.#temp_core_data ttCD WHERE ttCD.plan_handle IS NOT NULL ORDER BY ttCD.plan_handle) + + + WHILE @Plan_Handle IS NOT NULL + BEGIN + + SET LOCK_TIMEOUT 5 + + + BEGIN TRY + + UPDATE + ttCD + SET + ttCD.[dbid] = (CASE + WHEN ttCD.[dbid] IS NULL AND ttCD.objectid IS NULL THEN DEQP.[dbid] + ELSE ttCD.[dbid] + END) + ,ttCD.objectid = (CASE + WHEN ttCD.[dbid] IS NULL AND ttCD.objectid IS NULL THEN DEQP.objectid + ELSE ttCD.objectid + END) + ,ttCD.query_plan = DEQP.query_plan + FROM + dbo.#temp_core_data ttCD + CROSS APPLY master.sys.dm_exec_query_plan (ttCD.plan_handle) DEQP + WHERE + ttCD.plan_handle = @Plan_Handle + + END TRY + BEGIN CATCH + + END CATCH + + + SET LOCK_TIMEOUT -1 + + + SET @Plan_Handle = (SELECT TOP (1) ttCD.plan_handle FROM dbo.#temp_core_data ttCD WHERE ttCD.plan_handle IS NOT NULL AND ttCD.plan_handle > @Plan_Handle ORDER BY ttCD.plan_handle) + + END + +END + + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Update: Attempt To Populate Object Name +----------------------------------------------------------------------------------------------------------------------------- + +IF (@Exclude_Plan = 0 OR @Exclude_SQL = 0) +BEGIN + + SET @Database_ID = (SELECT TOP (1) ttCD.[dbid] FROM dbo.#temp_core_data ttCD WHERE ttCD.[dbid] IS NOT NULL AND ttCD.objectid IS NOT NULL ORDER BY ttCD.[dbid]) + + + WHILE @Database_ID IS NOT NULL + BEGIN + + SET @SQL_String = + + N' + USE [' + (SELECT ttDB.database_name FROM dbo.#temp_databases ttDB WHERE ttDB.database_id = @Database_ID) + N'] + + + UPDATE + ttCD + SET + ttCD.[object_name] = N''['' + S.name + N''].['' + AO.name + N'']'' + FROM + dbo.#temp_core_data ttCD + INNER JOIN sys.all_objects AO ON AO.[object_id] = ttCD.objectid + INNER JOIN sys.schemas S ON S.[schema_id] = AO.[schema_id] + WHERE + ttCD.[dbid] = ' + CONVERT (NVARCHAR (11), @Database_ID) + N' + ' + + + IF @SQL_String IS NOT NULL + BEGIN + + SET LOCK_TIMEOUT 5 + + + BEGIN TRY + + EXECUTE (@SQL_String) + + END TRY + BEGIN CATCH + + END CATCH + + + SET LOCK_TIMEOUT -1 + + END + + + SET @Database_ID = (SELECT TOP (1) ttCD.[dbid] FROM dbo.#temp_core_data ttCD WHERE ttCD.[dbid] IS NOT NULL AND ttCD.objectid IS NOT NULL AND ttCD.[dbid] > @Database_ID ORDER BY ttCD.[dbid]) + + END + +END + + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Update: Attempt To Populate Lock Details' Database Name / Object Name / Index Name +----------------------------------------------------------------------------------------------------------------------------- + +IF @Exclude_Lock = 0 +BEGIN + + SET @Database_ID = (SELECT TOP (1) ttLKD.rsc_dbid FROM dbo.#temp_lock_details ttLKD ORDER BY ttLKD.rsc_dbid) + + + WHILE @Database_ID IS NOT NULL + BEGIN + + SET @SQL_String = + + N' + USE [' + (SELECT ttDB.database_name FROM dbo.#temp_databases ttDB WHERE ttDB.database_id = @Database_ID) + N'] + + + UPDATE + ttLKD + SET + ttLKD.[object_name] = N''['' + S.name + N''].['' + AO.name + N'']'' + ,ttLKD.index_name = I.name + FROM + dbo.#temp_lock_details ttLKD + LEFT JOIN sys.all_objects AO ON AO.[object_id] = ttLKD.rsc_objid + LEFT JOIN sys.schemas S ON S.[schema_id] = AO.[schema_id] + LEFT JOIN sys.indexes I ON I.[object_id] = ttLKD.rsc_objid + AND I.index_id = ttLKD.rsc_indid + WHERE + ttLKD.rsc_dbid = ' + CONVERT (NVARCHAR (11), @Database_ID) + N' + ' + + + IF @SQL_String IS NOT NULL + BEGIN + + SET LOCK_TIMEOUT 5 + + + BEGIN TRY + + EXECUTE (@SQL_String) + + END TRY + BEGIN CATCH + + END CATCH + + + SET LOCK_TIMEOUT -1 + + END + + + SET @Database_ID = (SELECT TOP (1) ttLKD.rsc_dbid FROM dbo.#temp_lock_details ttLKD WHERE ttLKD.rsc_dbid > @Database_ID ORDER BY ttLKD.rsc_dbid) + + END + +END + + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Insert: Identify False Positive Blocking Cause By Timing Issues +----------------------------------------------------------------------------------------------------------------------------- + +SELECT + ttCD.session_id + ,(CASE + WHEN caCB.matches_filter_criteria = 0 AND caCB.is_truly_blocked = 0 AND caCB.is_truly_blocking = 0 THEN N'D' + ELSE N'U' + END) AS modification_type +INTO + dbo.#temp_false_positive_blocking +FROM + dbo.#temp_core_data ttCD + LEFT JOIN dbo.#temp_core_data ttXCD ON ttXCD.session_id = ttCD.blocking_session_id + LEFT JOIN + + ( + SELECT DISTINCT + ttCD.blocking_session_id + FROM + dbo.#temp_core_data ttCD + ) sqBS ON sqBS.blocking_session_id = ttCD.session_id + + CROSS APPLY + + ( + SELECT + (CASE + WHEN @Filter_Blocked = 1 THEN 0 + WHEN ISNULL (ttCD.database_name, N'----------') <> @Database_Name THEN 0 + WHEN @Filter_Active = 1 AND (CASE + WHEN @Filter_Sleeping = 0 AND ttCD.open_tran > 0 THEN N'' + ELSE ttCD.status_session + END) IN (N'dormant', N'sleeping') THEN 0 + WHEN @Filter_System = 1 AND ttCD.is_user_process <> 1 THEN 0 + WHEN ISNULL (ttCD.nt_user_name, N'') <> @Login AND ttCD.login_name <> @Login THEN 0 + WHEN ttCD.session_id <> @SPID THEN 0 + ELSE 1 + END) AS matches_filter_criteria + ,(CASE + WHEN ttXCD.session_id IS NOT NULL THEN 1 + ELSE 0 + END) AS is_truly_blocked + ,(CASE + WHEN sqBS.blocking_session_id IS NOT NULL THEN 1 + ELSE 0 + END) AS is_truly_blocking + ) caCB + +WHERE + ( + ( + caCB.matches_filter_criteria = 0 + AND caCB.is_truly_blocked = 0 + AND caCB.is_truly_blocking = 0 + ) + OR + ( + ( + caCB.matches_filter_criteria = 1 + OR caCB.is_truly_blocking = 1 + ) + AND caCB.is_truly_blocked = 0 + AND NULLIF (ttCD.blocking_session_id, 0) IS NOT NULL + ) + ) + + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Delete: Remove False Positives Which Meet Neither Filter Criteria Nor Block Chain Dependencies +----------------------------------------------------------------------------------------------------------------------------- + +DELETE + ttCD +FROM + dbo.#temp_core_data ttCD +WHERE + EXISTS + + ( + SELECT + * + FROM + dbo.#temp_false_positive_blocking ttFPB + WHERE + ttFPB.modification_type = N'D' + AND ttFPB.session_id = ttCD.session_id + ) + + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Update: Update False Positives Which Meet Either Filter Criteria And / Or Block Chain Dependencies +----------------------------------------------------------------------------------------------------------------------------- + +UPDATE + ttCD +SET + ttCD.blocking_session_id = NULL +FROM + dbo.#temp_core_data ttCD +WHERE + EXISTS + + ( + SELECT + * + FROM + dbo.#temp_false_positive_blocking ttFPB + WHERE + ttFPB.modification_type = N'U' + AND ttFPB.session_id = ttCD.session_id + ) + + +IF OBJECT_ID (N'tempdb.dbo.#temp_false_positive_blocking', N'U') IS NOT NULL +BEGIN + + DROP TABLE dbo.#temp_false_positive_blocking + +END + + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Insert: Identify Blocking SPIDs Which Are Deadlocking +----------------------------------------------------------------------------------------------------------------------------- + +SELECT + sqBL.session_id + ,sqBL.blocking_session_id +INTO + dbo.#temp_deadlocking +FROM + + ( + SELECT + ttCD.session_id + ,ttCD.blocking_session_id + FROM + dbo.#temp_core_data ttCD + WHERE + ttCD.blocking_session_id <> 0 + AND ttCD.session_id <> ttCD.blocking_session_id + + UNION ALL + + SELECT + ttCD.blocking_session_id AS session_id + ,ttCD.session_id AS blocking_session_id + FROM + dbo.#temp_core_data ttCD + WHERE + ttCD.blocking_session_id <> 0 + AND ttCD.session_id <> ttCD.blocking_session_id + ) sqBL + +GROUP BY + sqBL.session_id + ,sqBL.blocking_session_id +HAVING + COUNT (*) > 1 + + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Insert: Identify Queries Running In Parallel With Threads Waiting For Others To Complete +----------------------------------------------------------------------------------------------------------------------------- + +SELECT + ttCD.session_id +INTO + dbo.#temp_parallelism +FROM + dbo.#temp_core_data ttCD +WHERE + ttCD.blocking_session_id <> 0 + AND ttCD.session_id = ttCD.blocking_session_id + + +----------------------------------------------------------------------------------------------------------------------------- +-- Table Update: Remove Specific Blocking Session IDs From The Main Blocking Group +----------------------------------------------------------------------------------------------------------------------------- + +UPDATE + ttCD +SET + ttCD.blocking_session_id = NULL +FROM + dbo.#temp_core_data ttCD +WHERE + ( + ttCD.blocking_session_id = 0 + OR EXISTS + + ( + SELECT + * + FROM + dbo.#temp_deadlocking ttD + WHERE + ttD.session_id = ttCD.session_id + ) + + OR EXISTS + + ( + SELECT + * + FROM + dbo.#temp_parallelism ttP + WHERE + ttP.session_id = ttCD.session_id + ) + ) + + +----------------------------------------------------------------------------------------------------------------------------- +-- Main Query: Final Display / Output +----------------------------------------------------------------------------------------------------------------------------- + +SELECT + caFL.spid AS SPID + ,ISNULL (ttCD.database_name, N'----------') AS Database_Name + ,REPLICATE (N' ', 5) + (CASE + WHEN caFL.status_session = N'BACKGROUND' THEN N'---' + WHEN caFL.status_session IN (N'dormant', N'sleeping') AND ttCD.open_tran = 0 THEN N'' + WHEN caFL.status_session IN (N'dormant', N'sleeping') AND ttCD.open_tran > 0 THEN N'•' + WHEN caFL.status_session IN (N'PENDING', N'PRECONNECT', N'RUNNABLE', N'SPINLOOP', N'SUSPENDED') THEN N'[]' + WHEN caFL.status_session IN (N'ROLLBACK', N'RUNNING') THEN N'X' + ELSE N'N/A' + END) AS Running + ,(CASE + WHEN ttD.session_id IS NULL AND caFL.blocking IS NULL AND ttCD.blocking_session_id IS NULL AND ttP.session_id IS NULL THEN N'' + ELSE ISNULL (caCP.deadlocking_spid + caCP.separator_01, N'') + ISNULL (caCP.blocking_spids + caCP.separator_02, N'') + ISNULL (caCP.blocked_by_spid + caCP.separator_03, N'') + ISNULL (caCP.parallelism_spid, N'') + END) AS Blocking + ,caFL.status_session + N' -> ' + ISNULL (caFL.status_request, N'N/A') AS [Status] + ,ISNULL (ISNULL (ttCD.[object_name], N'Database ID: ' + CONVERT (NVARCHAR (11), ttCD.[dbid]) + N', Object ID: ' + CONVERT (NVARCHAR (11), ttCD.objectid)), N'') AS [Object_Name] + ,ISNULL (ttCD.command, N'awaiting command') AS Command + ,ISNULL (CONVERT (NVARCHAR (11), ttCD.threads), N'') AS Threads + ,ISNULL (ttCD.[text], N'') AS SQL_Statement_Batch + ,caCP.sql_statement_current AS SQL_Statement_Current + ,(CASE ttCD.transaction_isolation_level + WHEN 0 THEN N'UNSPECIFIED' + WHEN 1 THEN N'READ UNCOMMITTED' + WHEN 2 THEN N'READ COMMITTED' + WHEN 3 THEN N'REPEATABLE READ' + WHEN 4 THEN N'SERIALIZABLE' + WHEN 5 THEN N'SNAPSHOT' + ELSE N'N/A' + END) AS Isolation_Level + ,ISNULL (CONVERT (NVARCHAR (15), (NULLIF (caFL.wait_time, 0) / 1000) / 86400) + N' Day(s) ' + CONVERT (NVARCHAR (8), DATEADD (SECOND, NULLIF (caFL.wait_time, 0) / 1000, 0), 108), N'') AS Wait_Time + ,ISNULL (ttCD.wait_type, N'') AS Wait_Type + ,ISNULL (ttCD.last_wait_type, N'') AS Last_Wait_Type + ,ISNULL (CONVERT (NVARCHAR (15), (NULLIF (caFL.total_elapsed_time, 0) / 1000) / 86400) + N' Day(s) ' + CONVERT (NVARCHAR (8), DATEADD (SECOND, NULLIF (caFL.total_elapsed_time, 0) / 1000, 0), 108), N'') AS Elapsed_Time + ,ISNULL (CONVERT (NVARCHAR (15), (NULLIF (ttCD.cpu_time_total, 0) / 1000) / 86400) + N' Day(s) ' + CONVERT (NVARCHAR (8), DATEADD (SECOND, NULLIF (ttCD.cpu_time_total, 0) / 1000, 0), 108), N'') AS CPU_Total + ,ISNULL (CONVERT (NVARCHAR (15), (NULLIF (ttCD.cpu_time_current, 0) / 1000) / 86400) + N' Day(s) ' + CONVERT (NVARCHAR (8), DATEADD (SECOND, NULLIF (ttCD.cpu_time_current, 0) / 1000, 0), 108), N'') AS CPU_Current + ,ISNULL (REVERSE (SUBSTRING (REVERSE (CONVERT (NVARCHAR (23), CONVERT (MONEY, NULLIF (ttCD.logical_reads_total, 0)), 1)), 4, 23)), N'') AS Logical_Reads_Total + ,ISNULL (REVERSE (SUBSTRING (REVERSE (CONVERT (NVARCHAR (23), CONVERT (MONEY, NULLIF (ttCD.logical_reads_current, 0)), 1)), 4, 23)), N'') AS Logical_Reads_Current + ,ISNULL (REVERSE (SUBSTRING (REVERSE (CONVERT (NVARCHAR (23), CONVERT (MONEY, NULLIF (ttCD.reads_total, 0)), 1)), 4, 23)), N'') AS Physical_Reads_Total + ,ISNULL (REVERSE (SUBSTRING (REVERSE (CONVERT (NVARCHAR (23), CONVERT (MONEY, NULLIF (ttCD.reads_current, 0)), 1)), 4, 23)), N'') AS Physical_Reads_Current + ,ISNULL (REVERSE (SUBSTRING (REVERSE (CONVERT (NVARCHAR (23), CONVERT (MONEY, NULLIF (ttCD.writes_total, 0)), 1)), 4, 23)), N'') AS Writes_Total + ,ISNULL (REVERSE (SUBSTRING (REVERSE (CONVERT (NVARCHAR (23), CONVERT (MONEY, NULLIF (ttCD.writes_current, 0)), 1)), 4, 23)), N'') AS Writes_Current + ,ISNULL (REVERSE (SUBSTRING (REVERSE (CONVERT (NVARCHAR (23), CONVERT (MONEY, NULLIF (ttCD.row_count, 0)), 1)), 4, 23)), N'') AS Last_Row_Count + ,ISNULL (CONVERT (NVARCHAR (23), CONVERT (MONEY, (NULLIF (ttCD.granted_query_memory, 0) * 8) / 1024.0), 1), N'') AS Allocated_Memory_MB + ,ISNULL (CONVERT (NVARCHAR (11), NULLIF (ttCD.memory_usage, 0)), N'') AS Pages_Used + ,ISNULL (CONVERT (NVARCHAR (6), NULLIF (ttCD.open_tran, 0)), N'') AS Transactions + ,ISNULL (CONVERT (NVARCHAR (20), NULLIF (ttCD.transaction_id, 0)), N'') AS Transaction_ID + ,ISNULL ((CASE + WHEN ttCD.transaction_begin_time > @Date_Now THEN N'0 Day(s) 00:00:00' + ELSE CONVERT (NVARCHAR (15), DATEDIFF (SECOND, ttCD.transaction_begin_time, @Date_Now) / 86400) + N' Day(s) ' + CONVERT (NVARCHAR (8), DATEADD (SECOND, DATEDIFF (SECOND, ttCD.transaction_begin_time, @Date_Now), 0), 108) + END), N'') AS Transaction_Time + ,(CASE + WHEN ttCD.transaction_type IS NULL THEN N'' + WHEN ttCD.transaction_type = 1 THEN N'Read / Write' + WHEN ttCD.transaction_type = 2 THEN N'Read-Only' + WHEN ttCD.transaction_type = 3 THEN N'System' + WHEN ttCD.transaction_type = 4 THEN N'Distributed' + ELSE N'N/A' + END) AS Transaction_Type + ,(CASE + WHEN ttCD.transaction_state IS NULL THEN N'' + WHEN ttCD.transaction_state = 0 THEN N'Initializing' + WHEN ttCD.transaction_state = 1 THEN N'Initialized / Not Started' + WHEN ttCD.transaction_state = 2 THEN N'Active' + WHEN ttCD.transaction_state = 3 THEN N'Ended (Read-Only Transaction)' + WHEN ttCD.transaction_state = 4 THEN N'Commit Initiated (Distributed Transaction)' + WHEN ttCD.transaction_state = 5 THEN N'Prepared / Waiting Resolution' + WHEN ttCD.transaction_state = 6 THEN N'Committed' + WHEN ttCD.transaction_state = 7 THEN N'Rolling Back' + WHEN ttCD.transaction_state = 8 THEN N'Rolled Back' + ELSE N'N/A' + END) AS Transaction_State + ,ISNULL (CONVERT (NVARCHAR (11), NULLIF (ttCD.nest_level, 0)), N'') AS Nesting_Level + ,ISNULL (CONVERT (NVARCHAR (23), CONVERT (MONEY, (NULLIF (ttCD.tempdb_page_allocation_session, 0) * 8) / 1024.0), 1), N'') AS TempDB_Session_Total_MB + ,ISNULL (CONVERT (NVARCHAR (23), CONVERT (MONEY, ((NULLIF (ttCD.tempdb_page_allocation_session, 0) - ttCD.tempdb_page_deallocation_session) * 8) / 1024.0), 1), N'') AS TempDB_Session_Current_MB + ,ISNULL (CONVERT (NVARCHAR (23), CONVERT (MONEY, (NULLIF (ttCD.tempdb_page_allocation_task, 0) * 8) / 1024.0), 1), N'') AS TempDB_Task_Total_MB + ,ISNULL (CONVERT (NVARCHAR (23), CONVERT (MONEY, ((NULLIF (ttCD.tempdb_page_allocation_task, 0) - ttCD.tempdb_page_deallocation_task) * 8) / 1024.0), 1), N'') AS TempDB_Task_Current_MB + ,ISNULL (REVERSE (SUBSTRING (REVERSE (CONVERT (NVARCHAR (23), CONVERT (MONEY, NULLIF (sqLS.log_database_count, 0)), 1)), 4, 23)), N'') AS Log_Database_Count + ,ISNULL (REVERSE (SUBSTRING (REVERSE (CONVERT (NVARCHAR (23), CONVERT (MONEY, NULLIF (sqLS.log_record_count_all, 0)), 1)), 4, 23)), N'') AS Log_Records_All + ,ISNULL (CONVERT (NVARCHAR (23), CONVERT (MONEY, NULLIF (sqLS.log_bytes_reserved_all, 0) / 1048576.0), 1), N'') AS Log_Reserved_MB_All + ,ISNULL (CONVERT (NVARCHAR (23), CONVERT (MONEY, NULLIF (sqLS.log_bytes_used_all, 0) / 1048576.0), 1), N'') AS Log_Used_MB_All + ,ISNULL (( + SELECT + ISNULL ((CASE + WHEN ttLGD.database_id = 32767 THEN N'mssqlsystemresource (Hidden Resource Database)' + ELSE ttDB.database_name + END), N'N/A') + + ISNULL (@CR_LF_Tab + + LEFT (N'Transaction Time' + REPLICATE (N' ', 25), 25) + N': ' + + (CASE + WHEN ttLGD.database_transaction_begin_time > @Date_Now THEN N'0 Day(s) 00:00:00' + ELSE CONVERT (NVARCHAR (15), DATEDIFF (SECOND, ttLGD.database_transaction_begin_time, @Date_Now) / 86400) + N' Day(s) ' + CONVERT (NVARCHAR (8), DATEADD (SECOND, DATEDIFF (SECOND, ttLGD.database_transaction_begin_time, @Date_Now), 0), 108) + END), N'') + + @CR_LF_Tab + + LEFT (N'Transaction Type' + REPLICATE (N' ', 25), 25) + N': ' + + (CASE ttLGD.database_transaction_type + WHEN 1 THEN N'Read / Write' + WHEN 2 THEN N'Read-Only' + WHEN 3 THEN N'System' + ELSE N'N/A' + END) + + @CR_LF_Tab + + LEFT (N'Transaction State' + REPLICATE (N' ', 25), 25) + N': ' + + (CASE ttLGD.database_transaction_state + WHEN 1 THEN N'Not Initialized' + WHEN 3 THEN N'No Log Records Generated' + WHEN 4 THEN N'Log Records Generated' + WHEN 5 THEN N'Prepared' + WHEN 10 THEN N'Committed' + WHEN 11 THEN N'Rolled Back' + WHEN 12 THEN N'Committing / Log Records Generating' + ELSE N'N/A' + END) + + ISNULL (@CR_LF_Tab + + LEFT (N'Log Records Generated' + REPLICATE (N' ', 25), 25) + N': ' + + REVERSE (SUBSTRING (REVERSE (CONVERT (NVARCHAR (23), CONVERT (MONEY, NULLIF (ttLGD.database_transaction_log_record_count, 0)), 1)), 4, 23)), N'') + + ISNULL (@CR_LF_Tab + + LEFT (N'Log MB Reserved' + REPLICATE (N' ', 25), 25) + N': ' + + CONVERT (NVARCHAR (23), CONVERT (MONEY, NULLIF (ttLGD.database_transaction_log_bytes_reserved, 0) / 1048576.0), 1), N'') + + ISNULL (@CR_LF_Tab + + LEFT (N'Log MB Used' + REPLICATE (N' ', 25), 25) + N': ' + + CONVERT (NVARCHAR (23), CONVERT (MONEY, NULLIF (ttLGD.database_transaction_log_bytes_used, 0) / 1048576.0), 1), N'') + + ISNULL (@CR_LF_Tab + + LEFT (N'Log MB Reserved (System)' + REPLICATE (N' ', 25), 25) + N': ' + + CONVERT (NVARCHAR (23), CONVERT (MONEY, NULLIF (ttLGD.database_transaction_log_bytes_reserved_system, 0) / 1048576.0), 1), N'') + + ISNULL (@CR_LF_Tab + + LEFT (N'Log MB Used (System)' + REPLICATE (N' ', 25), 25) + N': ' + + CONVERT (NVARCHAR (23), CONVERT (MONEY, NULLIF (ttLGD.database_transaction_log_bytes_used_system, 0) / 1048576.0), 1), N'') + + @CR_LF + + @CR_LF AS [text()] + FROM + dbo.#temp_log_details ttLGD + LEFT JOIN dbo.#temp_databases ttDB ON ttDB.database_id = ttLGD.database_id + WHERE + ttLGD.transaction_id = ttCD.transaction_id + ORDER BY + (CASE + WHEN ttLGD.database_id = 32767 THEN N'mssqlsystemresource (Hidden Resource Database)' + ELSE ttDB.database_name + END) + FOR + XML PATH (N'') + ,TYPE + ), N'') AS Log_Details + ,(CASE + WHEN ttCD.[lock_timeout] = -1 THEN N'Wait Forever' + WHEN ttCD.[lock_timeout] = 0 THEN N'Immediately' + ELSE CONVERT (NVARCHAR (11), CONVERT (DECIMAL (18, 2), ROUND (ttCD.[lock_timeout] / 1000.0, 2))) + END) AS Lock_Timeout_Seconds + ,ISNULL (( + SELECT + ISNULL (N'Database ' + ISNULL (N'Name: ' + ttDB.database_name, N'ID: ' + CONVERT (NVARCHAR (11), ttLKD.rsc_dbid)), N'') + + ISNULL (N' ••• Object ' + ISNULL (N'Name: ' + ttLKD.[object_name], N'ID: ' + CONVERT (NVARCHAR (11), NULLIF (ttLKD.rsc_objid, 0))), N'') + + ISNULL (N' ••• Index ' + ISNULL (N'Name: ' + ttLKD.index_name, N'ID: ' + CONVERT (NVARCHAR (11), NULLIF (ttLKD.rsc_indid, 0))), N'') + + @CR_LF_Tab + + N'Resource Type: ' + + (CASE ttLKD.rsc_type + WHEN 1 THEN N'NULL Resource' + WHEN 2 THEN N'Database' + WHEN 3 THEN N'File' + WHEN 4 THEN N'Index' + WHEN 5 THEN N'Object' + WHEN 6 THEN N'Page' + WHEN 7 THEN N'Key' + WHEN 8 THEN N'Extent' + WHEN 9 THEN N'Row ID (RID)' + WHEN 10 THEN N'Application' + WHEN 11 THEN N'Metadata' + WHEN 12 THEN N'Heap Or B-Tree (HoBt)' + WHEN 13 THEN N'Allocation Unit' + ELSE N'N/A' + END) + + @CR_LF_Tab + + N'Request Mode: ' + + (CASE ttLKD.req_mode + WHEN 0 THEN N'NULL Resource' + WHEN 1 THEN N'Sch-S (Schema Stability)' + WHEN 2 THEN N'Sch-M (Schema Modification)' + WHEN 3 THEN N'S (Shared)' + WHEN 4 THEN N'U (Update)' + WHEN 5 THEN N'X (Exclusive)' + WHEN 6 THEN N'IS (Intent Shared)' + WHEN 7 THEN N'IU (Intent Update)' + WHEN 8 THEN N'IX (Intent Exclusive)' + WHEN 9 THEN N'SIU (Shared Intent Update)' + WHEN 10 THEN N'SIX (Shared Intent Exclusive)' + WHEN 11 THEN N'UIX (Update Intent Exclusive)' + WHEN 12 THEN N'BU (Bulk Update)' + WHEN 13 THEN N'RangeS-S (Serializable Range Scan)' + WHEN 14 THEN N'RangeS-U (Serializable Update Scan)' + WHEN 15 THEN N'RangeI-N (Insert Key-Range / NULL Resource Lock)' + WHEN 16 THEN N'RangeI-S (Overlap Of RangeI-N / S Locks)' + WHEN 17 THEN N'RangeI-U (Overlap Of RangeI-N / U Locks)' + WHEN 18 THEN N'RangeI-X (Overlap Of RangeI-N / X Locks)' + WHEN 19 THEN N'RangeX-S (Overlap Of RangeI-N / RangeS-S Locks)' + WHEN 20 THEN N'RangeX-U (Overlap Of RangeI-N / RangeS-U Locks)' + WHEN 21 THEN N'RangeX-X (Exclusive Key-Range / Exclusive Resource Lock)' + ELSE N'N/A' + END) + + @CR_LF_Tab + + N'Request Status: ' + + (CASE ttLKD.req_status + WHEN 1 THEN N'Granted' + WHEN 2 THEN N'Convert' + WHEN 3 THEN N'Wait' + WHEN 4 THEN N'RELN' + WHEN 5 THEN N'BLCKN' + ELSE N'N/A' + END) + + @CR_LF_Tab + + N'Request Owner Type: ' + + (CASE ttLKD.req_ownertype + WHEN 1 THEN N'Transaction' + WHEN 2 THEN N'Cursor' + WHEN 3 THEN N'User Session' + WHEN 4 THEN N'Shared Transaction Workspace' + WHEN 5 THEN N'Exclusive Transaction Workspace' + WHEN 6 THEN N'WFR' + ELSE N'N/A' + END) + + @CR_LF_Tab + + N'ECID: ' + CONVERT (NVARCHAR (11), ttLKD.req_ecid) + + @CR_LF_Tab + + N'Request Reference Count: ' + CONVERT (NVARCHAR (6), ttLKD.req_refcnt) + + @CR_LF + + @CR_LF AS [text()] + FROM + dbo.#temp_lock_details ttLKD + LEFT JOIN dbo.#temp_databases ttDB ON ttDB.database_id = ttLKD.rsc_dbid + WHERE + ttLKD.req_spid = ttCD.session_id + ORDER BY + ttDB.database_name + ,ttLKD.[object_name] + ,ttLKD.index_name + ,ttLKD.rsc_type + ,ttLKD.req_mode + ,ttLKD.req_status + ,ttLKD.req_ownertype + ,ttLKD.req_ecid + ,ttLKD.req_refcnt + FOR + XML PATH (N'') + ,TYPE + ), N'') AS Lock_Details + ,(CASE + WHEN ttCD.[deadlock_priority] <= -5 THEN N'Low' + WHEN ttCD.[deadlock_priority] >= 5 THEN N'High' + ELSE N'Normal' + END) + N': ' + CONVERT (NVARCHAR (3), ttCD.[deadlock_priority]) AS [Deadlock_Priority] + ,CONVERT (XML, ISNULL ((CASE + WHEN (@Exclude_SQL = 1 OR @Exclude_SQL_XML = 1) THEN N'' + ELSE REPLACE (REPLACE (REPLACE (REPLACE (REPLACE (REPLACE (ttCD.[text] COLLATE Latin1_General_BIN, NCHAR (0) COLLATE Latin1_General_BIN, N''), N'&', @Ampersand + N'amp;'), N'<', @Ampersand + N'lt;'), N'>', @Ampersand + N'gt;'), N'"', @Ampersand + N'quot;'), N'''', @Ampersand + N'#39;') + END), N'')) AS SQL_Statement_Batch_XML + ,CONVERT (XML, (CASE + WHEN (@Exclude_SQL = 1 OR @Exclude_SQL_XML = 1) THEN N'' + ELSE REPLACE (REPLACE (REPLACE (REPLACE (REPLACE (REPLACE (ISNULL (NULLIF (NULLIF (caCP.sql_statement_current, N'<< Derived Statement >>'), N'<< Single Statement >>'), ttCD.[text]) COLLATE Latin1_General_BIN, NCHAR (0) COLLATE Latin1_General_BIN, N''), N'&', @Ampersand + N'amp;'), N'<', @Ampersand + N'lt;'), N'>', @Ampersand + N'gt;'), N'"', @Ampersand + N'quot;'), N'''', @Ampersand + N'#39;') + END)) AS SQL_Statement_Current_XML + ,ISNULL (CONVERT (NVARCHAR (130), ttCD.[sql_handle], 1), N'') AS [SQL_Handle] + ,ISNULL (ttCD.query_plan, N'') AS Query_Plan + ,ISNULL (CONVERT (NVARCHAR (130), ttCD.plan_handle, 1), N'') AS Plan_Handle + ,ISNULL ((CASE + WHEN caFL.login_time > @Date_Now THEN N'0 Day(s) 00:00:00' + ELSE CONVERT (NVARCHAR (15), DATEDIFF (SECOND, caFL.login_time, @Date_Now) / 86400) + N' Day(s) ' + CONVERT (NVARCHAR (8), DATEADD (SECOND, DATEDIFF (SECOND, caFL.login_time, @Date_Now), 0), 108) + END), N'') AS Since_SPID_Login + ,ISNULL ((CASE + WHEN caFL.last_request_start_time > @Date_Now THEN N'0 Day(s) 00:00:00' + ELSE CONVERT (NVARCHAR (15), DATEDIFF (SECOND, caFL.last_request_start_time, @Date_Now) / 86400) + N' Day(s) ' + CONVERT (NVARCHAR (8), DATEADD (SECOND, DATEDIFF (SECOND, caFL.last_request_start_time, @Date_Now), 0), 108) + END), N'') AS Since_Last_Batch_Start + ,ISNULL ((CASE + WHEN caFL.last_request_end_time > @Date_Now THEN N'0 Day(s) 00:00:00' + ELSE CONVERT (NVARCHAR (15), DATEDIFF (SECOND, caFL.last_request_end_time, @Date_Now) / 86400) + N' Day(s) ' + CONVERT (NVARCHAR (8), DATEADD (SECOND, DATEDIFF (SECOND, caFL.last_request_end_time, @Date_Now), 0), 108) + END), N'') AS Since_Last_Batch_End + ,ISNULL (CONVERT (NVARCHAR (7), CONVERT (DECIMAL (5, 2), NULLIF (ttCD.percent_complete, 0))), N'') AS Command_Pct + ,ISNULL ((CASE + WHEN ttCD.percent_complete = 0 THEN N'' + ELSE CONVERT (NVARCHAR (19), DATEADD (MILLISECOND, ttCD.estimated_completion_time, @Date_Now), 120) + END), N'') AS Command_Completion + ,ISNULL (CONVERT (NVARCHAR (15), (NULLIF (ttCD.estimated_completion_time, 0) / 1000) / 86400) + N' Day(s) ' + CONVERT (NVARCHAR (8), DATEADD (SECOND, NULLIF (ttCD.estimated_completion_time, 0) / 1000, 0), 108), N'') AS Command_Time_Left + ,ISNULL (ttCD.[host_name], N'') AS [Host_Name] + ,caFL.login_id AS Login_ID + ,(CASE + WHEN ttCD.login_name = N'sa' THEN N'<< System Administrator >>' + ELSE ttCD.login_name + END) AS Login_Name + ,ISNULL (REPLACE (REPLACE (ttCD.[program_name], N'Microsoft® Windows® Operating System', N'Windows OS'), N'Microsoft', N'MS'), N'') AS Application_Description + ,(CASE ttCD.is_user_process + WHEN 1 THEN N'' + ELSE N'Yes' + END) AS System_Process + ,caFL.spid AS SPID +FROM + dbo.#temp_core_data ttCD + LEFT JOIN dbo.#temp_deadlocking ttD ON ttD.session_id = ttCD.session_id + LEFT JOIN dbo.#temp_parallelism ttP ON ttP.session_id = ttCD.session_id + LEFT JOIN + + ( + SELECT + ttLGD.transaction_id + ,COUNT (*) AS log_database_count + ,SUM (ttLGD.database_transaction_log_record_count) AS log_record_count_all + ,SUM (ttLGD.database_transaction_log_bytes_reserved + ttLGD.database_transaction_log_bytes_reserved_system) AS log_bytes_reserved_all + ,SUM (ttLGD.database_transaction_log_bytes_used + ttLGD.database_transaction_log_bytes_used_system) AS log_bytes_used_all + FROM + dbo.#temp_log_details ttLGD + GROUP BY + ttLGD.transaction_id + ) sqLS ON sqLS.transaction_id = ttCD.transaction_id + + CROSS APPLY + + ( + SELECT + CONVERT (NVARCHAR (6), ttCD.session_id) + ISNULL (N' ' + (CASE + WHEN ttCD.session_id = @@SPID THEN N'••' + WHEN ttCD.is_user_process = 0 THEN N'•' + END), N'') AS spid + ,STUFF (( + SELECT + N', ' + CONVERT (NVARCHAR (MAX), ttXCD.session_id) AS [text()] + FROM + dbo.#temp_core_data ttXCD + WHERE + ttXCD.blocking_session_id = ttCD.session_id + ORDER BY + ttXCD.session_id + FOR + XML PATH (N'') + ), 1, 2, N'') AS blocking + ,(CASE + WHEN ttCD.status_session NOT IN (N'dormant', N'sleeping') THEN UPPER (ttCD.status_session) + ELSE ttCD.status_session + END) AS status_session + ,(CASE + WHEN ttCD.status_request <> N'sleeping' THEN UPPER (ttCD.status_request) + ELSE ttCD.status_request + END) AS status_request + ,CONVERT (BIGINT, (CASE + WHEN ttCD.wait_time < 0 THEN 2147483647 + (2147483649 + ttCD.wait_time) + ELSE ttCD.wait_time + END)) AS wait_time + ,CONVERT (BIGINT, (CASE + WHEN ttCD.total_elapsed_time < 0 THEN 2147483647 + (2147483649 + ttCD.total_elapsed_time) + ELSE ttCD.total_elapsed_time + END)) AS total_elapsed_time + ,(CASE + WHEN ttCD.login_time_sessions = N'1900-01-01 00:00:00.000' THEN ttCD.login_time_processes + ELSE ttCD.login_time_sessions + END) AS login_time + ,(CASE + WHEN ttCD.last_request_start_time = N'1900-01-01 00:00:00.000' THEN NULL + ELSE ttCD.last_request_start_time + END) AS last_request_start_time + ,(CASE + WHEN ttCD.last_request_end_time = N'1900-01-01 00:00:00.000' THEN ttCD.last_batch + ELSE ttCD.last_request_end_time + END) AS last_request_end_time + ,ISNULL (NULLIF (ttCD.nt_user_name, N''), ttCD.login_name) AS login_id + ) caFL + + CROSS APPLY + + ( + SELECT + N'[ Deadlocking ] : ' + CONVERT (NVARCHAR (6), ttD.blocking_session_id) AS deadlocking_spid + ,(CASE + WHEN (caFL.blocking IS NOT NULL OR ttCD.blocking_session_id IS NOT NULL OR ttP.session_id IS NOT NULL) THEN N' •• ' + ELSE N'' + END) AS separator_01 + ,N'< Blocking > : ' + caFL.blocking AS blocking_spids + ,(CASE + WHEN (ttCD.blocking_session_id IS NOT NULL OR ttP.session_id IS NOT NULL) THEN N' •• ' + ELSE N'' + END) AS separator_02 + ,N'> Blocked By < : ' + CONVERT (NVARCHAR (6), ttCD.blocking_session_id) AS blocked_by_spid + ,(CASE + WHEN ttP.session_id IS NOT NULL THEN N' •• ' + ELSE N'' + END) AS separator_03 + ,N'( Parallelism ) : ' + CONVERT (NVARCHAR (6), ttP.session_id) AS parallelism_spid + ,ISNULL ((CASE + WHEN ttCD.[text] IS NULL THEN N'' + WHEN caFL.status_session = N'sleeping' AND caFL.status_request IS NULL THEN N'' + WHEN ttCD.stmt_start < 1 AND ttCD.stmt_end = -1 THEN N'<< Single Statement >>' + WHEN (DATALENGTH (ttCD.[text]) - ttCD.stmt_start) / 2 < 0 AND ttCD.stmt_end = -1 THEN N'<< Derived Statement >>' + WHEN ttCD.stmt_end = -1 THEN SUBSTRING (ttCD.[text], (ttCD.stmt_start / 2) + 1, ((DATALENGTH (ttCD.[text]) - ttCD.stmt_start) / 2) + 1) + ELSE SUBSTRING (ttCD.[text], (ttCD.stmt_start / 2) + 1, ((ttCD.stmt_end - ttCD.stmt_start) / 2) + 1) + END), N'') AS sql_statement_current + ) caCP + +ORDER BY + (CASE + WHEN ttD.blocking_session_id IS NOT NULL AND caFL.blocking IS NULL THEN 1 + WHEN ttD.blocking_session_id IS NOT NULL AND caFL.blocking IS NOT NULL THEN 2 + WHEN caFL.blocking IS NOT NULL AND ttCD.blocking_session_id IS NULL THEN 3 + WHEN caFL.blocking IS NOT NULL AND ttCD.blocking_session_id IS NOT NULL THEN 4 + WHEN ttCD.blocking_session_id IS NOT NULL THEN 5 + WHEN ttP.session_id IS NOT NULL THEN 6 + ELSE 7 + END) + ,ttCD.session_id + + +----------------------------------------------------------------------------------------------------------------------------- +-- Cleanup: Drop Any Remaining Temp Tables +----------------------------------------------------------------------------------------------------------------------------- + +IF OBJECT_ID (N'tempdb.dbo.#temp_core_data', N'U') IS NOT NULL +BEGIN + + DROP TABLE dbo.#temp_core_data + +END + + +IF OBJECT_ID (N'tempdb.dbo.#temp_databases', N'U') IS NOT NULL +BEGIN + + DROP TABLE dbo.#temp_databases + +END + + +IF OBJECT_ID (N'tempdb.dbo.#temp_deadlocking', N'U') IS NOT NULL +BEGIN + + DROP TABLE dbo.#temp_deadlocking + +END + + +IF OBJECT_ID (N'tempdb.dbo.#temp_lock_details', N'U') IS NOT NULL +BEGIN + + DROP TABLE dbo.#temp_lock_details + +END + + +IF OBJECT_ID (N'tempdb.dbo.#temp_log_details', N'U') IS NOT NULL +BEGIN + + DROP TABLE dbo.#temp_log_details + +END + + +IF OBJECT_ID (N'tempdb.dbo.#temp_parallelism', N'U') IS NOT NULL +BEGIN + + DROP TABLE dbo.#temp_parallelism + +END +GO \ No newline at end of file diff --git a/Stored_Procedure/sp_BenchmarkTSQL.sql b/Stored_Procedure/sp_BenchmarkTSQL.sql deleted file mode 100644 index 7091c0d0..00000000 --- a/Stored_Procedure/sp_BenchmarkTSQL.sql +++ /dev/null @@ -1,366 +0,0 @@ -IF OBJECT_ID('dbo.sp_BenchmarkTSQL', 'P') IS NULL - EXECUTE ('CREATE PROCEDURE dbo.sp_BenchmarkTSQL AS SELECT 1;'); -GO - - -ALTER PROCEDURE dbo.sp_BenchmarkTSQL( - @tsqlStatement NVARCHAR(MAX) - , @numberOfExecution INT = 10 - , @saveResults BIT = 0 - , @clearCache BIT = 0 - , @calcMedian BIT = 0 - , @printStepInfo BIT = 1 - , @durationAccuracy VARCHAR(3) = 'ns' -) -/* -.SYNOPSIS - Calculate TSQL statement execution time, save results if needed. - -.DESCRIPTION - Run SQL statement specified times, show results, insert execution details into table dbo.BenchmarkTSQL (create if not exist). - -.PARAMETER @tsqlStatement - TSQL statement for benchmarking. - -.PARAMETER @numberOfExecution - Number of execution TSQL statement. - -.PARAMETER @saveResults - Save benchmark details to dbo.BenchmarkTSQL table if @saveResults = 1. - -.PARAMETER @clearCache - Clear cached plan for TSQL statement. - -.PARAMETER @calcMedian - Calculate pseudo median of execution time. - -.PARAMETER @printStepInfo - PRINT detailed step information: step count, start time, end time, duration. - -.PARAMETER @durationAccuracy - Duration accuracy calculation, possible values: ns, mcs, ms, ss, s, mi, n, hh, wk, ww, dd, d. - -.EXAMPLE - EXEC sp_BenchmarkTSQL @tsqlStatement = 'SELECT * FROM , sys.databases'; - -- RETURN: Incorrect syntax near ','. - -.EXAMPLE - EXEC sp_BenchmarkTSQL @tsqlStatement = 'SELECT * FROM sys.databases'; - -.EXAMPLE - EXEC sp_BenchmarkTSQL @tsqlStatement = 'SELECT TOP(100000) * FROM sys.objects AS o1 CROSS JOIN sys.objects AS o2 CROSS JOIN sys.objects AS o3;' - , @numberOfExecution = 10 - , @saveResults = 1 - , @calcMedian = 1 - , @clearCache = 1 - , @printStepInfo = 1 - , @durationAccuracy = 'ms'; - -.LICENSE MIT -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -.NOTE - Author: Aleksei Nagorskii - Created date: 2017-12-14 - Version: 1.0 - - Author: Aleksei Nagorskii - Modified date: 2017-12-15 - Version: 1.1 - - Author: Konstantin Taranov - Modified date: 2017-12-23 - Version: 2.0 - - Author: Konstantin Taranov - Modified date: 2017-12-25 - Version: 2.1 - - Author: Konstantin Taranov - Modified date: 2018-01-01 - Version: 2.2 - - Author: Konstantin Taranov - Modified date: 2018-01-04 - Version: 2.3 -*/ -AS -BEGIN TRY - - SET NOCOUNT ON; - - IF @tsqlStatement IS NULL - THROW 55001, '@tsqlStatement is NULL, please specify TSQL statement.', 1; - IF @tsqlStatement = N'' - THROW 55002, '@tsqlStatement is empty, please specify TSQL statement.', 1; - - IF @durationAccuracy NOT IN ( - 'ns' -- nanosecond - , 'mcs' -- microsecond - , 'ms' -- millisecond - , 'ss' -- second - , 's' -- second - , 'mi' -- minute - , 'n' -- minute - , 'hh' -- hour - , 'wk' -- week - , 'ww' -- week - , 'dd' -- day - , 'd' -- day - ) - THROW 55003, '@durationAccuracy can be only in this values: ns, mcs, ms, ss, s, mi, n, hh, wk, ww, dd, d. See DATEDIFF https://docs.microsoft.com/en-us/sql/t-sql/functions/datediff-transact-sql' , 1; - - IF EXISTS ( - SELECT 1 - FROM sys.dm_exec_describe_first_result_set(@tsqlStatement, NULL, 0) - WHERE error_message IS NOT NULL - AND error_number IS NOT NULL - AND error_severity IS NOT NULL - AND error_state IS NOT NULL - AND error_type IS NOT NULL - AND error_type_desc IS NOT NULL - ) - BEGIN - DECLARE @err_msg NVARCHAR(MAX); - - SELECT @err_msg = [error_message] - FROM sys.dm_exec_describe_first_result_set(@tsqlStatement, NULL, 0) - WHERE column_ordinal = 0; - - THROW 55004, @err_msg, 1; - END - - DECLARE @crlf VARCHAR(10) = CHAR(10); - DECLARE @cts DATETIME2(7) = CURRENT_TIMESTAMP; - DECLARE @r INT = 0; - DECLARE @min BIGINT; - DECLARE @avg BIGINT; - DECLARE @max BIGINT; - DECLARE @median REAL; - DECLARE @plan_handle VARBINARY(64); - DECLARE @rts DATETIME2(7); - DECLARE @finishTime DATETIME2(7); - DECLARE @duration INT; - DECLARE @startTime VARCHAR(27); - DECLARE @originalLogin SYSNAME = ORIGINAL_LOGIN(); - - DECLARE @t TABLE ( - StartTimeStamp DATETIME2(7) - , RunTimeStamp DATETIME2(7) - , FinishTimeStamp DATETIME2(7) - , Duration BIGINT - , TsqlStatement NVARCHAR(MAX) - , ClearCache BIT - , PrintStepInfo BIT - , DurationAccuracy VARCHAR(10) - ); - - SET @startTime = CONVERT(VARCHAR(27), CAST(CURRENT_TIMESTAMP AS DATETIME2(7)), 121); - PRINT('Benchmark started at ' + @startTime + ' by ' + @originalLogin); - - WHILE @r < @numberOfExecution - BEGIN - SET @r = @r + 1; - SET @rts = CAST(CURRENT_TIMESTAMP AS DATETIME2(7)); - - IF @clearCache = 1 - BEGIN - SELECT @plan_handle = plan_handle - FROM sys.dm_exec_cached_plans - CROSS APPLY sys.dm_exec_sql_text(plan_handle) - WHERE [text] LIKE @tsqlStatement; -- LIKE instead = (equal) because = ignore trailing spaces - - IF @plan_handle IS NOT NULL DBCC FREEPROCCACHE (@plan_handle); - END; - - EXECUTE sp_executesql @tsqlStatement; - - SET @finishTime = CAST(CURRENT_TIMESTAMP AS DATETIME2(7)); - SET @duration = CASE WHEN @durationAccuracy = 'ns' THEN CAST(DATEDIFF(ns, @rts, @finishTime) AS INT) - WHEN @durationAccuracy = 'mcs' THEN CAST(DATEDIFF(mcs, @rts, @finishTime) AS INT) - WHEN @durationAccuracy = 'ms' THEN CAST(DATEDIFF(ms, @rts, @finishTime) AS INT) - WHEN @durationAccuracy = 'ss' THEN CAST(DATEDIFF(ss, @rts, @finishTime) AS INT) - WHEN @durationAccuracy = 's' THEN CAST(DATEDIFF(s, @rts, @finishTime) AS INT) - WHEN @durationAccuracy = 'mi' THEN CAST(DATEDIFF(mi, @rts, @finishTime) AS INT) - WHEN @durationAccuracy = 'n' THEN CAST(DATEDIFF(n, @rts, @finishTime) AS INT) - WHEN @durationAccuracy = 'hh' THEN CAST(DATEDIFF(hh, @rts, @finishTime) AS INT) - WHEN @durationAccuracy = 'wk' THEN CAST(DATEDIFF(wk, @rts, @finishTime) AS INT) - WHEN @durationAccuracy = 'ww' THEN CAST(DATEDIFF(ww, @rts, @finishTime) AS INT) - WHEN @durationAccuracy = 'dd' THEN CAST(DATEDIFF(dd, @rts, @finishTime) AS INT) - WHEN @durationAccuracy = 'd' THEN CAST(DATEDIFF(d, @rts, @finishTime) AS INT) - ELSE 0 - END; - - INSERT @t ( - StartTimeStamp - , RunTimeStamp - , FinishTimeStamp - , Duration - , TsqlStatement - , ClearCache - , PrintStepInfo - , DurationAccuracy - ) - VALUES ( - @cts - , @rts - , @finishTime - , @duration - , @tsqlStatement - , @clearCache - , @printStepInfo - , @durationAccuracy - ); - - IF @printStepInfo = 1 - PRINT ( - 'Run ' + CASE WHEN @r < 10 THEN ' ' + CAST(@r AS VARCHAR(30)) - WHEN @r < 100 THEN ' ' + CAST(@r AS VARCHAR(30)) - ELSE CAST(@r AS VARCHAR(30)) - END + - ', start: ' + CONVERT(VARCHAR(27), @rts, 121) + - ', finish: ' + CONVERT(VARCHAR(27), CAST(CURRENT_TIMESTAMP AS DATETIME2(7)), 121) + - ', duration: ' + CAST(@duration AS VARCHAR(100)) + @durationAccuracy + '.' - ); - - END; - - SELECT @min = MIN(Duration) - , @avg = AVG(Duration) - , @max = MAX(Duration) - FROM @t; - - IF @calcMedian = 1 - BEGIN - SELECT @median = - ( - (SELECT MAX(TMIN) FROM - (SELECT TOP(50) PERCENT - CASE WHEN @durationAccuracy = 'ns' THEN CAST(DATEDIFF(ns, RunTimeStamp, FinishTimeStamp) AS INT) - WHEN @durationAccuracy = 'mcs' THEN CAST(DATEDIFF(mcs, RunTimeStamp, FinishTimeStamp) AS INT) - WHEN @durationAccuracy = 'ms' THEN CAST(DATEDIFF(ms, RunTimeStamp, FinishTimeStamp) AS INT) - WHEN @durationAccuracy = 'ss' THEN CAST(DATEDIFF(ss, RunTimeStamp, FinishTimeStamp) AS INT) - WHEN @durationAccuracy = 's' THEN CAST(DATEDIFF(s, RunTimeStamp, FinishTimeStamp) AS INT) - WHEN @durationAccuracy = 'mi' THEN CAST(DATEDIFF(mi, RunTimeStamp, FinishTimeStamp) AS INT) - WHEN @durationAccuracy = 'n' THEN CAST(DATEDIFF(n, RunTimeStamp, FinishTimeStamp) AS INT) - WHEN @durationAccuracy = 'hh' THEN CAST(DATEDIFF(hh, RunTimeStamp, FinishTimeStamp) AS INT) - WHEN @durationAccuracy = 'wk' THEN CAST(DATEDIFF(wk, RunTimeStamp, FinishTimeStamp) AS INT) - WHEN @durationAccuracy = 'ww' THEN CAST(DATEDIFF(ww, RunTimeStamp, FinishTimeStamp) AS INT) - WHEN @durationAccuracy = 'dd' THEN CAST(DATEDIFF(dd, RunTimeStamp, FinishTimeStamp) AS INT) - WHEN @durationAccuracy = 'd' THEN CAST(DATEDIFF(d, RunTimeStamp, FinishTimeStamp) AS INT) - ELSE 0 - END AS TMIN - FROM @t - ORDER BY TMIN - ) AS BottomHalf - ) - + - (SELECT MIN(TMAX) FROM - (SELECT TOP 50 PERCENT - CASE WHEN @durationAccuracy = 'ns' THEN CAST(DATEDIFF(ns, RunTimeStamp, FinishTimeStamp) AS INT) - WHEN @durationAccuracy = 'mcs' THEN CAST(DATEDIFF(mcs, RunTimeStamp, FinishTimeStamp) AS INT) - WHEN @durationAccuracy = 'ms' THEN CAST(DATEDIFF(ms, RunTimeStamp, FinishTimeStamp) AS INT) - WHEN @durationAccuracy = 'ss' THEN CAST(DATEDIFF(ss, RunTimeStamp, FinishTimeStamp) AS INT) - WHEN @durationAccuracy = 's' THEN CAST(DATEDIFF(s, RunTimeStamp, FinishTimeStamp) AS INT) - WHEN @durationAccuracy = 'mi' THEN CAST(DATEDIFF(mi, RunTimeStamp, FinishTimeStamp) AS INT) - WHEN @durationAccuracy = 'n' THEN CAST(DATEDIFF(n, RunTimeStamp, FinishTimeStamp) AS INT) - WHEN @durationAccuracy = 'hh' THEN CAST(DATEDIFF(hh, RunTimeStamp, FinishTimeStamp) AS INT) - WHEN @durationAccuracy = 'wk' THEN CAST(DATEDIFF(wk, RunTimeStamp, FinishTimeStamp) AS INT) - WHEN @durationAccuracy = 'ww' THEN CAST(DATEDIFF(ww, RunTimeStamp, FinishTimeStamp) AS INT) - WHEN @durationAccuracy = 'dd' THEN CAST(DATEDIFF(dd, RunTimeStamp, FinishTimeStamp) AS INT) - WHEN @durationAccuracy = 'd' THEN CAST(DATEDIFF(d, RunTimeStamp, FinishTimeStamp) AS INT) - ELSE 0 - END AS TMAX - FROM @t - ORDER BY TMAX DESC - ) AS TopHalf - ) - ) / 2.0; - END; - - PRINT ( - 'Min: ' + CAST(@min AS VARCHAR(30)) + @durationAccuracy + - ', Max: ' + CAST(@max AS VARCHAR(30)) + @durationAccuracy + - ', Average: ' + CAST(@avg AS VARCHAR(30)) + @durationAccuracy + - CASE WHEN @calcMedian = 1 THEN ', Median: ' + CAST(@median AS VARCHAR(30)) + @durationAccuracy ELSE '' END + - @crlf + - 'Benchmark finished at ' + CONVERT(VARCHAR(23), CURRENT_TIMESTAMP, 121) + ' by ' + @originalLogin + '.' - ); - - IF @saveResults = 1 - - DECLARE @TSQLStatementGUID VARCHAR(36) = NEWID(); - - IF OBJECT_ID('dbo.BenchmarkTSQL', 'U') IS NULL - BEGIN - CREATE TABLE dbo.BenchmarkTSQL( - BenchmarkTSQLID INT IDENTITY NOT NULL - , TSQLStatementGUID VARCHAR(36) NOT NULL - , StepRowNumber INT NOT NULL - , StartTimeStamp DATETIME2(7) NOT NULL - , RunTimeStamp DATETIME2(7) NOT NULL - , FinishTimeStamp DATETIME2(7) NOT NULL - , Duration BIGINT NOT NULL - , TsqlStatement NVARCHAR(MAX) NOT NULL - , ClearCache BIT NOT NULL - , PrintStepInfo BIT NOT NULL - , DurationAccuracy VARCHAR(10) NOT NULL - , OriginalLogin SYSNAME NOT NULL - ); - - INSERT INTO dbo.BenchmarkTSQL( - TSQLStatementGUID - , StepRowNumber - , StartTimeStamp - , RunTimeStamp - , FinishTimeStamp - , Duration - , TsqlStatement - , ClearCache - , PrintStepInfo - , DurationAccuracy - , OriginalLogin - ) - SELECT @TSQLStatementGUID AS TSQLStatementGUID - , ROW_NUMBER() OVER (ORDER BY RunTimeStamp, FinishTimeStamp) AS StepRowNumber - , StartTimeStamp - , RunTimeStamp - , FinishTimeStamp - , Duration - , TsqlStatement - , ClearCache - , PrintStepInfo - , DurationAccuracy - , @originalLogin AS OriginalLogin - FROM @t; - END - ELSE - INSERT INTO dbo.BenchmarkTSQL - SELECT @TSQLStatementGUID AS TSQLStatementGUID - , ROW_NUMBER() OVER (ORDER BY RunTimeStamp, FinishTimeStamp) AS StepRowNumber - , StartTimeStamp - , RunTimeStamp - , FinishTimeStamp - , Duration - , TsqlStatement - , ClearCache - , PrintStepInfo - , DurationAccuracy - , @originalLogin - FROM @t; - - SET NOCOUNT OFF; -END TRY - -BEGIN CATCH - PRINT 'Error: ' + CONVERT(varchar(50), ERROR_NUMBER()) + - ', Severity: ' + CONVERT(varchar(5), ERROR_SEVERITY()) + - ', State: ' + CONVERT(varchar(5), ERROR_STATE()) + - ', Procedure: ' + ISNULL(ERROR_PROCEDURE(), '-') + - ', Line: ' + CONVERT(varchar(5), ERROR_LINE()) + - ', User name: ' + CONVERT(sysname, CURRENT_USER); - PRINT ERROR_MESSAGE(); -END CATCH; -GO diff --git a/Stored_Procedure/sp_DBPermissions.sql b/Stored_Procedure/sp_DBPermissions.sql deleted file mode 100644 index 0d8c579c..00000000 --- a/Stored_Procedure/sp_DBPermissions.sql +++ /dev/null @@ -1,898 +0,0 @@ -USE master -GO -IF OBJECT_ID('dbo.sp_DBPermissions') IS NULL - EXEC sp_executesql N'CREATE PROCEDURE dbo.sp_DBPermissions AS PRINT ''Stub'';' -GO -/********************************************************************************************* -sp_DBPermissions V6.0 -Kenneth Fisher - -http://www.sqlstudies.com - -This stored procedure returns 3 data sets. The first dataset is the list of database -principals, the second is role membership, and the third is object and database level -permissions. - -The final 2 columns of each query are "Un-Do"/"Do" scripts. For example removing a member -from a role or adding them to a role. I am fairly confident in the role scripts, however, -the scripts in the database principals query and database/object permissions query are -works in progress. In particular certificates, keys and column level permissions are not -scripted out. Also while the scripts have worked flawlessly on the systems I've tested -them on, these systems are fairly similar when it comes to security so I can't say that -in a more complicated system there won't be the odd bug. - -Standard disclaimer: You use scripts off of the web at your own risk. I fully expect this - script to work without issue but I've been known to be wrong before. - -Parameters: - @DBName - If NULL use the current database, otherwise give permissions based on the parameter. - - There is a special case where you pass in ALL to the @DBName. In this case the SP - will loop through (yes I'm using a cursor) all of the DBs in sysdatabases and run - the queries into temp tables before returning the results. WARNINGS: If you use - this option and have a large number of databases it will be SLOW. If you use this - option and don't specify any other parameters (say a specific @Principal) and have - even a medium number of databases it will be SLOW. Also the undo/do scripts do - not have USE statements in them so please take that into account. - @Principal - If NOT NULL then all three queries only pull for that database principal. @Principal - is a pattern check. The queries check for any row where the passed in value exists. - It uses the pattern '%' + @Principal + '%' - @Role - If NOT NULL then the roles query will pull members of the role. If it is NOT NULL and - @DBName is NULL then DB principal and permissions query will pull the principal row for - the role and the permissions for the role. @Role is a pattern check. The queries - check for any row where the passed in value exists. It uses the pattern '%' + @Role + - '%' - @Type - If NOT NULL then all three queries will only pull principals of that type. - S = SQL login - U = Windows login - G = Windows group - R = Server role - C = Login mapped to a certificate - K = Login mapped to an asymmetric key - @ObjectName - If NOT NULL then the third query will display permissions specific to the object - specified and the first two queries will display only those users with those specific - permissions. Unfortunately at this point only objects in sys.all_objects will work. - This parameter uses the pattern '%' + @ObjectName + '%' - @Permission - If NOT NULL then the third query will display only permissions that match what is in - the parameter. The first two queries will display only those users with that specific - permission. - @LoginName - If NOT NULL then each of the queries will only pull back database principals that - have the same SID as a login that matches the pattern '%' + @LoginName + '%' - @UseLikeSearch - When this is set to 1 (the default) then the search parameters will use LIKE (and - %'s will be added around the @Principal, @Role, @ObjectName, and @LoginName parameters). - When set to 0 searchs will use =. - @IncludeMSShipped - When this is set to 1 (the default) then all principals will be included. When set - to 0 the fixed server roles and SA and Public principals will be excluded. - @DropTempTables - When this is set to 1 (the default) the temp tables used are dropped. If it's 0 - then the tempt ables are kept for references after the code has finished. - The temp tables are: - ##DBPrincipals - ##DBRoles - ##DBPermissions - @Output - What type of output is desired. - Default - Either 'Default' or it doesn't match any of the allowed values then the SP - will return the standard 3 outputs. - None - No output at all. Usually used if you keeping the temp tables to do your own - reporting. - CreateOnly - Only return the create scripts where they aren't NULL. - DropOnly - Only return the drop scripts where they aren't NULL. - ScriptsOnly - Return drop and create scripts where they aren't NULL. - Report - Returns one output with one row per principal and a comma delimited list of - roles the principal is a member of and a comma delimited list of the - individual permissions they have. - @Print - Defaults to 0, but if a 1 is passed in then the queries are not run but printed - out instead. This is primarily for debugging. - -Data is ordered as follows - 1st result set: DBPrincipal - 2nd result set: RoleName, UserName if the parameter @Role is used else - UserName, RoleName - 3rd result set: ObjectName then Grantee_Name if the parameter @ObjectName - is used otherwise Grantee_Name, ObjectName - --- V2.0 --- 8/18/2013 – Create a stub if the SP doesn’t exist, then always do an alter --- 8/18/2013 - Use instance collation for all concatenated strings --- 9/04/2013 - dbo can’t be added or removed from roles. Don’t script. --- 9/04/2013 - Fix scripts for schema level permissions. --- 9/04/2013 – Change print option to show values of variables not the --- Variable names. --- V3.0 --- 10/5/2013 - Added @Type parameter to pull only principals of a given type. --- 10/10/2013 - Added @ObjectName parameter to pull only permissions for a given object. --- V4.0 --- 11/18/2013 - Added parameter names to sp_addrolemember and sp_droprolemember. --- 11/19/2013 - Added an ORDER BY to each of the result sets. See above for details. --- 01/04/2014 - Add an ALL option to the DBName parameter. --- V4.1 --- 02/07/2014 - Fix bug scripting permissions where object and schema have the same ID --- 02/15/2014 - Add support for user defined types --- 02/15/2014 - Fix: Add schema to object GRANT and REVOKE scripts --- V5.0 --- 4/29/2014 - Fix: Removed extra print statements --- 4/29/2014 - Fix: Added SET NOCOUNT ON --- 4/29/2014 - Added a USE statement to the scripts when using the @DBName = 'All' option --- 5/01/2014 - Added @Permission parameter --- 5/14/2014 - Added additional permissions based on information from Kendal Van Dyke's - post http://www.kendalvandyke.com/2014/02/using-sysobjects-when-scripting.html --- 6/02/2014 - Added @LoginName parameter --- V5.5 --- 7/15/2014 - Bunch of changes recommended by @SQLSoldier/"https://twitter.com/SQLSoldier" - Primarily changing the strings to unicode & adding QUOTENAME in a few places - I'd missed it. --- V6.0 --- 10/19/2014 - Add @UserLikeSearch and @IncludeMSShipped parameters. --- 11/29/2016 - Fixed permissions for symmetric keys --- Found and fixed by Brenda Grossnickle --- 03/25/2017 - Move SID towards the end of the first output so the more important --- columns are closer to the front. --- 03/25/2017 - Add IF Exists to drop and create user scripts --- 03/25/2017 - Remove create/drop user scripts for guest, public, sys and INFORMATION_SCHEMA --- 03/25/2017 - Add @DropTempTables to keep the temp tables after the SP is run. --- 03/26/2017 - Add @Output to allow different types of output. -*********************************************************************************************/ - -ALTER PROCEDURE dbo.sp_DBPermissions -( - @DBName sysname = NULL, - @Principal sysname = NULL, - @Role sysname = NULL, - @Type nvarchar(30) = NULL, - @ObjectName sysname = NULL, - @Permission sysname = NULL, - @LoginName sysname = NULL, - @UseLikeSearch bit = 1, - @IncludeMSShipped bit = 1, - @DropTempTables bit = 1, - @Output varchar(30) = 'Default', - @Print bit = 0 -) -AS - -SET NOCOUNT ON - -DECLARE @Collation nvarchar(75) -SET @Collation = N' COLLATE ' + CAST(SERVERPROPERTY('Collation') AS nvarchar(50)) - -DECLARE @sql nvarchar(max) -DECLARE @sql2 nvarchar(max) -DECLARE @ObjectList nvarchar(max) -DECLARE @use nvarchar(500) -DECLARE @AllDBNames sysname - -IF @DBName IS NULL OR @DBName = N'All' - BEGIN - SET @use = '' - IF @DBName IS NULL - SET @DBName = DB_NAME() - --SELECT @DBName = db_name(database_id) - --FROM sys.dm_exec_requests - --WHERE session_id = @@SPID - END -ELSE --- IF EXISTS (SELECT 1 FROM sys.databases WHERE name = @DBName) - IF db_id(@DBName) IS NOT NULL - SET @use = N'USE ' + QUOTENAME(@DBName) + N';' + NCHAR(13) - ELSE - BEGIN - RAISERROR (N'%s is not a valid database name.', - 16, - 1, - @DBName) - RETURN - END - -DECLARE @LikeOperator nvarchar(4) - -IF @UseLikeSearch = 1 - SET @LikeOperator = N'LIKE' -ELSE - SET @LikeOperator = N'=' - -IF @UseLikeSearch = 1 -BEGIN - IF LEN(ISNULL(@Principal,'')) > 0 - SET @Principal = N'%' + @Principal + N'%' - - IF LEN(ISNULL(@Role,'')) > 0 - SET @Role = N'%' + @Role + N'%' - - IF LEN(ISNULL(@ObjectName,'')) > 0 - SET @ObjectName = N'%' + @ObjectName + N'%' - - IF LEN(ISNULL(@LoginName,'')) > 0 - SET @LoginName = N'%' + @LoginName + N'%' -END - -IF @Print = 1 AND @DBName = N'All' - BEGIN - PRINT 'DECLARE @AllDBNames sysname' - PRINT 'SET @AllDBNames = ''master''' - PRINT '' - END ---========================================================================= --- Database Principals -SET @sql = - N'SELECT ' + CASE WHEN @DBName = 'All' THEN N'@AllDBNames' ELSE N'''' + @DBName + N'''' END + N' AS DBName,' + - N' DBPrincipals.principal_id AS DBPrincipalId, DBPrincipals.name AS DBPrincipal, SrvPrincipals.name AS SrvPrincipal, ' + NCHAR(13) + - N' DBPrincipals.type, DBPrincipals.type_desc, DBPrincipals.default_schema_name, DBPrincipals.create_date, ' + NCHAR(13) + - N' DBPrincipals.modify_date, DBPrincipals.is_fixed_role, ' + NCHAR(13) + - N' Authorizations.name AS RoleAuthorization, DBPrincipals.sid, ' + NCHAR(13) + - N' CASE WHEN DBPrincipals.is_fixed_role = 0 AND DBPrincipals.name NOT IN (''dbo'',''guest'', ''INFORMATION_SCHEMA'', ''public'', ''sys'') THEN ' + NCHAR(13) + - CASE WHEN @DBName = 'All' THEN N' ''USE '' + QUOTENAME(@AllDBNames) + ''; '' + ' + NCHAR(13) ELSE N'' END + - N' ''IF DATABASE_PRINCIPAL_ID('''''' + DBPrincipals.name + '''''') IS NOT NULL '' + ' + NCHAR(13) + - N' ''DROP '' + CASE DBPrincipals.[type] WHEN ''C'' THEN NULL ' + NCHAR(13) + - N' WHEN ''K'' THEN NULL ' + NCHAR(13) + - N' WHEN ''R'' THEN ''ROLE'' ' + NCHAR(13) + - N' WHEN ''A'' THEN ''APPLICATION ROLE'' ' + NCHAR(13) + - N' ELSE ''USER'' END + ' + NCHAR(13) + - N' '' ''+QUOTENAME(DBPrincipals.name' + @Collation + N') + '';'' ELSE NULL END AS DropScript, ' + NCHAR(13) + - N' CASE WHEN DBPrincipals.is_fixed_role = 0 AND DBPrincipals.name NOT IN (''dbo'',''guest'', ''INFORMATION_SCHEMA'', ''public'', ''sys'') THEN ' + NCHAR(13) + - CASE WHEN @DBName = 'All' THEN N' ''USE '' + QUOTENAME(@AllDBNames) + ''; '' + ' +NCHAR(13) ELSE N'' END + - N' ''IF DATABASE_PRINCIPAL_ID('''''' + DBPrincipals.name + '''''') IS NULL '' + ' + NCHAR(13) + - N' ''CREATE '' + CASE DBPrincipals.[type] WHEN ''C'' THEN NULL ' + NCHAR(13) + - N' WHEN ''K'' THEN NULL ' + NCHAR(13) + - N' WHEN ''R'' THEN ''ROLE'' ' + NCHAR(13) + - N' WHEN ''A'' THEN ''APPLICATION ROLE'' ' + NCHAR(13) + - N' ELSE ''USER'' END + ' + NCHAR(13) + - N' '' ''+QUOTENAME(DBPrincipals.name' + @Collation + N') END + ' + NCHAR(13) + - N' CASE WHEN DBPrincipals.[type] = ''R'' THEN ' + NCHAR(13) + - N' ISNULL('' AUTHORIZATION ''+QUOTENAME(Authorizations.name' + @Collation + N'),'''') ' + NCHAR(13) + - N' WHEN DBPrincipals.[type] = ''A'' THEN ' + NCHAR(13) + - N' '''' ' + NCHAR(13) + - N' WHEN DBPrincipals.[type] NOT IN (''C'',''K'') THEN ' + NCHAR(13) + - N' ISNULL('' FOR LOGIN '' + - QUOTENAME(SrvPrincipals.name' + @Collation + N'),'' WITHOUT LOGIN'') + ' + NCHAR(13) + - N' ISNULL('' WITH DEFAULT_SCHEMA = ''+ - QUOTENAME(DBPrincipals.default_schema_name' + @Collation + N'),'''') ' + NCHAR(13) + - N' ELSE '''' ' + NCHAR(13) + - N' END + '';'' + ' + NCHAR(13) + - N' CASE WHEN DBPrincipals.[type] NOT IN (''C'',''K'',''R'',''A'') ' + NCHAR(13) + - N' AND SrvPrincipals.name IS NULL ' + NCHAR(13) + - N' AND DBPrincipals.sid IS NOT NULL ' + NCHAR(13) + - N' AND DBPrincipals.sid NOT IN (0x00, 0x01) ' + NCHAR(13) + - N' THEN '' -- Possible missing server principal'' ' + NCHAR(13) + - N' ELSE '''' END ' + NCHAR(13) + - N' AS CreateScript ' + NCHAR(13) + - N'FROM sys.database_principals DBPrincipals ' + NCHAR(13) + - N'LEFT OUTER JOIN sys.database_principals Authorizations ' + NCHAR(13) + - N' ON DBPrincipals.owning_principal_id = Authorizations.principal_id ' + NCHAR(13) + - N'LEFT OUTER JOIN sys.server_principals SrvPrincipals ' + NCHAR(13) + - N' ON DBPrincipals.sid = SrvPrincipals.sid ' + NCHAR(13) + - N' AND DBPrincipals.sid NOT IN (0x00, 0x01) ' + NCHAR(13) + - N'WHERE 1=1 ' - -IF LEN(ISNULL(@Principal,@Role)) > 0 - IF @Print = 1 - SET @sql = @sql + NCHAR(13) + N' AND DBPrincipals.name ' + @LikeOperator + N' ' + - ISNULL(QUOTENAME(@Principal,N''''),QUOTENAME(@Role,'''')) - ELSE - SET @sql = @sql + NCHAR(13) + N' AND DBPrincipals.name ' + @LikeOperator + N' ISNULL(@Principal,@Role) ' - -IF LEN(@Type) > 0 - IF @Print = 1 - SET @sql = @sql + NCHAR(13) + N' AND DBPrincipals.type ' + @LikeOperator + N' ' + QUOTENAME(@Type,'''') - ELSE - SET @sql = @sql + NCHAR(13) + N' AND DBPrincipals.type ' + @LikeOperator + N' @Type' - -IF LEN(@LoginName) > 0 - IF @Print = 1 - SET @sql = @sql + NCHAR(13) + N' AND SrvPrincipals.name ' + @LikeOperator + N' ' + QUOTENAME(@LoginName,'''') - ELSE - SET @sql = @sql + NCHAR(13) + N' AND SrvPrincipals.name ' + @LikeOperator + N' @LoginName' - -IF LEN(@ObjectName) > 0 - BEGIN - SET @sql = @sql + NCHAR(13) + - N' AND EXISTS (SELECT 1 ' + NCHAR(13) + - N' FROM sys.all_objects [Objects] ' + NCHAR(13) + - N' INNER JOIN sys.database_permissions Permission ' + NCHAR(13) + - N' ON Permission.major_id = [Objects].object_id ' + NCHAR(13) + - N' WHERE Permission.major_id = [Objects].object_id ' + NCHAR(13) + - N' AND Permission.grantee_principal_id = DBPrincipals.principal_id ' + NCHAR(13) - - IF @Print = 1 - SET @sql = @sql + N' AND [Objects].name ' + @LikeOperator + N' ' + QUOTENAME(@ObjectName,'''') - ELSE - SET @sql = @sql + N' AND [Objects].name ' + @LikeOperator + N' @ObjectName' - - SET @sql = @sql + N')' - END - -IF LEN(@Permission) > 0 - BEGIN - SET @sql = @sql + NCHAR(13) + - N' AND EXISTS (SELECT 1 ' + NCHAR(13) + - N' FROM sys.database_permissions Permission ' + NCHAR(13) + - N' WHERE Permission.grantee_principal_id = DBPrincipals.principal_id ' + NCHAR(13) - - IF @Print = 1 - SET @sql = @sql + N' AND Permission.permission_name ' + @LikeOperator + N' ' + QUOTENAME(@Permission,'''') - ELSE - SET @sql = @sql + N' AND Permission.permission_name ' + @LikeOperator + N' @Permission' - - SET @sql = @sql + N')' - END - -IF @IncludeMSShipped = 0 - SET @sql = @sql + NCHAR(13) + N' AND DBPrincipals.is_fixed_role = 0 ' + NCHAR(13) + - ' AND DBPrincipals.name NOT IN (''dbo'',''public'',''INFORMATION_SCHEMA'',''guest'',''sys'') ' - -IF @Print = 1 -BEGIN - PRINT N'-- Database Principals' - PRINT CAST(@sql AS nvarchar(max)) - PRINT '' -- Spacing before the next print - PRINT '' -END -ELSE -BEGIN - IF object_id('tempdb..##DBPrincipals') IS NOT NULL - DROP TABLE ##DBPrincipals - - -- Create temp table to store the data in - CREATE TABLE ##DBPrincipals ( - DBName sysname NULL, - DBPrincipalId int NULL, - DBPrincipal sysname NULL, - SrvPrincipal sysname NULL, - type char(1) NULL, - type_desc nchar(60) NULL, - default_schema_name sysname NULL, - create_date datetime NULL, - modify_date datetime NULL, - is_fixed_role bit NULL, - RoleAuthorization sysname NULL, - sid varbinary(85) NULL, - DropScript nvarchar(max) NULL, - CreateScript nvarchar(max) NULL - ) - - SET @sql = @use + N'INSERT INTO ##DBPrincipals ' + NCHAR(13) + @sql - - IF @DBName = 'All' - BEGIN - -- Declare a READ_ONLY cursor to loop through the databases - DECLARE cur_DBList CURSOR - READ_ONLY - FOR SELECT name FROM sys.databases ORDER BY name - - OPEN cur_DBList - - FETCH NEXT FROM cur_DBList INTO @AllDBNames - WHILE (@@fetch_status <> -1) - BEGIN - IF (@@fetch_status <> -2) - BEGIN - SET @sql2 = N'USE ' + QUOTENAME(@AllDBNames) + N';' + NCHAR(13) + @sql - EXEC sp_executesql @sql2, - N'@Principal sysname, @Role sysname, @Type nvarchar(30), @ObjectName sysname, - @AllDBNames sysname, @Permission sysname, @LoginName sysname', - @Principal, @Role, @Type, @ObjectName, @AllDBNames, @Permission, @LoginName - -- PRINT @sql2 - END - FETCH NEXT FROM cur_DBList INTO @AllDBNames - END - - CLOSE cur_DBList - DEALLOCATE cur_DBList - END - ELSE - EXEC sp_executesql @sql, N'@Principal sysname, @Role sysname, @Type nvarchar(30), - @ObjectName sysname, @Permission sysname, @LoginName sysname', - @Principal, @Role, @Type, @ObjectName, @Permission, @LoginName -END ---========================================================================= --- Database Role Members -SET @sql = - N'SELECT ' + CASE WHEN @DBName = 'All' THEN N'@AllDBNames' ELSE N'''' + @DBName + N'''' END + N' AS DBName,' + - N' Users.principal_id AS UserPrincipalId, Users.name AS UserName, Roles.name AS RoleName, ' + NCHAR(13) + - CASE WHEN @DBName = 'All' THEN N' ''USE '' + QUOTENAME(@AllDBNames) + ''; '' + ' + NCHAR(13) ELSE N'' END + - N' CASE WHEN Users.is_fixed_role = 0 AND Users.name <> ''dbo'' THEN ' + NCHAR(13) + - N' ''EXEC sp_droprolemember @rolename = ''+QUOTENAME(Roles.name' + @Collation + - N','''''''')+'', @membername = ''+QUOTENAME(CASE WHEN Users.name = ''dbo'' THEN NULL - ELSE Users.name END' + @Collation + - N','''''''')+'';'' END AS DropScript, ' + NCHAR(13) + - CASE WHEN @DBName = 'All' THEN N' ''USE '' + QUOTENAME(@AllDBNames) + ''; '' + ' + NCHAR(13) ELSE N'' END + - N' CASE WHEN Users.is_fixed_role = 0 AND Users.name <> ''dbo'' THEN ' + NCHAR(13) + - N' ''EXEC sp_addrolemember @rolename = ''+QUOTENAME(Roles.name' + @Collation + - N','''''''')+'', @membername = ''+QUOTENAME(CASE WHEN Users.name = ''dbo'' THEN NULL - ELSE Users.name END' + @Collation + - N','''''''')+'';'' END AS AddScript ' + NCHAR(13) + - N'FROM sys.database_role_members RoleMembers ' + NCHAR(13) + - N'JOIN sys.database_principals Users ' + NCHAR(13) + - N' ON RoleMembers.member_principal_id = Users.principal_id ' + NCHAR(13) + - N'JOIN sys.database_principals Roles ' + NCHAR(13) + - N' ON RoleMembers.role_principal_id = Roles.principal_id ' + NCHAR(13) + - N'WHERE 1=1 ' - -IF LEN(ISNULL(@Principal,'')) > 0 - IF @Print = 1 - SET @sql = @sql + NCHAR(13) + N' AND Users.name ' + @LikeOperator + N' '+QUOTENAME(@Principal,'''') - ELSE - SET @sql = @sql + NCHAR(13) + N' AND Users.name ' + @LikeOperator + N' @Principal' - -IF LEN(ISNULL(@Role,'')) > 0 - IF @Print = 1 - SET @sql = @sql + NCHAR(13) + N' AND Roles.name ' + @LikeOperator + N' '+QUOTENAME(@Role,'''') - ELSE - SET @sql = @sql + NCHAR(13) + N' AND Roles.name ' + @LikeOperator + N' @Role' - -IF LEN(@Type) > 0 - IF @Print = 1 - SET @sql = @sql + NCHAR(13) + N' AND Users.type ' + @LikeOperator + N' ' + QUOTENAME(@Type,'''') - ELSE - SET @sql = @sql + NCHAR(13) + N' AND Users.type ' + @LikeOperator + N' @Type' - -IF LEN(@LoginName) > 0 - BEGIN - SET @sql = @sql + NCHAR(13) + - N' AND EXISTS (SELECT 1 ' + NCHAR(13) + - N' FROM sys.server_principals SrvPrincipals ' + NCHAR(13) + - N' WHERE Users.sid NOT IN (0x00, 0x01) ' + NCHAR(13) + - N' AND SrvPrincipals.sid = Users.sid ' + NCHAR(13) + - N' AND Users.type NOT IN (''R'') ' + NCHAR(13) - IF @Print = 1 - SET @sql = @sql + NCHAR(13) + ' AND SrvPrincipals.name ' + @LikeOperator + N' ' + QUOTENAME(@LoginName,'''') - ELSE - SET @sql = @sql + NCHAR(13) + ' AND SrvPrincipals.name ' + @LikeOperator + N' @LoginName' - - SET @sql = @sql + N')' - END - -IF LEN(@ObjectName) > 0 - BEGIN - SET @sql = @sql + NCHAR(13) + - N' AND EXISTS (SELECT 1 ' + NCHAR(13) + - N' FROM sys.all_objects [Objects] ' + NCHAR(13) + - N' INNER JOIN sys.database_permissions Permission ' + NCHAR(13) + - N' ON Permission.major_id = [Objects].object_id ' + NCHAR(13) + - N' WHERE Permission.major_id = [Objects].object_id ' + NCHAR(13) + - N' AND Permission.grantee_principal_id = Users.principal_id ' + NCHAR(13) - - IF @Print = 1 - SET @sql = @sql + N' AND [Objects].name ' + @LikeOperator + N' ' + QUOTENAME(@ObjectName,'''') - ELSE - SET @sql = @sql + N' AND [Objects].name ' + @LikeOperator + N' @ObjectName' - - SET @sql = @sql + N')' - END - -IF LEN(@Permission) > 0 - BEGIN - SET @sql = @sql + NCHAR(13) + - N' AND EXISTS (SELECT 1 ' + NCHAR(13) + - N' FROM sys.database_permissions Permission ' + NCHAR(13) + - N' WHERE Permission.grantee_principal_id = Users.principal_id ' + NCHAR(13) - - IF @Print = 1 - SET @sql = @sql + N' AND Permission.permission_name ' + @LikeOperator + N' ' + QUOTENAME(@Permission,'''') - ELSE - SET @sql = @sql + N' AND Permission.permission_name ' + @LikeOperator + N' @Permission' - - SET @sql = @sql + N')' - END - -IF @IncludeMSShipped = 0 - SET @sql = @sql + NCHAR(13) + N' AND Users.is_fixed_role = 0 ' + NCHAR(13) + - ' AND Users.name NOT IN (''dbo'',''public'',''INFORMATION_SCHEMA'',''guest'',''sys'') ' - -IF @Print = 1 -BEGIN - PRINT N'-- Database Role Members' - PRINT CAST(@sql AS nvarchar(max)) - PRINT '' -- Spacing before the next print - PRINT '' -END -ELSE -BEGIN - IF object_id('tempdb..##DBRoles') IS NOT NULL - DROP TABLE ##DBRoles - - -- Create temp table to store the data in - CREATE TABLE ##DBRoles ( - DBName sysname NULL, - UserPrincipalId int NULL, - UserName sysname NULL, - RoleName sysname NULL, - DropScript nvarchar(max) NULL, - AddScript nvarchar(max) NULL - ) - - SET @sql = @use + NCHAR(13) + 'INSERT INTO ##DBRoles ' + NCHAR(13) + @sql - - IF @DBName = 'All' - BEGIN - -- Declare a READ_ONLY cursor to loop through the databases - DECLARE cur_DBList CURSOR - READ_ONLY - FOR SELECT name FROM sys.databases ORDER BY name - - OPEN cur_DBList - - FETCH NEXT FROM cur_DBList INTO @AllDBNames - WHILE (@@fetch_status <> -1) - BEGIN - IF (@@fetch_status <> -2) - BEGIN - SET @sql2 = 'USE ' + QUOTENAME(@AllDBNames) + ';' + NCHAR(13) + @sql - EXEC sp_executesql @sql2, - N'@Principal sysname, @Role sysname, @Type nvarchar(30), @ObjectName sysname, - @AllDBNames sysname, @Permission sysname, @LoginName sysname', - @Principal, @Role, @Type, @ObjectName, @AllDBNames, @Permission, @LoginName - -- PRINT @sql2 - END - FETCH NEXT FROM cur_DBList INTO @AllDBNames - END - - CLOSE cur_DBList - DEALLOCATE cur_DBList - END - ELSE - EXEC sp_executesql @sql, N'@Principal sysname, @Role sysname, @Type nvarchar(30), - @ObjectName sysname, @Permission sysname, @LoginName sysname', - @Principal, @Role, @Type, @ObjectName, @Permission, @LoginName -END - ---========================================================================= --- Database & object Permissions -SET @ObjectList = - N'; WITH ObjectList AS (' + NCHAR(13) + - N' SELECT NULL AS SchemaName , ' + NCHAR(13) + - N' name ' + @Collation + ' AS name, ' + NCHAR(13) + - N' database_id AS id, ' + NCHAR(13) + - N' ''DATABASE'' AS class_desc,' + NCHAR(13) + - N' '''' AS class ' + NCHAR(13) + - N' FROM master.sys.databases' + NCHAR(13) + - N' UNION ALL' + NCHAR(13) + - N' SELECT SCHEMA_NAME(sys.all_objects.schema_id) ' + @Collation + N' AS SchemaName,' + NCHAR(13) + - N' name ' + @Collation + N' AS name, ' + NCHAR(13) + - N' object_id AS id, ' + NCHAR(13) + - N' ''OBJECT_OR_COLUMN'' AS class_desc,' + NCHAR(13) + - N' ''OBJECT'' AS class ' + NCHAR(13) + - N' FROM sys.all_objects' + NCHAR(13) + - N' UNION ALL' + NCHAR(13) + - N' SELECT name ' + @Collation + N' AS SchemaName, ' + NCHAR(13) + - N' NULL AS name, ' + NCHAR(13) + - N' schema_id AS id, ' + NCHAR(13) + - N' ''SCHEMA'' AS class_desc,' + NCHAR(13) + - N' ''SCHEMA'' AS class ' + NCHAR(13) + - N' FROM sys.schemas' + NCHAR(13) + - N' UNION ALL' + NCHAR(13) + - N' SELECT NULL AS SchemaName, ' + NCHAR(13) + - N' name ' + @Collation + N' AS name, ' + NCHAR(13) + - N' principal_id AS id, ' + NCHAR(13) + - N' ''DATABASE_PRINCIPAL'' AS class_desc,' + NCHAR(13) + - N' CASE type_desc ' + NCHAR(13) + - N' WHEN ''APPLICATION_ROLE'' THEN ''APPLICATION ROLE'' ' + NCHAR(13) + - N' WHEN ''DATABASE_ROLE'' THEN ''ROLE'' ' + NCHAR(13) + - N' ELSE ''USER'' END AS class ' + NCHAR(13) + - N' FROM sys.database_principals' + NCHAR(13) + - N' UNION ALL' + NCHAR(13) + - N' SELECT NULL AS SchemaName, ' + NCHAR(13) + - N' name ' + @Collation + N' AS name, ' + NCHAR(13) + - N' assembly_id AS id, ' + NCHAR(13) + - N' ''ASSEMBLY'' AS class_desc,' + NCHAR(13) + - N' ''ASSEMBLY'' AS class ' + NCHAR(13) + - N' FROM sys.assemblies' + NCHAR(13) + - N' UNION ALL' + NCHAR(13) - -SET @ObjectList = @ObjectList + - N' SELECT SCHEMA_NAME(sys.types.schema_id) ' + @Collation + N' AS SchemaName, ' + NCHAR(13) + - N' name ' + @Collation + N' AS name, ' + NCHAR(13) + - N' user_type_id AS id, ' + NCHAR(13) + - N' ''TYPE'' AS class_desc,' + NCHAR(13) + - N' ''TYPE'' AS class ' + NCHAR(13) + - N' FROM sys.types' + NCHAR(13) + - N' UNION ALL' + NCHAR(13) + - N' SELECT SCHEMA_NAME(schema_id) ' + @Collation + N' AS SchemaName, ' + NCHAR(13) + - N' name ' + @Collation + N' AS name, ' + NCHAR(13) + - N' xml_collection_id AS id, ' + NCHAR(13) + - N' ''XML_SCHEMA_COLLECTION'' AS class_desc,' + NCHAR(13) + - N' ''XML SCHEMA COLLECTION'' AS class ' + NCHAR(13) + - N' FROM sys.xml_schema_collections' + NCHAR(13) + - N' UNION ALL' + NCHAR(13) + - N' SELECT NULL AS SchemaName, ' + NCHAR(13) + - N' name ' + @Collation + N' AS name, ' + NCHAR(13) + - N' message_type_id AS id, ' + NCHAR(13) + - N' ''MESSAGE_TYPE'' AS class_desc,' + NCHAR(13) + - N' ''MESSAGE TYPE'' AS class ' + NCHAR(13) + - N' FROM sys.service_message_types' + NCHAR(13) + - N' UNION ALL' + NCHAR(13) + - N' SELECT NULL AS SchemaName, ' + NCHAR(13) + - N' name ' + @Collation + N' AS name, ' + NCHAR(13) + - N' service_contract_id AS id, ' + NCHAR(13) + - N' ''SERVICE_CONTRACT'' AS class_desc,' + NCHAR(13) + - N' ''CONTRACT'' AS class ' + NCHAR(13) + - N' FROM sys.service_contracts' + NCHAR(13) + - N' UNION ALL' + NCHAR(13) + - N' SELECT NULL AS SchemaName, ' + NCHAR(13) + - N' name ' + @Collation + N' AS name, ' + NCHAR(13) + - N' service_id AS id, ' + NCHAR(13) + - N' ''SERVICE'' AS class_desc,' + NCHAR(13) + - N' ''SERVICE'' AS class ' + NCHAR(13) + - N' FROM sys.services' + NCHAR(13) + - N' UNION ALL' + NCHAR(13) + - N' SELECT NULL AS SchemaName, ' + NCHAR(13) + - N' name ' + @Collation + N' AS name, ' + NCHAR(13) + - N' remote_service_binding_id AS id, ' + NCHAR(13) + - N' ''REMOTE_SERVICE_BINDING'' AS class_desc,' + NCHAR(13) + - N' ''REMOTE SERVICE BINDING'' AS class ' + NCHAR(13) + - N' FROM sys.remote_service_bindings' + NCHAR(13) + - N' UNION ALL' + NCHAR(13) + - N' SELECT NULL AS SchemaName, ' + NCHAR(13) + - N' name ' + @Collation + N' AS name, ' + NCHAR(13) + - N' route_id AS id, ' + NCHAR(13) + - N' ''ROUTE'' AS class_desc,' + NCHAR(13) + - N' ''ROUTE'' AS class ' + NCHAR(13) + - N' FROM sys.routes' + NCHAR(13) + - N' UNION ALL' + NCHAR(13) + - N' SELECT NULL AS SchemaName, ' + NCHAR(13) + - N' name ' + @Collation + N' AS name, ' + NCHAR(13) + - N' fulltext_catalog_id AS id, ' + NCHAR(13) + - N' ''FULLTEXT_CATALOG'' AS class_desc,' + NCHAR(13) + - N' ''FULLTEXT CATALOG'' AS class ' + NCHAR(13) + - N' FROM sys.fulltext_catalogs' + NCHAR(13) + - N' UNION ALL' + NCHAR(13) + - N' SELECT NULL AS SchemaName, ' + NCHAR(13) + - N' name ' + @Collation + N' AS name, ' + NCHAR(13) + - N' symmetric_key_id AS id, ' + NCHAR(13) + - N' ''SYMMETRIC_KEYS'' AS class_desc,' + NCHAR(13) + - N' ''SYMMETRIC KEY'' AS class ' + NCHAR(13) + - N' FROM sys.symmetric_keys' + NCHAR(13) + - N' UNION ALL' + NCHAR(13) + - N' SELECT NULL AS SchemaName, ' + NCHAR(13) + - N' name ' + @Collation + N' AS name, ' + NCHAR(13) + - N' certificate_id AS id, ' + NCHAR(13) + - N' ''CERTIFICATE'' AS class_desc,' + NCHAR(13) + - N' ''CERTIFICATE'' AS class ' + NCHAR(13) + - N' FROM sys.certificates' + NCHAR(13) + - N' UNION ALL' + NCHAR(13) + - N' SELECT NULL AS SchemaName, ' + NCHAR(13) + - N' name ' + @Collation + N' AS name, ' + NCHAR(13) + - N' asymmetric_key_id AS id, ' + NCHAR(13) + - N' ''ASYMMETRIC_KEY'' AS class_desc,' + NCHAR(13) + - N' ''ASYMMETRIC KEY'' AS class ' + NCHAR(13) + - N' FROM sys.asymmetric_keys' + NCHAR(13) + - N' ) ' + NCHAR(13) - - SET @sql = - N'SELECT ' + CASE WHEN @DBName = 'All' THEN N'@AllDBNames' ELSE N'''' + @DBName + N'''' END + N' AS DBName,' + NCHAR(13) + - N' Grantee.principal_id AS GranteePrincipalId, Grantee.name AS GranteeName, Grantor.name AS GrantorName, ' + NCHAR(13) + - N' Permission.class_desc, Permission.permission_name, ' + NCHAR(13) + - N' ObjectList.name AS ObjectName, ' + NCHAR(13) + - N' ObjectList.SchemaName, ' + NCHAR(13) + - N' Permission.state_desc, ' + NCHAR(13) + - N' CASE WHEN Grantee.is_fixed_role = 0 AND Grantee.name <> ''dbo'' THEN ' + NCHAR(13) + - CASE WHEN @DBName = 'All' THEN N' ''USE '' + QUOTENAME(@AllDBNames) + ''; '' + ' + NCHAR(13) ELSE N'' END + - N' ''REVOKE '' + ' + NCHAR(13) + - N' CASE WHEN Permission.[state] = ''W'' THEN ''GRANT OPTION FOR '' ELSE '''' END + ' + NCHAR(13) + - N' '' '' + Permission.permission_name' + @Collation + N' + ' + NCHAR(13) + - N' CASE WHEN Permission.major_id <> 0 THEN '' ON '' + ' + NCHAR(13) + - N' ObjectList.class + ''::'' + ' + NCHAR(13) + - N' ISNULL(QUOTENAME(ObjectList.SchemaName),'''') + ' + NCHAR(13) + - N' CASE WHEN ObjectList.SchemaName + ObjectList.name IS NULL THEN '''' ELSE ''.'' END + ' + NCHAR(13) + - N' ISNULL(QUOTENAME(ObjectList.name),'''') ' + NCHAR(13) + - N' ' + @Collation + ' + '' '' ELSE '''' END + ' + NCHAR(13) + - N' '' FROM '' + QUOTENAME(Grantee.name' + @Collation + N') + ''; '' END AS RevokeScript, ' + NCHAR(13) + - N' CASE WHEN Grantee.is_fixed_role = 0 AND Grantee.name <> ''dbo'' THEN ' + NCHAR(13) + - CASE WHEN @DBName = 'All' THEN N' ''USE '' + QUOTENAME(@AllDBNames) + ''; '' + ' + NCHAR(13) ELSE N'' END + - N' CASE WHEN Permission.[state] = ''W'' THEN ''GRANT'' ELSE Permission.state_desc' + @Collation + - N' END + ' + NCHAR(13) + - N' '' '' + Permission.permission_name' + @Collation + N' + ' + NCHAR(13) + - N' CASE WHEN Permission.major_id <> 0 THEN '' ON '' + ' + NCHAR(13) + - N' ObjectList.class + ''::'' + ' + NCHAR(13) + - N' ISNULL(QUOTENAME(ObjectList.SchemaName),'''') + ' + NCHAR(13) + - N' CASE WHEN ObjectList.SchemaName + ObjectList.name IS NULL THEN '''' ELSE ''.'' END + ' + NCHAR(13) + - N' ISNULL(QUOTENAME(ObjectList.name),'''') ' + NCHAR(13) + - N' ' + @Collation + N' + '' '' ELSE '''' END + ' + NCHAR(13) + - N' '' TO '' + QUOTENAME(Grantee.name' + @Collation + N') + '' '' + ' + NCHAR(13) + - N' CASE WHEN Permission.[state] = ''W'' THEN '' WITH GRANT OPTION '' ELSE '''' END + ' + NCHAR(13) + - N' '' AS ''+ QUOTENAME(Grantor.name' + @Collation + N')+'';'' END AS GrantScript ' + NCHAR(13) + - N'FROM sys.database_permissions Permission ' + NCHAR(13) + - N'JOIN sys.database_principals Grantee ' + NCHAR(13) + - N' ON Permission.grantee_principal_id = Grantee.principal_id ' + NCHAR(13) + - N'JOIN sys.database_principals Grantor ' + NCHAR(13) + - N' ON Permission.grantor_principal_id = Grantor.principal_id ' + NCHAR(13) + - N'LEFT OUTER JOIN ObjectList ' + NCHAR(13) + - N' ON Permission.major_id = ObjectList.id ' + NCHAR(13) + - N' AND Permission.class_desc = ObjectList.class_desc ' + NCHAR(13) + - N'WHERE 1=1 ' - -IF LEN(ISNULL(@Principal,@Role)) > 0 - IF @Print = 1 - SET @sql = @sql + NCHAR(13) + N' AND Grantee.name ' + @LikeOperator + N' ' + ISNULL(QUOTENAME(@Principal,''''),QUOTENAME(@Role,'''')) - ELSE - SET @sql = @sql + NCHAR(13) + N' AND Grantee.name ' + @LikeOperator + N' ISNULL(@Principal,@Role) ' - -IF LEN(@Type) > 0 - IF @Print = 1 - SET @sql = @sql + NCHAR(13) + N' AND Grantee.type ' + @LikeOperator + N' ' + QUOTENAME(@Type,'''') - ELSE - SET @sql = @sql + NCHAR(13) + N' AND Grantee.type ' + @LikeOperator + N' @Type' - -IF LEN(@ObjectName) > 0 - IF @Print = 1 - SET @sql = @sql + NCHAR(13) + N' AND ObjectList.name ' + @LikeOperator + N' ' + QUOTENAME(@ObjectName,'''') - ELSE - SET @sql = @sql + NCHAR(13) + N' AND ObjectList.name ' + @LikeOperator + N' @ObjectName ' - -IF LEN(@Permission) > 0 - IF @Print = 1 - SET @sql = @sql + NCHAR(13) + N' AND Permission.permission_name ' + @LikeOperator + N' ' + QUOTENAME(@Permission,'''') - ELSE - SET @sql = @sql + NCHAR(13) + N' AND Permission.permission_name ' + @LikeOperator + N' @Permission' - -IF LEN(@LoginName) > 0 - BEGIN - SET @sql = @sql + NCHAR(13) + - N' AND EXISTS (SELECT 1 ' + NCHAR(13) + - N' FROM sys.server_principals SrvPrincipals ' + NCHAR(13) + - N' WHERE SrvPrincipals.sid = Grantee.sid ' + NCHAR(13) + - N' AND Grantee.sid NOT IN (0x00, 0x01) ' + NCHAR(13) + - N' AND Grantee.type NOT IN (''R'') ' + NCHAR(13) - IF @Print = 1 - SET @sql = @sql + NCHAR(13) + N' AND SrvPrincipals.name ' + @LikeOperator + N' ' + QUOTENAME(@LoginName,'''') - ELSE - SET @sql = @sql + NCHAR(13) + N' AND SrvPrincipals.name ' + @LikeOperator + N' @LoginName' - - SET @sql = @sql + ')' - END - -IF @IncludeMSShipped = 0 - SET @sql = @sql + NCHAR(13) + N' AND Grantee.is_fixed_role = 0 ' + NCHAR(13) + - ' AND Grantee.name NOT IN (''dbo'',''public'',''INFORMATION_SCHEMA'',''guest'',''sys'') ' - -IF @Print = 1 - BEGIN - PRINT '-- Database & object Permissions' - PRINT CAST(@use AS nvarchar(max)) - PRINT CAST(@ObjectList AS nvarchar(max)) - PRINT CAST(@sql AS nvarchar(max)) - END -ELSE -BEGIN - IF object_id('tempdb..##DBPermissions') IS NOT NULL - DROP TABLE ##DBPermissions - - -- Create temp table to store the data in - CREATE TABLE ##DBPermissions ( - DBName sysname NULL, - GranteePrincipalId int NULL, - GranteeName sysname NULL, - GrantorName sysname NULL, - class_desc nvarchar(60) NULL, - permission_name nvarchar(128) NULL, - ObjectName sysname NULL, - SchemaName sysname NULL, - state_desc nvarchar(60) NULL, - RevokeScript nvarchar(max) NULL, - GrantScript nvarchar(max) NULL - ) - - -- Add insert statement to @sql - SET @sql = @use + @ObjectList + - N'INSERT INTO ##DBPermissions ' + NCHAR(13) + - @sql - - IF @DBName = 'All' - BEGIN - -- Declare a READ_ONLY cursor to loop through the databases - DECLARE cur_DBList CURSOR - READ_ONLY - FOR SELECT name FROM sys.databases ORDER BY name - - OPEN cur_DBList - - FETCH NEXT FROM cur_DBList INTO @AllDBNames - WHILE (@@fetch_status <> -1) - BEGIN - IF (@@fetch_status <> -2) - BEGIN - SET @sql2 = 'USE ' + QUOTENAME(@AllDBNames) + ';' + NCHAR(13) + @sql - EXEC sp_executesql @sql2, - N'@Principal sysname, @Role sysname, @Type nvarchar(30), @ObjectName sysname, - @AllDBNames sysname, @Permission sysname, @LoginName sysname', - @Principal, @Role, @Type, @ObjectName, @AllDBNames, @Permission, @LoginName - -- PRINT @sql2 - END - FETCH NEXT FROM cur_DBList INTO @AllDBNames - END - - CLOSE cur_DBList - DEALLOCATE cur_DBList - END - ELSE - BEGIN - EXEC sp_executesql @sql, N'@Principal sysname, @Role sysname, @Type nvarchar(30), - @ObjectName sysname, @Permission sysname, @LoginName sysname', - @Principal, @Role, @Type, @ObjectName, @Permission, @LoginName - END -END - -IF @Print <> 1 -BEGIN - IF @Output = 'None' - PRINT '' - ELSE IF @Output = 'CreateOnly' - BEGIN - SELECT CreateScript FROM ##DBPrincipals WHERE CreateScript IS NOT NULL - SELECT AddScript FROM ##DBRoles WHERE AddScript IS NOT NULL - SELECT GrantScript FROM ##DBPermissions WHERE GrantScript IS NOT NULL - END - ELSE IF @Output = 'DropOnly' - BEGIN - SELECT DropScript FROM ##DBPrincipals WHERE DropScript IS NOT NULL - SELECT DropScript FROM ##DBRoles WHERE DropScript IS NOT NULL - SELECT RevokeScript FROM ##DBPermissions WHERE RevokeScript IS NOT NULL - END - ELSE IF @Output = 'ScriptOnly' - BEGIN - SELECT DropScript, CreateScript FROM ##DBPrincipals WHERE DropScript IS NOT NULL OR CreateScript IS NOT NULL - SELECT DropScript, AddScript FROM ##DBRoles WHERE DropScript IS NOT NULL OR AddScript IS NOT NULL - SELECT RevokeScript, GrantScript FROM ##DBPermissions WHERE RevokeScript IS NOT NULL OR GrantScript IS NOT NULL - END - ELSE IF @Output = 'Report' - BEGIN - SELECT DBName, DBPrincipal, SrvPrincipal, type, type_desc, - STUFF((SELECT ', ' + ##DBRoles.RoleName - FROM ##DBRoles - WHERE ##DBPrincipals.DBName = ##DBRoles.DBName - AND ##DBPrincipals.DBPrincipalId = ##DBRoles.UserPrincipalId - ORDER BY ##DBRoles.RoleName - FOR XML PATH(''),TYPE).value('.','VARCHAR(MAX)') - , 1, 2, '') AS RoleMembership, - STUFF((SELECT ', ' + ##DBPermissions.state_desc + ' ' + ##DBPermissions.permission_name + ' on ' + - ISNULL('OBJECT:'+##DBPermissions.ObjectName, 'DATABASE:'+##DBPermissions.DBName) - FROM ##DBPermissions - WHERE ##DBPrincipals.DBName = ##DBPermissions.DBName - AND ##DBPrincipals.DBPrincipalId = ##DBPermissions.GranteePrincipalId - ORDER BY ##DBPermissions.state_desc, ISNULL(##DBPermissions.ObjectName, ##DBPermissions.DBName), ##DBPermissions.permission_name - FOR XML PATH(''),TYPE).value('.','VARCHAR(MAX)') - , 1, 2, '') AS DirectPermissions - FROM ##DBPrincipals - ORDER BY DBName, type, DBPrincipal - END - ELSE -- 'Default' or no match - BEGIN - SELECT DBName, DBPrincipal, SrvPrincipal, type, type_desc, default_schema_name, - create_date, modify_date, is_fixed_role, RoleAuthorization, sid, - DropScript, CreateScript - FROM ##DBPrincipals ORDER BY DBName, DBPrincipal - IF LEN(@Role) > 0 - SELECT DBName, UserName, RoleName, DropScript, AddScript - FROM ##DBRoles ORDER BY DBName, RoleName, UserName - ELSE - SELECT DBName, UserName, RoleName, DropScript, AddScript - FROM ##DBRoles ORDER BY DBName, UserName, RoleName - - IF LEN(@ObjectName) > 0 - SELECT DBName, GranteeName, GrantorName, class_desc, permission_name, ObjectName, - SchemaName, state_desc, RevokeScript, GrantScript - FROM ##DBPermissions ORDER BY DBName, ObjectName, GranteeName - ELSE - SELECT DBName, GranteeName, GrantorName, class_desc, permission_name, ObjectName, - SchemaName, state_desc, RevokeScript, GrantScript - FROM ##DBPermissions ORDER BY DBName, GranteeName, ObjectName - END - - IF @DropTempTables = 1 - BEGIN - DROP TABLE ##DBPrincipals - DROP TABLE ##DBRoles - DROP TABLE ##DBPermissions - END -END -GO diff --git a/Stored_Procedure/sp_RestoreGene.sql b/Stored_Procedure/sp_RestoreGene.sql deleted file mode 100644 index 7bea9b5d..00000000 --- a/Stored_Procedure/sp_RestoreGene.sql +++ /dev/null @@ -1,1005 +0,0 @@ -USE [master] -GO -IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_RestoreGene') -EXEC ('CREATE PROC dbo.sp_RestoreGene AS SELECT 1') -GO - -/********************************************************************************************* -Restore Generator v4.3 (2014-10-03) -(C) 2012, Paul Brewer - -Feedback: paulbrewer@yahoo.co.uk -Updates: https://paulbrewer.wordpress.com/ - -This procedure queries msdb database backup history and database file details in master. -It builds and returns RESTORE DATABASE commands as it's result set, it does not execute the commands. - -CHANGE LOG: -December 23, 2012 - V1.01 - Release -January 4,2013 - V1.02 - LSN Checks + Bug fix to STOPAT date format -January 11,2013 - V1.03 - SQL Server 2005 compatibility (backup compression problem) & @StandbyMode -January 14, 2013 - V1.04 - WITH COPY and up to 10 striped backup files -January 15, 2013 - V1.05 - Format of constructed restore script, enclose database name in [ ] -February 7, 2013 - V1.06 - Modified WHERE device_type IN (7,102,2) -May 26, 2013 - V1.07 - Various changes for PoSh Driver Script compatibility -October 14, 2013 - V1.08 - Rename parameters, more meaningful names -October 15, 2013 - V2.00 - Add 2nd CTE for striped backup files and remove repeating calls to CTE -November 5, 2013 - V2.01 - Secondary .ndf files only included if @WithMoveDataFiles NOT NULL - - Extended artificial LSN used for sequencing WITH RECOVERY/CHECKDB to 21 characters - - Include database name in results for logging in PoSh -May 23, 2014 - V3.0 - Improved logging and error handling, add 'LogShippingVariableDeclare' parameter - Default is Yes when called from query analysier, set to No when called by PoSh -May 30, 2014 - V3.1 - Restructured CTE, all predicates moved to the CTE -June 6, 2014 - V3.2 - Add 'LogShippingStartTime' parameter for PowerShell script. - To skip subsequent full and diff backups when restoring Logs in PoSh log shipping mode - - Add 'Target Restore Database Name' parameter, Manuj Bahl suggestion - If restoring a specific database, allows overriding restored name - Probably used in conjunction with a @WithMove override of data and log files to a different folder. - - Add LogShippingLastLSN parameter, used to filter results sent to ps_LogShippingLight -June 10, 2014 - V3.3 - Standardize Log Shipping Parameter Names & make &msg variable declare unique -June 27, 2014 - V3.31 - Diff restore bug fix -July 13, 2014 - V3.32 - Feedback from Tony Davis - Rename framework to memorable name 'RestoreGene' - Paramater for WITH REPLACE -August 5, 2014 - V3.4 - Remove TRY CATCH blocks from log restores and checkdb - - Remove CTE's,use #temp tables, suggested by S.Stresser -August 25, 2014 - V3.5 - goestock suggestion - Include device type 7 for AWS EC2 backups -August 29th, 2014 - V3.6 - Richard found and fixed a problem with variable declare where database name has a space or full stop. -July 28, 2015 - V3.7 - Luke Sarro, modifications for case sensitivity & parameter sniffing -August 28, 2015 - V3.8 - Luke Sarro modifications, recovery fork management. supports forking in recovery plans when constructing a restore script. - Only tested where a single fork exists, IE a restore was done to a historic point in time, with recovery, then subsequent log backups are taken. - When a fork exists the restore script will follow the new path for subsequent differential and log backups taken after the forking point. - If no rbackup forks exist, the procedure works as before. -September 02 2015 - V3.9 - SQLMongo modification to replace hyphens in database name -September 04, 2015 - V4.0 - Domingo modification, check for default backup path = '' -September 29, 2015 - V4.2 - Fixes bug identifying full backups taken after a recovery fork, has introduced code duplication to be removed later but fixes problem -October 3, 2015 - V4.3 - Remove code duplication introduced in V4.2 -********************************************************************************************/ - - -ALTER PROC dbo.sp_RestoreGene -( - @Database SYSNAME = NULL, - @TargetDatabase SYSNAME = NULL, - @WithMoveDataFiles VARCHAR(2000) = NULL, - @WithMoveLogFile VARCHAR(2000) = NULL, - @FromFileFullUNC VARCHAR(2000) = NULL, - @FromFileDiffUNC VARCHAR(2000) = NULL, - @FromFileLogUNC VARCHAR(2000) = NULL, - @StopAt DATETIME = NULL, - @StandbyMode BIT = 0, - @IncludeSystemDBs BIT = 0, - @WithRecovery BIT = 0, - @WithCHECKDB BIT = 0, - @WithReplace BIT = 0, - @UseDefaultDatabaseBackupPath BIT = 0, - @Log_Reference VARCHAR (250) = NULL, - @LogShippingVariableDeclare BIT = 1, - @LogShippingStartTime DATETIME = NULL, - @LogShippingLastLSN VARCHAR(25) = NULL -) -AS -BEGIN - -SET NOCOUNT ON; - --- Avoid Parameter Sniffing Problems -DECLARE @Database_ SYSNAME = @Database, - @TargetDatabase_ SYSNAME = @TargetDatabase, - @WithMoveDataFiles_ VARCHAR(2000) = @WithMoveDataFiles, - @WithMoveLogFile_ VARCHAR(2000) = @WithMoveLogFile, - @FromFileFullUNC_ VARCHAR(2000) = @FromFileFullUNC, - @FromFileDiffUNC_ VARCHAR(2000) = @FromFileDiffUNC, - @FromFileLogUNC_ VARCHAR(2000) = @FromFileLogUNC, - @StopAt_ DATETIME = @StopAt, - @StandbyMode_ BIT = @StandbyMode, - @IncludeSystemDBs_ BIT = @IncludeSystemDBs, - @WithRecovery_ BIT = @WithRecovery, - @WithCHECKDB_ BIT = @WithCHECKDB, - @WithReplace_ BIT = @WithReplace, - @UseDefaultDatabaseBackupPath_ BIT = @UseDefaultDatabaseBackupPath, - @Log_Reference_ VARCHAR (250) = @Log_Reference, - @LogShippingVariableDeclare_ BIT = @LogShippingVariableDeclare, - @LogShippingStartTime_ DATETIME = @LogShippingStartTime, - @LogShippingLastLSN_ VARCHAR(25) = @LogShippingLastLSN - --- Defaults Recovery Point Times -IF ISNULL(@StopAt_,'') = '' - SET @StopAt_ = GETDATE(); - -IF ISNULL(@LogShippingStartTime_,'') = '' - SET @LogShippingStartTime_ = @StopAt_; - --- Default written to the SQL Server Error Log -IF ISNULL(@Log_Reference_,'') = '' - SET @Log_Reference_ = 'sp_RestoreGene - Recovery in Progress'; - --- Allow override of restored database name only if working with a specific database -IF @TargetDatabase_ IS NOT NULL AND @Database_ IS NULL - SET @TargetDatabase_ = NULL; - --- ps_LogShippingLight - Filtered Results -IF ISNULL(@LogShippingLastLSN_,'') = '' - SET @LogShippingLastLSN_ = '-1'; - --- Backup file locations defaulted to '' by ps_RestoreGene -IF @FromFileFullUNC_ = '' - SET @FromFileFullUNC_ = NULL; - -IF @FromFileDiffUNC_ = '' - SET @FromFileDiffUNC_ = NULL; - -IF @FromFileLogUNC_ = '' - SET @FromFileLogUNC_ = NULL; - --- Environment Preparation -IF OBJECT_ID('tempdb..#CTE') IS NOT NULL - DROP TABLE #CTE; - -IF OBJECT_ID('tempdb..#Stripes') IS NOT NULL - DROP TABLE #Stripes; - --- Backup forking -IF OBJECT_ID('tempdb..#BackupFork') IS NOT NULL - DROP TABLE #BackupFork; - -SELECT rf1.database_name, MAX(database_backup_lsn) database_backup_lsn, MAX(fork_point_lsn) fork_point_lsn, MAX(last_lsn) last_lsn -INTO #BackupFork -FROM msdb.dbo.backupset rf1 -INNER JOIN -( - SELECT database_name, MAX(backup_finish_date) AS backup_finish_date - FROM msdb.dbo.backupset - WHERE backup_start_date <= @LogShippingStartTime_ - AND fork_point_lsn IS NULL - GROUP BY database_name -) rf2 - ON rf1.database_name = rf2.database_name - -WHERE fork_point_lsn IS NOT NULL -AND rf1.backup_start_date <= @LogShippingStartTime_ -AND rf1.backup_finish_date > rf2.backup_finish_date -GROUP BY rf1.database_name; - -CREATE INDEX IDX_BackupFork ON #BackupFork(database_name); - - --------------------------------------------------------------- --- CTE1 Full Backup UNION Differential Backup UNION Log Backup --------------------------------------------------------------- -WITH CTE -( - database_name - ,current_compatibility_level - ,last_lsn - ,current_is_read_only - ,current_state_desc - ,current_recovery_model_desc - ,has_backup_checksums - ,backup_size - ,[type] - ,backupmediasetid - ,family_sequence_number - ,backupstartdate - ,physical_device_name - ,position -) -AS -( - --------------------------------------------------------------- --- Full backup - Most current immediately before @LogShippingStartTime_ -SELECT - bs.database_name - ,d.[compatibility_level] AS current_compatibility_level - ,bs.last_lsn - ,d.[is_read_only] AS current_is_read_only - ,d.[state_desc] AS current_state_desc - ,d.[recovery_model_desc] current_recovery_model_desc - ,bs.has_backup_checksums - ,bs.backup_size AS backup_size - ,'D' AS [type] - ,bs.media_set_id AS backupmediasetid - ,mf.family_sequence_number - ,x.backup_start_date AS backupstartdate - ,mf.physical_device_name - ,bs.position -FROM msdb.dbo.backupset bs - -INNER JOIN sys.databases d - ON bs.database_name = d.name - -INNER JOIN -( - SELECT - a.database_name - ,MAX(a.backup_start_date) backup_start_date - FROM msdb.dbo.backupset a - JOIN msdb.dbo.backupmediafamily b - ON a.media_set_id = b.media_set_id - - LEFT OUTER JOIN #BackupFork c - ON c.database_name = a.database_name - - WHERE a.[type] = 'D' - AND device_type IN (7,102,2) - AND a.is_copy_only = 0 - AND a.backup_start_date <= @LogShippingStartTime_ - - -- Recovery Forking - AND ISNULL(c.fork_point_lsn,a.database_backup_lsn) >= a.database_backup_lsn - AND ((c.fork_point_lsn IS NOT NULL AND a.database_backup_lsn < c.database_backup_lsn) OR c.fork_point_lsn IS NULL) - - GROUP BY a.database_name - -) x - ON x.database_name = bs.database_name - AND x.backup_start_date = bs.backup_start_date - -JOIN msdb.dbo.backupmediafamily mf - ON mf.media_set_id = bs.media_set_id - AND mf.family_sequence_number Between bs.first_family_number And bs.last_family_number - -WHERE bs.type = 'D' -AND mf.physical_device_name NOT IN ('Nul', 'Nul:') - -UNION - --------------------------------------------------------------- --- Differential backup, most current immediately before @StopAt_ -SELECT - bs.database_name - ,d.[compatibility_level] AS current_compatibility_level - ,bs.last_lsn - ,d.[is_read_only] AS current_is_read_only - ,d.[state_desc] AS current_state_desc - ,d.[recovery_model_desc] current_recovery_model_desc - ,bs.has_backup_checksums - ,bs.backup_size AS backup_size - ,'I' AS [type] - ,bs.media_set_id AS backupmediasetid - ,mf.family_sequence_number - ,x.backup_start_date AS backupstartdate - ,mf.physical_device_name - ,bs.position -FROM msdb.dbo.backupset bs - -INNER JOIN sys.databases d - ON bs.database_name = d.name - - -INNER JOIN -- Last Full in recovery fork before STOPAT -( --------------------------------------------- - SELECT - a.database_name - ,MAX(a.backup_start_date) backup_start_date - FROM msdb.dbo.backupset a - JOIN msdb.dbo.backupmediafamily b - ON a.media_set_id = b.media_set_id - - LEFT OUTER JOIN #BackupFork c - ON c.database_name = a.database_name - - WHERE a.[type] = 'D' - AND device_type IN (7,102,2) - AND a.is_copy_only = 0 - AND a.backup_start_date <= @LogShippingStartTime_ - - -- Recovery Forking - AND ISNULL(c.fork_point_lsn,a.database_backup_lsn) >= a.database_backup_lsn - AND ((c.fork_point_lsn IS NOT NULL AND a.database_backup_lsn < c.database_backup_lsn) OR c.fork_point_lsn IS NULL) - - GROUP BY a.database_name --------------------------------------------- -) y - ON y.database_name = bs.database_name - -INNER JOIN -- Last Diff before STOPAT -( - SELECT - a.database_name - ,MAX(backup_start_date) backup_start_date - FROM msdb.dbo.backupset a - JOIN msdb.dbo.backupmediafamily b - ON a.media_set_id = b.media_set_id - - LEFT OUTER JOIN #BackupFork c - ON c.database_name = a.database_name - - WHERE a.[type] = 'I' - AND device_type IN (7,102,2) - AND a.is_copy_only = 0 - AND a.backup_start_date <= ISNULL(@StopAt_,GETDATE()) - AND a.database_backup_lsn = ISNULL(c.database_backup_lsn,a.database_backup_lsn ) - AND a.last_lsn <= ISNULL(c.fork_point_lsn, a.last_lsn) - GROUP BY a.database_name - -) x - ON x.database_name = bs.database_name - AND x.backup_start_date = bs.backup_start_date - - -INNER JOIN msdb.dbo.backupmediafamily mf - ON mf.media_set_id = bs.media_set_id - AND mf.family_sequence_number Between bs.first_family_number And bs.last_family_number - -WHERE bs.type = 'I' -AND mf.physical_device_name NOT IN ('Nul', 'Nul:') -AND x.backup_start_date > y.backup_start_date -AND @StopAt_ = @LogShippingStartTime_ - -UNION - --------------------------------------------------------------- --- Log file backups - after 1st full / before @StopAt_ -SELECT - bs.database_name - ,d.[compatibility_level] AS current_compatibility_level - ,bs.last_lsn - ,d.[is_read_only] AS current_is_read_only - ,d.[state_desc] AS current_state_desc - ,d.[recovery_model_desc] current_recovery_model_desc - ,bs.has_backup_checksums - ,bs.backup_size AS backup_size - ,'L' AS [type] - ,bs.media_set_id AS backupmediasetid - ,mf.family_sequence_number - ,bs.backup_start_date as backupstartdate - ,mf.physical_device_name - ,bs.position - -FROM msdb.dbo.backupset bs - -INNER JOIN sys.databases d - ON bs.database_name = d.name - -INNER JOIN msdb.dbo.backupmediafamily mf - ON mf.media_set_id = bs.media_set_id - AND mf.family_sequence_number Between bs.first_family_number And bs.last_family_number - -INNER JOIN -- After the selected full backup -( - SELECT - a.database_name - ,MAX(a.backup_start_date) backup_start_date - FROM msdb.dbo.backupset a - JOIN msdb.dbo.backupmediafamily b - ON a.media_set_id = b.media_set_id - - LEFT OUTER JOIN #BackupFork c - ON c.database_name = a.database_name - - WHERE a.[type] = 'D' - AND device_type IN (7,102,2) - AND a.is_copy_only = 0 - AND a.backup_start_date <= @LogShippingStartTime_ - - -- Recovery Forking - AND ISNULL(c.fork_point_lsn,a.database_backup_lsn) >= a.database_backup_lsn - AND ((c.fork_point_lsn IS NOT NULL AND a.database_backup_lsn < c.database_backup_lsn) OR c.fork_point_lsn IS NULL) - - GROUP BY a.database_name -) y - ON bs.database_name = y.database_name - -LEFT OUTER JOIN #BackupFork r - ON r.database_name = bs.database_name - -LEFT OUTER JOIN -- Select the first log file after STOPAT -( - SELECT DISTINCT x.database_name, database_backup_lsn, - CASE WHEN y.last_Log_After_StopAt IS NULL THEN CONVERT(datetime, '31 Dec 2050') ELSE y.last_Log_After_StopAt END AS last_Log_After_StopAt - FROM msdb.dbo.backupset x - LEFT JOIN - ( - SELECT - database_name - ,MIN(backup_start_date) last_Log_After_StopAt - FROM msdb.dbo.backupset a - JOIN msdb.dbo.backupmediafamily b - ON a.media_set_id = b.media_set_id - WHERE a.[type] = 'L' - AND device_type IN (7,102,2) - AND a.backup_start_date > ISNULL(@StopAt_,'1 Jan, 1900') - GROUP BY database_name - ) y - ON x.database_name = y.database_name -) x - ON bs.database_name = x.database_name - AND bs.database_backup_lsn = ISNULL(r.database_backup_lsn,bs.database_backup_lsn) - -WHERE bs.backup_start_date <= x.last_Log_After_StopAt -- Include 1st log after stop at -AND bs.backup_start_date >= y.backup_start_date -- After last full backup start date -AND bs.database_backup_lsn = ISNULL(r.database_backup_lsn,bs.database_backup_lsn) -- Recovery Fork -AND NOT (bs.first_lsn < ISNULL(r.fork_point_lsn,'99999999999999999') AND bs.last_lsn > ISNULL(r.fork_point_lsn,'00000000000000000') AND bs.last_lsn <> ISNULL(r.last_lsn,bs.last_lsn)) - - -AND mf.physical_device_name NOT IN ('Nul', 'Nul:') -AND bs.type = 'L' -AND device_type IN (7,102,2) -) - -SELECT * INTO #CTE FROM CTE; -CREATE INDEX IDX_CTE ON #CTE(database_name); - --------------------------------------------------------------- --- CTE2 Optionally, striped backup file details --------------------------------------------------------------- -WITH Stripes -( - database_name, - backupmediasetid, - family_sequence_number, - last_lsn, - S2_pdn, - S3_pdn, - S4_pdn, - S5_pdn, - S6_pdn, - S7_pdn, - S8_pdn, - S9_pdn, - S10_pdn -) -AS -( -SELECT - Stripe1.database_name, - Stripe1.backupmediasetid, - Stripe1.family_sequence_number, - Stripe1.last_lsn, - Stripe2.physical_device_name AS S2_pdn, - Stripe3.physical_device_name AS S3_pdn, - Stripe4.physical_device_name AS S4_pdn, - Stripe5.physical_device_name AS S5_pdn, - Stripe6.physical_device_name AS S6_pdn, - Stripe7.physical_device_name AS S7_pdn, - Stripe8.physical_device_name AS S8_pdn, - Stripe9.physical_device_name AS S9_pdn, - Stripe10.physical_device_name AS S10_pdn -FROM #CTE AS Stripe1 - -LEFT OUTER JOIN #CTE AS Stripe2 - ON Stripe2.database_name = Stripe1.database_name - AND Stripe2.backupmediasetid = Stripe1.backupmediasetid - AND Stripe2.family_sequence_number = 2 - -LEFT OUTER JOIN #CTE AS Stripe3 - ON Stripe3.database_name = Stripe1.database_name - AND Stripe3.backupmediasetid = Stripe1.backupmediasetid - AND Stripe3.family_sequence_number = 3 - -LEFT OUTER JOIN #CTE AS Stripe4 - ON Stripe4.database_name = Stripe1.database_name - AND Stripe4.backupmediasetid = Stripe1.backupmediasetid - AND Stripe4.family_sequence_number = 4 - -LEFT OUTER JOIN #CTE AS Stripe5 - ON Stripe5.database_name = Stripe1.database_name - AND Stripe5.backupmediasetid = Stripe1.backupmediasetid - AND Stripe5.family_sequence_number = 5 - -LEFT OUTER JOIN #CTE AS Stripe6 - ON Stripe6.database_name = Stripe1.database_name - AND Stripe6.backupmediasetid = Stripe1.backupmediasetid - AND Stripe6.family_sequence_number = 6 - -LEFT OUTER JOIN #CTE AS Stripe7 - ON Stripe7.database_name = Stripe1.database_name - AND Stripe7.backupmediasetid = Stripe1.backupmediasetid - AND Stripe7.family_sequence_number = 7 - -LEFT OUTER JOIN #CTE AS Stripe8 - ON Stripe8.database_name = Stripe1.database_name - AND Stripe8.backupmediasetid = Stripe1.backupmediasetid - AND Stripe8.family_sequence_number = 8 - -LEFT OUTER JOIN #CTE AS Stripe9 - ON Stripe9.database_name = Stripe1.database_name - AND Stripe9.backupmediasetid = Stripe1.backupmediasetid - AND Stripe9.family_sequence_number = 9 - -LEFT OUTER JOIN #CTE AS Stripe10 - ON Stripe10.database_name = Stripe1.database_name - AND Stripe10.backupmediasetid = Stripe1.backupmediasetid - AND Stripe10.family_sequence_number = 10 -) - -SELECT * INTO #Stripes FROM Stripes; - -CREATE INDEX IDX_Stripes ON #Stripes(database_name); - --------------------------------------------------------------- --- Results, T-SQL RESTORE commands, below are based on CTE's above --------------------------------------------------------------- - -SELECT - a.Command AS TSQL, - CONVERT(nvarchar(30), a.backupstartdate, 126) - AS BackupDate, - a.BackupDevice, - a.last_lsn, - a.database_name , - --ROW_NUMBER() OVER(ORDER BY database_name, Sequence, last_lsn) AS SortSequence - ROW_NUMBER() OVER(ORDER BY database_name, Sequence, a.backupstartdate) AS SortSequence -FROM -( - --------------------------------------------------------------- --- Most recent full backup --------------------------------------------------------------- - -SELECT - ';RESTORE DATABASE [' + CASE ISNULL(@TargetDatabase_,'') WHEN '' THEN d.[name] ELSE @TargetDatabase_ END + ']' + SPACE(1) + - 'FROM DISK = N' + '''' + - CASE ISNULL(@FromFileFullUNC_,'Actual') - WHEN 'Actual' THEN #CTE.physical_device_name - ELSE @FromFileFullUNC_ + SUBSTRING(#CTE.physical_device_name,LEN(#CTE.physical_device_name) - CHARINDEX('\',REVERSE(#CTE.physical_device_name),1) + 2,CHARINDEX('\',REVERSE(#CTE.physical_device_name),1) + 1) - END + '''' + SPACE(1) + - - -- Striped backup files - CASE ISNULL(#Stripes.S2_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S2_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S2_pdn,LEN(#Stripes.S2_pdn) - CHARINDEX('\',REVERSE(#Stripes.S2_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S2_pdn),1) + 1) END + '''' - END + - - CASE ISNULL(#Stripes.S3_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S3_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S3_pdn,LEN(#Stripes.S3_pdn) - CHARINDEX('\',REVERSE(#Stripes.S3_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S3_pdn),1) + 1) END + '''' - END + - - CASE ISNULL(#Stripes.S4_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S4_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S4_pdn,LEN(#Stripes.S4_pdn) - CHARINDEX('\',REVERSE(#Stripes.S4_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S4_pdn),1) + 1) END + '''' - END + - - CASE ISNULL(#Stripes.S5_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S5_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S5_pdn,LEN(#Stripes.S5_pdn) - CHARINDEX('\',REVERSE(#Stripes.S5_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S5_pdn),1) + 1) END + '''' - END + - - CASE ISNULL(#Stripes.S6_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S6_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S6_pdn,LEN(#Stripes.S6_pdn) - CHARINDEX('\',REVERSE(#Stripes.S6_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S6_pdn),1) + 1) END + '''' - END + - - CASE ISNULL(#Stripes.S7_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S7_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S7_pdn,LEN(#Stripes.S7_pdn) - CHARINDEX('\',REVERSE(#Stripes.S7_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S7_pdn),1) + 1) END + '''' - END + - - CASE ISNULL(#Stripes.S8_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S8_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S8_pdn,LEN(#Stripes.S8_pdn) - CHARINDEX('\',REVERSE(#Stripes.S8_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S8_pdn),1) + 1) END + '''' - END + - - CASE ISNULL(#Stripes.S9_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S9_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S9_pdn,LEN(#Stripes.S9_pdn) - CHARINDEX('\',REVERSE(#Stripes.S9_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S9_pdn),1) + 1) END + '''' - END + - - CASE ISNULL(#Stripes.S10_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileFullUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S10_pdn ELSE @FromFileFullUNC_ + SUBSTRING(#Stripes.S10_pdn,LEN(#Stripes.S10_pdn) - CHARINDEX('\',REVERSE(#Stripes.S10_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S10_pdn),1) + 1) END + '''' - END + - - ' WITH ' + CASE ISNULL(@WithReplace_,0) WHEN 1 THEN 'REPLACE, ' ELSE '' END + 'FILE = ' + CAST(#CTE.position AS VARCHAR(5)) + ',' + - CASE #CTE.has_backup_checksums WHEN 1 THEN 'CHECKSUM, ' ELSE ' ' END + - - CASE @StandbyMode_ WHEN 0 THEN 'NORECOVERY,' ELSE 'STANDBY =N' + '''' + ISNULL(@FromFileFullUNC_,SUBSTRING(#CTE.physical_device_name,1,LEN(#CTE.physical_device_name) - CHARINDEX('\',REVERSE(#CTE.physical_device_name)))) + '\' + d.name + '_ROLLBACK_UNDO.bak ' + '''' + ',' END + SPACE(1) + - - 'STATS=10,' + SPACE(1) + - 'MOVE N' + '''' + x.LogicalName + '''' + ' TO ' + - '''' + - CASE ISNULL(@WithMoveDataFiles_,'Actual') - WHEN 'Actual' THEN x.PhysicalName - ELSE @WithMoveDataFiles_ + SUBSTRING(x.PhysicalName,LEN(x.PhysicalName) - CHARINDEX('\',REVERSE(x.PhysicalName),1) + 2,CHARINDEX('\',REVERSE(x.PhysicalName),1) + 1) - END + '''' + ',' + SPACE(1) + - - 'MOVE N' + '''' + y.LogicalName + '''' + ' TO ' + - '''' + - CASE ISNULL(@WithMoveLogFile_ ,'Actual') - WHEN 'Actual' THEN y.PhysicalName - ELSE @WithMoveLogFile_ + SUBSTRING(y.PhysicalName,LEN(y.PhysicalName) - CHARINDEX('\',REVERSE(y.PhysicalName),1) + 2,CHARINDEX('\',REVERSE(y.PhysicalName),1) + 1) - END + '''' AS Command, - 1 AS Sequence, - d.name AS database_name, - #CTE.physical_device_name AS BackupDevice, - #CTE.backupstartdate, - #CTE.backup_size, - #CTE.last_lsn - -FROM sys.databases d - -JOIN -( - SELECT - DB_NAME(mf.database_id) AS name - ,mf.Physical_Name AS PhysicalName - ,mf.Name AS LogicalName - FROM sys.master_files mf - WHERE type_desc = 'ROWS' - AND mf.file_id = 1 -) x - ON d.name = x.name - -JOIN -( - SELECT - DB_NAME(mf.database_id) AS name, type_desc - ,mf.Physical_Name PhysicalName - ,mf.Name AS LogicalName - FROM sys.master_files mf - WHERE type_desc = 'LOG' -) y - ON d.name = y.name - -LEFT OUTER JOIN #CTE - ON #CTE.database_name = d.name - AND #CTE.family_sequence_number = 1 - -JOIN #Stripes - ON #Stripes.database_name = d.name - AND #Stripes.backupmediasetid = #CTE.backupmediasetid - AND #Stripes.last_lsn = #CTE.last_lsn - -WHERE #CTE.[type] = 'D' -AND #CTE.family_sequence_number = 1 - --------------------------------------------------------------- --- Most recent differential backup --------------------------------------------------------------- -UNION - -SELECT - ';RESTORE DATABASE [' + CASE ISNULL(@TargetDatabase_,'') WHEN '' THEN d.[name] ELSE @TargetDatabase_ END + ']' + SPACE(1) + - 'FROM DISK = N' + '''' + - CASE ISNULL(@FromFileDiffUNC_,'Actual') - WHEN 'Actual' THEN #CTE.physical_device_name - ELSE @FromFileDiffUNC_ + SUBSTRING(#CTE.physical_device_name,LEN(#CTE.physical_device_name) - CHARINDEX('\',REVERSE(#CTE.physical_device_name),1) + 2,CHARINDEX('\',REVERSE(#CTE.physical_device_name),1) + 1) - END + '''' + SPACE(1) + - - -- Striped backup files - CASE ISNULL(#Stripes.S2_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S2_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S2_pdn,LEN(#Stripes.S2_pdn) - CHARINDEX('\',REVERSE(#Stripes.S2_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S2_pdn),1) + 1) END + '''' - END + - - CASE ISNULL(#Stripes.S3_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S3_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S3_pdn,LEN(#Stripes.S3_pdn) - CHARINDEX('\',REVERSE(#Stripes.S3_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S3_pdn),1) + 1) END + '''' - END + - - CASE ISNULL(#Stripes.S4_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S4_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S4_pdn,LEN(#Stripes.S4_pdn) - CHARINDEX('\',REVERSE(#Stripes.S4_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S4_pdn),1) + 1) END + '''' - END + - - CASE ISNULL(#Stripes.S5_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S5_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S5_pdn,LEN(#Stripes.S5_pdn) - CHARINDEX('\',REVERSE(#Stripes.S5_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S5_pdn),1) + 1) END + '''' - END + - - CASE ISNULL(#Stripes.S6_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S6_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S6_pdn,LEN(#Stripes.S6_pdn) - CHARINDEX('\',REVERSE(#Stripes.S6_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S6_pdn),1) + 1) END + '''' - END + - - CASE ISNULL(#Stripes.S7_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S7_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S7_pdn,LEN(#Stripes.S7_pdn) - CHARINDEX('\',REVERSE(#Stripes.S7_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S7_pdn),1) + 1) END + '''' - END + - - CASE ISNULL(#Stripes.S8_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S8_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S8_pdn,LEN(#Stripes.S8_pdn) - CHARINDEX('\',REVERSE(#Stripes.S8_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S8_pdn),1) + 1) END + '''' - END + - - CASE ISNULL(#Stripes.S9_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S9_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S9_pdn,LEN(#Stripes.S9_pdn) - CHARINDEX('\',REVERSE(#Stripes.S9_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S9_pdn),1) + 1) END + '''' - END + - - CASE ISNULL(#Stripes.S10_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileDiffUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S10_pdn ELSE @FromFileDiffUNC_ + SUBSTRING(#Stripes.S10_pdn,LEN(#Stripes.S10_pdn) - CHARINDEX('\',REVERSE(#Stripes.S10_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S10_pdn),1) + 1) END + '''' - END + - - ' WITH FILE = ' + CAST(#CTE.position AS VARCHAR(5)) + ',' + - CASE #CTE.has_backup_checksums WHEN 1 THEN 'CHECKSUM, ' ELSE ' ' END + - - CASE @StandbyMode_ WHEN 0 THEN 'NORECOVERY,' ELSE 'STANDBY =N' + '''' + ISNULL(@FromFileFullUNC_,SUBSTRING(#CTE.physical_device_name,1,LEN(#CTE.physical_device_name) - CHARINDEX('\',REVERSE(#CTE.physical_device_name)))) + '\' + d.name + '_ROLLBACK_UNDO.bak ' + '''' + ',' END + SPACE(1) + - - 'STATS=10,' + SPACE(1) + - 'MOVE N' + '''' + x.LogicalName + '''' + ' TO ' + - '''' + - CASE ISNULL(@WithMoveDataFiles_,'Actual') - WHEN 'Actual' THEN x.PhysicalName - ELSE @WithMoveDataFiles_ + SUBSTRING(x.PhysicalName,LEN(x.PhysicalName) - CHARINDEX('\',REVERSE(x.PhysicalName),1) + 2,CHARINDEX('\',REVERSE(x.PhysicalName),1) + 1) - END + '''' + ',' + SPACE(1) + - - 'MOVE N' + '''' + y.LogicalName + '''' + ' TO ' + - '''' + - CASE ISNULL(@WithMoveLogFile_ ,'Actual') - WHEN 'Actual' THEN y.PhysicalName - ELSE @WithMoveLogFile_ + SUBSTRING(y.PhysicalName,LEN(y.PhysicalName) - CHARINDEX('\',REVERSE(y.PhysicalName),1) + 2,CHARINDEX('\',REVERSE(y.PhysicalName),1) + 1) - END + '''' AS Command, - 32769/2 AS Sequence, - d.name AS database_name, - #CTE.physical_device_name AS BackupDevice, - #CTE.backupstartdate, - #CTE.backup_size, - #CTE.last_lsn - -FROM sys.databases d - -JOIN #CTE -ON #CTE.database_name = d.name -AND #CTE.family_sequence_number = 1 - -LEFT OUTER JOIN #Stripes -ON #Stripes.database_name = d.name -AND #Stripes.backupmediasetid = #CTE.backupmediasetid -AND #Stripes.last_lsn = #CTE.last_lsn - -INNER JOIN -( - SELECT - DB_NAME(mf.database_id) AS name - ,mf.Physical_Name AS PhysicalName - ,mf.Name AS LogicalName - FROM sys.master_files mf - WHERE type_desc = 'ROWS' - AND mf.file_id = 1 -) x - ON d.name = x.name - -JOIN -( - SELECT - DB_NAME(mf.database_id) AS name, type_desc - ,mf.Physical_Name PhysicalName - ,mf.Name AS LogicalName - FROM sys.master_files mf - WHERE type_desc = 'LOG' -) y - ON d.name = y.name - -WHERE #CTE.[type] = 'I' -AND #CTE.family_sequence_number = 1 - --------------------------------------------------------------- -UNION -- Log backups taken since most recent full or diff --------------------------------------------------------------- - -SELECT - ';BEGIN TRY RESTORE LOG [' + CASE ISNULL(@TargetDatabase_,'') WHEN '' THEN d.[name] ELSE @TargetDatabase_ END + ']' + SPACE(1) + - 'FROM DISK = N' + '''' + --#CTE.physical_device_name + '''' + SPACE(1) + - CASE ISNULL(@FromFileLogUNC_,'Actual') - WHEN 'Actual' THEN #CTE.physical_device_name - ELSE @FromFileLogUNC_ + SUBSTRING(#CTE.physical_device_name,LEN(#CTE.physical_device_name) - CHARINDEX('\',REVERSE(#CTE.physical_device_name),1) + 2,CHARINDEX('\',REVERSE(#CTE.physical_device_name),1) + 1) - END + '''' + - - -- Striped backup files - CASE ISNULL(#Stripes.S2_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S2_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S2_pdn,LEN(#Stripes.S2_pdn) - CHARINDEX('\',REVERSE(#Stripes.S2_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S2_pdn),1) + 1) END + '''' - END + - - CASE ISNULL(#Stripes.S3_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S3_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S3_pdn,LEN(#Stripes.S3_pdn) - CHARINDEX('\',REVERSE(#Stripes.S3_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S3_pdn),1) + 1) END + '''' - END + - - CASE ISNULL(#Stripes.S4_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S4_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S4_pdn,LEN(#Stripes.S4_pdn) - CHARINDEX('\',REVERSE(#Stripes.S4_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S4_pdn),1) + 1) END + '''' - END + - - CASE ISNULL(#Stripes.S5_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S5_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S5_pdn,LEN(#Stripes.S5_pdn) - CHARINDEX('\',REVERSE(#Stripes.S5_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S5_pdn),1) + 1) END + '''' - END + - - CASE ISNULL(#Stripes.S6_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S6_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S6_pdn,LEN(#Stripes.S6_pdn) - CHARINDEX('\',REVERSE(#Stripes.S6_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S6_pdn),1) + 1) END + '''' - END + - - CASE ISNULL(#Stripes.S7_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S7_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S7_pdn,LEN(#Stripes.S7_pdn) - CHARINDEX('\',REVERSE(#Stripes.S7_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S7_pdn),1) + 1) END + '''' - END + - - CASE ISNULL(#Stripes.S8_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S8_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S8_pdn,LEN(#Stripes.S8_pdn) - CHARINDEX('\',REVERSE(#Stripes.S8_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S8_pdn),1) + 1) END + '''' - END + - - CASE ISNULL(#Stripes.S9_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S9_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S9_pdn,LEN(#Stripes.S9_pdn) - CHARINDEX('\',REVERSE(#Stripes.S9_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S9_pdn),1) + 1) END + '''' - END + - - CASE ISNULL(#Stripes.S10_pdn,'') - WHEN '' THEN '' - ELSE ', DISK = N' + '''' + CASE ISNULL(@FromFileLogUNC_,'Actual') WHEN 'Actual' THEN #Stripes.S10_pdn ELSE @FromFileLogUNC_ + SUBSTRING(#Stripes.S10_pdn,LEN(#Stripes.S10_pdn) - CHARINDEX('\',REVERSE(#Stripes.S10_pdn),1) + 2,CHARINDEX('\',REVERSE(#Stripes.S10_pdn),1) + 1) END + '''' - END + - - CASE @StandbyMode_ WHEN 0 THEN ' WITH NORECOVERY,' ELSE ' WITH STANDBY =N' + '''' + ISNULL(@FromFileFullUNC_,SUBSTRING(#CTE.physical_device_name,1,LEN(#CTE.physical_device_name) - CHARINDEX('\',REVERSE(#CTE.physical_device_name)))) + '\' + d.name + '_ROLLBACK_UNDO.bak ' + '''' + ',' END + SPACE(1) + - - CASE #CTE.has_backup_checksums WHEN 1 THEN ' CHECKSUM, ' ELSE ' ' END + - - + 'FILE = ' + CAST(#CTE.position AS VARCHAR(5)) + - ' ,STOPAT = ' + '''' + CONVERT(VARCHAR(21),@StopAt_,120) + '''' + - ' ,MOVE N' + '''' + x2.LogicalName + '''' + ' TO ' + - '''' + - CASE ISNULL(@WithMoveDataFiles_,'Actual') - WHEN 'Actual' THEN x2.PhysicalName - ELSE @WithMoveDataFiles_ + SUBSTRING(x2.PhysicalName,LEN(x2.PhysicalName) - CHARINDEX('\',REVERSE(x2.PhysicalName),1) + 2,CHARINDEX('\',REVERSE(x2.PhysicalName),1) + 1) - END + '''' + ',' + SPACE(1) + - - ' MOVE N' + '''' + y1.LogicalName + '''' + ' TO ' + - '''' + - CASE ISNULL(@WithMoveLogFile_ ,'Actual') - WHEN 'Actual' THEN y1.PhysicalName - ELSE @WithMoveLogFile_ + SUBSTRING(y1.PhysicalName,LEN(y1.PhysicalName) - CHARINDEX('\',REVERSE(y1.PhysicalName),1) + 2,CHARINDEX('\',REVERSE(y1.PhysicalName),1) + 1) - END + '''' + 'END TRY BEGIN CATCH PRINT ' + '''' + 'Transaction Log File Restore Exclusion - Check Recovery Sequence.' + '''' + ' END CATCH;' AS Command, - 32769 AS Sequence, - d.name AS database_name, - #CTE.physical_device_name AS BackupDevice, - #CTE.backupstartdate, - #CTE.backup_size, - #CTE.last_lsn - -FROM sys.databases d - -INNER JOIN -( - SELECT - DB_NAME(mf.database_id) AS name - ,mf.Physical_Name AS PhysicalName - ,mf.Name AS LogicalName - FROM sys.master_files mf - WHERE type_desc = 'ROWS' - AND mf.file_id = 1 -) x2 -ON d.name = x2.name - -INNER JOIN -( - SELECT - DB_NAME(mf.database_id) AS name, type_desc - ,mf.Physical_Name PhysicalName - ,mf.Name AS LogicalName - FROM sys.master_files mf - WHERE type_desc = 'LOG' -) y1 - ON d.name = y1.name - -INNER JOIN #CTE - ON #CTE.database_name = d.name - AND #CTE.family_sequence_number = 1 - -LEFT OUTER JOIN #Stripes - ON #Stripes.database_name = d.name - AND #Stripes.backupmediasetid = #CTE.backupmediasetid - AND #Stripes.last_lsn = #CTE.last_lsn - -LEFT OUTER JOIN -( - SELECT database_name, MAX(last_lsn) last_lsn - FROM #CTE - WHERE [type] = 'I' - GROUP BY database_name -) after_diff - ON after_diff.database_name = #CTE.database_name - - -WHERE #CTE.[type] = 'L' -AND #CTE.family_sequence_number = 1 -AND #CTE.last_lsn > ISNULL(after_diff.last_lsn,'0') - --------------------------------------------------------------- -UNION -- Declare @msg_ variable --------------------------------------------------------------- -SELECT --- '; DECLARE @msg_' + d.name + ' VARCHAR(1000)' AS Command, - ';DECLARE @msg_' + REPLACE(REPLACE(REPLACE(d.name,' ','_'),'.','_'),'-','_') + ' VARCHAR(1000)' AS Command, - 0 AS Sequence, - d.name AS database_name, - '' AS BackupDevice, - GETDATE() AS backupstartdate, - #CTE.backup_size, - '0' AS last_lsn - -FROM sys.databases d - -JOIN #CTE -ON #CTE.database_name = d.name - -WHERE #CTE.[type] = 'D' -AND @LogShippingVariableDeclare_ = 1 - --------------------------------------------------------------- -UNION -- Restore WITH RECOVERY --------------------------------------------------------------- -SELECT - ';SET @msg_' + REPLACE(REPLACE(REPLACE(d.name,' ','_'),'.','_'),'-','_') + ' = ' + '''' + @Log_Reference_ + '''' + '; RAISERROR (@msg_' + REPLACE(REPLACE(REPLACE(d.name,' ','_'),'.','_'),'-','_') + ',0,0) WITH LOG' + ';RESTORE DATABASE [' + CASE ISNULL(@TargetDatabase_,'') WHEN '' THEN d.[name] ELSE @TargetDatabase_ END + ']' + SPACE(1) + 'WITH RECOVERY' AS Command, - 32771 AS Sequence, - d.name AS database_name, - '' AS BackupDevice, - GETDATE() AS backupstartdate, - #CTE.backup_size, - '999999999999999999998' AS last_lsn - -FROM sys.databases d - -JOIN #CTE -ON #CTE.database_name = d.name - -WHERE #CTE.[type] = 'D' -AND @WithRecovery_ = 1 - --------------------------------------------------------------- -UNION -- CHECKDB --------------------------------------------------------------- -SELECT - ';SET @msg_' + REPLACE(REPLACE(REPLACE(d.name,' ','_'),'.','_'),'-','_') + ' = ' + '''' + @Log_Reference_ + '''' + '; RAISERROR (@msg_' + REPLACE(REPLACE(REPLACE(d.name,' ','_'),'.','_'),'-','_') + ',0,0) WITH LOG' + ';DBCC CHECKDB(' + '''' + CASE ISNULL(@TargetDatabase_,'') WHEN '' THEN d.[name] ELSE @TargetDatabase_ END + '''' + ') WITH NO_INFOMSGS, ALL_ERRORMSGS' AS Command, - 32772 AS Sequence, - d.name AS database_name, - '' AS BackupDevice, - DATEADD(minute,1,GETDATE()) AS backupstartdate, - #CTE.backup_size, - '999999999999999999999' AS last_lsn - -FROM sys.databases d - -JOIN #CTE -ON #CTE.database_name = d.name - -WHERE #CTE.[type] = 'D' -AND @WithCHECKDB_ = 1 -AND @WithRecovery_ = 1 - --------------------------------------------------------------- -UNION -- WITH MOVE secondary data files, allows for up to 32769/2 file groups --------------------------------------------------------------- -SELECT - ', MOVE N' + '''' + b.name + '''' + ' TO N' + '''' + - CASE ISNULL(@WithMoveDataFiles_,'Actual') - WHEN 'Actual' THEN b.physical_name - ELSE @WithMoveDataFiles_ + SUBSTRING(b.Physical_Name,LEN(b.Physical_Name) - CHARINDEX('\',REVERSE(b.Physical_Name),1) + 2,CHARINDEX('\',REVERSE(b.Physical_Name),1) + 1) - END + '''', - b.file_id AS Sequence, - DB_NAME(b.database_id) AS database_name, - 'SECONDARY FULL' AS BackupDevice, - #CTE.backupstartdate, - #CTE.backup_size, - #CTE.last_lsn - -FROM sys.master_files b -INNER JOIN #CTE -ON #CTE.database_name = DB_NAME(b.database_id) - -WHERE #CTE.[type] = 'D' -AND b.type_desc = 'ROWS' -AND b.file_id > 2 -AND @WithMoveDataFiles_ IS NOT NULL --------------------------------------------------------------- -) a --------------------------------------------------------------- - -WHERE a.database_name = ISNULL(@Database_,a.database_name) -AND (@IncludeSystemDBs_ = 1 OR a.database_name NOT IN('master','model','msdb')) -AND a.last_lsn > @LogShippingLastLSN_ - -ORDER BY - database_name, - Sequence, - --last_lsn - backupstartdate - -END; -GO diff --git a/Stored_Procedure/sp_SQLskills_helpindex.sql b/Stored_Procedure/sp_SQLskills_helpindex.sql deleted file mode 100644 index 0cacbb85..00000000 --- a/Stored_Procedure/sp_SQLskills_helpindex.sql +++ /dev/null @@ -1,413 +0,0 @@ -/*============================================================================ - File: sp_SQLskills_helpindex.sql - - Summary: So, what are the included columns?! Do you have a filter? - This is a MODIFIED sp_helpindex script that includes: - - Index IDs - - INCLUDEd columns - - Filtered index columns - - Leaf/tree details for rowstore indexes - - Columns defined for columnstore indexes - Additional details: - - whether or not the index is disabled - - Index usage stats - - Date: February 2016 - - Version: Works on 2008R2 - 2016 (requires: sp_SQLskills_ExposeColsInIndexLevels) ------------------------------------------------------------------------------- - Written by Kimberly L. Tripp, SYSolutions, Inc. - - For more scripts and sample code, check out - http://www.SQLskills.com - - This script is intended only as a supplement to demos and lectures - given by SQLskills instructors. - - THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF - ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED - TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A - PARTICULAR PURPOSE. -============================================================================*/ - -USE [master]; -GO - -IF OBJECTPROPERTY(OBJECT_ID(N'sp_SQLskills_helpindex') - , N'IsProcedure') = 1 - DROP PROCEDURE [dbo].[sp_SQLskills_helpindex]; -GO - -SET ANSI_NULLS ON; -SET QUOTED_IDENTIFIER ON; -GO - -CREATE PROCEDURE [dbo].[sp_SQLskills_helpindex] - @objname nvarchar(776) -- the table to check for indexes -as - --- June 2016: Support for clustered columnstore as well as removing --- errors around other index types (hekaton, XML, spatial, etc.) ---September 2013: Correct the output for columnstore indexes. --- November 2010: Added a column to show if an index is disabled. --- May 2010: Added tree/leaf columns to the output - this requires the --- stored procedure: sp_SQLskills_ExposeColsInIndexLevels --- March 2010: Added index_id to the output (ordered by index_id as well) --- August 2008: Fixed a bug (missing begin/end block) AND I found --- a few other issues that people hadn't noticed (yikes!)! --- April 2008: Updated to add included columns to the output. - - --- See my blog for updates and/or additional information --- http://www.SQLskills.com/blogs/Kimberly (Kimberly L. Tripp) - - set nocount on - - declare @objid int, -- the object id of the table - @indid smallint, -- the index id of an index - @type tinyint, -- the index type - @groupid int, -- the filegroup id of an index - @indname sysname, - @groupname sysname, - @status int, - @keys nvarchar(2126), --Length (16*max_identifierLength)+(15*2)+(16*3) - @inc_columns nvarchar(max), - @inc_Count smallint, - @loop_inc_Count smallint, - @dbname sysname, - @ignore_dup_key bit, - @is_unique bit, - @is_hypothetical bit, - @is_primary_key bit, - @is_unique_key bit, - @is_disabled bit, - @auto_created bit, - @no_recompute bit, - @filter_definition nvarchar(max), - @ColsInTree nvarchar(2126), - @ColsInLeaf nvarchar(max), - @ExecStr nvarchar(max) - - -- Check to see that the object names are local to the current database. - select @dbname = parsename(@objname,3) - if @dbname is null - select @dbname = db_name() - else if @dbname <> db_name() - begin - raiserror(15250,-1,-1) - return (1) - end - - -- Check to see the the table exists and initialize @objid. - select @objid = object_id(@objname) - if @objid is NULL - begin - raiserror(15009,-1,-1,@objname,@dbname) - return (1) - end - - -- OPEN CURSOR OVER INDEXES (skip stats: bug shiloh_51196) - declare ms_crs_ind cursor local static for - select i.index_id, i.[type], i.data_space_id, QUOTENAME(i.name, N']') AS name, - i.ignore_dup_key, i.is_unique, i.is_hypothetical, i.is_primary_key, i.is_unique_constraint, - s.auto_created, s.no_recompute, i.filter_definition, i.is_disabled - from sys.indexes as i - join sys.stats as s - on i.object_id = s.object_id - and i.index_id = s.stats_id - where i.object_id = @objid - open ms_crs_ind - fetch ms_crs_ind into @indid, @type, @groupid, @indname, @ignore_dup_key, @is_unique, @is_hypothetical, - @is_primary_key, @is_unique_key, @auto_created, @no_recompute, @filter_definition, @is_disabled - - -- IF NO INDEX, QUIT - if @@fetch_status < 0 - begin - deallocate ms_crs_ind - raiserror(15472,-1,-1,@objname) -- Object does not have any indexes. - return (0) - end - - -- create temp tables - CREATE TABLE #spindtab - ( - index_name sysname collate database_default NOT NULL, - index_id int, - [type] tinyint, - ignore_dup_key bit, - is_unique bit, - is_hypothetical bit, - is_primary_key bit, - is_unique_key bit, - is_disabled bit, - auto_created bit, - no_recompute bit, - groupname sysname collate database_default NULL, - index_keys nvarchar(2126) collate database_default NULL, -- see @keys above for length descr - filter_definition nvarchar(max), - inc_Count smallint, - inc_columns nvarchar(max), - cols_in_tree nvarchar(2126), - cols_in_leaf nvarchar(max) - ) - - CREATE TABLE #IncludedColumns - ( RowNumber smallint, - [Name] nvarchar(128) - ) - - -- Now check out each index, figure out its type and keys and - -- save the info in a temporary table that we'll print out at the end. - while @@fetch_status >= 0 - begin - -- First we'll figure out what the keys are. - declare @i int, @thiskey nvarchar(131) -- 128+3 - - select @keys = QUOTENAME(index_col(@objname, @indid, 1), N']'), @i = 2 - if (indexkey_property(@objid, @indid, 1, 'isdescending') = 1) - select @keys = @keys + '(-)' - - select @thiskey = QUOTENAME(index_col(@objname, @indid, @i), N']') - if ((@thiskey is not null) and (indexkey_property(@objid, @indid, @i, 'isdescending') = 1)) - select @thiskey = @thiskey + '(-)' - - while (@thiskey is not null ) - begin - select @keys = @keys + ', ' + @thiskey, @i = @i + 1 - select @thiskey = QUOTENAME(index_col(@objname, @indid, @i), N']') - if ((@thiskey is not null) and (indexkey_property(@objid, @indid, @i, 'isdescending') = 1)) - select @thiskey = @thiskey + '(-)' - end - - -- Second, we'll figure out what the included columns are. - select @inc_columns = NULL - - SELECT @inc_Count = count(*) - FROM sys.tables AS tbl - INNER JOIN sys.indexes AS si - ON (si.index_id > 0 - and si.is_hypothetical = 0) - AND (si.object_id=tbl.object_id) - INNER JOIN sys.index_columns AS ic - ON (ic.column_id > 0 - and (ic.key_ordinal > 0 or ic.partition_ordinal = 0 or ic.is_included_column != 0)) - AND (ic.index_id=CAST(si.index_id AS int) AND ic.object_id=si.object_id) - INNER JOIN sys.columns AS clmns - ON clmns.object_id = ic.object_id - and clmns.column_id = ic.column_id - WHERE ic.is_included_column = 1 and - (si.index_id = @indid) and - (tbl.object_id= @objid) - - IF @inc_Count > 0 - BEGIN - DELETE FROM #IncludedColumns - INSERT #IncludedColumns - SELECT ROW_NUMBER() OVER (ORDER BY clmns.column_id) - , clmns.name - FROM sys.tables AS tbl - INNER JOIN sys.indexes AS si - ON (si.index_id > 0 - AND si.is_hypothetical = 0) - AND (si.object_id=tbl.object_id) - INNER JOIN sys.index_columns AS ic - ON (ic.column_id > 0 - AND (ic.key_ordinal > 0 OR ic.partition_ordinal = 0 OR ic.is_included_column != 0)) - AND (ic.index_id=CAST(si.index_id AS int) AND ic.object_id=si.object_id) - INNER JOIN sys.columns AS clmns - ON clmns.object_id = ic.object_id - AND clmns.column_id = ic.column_id - WHERE ic.is_included_column = 1 AND - (si.index_id = @indid) AND - (tbl.object_id= @objid) - - SELECT @inc_columns = QUOTENAME([Name], N']') - FROM #IncludedColumns - WHERE RowNumber = 1 - - SET @loop_inc_Count = 1 - - WHILE @loop_inc_Count < @inc_Count - BEGIN - SELECT @inc_columns = @inc_columns + ', ' + QUOTENAME([Name], N']') - FROM #IncludedColumns WHERE RowNumber = @loop_inc_Count + 1 - SET @loop_inc_Count = @loop_inc_Count + 1 - END - END - - SELECT @groupname = null - - SELECT @groupname = name - FROM sys.data_spaces - WHERE data_space_id = @groupid - - -- Get the column list for the tree and leaf level, for all nonclustered indexes IF - -- the table has a clustered index - - -- Clustered index is non-unique - IF @indid = 1 AND - (SELECT is_unique - FROM sys.indexes - WHERE index_id = 1 - AND object_id = @objid) = 0 - SELECT @ColsInTree = @keys + N', UNIQUIFIER', @ColsInLeaf = N'All columns "included" - the leaf level IS the data row, plus the UNIQUIFIER' - - -- Clustered index AND is unique - IF @indid = 1 AND (SELECT is_unique FROM sys.indexes WHERE index_id = 1 AND object_id = @objid) = 1 - SELECT @ColsInTree = @keys, @ColsInLeaf = N'All columns "included" - the leaf level IS the data row.' - - -- Only run this for nonclustered indexes - IF @indid > 1 - EXEC [sp_SQLskills_ExposeColsInIndexLevels] @objid, @indid, @ColsInTree OUTPUT, @ColsInLeaf OUTPUT - - -- Nonclustered, non-unique index with non-unique clustered ROWSTORE (type = 1) index - IF @indid > 1 AND @is_unique = 0 - AND (SELECT is_unique - FROM sys.indexes - WHERE index_id = 1 AND type = 1 - AND object_id = @objid) = 0 - SELECT @ColsInTree = @ColsInTree + N', UNIQUIFIER', @ColsInLeaf = @ColsInLeaf + N', UNIQUIFIER' - - -- Nonclustered, unique index with non-unique clustered ROWSTORE (type = 1) index - IF @indid > 1 AND @is_unique = 1 - AND (SELECT is_unique - FROM sys.indexes - WHERE index_id = 1 AND type = 1 - AND object_id = @objid) = 0 - SELECT @ColsInLeaf = @ColsInLeaf + N', UNIQUIFIER' - - -- Nonclustered rowstore on a heap - IF (@indid > 1 AND @type = 2) - AND (SELECT COUNT(*) - FROM sys.indexes - WHERE index_id = 1 - AND object_id = @objid) = 0 -- table is a HEAP - BEGIN - IF (@is_unique_key = 0) - SELECT @ColsInTree = @keys + N', RID' - , @ColsInLeaf = @keys + N', RID' + CASE WHEN @inc_columns IS NOT NULL THEN N', ' + @inc_columns ELSE N'' END - - IF (@is_unique_key = 1) - SELECT @ColsInTree = @keys - , @ColsInLeaf = @keys + N', RID' + CASE WHEN @inc_columns IS NOT NULL THEN N', ' + @inc_columns ELSE N'' END - END - - -- INSERT ROW FOR INDEX - - insert into #spindtab values (@indname, @indid, @type, @ignore_dup_key, @is_unique, @is_hypothetical, - @is_primary_key, @is_unique_key, @is_disabled, @auto_created, @no_recompute, @groupname, @keys, @filter_definition, @inc_Count, @inc_columns, @ColsInTree, @ColsInLeaf) - - -- Next index - fetch ms_crs_ind into @indid, @type, @groupid, @indname, @ignore_dup_key, @is_unique, @is_hypothetical, - @is_primary_key, @is_unique_key, @auto_created, @no_recompute, @filter_definition, @is_disabled - end - deallocate ms_crs_ind - - -- DISPLAY THE RESULTS - --- Query by version - IF CONVERT(smallint, SUBSTRING(CONVERT(varchar(50), SERVERPROPERTY('ProductVersion')), 1, 2)) < 16 - - select @ExecStr = - - N'select ' - + N'''index_id'' = index_id, ' - + N'''is_disabled'' = is_disabled, ' - + N'''index_name'' = index_name, ' - + N'''index_description'' = ' - + N' convert(varchar(210), ' --bits 16 off, 1, 2, 16777216 on, located on group ' - + N' case when index_id = 1 and type = 1 then ''clustered'' ' - + N' when index_id = 1 and type = 5 then ''clustered, columnstore'' ' - + N' when index_id > 1 and type = 2 then ''nonclustered'' ' - + N' when index_id > 1 and type = 6 then ''nonclustered, columnstore'' ' - + N' when index_id > 1 and type = 7 then ''nonclustered, HASH'' ' - + N' else ''new index type'' end ' - + N' + case when ignore_dup_key <>0 then '', ignore duplicate keys'' else '''' end ' - + N' + case when is_unique=1 then '', unique'' else '''' end ' - + N' + case when is_hypothetical <>0 then '', hypothetical'' else '''' end ' - + N' + case when is_primary_key <>0 then '', primary key'' else '''' end ' - + N' + case when is_unique_key <>0 then '', unique key'' else '''' end ' - + N' + case when auto_created <>0 then '', auto create'' else '''' end ' - + N' + case when no_recompute <>0 then '', stats no recompute'' else '''' end ' - + N' + case when groupname IS NOT NULL then '' located on '' + groupname else '''' end), ' - + N'''index_keys'' = - case when type IN (5, 6) then ''n/a, see columns_in_leaf for details'' - else index_keys end, - ''included_columns'' = - case when type IN (5, 6) then ''n/a, columnstore index'' - when type = 7 then ''n/a, HASH'' - else inc_columns end, - ''filter_definition'' = - case when type IN (5, 6) then ''n/a, columnstore index'' - when type = 7 then ''n/a, HASH'' - else filter_definition end, - ''columns_in_tree'' = - case when type IN (5, 6) then ''n/a, columnstore index'' - when type = 7 then ''n/a, HASH'' - else cols_in_tree end, - ''columns_in_leaf'' = - case when type IN (5, 6) then ''Columns with columnstore index: '' + cols_in_leaf - when type = 7 then ''n/a, HASH'' - else cols_in_leaf end - - from #spindtab - order by index_id ' - - IF CONVERT(smallint, SUBSTRING(CONVERT(varchar(50), SERVERPROPERTY('ProductVersion')), 1, 2)) >= 16 - - select @ExecStr = - - N'select ' - + N'''index_id'' = index_id, ' - + N'''is_disabled'' = is_disabled, ' - + N'''index_name'' = index_name, ' - + N'''index_description'' = ' - + N' convert(varchar(210), ' --bits 16 off, 1, 2, 16777216 on, located on group ' - + N' case when index_id = 1 and type = 1 then ''clustered'' ' - + N' when index_id = 1 and type = 5 then ''clustered, columnstore'' ' - + N' when index_id > 1 and type = 2 then ''nonclustered'' ' - + N' when index_id > 1 and type = 6 then ''nonclustered, columnstore'' ' - + N' when index_id > 1 and type = 7 then ''nonclustered, HASH'' ' - + N' else ''new index type'' end ' - + N' + case when ignore_dup_key <>0 then '', ignore duplicate keys'' else '''' end ' - + N' + case when is_unique=1 then '', unique'' else '''' end ' - + N' + case when is_hypothetical <>0 then '', hypothetical'' else '''' end ' - + N' + case when is_primary_key <>0 then '', primary key'' else '''' end ' - + N' + case when is_unique_key <>0 then '', unique key'' else '''' end ' - + N' + case when auto_created <>0 then '', auto create'' else '''' end ' - + N' + case when no_recompute <>0 then '', stats no recompute'' else '''' end ' - + N' + case when memory_optimized = 1 then '' located in MEMORY '' else '''' end ' - + N' + case when groupname IS NOT NULL AND - (memory_optimized = 0 OR memory_optimized IS NULL) - then '' located on '' + groupname else '''' end), ' - + N'''index_keys'' = - case when type IN (5, 6) then ''n/a, see columns_in_leaf for details'' - else index_keys end, - ''included_columns'' = - case when type IN (5, 6) then ''n/a, columnstore index'' - when type = 7 then ''n/a, HASH'' - else inc_columns end, - ''filter_definition'' = - case when type IN (5, 6) then ''n/a, columnstore index'' - when type = 7 then ''n/a, HASH'' - else filter_definition end, - ''columns_in_tree'' = - case when type IN (5, 6) then ''n/a, columnstore index'' - when type = 7 then ''n/a, HASH'' - else cols_in_tree end, - ''columns_in_leaf'' = - case when type IN (5, 6) then ''Columns with columnstore index: '' + cols_in_leaf - when type = 7 then ''n/a, HASH'' - else cols_in_leaf end - - from #spindtab - order by index_id ' - - --SELECT (@ExecStr) - EXEC (@ExecStr) - - return (0) -- sp_SQLskills_helpindex -go - -exec [sys].[sp_MS_marksystemobject] 'sp_SQLskills_helpindex' -go \ No newline at end of file diff --git a/Stored_Procedure/sp_SrvPermissions.sql b/Stored_Procedure/sp_SrvPermissions.sql deleted file mode 100644 index 12c4353e..00000000 --- a/Stored_Procedure/sp_SrvPermissions.sql +++ /dev/null @@ -1,448 +0,0 @@ -USE master -GO -IF OBJECT_ID('dbo.sp_SrvPermissions') IS NULL - EXEC sp_executesql N'CREATE PROCEDURE dbo.sp_SrvPermissions AS PRINT ''Stub'';' -GO -/********************************************************************************************* -sp_SrvPermissions V6.0 -Kenneth Fisher - -http://www.sqlstudies.com - -This stored procedure returns 3 data sets. The first dataset is the list of server -principals, the second is role membership, and the third is server level permissions. - -The final 2 columns of each query are "Un-Do"/"Do" scripts. For example removing a member -from a role or adding them to a role. I am fairly confident in the role scripts, however, -the scripts in the server principals query and server permissions query are works in -progress. In particular certificates and keys are not scripted out. Also while the scripts -have worked flawlessly on the systems I've tested them on, these systems are fairly similar -when it comes to security so I can't say that in a more complicated system there won't be -the odd bug. - -Notes on the create script for server principals: -1) I have included a hashed version of the password and the sid. This means that when run - on another server the password and the sid will remain the same. -2) In SQL 2005 the create script on the server principals query DOES NOT WORK. This is - because the conversion of the sid (in varbinary) to character doesn't appear to work - as I expected in SQL 2005. It works fine in SQL 2008 and above. If you want to use - this script in SQL 2005 you can change the CONVERTs in the principal script to - master.sys.fn_varbintohexstr - -Standard disclaimer: You use scripts off of the web at your own risk. I fully expect this - script to work without issue but I've been known to be wrong before. - -Parameters: - @Principal - If NOT NULL then all three queries only pull for that server principal. @Principal - is a pattern check. The queries check for any row where the passed in value exists. - It uses the pattern '%' + @Principal + '%' - @Role - If NOT NULL then the roles query will pull members of the role. If it is NOT NULL and - @Principal is NULL then Server principal and permissions query will pull the principal - row for the role and the permissions for the role. @Role is a pattern check. The - queries check for any row where the passed in value exists. It uses the pattern - '%' + @Role + '%' - @Type - If NOT NULL then all three queries will only pull principals of that type. - S = SQL login - U = Windows login - G = Windows group - R = Server role - C = Login mapped to a certificate - K = Login mapped to an asymmetric key - @DBName - If NOT NULL then only return those principals and information about them where the - principal exists within the DB specified. - @UseLikeSearch - When this is set to 1 (the default) then the search parameters will use LIKE (and - %'s will be added around the @Principal and @Role parameters). - When set to 0 searchs will use =. - @IncludeMSShipped - When this is set to 1 (the default) then all principals will be included. When set - to 0 the fixed server roles and SA and Public principals will be excluded. - @DropTempTables - When this is set to 1 (the default) the temp tables used are dropped. If it's 0 - then the tempt ables are kept for references after the code has finished. - The temp tables are: - ##SrvPrincipals - ##SrvRoles - ##SrvPermissions - @Output - What type of output is desired. - Default - Either 'Default' or it doesn't match any of the allowed values then the SP - will return the standard 3 outputs. - None - No output at all. Usually used if you keeping the temp tables to do your own - reporting. - CreateOnly - Only return the create scripts where they aren't NULL. - DropOnly - Only return the drop scripts where they aren't NULL. - ScriptsOnly - Return drop and create scripts where they aren't NULL. - Report - Returns one output with one row per principal and a comma delimited list of - roles the principal is a member of and a comma delimited list of the - individual permissions they have. - @Print - Defaults to 0, but if a 1 is passed in then the queries are not run but printed - out instead. This is primarily for debugging. - -Data is ordered as follows - 1st result set: SrvPrincipal - 2nd result set: RoleName, LoginName if the parameter @Role is used else - LoginName, RoleName - 3rd result set: GranteeName - -********************************************************************************************* --- V2.0 --- 8/18/2013 – Create a stub if the SP doesn’t exist, then always do an alter --- 9/04/2013 – Change print option to show values of variables not the --- Variable names. --- V3.0 --- 10/5/2013 - Added @Type parameter to pull only principals of a given type. --- 10/20/2013 - Remove SID in CREATE LOGIN script from v2005 and lower since it requires - a special function to convert from binary to varchar. --- V4.0 --- 11/18/2013 - Corrected bug in the order of the parameters for sp_addsrvrolemember - and sp_dropsrvrolemember, also added parameter names both. --- 01/09/2014 - Added an ORDER BY to each of the result sets. See above for details. --- V5.0 --- 04/27/2014 - Add @DBName parameter --- V5.5 --- 7/22/2014 - Changed strings to unicode --- V6.0 --- 10/19/2014 - Add @UserLikeSearch and @IncludeMSShipped parameters. --- 03/25/2017 - Move SID towards the end of the first output so the more important --- columns are closer to the front. --- 03/25/2017 - Add IF Exists to drop and create principal scripts --- 03/25/2017 - Add @DropTempTables to keep the temp tables after the SP is run. --- 03/26/2017 - Add @Output to allow different types of output. -*********************************************************************************************/ -ALTER PROCEDURE dbo.sp_SrvPermissions -( - @Principal sysname = NULL, - @Role sysname = NULL, - @Type nvarchar(30) = NULL, - @DBName sysname = NULL, - @UseLikeSearch bit = 1, - @IncludeMSShipped bit = 1, - @DropTempTables bit = 1, - @Output varchar(30) = 'Default', - @Print bit = 0 -) -AS - -IF @DBName IS NOT NULL AND NOT EXISTS (SELECT 1 FROM sys.databases WHERE name = @DBName) - BEGIN - RAISERROR (N'%s is not a valid database name.', - 16, - 1, - @DBName) - RETURN - END - -DECLARE @Collation nvarchar(50) -SET @Collation = N' COLLATE ' + CAST(SERVERPROPERTY('Collation') AS nvarchar(50)) - -DECLARE @Version2005orLower bit -SELECT @Version2005orLower = CASE WHEN PARSENAME(CAST(SERVERPROPERTY('productversion') AS VARCHAR(20)),4) < 10 THEN 1 - ELSE 0 END - -DECLARE @sql nvarchar(max) -DECLARE @LikeOperator nvarchar(4) - -IF @UseLikeSearch = 1 - SET @LikeOperator = N'LIKE' -ELSE - SET @LikeOperator = N'=' - -IF @UseLikeSearch = 1 -BEGIN - IF LEN(ISNULL(@Principal,'')) > 0 - SET @Principal = N'%' + @Principal + N'%' - - IF LEN(ISNULL(@Role,'')) > 0 - SET @Role = N'%' + @Role+ N'%' -END - ---========================================================================= --- Server Principals -SET @sql = - N'SELECT principal_id AS SrvPrincipalId, name AS SrvPrincipal, type, type_desc, is_disabled, default_database_name, - default_language_name, sid, ' + NCHAR(13) + - N' CASE WHEN principal_id < 100 THEN NULL ELSE ' + NCHAR(13) + - N' ''IF EXISTS (SELECT * FROM sys.server_principals WHERE name = '' + QuoteName(Logins.name,'''''''') + '') '' + ' + NCHAR(13) + - N' ''DROP '' + CASE [type] WHEN ''C'' THEN NULL ' + NCHAR(13) + - N' WHEN ''K'' THEN NULL ' + NCHAR(13) + - N' WHEN ''R'' THEN ''ROLE'' ' + NCHAR(13) + - N' ELSE ''LOGIN'' END + ' + NCHAR(13) + - N' '' ''+QUOTENAME(name' + @Collation + ') END + '';'' AS DropScript, ' + NCHAR(13) + - N' CASE WHEN principal_id < 100 THEN NULL ELSE ' + NCHAR(13) + - N' ''IF NOT EXISTS (SELECT * FROM sys.server_principals WHERE name = '' + QuoteName(Logins.name,'''''''') + '') '' + ' + NCHAR(13) + - N' ''CREATE '' + CASE [type] WHEN ''C'' THEN NULL ' + NCHAR(13) + - N' WHEN ''K'' THEN NULL ' + NCHAR(13) + - N' WHEN ''R'' THEN ''ROLE'' ' + NCHAR(13) + - N' ELSE ''LOGIN'' END + ' + NCHAR(13) + - N' '' ''+QUOTENAME(name' + @Collation + ') END + ' + NCHAR(13) + - N' CASE WHEN [type] = (''S'') THEN ' + NCHAR(13) + - N' '' WITH PASSWORD = '' + ' + NCHAR(13) + - N' CONVERT(varchar(256), LOGINPROPERTY(name, ''PasswordHash''),1 ) + '' HASHED' + - CASE WHEN @Version2005orLower = 0 THEN N','' + ' + NCHAR(13) + N' '' SID = '' + - CONVERT(varchar(85), sid, 1) + ' + NCHAR(13) - ELSE N''' + ' + NCHAR(13) END + - N' CASE WHEN default_database_name IS NOT NULL OR default_language_name IS NOT NULL THEN '','' - ELSE '''' END ' + NCHAR(13) + - N' WHEN [type] IN (''U'',''G'') THEN '' FROM WINDOWS '' + ' + NCHAR(13) + - N' CASE WHEN default_database_name IS NOT NULL OR default_language_name IS NOT NULL THEN '' WITH '' - ELSE '''' END ' + NCHAR(13) + - N' ELSE '''' END + ' + NCHAR(13) + - N' ISNULL('' DEFAULT_DATABASE = '' + QUOTENAME(default_database_name' + @Collation + N'), '''') + ' + - NCHAR(13) + - N' CASE WHEN default_database_name IS NOT NULL AND default_language_name IS NOT NULL THEN '','' - ELSE '''' END + ' + NCHAR(13) + - N' ISNULL('' DEFAULT_LANGUAGE = '' + QUOTENAME(default_language_name' + @Collation + N'), '''') + ' + - NCHAR(13) + - N' '';'' ' + NCHAR(13) + - N' AS CreateScript ' + NCHAR(13) + - N'FROM sys.server_principals Logins ' + NCHAR(13) + - N'WHERE 1=1 ' - -IF LEN(ISNULL(@Principal,@Role)) > 0 - IF @Print = 1 - SET @sql = @sql + NCHAR(13) + N' AND Logins.name ' + @LikeOperator + N' ' + ISNULL(+QUOTENAME(@Principal,''''),QUOTENAME(@Role,'''')) - ELSE - SET @sql = @sql + NCHAR(13) + N' AND Logins.name ' + @LikeOperator + N' ISNULL(@Principal,@Role) ' - -IF LEN(@Type) > 0 - IF @Print = 1 - SET @sql = @sql + NCHAR(13) + N' AND Logins.type ' + @LikeOperator + N' ' + QUOTENAME(@Type,'''') - ELSE - SET @sql = @sql + NCHAR(13) + N' AND Logins.type ' + @LikeOperator + N' @Type' - -IF @DBName IS NOT NULL - SET @sql = @sql + NCHAR(13) + N' AND Logins.SID IN (SELECT SID FROM [' + @DBName + N'].sys.database_principals - WHERE type IN (''G'',''S'',''U'',''K'',''C''))' - -IF @IncludeMSShipped = 0 - SET @sql = @sql + NCHAR(13) + N' AND Logins.is_fixed_role = 0 ' + NCHAR(13) + - ' AND Logins.name NOT IN (''sa'',''public'') ' - -IF @Print = 1 - PRINT '-- Server Principals' + NCHAR(13) + @sql + NCHAR(13) + NCHAR(13) -ELSE -BEGIN - IF object_id('tempdb..##SrvPrincipals') IS NOT NULL - DROP TABLE ##SrvPrincipals - - -- Create temp table to store the data in - CREATE TABLE ##SrvPrincipals ( - SrvPrincipalId int NULL, - SrvPrincipal sysname NULL, - type char(1) NULL, - type_desc nchar(60) NULL, - is_disabled bit NULL, - default_database_name sysname NULL, - default_language_name sysname NULL, - sid varbinary(85) NULL, - DropScript nvarchar(max) NULL, - CreateScript nvarchar(max) NULL - ) - - SET @sql = N'INSERT INTO ##SrvPrincipals ' + NCHAR(13) + @sql - - EXEC sp_executesql @sql, N'@Principal sysname, @Role sysname, @Type varchar(30)', @Principal, @Role, @Type -END ---========================================================================= --- Server level roles -SET @sql = - N'SELECT Logins.principal_id AS LoginPrincipalId, Logins.name AS LoginName, Roles.name AS RoleName, ' + NCHAR(13) + - N' ''EXEC sp_dropsrvrolemember @loginame = ''+QUOTENAME(Logins.name' + @Collation + - ','''''''')+'', @rolename = ''+QUOTENAME(Roles.name' + @Collation + - ','''''''') + '';'' AS DropScript, ' + NCHAR(13) + - N' ''EXEC sp_addsrvrolemember @loginame = ''+QUOTENAME(Logins.name' + @Collation + - ','''''''')+'', @rolename = ''+QUOTENAME(Roles.name' + @Collation + - ','''''''') + '';'' AS AddScript ' + NCHAR(13) + - N'FROM sys.server_role_members RoleMembers ' + NCHAR(13) + - N'JOIN sys.server_principals Logins ' + NCHAR(13) + - N' ON RoleMembers.member_principal_id = Logins.principal_id ' + NCHAR(13) + - N'JOIN sys.server_principals Roles ' + NCHAR(13) + - N' ON RoleMembers.role_principal_id = Roles.principal_id ' + NCHAR(13) + - N'WHERE 1=1 ' - -IF LEN(ISNULL(@Principal,'')) > 0 - IF @Print = 1 - SET @sql = @sql + NCHAR(13) + N' AND Logins.name ' + @LikeOperator + N' '+QUOTENAME(@Principal,'''') - ELSE - SET @sql = @sql + NCHAR(13) + N' AND Logins.name ' + @LikeOperator + N' @Principal' - -IF LEN(ISNULL(@Role,'')) > 0 - IF @Print = 1 - SET @sql = @sql + NCHAR(13) + N' AND Roles.name ' + @LikeOperator + N' '+QUOTENAME(@Role,'''') - ELSE - SET @sql = @sql + NCHAR(13) + N' AND Roles.name ' + @LikeOperator + N' @Role' - -IF LEN(@Type) > 0 - IF @Print = 1 - SET @sql = @sql + NCHAR(13) + N' AND Logins.type ' + @LikeOperator + N' ' + QUOTENAME(@Type,'''') - ELSE - SET @sql = @sql + NCHAR(13) + N' AND Logins.type ' + @LikeOperator + N' @Type' - -IF @DBName IS NOT NULL - SET @sql = @sql + NCHAR(13) + N' AND Logins.SID IN (SELECT SID FROM [' + @DBName + N'].sys.database_principals - WHERE type IN (''G'',''S'',''U'',''K'',''C''))' - -IF @IncludeMSShipped = 0 - SET @sql = @sql + NCHAR(13) + N' AND Logins.is_fixed_role = 0 ' + NCHAR(13) + - ' AND Logins.name NOT IN (''sa'',''public'') ' - -IF @Print = 1 - PRINT '-- Server Role Members' + NCHAR(13) + @sql + NCHAR(13) + NCHAR(13) -ELSE -BEGIN - IF object_id('tempdb..##SrvRoles') IS NOT NULL - DROP TABLE ##SrvRoles - - -- Create temp table to store the data in - CREATE TABLE ##SrvRoles ( - LoginPrincipalId int NULL, - LoginName sysname NULL, - RoleName sysname NULL, - DropScript nvarchar(max) NULL, - AddScript nvarchar(max) NULL - ) - - SET @sql = 'INSERT INTO ##SrvRoles ' + NCHAR(13) + @sql - - EXEC sp_executesql @sql, N'@Principal sysname, @Role sysname, @Type nvarchar(30)', @Principal, @Role, @Type -END - ---========================================================================= --- Server Permissions -SET @sql = - N'SELECT Grantee.principal_id AS GranteePrincipalId, Grantee.name AS GranteeName, ' + NCHAR(13) + - N' Grantor.name AS GrantorName, Permission.class_desc, Permission.permission_name, ' + NCHAR(13) + - N' Permission.state_desc, ' + NCHAR(13) + - N' ''REVOKE '' + ' + NCHAR(13) + - N' CASE WHEN Permission.class_desc = ''ENDPOINT'' THEN NULL ' + NCHAR(13) + - N' WHEN Permission.[state] = ''W'' THEN ''GRANT OPTION FOR '' ELSE '''' END + ' + NCHAR(13) + - N' '' '' + Permission.permission_name' + @Collation + ' + ' + NCHAR(13) + - N' '' FROM '' + QUOTENAME(Grantee.name' + @Collation + ') + ''; '' AS RevokeScript, ' + NCHAR(13) + - N' CASE WHEN Permission.class_desc = ''ENDPOINT'' THEN NULL ' + NCHAR(13) + - N' WHEN Permission.[state] = ''W'' THEN ''GRANT'' ELSE Permission.state_desc' + @Collation + - ' END + ' + NCHAR(13) + - N' '' '' + Permission.permission_name' + @Collation + ' + ' + NCHAR(13) + - N' '' TO '' + QUOTENAME(Grantee.name' + @Collation + ') + '' '' + ' + NCHAR(13) + - N' CASE WHEN Permission.[state] = ''W'' THEN '' WITH GRANT OPTION '' ELSE '''' END + ' + NCHAR(13) + - N' '' AS ''+ QUOTENAME(Grantor.name' + @Collation + ') + '';'' AS GrantScript ' + NCHAR(13) + - N'FROM sys.server_permissions Permission ' + NCHAR(13) + - N'JOIN sys.server_principals Grantee ' + NCHAR(13) + - N' ON Permission.grantee_principal_id = Grantee.principal_id ' + NCHAR(13) + - N'JOIN sys.server_principals Grantor ' + NCHAR(13) + - N' ON Permission.grantor_principal_id = Grantor.principal_id ' + NCHAR(13) + - N'WHERE 1=1 ' - -IF LEN(ISNULL(@Principal,@Role)) > 0 - IF @Print = 1 - SET @sql = @sql + NCHAR(13) + N' AND Grantee.name ' + @LikeOperator + N' ' + ISNULL(+QUOTENAME(@Principal,''''),QUOTENAME(@Role,'''')) - ELSE - SET @sql = @sql + NCHAR(13) + N' AND Grantee.name ' + @LikeOperator + N' ISNULL(@Principal,@Role) ' - -IF LEN(@Type) > 0 - IF @Print = 1 - SET @sql = @sql + NCHAR(13) + N' AND Grantee.type ' + @LikeOperator + N' ' + QUOTENAME(@Type,'''') - ELSE - SET @sql = @sql + NCHAR(13) + N' AND Grantee.type ' + @LikeOperator + N' @Type' - -IF @DBName IS NOT NULL - SET @sql = @sql + NCHAR(13) + N' AND Grantee.SID IN (SELECT SID FROM [' + @DBName + N'].sys.database_principals - WHERE type IN (''G'',''S'',''U'',''K'',''C''))' - -IF @IncludeMSShipped = 0 - SET @sql = @sql + NCHAR(13) + N' AND Grantee.is_fixed_role = 0 ' + NCHAR(13) + - ' AND Grantee.name NOT IN (''sa'',''public'') ' - -IF @Print = 1 - PRINT '-- Server Permissions' + NCHAR(13) + @sql + NCHAR(13) + NCHAR(13) -ELSE -BEGIN - IF object_id('tempdb..##SrvPermissions') IS NOT NULL - DROP TABLE ##SrvPermissions - - -- Create temp table to store the data in - CREATE TABLE ##SrvPermissions ( - GranteePrincipalId int NULL, - GranteeName sysname NULL, - GrantorName sysname NULL, - class_desc nvarchar(60) NULL, - permission_name nvarchar(128) NULL, - state_desc nvarchar(60) NULL, - RevokeScript nvarchar(max) NULL, - GrantScript nvarchar(max) NULL - ) - - -- Add insert statement to @sql - SET @sql = N'INSERT INTO ##SrvPermissions ' + NCHAR(13) + @sql - - EXEC sp_executesql @sql, N'@Principal sysname, @Role sysname, @Type nvarchar(30)', @Principal, @Role, @Type -END - -IF @Print <> 1 -BEGIN - - IF @Output = 'None' - PRINT '' - ELSE IF @Output = 'CreateOnly' - BEGIN - SELECT CreateScript FROM ##SrvPrincipals WHERE CreateScript IS NOT NULL - SELECT AddScript FROM ##SrvRoles WHERE AddScript IS NOT NULL - SELECT GrantScript FROM ##SrvPermissions WHERE GrantScript IS NOT NULL - END - ELSE IF @Output = 'DropOnly' - BEGIN - SELECT DropScript FROM ##SrvPrincipals WHERE DropScript IS NOT NULL - SELECT DropScript FROM ##SrvRoles WHERE DropScript IS NOT NULL - SELECT RevokeScript FROM ##SrvPermissions WHERE RevokeScript IS NOT NULL - END - ELSE IF @Output = 'ScriptOnly' - BEGIN - SELECT DropScript, CreateScript FROM ##SrvPrincipals WHERE DropScript IS NOT NULL OR CreateScript IS NOT NULL - SELECT DropScript, AddScript FROM ##SrvRoles WHERE DropScript IS NOT NULL OR AddScript IS NOT NULL - SELECT RevokeScript, GrantScript FROM ##SrvPermissions WHERE RevokeScript IS NOT NULL OR GrantScript IS NOT NULL - END - ELSE IF @Output = 'Report' - BEGIN - SELECT SrvPrincipal, type, type_desc, is_disabled, - STUFF((SELECT ', ' + ##SrvRoles.RoleName - FROM ##SrvRoles - WHERE ##SrvPrincipals.SrvPrincipalId = ##SrvRoles.LoginPrincipalId - ORDER BY ##SrvRoles.RoleName - FOR XML PATH(''),TYPE).value('.','VARCHAR(MAX)') - , 1, 2, '') AS RoleMembership, - STUFF((SELECT ', ' + ##SrvPermissions.state_desc + ' ' + ##SrvPermissions.permission_name + ' ' + - CASE WHEN class_desc <> 'SERVER' THEN class_desc ELSE '' END - FROM (SELECT DISTINCT * FROM ##SrvPermissions) ##SrvPermissions - WHERE ##SrvPrincipals.SrvPrincipalId = ##SrvPermissions.GranteePrincipalId - ORDER BY ##SrvPermissions.state_desc, ##SrvPermissions.permission_name - FOR XML PATH(''),TYPE).value('.','VARCHAR(MAX)') - , 1, 2, '') AS DirectPermissions - FROM ##SrvPrincipals - ORDER BY SrvPrincipal - END - ELSE -- 'Default' or no match - BEGIN - SELECT SrvPrincipal, type, type_desc, is_disabled, default_database_name, - default_language_name, sid, DropScript, CreateScript - FROM ##SrvPrincipals ORDER BY SrvPrincipal - IF LEN(@Role) > 0 - SELECT LoginName, RoleName, DropScript, AddScript FROM ##SrvRoles ORDER BY RoleName, LoginName - ELSE - SELECT LoginName, RoleName, DropScript, AddScript FROM ##SrvRoles ORDER BY LoginName, RoleName - SELECT GranteeName, GrantorName, class_desc, permission_name, state_desc, RevokeScript, GrantScript - FROM ##SrvPermissions ORDER BY GranteeName - END - - IF @DropTempTables = 1 - BEGIN - DROP TABLE ##SrvPrincipals - DROP TABLE ##SrvRoles - DROP TABLE ##SrvPermissions - END -END -GO diff --git a/Stored_Procedure/usp_MonitorIdentityColumn.sql b/Stored_Procedure/usp_MonitorIdentityColumn.sql deleted file mode 100644 index 7f521b04..00000000 --- a/Stored_Procedure/usp_MonitorIdentityColumn.sql +++ /dev/null @@ -1,68 +0,0 @@ -IF OBJECT_ID('dbo.usp_MonitorIdentityColumn', 'P') IS NULL -EXECUTE('CREATE PROCEDURE dbo.usp_MonitorIdentityColumn as SELECT 1'); -GO - - -ALTER PROCEDURE dbo.usp_MonitorIdentityColumn ( - @databaseName SYSNAME - , @schemaMask SYSNAME = NULL - , @tableMask SYSNAME = NULL - , @debug BIT = 0 -) -AS -/* -EXECUTE dbo.usp_MonitorIdentityColumn - @databaseName = 'YourDatabase' - , @schemaMask = '%YourMask%' - , @tableMask = '%YourMask%' -*/ -SET NOCOUNT ON; - -BEGIN TRY -DECLARE @tsqlCommand NVARCHAR(MAX) = N''; -DECLARE @ParamDefinitionIndentity NVARCHAR(500) = N'@DabataseNameIN SYSNAME'; - -SET @tsqlCommand = N' -USE ' + @databaseName + '; - -DECLARE @DataTypeValue AS TABLE (DataType VARCHAR(50), MinValue BIGINT, MaxValue BIGINT); - -INSERT INTO @DataTypeValue VALUES - (''tinyint'', 0, 255), - (''smallint'', -32768, 32767), - (''int'', -2147483648, 2147483647), - (''bigint'', -9223372036854775808, 9223372036854775807); - -SELECT DISTINCT SS.name AS SchemaName - , TN.name AS TableName - , IC.name AS ColumnName - , TYPE_NAME(IC.system_type_id) AS ColumnDataType - , DTM.MinValue AS MinDataTypeValue - , DTM.MaxValue AS MaxDataTypeValue - , IC.seed_value IdentitySeed - , IC.increment_value AS IdentityIncrement - , IC.last_value AS LastIdentityValue - , DBPS.row_count AS NumberOfRows - , (CONVERT(decimal(9,7), CONVERT(bigint,IC.last_value) * 100 / DTM.MaxValue)) AS ReachMaxValuePercent - FROM sys.identity_columns IC - INNER JOIN sys.tables TN ON IC.object_id = TN.object_id - INNER JOIN sys.schemas SS ON TN.schema_id = SS.schema_id - INNER JOIN @DataTypeValue DTM ON TYPE_NAME(IC.system_type_id)=DTM.DataType - INNER JOIN sys.dm_db_partition_stats DBPS ON DBPS.object_id =IC.object_id - INNER JOIN sys.indexes as IDX ON DBPS.index_id =IDX.index_id -WHERE DBPS.row_count > 0 AND TN.name LIKE ''' + ISNULL(@tableMask, '%') + ''' - AND SS.name LIKE ''' + ISNULL(@schemaMask, '%') + ''' -ORDER BY ReachMaxValuePercent DESC; -'; - -IF @debug = 1 PRINT @tsqlCommand -ELSE -EXECUTE sp_executesql @tsqlCommand; - -END TRY - -BEGIN CATCH - EXECUTE dbo.usp_LogError; - EXECUTE dbo.usp_PrintError; -END CATCH; -GO diff --git a/Stored_Procedure/usp_PrintString.sql b/Stored_Procedure/usp_PrintString.sql deleted file mode 100644 index c251a6f8..00000000 --- a/Stored_Procedure/usp_PrintString.sql +++ /dev/null @@ -1,90 +0,0 @@ -IF OBJECT_ID('dbo.usp_PrintString', 'P') IS NULL - EXECUTE ('CREATE PROCEDURE dbo.usp_PrintString AS SELECT 1'); -GO - -ALTER PROCEDURE dbo.usp_PrintString ( - @str NVARCHAR(MAX) -) -AS -/* -EXEC dbo.usp_PrintString REPLICATE(, 5000); -*/ -BEGIN - DECLARE @line NVARCHAR(MAX) - , @StartLocation INT - , @Length INT - , @TotalLength INT - , @Current INT - - SELECT @StartLocation = 1 - ,@TotalLength = DATALENGTH(@str) - ,@Current = 1 - ,@Length = 0 - - DECLARE @PrintLine NVARCHAR(MAX) = - N'DECLARE @pos int = 1 - WHILE @pos <= LEN(@line) - BEGIN - PRINT SUBSTRING(@line, @pos, 4000); - SET @pos = @pos + 4000; - END;' - - WHILE @Current <= @TotalLength - BEGIN - IF ( - SUBSTRING(@str, @Current, 2) IN ( - CHAR(0x0D) + CHAR(0x0A) - ,CHAR(0x0A) + CHAR(0x0D) - ) - ) - BEGIN - IF @Length <= 0 - PRINT ''; - ELSE - BEGIN -- line - SELECT @line = SUBSTRING(@str, @StartLocation, @Length); - - EXEC sp_executesql @PrintLine - ,N'@line NVARCHAR(max)' - ,@line; - END - - SELECT @StartLocation = @Current + 2 - ,@Current = @Current + 2 - ,@Length = 0; - - CONTINUE; - END - ELSE IF ( - SUBSTRING(@str, @Current, 1) IN ( - CHAR(0x0D) - ,CHAR(0x0A) - ) - ) - BEGIN - IF @Length <= 0 - PRINT ''; - ELSE - BEGIN - SELECT @line = SUBSTRING(@str, @StartLocation, @Length); - - EXEC sp_executesql @PrintLine - ,N'@line NVARCHAR(max)' - ,@line; - END - - SELECT @StartLocation = @Current + 1 - ,@Current = @Current + 1 - ,@Length = 0; - - CONTINUE; - END - - SELECT @Current = @Current + 1 - , @Length = @Length + 1; - END - - IF (@StartLocation <= DATALENGTH(@str)) - PRINT SUBSTRING(@str, @StartLocation, DATALENGTH(@str)) -END; -GO diff --git a/Stored_Procedure/usp_SearchOnAllDB.sql b/Stored_Procedure/usp_SearchOnAllDB.sql deleted file mode 100644 index 94095378..00000000 --- a/Stored_Procedure/usp_SearchOnAllDB.sql +++ /dev/null @@ -1,147 +0,0 @@ -/*************************************************************************/ -/* Procedure of search of a phrase on all database */ -/* Originally developed by Oufimtsev Gleb, MCSE */ -/* */ -/* Updated by David Musgrave, Microsoft */ -/* from feedback from Eduardo Barbosa & Marc K */ -/* */ -/* Last Modified: 26-Jul-2013 */ -/* */ -/* Search for spSearchOnAllDB at http://aka.ms/Dev4DynGP for more info */ -/* */ -/*************************************************************************/ - -if exists (select * from sysobjects where id = object_id('dbo.spSearchOnAllDB') ) - drop procedure dbo.spSearchOnAllDB -GO - -CREATE PROCEDURE spSearchOnAllDB @phrase varchar(8000), @OutFullRecords bit = 0 AS - -/* - To apply so: - exec spSearchOnAllDB 'Sugar%' - exec spSearchOnAllDB '%soft%' - exec spSearchOnAllDB '_5234_57%', 1 - exec spSearchOnAllDB M_cro_oft -*/ - -declare @sql varchar(8000) -declare @tbl varchar(128) -declare @col varchar(128) -declare @id_present bit - -declare @is_char_phrase bit -declare @min_len int -declare @loop_idx int -declare @loop_chr char(1) - -set nocount on - -if IsNull(@phrase, '') = '' begin - raiserror('Phrase is absent', 16, -1) - return -end - --- Handle Quotes passed in the search string -set @phrase = replace(@phrase, '''', '''''') - -select @loop_idx = 1, @is_char_phrase = 0, @min_len = 0 - -while @loop_idx <= LEN(@phrase) begin - set @loop_chr = SUBSTRING(@phrase, @loop_idx,1) - if @loop_chr not in ('%', '_') - set @min_len = @min_len + 1 - if @is_char_phrase = 0 and @loop_chr not in ('%', '_', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.') - set @is_char_phrase = 1 - set @loop_idx = @loop_idx + 1 -end - -create table #tbl_res - (TableName varchar(128) not NULL, - ColumnName varchar(128) not NULL, - Id int NULL, - ColumnValue varchar(7500) not NULL) - -create table #tbl_res2 - (TableName varchar(128) not NULL, - ColumnName varchar(128) not NULL, - Id int NULL, - ColumnValue varchar(7500) not NULL) - -declare CRR cursor local fast_forward for - select t.name, c.name, 1 - from sysobjects t, syscolumns c - where t.type = 'U' - and c.id = t.id - and c.status&0x80 = 0 -- Not IDENTITY - and exists (select * from syscolumns c2 where t.id = c2.id and c2.status&0x80 = 0x80 and c2.xtype in (48, 52, 56)) - and ( (@is_char_phrase = 1 and c.xtype in (175, 239, 99, 231, 35, 167) and c.length >= @min_len) -- char only - or (@is_char_phrase = 0 and c.xtype not in (34, 165, 173, 189, 61, 58, 36))) -- char and numeric - union - select t.name, c.name, 0 - from sysobjects t, syscolumns c - where t.type = 'U' - and c.id = t.id - and not exists (select * from syscolumns c2 where t.id=c2.id and c2.status&0x80 = 0x80 and c2.xtype in (48, 52, 56)) - and ( (@is_char_phrase = 1 and c.xtype in (175, 239, 99, 231, 35, 167) and c.length >= @min_len) -- char only - or (@is_char_phrase = 0 and c.xtype not in (34, 165, 173, 189, 61, 58, 36))) -- char and numeric - order by 1, 2 - -open CRR -fetch CRR into @tbl, @col, @id_present -while @@FETCH_STATUS = 0 begin - if @OutFullRecords = 0 begin - set @sql = 'insert into #tbl_res (TableName, ColumnName, Id, ColumnValue) ' - + 'select ''[' + @tbl + ']'', ''[' + @col + ']'', ' - if @id_present = 1 - set @sql = @sql + 'IDENTITYCOL, ' - else - set @sql = @sql + 'NULL, ' - set @sql = @sql + 'convert(varchar(7500), [' + @col + ']) ' - + 'from [' + @tbl + '] (nolock) ' - + 'where convert(varchar(8000), [' + @col + ']) like ''' + @phrase + ''' ' - end - if @OutFullRecords = 1 begin - set @sql = 'if exists (select * from [' + @tbl + '] (nolock) ' - + 'where convert(varchar(8000), [' + @col + ']) like ''' + @phrase + ''') ' - + 'select ''[' + @tbl + ']'' TableName, ''[' + @col+ ']'' ColumnName, * ' - + 'from [' + @tbl + '] (nolock) where convert(varchar(8000), [' + @col + ']) like ''' + @phrase + ''' ' - end - exec(@sql) - fetch CRR into @tbl, @col, @id_present -end -close CRR -deallocate CRR - -if @OutFullRecords = 0 begin - -- For the clients supporting new types: - --exec('select * from #tbl_res order by 1,2,3') - - -- For the clients who are not supporting new types: - INSERT #tbl_res2 - select TableName, ColumnName, Id, convert(varchar(255),ColumnValue) ColumnValue from #tbl_res - - /** exec('select TableName, ColumnName, Id, convert(varchar(255),ColumnValue) ColumnValue from #tbl_res order by 1,2,3')**/ -end - -drop table #tbl_res - -/***Select Statement to show tables***/ - -select TableName, ColumnName, ColumnValue from #tbl_res2 group by TableName, ColumnName, ColumnValue - order by TableName - -truncate table #tbl_res2 -drop table #tbl_res2 -RETURN - -GO - ---GRANT EXECUTE ON dbo.spSearchOnAllDB TO DYNGRP - -/* Copyright Microsoft Corporation. All Rights Reserved. */ -/* This code released under the terms of the */ -/* Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.) */ - ---exec spSearchOnAllDB '100XL%', 1 ---exec spSearchOnAllDB '%''%', 0 diff --git a/Stored_Procedure/usp_String_Search.sql b/Stored_Procedure/usp_String_Search.sql deleted file mode 100644 index 439b11a1..00000000 --- a/Stored_Procedure/usp_String_Search.sql +++ /dev/null @@ -1,577 +0,0 @@ -SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED -SET NOCOUNT ON - - ------------------------------------------------------------------------------------------------------------------------------ --- Error Trapping: Check If Procedure Already Exists And Create Shell If Applicable ------------------------------------------------------------------------------------------------------------------------------ - -IF OBJECT_ID (N'dbo.usp_String_Search', N'P') IS NULL -BEGIN - - EXECUTE ('CREATE PROCEDURE dbo.usp_String_Search AS SELECT 1 AS shell') - -END -GO - - ------------------------------------------------------------------------------------------------------------------------------ --- Stored Procedure Details: Listing Of Standard Details Related To The Stored Procedure ------------------------------------------------------------------------------------------------------------------------------ - --- Purpose: Search For A String Value Within Columns Of Data Types CHAR, NCHAR, NTEXT, NVARCHAR, TEXT, VARCHAR, XML --- Create Date (MM/DD/YYYY): 03/20/2012 --- Developer: Sean Smith (s.smith.sql AT gmail DOT com) --- Additional Notes: N/A - - ------------------------------------------------------------------------------------------------------------------------------ --- Modification History: Listing Of All Modifications Since Original Implementation ------------------------------------------------------------------------------------------------------------------------------ - --- Description: Added "is_ms_shipped" Field --- : Added Option To Include System Objects In Search --- Date (MM/DD/YYYY): 12/06/2015 --- Developer: Sean Smith (s.smith.sql AT gmail DOT com) --- Additional Notes: N/A - - ------------------------------------------------------------------------------------------------------------------------------ --- Main Query: Create Procedure ------------------------------------------------------------------------------------------------------------------------------ - -ALTER PROCEDURE dbo.usp_String_Search - - @Search_String AS NVARCHAR (500) - ,@Database_Name AS NVARCHAR (300) - ,@Object_Types AS NVARCHAR (10) = NULL - ,@Data_Types AS NVARCHAR (100) = NULL - ,@Table_Max_Rows AS BIGINT = NULL - ,@Column_Max_Length AS SMALLINT = NULL - ,@Creation_Source AS NVARCHAR (1) = N'U' - -WITH RECOMPILE - -AS - -SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED -SET NOCOUNT ON -SET ANSI_WARNINGS OFF -SET ARITHABORT OFF -SET ARITHIGNORE ON -SET TEXTSIZE 2147483647 - - -DECLARE - @Creation_Filter AS NVARCHAR (30) - ,@Loop_Column_Number AS BIGINT - ,@Loop_Column_Number_First AS BIGINT - ,@Loop_Object_Number AS BIGINT - ,@Object_Name AS SYSNAME - ,@Object_Prefix AS NVARCHAR (4) - ,@Schema_Name AS SYSNAME - ,@SQL_String_Full AS NVARCHAR (MAX) - ,@SQL_String_IN_Column_Name AS NVARCHAR (MAX) - ,@SQL_String_SELECT AS NVARCHAR (MAX) - ,@SQL_String_WHERE AS NVARCHAR (MAX) - - -SET @Creation_Filter = (CASE @Creation_Source - WHEN N'S' THEN N'AND O.is_ms_shipped = 1' - WHEN N'U' THEN N'AND O.is_ms_shipped = 0' - ELSE N'' - END) - - -SET @Object_Prefix = (CASE - WHEN @Creation_Source IN (N'B', N'S') THEN N'all_' - ELSE N'' - END) - - -SET @Object_Types = N'''' + REPLACE (REPLACE (NULLIF (@Object_Types, N''), N' ', N''), N',', N''',''') + N'''' - - -SET @Data_Types = N'''' + REPLACE (REPLACE (NULLIF (@Data_Types, N''), N' ', N''), N',', N''',''') + N'''' - - ------------------------------------------------------------------------------------------------------------------------------ --- Error Trapping I: Validate "@Creation_Source", "@Database_Name", And "@Search_String" Input Parameter Values ------------------------------------------------------------------------------------------------------------------------------ - -IF @Creation_Source NOT IN (N'B', N'S', N'U') -BEGIN - - RAISERROR - - ( - 'ERROR: ''%s'' is not a valid creation source. - -Valid Creation Sources: - -B : Both (User and System created objects) -S : System created objects only -U : User created objects only' - ,16 - ,1 - ,@Creation_Source - ) - - - RETURN - -END - - -IF EXISTS (SELECT * FROM master.sys.databases DB WHERE DB.name = @Database_Name) -BEGIN - - SET @Database_Name = QUOTENAME (@Database_Name) - -END -ELSE IF EXISTS (SELECT * FROM master.sys.databases DB WHERE QUOTENAME (DB.name) = @Database_Name + N']') -BEGIN - - SET @Database_Name = @Database_Name + N']' - -END -ELSE IF NOT EXISTS (SELECT * FROM master.sys.databases DB WHERE QUOTENAME (DB.name) = @Database_Name) -BEGIN - - RAISERROR - - ( - N'ERROR: Database (''%s'') does not exist. Make sure that the name is entered correctly.' - ,16 - ,1 - ,@Database_Name - ) - - - RETURN - -END - - -IF NULLIF (@Search_String, N'') IS NOT NULL -BEGIN - - SET @Search_String = REPLACE (REPLACE (REPLACE (REPLACE (@Search_String, N'[', N'[[]'), N'%', N'[%]'), N'_', N'[_]'), N'''', N'''''') - -END -ELSE BEGIN - - RAISERROR - - ( - N'ERROR: @Search_String input parameter cannot be blank or NULL.' - ,16 - ,1 - ) - - - RETURN - -END - - ------------------------------------------------------------------------------------------------------------------------------ --- Error Trapping II: Check If Temp Table(s) Already Exist(s) And Drop If Applicable ------------------------------------------------------------------------------------------------------------------------------ - -IF OBJECT_ID (N'tempdb.dbo.#temp_string_search_objects_columns', N'U') IS NOT NULL -BEGIN - - DROP TABLE dbo.#temp_string_search_objects_columns - -END - - -IF OBJECT_ID (N'tempdb.dbo.#temp_string_search_results', N'U') IS NOT NULL -BEGIN - - DROP TABLE dbo.#temp_string_search_results - -END - - ------------------------------------------------------------------------------------------------------------------------------ --- Table Creation: Create Temp Tables To Temporarily Store Searchable Objects / Columns And Output Results ------------------------------------------------------------------------------------------------------------------------------ - -CREATE TABLE dbo.#temp_string_search_objects_columns - - ( - object_type VARCHAR (2) NOT NULL - ,is_ms_shipped BIT NOT NULL - ,data_type SYSNAME NOT NULL - ,data_length SMALLINT NOT NULL - ,[schema_name] SYSNAME NOT NULL - ,[object_name] SYSNAME NOT NULL - ,column_name SYSNAME NOT NULL - ,schema_object_dense_rank BIGINT NOT NULL - ,column_row_number BIGINT UNIQUE NOT NULL - ,PRIMARY KEY CLUSTERED - ( - schema_object_dense_rank - ,column_row_number - ) - ) - - -CREATE TABLE dbo.#temp_string_search_results - - ( - [schema_name] SYSNAME NOT NULL - ,[object_name] SYSNAME NOT NULL - ,column_name SYSNAME NOT NULL - ,column_data NVARCHAR (MAX) NOT NULL - ,occurrences INT NOT NULL - ) - - ------------------------------------------------------------------------------------------------------------------------------ --- Table Update I: Insert Searchable Objects / Columns Into Temp Table ------------------------------------------------------------------------------------------------------------------------------ - -SET @SQL_String_Full = - - N' - SELECT - O.[type] AS object_type - ,O.is_ms_shipped - ,LOWER (TYPE_NAME (C.user_type_id) + ISNULL ((N'': [ '' + (CASE - WHEN C.system_type_id <> C.user_type_id THEN TYPE_NAME (C.system_type_id) - END) + N'' ]''), N'''')) AS data_type - ,(CASE - WHEN LOWER (TYPE_NAME (C.system_type_id)) IN (N''nchar'', N''ntext'', N''nvarchar'') THEN CONVERT (VARCHAR (6), C.max_length / 2) - WHEN LOWER (TYPE_NAME (C.system_type_id)) NOT IN (N''bigint'', N''bit'', N''date'', N''datetime'', N''datetime2'', N''datetimeoffset'', N''decimal'', N''float'', N''int'', N''money'', N''numeric'', N''real'', N''smalldatetime'', N''smallint'', N''smallmoney'', N''time'', N''tinyint'') THEN CONVERT (VARCHAR (6), C.max_length) - ELSE CONVERT (VARCHAR (6), C.max_length) + '' ('' + CONVERT (VARCHAR (11), COLUMNPROPERTY (C.[object_id], C.name, ''Precision'')) + '','' + ISNULL (CONVERT (VARCHAR (11), COLUMNPROPERTY (C.[object_id], C.name, ''Scale'')), 0) + '')'' - END) AS data_length - ,S.name AS [schema_name] - ,O.name AS [object_name] - ,C.name AS column_name - ,DENSE_RANK () OVER - ( - ORDER BY - S.name - ,O.name - ) AS schema_object_dense_rank - ,ROW_NUMBER () OVER - ( - ORDER BY - C.name - ) AS column_row_number - FROM - ' + @Database_Name + N'.sys.schemas S - INNER JOIN ' + @Database_Name + N'.sys.' + @Object_Prefix + N'objects O ON O.[schema_id] = S.[schema_id] - AND O.[type] IN (' + (CASE - WHEN @Object_Types IS NOT NULL THEN @Object_Types - ELSE N'''U'', ''V''' - END) + N') - ' - - + @Creation_Filter + - - N' - INNER JOIN ' + @Database_Name + N'.sys.' + @Object_Prefix + N'columns C ON C.[object_id] = O.[object_id] - ' - - -IF @Column_Max_Length > 0 -BEGIN - - SET @SQL_String_Full = @SQL_String_Full + - - N' - ' + NCHAR (9) + N'AND C.system_type_id IN (167, 175, 231, 239) - ' + NCHAR (9) + N'AND (CASE - WHEN TYPE_NAME (C.system_type_id) IN (N''nchar'', N''ntext'', N''nvarchar'') THEN C.max_length / 2 - ELSE C.max_length - END) BETWEEN 1 AND ' + CONVERT (NVARCHAR (6), @Column_Max_Length) + N' - ' - -END -ELSE BEGIN - - SET @SQL_String_Full = @SQL_String_Full + - - N' - ' + NCHAR (9) + N'AND C.system_type_id IN (35, 99, 167, 175, 231, 239, 241) - ' - -END - - -SET @SQL_String_Full = @SQL_String_Full + - - N' - INNER JOIN ' + @Database_Name + N'.sys.types T ON T.system_type_id = C.system_type_id - AND T.user_type_id = C.user_type_id - ' + (CASE - WHEN @Data_Types IS NOT NULL THEN REPLICATE (NCHAR (9), 3) + N'AND T.name IN (' + @Data_Types + N')' - ELSE N'' - END) - - -IF @Table_Max_Rows > 0 -BEGIN - - SET @SQL_String_Full = @SQL_String_Full + - - N' - INNER JOIN - - ( - SELECT - DDPS.[object_id] - FROM - ' + @Database_Name + N'.sys.dm_db_partition_stats DDPS - WHERE - DDPS.index_id < 2 - GROUP BY - DDPS.[object_id] - HAVING - SUM (DDPS.row_count) <= ' + CONVERT (NVARCHAR (20), @Table_Max_Rows) + N' - ) sqTMR ON sqTMR.[object_id] = O.[object_id] - ' - -END - - -INSERT INTO dbo.#temp_string_search_objects_columns - - ( - object_type - ,is_ms_shipped - ,data_type - ,data_length - ,[schema_name] - ,[object_name] - ,column_name - ,schema_object_dense_rank - ,column_row_number - ) - -EXECUTE (@SQL_String_Full) - - ------------------------------------------------------------------------------------------------------------------------------ --- Table Update II: Insert Matched Results Into Temp Table ------------------------------------------------------------------------------------------------------------------------------ - -SELECT TOP (1) - @Loop_Object_Number = X.schema_object_dense_rank - ,@Schema_Name = X.[schema_name] - ,@Object_Name = X.[object_name] -FROM - dbo.#temp_string_search_objects_columns X -ORDER BY - X.schema_object_dense_rank - - -WHILE @Loop_Object_Number IS NOT NULL -BEGIN - - SET @SQL_String_SELECT = N'' - - - SET @SQL_String_IN_Column_Name = N'' - - - SET @SQL_String_WHERE = N'' - - - SET @Loop_Column_Number = (SELECT MIN (X.column_row_number) FROM dbo.#temp_string_search_objects_columns X WHERE X.schema_object_dense_rank = @Loop_Object_Number) - - - SET @Loop_Column_Number_First = @Loop_Column_Number - - - WHILE @Loop_Column_Number IS NOT NULL - BEGIN - - SELECT - @SQL_String_SELECT = @SQL_String_SELECT + (CASE - WHEN @Loop_Column_Number = @Loop_Column_Number_First THEN N'SELECT' + NCHAR (13) + REPLICATE (NCHAR (9), 7) + N' ' - ELSE NCHAR (13) + REPLICATE (NCHAR (9), 7) + N',' - END) + N'CONVERT (NVARCHAR (MAX), (CASE - WHEN ' + (CASE - WHEN X.data_type = N'XML' THEN N'CONVERT (NVARCHAR (MAX), ' - ELSE N'' - END) + QUOTENAME (X.column_name) + (CASE - WHEN X.data_type = N'XML' THEN N')' - ELSE N'' - END) + N' LIKE ''%' + @Search_String + N'%'' THEN ' + QUOTENAME (X.column_name) + N' - ELSE NULL - END)) AS ' + QUOTENAME (X.column_name) - ,@SQL_String_IN_Column_Name = @SQL_String_IN_Column_Name + (CASE - WHEN @Loop_Column_Number = @Loop_Column_Number_First THEN N'' - ELSE N', ' - END) + QUOTENAME (X.column_name) - ,@SQL_String_WHERE = @SQL_String_WHERE + (CASE - WHEN @Loop_Column_Number = @Loop_Column_Number_First THEN NCHAR (13) + REPLICATE (NCHAR (9), 6) + N'WHERE' + NCHAR (13) + REPLICATE (NCHAR (9), 7) - ELSE NCHAR (13) + REPLICATE (NCHAR (9), 7) + N'OR ' - END) + (CASE - WHEN X.data_type = N'XML' THEN N'CONVERT (NVARCHAR (MAX), ' - ELSE N'' - END) + QUOTENAME (X.column_name) + (CASE - WHEN X.data_type = N'XML' THEN N')' - ELSE N'' - END) + N' LIKE ''%' + @Search_String + N'%''' - FROM - dbo.#temp_string_search_objects_columns X - WHERE - X.schema_object_dense_rank = @Loop_Object_Number - AND X.column_row_number = @Loop_Column_Number - - - SET @Loop_Column_Number = (SELECT MIN (X.column_row_number) FROM dbo.#temp_string_search_objects_columns X WHERE X.schema_object_dense_rank = @Loop_Object_Number AND X.column_row_number > @Loop_Column_Number) - - END - - - SET @SQL_String_Full = - - ( - N' - SELECT - ''' + @Schema_Name + N''' AS [schema_name] - ,''' + @Object_Name + N''' AS [object_name] - ,UNPV.column_name - ,UNPV.column_data - ,COUNT (*) AS occurrences - FROM - - ( - ' - + @SQL_String_SELECT - + NCHAR (13) + REPLICATE (NCHAR (9), 6) + N'FROM' + NCHAR (13) - + REPLICATE (NCHAR (9), 7) + @Database_Name - + N'.' - + QUOTENAME (@Schema_Name) - + N'.' - + QUOTENAME (@Object_Name) - + @SQL_String_WHERE - + N' - ) sqMAT - - UNPIVOT - - ( - column_data FOR column_name IN - - ( - ' + @SQL_String_IN_Column_Name + N' - ) - - ) UNPV - - GROUP BY - UNPV.column_name - ,UNPV.column_data - ' - ) - - - BEGIN TRY - - INSERT INTO dbo.#temp_string_search_results - - ( - [schema_name] - ,[object_name] - ,column_name - ,column_data - ,occurrences - ) - - EXECUTE (@SQL_String_Full) - - END TRY - BEGIN CATCH - - END CATCH - - - SELECT TOP (1) - @Loop_Object_Number = X.schema_object_dense_rank - ,@Schema_Name = X.[schema_name] - ,@Object_Name = X.[object_name] - FROM - dbo.#temp_string_search_objects_columns X - WHERE - X.schema_object_dense_rank = @Loop_Object_Number + 1 - ORDER BY - X.schema_object_dense_rank - - - IF @@ROWCOUNT = 0 - BEGIN - - SET @Loop_Object_Number = NULL - - END - -END - - ------------------------------------------------------------------------------------------------------------------------------ --- Main Query: Final Display / Output ------------------------------------------------------------------------------------------------------------------------------ - -SELECT - (CASE Y.object_type - WHEN 'U' THEN 'Table' - WHEN 'V' THEN 'View' - ELSE 'ERROR' - END) AS object_type - ,(CASE - WHEN Y.is_ms_shipped = 1 THEN 'Yes' - ELSE 'No' - END) AS is_ms_shipped - ,Y.data_type - ,Y.data_length - ,DB_NAME (DB_ID (SUBSTRING (@Database_Name, 2, LEN (@Database_Name) - 2))) AS database_name - ,Y.[schema_name] - ,Y.[object_name] - ,Y.column_name - ,Z.column_data - ,CONVERT (XML, (CASE - WHEN Y.data_type = N'XML' THEN Z.column_data - ELSE N'' - END)) AS column_data_xml - ,Z.occurrences -FROM - dbo.#temp_string_search_objects_columns Y - INNER JOIN dbo.#temp_string_search_results Z ON Z.[schema_name] = Y.[schema_name] - AND Z.[object_name] = Y.[object_name] - AND Z.column_name = Y.column_name -ORDER BY - Y.object_type - ,Y.is_ms_shipped - ,Y.[schema_name] - ,Y.[object_name] - ,Y.column_name - ,Z.column_data - - ------------------------------------------------------------------------------------------------------------------------------ --- Cleanup: Drop Any Remaining Temp Tables ------------------------------------------------------------------------------------------------------------------------------ - -IF OBJECT_ID (N'tempdb.dbo.#temp_string_search_objects_columns', N'U') IS NOT NULL -BEGIN - - DROP TABLE dbo.#temp_string_search_objects_columns - -END - - -IF OBJECT_ID (N'tempdb.dbo.#temp_string_search_results', N'U') IS NOT NULL -BEGIN - - DROP TABLE dbo.#temp_string_search_results - -END -GO diff --git a/Stored_Procedure/usp_TableUnpivot.sql b/Stored_Procedure/usp_TableUnpivot.sql deleted file mode 100644 index 9e9105ed..00000000 --- a/Stored_Procedure/usp_TableUnpivot.sql +++ /dev/null @@ -1,76 +0,0 @@ -IF OBJECT_ID('dbo.usp_TableUnpivot', 'P') IS NULL EXECUTE ('CREATE PROCEDURE dbo.usp_TableUnpivot as select 1'); -go - -ALTER PROCEDURE dbo.usp_TableUnpivot ( - @databaseName SYSNAME = '', - @schemaName SYSNAME = 'dbo', - @tableName SYSNAME, - @unpivotColumns NVARCHAR(MAX) = '', - @constantColumns NVARCHAR(MAX) = '', - @excludeColumns NVARCHAR(MAX) = '', - @orderBYColumns NVARCHAR(MAX) = '', - @debug BIT = 0 - ) -AS - -/* -EXECUTE [usp_TableUnpivot] @databaseName = '', - @schemaName = 'dbo', - @tableName = 'TableName', - @unpivotColumns = 'UnpivotColumnName', /*!!! table columns list for unpivot with comma separator without spaces !!!*/ - @excludeColumns = 'TableNameID', /*!!! table columns list for excluding with comma separator without spaces !!!*/ - @constantColumns = ', ''Constant1'' AS ConstantColumnName1, ''Constant2'' AS ConstantColumnName2', /*!!! constant values !!!*/ - @oderByColumns = '', - @debug = 1; /*!!! only generate sql statement without executing it !!!*/ -*/ - -BEGIN - -DECLARE @tableColumns NVARCHAR(MAX) = ''; -DECLARE @tableNameFull NVARCHAR(400) = CASE WHEN @databaseName = '' THEN '' ELSE QUOTENAME(@databaseName) + '.' END + QUOTENAME(@schemaName) + '.' + QUOTENAME(@tableName); -DECLARE @object_id INTEGER = OBJECT_ID(@tableNameFull); -DECLARE @sqlCommand NVARCHAR(MAX) = ''; -DECLARE @ParmDefinition NVARCHAR(500) = '@object_idIN INTEGER, @ColumnsOUT VARCHAR(MAX) OUTPUT'; -DECLARE @crlf NVARCHAR(5) = CHAR(13); - -IF @debug = 0 SET NOCOUNT ON ELSE PRINT '/******* Start Debug' + @crlf; - -IF @debug = 1 PRINT ISNULL('@tableNameFull = {' + CAST(@tableNameFull AS VARCHAR) + '}', '@tableNameFull = Null'); -IF @debug = 1 PRINT ISNULL('@object_id = {' + CAST(@object_id AS VARCHAR) + '}', '@object_id = Null'); - -SET @sqlCommand = CASE WHEN @databaseName = '' THEN '' ELSE N'USE ' + QUOTENAME(@databaseName) + N';' END + @crlf + - N'SELECT @ColumnsOUT = @ColumnsOUT + QUOTENAME(Name) + '',''' + @crlf + - N'FROM sys.columns sac ' + @crlf + - N'WHERE sac.object_id = @object_idIN' + @crlf + - N' AND Name NOT IN (''' + REPLACE(@unpivotColumns, N',', N''',''') + N''',''' - + REPLACE(@excludeColumns, N',', N''',''') + N''')' + @crlf + - N'ORDER BY Name;'; - -IF @debug = 1 PRINT ISNULL(N'@sqlCommand = {' + @crlf + @sqlCommand + @crlf + N'}', N'@sqlCommand = Null'); - -EXECUTE sp_executesql @sqlCommand, @ParmDefinition, @object_idIN = @object_id, @ColumnsOUT = @tableColumns OUTPUT SELECT @tableColumns; - -IF @debug = 1 PRINT ISNULL('@tableColumns = {' + @crlf + @tableColumns + @crlf + '}', '@tableColumns = Null'); - -SET @tableColumns = CASE WHEN LEN(@tableColumns) > 0 THEN LEFT(@tableColumns, LEN(@tableColumns) - 1) END; - -SET @sqlCommand = N'SELECT ' + @unpivotColumns + N', val, columns' + @constantColumns + @crlf + - N' FROM ' + @crlf + - N' (' + @crlf + - N' SELECT *' + @crlf + - N' FROM ' + @schemaName + '.' + @tableName + @crlf + - N') s' + @crlf + - N'UNPIVOT' + @crlf + - N' (' + @crlf + - N' val FOR columns IN (' + @tableColumns + ' )' + @crlf + - N' ) p' + @crlf + - CASE WHEN @orderBYColumns != '' THEN N'ORDER BY ' + @orderBYColumns ELSE '' END; - -IF @debug = 1 PRINT CAST(ISNULL('@sqlCommand = {' + @crlf + @sqlCommand + @crlf + '}' + @crlf, '@sqlCommand = Null' + @crlf) AS TEXT); - -IF @debug = 0 EXECUTE sp_executesql @sqlCommand; - -IF @debug = 0 SET NOCOUNT OFF ELSE PRINT 'End Debug *******/'; - -END -go diff --git a/Stored_Procedure/usp_bcpUnloadSelect.sql b/Stored_Procedure/usp_bcpUnloadSelect.sql deleted file mode 100644 index cd461c78..00000000 --- a/Stored_Procedure/usp_bcpUnloadSelect.sql +++ /dev/null @@ -1,66 +0,0 @@ -IF OBJECT_ID('dbo.usp_bcpUnloadSelect', 'P') IS NULL EXECUTE('CREATE PROCEDURE dbo.usp_bcpUnloadSelect AS SELECT 1'); -GO - -ALTER PROCEDURE dbo.usp_bcpUnloadSelect( - @outputFilePath VARCHAR(255) -- The path can have from 1 through 255 characters, see documentation - , @serverName SYSNAME = @@SERVERNAME - , @sqlCommand VARCHAR(MAX) - , @fileName VARCHAR(300) = '' - , @field_term VARCHAR( 10) = '|' - , @fileExtension VARCHAR( 10) = 'txt' - , @codePage VARCHAR( 10) = 'C1251' - , @row_term VARCHAR( 10) = '\n' - , @debug BIT = 0 -) -AS -/*-- -Official bcp documentation: http://technet.microsoft.com/en-us/library/ms162802.aspx -In select statement use full table names: DATABASENAME.SCHEMANAME.TABLENAME -EXECUTE [NIIGAZ].[dbo].[usp_bcpUnloadSelect] - @outputFilePath = 'd:\' - , @serverName = '' - , @sqlCommand = 'SELECT * FROM DATABASENAME.SCHEMANAME.TABLENAME1 AS t1 INNER JOIN DATABASENAME.SCHEMANAME.TABLENAME2 AS t2 ON t1.Column1 = t2.Column1' - , @fileName = 'file_name.txt' - , @field_term = '|' - , @row_term = '\n' - , @fileExtension = 'txt' - , @debug = 0; ---*/ -BEGIN - BEGIN TRY - DECLARE @filePath VARCHAR(2000) = @outputFilePath + - CASE WHEN @fileName = '' THEN 'bcp_export_' ELSE @fileName END + - QUOTENAME(REPLACE(CONVERT(VARCHAR, GETDATE(), 126 ), ':', '_')) + - '.' + @fileExtension; - DECLARE @tsqlCommand VARCHAR(8000) = ''; - DECLARE @crlf VARCHAR(10) = CHAR(13) + CHAR(10); - - IF @debug = 0 SET NOCOUNT ON ELSE PRINT '/******* Start Debug' + @crlf; - - /* remove break lines from select statement */ - SET @sqlCommand = REPLACE(REPLACE(@sqlCommand, CHAR(13), ' '), CHAR(10), ' '); - /* remove duplicate spaces from select statement */ - SET @sqlCommand = REPLACE(REPLACE(REPLACE(@sqlCommand,' ','<>'),'><',''),'<>',' '); - - IF @debug = 1 - PRINT ISNULL('@filePath = {' + @crlf + @filePath + @crlf + '}', '@filePath = {Null}' + @crlf) - PRINT'@sqlCommand = {' + @crlf + @sqlCommand + @crlf + '}'; - - SET @tsqlCommand = 'bcp "' + REPLACE(@sqlCommand, @crlf, ' ') + '" queryout "' + @filePath + - '" -T -S ' + @serverName + ' -c -' + @codePage + ' -t"' + @field_term + '"' + - ' -r"' + @row_term + '"' + @crlf; - - IF @debug = 1 - PRINT ISNULL( '@tsqlCommand = {' + @crlf + @tsqlCommand + '}' + @crlf, '@tsqlCommand = {Null}'); - ELSE - EXECUTE xp_cmdshell @tsqlCommand; - - IF @debug = 0 SET NOCOUNT OFF ELSE PRINT @crlf + '--End Deubg*********/'; - END TRY - - BEGIN CATCH - EXECUTE dbo.usp_LogError; - EXECUTE dbo.usp_PrintError; - END CATCH -END -go diff --git a/Stored_Procedure/usp_who5.sql b/Stored_Procedure/usp_who5.sql deleted file mode 100644 index 95028a05..00000000 --- a/Stored_Procedure/usp_who5.sql +++ /dev/null @@ -1,748 +0,0 @@ -SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED -SET NOCOUNT ON - - ------------------------------------------------------------------------------------------------------------------------------ --- Error Trapping: Check If Procedure Already Exists And Create Shell If Applicable ------------------------------------------------------------------------------------------------------------------------------ - -IF OBJECT_ID (N'dbo.usp_who5', N'P') IS NULL -BEGIN - - EXECUTE ('CREATE PROCEDURE dbo.usp_who5 AS SELECT 1 AS shell') - -END -GO - - ------------------------------------------------------------------------------------------------------------------------------ --- Stored Procedure Details: Listing Of Standard Details Related To The Stored Procedure ------------------------------------------------------------------------------------------------------------------------------ - --- Purpose: Return Information Regarding Current Users / Sessions / Processes On A SQL Server Instance --- Create Date (MM/DD/YYYY): 10/27/2009 --- Developer: Sean Smith (s.smith.sql AT gmail DOT com) --- Additional Notes: N/A - - ------------------------------------------------------------------------------------------------------------------------------ --- Modification History: Listing Of All Modifications Since Original Implementation ------------------------------------------------------------------------------------------------------------------------------ - --- Description: Converted Script To Dynamic-SQL --- : Minor Changes To Code Style --- : Added "@Database_Name" Filter Variable --- : Added "Last_Wait_Type", "Query_Plan", And "Wait_Type" Fields To Output --- Date (MM/DD/YYYY): 08/08/2011 --- Developer: Sean Smith (s.smith.sql AT gmail DOT com) --- Additional Notes: N/A - - --- Description: Renamed Input Variables --- : Added "Plan_Cache_Object_Type", "Plan_Object_Type", "Plan_Times_Used", And "Plan_Size_MB" Fields To Output --- : Changed Help Output From RAISERROR To PRINT --- : Merged "I?" And "O?" Help Parameters Into "?" --- : Added "C" Type "@Filter" Option --- : Rewrote Time Calculation Logic --- Date (MM/DD/YYYY): 11/09/2011 --- Developer: Sean Smith (s.smith.sql AT gmail DOT com) --- Additional Notes: N/A - - --- Description: Expanded "Running" Type Indicators --- : Added System Reserved SPID Indicator To "SPECID" --- : Added "SQL_Statement_Current" And "End_Of_Batch" Fields To Output --- Date (MM/DD/YYYY): 02/01/2012 --- Developer: Sean Smith (s.smith.sql AT gmail DOT com) --- Additional Notes: N/A - - --- Description: Minor Code Formatting Changes --- : Bug Fixes --- : Changes To Date Calculation Method --- Date (MM/DD/YYYY): 08/19/2013 --- Developer: Sean Smith (s.smith.sql AT gmail DOT com) --- Additional Notes: N/A - - --- Description: Added "Batch_Pct", "Command_Completion", "Command_Pct", "Command_Time_Left", "Deadlock_Priority", "Isolation_Level", "Last_Row_Count", "Lock_Details", "Lock_Timeout_Seconds", And "Previous_Error" Fields To Output --- Date (MM/DD/YYYY): 11/24/2013 --- Developer: Sean Smith (s.smith.sql AT gmail DOT com) --- Additional Notes: N/A - - --- Description: Massive Rewrite Of Entire Stored Procedure --- Date (MM/DD/YYYY): 11/28/2015 --- Developer: Sean Smith (s.smith.sql AT gmail DOT com) --- Additional Notes: N/A - - ------------------------------------------------------------------------------------------------------------------------------ --- Main Query: Create Procedure ------------------------------------------------------------------------------------------------------------------------------ - -ALTER PROCEDURE dbo.usp_who5 - - @Filter AS NVARCHAR (5) = NULL - ,@Database_Name AS NVARCHAR (512) = NULL - ,@Exclude_Lock AS BIT = 1 - ,@Exclude_Plan AS BIT = 1 - ,@Exclude_SQL AS BIT = 0 - ,@Exclude_SQL_XML AS BIT = 1 - ,@Login AS NVARCHAR (128) = NULL - ,@SPID AS SMALLINT = NULL - ,@SQL_Text AS NVARCHAR (MAX) = NULL - -AS - -SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED -SET NOCOUNT ON -SET ANSI_WARNINGS OFF -SET ARITHABORT OFF -SET ARITHIGNORE ON -SET TEXTSIZE 2147483647 - - -DECLARE - @Ampersand AS NVARCHAR (1) - ,@Print AS NVARCHAR (MAX) - - -SET @Ampersand = N'&' - - ------------------------------------------------------------------------------------------------------------------------------ --- Error Trapping: Check If "@Filter" Parameter Is An Input / Output Help Request ------------------------------------------------------------------------------------------------------------------------------ - -IF @Filter = N'?' -BEGIN - - SET @Print = - - N' -Optional input parameters: - - @Filter : Limit the result set by passing one or more values listed below (can be combined in any order) - - A - Active sessions only (includes sleeping SPIDs with open transactions) - B - Blocked sessions only - S - Exclude sleeping SPIDs with open transactions - X - Exclude system processes - - @Database_Name : Limit the result set to a specific database (use ---------- for NULL database names) - @Exclude_Lock : Suppress locking details from the output (can increases procedure performance on busy servers; defaulted to 1) - @Exclude_Plan : Suppress execution plan details from the output (can increases procedure performance on busy servers; defaulted to 1) - @Exclude_SQL : Suppress SQL statement details from the output (can increases procedure performance on busy servers; defaulted to 0) - @Exclude_SQL_XML : Suppress SQL statement XML details from the output (can increases procedure performance on busy servers; defaulted to 1) - @Login : Limit the result set to a specific Windows user name (if populated, otherwise by SQL Server login name) - @SPID : Limit the result set to a specific session - @SQL_Text : Limit the result set to SQL statements containing specific text - - -Notes: - - Blocking / blocked sessions will always be displayed first in the result set (when applicable) - - -Output: - - SPECID : System Process ID with Execution Context ID - Database_Name : Database context of the session - Running : Indicates if the session is executing (X), waiting ([]), inactive (blank), inactive with open transactions (•), a background task (--), or not defined (N/A) - Blocking : Blocking indicator (includes type of block and SPID list) - Status : Status of the session -> request -> task - Object_Name : Object being referenced (blank for ad hoc and prepared statements) - Command : Command executed - SQL_Statement_Batch : Batch statement of the session - SQL_Statement_Current : Current statement of the session - Open_Trans : Open transactions for the process - Isolation_Level : Isolation level of the session - Wait_Time : Current wait time (DAYS HH:MM:SS) - Wait_Type : Current wait type - Last_Wait_Type : Previous wait type - SQL_Statement_Batch_XML : Same as "SQL_Statement_Batch" but in XML format - SQL_Statement_Current_XML : Same as "SQL_Statement_Current" but in XML format - SQL_Handle : Identifier for the executing batch or object - Elapsed_Time : Elapsed time since the request began (DAYS HH:MM:SS) - CPU_Total : CPU time used since login (DAYS HH:MM:SS) - CPU_Current : CPU time used for the current process (DAYS HH:MM:SS) - Logical_Reads_Total : Logical reads performed since login - Logical_Reads_Current : Logical reads performed by the current process - Physical_Reads_Total : Physical reads performed since login - Physical_Reads_Current : Physical reads performed by the current process - Writes_Total : Writes performed since login - Writes_Current : Writes performed by the current process - Nesting_Level : Nesting level of the statement currently executing - Last_Row_Count : Row count produced by the last statement executed - Allocated_Memory_MB : Memory allocated to the query in megabytes - Pages_Used : Pages in the procedure cache allocated to the process - Since_SPID_Login : Elapsed time since the client logged in (DAYS HH:MM:SS) - Since_Last_Batch_Start : Elapsed time since the last request began (DAYS HH:MM:SS) - Since_Last_Batch_End : Elapsed time since the last completion of a request (DAYS HH:MM:SS) - Query_Plan : Execution plan of the session (in XML format) - Plan_Cache_Object_Type : Type of object in the cache - Plan_Object_Type : Plan object type - Plan_Times_Used : Times the plan has been utilized since its creation - Plan_Size_MB : Size consumed by the plan in megabytes - Plan_Handle : Identifier for the in-memory plan - Batch_Pct : Percentage of the batch which has been processed - End_Of_Batch : Indicates if the current statement is the last of the entire batch - Command_Pct : Percentage of work completed (applies to a limited set of commands) - Command_Completion : Estimated completion time for the command - Command_Time_Left : Time left before the command completes (DAYS HH:MM:SS) - Lock_Details : Lock details of the session (in XML format) - Lock_Timeout_Seconds : Lock timeout of the session - Deadlock_Priority : Deadlock priority of the session - Host_Name : Name of the client workstation specific to a session - Login_ID : Windows user name (or "Login_Name" if user name is unavailable) - Login_Name : Full name of the user associated to the "Login_ID" - Application_Description : Application accessing SQL Server - Previous_Error : Previous error returned by the session - System_Process : Indicates if the session is a system process - SPECID : System Process ID with Execution Context ID - ' - - - PRINT SUBSTRING (@Print, 1, 3989) - - - PRINT SUBSTRING (@Print, 3992, 4000) - - - RETURN - -END - - ------------------------------------------------------------------------------------------------------------------------------ --- Declarations / Sets: Declare And Set Variables ------------------------------------------------------------------------------------------------------------------------------ - -DECLARE - @Filter_Active AS BIT - ,@Filter_Blocked AS BIT - ,@Filter_Sleeping AS BIT - ,@Filter_System AS BIT - - -SET @Database_Name = NULLIF (@Database_Name, N'') - - -SET @Filter_Active = (CASE - WHEN @Filter LIKE N'%A%' THEN 1 - ELSE 0 - END) - - -SET @Filter_Blocked = (CASE - WHEN @Filter LIKE N'%B%' THEN 1 - ELSE 0 - END) - - -SET @Filter_Sleeping = (CASE - WHEN @Filter LIKE N'%S%' THEN 1 - ELSE 0 - END) - - -SET @Filter_System = (CASE - WHEN @Filter LIKE N'%X%' THEN 1 - ELSE 0 - END) - - -SET @Login = NULLIF (@Login, N'') - - -SET @SQL_Text = NULLIF (REPLACE (@SQL_Text, N'''', N''''''), N'') - - ------------------------------------------------------------------------------------------------------------------------------ --- Main Query: Final Display / Output ------------------------------------------------------------------------------------------------------------------------------ - -SELECT - caCV.SPECID - ,ISNULL (DB.name, N'----------') AS Database_Name - ,REPLICATE (N' ', 5) + (CASE - WHEN caCV.status_session = N'BACKGROUND' THEN N'---' - WHEN caCV.status_session IN (N'dormant', N'sleeping') AND SP.open_tran = 0 THEN N'' - WHEN caCV.status_session IN (N'dormant', N'sleeping') AND SP.open_tran > 0 THEN N'•' - WHEN caCV.status_session IN (N'PENDING', N'PRECONNECT', N'RUNNABLE', N'SPINLOOP', N'SUSPENDED') THEN N'[]' - WHEN caCV.status_session IN (N'ROLLBACK', N'RUNNING') THEN N'X' - ELSE N'N/A' - END) AS Running - ,(CASE - WHEN caCV.blocking IS NULL AND NULLIF (DER.blocking_session_id, 0) IS NULL THEN N'' - WHEN DER.blocking_session_id = DXS.session_id THEN N'> Parallelism <' - ELSE ISNULL (N'[ Blocking ] : ' + caCV.blocking, N'') + (CASE - WHEN caCV.blocking IS NOT NULL AND DER.blocking_session_id <> 0 THEN N' •• ' - ELSE N'' - END) + ISNULL (N'< Blocked By > : ' + CONVERT (NVARCHAR (6), NULLIF (DER.blocking_session_id, 0)), N'') - END) AS Blocking - ,caCV.status_session + N' -> ' + ISNULL (caCV.status_request, N'N/A') + N' -> ' + ISNULL (caCV.status_task, N'N/A') AS [Status] - ,COALESCE (OBJECT_NAME (DEST.objectid, DEST.[dbid]), OBJECT_NAME (DEQP.objectid, DEQP.[dbid]), N'') AS [Object_Name] - ,(CASE - WHEN ISNULL (DER.command, SP.cmd) = N'AWAITING COMMAND' THEN LOWER (ISNULL (DER.command, SP.cmd)) - ELSE ISNULL (DER.command, SP.cmd) - END) AS Command - ,ISNULL (DEST.[text], N'') AS SQL_Statement_Batch - ,ISNULL ((CASE - WHEN DEST.[text] IS NULL THEN N'' - WHEN caCV.status_session = N'sleeping' AND caCV.status_request IS NULL AND caCV.status_task IS NULL THEN N'' - WHEN caCV.statement_start_offset < 1 AND caCV.statement_end_offset = -1 THEN N'<< Single Statement >>' - WHEN (DATALENGTH (DEST.[text]) - caCV.statement_start_offset) / 2 < 0 AND caCV.statement_end_offset = -1 THEN N'<< Derived Statement >>' - WHEN caCV.statement_end_offset = -1 THEN SUBSTRING (DEST.[text], (caCV.statement_start_offset / 2) + 1, ((DATALENGTH (DEST.[text]) - caCV.statement_start_offset) / 2) + 1) - ELSE SUBSTRING (DEST.[text], (caCV.statement_start_offset / 2) + 1, ((caCV.statement_end_offset - caCV.statement_start_offset) / 2) + 1) - END), N'') AS SQL_Statement_Current - ,(CASE - WHEN SP.open_tran = 0 THEN N'' - ELSE CONVERT (NVARCHAR (6), SP.open_tran) - END) AS Open_Trans - ,(CASE DXS.transaction_isolation_level - WHEN 0 THEN N'UNSPECIFIED' - WHEN 1 THEN N'READ UNCOMMITTED' - WHEN 2 THEN N'READ COMMITTED' - WHEN 3 THEN N'REPEATABLE READ' - WHEN 4 THEN N'SERIALIZABLE' - WHEN 5 THEN N'SNAPSHOT' - ELSE N'N/A' - END) AS Isolation_Level - ,ISNULL ((CASE - WHEN oaDHMS.wait_time_days <= 0 THEN REPLICATE (N'_', cjMAX.wait_time_days_length_max) - ELSE REPLICATE (N'0', cjMAX.wait_time_days_length_max - LEN (oaDHMS.wait_time_days)) + oaDHMS.wait_time_days - END) + N' Day(s) ' + (CASE - WHEN oaDHMS.wait_time_hhmmss = N'00:00:00' THEN N'__:__:__' - WHEN LEFT (oaDHMS.wait_time_hhmmss, 5) = N'00:00' THEN N'__:__:' + RIGHT (oaDHMS.wait_time_hhmmss, 2) - WHEN LEFT (oaDHMS.wait_time_hhmmss, 2) = N'00' THEN N'__:' + RIGHT (oaDHMS.wait_time_hhmmss, 5) - ELSE oaDHMS.wait_time_hhmmss - END), N'') AS Wait_Time - ,ISNULL (DER.wait_type, N'') AS Wait_Type - ,ISNULL (DER.last_wait_type, N'') AS Last_Wait_Type - ,CONVERT (XML, ISNULL ((CASE - WHEN (@Exclude_SQL = 1 OR @Exclude_SQL_XML = 1) THEN N'' - ELSE REPLACE (REPLACE (REPLACE (REPLACE (REPLACE (DEST.[text], N'&', @Ampersand + N'amp;'), N'<', @Ampersand + N'lt;'), N'>', @Ampersand + N'gt;'), N'"', @Ampersand + N'quot;'), N'''', @Ampersand + N'#39;') - END), N'')) AS SQL_Statement_Batch_XML - ,CONVERT (XML, (CASE - WHEN (@Exclude_SQL = 1 OR @Exclude_SQL_XML = 1) THEN N'' - ELSE REPLACE (REPLACE (REPLACE (REPLACE (REPLACE (ISNULL (NULLIF (NULLIF (oaSSC.SQL_Statement_Current, N'<< Derived Statement >>'), N'<< Single Statement >>'), DEST.[text]), N'&', @Ampersand + N'amp;'), N'<', @Ampersand + N'lt;'), N'>', @Ampersand + N'gt;'), N'"', @Ampersand + N'quot;'), N'''', @Ampersand + N'#39;') - END)) AS SQL_Statement_Current_XML - ,ISNULL (CONVERT (NVARCHAR (130), (CASE - WHEN SP.[sql_handle] <> 0x0000000000000000000000000000000000000000 THEN SP.[sql_handle] - END), 1), N'') AS [SQL_Handle] - ,ISNULL ((CASE - WHEN oaDHMS.total_elapsed_time_days <= 0 THEN REPLICATE (N'_', cjMAX.total_elapsed_time_days_length_max) - ELSE REPLICATE (N'0', cjMAX.total_elapsed_time_days_length_max - LEN (oaDHMS.total_elapsed_time_days)) + oaDHMS.total_elapsed_time_days - END) + N' Day(s) ' + (CASE - WHEN oaDHMS.total_elapsed_time_hhmmss = N'00:00:00' THEN N'__:__:__' - WHEN LEFT (oaDHMS.total_elapsed_time_hhmmss, 5) = N'00:00' THEN N'__:__:' + RIGHT (oaDHMS.total_elapsed_time_hhmmss, 2) - WHEN LEFT (oaDHMS.total_elapsed_time_hhmmss, 2) = N'00' THEN N'__:' + RIGHT (oaDHMS.total_elapsed_time_hhmmss, 5) - ELSE oaDHMS.total_elapsed_time_hhmmss - END), N'') AS Elapsed_Time - ,ISNULL ((CASE - WHEN oaDHMS.cpu_days <= 0 THEN REPLICATE (N'_', cjMAX.cpu_days_length_max) - ELSE REPLICATE (N'0', cjMAX.cpu_days_length_max - LEN (oaDHMS.cpu_days)) + oaDHMS.cpu_days - END) + N' Day(s) ' + (CASE - WHEN oaDHMS.cpu_hhmmss = N'00:00:00' THEN N'__:__:__' - WHEN LEFT (oaDHMS.cpu_hhmmss, 5) = N'00:00' THEN N'__:__:' + RIGHT (oaDHMS.cpu_hhmmss, 2) - WHEN LEFT (oaDHMS.cpu_hhmmss, 2) = N'00' THEN N'__:' + RIGHT (oaDHMS.cpu_hhmmss, 5) - ELSE oaDHMS.cpu_hhmmss - END), N'') AS CPU_Total - ,ISNULL ((CASE - WHEN oaDHMS.cpu_time_days <= 0 THEN REPLICATE (N'_', cjMAX.cpu_time_days_length_max) - ELSE REPLICATE (N'0', cjMAX.cpu_time_days_length_max - LEN (oaDHMS.cpu_time_days)) + oaDHMS.cpu_time_days - END) + N' Day(s) ' + (CASE - WHEN oaDHMS.cpu_time_hhmmss = N'00:00:00' THEN N'__:__:__' - WHEN LEFT (oaDHMS.cpu_time_hhmmss, 5) = N'00:00' THEN N'__:__:' + RIGHT (oaDHMS.cpu_time_hhmmss, 2) - WHEN LEFT (oaDHMS.cpu_time_hhmmss, 2) = N'00' THEN N'__:' + RIGHT (oaDHMS.cpu_time_hhmmss, 5) - ELSE oaDHMS.cpu_time_hhmmss - END), N'') AS CPU_Current - ,ISNULL (REVERSE (SUBSTRING (REVERSE (CONVERT (NVARCHAR (23), CONVERT (MONEY, NULLIF (DXS.logical_reads, 0)), 1)), 4, 23)), N'') AS Logical_Reads_Total - ,ISNULL (REVERSE (SUBSTRING (REVERSE (CONVERT (NVARCHAR (23), CONVERT (MONEY, NULLIF (DER.logical_reads, 0)), 1)), 4, 23)), N'') AS Logical_Reads_Current - ,ISNULL (REVERSE (SUBSTRING (REVERSE (CONVERT (NVARCHAR (23), CONVERT (MONEY, NULLIF (DXS.reads, 0)), 1)), 4, 23)), N'') AS Physical_Reads_Total - ,ISNULL (REVERSE (SUBSTRING (REVERSE (CONVERT (NVARCHAR (23), CONVERT (MONEY, NULLIF (DER.reads, 0)), 1)), 4, 23)), N'') AS Physical_Reads_Current - ,ISNULL (REVERSE (SUBSTRING (REVERSE (CONVERT (NVARCHAR (23), CONVERT (MONEY, NULLIF (DXS.writes, 0)), 1)), 4, 23)), N'') AS Writes_Total - ,ISNULL (REVERSE (SUBSTRING (REVERSE (CONVERT (NVARCHAR (23), CONVERT (MONEY, NULLIF (DER.writes, 0)), 1)), 4, 23)), N'') AS Writes_Current - ,ISNULL (CONVERT (NVARCHAR (11), DER.nest_level), N'') AS Nesting_Level - ,(CASE - WHEN DXS.row_count = 0 THEN N'' - ELSE REVERSE (SUBSTRING (REVERSE (CONVERT (NVARCHAR (23), CONVERT (MONEY, NULLIF (DXS.row_count, 0)), 1)), 4, 23)) - END) AS Last_Row_Count - ,ISNULL ((CASE - WHEN ISNULL (DOT.exec_context_id, 0) = 0 THEN CONVERT (NVARCHAR (23), CONVERT (MONEY, (NULLIF (DER.granted_query_memory, 0) * 8) / 1024.0), 1) - END), N'') AS Allocated_Memory_MB - ,(CASE - WHEN DXS.memory_usage = 0 THEN N'' - ELSE CONVERT (NVARCHAR (11), DXS.memory_usage) - END) AS Pages_Used - ,ISNULL ((CASE - WHEN oaDHMS.login_time_days <= 0 THEN REPLICATE (N'_', cjMAX.login_time_days_length_max) - ELSE REPLICATE (N'0', cjMAX.login_time_days_length_max - LEN (oaDHMS.login_time_days)) + oaDHMS.login_time_days - END) + N' Day(s) ' + (CASE - WHEN oaDHMS.login_time_hhmmss = N'00:00:00' THEN N'__:__:__' - WHEN LEFT (oaDHMS.login_time_hhmmss, 5) = N'00:00' THEN N'__:__:' + RIGHT (oaDHMS.login_time_hhmmss, 2) - WHEN LEFT (oaDHMS.login_time_hhmmss, 2) = N'00' THEN N'__:' + RIGHT (oaDHMS.login_time_hhmmss, 5) - ELSE oaDHMS.login_time_hhmmss - END), N'') AS Since_SPID_Login - ,ISNULL ((CASE - WHEN oaDHMS.last_request_start_time_days <= 0 THEN REPLICATE (N'_', cjMAX.last_request_start_time_days_length_max) - ELSE REPLICATE (N'0', cjMAX.last_request_start_time_days_length_max - LEN (oaDHMS.last_request_start_time_days)) + oaDHMS.last_request_start_time_days - END) + N' Day(s) ' + (CASE - WHEN oaDHMS.last_request_start_time_hhmmss = N'00:00:00' THEN N'__:__:__' - WHEN LEFT (oaDHMS.last_request_start_time_hhmmss, 5) = N'00:00' THEN N'__:__:' + RIGHT (oaDHMS.last_request_start_time_hhmmss, 2) - WHEN LEFT (oaDHMS.last_request_start_time_hhmmss, 2) = N'00' THEN N'__:' + RIGHT (oaDHMS.last_request_start_time_hhmmss, 5) - ELSE oaDHMS.last_request_start_time_hhmmss - END), N'') AS Since_Last_Batch_Start - ,ISNULL ((CASE - WHEN oaDHMS.last_request_end_time_days <= 0 THEN REPLICATE (N'_', cjMAX.last_request_end_time_days_length_max) - ELSE REPLICATE (N'0', cjMAX.last_request_end_time_days_length_max - LEN (oaDHMS.last_request_end_time_days)) + oaDHMS.last_request_end_time_days - END) + N' Day(s) ' + (CASE - WHEN oaDHMS.last_request_end_time_hhmmss = N'00:00:00' THEN N'__:__:__' - WHEN LEFT (oaDHMS.last_request_end_time_hhmmss, 5) = N'00:00' THEN N'__:__:' + RIGHT (oaDHMS.last_request_end_time_hhmmss, 2) - WHEN LEFT (oaDHMS.last_request_end_time_hhmmss, 2) = N'00' THEN N'__:' + RIGHT (oaDHMS.last_request_end_time_hhmmss, 5) - ELSE oaDHMS.last_request_end_time_hhmmss - END), N'') AS Since_Last_Batch_End - ,ISNULL (DEQP.query_plan, N'') AS Query_Plan - ,ISNULL (DECP.cacheobjtype, N'') AS Plan_Cache_Object_Type - ,ISNULL ((CASE - WHEN DECP.objtype = N'Adhoc' THEN N'Ad Hoc Query' - WHEN DECP.objtype = N'Check' THEN N'CHECK Constraint' - WHEN DECP.objtype = N'Prepared' THEN N'Prepared Statement' - WHEN DECP.objtype = N'Proc' THEN N'Stored Procedure' - WHEN DECP.objtype = N'ReplProc' THEN N'Replication Filter Procedure' - WHEN DECP.objtype = N'SysTab' THEN N'System Table' - WHEN DECP.objtype = N'UsrTab' THEN N'User Table' - ELSE DECP.objtype - END), N'') AS Plan_Object_Type - ,ISNULL (CONVERT (NVARCHAR (11), DECP.usecounts), N'') AS Plan_Times_Used - ,ISNULL (CONVERT (NVARCHAR (11), CONVERT (DECIMAL (18, 2), ROUND (DECP.size_in_bytes / 1048576.0, 2))), N'') AS Plan_Size_MB - ,ISNULL (CONVERT (NVARCHAR (130), DER.plan_handle, 1), N'') AS Plan_Handle - ,ISNULL ((CASE - WHEN caCV.statement_start_offset = -1 AND caCV.statement_end_offset = -1 AND SP.open_tran = 0 THEN N'' - WHEN caCV.statement_start_offset = -1 AND caCV.statement_end_offset = -1 AND SP.open_tran > 0 THEN N'100.00' - WHEN caCV.statement_start_offset = 0 THEN N'0.00' - WHEN (DATALENGTH (DEST.[text]) - caCV.statement_start_offset) / 2 < 0 AND caCV.statement_end_offset = -1 THEN N'N/A' - ELSE CONVERT (NVARCHAR (23), CONVERT (DECIMAL (20, 2), ROUND (((caCV.statement_start_offset - 2.0) / DATALENGTH (DEST.[text])) * 100, 2))) - END), N'') AS Batch_Pct - ,(CASE - WHEN caCV.statement_end_offset = -1 AND DEST.[text] IS NOT NULL THEN N'Yes' - WHEN caCV.statement_end_offset > 0 THEN N'No' - ELSE N'' - END) AS End_Of_Batch - ,ISNULL ((CASE - WHEN DER.percent_complete = 0 THEN N'' - ELSE CONVERT (NVARCHAR (7), CONVERT (DECIMAL (5, 2), DER.percent_complete)) - END), N'') AS Command_Pct - ,ISNULL ((CASE - WHEN DER.percent_complete = 0 THEN N'' - ELSE CONVERT (NVARCHAR (19), DATEADD (MILLISECOND, DER.estimated_completion_time, GETDATE ()), 120) - END), N'') AS Command_Completion - ,ISNULL ((CASE - WHEN oaDHMS.estimated_completion_time_days <= 0 THEN REPLICATE (N'_', cjMAX.estimated_completion_time_days_length_max) - ELSE REPLICATE (N'0', cjMAX.estimated_completion_time_days_length_max - LEN (oaDHMS.estimated_completion_time_days)) + oaDHMS.estimated_completion_time_days - END) + N' Day(s) ' + (CASE - WHEN oaDHMS.estimated_completion_time_hhmmss = N'00:00:00' THEN N'__:__:__' - WHEN LEFT (oaDHMS.estimated_completion_time_hhmmss, 5) = N'00:00' THEN N'__:__:' + RIGHT (oaDHMS.estimated_completion_time_hhmmss, 2) - WHEN LEFT (oaDHMS.estimated_completion_time_hhmmss, 2) = N'00' THEN N'__:' + RIGHT (oaDHMS.estimated_completion_time_hhmmss, 5) - ELSE oaDHMS.estimated_completion_time_hhmmss - END), N'') AS Command_Time_Left - ,ISNULL (( - SELECT DISTINCT - (CASE - WHEN SLI.rsc_type = 2 THEN ISNULL (DB.name, N'----------') - WHEN SLI.rsc_type = 5 AND SLI.req_mode = 2 THEN N'LOCKED' - ELSE ISNULL (OBJECT_NAME (SLI.rsc_objid, SLI.rsc_dbid), N'N/A') - END) - + N': ' - + (CASE SLI.rsc_type - WHEN 1 THEN N'NULL Resource' - WHEN 2 THEN N'Database' - WHEN 3 THEN N'File' - WHEN 4 THEN N'Index' - WHEN 5 THEN N'Object' - WHEN 6 THEN N'Page' - WHEN 7 THEN N'Key' - WHEN 8 THEN N'Extent' - WHEN 9 THEN N'Row ID (RID)' - WHEN 10 THEN N'Application' - WHEN 11 THEN N'Metadata' - WHEN 12 THEN N'Heap Or B-Tree (HoBt)' - WHEN 13 THEN N'Allocation Unit' - ELSE N'N/A' - END) - + ISNULL (N' [' + CONVERT (NVARCHAR (11), NULLIF (SLI.rsc_indid, 0)) + N']', N'') - + N' - ' - + (CASE SLI.req_mode - WHEN 0 THEN N'NULL Resource' - WHEN 1 THEN N'Sch-S: Schema Stability' - WHEN 2 THEN N'Sch-M: Schema Modification' - WHEN 3 THEN N'S: Shared' - WHEN 4 THEN N'U: Update' - WHEN 5 THEN N'X: Exclusive' - WHEN 6 THEN N'IS: Intent Shared' - WHEN 7 THEN N'IU: Intent Update' - WHEN 8 THEN N'IX: Intent Exclusive' - WHEN 9 THEN N'SIU: Shared Intent Update' - WHEN 10 THEN N'SIX: Shared Intent Exclusive' - WHEN 11 THEN N'UIX: Update Intent Exclusive' - WHEN 12 THEN N'BU: Bulk Update' - WHEN 13 THEN N'RangeS-S: Serializable Range Scan' - WHEN 14 THEN N'RangeS-U: Serializable Update Scan' - WHEN 15 THEN N'RangeI-N: Insert Key-Range / Null Resource Lock' - WHEN 16 THEN N'RangeI-S: Overlap Of RangeI-N / S Locks' - WHEN 17 THEN N'RangeI-U: Overlap Of RangeI-N / U Locks' - WHEN 18 THEN N'RangeI-X: Overlap Of RangeI-N / X Locks' - WHEN 19 THEN N'RangeX-S: Overlap Of RangeI-N / RangeS-S Locks' - WHEN 20 THEN N'RangeX-U: Overlap Of RangeI-N / RangeS-U Locks' - WHEN 21 THEN N'RangeX-X: Exclusive Key-Range / Exclusive Resource Lock' - ELSE N'N/A' - END) - + N' (' - + (CASE SLI.req_status - WHEN 1 THEN N'Granted' - WHEN 2 THEN N'Convert' - WHEN 3 THEN N'Wait' - WHEN 4 THEN N'RELN' - WHEN 5 THEN N'BLCKN' - ELSE N'N/A' - END) - + N' / ' - + (CASE SLI.req_ownertype - WHEN 1 THEN N'Transaction' - WHEN 2 THEN N'Cursor' - WHEN 3 THEN N'User Session' - WHEN 4 THEN N'Shared Transaction Workspace' - WHEN 5 THEN N'Exclusive Transaction Workspace' - WHEN 6 THEN N'WFR' - ELSE N'N/A' - END) - + N')' - + NCHAR (13) - + NCHAR (10) AS [text()] - FROM - master.sys.syslockinfo SLI - LEFT JOIN master.sys.databases DB ON DB.database_id = SLI.rsc_dbid - WHERE - @Exclude_Lock = 0 - AND SLI.req_spid = DXS.session_id - AND SLI.req_ecid = ISNULL (DOT.exec_context_id, 0) - FOR - XML PATH ('') - ,TYPE - ), N'') AS Lock_Details - ,(CASE - WHEN DXS.[lock_timeout] = -1 THEN N'Wait Forever' - WHEN DXS.[lock_timeout] = 0 THEN N'Immediately' - ELSE CONVERT (NVARCHAR (11), CONVERT (DECIMAL (18, 2), ROUND (DXS.[lock_timeout] / 1000.0, 2))) - END) AS Lock_Timeout_Seconds - ,(CASE - WHEN DXS.[deadlock_priority] <= -5 THEN N'Low' - WHEN DXS.[deadlock_priority] >= 5 THEN N'High' - ELSE N'Normal' - END) + N': ' + CONVERT (NVARCHAR (3), DXS.[deadlock_priority]) AS [Deadlock_Priority] - ,ISNULL (DXS.[host_name], N'') AS [Host_Name] - ,caCV.login_id AS Login_ID - ,(CASE - WHEN DXS.login_name = N'sa' THEN N'<< System Administrator >>' - ELSE DXS.login_name - END) AS Login_Name - ,ISNULL (REPLACE (REPLACE (DXS.[program_name], N'Microsoft® Windows® Operating System', N'Windows OS'), N'Microsoft', N'MS'), N'') AS Application_Description - ,ISNULL (CONVERT (NVARCHAR (11), NULLIF (DXS.prev_error, 0)) - + N': ' - + M.[text] - + N' (Severity ' - + CONVERT (NVARCHAR (3), M.severity) - + N', ' - + (CASE M.is_event_logged - WHEN 0 THEN N'Not Logged' - WHEN 1 THEN N'Logged' - END) - + N')', N'') AS Previous_Error - ,(CASE DXS.is_user_process - WHEN 1 THEN N'' - ELSE N'Yes' - END) AS System_Process - ,caCV.SPECID -FROM - master.sys.sysprocesses SP - INNER JOIN master.sys.dm_exec_sessions DXS ON DXS.session_id = SP.spid - LEFT JOIN master.sys.dm_exec_requests DER ON DER.session_id = DXS.session_id - LEFT JOIN master.sys.dm_os_tasks DOT ON DOT.session_id = DXS.session_id - AND ISNULL (DOT.exec_context_id, 0) = SP.ecid - LEFT JOIN master.sys.dm_exec_cached_plans DECP ON DECP.plan_handle = DER.plan_handle - LEFT JOIN master.sys.messages M ON M.message_id = DXS.prev_error - AND M.language_id = CONVERT (SMALLINT, SERVERPROPERTY (N'LCID')) - LEFT JOIN master.sys.databases DB ON DB.database_id = SP.[dbid] - CROSS APPLY - - ( - SELECT - CONVERT (NVARCHAR (6), DXS.session_id) + N'.' + CONVERT (NVARCHAR (11), ISNULL (DOT.exec_context_id, 0)) + N' ' + (CASE - WHEN DXS.session_id = @@SPID THEN N'••' - WHEN DXS.is_user_process = 0 THEN N'•' - ELSE N'' - END) AS SPECID - ,STUFF (( - SELECT - N', ' + CONVERT (NVARCHAR (MAX), XDER.session_id) AS [text()] - FROM - master.sys.dm_exec_requests XDER - WHERE - XDER.blocking_session_id <> 0 - AND XDER.blocking_session_id = DXS.session_id - ORDER BY - XDER.session_id - FOR - XML PATH ('') - ), 1, 2, N'') AS blocking - ,(CASE - WHEN DXS.[status] NOT IN (N'dormant', N'sleeping') THEN UPPER (DXS.[status]) - ELSE DXS.[status] - END) AS status_session - ,(CASE - WHEN DER.[status] <> N'sleeping' THEN UPPER (DER.[status]) - ELSE DER.[status] - END) AS status_request - ,(CASE - WHEN DOT.task_state <> N'sleeping' THEN UPPER (DOT.task_state) - ELSE DOT.task_state - END) AS status_task - ,ISNULL (NULLIF (DXS.nt_user_name, N''), DXS.login_name) AS login_id - ,ISNULL (DER.statement_start_offset, -1) AS statement_start_offset - ,ISNULL (DER.statement_end_offset, -1) AS statement_end_offset - ) caCV - - CROSS JOIN - - ( - SELECT - MAX (LEN (CONVERT (NVARCHAR (5), YDER.total_elapsed_time / 1000 / 86400))) AS total_elapsed_time_days_length_max - ,MAX (LEN (CONVERT (NVARCHAR (5), XSP.cpu / 1000 / 86400))) AS cpu_days_length_max - ,MAX (LEN (CONVERT (NVARCHAR (5), YDER.cpu_time / 1000 / 86400))) AS cpu_time_days_length_max - ,MAX (LEN (CONVERT (NVARCHAR (5), YDER.estimated_completion_time / 1000 / 86400))) AS estimated_completion_time_days_length_max - ,MAX (LEN (CONVERT (NVARCHAR (5), YDER.wait_time / 1000 / 86400))) AS wait_time_days_length_max - ,MAX (LEN (FLOOR ((FLOOR ((((CONVERT (DECIMAL (38, 20), GETDATE ()) - CONVERT (DECIMAL (38, 20), XDXS.login_time)) * 24) * 60) * 60)) / 86400))) AS login_time_days_length_max - ,MAX (LEN (FLOOR ((FLOOR ((((CONVERT (DECIMAL (38, 20), GETDATE ()) - CONVERT (DECIMAL (38, 20), XDXS.last_request_start_time)) * 24) * 60) * 60)) / 86400))) AS last_request_start_time_days_length_max - ,MAX (LEN (FLOOR ((FLOOR ((((CONVERT (DECIMAL (38, 20), GETDATE ()) - CONVERT (DECIMAL (38, 20), XDXS.last_request_end_time)) * 24) * 60) * 60)) / 86400))) AS last_request_end_time_days_length_max - FROM - master.sys.sysprocesses XSP - INNER JOIN master.sys.dm_exec_sessions XDXS ON XDXS.session_id = XSP.spid - LEFT JOIN master.sys.dm_exec_requests YDER ON YDER.session_id = XDXS.session_id - ) cjMAX - - OUTER APPLY master.sys.dm_exec_sql_text (CASE - WHEN @Exclude_SQL = 1 THEN NULL - ELSE SP.[sql_handle] - END) DEST - OUTER APPLY master.sys.dm_exec_query_plan (CASE - WHEN @Exclude_Plan = 1 THEN NULL - ELSE DER.plan_handle - END) DEQP - OUTER APPLY - - ( - SELECT - ISNULL ((CASE - WHEN DEST.[text] IS NULL THEN N'' - WHEN caCV.status_session = N'sleeping' AND caCV.status_request IS NULL AND caCV.status_task IS NULL THEN N'' - WHEN caCV.statement_start_offset < 1 AND caCV.statement_end_offset = -1 THEN N'<< Single Statement >>' - WHEN (DATALENGTH (DEST.[text]) - caCV.statement_start_offset) / 2 < 0 AND caCV.statement_end_offset = -1 THEN N'<< Derived Statement >>' - WHEN caCV.statement_end_offset = -1 THEN SUBSTRING (DEST.[text], (caCV.statement_start_offset / 2) + 1, ((DATALENGTH (DEST.[text]) - caCV.statement_start_offset) / 2) + 1) - ELSE SUBSTRING (DEST.[text], (caCV.statement_start_offset / 2) + 1, ((caCV.statement_end_offset - caCV.statement_start_offset) / 2) + 1) - END), N'') AS SQL_Statement_Current - ) oaSSC - - OUTER APPLY - - ( - SELECT - NULLIF (DER.total_elapsed_time, 0) / 1000 AS total_elapsed_time_seconds - ,NULLIF (SP.cpu, 0) / 1000 AS cpu_seconds - ,NULLIF (DER.cpu_time, 0) / 1000 AS cpu_time_seconds - ,NULLIF (DER.estimated_completion_time, 0) / 1000 AS estimated_completion_time_seconds - ,NULLIF (DER.wait_time, 0) / 1000 AS wait_time_seconds - ,FLOOR ((((CONVERT (DECIMAL (38, 20), GETDATE ()) - CONVERT (DECIMAL (38, 20), DXS.login_time)) * 24) * 60) * 60) AS login_time_seconds - ,FLOOR ((((CONVERT (DECIMAL (38, 20), GETDATE ()) - CONVERT (DECIMAL (38, 20), DXS.last_request_start_time)) * 24) * 60) * 60) AS last_request_start_time_seconds - ,FLOOR ((((CONVERT (DECIMAL (38, 20), GETDATE ()) - CONVERT (DECIMAL (38, 20), DXS.last_request_end_time)) * 24) * 60) * 60) AS last_request_end_time_seconds - ) oaSEC - - OUTER APPLY - - ( - SELECT - CONVERT (NVARCHAR (5), oaSEC.total_elapsed_time_seconds / 86400) AS total_elapsed_time_days - ,CONVERT (NCHAR (8), DATEADD (SECOND, oaSEC.total_elapsed_time_seconds % 86400, 0), 108) AS total_elapsed_time_hhmmss - ,CONVERT (NVARCHAR (5), oaSEC.cpu_seconds / 86400) AS cpu_days - ,CONVERT (NCHAR (8), DATEADD (SECOND, oaSEC.cpu_seconds % 86400, 0), 108) AS cpu_hhmmss - ,CONVERT (NVARCHAR (5), oaSEC.cpu_time_seconds / 86400) AS cpu_time_days - ,CONVERT (NCHAR (8), DATEADD (SECOND, oaSEC.cpu_time_seconds % 86400, 0), 108) AS cpu_time_hhmmss - ,CONVERT (NVARCHAR (5), oaSEC.estimated_completion_time_seconds / 86400) AS estimated_completion_time_days - ,CONVERT (NCHAR (8), DATEADD (SECOND, oaSEC.estimated_completion_time_seconds % 86400, 0), 108) AS estimated_completion_time_hhmmss - ,CONVERT (NVARCHAR (5), oaSEC.wait_time_seconds / 86400) AS wait_time_days - ,CONVERT (NCHAR (8), DATEADD (SECOND, oaSEC.wait_time_seconds % 86400, 0), 108) AS wait_time_hhmmss - ,CONVERT (NVARCHAR (7), FLOOR (oaSEC.login_time_seconds / 86400)) AS login_time_days - ,CONVERT (NCHAR (8), DATEADD (SECOND, oaSEC.login_time_seconds % 86400, 0), 108) AS login_time_hhmmss - ,CONVERT (NVARCHAR (7), FLOOR (oaSEC.last_request_start_time_seconds / 86400)) AS last_request_start_time_days - ,CONVERT (NCHAR (8), DATEADD (SECOND, oaSEC.last_request_start_time_seconds % 86400, 0), 108) AS last_request_start_time_hhmmss - ,CONVERT (NVARCHAR (7), FLOOR (oaSEC.last_request_end_time_seconds / 86400)) AS last_request_end_time_days - ,CONVERT (NCHAR (8), DATEADD (SECOND, oaSEC.last_request_end_time_seconds % 86400, 0), 108) AS last_request_end_time_hhmmss - ) oaDHMS - -WHERE - ( - ( - @Filter_Active = 0 - OR (CASE - WHEN @Filter_Sleeping = 0 AND SP.open_tran > 0 THEN N'' - ELSE caCV.status_session - END) NOT IN (N'dormant', N'sleeping') - ) - AND - ( - @Filter_Blocked = 0 - OR DER.blocking_session_id <> 0 - ) - AND - ( - @Filter_System = 0 - OR DXS.is_user_process = 1 - ) - AND - ( - @Database_Name IS NULL - OR ISNULL (DB.name, N'----------') = @Database_Name - ) - AND - ( - @Login IS NULL - OR caCV.login_id = @Login - ) - AND - ( - @SPID IS NULL - OR DXS.session_id = @SPID - ) - AND - ( - @SQL_Text IS NULL - OR DEST.[text] LIKE N'%' + REPLACE (REPLACE (REPLACE (@SQL_Text, N'[', N'[[]'), N'%', N'[%]'), N'_', N'[_]') + N'%' - ) - ) - OR - ( - caCV.blocking IS NOT NULL - OR NULLIF (DER.blocking_session_id, 0) IS NOT NULL - ) -ORDER BY - (CASE - WHEN caCV.blocking IS NOT NULL AND NULLIF (DER.blocking_session_id, 0) IS NULL THEN 10 - WHEN caCV.blocking IS NOT NULL AND NULLIF (DER.blocking_session_id, 0) IS NOT NULL THEN 20 - WHEN caCV.blocking IS NULL AND NULLIF (DER.blocking_session_id, 0) IS NOT NULL THEN 30 - WHEN DER.blocking_session_id = DXS.session_id THEN 40 - ELSE 999 - END) - ,DXS.session_id - ,DOT.exec_context_id -GO diff --git a/User_Defined_Function/RemoveNonAlphaCharacters.sql b/User_Defined_Function/RemoveNonAlphaCharacters.sql deleted file mode 100644 index 18218860..00000000 Binary files a/User_Defined_Function/RemoveNonAlphaCharacters.sql and /dev/null differ diff --git a/User_Defined_Function/dbo.ConvertHexLSN.sql b/User_Defined_Function/dbo.ConvertHexLSN.sql new file mode 100644 index 00000000..f674c153 --- /dev/null +++ b/User_Defined_Function/dbo.ConvertHexLSN.sql @@ -0,0 +1,25 @@ +IF OBJECT_ID('dbo.udf_ConvertHexLSN') IS NULL + EXECUTE ('CREATE FUNCTION udf_ConvertHexLSN() RETURNS TABLE AS RETURN SELECT 1 AS A;'); +GO + + +ALTER FUNCTION dbo.udf_ConvertHexLSN( + @lsnc varchar(25) +) +/* +Author: Max Vernon +Original link: https://www.sqlserverscience.com/internals/convert-lsn-hex-decimal/ + +SELECT * FROM dbo.udf_ConvertHexLSN('00000268:0000356c:0001'); +*/ +RETURNS TABLE +WITH SCHEMABINDING +AS + RETURN + ( + SELECT TOP(1) + LSNd = CONVERT(varchar(8), CONVERT(int, CONVERT(varbinary(8), '0x' + CONVERT(varchar(10), LEFT(@lsnc, 8), 0), 1), 1)) + + ':' + CONVERT(varchar(8), CONVERT(int, CONVERT(varbinary(8), '0x' + CONVERT(varchar(10), SUBSTRING(@lsnc, 10, 8), 0), 1)), 1) + + ':' + CONVERT(varchar(8), CONVERT(int, CONVERT(varbinary(8), '0x' + CONVERT(varchar(10), RIGHT(@lsnc, 4), 0), 1), 1)) + ); +GO diff --git a/User_Defined_Function/dbo.udf_InitCap.sql b/User_Defined_Function/dbo.udf_InitCap.sql new file mode 100644 index 00000000..ae0f3c43 --- /dev/null +++ b/User_Defined_Function/dbo.udf_InitCap.sql @@ -0,0 +1,64 @@ +IF OBJECT_ID('dbo.udf_InitCap') IS NULL + EXECUTE ('CREATE FUNCTION dbo.udf_InitCap() RETURNS nvarchar(max) AS RETURN SELECT 1 AS A;'); +GO + +ALTER FUNCTION dbo.udf_InitCap( + @StrStr nvarchar(max) + ) +/* +SELECT dbo.udf_InitCap(N'test STRING ß'); + +Source link: https://github.com/ktaranov/sqlserver-kit/blob/master/User_Defined_Function/dbo.udf_InitCap.sql +Original link: https://gist.github.com/jef-sure/f67bc2c06c4804ca832f1dc5550c8db4 +Author: Anton Petrusevich +Created Date: 2018-09-24 +Modified Date: 2019-07-23 by Konstantin Taranov +*/ +RETURNS nvarchar(max) AS +BEGIN + DECLARE @StrNew nvarchar(max); + DECLARE @c nvarchar(1); + DECLARE @x integer; + DECLARE @StrLen integer; + DECLARE @CloseBracket nvarchar(5); + DECLARE @OpenBracket varchar(5); + DECLARE @mode varchar(20) = 'upper'; + SELECT @StrNew = '', @x = 1, @StrLen = LEN(@StrStr)+1; + SELECT @OpenBracket = CHAR(34) + CHAR(39) + CHAR(40) + CHAR(91) + CHAR(123); + SELECT @CloseBracket = CHAR(34) + CHAR(39) + CHAR(41) + CHAR(93) + CHAR(125); + WHILE @x < @StrLen + BEGIN + SET @c = SUBSTRING(@StrStr, @x, 1); + DECLARE @pbi INT; + DECLARE @cb NCHAR(1); + IF @c = 'ß' or unicode(LOWER(@c)) <> unicode(UPPER(@c)) + BEGIN + IF @mode = 'lower' + SET @c = lower(@c); + IF @mode = 'upper' + BEGIN + SET @c = upper(@c); + SET @mode = 'lower'; + END; + END; + ELSE + BEGIN + SET @pbi = CHARINDEX(@c, @OpenBracket); + IF @pbi <> 0 + BEGIN + SET @cb = SUBSTRING(@CloseBracket, @pbi, 1); + SET @mode = 'preserve'; + END + ELSE + IF @mode <> 'preserve' + SET @mode = 'upper'; + ELSE + IF @c = @cb + SET @mode = 'upper'; + END; + SET @StrNew = @StrNew + @c; + SET @x = @x +1; + END; + RETURN @StrNew; +END; +GO diff --git a/User_Defined_Function/dbo.udf_LCS.sql b/User_Defined_Function/dbo.udf_LCS.sql new file mode 100644 index 00000000..c0930dba --- /dev/null +++ b/User_Defined_Function/dbo.udf_LCS.sql @@ -0,0 +1,116 @@ +IF OBJECT_ID('dbo.udf_LCS') IS NULL + EXECUTE ('CREATE FUNCTION dbo.udf_LCS() RETURNS nvarchar(max) AS RETURN SELECT 1 AS A;'); +GO + + +ALTER FUNCTION dbo.udf_LCS + /** +summary: > + The longest common subsequence (LCS) problem is the problem of finding the + longest subsequence common to all sequences in two sequences. It differs + from problems of finding common substrings: unlike substrings, subsequences + are not required to occupy consecutive positions within the original + sequences. For example, the sequences "1234" and "1224533324" have an LCS of "1234" +Author: Phil Factor +Revision: 1.1 +Created Date: 2019-04-05 +Modified date: 2019-07-08 Konstantin Taranov +Original link: https://www.red-gate.com/simple-talk/blogs/using-json-for-matrices-in-sql-server/ +example: + code: + SELECT dbo.udf_LCS ('1234', '1224533324'); + SELECT dbo.udf_LCS ('thisisatest', 'testing123testing'); + SELECT dbo.udf_LCS ( 'XMJYAUZ', 'MZJAWXU'); + SELECT dbo.udf_LCS ( 'beginning-middle-ending', 'beginning-diddle-dum-ending'); +returns: > + the longest common subsequence as a string +**/ + (@xString varchar(max), @yString varchar(max)) +RETURNS varchar(max) +AS + BEGIN + + DECLARE @ii int = 1; --inner index + DECLARE @jj int = 1; --next loop index + DECLARE @West int; --array reference number to left + DECLARE @NorthWest int; --array reference previous left + DECLARE @North int; --array reference previous + DECLARE @Max int; --holds the maximum of two values + DECLARE @Current int; --current number of matches + DECLARE @Matrix nvarchar(max); + DECLARE @PreviousRow nvarchar(2000); -- the previous matrix row + DECLARE @JSON nvarchar(4000); --json work variable + DECLARE @Numbers TABLE (jj int); +-- SQL Prompt formatting off + +INSERT INTO @Numbers(jj) --this is designed for words of max 40 characters +VALUES(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15), + (16),(17),(18),(19),(20),(21),(22),(23),(24),(25),(26),(27),(28), + (29),(30),(31),(32),(33),(34),(35),(36),(37),(38),(39),(40) +-- SQL Prompt formatting on +--the to start with, the first row is all zeros. + SELECT @PreviousRow = + N'[' + Replicate('0,', Len(@xString) + 1) + N'"' + + Substring(@yString, 1, 1) + N'"]'; + SELECT @Matrix = @PreviousRow;--add this to the matrix + /* we now build the matrix in bottom up fashion. */ + WHILE (@ii <= Len(@yString)) + BEGIN + SELECT @West = 0, @JSON = NULL; + --now create a row in just one query + SELECT @NorthWest = + Json_Value(@PreviousRow, '$[' + Cast(jj - 1 AS varchar(5)) + ']'), + @North = + Json_Value(@PreviousRow, '$[' + Cast(jj AS varchar(5)) + ']'), + @Max = CASE WHEN @West > @North THEN @West ELSE @North END, + @Current = + CASE WHEN Substring(@xString, jj, 1) = Substring(@yString, @ii, 1) THEN + @NorthWest + 1 ELSE @Max END, + @JSON = + Coalesce(@JSON + ',', '[0,') + + Coalesce(Cast(@Current AS varchar(5)), 'null'), @West = @Current + FROM @Numbers AS f + WHERE f.jj <= Len(@xString); + --and store the result as the previous row + SELECT @PreviousRow = + @JSON + N',"' + Substring(@yString, @ii, 1) + N'"]'; + --and add the reow to the matrix + SELECT @Matrix = Coalesce(@Matrix + ', + ', '') + @PreviousRow, @ii = @ii + 1; + END; + --we add the boundong brackets. + SELECT @Matrix = N'[' + @Matrix + N']'; + SELECT @ii = Len(@yString), @jj = Len(@xString); + DECLARE @previousColScore INT, @PreviousRowScore INT, @Ychar NCHAR; + DECLARE @Subsequence NVARCHAR(4000) = ''; + WHILE (@Current > 0) + BEGIN + SELECT @Ychar = Substring(@yString, @ii, 1); + IF (@Ychar = Substring(@xString, @jj, 1)) +-- If current character in X[] and Y[] are same, then it is part of LCS + SELECT @ii = @ii - 1, @jj = @jj - 1, + @Subsequence = @Ychar + @Subsequence, @Current = @Current - 1; + ELSE +--If not same, then find the larger of two and traverse in that direction + BEGIN + --find out the two scores, one to the north and one to the west + SELECT @PreviousRowScore = + Json_Value( + @Matrix, + 'strict $[' + Convert(varchar(5), @ii - 1) + '][' + + Convert(varchar(5), @jj) + ']' + ), + @previousColScore = + Json_Value( + @Matrix, + 'strict $[' + Convert(varchar(5), @ii) + '][' + + Convert(varchar(5), @jj - 1) + ']' + ); + --either go north or west + IF @PreviousRowScore < @previousColScore SELECT @jj = @jj - 1; + ELSE SELECT @ii = @ii - 1; + END; + END; + RETURN @Subsequence; + END; +GO diff --git a/User_Defined_Function/dbo.udf_ListAllUnicodeCodePoints.sql b/User_Defined_Function/dbo.udf_ListAllUnicodeCodePoints.sql new file mode 100644 index 00000000..3dbdbe98 --- /dev/null +++ b/User_Defined_Function/dbo.udf_ListAllUnicodeCodePoints.sql @@ -0,0 +1,96 @@ +IF OBJECT_ID(N'dbo.udf_ListAllUnicodeCodePoints', N'IF') IS NULL + EXEC (N'CREATE FUNCTION dbo.udf_ListAllUnicodeCodePoints() RETURNS TABLE AS RETURN SELECT 1 AS A;'); +GO + + +ALTER FUNCTION dbo.udf_ListAllUnicodeCodePoints +/* + + Solomon Rutzky + List All Unicode Code Points. + List of 188657 Unicode Code Points. + 2019-03-25 + 2019-03-30 + + List some emoji: + + SELECT cp.* + FROM dbo.udf_ListAllUnicodeCodePoints() cp + WHERE cp.[CdPntINT] BETWEEN 0x1F000 AND 0x1F9FF; + + + + List the Tibetan characters, sorted naturally for that language: + + SELECT cp.* + FROM dbo.ListAllUnicodeCodePoints() cp + WHERE cp.[CdPntINT] BETWEEN 0x0F00 AND 0x0FFF -- Tibetan + ORDER BY cp.[Char] COLLATE Nepali_100_CS_AS; + + + +*/ +() +RETURNS TABLE +AS RETURN +WITH nums AS +( + SELECT TOP(1114111) (ROW_NUMBER() OVER + (ORDER BY @@MICROSOFTVERSION) - 1) AS [num] + FROM master.sys.all_columns AS ac1 + CROSS JOIN master.sys.all_columns AS ac2 +), chars AS +( + SELECT n.[num], /* pass-through */ + RIGHT(CONVERT(CHAR(6), CONVERT(BINARY(3), n.[num]), 2), + CASE + WHEN n.[num] > 65535 THEN 5 + ELSE 4 + END) AS [CodePointHex], + CASE + WHEN n.[num] > 65535 THEN 55232 + (n.[num] / 1024) + ELSE NULL + END AS [HighSurrogateINT], + CASE + WHEN n.[num] > 65535 THEN 56320 + (n.[num] % 1024) + ELSE NULL END AS [LowSurrogateINT] + FROM nums n + WHERE n.[num] BETWEEN 0x000000 AND 0x014700 /* filter out 925,455 */ + OR n.[num] BETWEEN 0x016800 AND 0x030000 /* unmapped code */ + OR n.[num] BETWEEN 0x0E0001 AND 0x0E01EF /* points */ +) +SELECT + 'U+' + c.[CodePointHex] AS [CodePoint], + c.[num] AS [CdPntINT], + '0x' + c.[CodePointHex] AS [CdPntBIN], + CASE + WHEN c.[num] > 65535 THEN NCHAR(c.[HighSurrogateINT]) + + NCHAR(c.[LowSurrogateINT]) + ELSE NCHAR(c.[num]) + END AS [Char], + CASE + WHEN c.[num] > 65535 THEN CONVERT(CHAR(10), CONVERT(BINARY(4), + NCHAR(c.[HighSurrogateINT]) + NCHAR(c.[LowSurrogateINT])), 1) + ELSE CONVERT(CHAR(6), CONVERT(BINARY(2), NCHAR(c.[num])), 1) + END AS [UTF-16LE ], + c.[HighSurrogateINT] AS [HighSrgtINT], + c.[LowSurrogateINT] AS [LowSrgtINT], + CONVERT(BINARY(2), c.[HighSurrogateINT]) AS [HighSrgtBIN], + CONVERT(BINARY(2), c.[LowSurrogateINT]) AS [LowSrgtBIN], + 'NCHAR(' + CASE + WHEN c.[num] > 65535 THEN CONVERT(CHAR(6), CONVERT(BINARY(2), c.[HighSurrogateINT]), 1) + + ') + NCHAR(' + CONVERT(CHAR(6), + CONVERT(BINARY(2), c.[LowSurrogateINT]), 1) + ELSE CONVERT(CHAR(6), CONVERT(BINARY(2), c.[num]), 1) + END + ')' + AS [T-SQL ], + '&#x' + c.[CodePointHex] + ';' AS [HTML ], + '\x' + CASE + WHEN c.[num] > 65535 THEN CONVERT(CHAR(4), + CONVERT(BINARY(2), c.[HighSurrogateINT]), 2) + '\x' + + CONVERT(CHAR(4), CONVERT(BINARY(2), + c.[LowSurrogateINT]), 2) + ELSE CONVERT(CHAR(4), CONVERT(BINARY(2), c.[num]), 2) + END AS [C/C++/C#/Java/?] +FROM chars c; +GO diff --git a/User_Defined_Function/dbo.udf_LongestCommonSubstring.sql b/User_Defined_Function/dbo.udf_LongestCommonSubstring.sql new file mode 100644 index 00000000..6aeb2878 --- /dev/null +++ b/User_Defined_Function/dbo.udf_LongestCommonSubstring.sql @@ -0,0 +1,117 @@ +/* This will need a NUMBERS table, stocked with numbers. +If you haven't got one this will create it automatically */ +IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Numbers') + BEGIN + CREATE TABLE dbo.Numbers( + [number] [int], + CONSTRAINT [Index_Numbers] PRIMARY KEY CLUSTERED ([number] ASC) + ON [PRIMARY] + ) + ON [PRIMARY] + END +IF NOT EXISTS(SELECT 1 FROM Numbers WHERE number = 99999) +BEGIN +TRUNCATE TABLE Numbers + ;WITH Digits(i) AS + (SELECT i + FROM (VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (0)) AS X(i)) + INSERT INTO Numbers(number) + SELECT (D6.i*1000000 +D5.i*100000 + D4.i*10000 + D3.i * 1000 + D2.i * 100 + + D1.i * 10 + D0.i + 1) AS seq + FROM Digits AS D0, Digits AS D1, Digits AS D2, Digits AS D3, + Digits AS D4, Digits AS D5, Digits AS D6 + END; + + +IF OBJECT_ID(N'dbo.udf_LongestCommonSubstring', N'TF') IS NULL + EXEC (N'CREATE FUNCTION dbo.udf_LongestCommonSubstring() RETURNS @hit TABLE ( + MatchLength INT,--the length of the match. Not necessarily the length of input + FirstCharInMatch INT,--first character of match in first string + FirstCharInString INT,--first character of match in second string + CommonString VARCHAR(8000) --the part of the FirstString successfully matched + ) AS BEGIN RETURN END;'); +GO + +ALTER FUNCTION dbo.udf_LongestCommonSubstring +/** +summary: > + The longest common subSubstring (LCS) tells you the longest common substring between two strings. + If you, for example, were to compare 'And the Dish ran away with the Spoon' with 'away', you'd + get 'away' as being the string in common. Likewise, comparing '465932859472109683472' with + '697834859472135348' would give you '8594721'. This returns a one-row table that gives you the + length and location of the string as well as the string itself. It can easily be modified to give + you all the substrings (whatever your criteria for the smallest substring. E.g. two characters? + +Author: Phil Factor +Revision: 1.1 +Created Date: 2014-12-05 +Modified date: 2019-07-08 Konstantin Taranov +Original link: https://www.red-gate.com/simple-talk/blogs/string-comparisons-in-sql-the-longest-common-substring/ +example: +code: + SELECT * FROM dbo.udf_LongestCommonSubstring ('1234', '1224533324'); + SELECT * FROM dbo.udf_LongestCommonSubstring ('thisisatest', 'testing123testing'); + SELECT * FROM dbo.udf_LongestCommonSubstring ( 'findthishere', 'where is this?'); + SELECT * FROM dbo.udf_LongestCommonSubstring ( NULL, 'xab'); + SELECT * FROM dbo.udf_LongestCommonSubstring ( 'not beginning-middle-ending', 'beginning-diddle-dum-ending'); +returns: > + the longest common subString as a string +**/ +( +@FirstString VARCHAR(MAX), +@SecondString VARCHAR(MAX) +) +/* returns a single row table +it is easy to change to return a string but I wanted the location of the match */ +RETURNS @hit TABLE ( + MatchLength INT,--the length of the match. Not necessarily the length of input + FirstCharInMatch INT,--first character of match in first string + FirstCharInString INT,--first character of match in second string + CommonString VARCHAR(8000) --the part of the FirstString successfully matched + ) +AS +BEGIN + DECLARE @order INT; + DECLARE @theGroup INT; + DECLARE @sequential INT; + /* this table is used to do a quirky update to enable a grouping only on sequential characters */ + DECLARE @Scratch TABLE (TheRightOrder INT IDENTITY PRIMARY KEY,TheGroup smallint, Sequential INT, + FirstOrder smallint, SecondOrder smallint, ch CHAR(1)); + + --first we reduce the amount of data to those characters in the first string that have a match + --in the second, and where they were. + INSERT INTO @Scratch ( TheGroup , FirstOrder, SecondOrder, ch) + SELECT TheFirst.number - TheSecond.number AS TheGroup + , TheFirst.number + , TheSecond.number + , TheSecond.ch + FROM /* divide up the first string into a table of characters/sequence */ + (SELECT number, SUBSTRING(@FirstString,number,1) AS ch + FROM Numbers WHERE number <= LEN(@FirstString)) TheFirst + INNER JOIN --divide up the second string into a table of characters/sequence + (SELECT number, SUBSTRING(@SecondString,number,1) AS ch + FROM Numbers WHERE number <= LEN(@SecondString)) TheSecond + ON TheFirst.ch= TheSecond.ch --do all valid matches + ORDER BY TheFirst.number-TheSecond.number, TheSecond.number + --now @scratch has all matches in the correct order for checking unbroken sequence + SELECT @order=-1, @theGroup=-1, @sequential=0 --initialise everything + UPDATE @Scratch --now check by incrementing a value every time a sequence is broken + SET @sequential = Sequential = + CASE --if it is not a sequence from the one before increment the variable + WHEN SecondOrder = @order+1 AND TheGroup=@theGroup + THEN @sequential ELSE @sequential + 1 END, + @order=SecondOrder, + @theGroup=TheGroup + --now we just aggregate it, and choose the first longest match. Easy + INSERT INTO @hit (MatchLength,FirstCharInMatch, FirstCharInString,CommonString) + SELECT TOP(1) ---just the first. You may want more so feel free to change + COUNT(*) AS MatchLength, + MIN(FirstOrder) AS FirstCharInMatch, + MIN(SecondOrder) AS FirstCharInString, + SUBSTRING(@SecondString, MIN(SecondOrder), COUNT(*)) AS CommonString + FROM @Scratch + GROUP BY TheGroup, Sequential + ORDER BY COUNT(*) DESC, MIN(FirstOrder) ASC, MIN(SecondOrder) ASC; +RETURN; +END +GO diff --git a/User_Defined_Function/dbo.udf_SeeAccessControlChanges.sql b/User_Defined_Function/dbo.udf_SeeAccessControlChanges.sql new file mode 100644 index 00000000..d66f0a38 --- /dev/null +++ b/User_Defined_Function/dbo.udf_SeeAccessControlChanges.sql @@ -0,0 +1,67 @@ +IF OBJECT_ID('dbo.udf_SeeAccessControlChanges') IS NULL + EXEC('CREATE FUNCTION dbo.udf_SeeAccessControlChanges() RETURNS TABLE WITH SCHEMABINDING AS RETURN SELECT 1 AS A;'); +GO + + +ALTER FUNCTION dbo.udf_SeeAccessControlChanges( + @Start DATETIME2,--the start of the period + @Finish DATETIME2--the end of the period + ) + RETURNS TABLE + --WITH ENCRYPTION|SCHEMABINDING, .. + AS +/** + Summary: > + This function gives you a list + of security events concerning users, roles and logins + from the default trace + Author: Phil Factor + Date: 2018-10-04 + Original link: https://www.red-gate.com/hub/product-learning/sql-monitor/monitoring-changes-permissions-users-roles-logins + Source link: https://github.com/ktaranov/sqlserver-kit/blob/master/User_Defined_Function/dbo.udf_SeeAccessControlChanges.sql + Modified: 2019-01-29 by Konstantin Taranov + Examples: + - SELECT * FROM dbo.udf_SeeAccessControlChanges(DateAdd(day, -1, SysDateTime()), SysDateTime()) + columns: datetime_local, action, data, hostname, ApplicationName, LoginName, traceName, spid, EventClass, objectName, rolename, TargetLoginName, category_id, ObjectType + Returns: > + datetime_local datetime2(7) + action nvarchar(816) + data ntext + hostname nvarchar(256) + ApplicationName nvarchar(256) + LoginName nvarchar(256) + traceName nvarchar(128) + spid int + EventClass int + objectName nvarchar(256) + rolename nvarchar(256) + TargetLoginName nvarchar(256) + category_id smallint + ObjectType nvarchar(128) +**/ + RETURN + ( + SELECT + CONVERT( + DATETIME2, + SWITCHOFFSET(CONVERT(datetimeoffset, StartTime), DATENAME(TzOffset, SYSDATETIMEOFFSET())) + ) AS datetime_local, 'User '+Coalesce( LoginName+ ' ','unknown ')+ + CASE EventSubClass --interpret the subclass for these traces + WHEN 1 THEN 'added ' WHEN 2 THEN 'dropped ' WHEN 3 THEN 'granted database access for ' + WHEN 4 THEN 'revoked database access from ' ELSE 'did something to ' END+ Coalesce(TargetLoginName,'') + + Coalesce( CASE EventSubclass WHEN 1 THEN ' to object ' ELSE ' from object ' end+objectname, '') AS action, + Coalesce(TextData,'') AS [data], hostname, ApplicationName, LoginName, TE.name AS traceName, spid, + EventClass, objectName, rolename, TargetLoginName, TE.category_id, + SysTSV.subclass_name AS ObjectType + FROM::fn_trace_gettable(--just use the latest trace + (SELECT TOP 1 traces.path FROM sys.traces + WHERE is_default = 1), DEFAULT) AS DT + LEFT OUTER JOIN sys.trace_events AS TE + ON DT.EventClass = TE.trace_event_id + LEFT OUTER JOIN sys.trace_subclass_values AS SysTSV + ON DT.EventClass = SysTSV.trace_event_id + AND DT.ObjectType = SysTSV.subclass_value + WHERE StartTime BETWEEN @Start AND @Finish + AND TargetLoginName IS NOT NULL + ); + GO diff --git a/User_Defined_Function/dbo.udf_SeeDatabaseObjectChanges.sql b/User_Defined_Function/dbo.udf_SeeDatabaseObjectChanges.sql new file mode 100644 index 00000000..90dd38db --- /dev/null +++ b/User_Defined_Function/dbo.udf_SeeDatabaseObjectChanges.sql @@ -0,0 +1,79 @@ +IF OBJECT_ID(N'dbo.udf_SeeDatabaseObjectChanges', N'IF') IS NULL + EXEC (N'CREATE FUNCTION dbo.udf_SeeDatabaseObjectChanges() RETURNS TABLE AS RETURN SELECT 1 AS A;'); +GO + + +ALTER FUNCTION dbo.udf_SeeDatabaseObjectChanges +/** +Summary: > + This function gives you a list + of database object changes that happened between + the two dates, taken from the default trace +Author: Phil Factor +Created Date: 2018-10-04 +Modified date: 2019-03-30 +Original link: https://www.red-gate.com/hub/product-learning/sql-monitor/monitoring-changes-permissions-users-roles-logins +Examples: + - SELECT * FROM dbo.udf_SeeDatabaseObjectChanges(DATEADD(day,-1, SYSDATETIME()), SYSDATETIME()); +Columns: datetime_local, action, databaseID, TransactionID, Hostname, ApplicationName, LoginName, spid, objectid +Returns: > + datetime_local datetime + action nvarchar(4000) + databaseID int + TransactionID bigint + Hostname nvarchar(256) + ApplicationName nvarchar(256) + LoginName nvarchar(256) + spid int + objectid int +**/ + ( + @start DATETIME2, --the start of the period + @finish DATETIME2 --the end of the period + ) +RETURNS TABLE + --WITH ENCRYPTION|SCHEMABINDING, .. +AS +RETURN + ( + SELECT + CONVERT( + DATETIME2, + SWITCHOFFSET(CONVERT(datetimeoffset, StartTime), DATENAME(TZOFFSET, SYSDATETIMEOFFSET())) + ) AS datetime_local, + 'User ' + Coalesce(SessionLoginName,loginName,'') + ' ' + Replace(name, 'Object:','') + +Coalesce(' '+ f.ObjType,'')+' '+ Coalesce(DatabaseName+'.'+ObjectName,databasename) AS action, + DatabaseID, TransactionID, HostName, ApplicationName, LoginName, SPID, ObjectID + FROM::fn_trace_gettable(/* just use the latest trace */ + (SELECT TOP 1 traces.path FROM sys.traces WHERE traces.is_default = 1), DEFAULT) AS DT + LEFT OUTER JOIN sys.trace_events AS TE + ON DT.EventClass = TE.trace_event_id + LEFT OUTER JOIN sys.trace_subclass_values AS SysTSV + ON DT.EventClass = SysTSV.trace_event_id + AND DT.ObjectType = SysTSV.subclass_value + LEFT OUTER JOIN + ( + VALUES(8259, 'Check Constraint'),( 8260, 'Default (constraint or standalone)'),( 8262, 'Foreign-key Constraint'),( 8272, 'Stored Procedure'), + ( 8274, 'Rule'),( 8275, 'System Table'),( 8276, 'Trigger on Server'),( 8277, 'User Table'),( 8278, 'View'), + ( 8280, 'Extended Stored Procedure'),(16724, 'CLR Trigger'),(16964, 'Database'),(16975, 'Object'),(17222, 'FullText Catalog'), + (17232, 'CLR Stored Procedure'),(17235, 'Schema'),(17475, 'Credential'),(17491, 'DDL Event'),(17741, 'Management Event'), + (17747, 'Security Event'),(17749, 'User Event'),(17985, 'CLR Aggregate Function'),(17993, 'Inline Table-valued SQL Function'), + (18000, 'Partition Function'),(18002, 'Replication Filter Procedure'),(18004, 'Table-valued SQL Function'),(18259, 'Server Role'), + (18263, 'Microsoft Windows Group'),(19265, 'Asymmetric Key'),(19277, 'Master Key'),(19280, 'Primary Key'),(19283, 'ObfusKey'), + (19521, 'Asymmetric Key Login'),(19523, 'Certificate Login'),(19538, 'Role'),(19539, 'SQL Login'),(19543, 'Windows Login'), + (20034, 'Remote Service Binding'),(20036, 'Event Notification on Database'),(20037, 'Event Notification'),(20038, 'Scalar SQL Function'), + (20047, 'Event Notification on Object'),(20051, 'Synonym'),(20549, 'End Point'),(20801, 'Adhoc Queries which may be cached'), + (20816, 'Prepared Queries which may be cached'),(20819, 'Service Broker Service Queue'),(20821, 'Unique Constraint'), + (21057, 'Application Role'),(21059, 'Certificate'),(21075, 'Server'),(21076, 'Transact-SQL Trigger'),(21313, 'Assembly'), + (21318, 'CLR Scalar Function'),(21321, 'Inline scalar SQL Function'),(21328, 'Partition Scheme'),(21333, 'User'), + (21571, 'Service Broker Service Contract'),(21572, 'Trigger on Database'),(21574, 'CLR Table-valued Function'), + (21577, 'Internal Table (For example, XML Node Table, Queue Table.)'),(21581, 'Service Broker Message Type'),(21586, 'Service Broker Route'), + (21587, 'Statistics'),(21825, 'User'),(21827, 'User'),(21831, 'User'),(21843, 'User'),(21847, 'User'),(22099, 'Service Broker Service'), + (22601, 'Index'),(22604, 'Certificate Login'),(22611, 'XMLSCHEMA'),(22868, 'Type (e.g. Table Type)')) f(ObjectTypeId, ObjType) + ON DT.ObjectType = f.ObjectTypeId + WHERE StartTime BETWEEN @start AND @finish + AND DT.DatabaseName NOT IN ('tempdb', 'master') + AND EventSubClass = 0 + AND category_id = 5 + ); +GO diff --git a/User_Defined_Function/dbo.udf_StringComparisonsLevenshteinFullMatrix.sql b/User_Defined_Function/dbo.udf_StringComparisonsLevenshteinFullMatrix.sql new file mode 100644 index 00000000..70b25e4f --- /dev/null +++ b/User_Defined_Function/dbo.udf_StringComparisonsLevenshteinFullMatrix.sql @@ -0,0 +1,50 @@ +CREATE FUNCTION dbo.udf_StringComparisonsLevenshteinFullMatrix( + @FirstString nvarchar(255) + , @SecondString nvarchar(255) +) +RETURNS int +AS BEGIN +DECLARE @PseudoMatrix table + (location int identity primary key, + FirstOrder int not null, + Firstch nchar(1), + SecondOrder int not null, + Secondch nchar(1), + TheValue int not null default 0, + PreviousRowValues varchar(200) + ); + +INSERT INTO @PseudoMatrix (FirstOrder, Firstch, SecondOrder, Secondch, TheValue) +SELECT TheFirst.number,TheFirst.ch, TheSecond.number,TheSecond.ch,0 + FROM --divide up the first string into a table of characters/sequence + (SELECT number, SUBSTRING(@FirstString,number,1) AS ch + FROM Numbers WHERE number <= LEN(@FirstString) union all Select 0,Char(0)) TheFirst + cross JOIN --divide up the second string into a table of characters/sequence + (SELECT number, SUBSTRING(@SecondString,number,1) AS ch + FROM Numbers WHERE number <= LEN(@SecondString) union all Select 0,Char(0)) TheSecond + --ON Thefirst.ch= Thesecond.ch --do all valid matches +order by TheFirst.number, TheSecond.number + +DECLARE @current varchar(255); +DECLARE @previous varchar(255); +DECLARE @TheValue int; +DECLARE @deletion int, @insertion int, @substitution int, @minim int; + +SELECT @current='', @previous='' +UPDATE @PseudoMatrix + SET + @deletion = @TheValue + 1, + @insertion = ASCII(SUBSTRING(@previous,SecondOrder+1,1))+1, + @substitution = ASCII(SUBSTRING(@previous,(SecondOrder),1)) +1, + @minim=case when @deletion < @insertion then @deletion else @insertion end, + @TheValue = TheValue = case + when SecondOrder = 0 then FirstOrder + When FirstOrder = 0 then SecondOrder + when Firstch = Secondch then ascii(substring(@previous,(SecondOrder),1)) + else case when @minim < @substitution then @minim ELSE @substitution end + end, + @previous = PreviousRowValues=case when SecondOrder =0 then @current else @previous end, + @current= case when SecondOrder =0 then char(@TheValue) else @current+char(@TheValue) end +return @TheValue +END; +GO diff --git a/User_Defined_Function/udf_ParseFilePath.sql b/User_Defined_Function/udf_ParseFilePath.sql new file mode 100644 index 00000000..e131fe05 --- /dev/null +++ b/User_Defined_Function/udf_ParseFilePath.sql @@ -0,0 +1,46 @@ +IF NOT EXISTS (SELECT * FROM sys.objects WHERE type = 'IF' AND object_id = object_id('dbo.udf_ParseFilePath')) + EXEC ('CREATE FUNCTION dbo.udf_ParseFilePath() RETURNS TABLE AS RETURN SELECT Result = ''This is a stub'';' ) +GO + + +ALTER FUNCTION dbo.udf_ParseFilePath (@FilePath nvarchar(300)) +RETURNS TABLE +/************************************************************************************************* +https://github.com/amtwo/dba-database/blob/master/functions-tvfs/dbo.ParseFilePath.sql +AUTHOR: Andy Mallon +CREATED: 20180114 + Parses a full file path into separate file & path values. + Also include the bare file name & file extension, because why not? +PARAMETERS: + @FilePath - Text string of a complete file & path +EXAMPLES: +* +************************************************************************************************** +MODIFICATIONS: + 20160218 - +************************************************************************************************** + This code is free to download and use for personal, educational, and internal + corporate purposes, provided that this header is preserved. Redistribution or sale, + in whole or in part, is prohibited without the author's express written consent. + ©2014-2018 ● Andy Mallon ● am2.co +*************************************************************************************************/ +AS +RETURN + WITH ParseInfo AS( + SELECT FilePath = @FilePath, + PathLen = LEN(@FilePath), + FinalSlashPos = CHARINDEX('\', REVERSE(@FilePath), 1) + ), + ParsedPaths AS ( + SELECT DirectoryPath = LEFT (FilePath, PathLen - FinalSlashPos + 1), + FullFileName = RIGHT(FilePath, FinalSlashPos - 1), + FileExtension = RIGHT(FilePath, CHARINDEX('.', REVERSE(FilePath)) -1), + * + FROM ParseInfo + ) + SELECT DirectoryPath, + FullFileName, + BareFilename = LEFT(FullFilename,LEN(FullFilename)-(LEN(FileExtension)+1)), + FileExtension + FROM ParsedPaths; +GO diff --git a/User_Defined_Function/udf_RemoveNonAlphaCharacters.sql b/User_Defined_Function/udf_RemoveNonAlphaCharacters.sql new file mode 100644 index 00000000..062a5f6c --- /dev/null +++ b/User_Defined_Function/udf_RemoveNonAlphaCharacters.sql @@ -0,0 +1,22 @@ +IF OBJECT_ID('dbo.udf_RemoveNonAlphaCharacters') IS NULL + EXECUTE ('CREATE FUNCTION dbo.udf_RemoveNonAlphaCharacters() RETURNS NVARCHAR(MAX) AS RETURN SELECT 1 AS A;'); +GO + + +ALTER FUNCTION dbo.udf_RemoveNonAlphaCharacters( + @inputString NVARCHAR(MAX) + , @keepValues NVARCHAR(1000) = N'%[^a-z0-9]%' + ) +RETURNS NVARCHAR(MAX) +/* +SELECT dbo.udf_RemoveNonAlphaCharacters(N'Тестовая строка - Test string 123_456', N'%[^a-z0-9]%'); +SELECT dbo.udf_RemoveNonAlphaCharacters(N'Тестовая строка - Test string 123_456', N'%[^3-9]%'); +*/ +AS +BEGIN + WHILE PATINDEX(@keepValues, @inputString) > 0 + SET @inputString = STUFF(@inputString, PATINDEX(@keepValues, @inputString), 1, ''); + + RETURN @inputString; +END; +GO diff --git a/User_Defined_Function/udf_StringComparisonsLevenshteinFull-matrix.sql b/User_Defined_Function/udf_StringComparisonsLevenshteinFull-matrix.sql deleted file mode 100644 index c90362b3..00000000 --- a/User_Defined_Function/udf_StringComparisonsLevenshteinFull-matrix.sql +++ /dev/null @@ -1,50 +0,0 @@ - -alter FUNCTION LevenschteinDifference -( -@FirstString nVarchar(255), @SecondString nVarchar(255) -) -RETURNS int -as begin -Declare @PseudoMatrix table - (location int identity primary key, - firstorder int not null, - Firstch nchar(1), - secondorder int not null, - Secondch nchar(1), - Thevalue int not null default 0, - PreviousRowValues varchar(200) - ) - -insert into @PseudoMatrix (firstorder, firstch, secondorder, secondch, TheValue ) -SELECT TheFirst.number,TheFirst.ch, TheSecond.number,TheSecond.ch,0 - FROM --divide up the first string into a table of characters/sequence - (SELECT number, SUBSTRING(@FirstString,number,1) AS ch - FROM numbers WHERE number <= LEN(@FirstString) union all Select 0,Char(0)) TheFirst - cross JOIN --divide up the second string into a table of characters/sequence - (SELECT number, SUBSTRING(@SecondString,number,1) AS ch - FROM numbers WHERE number <= LEN(@SecondString) union all Select 0,Char(0)) TheSecond - --ON Thefirst.ch= Thesecond.ch --do all valid matches -order by TheFirst.number, TheSecond.number - -Declare @current Varchar(255) -Declare @previous Varchar(255) -Declare @TheValue int -Declare @Deletion int, @Insertion int, @Substitution int, @minim int -Select @current='', @previous='' -Update @PseudoMatrix - Set - @Deletion=@TheValue+1, - @Insertion=ascii(substring(@previous,secondorder+1,1))+1, - @Substitution=ascii(substring(@previous,(secondorder),1)) +1, - @minim=case when @Deletion<@Insertion then @Deletion else @insertion end, - @TheValue = Thevalue = case --when Firstorder+SecondOrder=0 then 0 - when SecondOrder=0 then FirstOrder - When FirstOrder=0 then Secondorder - when FirstCh=SecondCh then ascii(substring(@previous,(secondorder),1)) - else case when @Minim<@Substitution then @Minim else @Substitution end - end, - @Previous=PreviousRowValues=case when secondorder =0 then @current else @Previous end, - @current= case when secondorder =0 then char(@TheValue) else @Current+char(@TheValue) end -return @TheValue -End -Go \ No newline at end of file diff --git a/Utilities/README.md b/Utilities/README.md index 9a273579..628e4570 100644 --- a/Utilities/README.md +++ b/Utilities/README.md @@ -1,295 +1,434 @@ # Microsoft SQL Server Utilities and Tools -Useful free and paid Microsoft SQL Server utilities and tools - complete list of **260** SQL Server Utilities +Useful free and paid Microsoft SQL Server utilities and tools - complete list of **395** SQL Server Utilities Utility types (main purpose), in braces `{}` current counts: - - **[B]**: Backup solutions {6} - - **[BI]**: Business Intelligence Solutions {3} - - **[D]**: Documentation solutions {6} - - **[DA]**: Database Architecture {12} - - **[DC]**: Data compare {11} - - **[ETL]**: Extract Download Load (ETL) Tools {1} - - **[I]**: Internal SQL Server utilities (for example, bcp) {15} - - **[IDX]**: Index manager {3} - - **[G]**: Data generation {4} - - **[J]**: Job managers {2} - - **[M]**: Monitoring and alerting Tools {13} - - **[MG]**: Migration tool {24} - - **[MS]**: Management Studio (alternative for SSMS) {22} - - **[REC]**: Recovery tools {7} - - **[S]**: Search tools {3} - - **[SC]**: Structure compare {18} - - **[T]**: Testing tools {5} - - **[ST]**: Statistics utilities {4} - - **[?]**: Not yet classified {111} - -| Name/Description | Cross Database | Cross Platform | Type | Official/Download page | Release Date | Author | License | Free version | Price | -|-----------------------------------------------------------------------|----------------------------------|----------------|------------|---------------------------------------------|--------------|-----------------------|------------|----------------|------:| -| [SSMS](#ssms) | No | No | [MS] | [SSMS] | 2017-10-09 | Microsoft | | Yes | No | -| [bcp Utility](#bcp) | No | No | [I] | [bcp Utility] | 2012-02-11 | Microsoft | | Yes | No | -| [sqlcmd Utility](#sqlcmd-utility) | No | No | [I] | [sqlcmd Utility] | 2016-08-23 | Microsoft | | Yes | No | -| [mssql-cli](#mssql-cli) | No | Linux, Mac | [? ] | [mssql-cli] | 2017-12-13 | Microsoft | BSD-3 | Open Source | No | -| [SQL OPS Studio](#sos) | No | Linux, Mac | [MS] | [SQL OPS Studio] | 2017-11-15 | Microsoft | | Yes | No | -| [RML Utilities for SQL Server](#rml) | No | No | [T] | [RML Utilities for SQL Server] | 2014-12-12 | Microsoft | | Yes | No | -| [GraphView](#graphview) | No | No | [?] | [GraphView] | 2016-02-23 | Microsoft | | Yes | No | -| [Baseline Security Analyze](#baseline-security-analyze) | No | No | [?] | [Baseline Security Analyze] | 2015-01-09 | Microsoft | | Yes | No | -| [tablediff Utility](#tablediff-utility) | No | No | [I] | [tablediff Utility] | - | Microsoft | | Yes | No | -| [Microsoft Log Parser](#microsoft-log-parser) | No | No | [?] | [Microsoft Log Parser] | - | Microsoft | | Yes | No | -| [Log Parser Lizard GUI](#log-parser-lizard-gui) | Oracle, MySQL, PostgreSQL, Other | No | [MS] | [Log Parser Lizard GUI] | 2017-06-01 | Lizard Labs | | Yes | $59 | -| [Diskspd](#diskspd) | No | No | [T] | [Diskspd] | 2015-12-14 | Microsoft | | Yes | No | -| [HammerDB](#hammerdb) | No | No | [T] | [HammerDB] | 2015-05-04 | Open Source | | Yes | No | -| [Exchange Server Error Code Look-up](#error-code-look-up) | No | No | [?] | [Exchange Server Error Code Look-up] | 2004-05-10 | Microsoft | | Yes | No | -| [LINQPad](#linqpad) | No | No | [?] | [LINQPad] | 2016-01-02 | Joseph Albahari | | Non-commercial | $45 | -| [SqlDynamite](#sqldynamite) | No | No | [S] | [SqlDynamite] | 2016-04-06 | Anatoly Sova | | Yes | No | -| [SQL Server Data Tools](#ssdt) | No | No | [MS] | [SQL Server Data Tools] | 2017-04-15 | Microsoft | | Yes | No | -| [Database Health Monitor](#database-health-monitor) | No | No | [M] | [Database Health Monitor] | 2016-03-20 | Steve Stedman | | Yes | No | -| [SchemaDrift](#schemadrift) | No | No | [SC] | [SchemaDrift] | 2016-02-28 | Steve Stedman | | Yes | No | -| [Dbeaver](#dbeaver) | Oracle, MySQL, PostgreSQL, Other | Linux, Mac | [MS] | [Dbeaver] | 2016-06-06 | Open Source | | Yes | No | -| [HeidiSQL](#heidisql) | Oracle, MySQL, PostgreSQL, Other | No | [MS] | [HeidiSQL] | 2016-06-19 | Open Source | | Yes | No | -| [SQLExecStats](#sqlexecstats) | No | No | [ST] | [SQLExecStats] | 2016-02-08 | Joe Chang | | Yes | No | -| [ExpressProfiler](#expressprofiler) | No | No | [?] | [ExpressProfiler] | 2016-02-15 | Chris Moore | | Yes | No | -| [Data Migration Assistant](#data-migration-assistant) | No | No | [MG] | [Data Migration Assistant] | 2017-03-15 | Microsoft | | Yes | No | -| [SQL Server Migration Assistant for Sybase](#sybasetosql) | No | No | [MG] | [Migration Assistant for Sybase] | 2017-02-17 | Microsoft | | Yes | No | -| [dta Utility](#dta-utility) | No | No | [I] | [dta Utility] | - | Microsoft | | Yes | No | -| [osql Utility](#osql-utility) | No | No | [I] | [osql Utility] | - | Microsoft | | Yes | No | -| [sqldiag Utility](#sqldiag-utility) | No | No | [I] | [sqldiag Utility] | - | Microsoft | | Yes | No | -| [sqldumper Utility](#sqldumper-utility) | No | No | [I] | [sqldumper Utility] | - | Microsoft | | Yes | No | -| [SqlLocalDB Utility](#sqllocaldb-utility) | No | No | [I] | [SqlLocalDB Utility] | - | Microsoft | | Yes | No | -| [sqllogship Utility](#sqllogship-utility) | No | No | [I] | [sqllogship Utility] | - | Microsoft | | Yes | No | -| [sqlservr Application](#sqlservr-application) | No | No | [I] | [sqlservr Application] | - | Microsoft | | Yes | No | -| [sqlps Utility](#sqlps-utility) | No | No | [I] | [sqlps Utility] | - | Microsoft | | Yes | No | -| [sqlmaint Utility](#sqlmaint-utility) | No | No | [I] | [sqlmaint Utility] | - | Microsoft | | Yes | No | -| [Ssms Utility](#ssms-utility) | No | No | [I] | [Ssms Utility] | - | Microsoft | | Yes | No | -| [dtexec Utility](#dtexec-utility) | No | No | [I] | [dtexec Utility] | - | Microsoft | | Yes | No | -| [SQL Server 2016 Report Builder](#report-builder-2016) | No | No | [?] | [SQL Server 2016 Report Builder] | 2016-09-16 | Microsoft | | Yes | No | -| [SQL Server 2005 Best Practices Analyzer](#bpa-2005) | No | No | [?] | [BPA 2005] | 2008-08-13 | Microsoft | | Yes | No | -| [SQL Server 2000 Best Practices Analyzer](#bpa-2000) | No | No | [?] | [BPA 2000] | 2010-04-26 | Microsoft | | Yes | No | -| [SQL Server 2008 R2 Best Practices Analyzer](#bpa-2008) | No | No | [?] | [BPA 2008] | 2010-06-18 | Microsoft | | Yes | No | -| [SQL Server 2012 Best Practices Analyzer](#bpa-2012) | No | No | [?] | [BPA 2012] | 2012-06-04 | Microsoft | | Yes | No | -| [DLM Dashboard](#dlm-dashboard) | No | No | [M] | [DLM Dashboard] | 2016-04-27 | Red Gate | | Yes | No | -| [Red Gate SQL Compare](#red-gate-sql-compare) | No | No | [DC] | [Red Gate SQL Compare] | 2016-10-31 | Red Gate | | No | $495 | -| [Red Gate SQL Data Compare](#red-gate-sql-data-compare) | No | No | [SC] | [Red Gate SQL Data Compare] | 2016-05-09 | Red Gate | | No | $495 | -| [Red Gate SQL Prompt](#red-gate-sql-prompt) | No | No | [MS] | [Red Gate SQL Prompt] | 2016-04-28 | Red Gate | | No | $369 | -| [Red Gate SQL Monitor](#red-gate-sql-monitor) | No | No | [M] | [Red Gate SQL Monitor] | 2015-10-15 | Red Gate | | No | $1495 | -| [Red Gate SQL Backup Pro](#red-gate-sql-backup-pro) | No | No | [B] | [Red Gate SQL Backup Pro] | 2014-07-08 | Red Gate | | No | $995 | -| [Red Gate SQL Doc](#red-gate-sql-doc) | No | No | [D] | [Red Gate SQL Doc] | 2016-04-26 | Red Gate | | No | $369 | -| [Red Gate SQL Data Generator](#red-gate-sql-data-generator) | No | No | [G] | [Red Gate SQL Data Generator] | 2016-04-26 | Red Gate | | No | $369 | -| [Red Gate SQL Dependency Tracker](#red-gate-sql-dependency-tracker) | No | No | [?] | [Red Gate SQL Dependency Tracker] | 2016-04-26 | Red Gate | | No | $369 | -| [Red Gate SQL Multi Script](#red-gate-sql-multi-script) | No | No | [?] | [Red Gate SQL Multi Script] | 2016-04-15 | Red Gate | | No | $245 | -| [Red Gate SQL Index Manager](#red-gate-sql-index-manager) | No | No | [IDX] | [Red Gate SQL Index Manager] | ? | Red Gate | | No | $149 | -| [Red Gate SQL Comparison SDK](#red-gate-sql-comparison-sdk) | No | No | [DC], [SC] | [Red Gate SQL Comparison SDK] | 2016-02-22 | Red Gate | | No | $895 | -| [Red Gate SQL Clone](#red-gate-sql-clone) | No | No | [?] | [Red Gate SQL Clone] | 2017-02-27 | Red Gate | | No | $6955 | -| [DLM Automation](#dlm-automation) | No | No | [?] | [DLM Automation] | ? | Red Gate | | No | ? | -| [ReadyRoll](#readyroll) | No | No | [?] | [ReadyRoll] | 2016-01-03 | Red Gate | | No | $345 | -| [Rapid Database Extractor](#rapid-database-extractor) | Oracle | No | [?] | [Rapid Database Extractor] | 2016-11-03 | Idera | | Yes | No | -| [SQL XEvent Profiler](#sql-xevent-profiler) | No | No | [?] | [SQL XEvent Profiler] | 2014-03-14 | Idera | | Yes | No | -| [SQL Check](#sql-check) | No | No | [?] | [SQL Check] | 2015-09-24 | Idera | | Yes | No | -| [SQL Fragmentation Analyzer](#sql-fragmentation-analyzer) | No | No | [?] | [SQL Fragmentation Analyzer] | 2012-11-16 | Idera | | Yes | No | -| [SQL Heat Map](#sql-heat-map) | No | No | [?] | [SQL Heat Map] | 2016-01-27 | Idera | | Yes | No | -| [SQL Hekaton Memory Check](#sql-hekaton-memory-check) | No | No | [?] | [SQL Hekaton Memory Check] | 2015-06-10 | Idera | | Yes | No | -| [SQL Page Viewer](#sql-page-viewer) | No | No | [?] | [SQL Page Viewer] | 2014-08-25 | Idera | | Yes | No | -| [SQL Update Statistics](#sql-update-statistics) | No | No | [ST] | [SQL Update Statistics] | 2015-12-14 | Idera | | Yes | No | -| [SQL Statistics Aggregator](#sql-statistics-aggregator) | No | No | [ST] | [SQL Statistics Aggregator] | 2015-05-18 | Idera | | Yes | No | -| [SQL Backup Status Reporter](#sql-backup-status-reporter) | No | No | [B] | [SQL Backup Status Reporter] | 2015-08-07 | Idera | | Yes | No | -| [SQL Integrity Check](#sql-integrity-check) | No | No | [?] | [SQL Integrity Check] | 2013-08-26 | Idera | | Yes | No | -| [SQL Job Manager](#sql-job-manager) | No | No | [J] | [SQL Job Manager] | 2012-03-19 | Idera | | Yes | No | -| [Azure SQL Database Backup](#azure-sql-database-backup) | No | No | [B] | [Azure SQL Database Backup] | 2012-10-02 | Idera | | Yes | No | -| [SQL Column Search](#sql-column-search) | No | No | [S] | [SQL Column Search] | 2015-11-17 | Idera | | Yes | No | -| [SQL Permissions Extractor](#sql-permissions-extractor) | No | No | [?] | [SQL Permissions Extractor] | 2015-08-07 | Idera | | Yes | No | -| [SQL BI Check](#sql-bi-check) | No | No | [BI] | [SQL BI Check] | 2016-04-13 | Idera | | Yes | No | -| [SQL Inventory Check](#sql-inventory-check) | No | No | [?] | [SQL Inventory Check] | 2016-03-24 | Idera | | Yes | No | -| [SQL Diagnostic Manager](#sql-diagnostic-manager) | No | No | [?] | [SQL Diagnostic Manager] | ? | Idera | | No | $1747 | -| [SQL Safe Backup](#sql-safe-backup) | No | No | [B] | [SQL Safe Backup] | 2016-09-08 | Idera | | No | $907 | -| [SQL Compliance Manager](#sql-compliance-manager) | No | No | [?] | [SQL Compliance Manager] | 2015-09-08 | Idera | | No | $2657 | -| [SQL Inventory Manager](#sql-inventory-manager) | No | No | [?] | [SQL Inventory Manager] | 2016-04-22 | Idera | | No | $3195 | -| [SQL Virtual Database](#sql-virtual-database) | No | No | [?] | [SQL Virtual Database] | 2016-03-24 | Idera | | No | $625 | -| [SQL Secure](#sql-secure) | No | No | [?] | [SQL Secure] | 2016-04-19 | Idera | | No | $907 | -| [SQL Doctor](#sql-doctor) | No | No | [?] | [SQL Doctor] | 2015-12-17 | Idera | | No | $625 | -| [SQL Admin Toolset](#sql-admin-toolset) | No | No | [?] | [SQL Admin Toolset] | 2016-01-13 | Idera | | No | $395 | -| [SQL Defrag Manager](#sql-defrag-manager) | No | No | [?] | [SQL Defrag Manager] | 2016-03-10 | Idera | | No | $1495 | -| [DBArtisan](#dbartisan) | No | No | [?] | [DBArtisan] | ? | Idera | | No | $3122 | -| [SQL BI Manager](#sql-bi-manager) | No | No | [BI] | [SQL BI Manager] | 2015-09-08 | Idera | | No | $697 | -| [SQL Enterprise Job Manager](#sql-enterprise-job-manager) | No | No | [J] | [SQL Enterprise Job Manager] | 2015-09-08 | Idera | | No | $697 | -| [DB Optimizer](#db-optimizer) | No | No | [?] | [DB Optimizer] | ? | Idera | | No | $1420 | -| [SQL Query Store Optimizer](#sql-query-store-optimizer) | No | No | [?] | [SQL Query Store Optimizer] | 2016-07-01 | Idera | | Yes | No | -| [Rapid SQL](#rapid-sql) | Oracle, MySQL, PostgreSQL, Other | No | [MS] | [Rapid SQL] | ? | Idera | | No | $710 | -| [SQL Comparison Toolset](#sql-comparison-toolset) | No | No | [DC], [SC] | [SQL Comparison Toolset] | ? | Idera | | No | $745 | -| [ER/Studio Data Architect](#erstudio-data-architect) | Oracle, MySQL, PostgreSQL, Other | No | [DA] | [ER/Studio Data Architect] | | Idera | | No | $1287 | -| [DB Change Manager](#db-change-manager) | Oracle, MySQL, PostgreSQL, Other | No | [SC] | [DB Change Manager] | ? | Idera | | No | $1420 | -| [Uptime Infrastructure Monitor](#uim) | No | Linux | [?] | [Uptime Infrastructure Monitor] | ? | Idera | | No | ? | -| [dbForge Schema Compare](#dbforge-schema-compare) | No | No | [SC] | [dbForge Schema Compare] | 2016-09-16 | Devart | Shareware | No | $150 | -| [dbForge Data Compare](#dbforge-data-compare) | No | No | [DC] | [dbForge Data Compare] | 2016-09-28 | Devart | Shareware | No | $150 | -| [dbForge Data Generator](#dbforge-data-generator) | No | No | [G] | [dbForge Data Generator] | 2016-09-16 | Devart | Shareware | No | $250 | -| [dbForge Query Builder](#dbforge-query-builder) | No | No | [?] | [dbForge Query Builder] | 2016-08-17 | Devart | Shareware | No | $100 | -| [dbForge Event Profiler](#dbforge-event-profiler) | No | No | [?] | [dbForge Event Profiler] | 2016-09-16 | Devart | Freeware | Yes | No | -| [dbForge SQL Decryptor](#dbforge-sql-decryptor) | No | No | [?] | [dbForge SQL Decryptor] | 2017-04-20 | Devart | Freeware | Yes | No | -| [dbForge Studio](#dbforge-studio) | No | No | [MS] | [dbForge Studio] | 2017-03-12 | Devart | Shareware | Yes | $250 | -| [dbForge Fusion](#dbforge-fusion) | No | No | [?] | [dbForge Fusion] | 2016-12-27 | Devart | Shareware | No | $150 | -| [dbForge Documenter](#dbforge-documenter) | No | No | [D] | [dbForge Documenter] | 2016-09-16 | Devart | Shareware | No | $150 | -| [Devart Excel Add-in for SQL Server](#devart-excel-addin) | No | No | [?] | [Devart Excel Add-in for SQL Server] | 2017-09-13 | Devart | Shareware | No | $100 | -| [dbMonitor](#dbmonitor) | Oracle, PostgreSQL, MySQL, Other | No | [M] | [dbMonitor] | 2012-11-01 | Devart | Freeware | Yes | No | -| [Minion Enterprise](#minion-enterprise) | No | No | [?] | [Minion Enterprise] | ? | MinionWare | | No | $1500 | -| [SQL Server Compression Estimator](#sql-server-compression-estimator) | No | No | [?] | [SQL Server Compression Estimator] | 2011-06-02 | Bob Tavlor | | Yes | No | -| [ClearTrace](#cleartrace) | No | No | [?] | [ClearTrace] | 2016-07-07 | Bill Graziano | | Yes | No | -| [Dell Security Explorer](#dell-security-explorer) | No | No | [?] | [Dell Security Explorer] | 2015-06-25 | Dell | | No | $850 | -| [Dell LiteSpeed for SQL Server](#dell-litespeed-for-sql-server) | No | No | [?] | [Dell LiteSpeed for SQL Server] | 2015-07-31 | Dell | | No | ? | -| [Dell Toad for SQL Server](#dell-toad-for-sql-server) | No | No | [MS] | [Dell Toad for SQL Server] | 2015-05-12 | Dell | | No | ? | -| [Dell Spotlight on SQL Server Enterprise](#dell-spotlight) | No | No | [?] | [Dell Spotlight] | 2016-03-10 | Dell | | No | $2561 | -| [Dell Foglight](#dell-foglight) | No | No | [?] | [Dell Foglight] | 2015-09-22 | Dell | | No | ? | -| [Dell Discovery Wizard](#dell-discovery-wizard) | No | No | [?] | [Dell Discovery Wizard] | 2011-09-22 | Dell | | Yes | No | -| [Dell Enterprise Reporter](#dell-enterprise-reporter) | No | No | [?] | [Dell Enterprise Reporter] | ? | Dell | | No | $511 | -| [SQL Scripter](#sql-scripter) | No | No | [?] | [SQL Scripter] | 2013-02-24 | Thomas Hinsenkamp | | No | €99 | -| [Simple Dynamic Scheduler](#simple-dynamic-scheduler) | No | No | [?] | [Simple Dynamic Scheduler] | 2016-05-02 | Miljan Radovic | | Yes | No | -| [ApexSQL Audit](#apexsql-audit) | No | No | [?] | [ApexSQL Audit] | 2017-07-11 | ApexSQL | | No | $1699 | -| [ApexSQL Backup](#apexsql-backup) | No | No | [B] | [ApexSQL Backup] | 2017-10-12 | ApexSQL | | No | $499 | -| [ApexSQL Defrag](#apexsql-defrag) | No | No | [IDX] | [ApexSQL Defrag] | 2017-06-29 | ApexSQL | | No | $499 | -| [ApexSQL Log](#apexsql-log) | No | No | [?] | [ApexSQL Log] | 2017-05-24 | ApexSQL | | No | $1999 | -| [ApexSQL Monitor](#apexsql-monitor) | No | No | [M] | [ApexSQL Monitor] | 2017-10-05 | ApexSQL | | No | $499 | -| [ApexSQL Plan](#apexsql-plan) | No | No | [?] | [ApexSQL Plan] | 2017-10-26 | ApexSQL | | Yes | No | -| [ApexSQL Propagate](#apexsql-propagate) | No | No | [?] | [ApexSQL Propagate] | 2017-09-25 | ApexSQL | | Yes | No | -| [ApexSQL Recover](#apexsql-recover) | No | No | [REC] | [ApexSQL Recover] | 2017-10-26 | ApexSQL | | No | $1999 | -| [ApexSQL Build](#apexsql-build) | No | No | [?] | [ApexSQL Build] | 2017-05-15 | ApexSQL | | No | $399 | -| [ApexSQL Clean](#apexsql-clean) | No | No | [?] | [ApexSQL Clean] | 2017-09-28 | ApexSQL | | No | $399 | -| [ApexSQL Data Diff](#apexsql-data-diff) | No | No | [DC] | [ApexSQL Data Diff] | 2017-10-26 | ApexSQL | | No | $399 | -| [ApexSQL Decrypt](#apexsql-decrypt) | No | No | [?] | [ApexSQL Decrypt] | 2017-08-16 | ApexSQL | | Yes | No | -| [ApexSQL Diff](#apexsql-diff) | No | No | [SC] | [ApexSQL Diff] | 2017-10-26 | ApexSQL | | No | $399 | -| [ApexSQL Doc](#apexsql-doc) | No | No | [D] | [ApexSQL Doc] | 2017-09-06 | ApexSQL | | No | $299 | -| [ApexSQL Generate](#apexsql-generate) | No | No | [G] | [ApexSQL Generate] | 2017-07-13 | ApexSQL | | No | $499 | -| [ApexSQL Script](#apexsql-script) | No | No | [?] | [ApexSQL Script] | 2016-05-10 | ApexSQL | | No | $249 | -| [ApexSQL Trigger](#apexsql-trigger) | No | No | [?] | [ApexSQL Trigger] | 2017-06-01 | ApexSQL | | No | $1999 | -| [ApexSQL Trigger Veiwer](#apexsql-trigger-viewer) | No | No | [?] | [ApexSQL Trigger Viewer] | 2017-06-01 | ApexSQL | | Yes | No | -| [ApexSQL Snapshot Utility](#apexsql-snapshot-utility) | No | No | [?] | [ApexSQL Snapshot Utility] | 2016-01-12 | ApexSQL | | Yes | No | -| [DBBest T-SQL Analyzer](#dbbest-t-sql-analyzer) | No | No | [?] | [DBBest T-SQL Analyzer] | 2015-03-13 | DBBest | | No | $89 | -| [DBBest Database Compare Suite](#dbbest-database-compare-suite) | No | No | [SC], [DC] | [DBBest Database Compare Suite] | 2015-09-04 | DBBest | | No | $349 | -| [Advanced Query Tool](#advanced-query-tool) | No | No | [?] | [Advanced Query Tool] | 2015-03-18 | Cardett Associates | | No | $180 | -| [SqlDiffFramework](#sqldiffframework) | No | No | [SC] | [SqlDiffFramework] | 2012-04-17 | Michael Sorens | | Yes | No | -| [DataGrip](#datagrip) | Oracle, MySQL, PostgreSQL, Other | Linux, Mac | [MS] | [DataGrip] | 2017-02-21 | Jet Brains | | No | $89 | -| [Pssdiag and Sqldiag Manager](#pssdiag-and-sqldiag-manager) | No | No | [?] | [Pssdiag and Sqldiag Manager] | 2017-01-06 | Jack Li | | Yes | No | -| [SQL Nexus Tool](#sql-nexus-tool) | No | No | [?] | [SQL Nexus Tool] | 2016-11-20 | Jack Li | | Yes | No | -| [DBSophic Qure Profiler](#dbsophic-qure-profiler) | No | No | [?] | [DBSophic Qure Profiler] | ? | DBSophic | | No | $300 | -| [DBSophic Qure Optimizer](#dbsophic-qure-optimizer) | No | No | [?] | [DBSophic Qure Optimizer] | ? | DBSophic | | No | ? | -| [RestoreChecker](#restorechecker) | No | No | [?] | [RestoreChecker] | 2015-01-15 | SQLServerUtilities | | No | $99 | -| [SQLScripter](#sqlscripter) | No | No | [?] | [SQLScripter] | 2009-08-24 | SQLServerUtilities | | No | $99 | -| [SQLC](#sqlc) | No | No | [DC], [SC] | [SQLC] | 2017-11-19 | David Ingleton | | Yes | No | -| [Database Performance Analyzer](#dpa-solarwinds) | Oracle, MySQL, Other | Linux | [M] | [Database Performance Analyzer] | ? | SolarWinds | | No | $1995 | -| [Database Performance Analyzer for MSSQL](#dpa-solarwinds-mssql) | No | No | [M] | [Database Performance Analyzer for MSSQL] | ? | SolarWinds | | No | $1995 | -| [SQL Enlight](#sql-enlight) | No | No | [MS] | [SQL Enlight] | 2016-04-25 | UbitSoft | | No | $295 | -| [Aireforge Studio](#aireforge-studio) | No | No | [MG], [SC] | [Aireforge Studio] | 2017-06-21 | AireForge | | Yes | $299 | -| [HexaTier](#hexatier) | No | No | [?] | [HexaTier] | ? | HexaTier | | No | ? | -| [SoftTree SQL Assistant](#softtree-sql-assistant) | Oracle, MySQL, PostgreSQL, Other | No | [MS] | [SoftTree SQL Assistant] | 2017-12-17 | SoftTree | | No | $215 | -| [DB Audit and Security 360](#db-audit-and-security-360) | Oracle, MySQL, Other | No | [?] | [DB Audit and Security 360] | 2015-02-07 | SoftTree | | No | $499 | -| [EMS SQL Management Studio](#ems-management-studio) | No | No | [MS] | [EMS SQL Management Studio] | 2016-05-26 | EMS | | No | $257 | -| [EMS SQL Backup](#ems-sql-backup) | No | No | [B] | [EMS SQL Backup] | 2016-04-13 | EMS | | Yes | $82 | -| [EMS SQL Administrator](#ems-sql-administrator) | No | No | [?] | [EMS SQL Administrator] | 2015-04-14 | EMS | | Yes | $135 | -| [EMS SQL Manager](#ems-sql-manager) | No | No | [?] | [EMS SQL Manager] | 2016-05-26 | EMS | | Yes | $135 | -| [EMS Data Export](#ems-data-export) | No | No | [?] | [EMS Data Export] | 2016-04-29 | EMS | | No | $47 | -| [EMS Data Import](#ems-data-import) | No | No | [?] | [EMS Data Import] | 2016-04-14 | EMS | | No | $47 | -| [EMS Data Pump](#ems-data-pump) | No | No | [?] | [EMS Data Pump] | 2016-11-03 | EMS | | No | $47 | -| [EMS Data Generator](#ems-generator) | No | No | [G] | [EMS Data Generator] | 2010-07-10 | EMS | | No | $47 | -| [EMS DB Comparer](#ems-bd-comparer) | No | No | [SC] | [EMS DB Comparer] | 2015-07-24 | EMS | | No | $47 | -| [EMS DB Extract](#ems-bd-extract) | No | No | [?] | [EMS DB Extract] | 2008-10-16 | EMS | | No | $47 | -| [EMS SQL Query](#ems-sql-query) | No | No | [?] | [EMS SQL Query] | 2012-03-29 | EMS | | No | $47 | -| [EMS Data Comparer](#ems-data-comparer) | No | No | [DC] | [EMS Data Comparer] | 2012-11-16 | EMS | | No | $47 | -| [NitroAccelerator](#nitroaccelerator) | No | No | [?] | [NitroAccelerator] | 2016-07-10 | Nitrosphere | | No | $1265 | -| [ERwin Data Modeler](#erwin-data-modeler) | Oracle, MySQL, PostgreSQL, Other | No | [DA] | [ERwin Data Modeler] | 2016-06-03 | ERwin | | No | $810 | -| [Toad Data Modeler](#toad-data-modeler) | Oracle, MySQL, PostgreSQL, Other | No | [DA] | [Toad Data Modeler] | 2016-06-16 | Dell | | No | $562 | -| [SQL Power Architect](#sql-power-architect) | Oracle, MySQL, PostgreSQL, Other | Linux, Mac | [DA] | [SQL Power Architect] | 2016-02-11 | SQLPower | | Yes | $995 | -| [DbWrench](#dbwrench) | Oracle, MySQL, PostgreSQL, Other | Linux, Mac | [DA] | [DbWrench] | 2016-07-06 | Nizana Systems | | No | $99 | -| [Navicat Data Modeler](#navicat-data-modeler) | Oracle, MySQL, PostgreSQL, Other | Linux, Mac | [DA] | [Navicat Data Modeler] | 2016-08-01 | PremiumSoft | | No | $199 | -| [DeZign for Databases](#dezign-for-databases) | Oracle, MySQL, PostgreSQL, Other | No | [DA] | [DeZign for Databases] | 2016-04-25 | Datanamic | | No | $259 | -| [ERDesigner NG](#erdesigner-ng) | Oracle, MySQL, PostgreSQL, Other | Linux, Mac | [DA] | [ERDesigner NG] | 2013-04-10 | Mirko Sertic | | Open Source | No | -| [Vertabelo](#vertabelo) | Oracle, MySQL, PostgreSQL, Other | Online | [DA] | [Vertabelo] | ? | Vertabelo | | No | $948 | -| [dbDiffo](#dbdiffo) | Oracle, MySQL, PostgreSQL, Other | Online | [DA] | [dbDiffo] | ? | Contenet Ltd | | Yes | No | -| [SQL DXP](#sql-dxp) | Oracle, MySQL | No | [DC], [SC] | [SQL DXP] | 2016-06-20 | SQL Delta | | No | $530 | -| [Aqua Data Studio](#aqua-data-studio) | Oracle, MySQL, PostgreSQL, Other | Linux, Mac | [MS] | [Aqua Data Studio] | 2016-07-06 | AquaFold | | No | $499 | -| [RazorSQL](#razorsql) | Oracle, MySQL, PostgreSQL, Other | Linux, Mac | [MS] | [RazorSQL] | 2016-09-29 | Richardson Software | | No | $100 | -| [SQL Pretty Printer](#sql-pretty-printer) | No | No | [?] | [SQL Pretty Printer] | 2016-02-19 | Gudu Software | | No | $50 | -| [Database .NET](#database-net) | Oracle, MySQL, PostgreSQL, Other | No | [MS], [SC] | [Database .NET] | 2017-01-13 | fish's dotNET | | Non-commercial | $69 | -| [dbMigration .NET](#dbmegration-net) | Oracle, MySQL, PostgreSQL, Other | No | [DC], [SC] | [dbMigration .NET] | 2017-01-13 | fish's dotNET | | Non-commercial | $49 | -| [Is It SQL](#is-it-sql) | No | No | [M] | [Is It SQL] | 2017-04-06 | Bill Graziano | | Non-commercial | No | -| [Database Experimentation Assistant Technical Preview 2](#dea) | No | No | [T] | [Database Experimentation Assistant] | 2017-03-24 | Microsoft | | Yes | No | -| [Data Platform Studio](#dps) | No | No | [MG] | [Data Platform Studio] | ? | Red Gate Software | | Yes | ? | -| [Flyway](#flyway) | Oracle, PostgreSQL, MySQL, Other | No | [MG] | [Flyway] | ? | boxfuse | | Open Source | No | -| [Liquibase](#liquibase) | Oracle, PostgreSQL, MySQL, Other | No | [?] | [Liquibase] | 2016-10-24 | Liquibase | | Open Source | No | -| [My Batis](#my-batis) | Oracle, PostgreSQL, MySQL, Other | Linux, Mac | [MG] | [My Batis] | 2016-06-22 | My Batis | | Open Source | No | -| [SentryOne Plan Explorer](#sentryone-plan-explorer) | No | No | [?] | [SentryOne Plan Explorer] | 2017-05-25 | SentryOne | | Yes | No | -| [SQL Sentry](#sql-sentry) | No | No | [M] | [SQL Sentry] | 2016-12-07 | SentryOne | | No | ? | -| [DBmaestro TeamWork](#dbmaestro-teamwork) | Oracle | No | [?] | [DBmaestro TeamWork] | ? | DBmaestro | | No | ? | -| [xSQL Schema Compare](#xsql-schema-compare) | No | No | [SC] | [xSQL Schema Compare] | 2017-03-01 | xSQL Software | Shareware | Yes | $399 | -| [xSQL Data Compare](#xsql-data-compare) | No | No | [DK] | [xSQL Data Compare] | 2017-06-26 | xSQL Software | Shareware | Yes | $399 | -| [xSQL Script Executor](#xsql-script-executor) | MySQL, DB2, SQL Server CE | No | [?] | [xSQL Script Executor] | 2015-02-25 | xSQL Software | Freeware | Yes | $249 | -| [xSQL Builder](#xsql-builder) | No | No | [?] | [xSQL Builder] | 2017-03-15 | xSQL Software | Shareware | No | $799 | -| [xSQL Documenter](#xsql-documenter) | Oracle, MySQL, SQLite, Other | No | [D] | [xSQL Documenter] | 2017-01-04 | xSQL Software | Shareware | No | $199 | -| [xSQL Profiler](#xsql-profiler) | No | No | [?] | [xSQL Profiler] | 2017-06-28 | xSQL Software | Shareware | Yes | $999 | -| [xSQL Schema Compare SDK](#xsql-schema-compare-sdk) | No | No | [SC] | [xSQL Schema Compare SDK] | 2017-10-25 | xSQL Software | Shareware | No | $1499 | -| [xSQL RSS Reporter](#xsql-rss-reporter) | No | No | [D] | [xSQL RSS Reporter] | 2014-11-25 | xSQL Software | Shareware | No | $169 | -| [xSQL Database Searcher](#xsql-database-sercher) | No | No | [S] | [xSQL Database Searcher] | 2017-05-09 | xSQL Software | Freeware | Yes | No | -| [Cloud-based DB Monitoring Platform](#cbmp) | No | Android, iOS | [M] | [Cloud-based DB Monitoring Platform] | ? | SQLTreeo | | No | €180 | -| [SchemaCrawler](#schema-crawler) | Oracle, PostgreSQL, MySQL, Other | Yes | [D], [SC] | [SchemaCrawler] | 2017-02-27 | Sualeh Fatehi | | Open Source | No | -| [SA MaaS Microsoft SQL Server](#sa-maas) | No | No | [M] | [SA MaaS Microsoft SQL Server] | ? | SENTINELAGENT | | No | ? | -| [CatCompare v2](#cat-compare) | No | No | [?] | [CatCompare v2] | 2017-01-07 | Andy Leonard | | No | $295 | -| [SSIS Catalog Compare v2.0 Bundle](#catalog-compare-bundle) | No | No | [?] | [SSIS Catalog Compare v2.0 Bundle] | 2017-01-06 | Andy Leonard | | No | $495 | -| [MS Kerberos Configuration Manager](#mkcm) | No | No | [?] | [MS Kerberos Configuration Manager] | 2017-01-31 | Microsoft | | Yes | No | -| [Spotlight](#spotlight) | No | No | [M] | [Spotlight] | ? | Quest Software | | Yes | ? | -| [DBConvert Studio](#dbconvert-studio) | Oracle, PostgreSQL, MySQL, Other | No | [MG] | [DBConvert Studio] | 2017-03-01 | DMSoft Technologies | | No | $499 | -| [DbDefence](#dbdefence) | No | No | [?] | [DbDefence] | 2017-03-01 | ActiveCrypt Software | | Yes | $698 | -| [SQL Server Migration Assistant for MySQL](#ssma-mysql) | MySQL | No | [MG] | [SQL Server Migration Assistant for MySQL] | 2017-02-17 | Microsoft | | Yes | No | -| [sqlcmd for Mac and Linux](#sqlcmd) | No | Linux, Mac | [?] | [sqlcmd for Mac and Linux] | 2017-01-26 | Soheil Rashidi | | Open Source | No | -| [SQL Migrator](#sql-migrator) | No | No | [MG] | [SQL Migrator] | ? | Datamate Technology | | ? | ? | -| [MS FoxPro to MS SQL Migration and Sync](#foxpro-sqlserver) | No | No | [MG] | [MS FoxPro to MS SQL Migration and Sync] | 2013-10-08 | DMSoft Technologies | | No | $149 | -| [MySQL to MS SQL Migration and Sync](#mysql-sqlserver) | No | No | [MG] | [MySQL to MS SQL Migration and Sync] | 2013-10-08 | DMSoft Technologies | | No | $149 | -| [Oracle to MS SQL Migration and Sync](#oracle-sqlserver) | No | No | [MG] | [Oracle to MS SQL Migration and Sync] | 2013-10-09 | DMSoft Technologies | | No | $149 | -| [PostgreSQL to MS SQL Migration and Sync](#postgresql-sqlserver) | No | No | [MG] | [PostgreSQL to MS SQL Migration and Sync] | 2013-10-08 | DMSoft Technologies | | No | $149 | -| [MS Excel to MS SQL Migration](#msexcel-sqlserver) | No | No | [MG] | [MS Excel to MS SQL Migration] | 2013-09-23 | DMSoft Technologies | | No | $149 | -| [SQLite to MS SQL Migration and Sync](#sqllite-sqlserver) | No | No | [MG] | [SQLite to MS SQL Migration and Sync] | 2014-05-08 | DMSoft Technologies | | No | $149 | -| [IBM DB2 to MS SQL Migration and Sync](#db2-sqlserver) | No | No | [MG] | [IBM DB2 to MS SQL Migration and Sync] | 2013-09-09 | DMSoft Technologies | | No | $149 | -| [MS Access to MS SQL Migration and Sync](#access-sqlserver) | No | No | [MG] | [MS Access to MS SQL Migration and Sync] | 2013-10-08 | DMSoft Technologies | | No | $149 | -| [Firebird to MS SQL Migration and Sync](#firebird-sqlserver) | No | No | [MG] | [Firebird to MS SQL Migration and Sync] | 2013-09-11 | DMSoft Technologies | | No | $149 | -| [SQLines SQL Converter](#sqllines-converter) | No | No | [MG] | [SQLines SQL Converter] | ? | Dmtolpeko | | Open Source | No | -| [SQLite & SQL Server Compact Toolbox](#sqlite-and-sqlserver-toolbox) | No | No | [?] | [SQLite & SQL Server Compact Toolbox] | ? | ErikEJ | | Open Source | No | -| [SqlPad](#sqlpad) | Postgres, MySQL, Crate, Vertica | No | [MS] | [SqlPad] | ? | Rickbergfalk | | Open Source | No | -| [Html-query-plan](#html-query-plan) | No | No | [?] | [Html-query-plan] | ? | JustinPealing | | Open Source | No | -| [SqlQueryStress](#sql-query-stress) | No | No | [?] | [SqlQueryStress] | ? | Adam Machanic | | Open Source | No | -| [SQL Server Migration Assistant for DB2](#ssma-db2) | DB2 | No | [MG] | [SQL Server Migration Assistant for DB2] | 2017-02-17 | Microsoft | | Yes | No | -| [SQL Server Migration Assistant for Oracle](#ssma-oracle) | Oracle | No | [MG] | [SQL Server Migration Assistant for Oracle] | 2017-02-17 | Microsoft | | Yes | No | -| [SQL Server Migration Assistant for Access](#ssma-access) | Access | No | [MG] | [SQL Server Migration Assistant for Access] | 2017-02-17 | Microsoft | | Yes | No | -| [mssql for Visual Studio Code](#mssql-for-vs-code) | No | Linux, Mac | [MS] | [mssql for Visual Studio Code] | 2017-05-02 | Microsoft | | Open Source | No | -| [Microsoft Assessment and Planning](#map) | No | No | [?] | [Microsoft Assessment and Planning] | 2017-02-10 | Microsoft | | Yes | No | -| [mssql-scripter](#mssql-scripter) | No | Linux, Mac | [?] | [mssql-scripter] | ? | Microsoft | | Open Source | No | -| [DBFS](#dbfs) | No | Linux | [M] | [DBFS] | ? | Microsoft | | Open Source | No | -| [comparator](#pumpet-comparator) | Oracle, PostgreSQL, MySQL, Other | No | [DC] | [comparator] | 2017-06-06 | Pumpet | [LGPL-3.0] | Open Source | No | -| [Navicat for SQL Server](#navicat-for-sql-server) | No | Mac | [MS] | [Navicat for SQL Server] | 2017-06-14 | PremiumSoft | | No | $699 | -| [Navicat Premium](#navicat-premium) | Oracle, PostgreSQL, MySQL, Other | Mac | [MS] | [Navicat Premium] | 2017-06-14 | PremiumSoft | | No | $1299 | -| [DbVisualizer](#dbvisualizer) | Oracle, PostgreSQL, MySQL, Other | Linux, Mac | [MS], [DA] | [DbVisualizer] | 2017-11-16 | DbVis Software AB. | | Yes | $197 | -| [DbSchema](#dbschema) | Oracle, PostgreSQL, MySQL, Other | Linux, Mac | [DA] | [DbSchema] | 2017-06-19 | Wise Coders Solutions | | Yes | $127 | -| [DBGhost](#dbghost) | No | No | [?] | [DBGhost] | 2017-01-31 | Innovartis Ltd | | No | £430 | -| [SQLAutomate](#sqlautomate) | Oracle, MySQL, Other | No | [?] | [SQLAutomate] | 2017-06-19 | OnLine ToolWorks     | | No | $99 | -| [BimlExpress](#bimlexpress) | No | No | [?] | [BimlExpress] | ? | Varigence   | | No | No | -| [BIDS Helper](#bidshelper) | No | No | [?] | [BIDS Helper] | 2015-03-17 | Microsoft   | | Open Source | No | -| [Azure Data Warehouse Migration Utility](#azure-data-migration) | No | No | [MG] | [Azure Data Warehouse Migration Utility] | ? | Microsoft | | ? | ? | -| [Dell Benchmark Factory](#dell-benchmark-factory) | Oracle, MySQL, Other | No | [T] | [Dell Benchmark Factory] | ? | Quest Software | | No | $4413 | -| [manduka](#maduka) | ? | Linux, Mac | [?] | [manduka] | 2017-03-08 | Virtusa Corporation | | Yes | No | -| [PowerBI Desktop](#powerbi-desktop) | Oracle, PostgreSQL, MySQL, Other | No | [BI] | [PowerBI Desktop] | 2017-07-11 | Microsoft | | Yes | ? | -| [Stellar Phoenix SQL Database Repair](#stellar-phoenix) | No | No | [REC] | [Stellar Phoenix SQL Database Repair] | 2017-07-05 | Stellar Technology | | No | $349 | -| [DataNumen SQL Recovery](#datanumen-sql-recovery) | No | No | [REC] | [DataNumen SQL Recovery] | 2017-03-20 | DataNumen | | No | $500 | -| [Recovery Toolbox for SQL Server](#recovery-toolbox-for-sql-server) | No | No | [REC] | [Recovery Toolbox for SQL Server] | ? | Recovery Toolbox | Shareware | No | $99 | -| [SQL MDF Viewer](#sql-mdf-viewer) | No | No | [?] | [SQL MDF Viewer] | ? | SysTools | Shareware | No | $129 | -| [SQL MDF Recovery Tool](#sql-mdf-recovery-tool) | No | No | [REC] | [SQL MDF Recovery Tool] | ? | SysTools | Shareware | No | $129 | -| [SQL Passord Recovery](#sql-password-recovery) | No | No | [REC] | [SQL Passord Recovery] | ? | SysTools | Shareware | No | $69 | -| [SQL Decryptor](#sql-decryptor) | No | No | [?] | [SQL Decryptor] | ? | SysTools | Shareware | No | $69 | -| [SQL Backup Database Recovery](#sql-backup-database-recovery) | No | No | [REC] | [Backup Database Recovery] | ? | SysTools | Shareware | No | $149 | -| [SQL Log File Viewer](#sql-log-file-viewer) | No | No | [?] | [Log File Viewer] | ? | SysTools | Shareware | No | $999 | -| [DAX Studio](#dax-studio) | No | No | [?] | [DAX Studio] | ? | Sqlbi | Freeware | Yes | No | -| [SQL Cop](#sql-cop) | No | No | [?] | [SQL Cop] | ? | LessThanDot | Freeware | Yes | No | -| [Dataedo](#dataedo) | Oracle, MySQL | No | [D] | [Dataedo] | 2017-09-15 | Logic Systems | Shareware | Yes | $239 | -| [Azure Database Migration Service](#azure-db-migration) | Oracle, MySQL, Other | Online | [MG] | [Azure Database Migration Service] | 2017-12-01 | Microsoft | | Yes | No | -| [FlowHeater](#flowheater) | Oracle, PostgreSQL, MySQL, Other | No | [ETL] | [FlowHeater] | 2017-10-02 | FlowHeater GmbH | Shareware | No | $79 | -| [EDIS](#edis) | No | No | [ETL] | [EDIS] | ? | SQL ETL | Shareware | Yes | $599 | +- **[B]**: Backup solutions {17} +- **[BI]**: Business Intelligence Solutions {4} +- **[D]**: Documentation solutions {8} +- **[DA]**: Database Architecture {20} +- **[DC]**: Data compare {15} +- **[ETL]**: Extract Download Load (ETL) Tools {9} +- **[I]**: Internal SQL Server utilities (for example, bcp) {15} +- **[IDX]**: Index manager {3} +- **[G]**: Data generation {4} +- **[J]**: Job managers {4} +- **[M]**: Monitoring and alerting Tools {28} +- **[MG]**: Migration tool {31} +- **[MS]**: Management Studio (alternative for SSMS) {33} +- **[REC]**: Recovery tools {13} +- **[S]**: Search tools {7} +- **[SEC]**: Security tools {7} +- **[SC]**: Structure compare {21} +- **[ST]**: Statistics utilities {3} +- **[T]**: Testing tools {7} +- **[?]**: Not yet classified {156} + +| Name/Description | Cross Database | Platform | Type | Official/Download page | Release | Author | License | Free version | Price | +|------------------------------------------------------------------|-------------------------------|-----------|----------|----------------------------------------------------|------------|-------------------------|------------|----------------|------:| +| [SSMS](#ssms) | No | No | [MS] | [SSMS] | 2020-10-27 | Microsoft | Freeware | Yes | No | +| [Azure Data Studio](#ads) | PostgreSQL | Linux,Mac | [MS] | [Azure Data Studio] | 2020-11-12 | Microsoft | [MIT] | Open Source | No | +| [bcp Utility](#bcp) | No | No | [I] | [bcp Utility] | 2012-02-11 | Microsoft | | Yes | No | +| [sqlcmd Utility](#sqlcmd-utility) | No | No | [I] | [sqlcmd Utility] | 2016-08-23 | Microsoft | | Yes | No | +| [mssql-cli](#mssql-cli) | No | Linux,Mac | [?] | [mssql-cli] | 2020-05-01 | Microsoft | [BSD-3] | Open Source | No | +| [RML Utilities for SQL Server](#rml) | No | No | [T] | [RML Utilities for SQL Server] | 2014-12-12 | Microsoft | | Yes | No | +| [GraphView](#graphview) | No | No | [?] | [GraphView] | 2016-02-23 | Microsoft | | Yes | No | +| [Baseline Security Analyze](#baseline-security-analyze) | No | No | [SEC] | [Baseline Security Analyze] | 2015-01-09 | Microsoft | | Yes | No | +| [tablediff Utility](#tablediff-utility) | No | No | [I] | [tablediff Utility] | - | Microsoft | | Yes | No | +| [Microsoft Log Parser](#microsoft-log-parser) | No | No | [?] | [Microsoft Log Parser] | - | Microsoft | | Yes | No | +| [Log Parser Lizard GUI](#log-parser-lizard-gui) | Oracle,MySQL,PostgreSQL,Other | No | [MS] | [Log Parser Lizard GUI] | 2017-06-01 | Lizard Labs | | Yes | $59 | +| [Diskspd](#diskspd) | No | No | [T] | [Diskspd] | 2015-12-14 | Microsoft | | Yes | No | +| [HammerDB](#hammerdb) | No | No | [T] | [HammerDB] | 2015-05-04 | Open Source | | Yes | No | +| [Exchange Server Error Code Look-up](#error-code-look-up) | No | No | [?] | [Exchange Server Error Code Look-up] | 2004-05-10 | Microsoft | | Yes | No | +| [LINQPad](#linqpad) | No | No | [?] | [LINQPad] | 2016-01-02 | Joseph Albahari | | Non-commercial | $45 | +| [SqlDynamite](#sqldynamite) | No | No | [S] | [SqlDynamite] | 2016-04-06 | Anatoly Sova | | Yes | No | +| [SQL Server Data Tools](#ssdt) | No | No | [MS] | [SQL Server Data Tools] | 2018-04-10 | Microsoft | | Yes | No | +| [Database Health Monitor](#database-health-monitor) | No | No | [M] | [Database Health Monitor] | 2019-12-01 | Steve Stedman | | Yes | No | +| [SchemaDrift](#schemadrift) | No | No | [SC] | [SchemaDrift] | 2016-02-28 | Steve Stedman | | Yes | No | +| [Dbeaver](#dbeaver) | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [MS] | [Dbeaver] | 2020-11-29 | Open Source | | Yes | No | +| [HeidiSQL](#heidisql) | MySQL,PostgreSQL,Other | No | [MS] | [HeidiSQL] | 2020-11-02 | Open Source | | Yes | No | +| [SQLExecStats](#sqlexecstats) | No | No | [ST] | [SQLExecStats] | 2016-02-08 | Joe Chang | | Yes | No | +| [ExpressProfiler](#expressprofiler) | No | No | [?] | [ExpressProfiler] | 2016-02-15 | Chris Moore | | Yes | No | +| [Data Migration Assistant](#data-migration-assistant) | No | No | [MG] | [Data Migration Assistant] | 2020-04-23 | Microsoft | | Yes | No | +| [SQL Server Migration Assistant for Sybase](#sybasetosql) | No | No | [MG] | [Migration Assistant for Sybase] | 2017-02-17 | Microsoft | | Yes | No | +| [dta Utility](#dta-utility) | No | No | [I] | [dta Utility] | - | Microsoft | | Yes | No | +| [osql Utility](#osql-utility) | No | No | [I] | [osql Utility] | - | Microsoft | | Yes | No | +| [sqldiag Utility](#sqldiag-utility) | No | No | [I] | [sqldiag Utility] | - | Microsoft | | Yes | No | +| [sqldumper Utility](#sqldumper-utility) | No | No | [I] | [sqldumper Utility] | - | Microsoft | | Yes | No | +| [SqlLocalDB Utility](#sqllocaldb-utility) | No | No | [I] | [SqlLocalDB Utility] | - | Microsoft | | Yes | No | +| [sqllogship Utility](#sqllogship-utility) | No | No | [I] | [sqllogship Utility] | - | Microsoft | | Yes | No | +| [sqlservr Application](#sqlservr-application) | No | No | [I] | [sqlservr Application] | - | Microsoft | | Yes | No | +| [sqlps Utility](#sqlps-utility) | No | No | [I] | [sqlps Utility] | - | Microsoft | | Yes | No | +| [sqlmaint Utility](#sqlmaint-utility) | No | No | [I] | [sqlmaint Utility] | - | Microsoft | | Yes | No | +| [SSMS Utility](#ssms-utility) | No | No | [I] | [SSMS Utility] | - | Microsoft | | Yes | No | +| [dtexec Utility](#dtexec-utility) | No | No | [I] | [dtexec Utility] | - | Microsoft | | Yes | No | +| [adutil Utility](#adutil-utility) | No | Linux | [I] | [adutil Utility] | 2020-10-30 | Microsoft | | Yes | No | +| [SQL Server 2016 Report Builder](#report-builder-2016) | No | No | [?] | [SQL Server 2016 Report Builder] | 2016-09-16 | Microsoft | | Yes | No | +| [SQL Server 2005 Best Practices Analyzer](#bpa-2005) | No | No | [?] | [BPA 2005] | 2008-08-13 | Microsoft | | Yes | No | +| [SQL Server 2000 Best Practices Analyzer](#bpa-2000) | No | No | [?] | [BPA 2000] | 2010-04-26 | Microsoft | | Yes | No | +| [SQL Server 2008 R2 Best Practices Analyzer](#bpa-2008) | No | No | [?] | [BPA 2008] | 2010-06-18 | Microsoft | | Yes | No | +| [SQL Server 2012 Best Practices Analyzer](#bpa-2012) | No | No | [?] | [BPA 2012] | 2012-06-04 | Microsoft | | Yes | No | +| [Elastic database tools](#elastic-database-tools) | No | No | [?] | [Elastic database tools] | ? | Microsoft | | Yes | No | +| [Microsoft Sync Framework](#microsoft-sync-framework) | No | No | [?] | [Microsoft Sync Framework] | 2020-04-22 | Microsoft | | Yes | No | +| [Query Performance Insight for Azure SQL Database](#query-perf) | No | No | [?] | [Query Performance Insight for Azure SQL Database] | ? | Microsoft | | Yes | No | +| [Microsoft Assessment and Planning (MAP) Toolkit](#map) | No | No | [MG] | [Microsoft Assessment and Planning (MAP) Toolkit] | 2020-05-26 | Microsoft | | Yes | No | +| [DLM Dashboard](#dlm-dashboard) | No | No | [M] | [DLM Dashboard] | 2016-04-27 | Red Gate | | Yes | No | +| [Red Gate SQL Compare](#red-gate-sql-compare) | No | No | [DC] | [Red Gate SQL Compare] | 2016-10-31 | Red Gate | | No | $495 | +| [Red Gate SQL Data Compare](#red-gate-sql-data-compare) | No | No | [SC] | [Red Gate SQL Data Compare] | 2016-05-09 | Red Gate | | No | $495 | +| [Red Gate SQL Monitor](#red-gate-sql-monitor) | No | No | [M] | [Red Gate SQL Monitor] | 2015-10-15 | Red Gate | | No | $1495 | +| [Red Gate SQL Backup Pro](#red-gate-sql-backup-pro) | No | No | [B] | [Red Gate SQL Backup Pro] | 2014-07-08 | Red Gate | | No | $995 | +| [Red Gate SQL Doc](#red-gate-sql-doc) | No | No | [D] | [Red Gate SQL Doc] | 2016-04-26 | Red Gate | | No | $369 | +| [Red Gate SQL Data Generator](#red-gate-sql-data-generator) | No | No | [G] | [Red Gate SQL Data Generator] | 2016-04-26 | Red Gate | | No | $369 | +| [Red Gate SQL Dependency Tracker](#sql-dependency-tracker) | No | No | [?] | [Red Gate SQL Dependency Tracker] | 2016-04-26 | Red Gate | | No | $369 | +| [Red Gate SQL Multi Script](#red-gate-sql-multi-script) | No | No | [?] | [Red Gate SQL Multi Script] | 2016-04-15 | Red Gate | | No | $245 | +| [Red Gate SQL Index Manager](#red-gate-sql-index-manager) | No | No | [IDX] | [Red Gate SQL Index Manager] | ? | Red Gate | | No | $149 | +| [Red Gate SQL Comparison SDK](#red-gate-sql-comparison-sdk) | No | No | [DC],[SC]| [Red Gate SQL Comparison SDK] | 2016-02-22 | Red Gate | | No | $895 | +| [Red Gate SQL Clone](#red-gate-sql-clone) | No | No | [?] | [Red Gate SQL Clone] | 2017-02-27 | Red Gate | | No | $6955 | +| [Red Gate SQL Provision](#red-gate-sql-provision) | No | No | [?] | [Red Gate SQL Provision] | 2018-02-26 | Red Gate | | No | $2955 | +| [Red Gate Data Masker](#red-gate-data-masker) | Oracle | No | [?] | [Red Gate SQL Data Masker] | 2018-02-26 | Red Gate | | No | $2395 | +| [DLM Automation](#dlm-automation) | No | No | [?] | [DLM Automation] | ? | Red Gate | | No | ? | +| [ReadyRoll](#readyroll) | No | No | [?] | [ReadyRoll] | 2016-01-03 | Red Gate | | No | $345 | +| [Rapid Database Extractor](#rapid-database-extractor) | Oracle | No | [?] | [Rapid Database Extractor] | 2016-11-03 | Idera | | Yes | No | +| [SQL XEvent Profiler](#sql-xevent-profiler) | No | No | [?] | [SQL XEvent Profiler] | 2014-03-14 | Idera | | Yes | No | +| [SQL Check](#sql-check) | No | No | [?] | [SQL Check] | 2015-09-24 | Idera | | Yes | No | +| [SQL Fragmentation Analyzer](#sql-fragmentation-analyzer) | No | No | [?] | [SQL Fragmentation Analyzer] | 2012-11-16 | Idera | | Yes | No | +| [SQL Heat Map](#sql-heat-map) | No | No | [?] | [SQL Heat Map] | 2016-01-27 | Idera | | Yes | No | +| [SQL Hekaton Memory Check](#sql-hekaton-memory-check) | No | No | [?] | [SQL Hekaton Memory Check] | 2015-06-10 | Idera | | Yes | No | +| [SQL Page Viewer](#sql-page-viewer) | No | No | [?] | [SQL Page Viewer] | 2014-08-25 | Idera | | Yes | No | +| [SQL Update Statistics](#sql-update-statistics) | No | No | [ST] | [SQL Update Statistics] | 2015-12-14 | Idera | | Yes | No | +| [SQL Statistics Aggregator](#sql-statistics-aggregator) | No | No | [ST] | [SQL Statistics Aggregator] | 2015-05-18 | Idera | | Yes | No | +| [SQL Backup Status Reporter](#sql-backup-status-reporter) | No | No | [B] | [SQL Backup Status Reporter] | 2015-08-07 | Idera | | Yes | No | +| [SQL Integrity Check](#sql-integrity-check) | No | No | [?] | [SQL Integrity Check] | 2013-08-26 | Idera | | Yes | No | +| [SQL Job Manager](#sql-job-manager) | No | No | [J] | [SQL Job Manager] | 2012-03-19 | Idera | | Yes | No | +| [Azure SQL Database Backup](#azure-sql-database-backup) | No | No | [B] | [Azure SQL Database Backup] | 2012-10-02 | Idera | | Yes | No | +| [SQL Column Search](#sql-column-search) | No | No | [S] | [SQL Column Search] | 2015-11-17 | Idera | | Yes | No | +| [SQL Permissions Extractor](#sql-permissions-extractor) | No | No | [?] | [SQL Permissions Extractor] | 2015-08-07 | Idera | | Yes | No | +| [SQL BI Check](#sql-bi-check) | No | No | [BI] | [SQL BI Check] | 2016-04-13 | Idera | | Yes | No | +| [SQL Inventory Check](#sql-inventory-check) | No | No | [?] | [SQL Inventory Check] | 2016-03-24 | Idera | | Yes | No | +| [SQL Diagnostic Manager](#sql-diagnostic-manager) | No | No | [?] | [SQL Diagnostic Manager] | ? | Idera | | No | $1747 | +| [SQL Safe Backup](#sql-safe-backup) | No | No | [B] | [SQL Safe Backup] | 2016-09-08 | Idera | | No | $907 | +| [SQL Compliance Manager](#sql-compliance-manager) | No | No | [?] | [SQL Compliance Manager] | 2015-09-08 | Idera | | No | $2657 | +| [SQL Inventory Manager](#sql-inventory-manager) | No | No | [?] | [SQL Inventory Manager] | 2016-04-22 | Idera | | No | $3195 | +| [SQL Virtual Database](#sql-virtual-database) | No | No | [?] | [SQL Virtual Database] | 2016-03-24 | Idera | | No | $625 | +| [SQL Secure](#sql-secure) | No | No | [?] | [SQL Secure] | 2016-04-19 | Idera | | No | $907 | +| [SQL Doctor](#sql-doctor) | No | No | [?] | [SQL Doctor] | 2015-12-17 | Idera | | No | $625 | +| [SQL Admin Toolset](#sql-admin-toolset) | No | No | [?] | [SQL Admin Toolset] | 2016-01-13 | Idera | | No | $395 | +| [SQL Defrag Manager](#sql-defrag-manager) | No | No | [?] | [SQL Defrag Manager] | 2016-03-10 | Idera | | No | $1495 | +| [DBArtisan](#dbartisan) | No | No | [?] | [DBArtisan] | ? | Idera | | No | $3122 | +| [SQL BI Manager](#sql-bi-manager) | No | No | [BI] | [SQL BI Manager] | 2015-09-08 | Idera | | No | $697 | +| [SQL Enterprise Job Manager](#sql-enterprise-job-manager) | No | No | [J] | [SQL Enterprise Job Manager] | 2015-09-08 | Idera | | No | $697 | +| [DB Optimizer](#db-optimizer) | No | No | [?] | [DB Optimizer] | ? | Idera | | No | $1420 | +| [SQL Query Store Optimizer](#sql-query-store-optimizer) | No | No | [?] | [SQL Query Store Optimizer] | 2016-07-01 | Idera | | Yes | No | +| [Rapid SQL](#rapid-sql) | Oracle,MySQL,PostgreSQL,Other | No | [MS] | [Rapid SQL] | ? | Idera | | No | $710 | +| [SQL Comparison Toolset](#sql-comparison-toolset) | No | No | [DC],[SC]| [SQL Comparison Toolset] | ? | Idera | | No | $745 | +| [ER/Studio Data Architect](#erstudio-data-architect) | Oracle,MySQL,PostgreSQL,Other | No | [DA] | [ER/Studio Data Architect] | | Idera | | No | $1287 | +| [DB Change Manager](#db-change-manager) | Oracle,MySQL,PostgreSQL,Other | No | [SC] | [DB Change Manager] | ? | Idera | | No | $1420 | +| [Uptime Infrastructure Monitor](#uim) | No | Linux | [?] | [Uptime Infrastructure Monitor] | ? | Idera | | No | ? | +| [Powershell Scripts](#powershell-scripts) | No | No | [?] | [Powershell Scripts] | ? | Idera | | No | ? | +| [SQL Data Profiler](#sql-data-profiler) | No | No | [?] | [SQL Data Profiler] | ? | Idera | | No | ? | +| [SQL Instance Check](#sql-instance-check) | No | No | [M] | [SQL Instance Check] | ? | Idera | | Yes | ? | +| [dbForge Schema Compare](#dbforge-schema-compare) | No | No | [SC] | [dbForge Schema Compare] | 2019-10-10 | Devart | Shareware | No | $150 | +| [dbForge Data Compare](#dbforge-data-compare) | No | No | [DC] | [dbForge Data Compare] | 2019-10-10 | Devart | Shareware | No | $150 | +| [dbForge Data Generator](#dbforge-data-generator) | No | No | [G] | [dbForge Data Generator] | 2019-10-10 | Devart | Shareware | No | $250 | +| [dbForge Query Builder](#dbforge-query-builder) | No | No | [?] | [dbForge Query Builder] | 2019-10-10 | Devart | Shareware | No | $100 | +| [dbForge Event Profiler](#dbforge-event-profiler) | No | No | [M] | [dbForge Event Profiler] | 2019-10-10 | Devart | Freeware | Yes | No | +| [dbForge SQL Decryptor](#dbforge-sql-decryptor) | No | No | [SEC] | [dbForge SQL Decryptor] | 2017-09-19 | Devart | Freeware | Yes | No | +| [dbForge Studio](#dbforge-studio) | No | No | [MS] | [dbForge Studio] | 2019-10-10 | Devart | Shareware | Yes | $250 | +| [dbForge Fusion](#dbforge-fusion) | No | No | [?] | [dbForge Fusion] | 2019-11-08 | Devart | Shareware | No | $150 | +| [dbForge Documenter](#dbforge-documenter) | No | No | [D] | [dbForge Documenter] | 2020-04-23 | Devart | Shareware | No | $150 | +| [dbForge SSIS Data Flow Components](#dbforge-ssis) | Oracle,MySQL,PostgreSQL,Other | No | [?] | [dbForge SSIS Data Flow Components] | 2020-03-31 | Devart | Shareware | No | $500 | +| [dbForge DevOps Automation for SQL Server](#dbforge-devops) | No | No | [?] | [dbForge DevOps Automation for SQL Server] | 2020-01-27 | Devart | Shareware | No | $900 | +| [dbForge Complete](#dbforge-complete) | No | No | [?] | [dbForge Complete] | 2020-09-01 | Devart | Shareware | No | $199 | +| [dbForge SQL Azure Backup](#dbforge-sql-azure-backup) | No | No | [B] | [dbForge SQL Azure Backup] | 2013-04-18 | Devart | Freeware | Yes | No | +| [Devart Transaction Log](#devart-transaction-log) | No | No | [B] | [Devart Transaction Log] | 2020-10-19 | Devart | Freeware | No | $600 | +| [Devart Excel Add-in for SQL Server](#devart-excel-addin) | No | No | [?] | [Devart Excel Add-in for SQL Server] | 2020-04-13 | Devart | Shareware | No | $250 | +| [dbMonitor](#dbmonitor) | Oracle,MySQL,PostgreSQL,Other | No | [M] | [dbMonitor] | 2012-11-01 | Devart | Freeware | Yes | No | +| [SQL Server Compression Estimator](#compression-estimator) | No | No | [?] | [SQL Server Compression Estimator] | 2011-06-02 | Bob Tavlor | | Yes | No | +| [ClearTrace](#cleartrace) | No | No | [M] | [ClearTrace] | 2016-07-07 | Bill Graziano | | Yes | No | +| [ClearTraceXE](#cleartracexe) | No | No | [M] | [ClearTraceXE] | 2019-09-04 | Bill Graziano | | Yes | No | +| [Security Explorer](#security-explorer) | No | No | [SEC] | [Security Explorer] | 2015-06-25 | Quest Software | | No | $850 | +| [LiteSpeed for SQL Server](#litespeed-for-sql-server) | No | No | [?] | [LiteSpeed for SQL Server] | 2015-07-31 | Quest Software | | No | ? | +| [Toad for SQL Server](#toad-for-sql-server) | No | No | [MS] | [Toad for SQL Server] | 2015-05-12 | Quest Software | | No | ? | +| [Quest Spotlight on SQL Server Enterprise](#quest-spotlight) | No | No | [?] | [Quest Spotlight] | 2016-03-10 | Quest Software | | No | $2561 | +| [Quest Foglight](#quest-foglight) | Oracle,MySQL,PostgreSQL,Other | No | [?] | [Quest Foglight] | 2019-08-29 | Quest Software | | No | $8203 | +| [Quest Enterprise Reporter](#quest-enterprise-reporter) | No | No | [?] | [Quest Enterprise Reporter] | ? | Quest Software | | No | $511 | +| [SQL Scripter](#sql-scripter) | No | No | [?] | [SQL Scripter] | 2013-02-24 | Thomas Hinsenkamp | | No | €99 | +| [Simple Dynamic Scheduler](#simple-dynamic-scheduler) | No | No | [?] | [Simple Dynamic Scheduler] | 2016-05-02 | Miljan Radovic | | Yes | No | +| [ApexSQL Audit](#apexsql-audit) | No | No | [?] | [ApexSQL Audit] | 2017-07-11 | ApexSQL | | No | $1699 | +| [ApexSQL Backup](#apexsql-backup) | No | No | [B] | [ApexSQL Backup] | 2017-10-12 | ApexSQL | | No | $499 | +| [ApexSQL Defrag](#apexsql-defrag) | No | No | [IDX] | [ApexSQL Defrag] | 2017-06-29 | ApexSQL | | No | $499 | +| [ApexSQL Log](#apexsql-log) | No | No | [?] | [ApexSQL Log] | 2017-05-24 | ApexSQL | | No | $1999 | +| [ApexSQL Monitor](#apexsql-monitor) | No | No | [M] | [ApexSQL Monitor] | 2017-10-05 | ApexSQL | | No | $499 | +| [ApexSQL Plan](#apexsql-plan) | No | No | [?] | [ApexSQL Plan] | 2019-12-02 | ApexSQL | | Yes | No | +| [ApexSQL Propagate](#apexsql-propagate) | No | No | [?] | [ApexSQL Propagate] | 2020-02-19 | ApexSQL | | Yes | No | +| [ApexSQL Recover](#apexsql-recover) | No | No | [REC] | [ApexSQL Recover] | 2017-10-26 | ApexSQL | | No | $1999 | +| [ApexSQL Build](#apexsql-build) | No | No | [?] | [ApexSQL Build] | 2017-05-15 | ApexSQL | | No | $399 | +| [ApexSQL Clean](#apexsql-clean) | No | No | [?] | [ApexSQL Clean] | 2017-09-28 | ApexSQL | | No | $399 | +| [ApexSQL Data Diff](#apexsql-data-diff) | No | No | [DC] | [ApexSQL Data Diff] | 2017-10-26 | ApexSQL | | No | $399 | +| [ApexSQL Decrypt](#apexsql-decrypt) | No | No | [SEC] | [ApexSQL Decrypt] | 2020-03-12 | ApexSQL | | Yes | No | +| [ApexSQL Diff](#apexsql-diff) | No | No | [SC] | [ApexSQL Diff] | 2017-10-26 | ApexSQL | | No | $399 | +| [ApexSQL Doc](#apexsql-doc) | No | No | [D] | [ApexSQL Doc] | 2017-09-06 | ApexSQL | | No | $299 | +| [ApexSQL Generate](#apexsql-generate) | No | No | [G] | [ApexSQL Generate] | 2017-07-13 | ApexSQL | | No | $499 | +| [ApexSQL Script](#apexsql-script) | No | No | [?] | [ApexSQL Script] | 2016-05-10 | ApexSQL | | No | $249 | +| [ApexSQL Trigger](#apexsql-trigger) | No | No | [?] | [ApexSQL Trigger] | 2017-06-01 | ApexSQL | | No | $1999 | +| [ApexSQL Trigger Veiwer](#apexsql-trigger-viewer) | No | No | [?] | [ApexSQL Trigger Viewer] | 2017-06-01 | ApexSQL | | Yes | No | +| [ApexSQL Snapshot Utility](#apexsql-snapshot-utility) | No | No | [?] | [ApexSQL Snapshot Utility] | 2016-01-12 | ApexSQL | | Yes | No | +| [ApexSQL Model](#apexsql-model) | No | No | [DA] | [ApexSQL Model] | 2019-05-22 | ApexSQL | | Yes | No | +| [ApexSQL Analyze](#apexsql-analyze) | No | No | [?] | [ApexSQL Analyze] | 2017-12-13 | ApexSQL | | No | $299 | +| [ApexSQL BI Monitor](#apexsql-bi-monitor) | No | No | [BI],[M] | [ApexSQL BI Monitor] | 2018-05-18 | ApexSQL | | No | $499 | +| [ApexSQL VM Monitor](#apexsql-vm-monitor) | No | No | [M] | [ApexSQL VM Monitor] | 2018-05-09 | ApexSQL | | No | $999 | +| [ApexSQL Job](#apexsql-job) | No | No | [J] | [ApexSQL Job] | 2018-03-29 | ApexSQL | | No | $499 | +| [ApexSQL Enforce](#apexsqlL-enforce) | No | No | [?] | [ApexSQL Enforce] | 2018-07-19 | ApexSQL | | No | $299 | +| [ApexSQL CI/CD toolkit](#apexsql-ci-cd) | No | No | [?] | [ApexSQL CI/CD toolkit] | 2020-05-21 | ApexSQL | | Yes | No | +| [ApexSQL Compare](#apexsql-compare) | No | No | [?] | [ApexSQL Compare] | 2020-03-17 | ApexSQL | | Yes | No | +| [ApexSQL Complete](#apexsql-complete) | No | No | [?] | [ApexSQL Complete] | 2020-05-28 | ApexSQL | | Yes | No | +| [ApexSQL Refactor](#apexsql-refactor) | No | No | [?] | [ApexSQL Refactor] | 2020-06-09 | ApexSQL | | Yes | No | +| [ApexSQL Search](#apexsql-search) | No | No | [S] | [ApexSQL Search] | 2020-07-30 | ApexSQL | | Yes | No | +| [ApexSQL Source Control](#apexsql-source-control) | No | No | [?] | [ApexSQL Source Control] | 2020-01-20 | ApexSQL | | No | $299 | +| [DBBest T-SQL Analyzer](#dbbest-t-sql-analyzer) | No | No | [?] | [DBBest T-SQL Analyzer] | 2015-03-13 | DBBest | | No | $89 | +| [DBBest Database Compare Suite](#dbbest-database-compare-suite) | No | No | [SC],[DC]| [DBBest Database Compare Suite] | 2015-09-04 | DBBest | | No | $349 | +| [Advanced Query Tool](#advanced-query-tool) | No | No | [?] | [Advanced Query Tool] | 2015-03-18 | Cardett Associates | | No | $180 | +| [SqlDiffFramework](#sqldiffframework) | No | No | [SC] | [SqlDiffFramework] | 2012-04-17 | Michael Sorens | | Yes | No | +| [DataGrip](#datagrip) | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [MS] | [DataGrip] | 2017-02-21 | Jet Brains | | No | $89 | +| [Pssdiag and Sqldiag Manager](#pssdiag-and-sqldiag-manager) | No | No | [?] | [Pssdiag and Sqldiag Manager] | 2017-01-06 | Jack Li | | Yes | No | +| [SQL Nexus Tool](#sql-nexus-tool) | No | No | [?] | [SQL Nexus Tool] | 2016-11-20 | Jack Li | | Yes | No | +| [DBSophic Qure Profiler](#dbsophic-qure-profiler) | No | No | [?] | [DBSophic Qure Profiler] | ? | DBSophic | | No | $300 | +| [DBSophic Qure Optimizer](#dbsophic-qure-optimizer) | No | No | [?] | [DBSophic Qure Optimizer] | ? | DBSophic | | No | ? | +| [RestoreChecker](#restorechecker) | No | No | [?] | [RestoreChecker] | 2015-01-15 | SQLServerUtilities | | No | $99 | +| [SQLScripter](#sqlscripter) | No | No | [?] | [SQLScripter] | 2009-08-24 | SQLServerUtilities | | No | $99 | +| [SQLC](#sqlc) | No | No | [DC],[SC]| [SQLC] | 2017-11-19 | David Ingleton | | Yes | No | +| [Database Performance Analyzer](#dpa-solarwinds) | Oracle, MySQL, Other | Linux | [M] | [Database Performance Analyzer] | ? | SolarWinds | | No | $1995 | +| [Database Performance Analyzer for MSSQL](#dpa-solarwinds-mssql) | No | No | [M] | [Database Performance Analyzer for MSSQL] | ? | SolarWinds | | No | $1995 | +| [SQL Enlight](#sql-enlight) | No | No | [MS] | [SQL Enlight] | 2016-04-25 | UbitSoft | | No | $295 | +| [Aireforge Studio](#aireforge-studio) | No | No | [MG],[SC]| [Aireforge Studio] | 2019-08-08 | AireForge | | Yes | $299 | +| [HexaTier](#hexatier) | No | No | [?] | [HexaTier] | ? | HexaTier | | No | ? | +| [SoftTree SQL Assistant](#softtree-sql-assistant) | Oracle,MySQL,PostgreSQL,Other | No | [MS] | [SoftTree SQL Assistant] | 2017-12-17 | SoftTree | | No | $215 | +| [DB Audit and Security 360](#db-audit-and-security-360) | Oracle,MySQL,Other | No | [SEC] | [DB Audit and Security 360] | 2015-02-07 | SoftTree | | No | $499 | +| [EMS SQL Management Studio](#ems-management-studio) | No | No | [MS] | [EMS SQL Management Studio] | 2016-05-26 | EMS | | No | $257 | +| [EMS SQL Backup](#ems-sql-backup) | No | No | [B] | [EMS SQL Backup] | 2016-04-13 | EMS | | Yes | $82 | +| [EMS SQL Administrator](#ems-sql-administrator) | No | No | [?] | [EMS SQL Administrator] | 2015-04-14 | EMS | | Yes | $135 | +| [EMS SQL Manager](#ems-sql-manager) | No | No | [?] | [EMS SQL Manager] | 2016-05-26 | EMS | | Yes | $135 | +| [EMS Data Export](#ems-data-export) | No | No | [?] | [EMS Data Export] | 2016-04-29 | EMS | | No | $47 | +| [EMS Data Import](#ems-data-import) | No | No | [?] | [EMS Data Import] | 2016-04-14 | EMS | | No | $47 | +| [EMS Data Pump](#ems-data-pump) | No | No | [?] | [EMS Data Pump] | 2016-11-03 | EMS | | No | $47 | +| [EMS Data Generator](#ems-generator) | No | No | [G] | [EMS Data Generator] | 2010-07-10 | EMS | | No | $47 | +| [EMS DB Comparer](#ems-bd-comparer) | No | No | [SC] | [EMS DB Comparer] | 2015-07-24 | EMS | | No | $47 | +| [EMS DB Extract](#ems-bd-extract) | No | No | [?] | [EMS DB Extract] | 2008-10-16 | EMS | | No | $47 | +| [EMS SQL Query](#ems-sql-query) | No | No | [?] | [EMS SQL Query] | 2012-03-29 | EMS | | No | $47 | +| [EMS Data Comparer](#ems-data-comparer) | No | No | [DC] | [EMS Data Comparer] | 2012-11-16 | EMS | | No | $47 | +| [NitroAccelerator](#nitroaccelerator) | No | No | [?] | [NitroAccelerator] | 2016-07-10 | Nitrosphere | | No | $1265 | +| [ERwin Data Modeler](#erwin-data-modeler) | Oracle,MySQL,PostgreSQL,Other | No | [DA] | [ERwin Data Modeler] | 2016-06-03 | ERwin | | No | $810 | +| [Luna Modeler](#luna-modeler) | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [DA] | [Luna Modeler] | 2022-10-05 | Ideamerit | | No | $99 | +| [Toad Data Point](#toad-data-point) | Oracle,MySQL,PostgreSQL,Other | No | [?] | [Toad Data Point] | 2016-06-16 | Quest Software | | No | ? | +| [SQL Power Architect](#sql-power-architect) | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [DA] | [SQL Power Architect] | 2016-02-11 | SQLPower | | Yes | $995 | +| [DbWrench](#dbwrench) | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [DA] | [DbWrench] | 2019-09-17 | Nizana Systems | | No | $99 | +| [Navicat Data Modeler](#navicat-data-modeler) | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [DA] | [Navicat Data Modeler] | 2016-08-01 | PremiumSoft | | No | $199 | +| [DeZign for Databases](#dezign-for-databases) | Oracle,MySQL,PostgreSQL,Other | No | [DA] | [DeZign for Databases] | 2019-04-01 | Datanamic | | No | €29/mo| +| [ERDesigner NG](#erdesigner-ng) | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [DA] | [ERDesigner NG] | 2013-04-10 | Mirko Sertic | | Open Source | No | +| [Vertabelo](#vertabelo) | Oracle,MySQL,PostgreSQL,Other | Online | [DA] | [Vertabelo] | ? | Vertabelo | | No | $948 | +| [dbDiffo](#dbdiffo) | Oracle,MySQL,PostgreSQL,Other | Online | [DA] | [dbDiffo] | ? | Contenet Ltd | | Yes | No | +| [SQL DXP](#sql-dxp) | Oracle,MySQL | No | [DC],[SC]| [SQL DXP] | 2016-06-20 | SQL Delta | | No | $530 | +| [Aqua Data Studio](#aqua-data-studio) | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [MS] | [Aqua Data Studio] | 2016-07-06 | AquaFold | | No | $499 | +| [RazorSQL](#razorsql) | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [MS] | [RazorSQL] | 2019-09-26 | Richardson Software | | No | $100 | +| [SQL Pretty Printer](#sql-pretty-printer) | No | No | [?] | [SQL Pretty Printer] | 2016-02-19 | Gudu Software | | No | $50 | +| [Database .NET](#database-net) | Oracle,MySQL,PostgreSQL,Other | No | [MS],[SC]| [Database .NET] | 2018-08-20 | fish's dotNET | | Non-commercial | $69 | +| [dbMigration .NET](#dbmegration-net) | Oracle,MySQL,PostgreSQL,Other | No | [DC],[SC]| [dbMigration .NET] | 2018-08-20 | fish's dotNET | | Non-commercial | $49 | +| [Is It SQL](#is-it-sql) | No | No | [M] | [Is It SQL] | 2017-04-06 | Bill Graziano | | Non-commercial | No | +| [Database Experimentation Assistant](#dea) | No | No | [T] | [Database Experimentation Assistant] | 2020-03-20 | Microsoft | | Yes | No | +| [Data Platform Studio](#dps) | No | No | [MG] | [Data Platform Studio] | ? | Red Gate Software | | Yes | ? | +| [Flyway](#flyway) | Oracle,MySQL,PostgreSQL,Other | No | [MG] | [Flyway] | 2018-01-30 | boxfuse | [Apache] | Open Source | $950 | +| [Liquibase](#liquibase) | Oracle,MySQL,PostgreSQL,Other | No | [MG] | [Liquibase] | 2018-04-11 | Liquibase | [Apache] | Open Source | No | +| [My Batis](#my-batis) | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [MG] | [My Batis] | 2018-03-20 | My Batis | [Apache] | Open Source | No | +| [SentryOne Plan Explorer](#sentryone-plan-explorer) | No | No | [?] | [SentryOne Plan Explorer] | 2017-05-25 | SentryOne | | Yes | No | +| [SQL Sentry](#sql-sentry) | No | No | [M] | [SQL Sentry] | 2016-12-07 | SentryOne | | No | ? | +| [DBmaestro TeamWork](#dbmaestro-teamwork) | Oracle | No | [?] | [DBmaestro TeamWork] | ? | DBmaestro | | No | ? | +| [xSQL Schema Compare](#xsql-schema-compare) | No | No | [SC] | [xSQL Schema Compare] | 2017-03-01 | xSQL Software | Shareware | Yes | $399 | +| [xSQL Data Compare](#xsql-data-compare) | No | No | [DK] | [xSQL Data Compare] | 2017-06-26 | xSQL Software | Shareware | Yes | $399 | +| [xSQL Script Executor](#xsql-script-executor) | MySQL,DB2,SQL Server CE | No | [?] | [xSQL Script Executor] | 2015-02-25 | xSQL Software | Freeware | Yes | $249 | +| [xSQL Builder](#xsql-builder) | No | No | [?] | [xSQL Builder] | 2017-03-15 | xSQL Software | Shareware | No | $799 | +| [xSQL Documenter](#xsql-documenter) | Oracle,MySQL,SQLite,Other | No | [D] | [xSQL Documenter] | 2017-01-04 | xSQL Software | Shareware | No | $199 | +| [xSQL Profiler](#xsql-profiler) | No | No | [?] | [xSQL Profiler] | 2017-06-28 | xSQL Software | Shareware | Yes | $999 | +| [xSQL Schema Compare SDK](#xsql-schema-compare-sdk) | No | No | [SC] | [xSQL Schema Compare SDK] | 2017-10-25 | xSQL Software | Shareware | No | $1499 | +| [xSQL RSS Reporter](#xsql-rss-reporter) | No | No | [D] | [xSQL RSS Reporter] | 2014-11-25 | xSQL Software | Shareware | No | $169 | +| [xSQL Database Searcher](#xsql-database-sercher) | No | No | [S] | [xSQL Database Searcher] | 2017-05-09 | xSQL Software | Freeware | Yes | No | +| [Cloud-based DB Monitoring Platform](#cbmp) | No | Mobile | [M] | [Cloud-based DB Monitoring Platform] | ? | SQLTreeo | | No | €180 | +| [SchemaCrawler](#schema-crawler) | Oracle,MySQL,PostgreSQL,Other | Yes | [D],[SC] | [SchemaCrawler] | 2017-02-27 | Sualeh Fatehi | | Open Source | No | +| [SA MaaS Microsoft SQL Server](#sa-maas) | No | No | [M] | [SA MaaS Microsoft SQL Server] | ? | SENTINELAGENT | | No | ? | +| [SSIS Framework](#ssis-framework) | No | No | [ETL] | [SSIS Framework] | 2017-01-07 | Andy Leonard | | Yes | ? | +| [SSIS Catalog Browser](#ssis-browser) | No | No | [ETL] | [SSIS Catalog Browser] | 2019-04-23 | Andy Leonard | | Yes | No | +| [BimlExpress Metadata Framework](#bimlexpress) | No | No | [?] | [BimlExpress Metadata Framework] | 2017-01-06 | Andy Leonard | | Yes | No | +| [MS Kerberos Configuration Manager](#mkcm) | No | No | [?] | [MS Kerberos Configuration Manager] | 2017-01-31 | Microsoft | | Yes | No | +| [Spotlight](#spotlight) | No | No | [M] | [Spotlight] | ? | Quest Software | | Yes | ? | +| [DBConvert Studio](#dbconvert-studio) | Oracle,MySQL,PostgreSQL,Other | No | [MG] | [DBConvert Studio] | 2020-05-11 | Slotix | | No | $499 | +| [DbDefence](#dbdefence) | No | No | [?] | [DbDefence] | 2017-03-01 | ActiveCrypt Software | | Yes | $698 | +| [SQL Server Migration Assistant for MySQL](#ssma-mysql) | MySQL | No | [MG] | [SQL Server Migration Assistant for MySQL] | 2017-02-17 | Microsoft | | Yes | No | +| [sqlcmd for Mac and Linux](#sqlcmd) | No | Linux,Mac | [?] | [sqlcmd for Mac and Linux] | 2017-01-26 | Soheil Rashidi | | Open Source | No | +| [SQL Migrator](#sql-migrator) | No | No | [MG] | [SQL Migrator] | ? | Datamate Technology | | ? | ? | +| [MS FoxPro to MS SQL Migration and Sync](#foxpro-sqlserver) | No | No | [MG] | [MS FoxPro to MS SQL Migration and Sync] | 2019-04-25 | Slotix | | No | $149 | +| [MySQL to MS SQL Migration and Sync](#mysql-sqlserver) | No | No | [MG] | [MySQL to MS SQL Migration and Sync] | 2018-10-03 | Slotix | | No | $149 | +| [Oracle to MS SQL Migration and Sync](#oracle-sqlserver) | No | No | [MG] | [Oracle to MS SQL Migration and Sync] | 2020-02-12 | Slotix | | No | $149 | +| [PostgreSQL to MS SQL Migration and Sync](#postgresql-sqlserver) | No | No | [MG] | [PostgreSQL to MS SQL Migration and Sync] | 2019-10-24 | Slotix | | No | $149 | +| [MS Excel to MS SQL Migration](#msexcel-sqlserver) | No | No | [MG] | [MS Excel to MS SQL Migration] | 2018-02-23 | Slotix | | No | $149 | +| [SQLite to MS SQL Migration and Sync](#sqllite-sqlserver) | No | No | [MG] | [SQLite to MS SQL Migration and Sync] | 2016-08-18 | Slotix | | No | $149 | +| [IBM DB2 to MS SQL Migration and Sync](#db2-sqlserver) | No | No | [MG] | [IBM DB2 to MS SQL Migration and Sync] | 2019-07-09 | Slotix | | No | $149 | +| [MS Access to MS SQL Migration and Sync](#access-sqlserver) | No | No | [MG] | [MS Access to MS SQL Migration and Sync] | 2020-01-15 | Slotix | | No | $149 | +| [Firebird to MS SQL Migration and Sync](#firebird-sqlserver) | No | No | [MG] | [Firebird to MS SQL Migration and Sync] | 2016-08-18 | Slotix | | No | $149 | +| [SQLines SQL Converter](#sqllines-converter) | No | No | [MG] | [SQLines SQL Converter] | ? | Dmtolpeko | | Open Source | No | +| [SQLite & SQL Server Compact Toolbox](#sqlite-sqlserver-toolbox) | No | No | [?] | [SQLite & SQL Server Compact Toolbox] | ? | ErikEJ | | Open Source | No | +| [SqlPad](#sqlpad) | Postgres,MySQL,Crate,Vertica | No | [MS] | [SqlPad] | ? | Rickbergfalk | | Open Source | No | +| [Html-query-plan](#html-query-plan) | No | No | [?] | [Html-query-plan] | ? | JustinPealing | | Open Source | No | +| [SqlQueryStress](#sql-query-stress) | No | No | [?] | [SqlQueryStress] | ? | Adam Machanic | | Open Source | No | +| [SQL Server Migration Assistant for DB2](#ssma-db2) | DB2 | No | [MG] | [SQL Server Migration Assistant for DB2] | 2017-02-17 | Microsoft | | Yes | No | +| [SQL Server Migration Assistant for Oracle](#ssma-oracle) | Oracle | No | [MG] | [SQL Server Migration Assistant for Oracle] | 2017-02-17 | Microsoft | | Yes | No | +| [SQL Server Migration Assistant for Access](#ssma-access) | Access | No | [MG] | [SQL Server Migration Assistant for Access] | 2017-02-17 | Microsoft | | Yes | No | +| [SQL Server Migration Assistant for SAP ASE](#ssma-sap) | SAP ASE | No | [MG] | [SQL Server Migration Assistant for SAP ASE] | 2020-06-29 | Microsoft | | Yes | No | +| [mssql for Visual Studio Code](#mssql-for-vs-code) | No | Linux,Mac | [MS] | [mssql for Visual Studio Code] | 2017-05-02 | Microsoft | | Open Source | No | +| [mssql-scripter](#mssql-scripter) | No | Linux,Mac | [?] | [mssql-scripter] | ? | Microsoft | | Open Source | No | +| [DBFS](#dbfs) | No | Linux | [M] | [DBFS] | ? | Microsoft | | Open Source | No | +| [comparator](#pumpet-comparator) | Oracle,MySQL,PostgreSQL,Other | No | [DC] | [comparator] | 2017-06-06 | Pumpet | [LGPL-3.0] | Open Source | No | +| [Navicat for SQL Server](#navicat-for-sql-server) | No | Mac | [MS] | [Navicat for SQL Server] | 2017-06-14 | PremiumSoft | | No | $699 | +| [Navicat Premium](#navicat-premium) | Oracle,MySQL,PostgreSQL,Other | Mac | [MS] | [Navicat Premium] | 2017-06-14 | PremiumSoft | | No | $1299 | +| [DbVisualizer](#dbvisualizer) | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [MS],[DA]| [DbVisualizer] | 2017-08-22 | DbVis Software AB. | | Yes | $197 | +| [DbSchema](#dbschema) | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [DA] | [DbSchema] | 2017-06-19 | Wise Coders Solutions | | Yes | $127 | +| [DBGhost](#dbghost) | No | No | [?] | [DBGhost] | 2017-01-31 | Innovartis Ltd | | No | £430 | +| [SQLAutomate](#sqlautomate) | Oracle,MySQL,Other | No | [?] | [SQLAutomate] | 2017-06-19 | OnLine ToolWorks     | | No | $99 | +| [BimlExpress](#bimlexpress) | No | No | [?] | [BimlExpress] | ? | Varigence   | | No | No | +| [BI Developer Extensions](#bi-developer-extensions) | No | No | [?] | [BI Developer Extensions] | 2019-04-29 | Microsoft   | | Open Source | No | +| [Azure Data Warehouse Migration Utility](#azure-migration) | No | No | [MG] | [Azure Data Warehouse Migration Utility] | ? | Microsoft | | ? | ? | +| [Benchmark Factory](#benchmark-factory) | Oracle,MySQL,Other | No | [T] | [Benchmark Factory] | ? | Quest Software | | No | $4413 | +| [manduka](#manduka) | Oracle | Linux,Mac | [?] | [manduka] | 2017-03-08 | Virtusa Corporation | | Yes | No | +| [PowerBI Desktop](#powerbi-desktop) | Oracle,MySQL,PostgreSQL,Other | No | [BI] | [PowerBI Desktop] | 2017-07-11 | Microsoft | | Yes | ? | +| [Stellar Phoenix SQL Database Repair](#stellar-phoenix) | No | No | [REC] | [Stellar Phoenix SQL Database Repair] | 2017-07-05 | Stellar Technology | | No | $349 | +| [DataNumen SQL Recovery](#datanumen-sql-recovery) | No | No | [REC] | [DataNumen SQL Recovery] | 2017-03-20 | DataNumen | | No | $500 | +| [Recovery Toolbox for SQL Server](#recovery-toolbox) | No | No | [REC] | [Recovery Toolbox for SQL Server] | ? | Recovery Toolbox | Shareware | No | $99 | +| [SQL MDF Viewer](#sql-mdf-viewer) | No | No | [?] | [SQL MDF Viewer] | ? | SysTools | Shareware | No | $129 | +| [SQL MDF Recovery Tool](#sql-mdf-recovery-tool) | No | No | [REC] | [SQL MDF Recovery Tool] | ? | SysTools | Shareware | No | $129 | +| [SQL Passord Recovery](#sql-password-recovery) | No | No | [REC] | [SQL Passord Recovery] | ? | SysTools | Shareware | No | $69 | +| [SQL Decryptor](#sql-decryptor) | No | No | [SEC] | [SQL Decryptor] | ? | SysTools | Shareware | No | $69 | +| [SQL Backup Database Recovery](#sql-backup-database-recovery) | No | No | [REC] | [SQL Backup Database Recovery] | ? | SysTools | Shareware | No | $149 | +| [SQL Log File Viewer](#sql-log-file-viewer) | No | No | [?] | [SQL Log File Viewer] | ? | SysTools | Shareware | No | $999 | +| [DAX Studio](#dax-studio) | No | No | [?] | [DAX Studio] | ? | Sqlbi | Freeware | Yes | No | +| [SQL Cop](#sql-cop) | No | No | [?] | [SQL Cop] | ? | LessThanDot | Freeware | Yes | No | +| [Dataedo](#dataedo) | Oracle,MySQL | No | [D] | [Dataedo] | 2017-09-15 | Logic Systems | Shareware | Yes | $239 | +| [Azure Database Migration Service](#azure-db-migration) | Oracle,MySQL, Other | Online | [MG] | [Azure Database Migration Service] | 2017-12-01 | Microsoft | | Yes | No | +| [FlowHeater](#flowheater) | Oracle,MySQL,PostgreSQL,Other | No | [ETL] | [FlowHeater] | 2017-10-02 | FlowHeater GmbH | Shareware | No | $79 | +| [EDIS](#edis) | No | No | [ETL] | [EDIS] | ? | SQL ETL | Shareware | Yes | $599 | +| [SchemaSpy](#schemaspy) | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [D] | [SchemaSpy] | 2018-08-05 | Rafal Kasa | [MIT] | Open Source | No | +| [Adminer](#adminer) | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [MS] | [Adminer] | 2019-08-27 | Jakub Vrána | [Apache] | Open Source | No | +| [Full Convert](#full-convert) | Oracle,MySQL,PostgreSQL,Other | No | [MG] | [Full Convert] | 2018-08-20 | Spectral Core | Shareware | Yes | $699 | +| [Replicator](#replicator) | Oracle,MySQL,PostgreSQL,Other | No | [DC] | [Replicator] | 2018-08-20 | Spectral Core | Shareware | Yes | $699 | +| [JackDB](#jackdb) | Oracle,MySQL,PostgreSQL,Other | Online | [MS] | [JackDB] | ? | JackDB | | No | $48 | +| [SQL Workbench](#sql-workbench) | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [MS] | [SQL Workbench] | 2018-08-20 | Thomas Kellerer | | Yes | No | +| [Valentina Studio](#valentina-studio) | MySQL,PostgreSQL,Other | Linux,Mac | [MS] | [Valentina Studio] | 2018-09-24 | Paradigma Software | | Yes | $200 | +| [SQL Plus Dot Net](#sql-plus-dot-net) | No | No | [?] | [SQL Plus Dot Net] | ? | SQL+.NET | | No | ? | +| [SQLIndexManager](#sqlindexmanager) | No | No | [IDX] | [SQLIndexManager] | 2019-05-19 | Sergey Syrovatchenko | | Open Source | No | +| [JAMS Enterprise Job Scheduling](#jams-job) | No | No | [J] | [JAMS Enterprise Job Scheduling] | 2019-08-20 | HelpSystems | | No | ? | +| [Stitch Data Loader](#stitch) | Oracle,MySQL,PostgreSQL,Other | Online | [ETL] | [Stitch Data Loader] | 2019-09-20 | Talend | | No | ? | +| [Talend Data Integration](#talend-integration) | Oracle,MySQL,PostgreSQL,Other | Mac | [ETL] | [Talend Data Integration] | 2019-06-20 | Talend | [Apache] | Yes | ? | +| [Talend Data Preparation](#talend-preparation) | Oracle,MySQL,PostgreSQL,Other | Mac | [ETL] | [Talend Data Preparation] | 2018-06-05 | Talend | [Apache] | Yes | ? | +| [Pentaho Data Integration](#pentaho) | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [ETL] | [Pentaho Data Integration] | 2019-06-20 | Hitachi Vantara | Shareware | No | ? | +| [Studio3T](#studio3t) | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [MG] | [Studio3T] | 2019-09-19 | Studio 3T | Shareware | No | $150 | +| [SQLGrease](#sqlgrease) | No | Online | [M] | [SQLGrease] | 2019-09-20 | SQLGrease | Shareware | No | $948 | +| [QuickDBD](#quickdbd) | Oracle,MySQL,PostgreSQL,Other | Online | [DA] | [QuickDBD] | ? | Dovetail Technologies | | Yes | $95 | +| [DB Designer](#dbdesigner) | Oracle,MySQL,PostgreSQL,Other | Online | [DA] | [DB Designer] | ? | DB Designer | | Yes | $180 | +| [ESF Database Migration Toolkit](#esf) | Oracle,MySQL,PostgreSQL,Other | No | [MG] | [ESF Database Migration Toolkit] | 2019-10-23 | DBSofts Inc | Shareware | No | $322 | +| [MS SQL Migration Toolkit](#msskit) | Oracle,MySQL,PostgreSQL,Other | No | [MG] | [MS SQL Migration Toolkit] | 2019-04-22 | Intelligent Converters | Shareware | No | $99 | +| [DatabasesSpy](#databasespy) | Oracle,MySQL,PostgreSQL,Other | No | [MS] | [DatabaseSpy] | 2019-10-09 | Altova | Shareware | No | €109 | +| [DiffDog](#diffdog) | Oracle,MySQL,PostgreSQL,Other | No | [DC],[SC]| [DiffDog] | 2019-10-09 | Altova | Shareware | No | €109 | +| [ERBuilder data modeler](#erbuilder) | Oracle,MySQL,PostgreSQL,Other | No | [DA] | [ERBuilder data modeler] | 2019-11-14 | Softbuilder | | Yes | $99 | +| [SQLDatabaseStudio](#sqldatabasestudio) | No | No | [MS] | [SQLDatabaseStudio] | 2017-05-10 | Jan Pivarcek | | Yes | $215 | +| [Enterprise Architect](#ea) | Oracle,MySQL,PostgreSQL,Other | Online | [DA] | [Enterprise Architect] | 2019-10-31 | Sparx Systems Pty Ltd | Shareware | No | $225 | +| [MogwaiERDesignerNG](#mogwai) | Oracle,MySQL,PostgreSQL | No | [DA] | [MogwaiERDesignerNG] | 2019-08-22 | Mirko Sertic | [LGPL-3.0] | Open Source | No | +| [Xcase](#xcase) | Oracle,MySQL,PostgreSQL,Other | No | [DA] | [Xcase] | 2018-06-19 | Resolution Software | Shareware | No | $799 | +| [Oracle SQL Developer Data Modeler](#oracle-modeler) | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [DA] | [Oracle SQL Developer Data Modeler] | 2019-08-01 | Oracle | Shareware | Yes | No | +| [Exportizer](#exportizer) | Oracle,MySQL,PostgreSQL,Other | No | [MG] | [Exportizer] | 2019-11-17 | Vitaliy Levchenko | Shareware | No | $29 | +| [Reportizer](#reportizer) | Oracle,MySQL,PostgreSQL,Other | No | [?] | [Reportizer] | 2019-09-10 | Vitaliy Levchenko | Shareware | No | $39 | +| [Database Tour](#database-tour) | Oracle,MySQL,PostgreSQL,Other | No | [MS] | [Database Tour] | 2019-11-20 | Vitaliy Levchenko | Shareware | No | $49 | +| [Ispirer MnMATK](#mnmatk) | Oracle,MySQL,PostgreSQL,Other | No | [MG] | [Ispirer MnMATK] | ? | Ispirer Systems | Shareware | No | ? | +| [SQL Database Recovery](#sql-database-recovery) | No | No | [REC] | [SQL Database Recovery] | 2019-09-10 | KernelApps Private | Shareware | No | $399 | +| [SysTools SQL Log Analyzer](#log-analzyer) | No | No | [M][REC] | [SysTools SQL Log Analyzer] | 2019-01-01 | SysTools | Shareware | No | $999 | +| [SysTools SQL Server Recovery Manager](#systools-rec-manager) | No | No | [REC] | [SysTools SQL Log Analyzer] | 2017-01-01 | SysTools | Shareware | No | $1499 | +| [SysTools SQL Recovery](#systools-recovery) | No | No | [REC] | [SysTools SQL Recovery] | 2019-01-01 | SysTools | Shareware | No | $249 | +| [SQL Backup Recovery](#systools-backup-recovery) | No | No | [REC] | [SQL Backup Recovery] | 2018-01-01 | SysTools | Shareware | No | $149 | +| [SysTools SQL Password Recovery](#systools-password-recovery) | No | No | [REC] | [SysTools SQL Password Recovery] | 2018-01-01 | SysTools | Shareware | No | $69 | +| [SysTools SQL Decryptor](#systools-sql-decryptor) | No | No | [SEC] | [SysTools SQL Decryptor] | 2019-01-01 | SysTools | Shareware | No | $69 | +| [SysTools SQL Server Database Migrator](#systools-migrator) | No | No | [MG] | [SysTools SQL Server Database Migrator] | 2018-01-01 | SysTools | Shareware | No | $249 | +| [SQL Server to Azure Database Migrator](#systools-azure) | No | No | [MG] | [SQL Server to Azure Database Migrator] | 2018-01-01 | SysTools | Shareware | No | $169 | +| [Commvault Complete Backup & Recovery](#commvault) | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [B] | [Commvault Complete Backup & Recovery] | 2019-12-31 | Commvault | Shareware | No | ? | +| [Veeam Backup & Replication](#veeam) | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [B] | [Veeam Backup & Replication] | 2019-12-31 | Veeam | Shareware | No | $600 | +| [Veeam Explorer for Microsoft SQL Server](#veeam-explorer) | ? | ? | [B] | [Veeam Explorer for Microsoft SQL Server] | ? | Veeam | Shareware | No | ? | +| [Database Modeling Excel](#database-modeling-excel) | Oracle,MySQL,PostgreSQL,Other | No | [DA] | [Database Modeling Excel] | ? | Yang Ning (Steven) | [BSD-3] | Open Source | No | +| [DBAchecks](#dbachecks) | No | No | [?] | [DBAchecks] | ? | sqlcollaborative | [MIT] | Open Source | No | +| [DBComparer](#dbcomparer) | No | No | [DC],[SC]| [DBComparer] | ? | DBComparer | | Yes | No | +| [DbViewSharp](#dbviewsharp) | No | No | [MS] | [DbViewSharp] | 2014-08-08 | David Moore | [MIT] | Yes | No | +| [DTSQL](#dtsql) | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [?] | [DTSQL] | 2017-08-18 | DigerTech Inc | Shareware | Yes | $69 | +| [MSKerberos Configuration Manager](#mskerberos-config-manager) | No | No | [DC],[SC]| [MSKerberos Configuration Manager] | 2020-02-25 | Microsoft | | Yes | No | +| [Partition Management](#partition-management) | No | No | [?] | [Partition Management] | ? | ? | | Open Source | No | +| [PSDatabaseClone](#psdatabaseclone) | No | No | [?] | [PSDatabaseClone] | 2018-07-27 | Sander Stad | | Open Source | No | +| [Pssdiag&Sqldiag Manager](#pssdiag-sqldiag-manager) | No | No | [?] | [Pssdiag&Sqldiag Manager] | 2020-05-04 | Jack Li | | Open Source | No | +| [SQuirreL SQL Client](#squirrelsql-client) | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [MS] | [SQuirreL SQL Client] | 2020-04-30 | Colin Bell | | Yes | No | +| [Data Synchronisation Studio](#data-synchronisation-studio) | No | No | [?] | [Data Synchronisation Studio] | 2020-05-26 | Simego Ltd | | No | $999 | +| [SQL Converter](#sql-converter) | No | No | [?] | [SQL Converter] | 2015-12-15 | Alaa Ben Fatma | | Yes | No | +| [SQLDBSearch](#sqldbsearch) | No | No | [S] | [SQLDBSearch] | ? | Mohamed Bouarroudj | | Yes | No | +| [SQLDBSize](#sqldbsize) | No | No | [?] | [SQLDBSize] | ? | Mohamed Bouarroudj | | Yes | No | +| [SQLines Data](#sqlines-data) | Oracle,MySQL,PostgreSQL,Other | Linux |[MG],[ETL]| [SQLines Data] | 2019-05-29 | SQLines | | Open Source | No | +| [SqlDbAid](#sqldbaid) | No | No | [?] | [SqlDbAid] | 2018-02-10 | Miken | | Yes | No | +| [sqlectron](#sqlectron) | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [?] | [sqlectron] | 2018-09-06 | sqlectron | | Open Source | No | +| [SQL ExecStats](#sql-execstats) | No | No | [?] | [SQL ExecStats] | ? | Elemental Inc | | Yes | No | +| [SQL-FineBuild](#sql-finebuild) | No | No | [?] | [SQL-FineBuild] | 2017-10-28 | Edward Vassie | | Open Source | No | +| [SQL Health Monitor](#sql-health-monitor) | No | No | [M] | [SQL Health Monitor] | ? | ManageEngine | | Yes | No | +| [SQLPRep](#sqlprep) | No | No | [?] | [SQLPRep] | ? | Consequential Solutions | | Yes | No | +| [SQL Server Monitoring](#sql-server-monitoring) | No | No | [M] | [SQL Server Monitoring] | ? | Spiceworks | | Yes | No | +| [SQL Server Storage manager](#sql-server-storage-manager) | No | No | [M] | [SQL Server Storage manager] | ? | Lepide Software | | Yes | No | +| [SysKit Pulse](#syskit-pulse) | No | No | [M] | [SysKit Pulse] | ? | SysKit Ltd | | Yes | No | +| [WhatsUp SQL Server Monitor](#whatsup-sql-server-monitor) | No | No | [M] | [WhatsUp SQL Server Monitor] | ? | Ipswitch | | Yes | No | +| [POPSQL](#popsql) | Oracle,MySQL,PostgreSQL,Other | Online | [MS] | [POPSQL] | 2020-08-01 | PopSQL | | Yes | $10 | +| [Azure Blob Studio 2011](#azure-blob-studio-2011) | No | No | [?] | [Azure Blob Studio 2011] | 2010-12-25 | Alessandro Del Sole | | Yes | No | +| [Azure Explorer](#azure-explorer) | No | No | [?] | [Azure Explorer] | ? | Monza Cloud | | Yes | No | +| [Azure SQL Agent](#azure-sql-agent) | No | No | [?] | [Azure SQL Agent] | ? | ? | [MIT] | Open Source | No | +| [Azure SQL Database DTU Calculator](#azure-sql-dtu-calculator) | No | No | [?] | [Azure SQL Database DTU Calculator] | ? | Justin Henriksen | [MIT] | Open Source | No | +| [Azure SQL Database Stress Test Tool](#azure-sql-stress-test) | No | No | [T] | [Azure SQL Database Stress Test Tool] | ? | Kiyoaki Tsurutani | [MIT] | Open Source | No | +| [Azure SQL Dev Cloner](#azure-sql-dev-cloner) | No | No | [?] | [Azure SQL Dev Cloner] | ? | ? | [MIT] | Open Source | No | +| [Azure User Management Console](#azure-user-management-console) | No | No | [?] | [Azure User Management Console] | ? | ? | [Apache] | Open Source | No | +| [CloudMonix SQL Azure Database Management](#cloudmonix-azure-man)| No | No | [?] | [CloudMonix SQL Azure Database Management] | ? | CloudMonix | | No | $15 | +| [DB Ghost Change Manager Professional](#db-ghost-change-manager) | No | No | [?] | [DB Ghost Change Manager Professional] | ? | Innovartis Ltd | | No | £430 | +| [MSSQL-Maestro](#mssql-maestro) | No | No | [MS] | [MSSQL-Maestro] | 2017-06-29 | SQL Maestro Group | | No | $229 | +| [MSSQLMerge](#mssqlmerge) | No | No | [DC],[SC]| [MSSQLMerge] | 2021-02-26 | Konstantin Semenenkov | | Yes | $75 | +| [SQL Backup and FTP](#sql-backup-and-ftp) | MySQL,PostgreSQL | Linux | [B] | [SQL Backup and FTP] | ? | Pranas.NET | | Yes | $129 | +| [SQL Bak](#sql-bak) | MySQL,PostgreSQL | Linux | [B] | [SQL Bak] | ? | Pranas.NET | | Yes | $9 | +| [SQL Bulk Tools](#sql-bulk-tools) | No | No | [?] | [SQL Bulk Tools] | ? | Greg Taylor | [MIT] | Open Source | No | +| [SQL Data Examiner](#sql-data-examiner) | Oracle,MySQL,PostgreSQL | No | [?] | [SQL Data Examiner] | ? | Intelligent Database Solutions | | No | $400 | +| [SQL Examiner](#sql-examiner) | Oracle,MySQL,PostgreSQL | No | [?] | [SQL Examiner] | ? | Intelligent Database Solutions | | No | $400 | +| [SQL Database Backup](#sql-database-backup) | No | No | [B] | [SQL Database Backup] | ? | Richard Astbury | [MIT] | Open Source | No | +| [SQL Database Copy](#sql-database-copy) | No | No | [MG] | [SQL Database Copy] | 2017-07-25 | ryanovic | [MIT] | Open Source | No | +| [SQL Delta Duo for SQL Server](#sql-delta-duo-for-sql-server) | No | No | [?] | [SQL Delta Duo for SQL Server] | ? | The Australian Software Company | | No | $370 | +| [SQL Trace Replay](#sql-trace-replay) | No | No | [?] | [SQL Trace Replay] | ? | Mikhail Shilkov | [MIT] | Open Source | No | +| [SQL Workload Profiler](#sql-workload-profiler) | No | No | [?] | [SQL Workload Profiler] | 2014-10-01 | Chris Bailiss | | Yes | No | +| [SQLDBdiff](#sqldbdiff) | No | Linux | [?] | [SQLDBdiff] | ? | SQLDBtools | | Yes | $60 | +| [SQL Backup Master](#sql-backup-master) | No | No | [B] | [SQL Backup Master] | ? | Key Metric Software | | Yes | $49 | +| [Handy Backup Server](#handy-backup-server) | Oracle,MySQL,PostgreSQL,Other | Linux | [B] | [Handy Backup Server] | 2019-03-11 | Novosoft | | No | $39 | +| [EaseUS Todo Backup Server](#easeus-todo-backup-server) | No | No | [B] | [EaseUS Todo Backup Server] | ? | EaseUS | | No | $39 | +| [SqlBackupFree](#sqlbackupfree) | No | No | [B] | [SqlBackupFree] | ? | pranas.net | | Yes | No | +| [ERDPlus](#erdplus) | No | No | [?] | [ERDPlus] | 2020-05-24 | ERDPlus | | ? | ? | +| [SentryOne Test](#sentryone-test) | No | No | [T] | [SentryOne Test] | ? | SQL Sentry | | No | $828 | +| [Code Quality and Security for T-SQL](#sonarsource) | No | No | [?] | [Code Quality and Security for T-SQL] | ? | SonarSource | | No | €120 | +| [DBBALANCE](#dbbalance) | Oracle,MySQL,PostgreSQL,Other | No | [?] | [DBBALANCE] | ? | DBBalance | | No | ? | +| [Convert SQL to Excel](#convert-sql-to-excel) | No | No | [?] | [Convert SQL to Excel] | 2015-10-09 | MSSQL.TOOLS | | Yes | No | +| [Search string in Schema](#search-string-in-schema) | No | No | [S] | [Search string in Schema] | 2015-10-09 | MSSQL.TOOLS | | Yes | No | +| [Search string in SQL](#search-string-in-sql) | No | No | [S] | [Search string in SQL] | 2015-10-09 | MSSQL.TOOLS | | Yes | No | +| [SQL Table Scripter](#sql-table-scripter) | No | No | [?] | [SQL Table Scripter] | 2015-10-09 | MSSQL.TOOLS | | Yes | No | +| [SQLCLR Util](#sqlclr-util) | No | No | [?] | [SQLCLR Util] | 2015-10-09 | MSSQL.TOOLS | | Yes | No | +| [Image To SQL](#image-to-sql) | No | No | [?] | [Image To SQL] | 2015-10-09 | MSSQL.TOOLS | | Yes | No | +| [dbdiagram](#dbdiagram) | No | No | [?] | [dbdiagram] | ? | holistics.io | | Yes | $9/mo | +| [Beekeeper Studio](#beekeeper) | MySQL,PostgreSQL,Other | Linux,Mac | [MS] | [Beekeeper Studio] | 2020-11-21 | Beekeeper Studio | [MIT] | Yes | No | +| [Babelfish for Aurora PostgreSQL](#babelfish) | No | Online | [?] | [Babelfish for Aurora PostgreSQL] | 2020-12-01 | Amazon | [Apache] | Open Source | No | +| [DBA Dash](#dbadash) | No | No | [M] | [DBA Dash] | - | Trimble | [MIT] | Open Source | No | +| [SQLWATCH](#sqlwatch) | No | No | [M] | [SQLWATCH] | - | Marcin Gminski | [MIT] | Open Source | No | ## SSMS Download page: [SSMS]
-Release date: 2017-10-09
-Support Version: 2008/2012/2014/2016/2017/Azure
+Release date: 2020-10-27
+Support Version: 2005-2019/Azure
Author: Microsoft
Free version: Yes
Price: No @@ -299,6 +438,33 @@ SSMS combines a broad group of graphical tools with a number of rich script edit This release features improved compatibility with previous versions of SQL Server, a stand-alone web installer, and toast notifications within SSMS when new releases become available. + +## Azure Data Studio +Download page: [Azure Data Studio]
+Release date: 2020-11-12
+Support Version: 2008-2019/Azure
+Author: Microsoft
+Free version: Yes
+Price: No + +Azure Data Studio (previously SQL Operations Studio) is a data management tool that enables working with SQL Server, Azure SQL DB and SQL DW from Windows, macOS and Linux. + +[Azure Data Studio List of Extensions](https://github.com/Microsoft/azuredatastudio/wiki/List-of-Extensions) + + - Cross-Platform DB management for Windows, macOS and Linux with simple XCopy deployment + - SQL Server Connection Management with Connection Dialog, Server Groups, and Registered Servers + - Object Explorer supporting schema browsing and contextual command execution + - T-SQL Query Editor with advanced coding features such as autosuggestions, error diagnostics, tooltips, formatting and peek definition + - Query Results Viewer with advanced data grid supporting large result sets, export to JSON\CSV\Excel, query plan and charting + - Management Dashboard supporting customizable widgets with drill-through actionable insights + - Visual Data Editor that enables direct row insertion, update and deletion into tables + - Backup and Restore dialogs that enables advanced customization and remote filesystem browsing, configured tasks can be executed or scripted + - Task History window to view current task execution status, completion results with error messages and task T-SQL scripting + - Scripting support to generate CREATE, SELECT and DROP statements for database objects + - Workspaces with full Git integration and Find In Files support to managing T-SQL script libraries + - Modern light-weight shell with theming, user settings, full screen support, integrated terminal and numerous other features + + ## bcp Utility Download page: [bcp Utility]
@@ -318,12 +484,12 @@ To import data into a table, you must either use a format file created for that ## sqlcmd Utility Download page: [sqlcmd Utility]
Release date: 2016-08-23
-Support Version: 2008/2012/2014/2016/2017/Azure
+Support Version: 2008-2017/Azure
Author: Microsoft
Free version: Yes
Price: No -The SQLCMD utility allows users to connect to, send Transact-SQL batches from, and output rowset information from SQL Server instances. +The SQLCMD utility allows users to connect to, send Transact-SQL batches from, and output rowset information from SQL Server instances. The bcp utility bulk copies data between an instance of Microsoft SQL Server and a data file in a user-specified format. The bcp utility can be used to import large numbers of new rows into SQL Server tables or to export data out of tables into data files. @@ -331,44 +497,19 @@ The bcp utility can be used to import large numbers of new rows into SQL Server ## mssql-cli Download page: [mssql-cli]
-Release date: 2017-12-13
-Support Version: ?
+Release date: 2020-01-05
+Support Version: 2008-2019/Azure
Author: Microsoft
Free version: Open Source
Price: No Interactive command line query tool for SQL Server. - - Auto-completion - - Syntax highlighting - - Query history - - Configuration file support - - Multi-line queries - - - -## SQL OPS Studio -Download page: [SQL OPS Studio]
-Release date: 2017-11-15
-Support Version: 2008/2012/2014/2016/2017/Azure
-Author: Microsoft
-Free version: Yes
-Price: No - -SQL Operations Studio is a data management tool that enables working with SQL Server, Azure SQL DB and SQL DW from Windows, macOS and Linux. - - - Cross-Platform DB management for Windows, macOS and Linux with simple XCopy deployment - - SQL Server Connection Management with Connection Dialog, Server Groups, and Registered Servers - - Object Explorer supporting schema browsing and contextual command execution - - T-SQL Query Editor with advanced coding features such as autosuggestions, error diagnostics, tooltips, formatting and peek definition - - Query Results Viewer with advanced data grid supporting large result sets, export to JSON\CSV\Excel, query plan and charting - - Management Dashboard supporting customizable widgets with drill-through actionable insights - - Visual Data Editor that enables direct row insertion, update and deletion into tables - - Backup and Restore dialogs that enables advanced customization and remote filesystem browsing, configured tasks can be executed or scripted - - Task History window to view current task execution status, completion results with error messages and task T-SQL scripting - - Scripting support to generate CREATE, SELECT and DROP statements for database objects - - Workspaces with full Git integration and Find In Files support to managing T-SQL script libraries - - Modern light-weight shell with theming, user settings, full screen support, integrated terminal and numerous other features +- Auto-completion +- Syntax highlighting +- Query history +- Configuration file support +- Multi-line queries ## RML Utilities for SQL Server @@ -417,7 +558,7 @@ MBSA 2.3 release adds support for Windows 8.1, Windows 8, Windows Server 2012 R2 Download page: [tablediff Utility]
Release date: -
-Support Version: 2005/2008/2008R2/2012/2014/2016
+Support Version: 2005-2016
Author: Microsoft
Free version: Yes
Price: No
@@ -450,7 +591,7 @@ XML files and CSV files, as well as key data sources on the Windows operating sy Download page: [Log Parser Lizard GUI]
Release date: 2017-06-01
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Author: Lizard Labs
Free version: Yes
Price: $59
@@ -527,8 +668,8 @@ Supports MSSQL, Oracle, SAP, Firebird, Mysql, PostgreSQL, DB2, Informix, SQLite, ## SQL Server Data Tools Download page: [SQL Server Data Tools]
-Release date: 2017-04-15
-Support Version: 2008/2012/2014/2016/2017/Azure
+Release date: 2018-04-10
+Support Version: 2008-2017/Azure
Author: Microsoft
Free version: Yes
Price: No @@ -541,7 +682,7 @@ With SSDT, you can design and deploy any SQL Server content type with the same e ## Database Health Monitor Download page: [Database Health Monitor]
-Release date: 2016-03-20
+Release date: 2019-12-01
Support Version: 2008/2012/2014/2016
Author: Steve Stedman
Free version: Yes
@@ -566,26 +707,26 @@ SchemaDrift is a SQL Server database comparison tool that allows you to compare ## DBeaver Download page: [DBeaver]
-Release date: 2016-06-06
-Support Version: 2005/2008/2008R2/2012/2014/2016
+Release date: 2020-11-29
+Support Version: 2005-2019
Author: Open Source
Free version: Yes
Price: No -Free multi-platform database tool for developers, SQL programmers, database administrators and analysts. -Supports all popular databases: MySQL, PostgreSQL, SQLite, Oracle, DB2, SQL Server, Sybase, MongoDB, Cassandra, etc +Free multi-platform database tool for developers, database administrators, analysts and all people who need to work with databases. +Supports all popular databases: MySQL, PostgreSQL, SQLite, Oracle, DB2, SQL Server, Sybase, MS Access, Teradata, Firebird, Apache Hive, Phoenix, Presto, etc. ## HeidiSQL Download page: [HeidiSQL]
-Release date: 2016-06-19
-Support Version: 2005/2008/2008R2/2012/2014/2016
+Release date: 2020-11-02
+Support Version: 2005-2019
Author: Open Source
Free version: Yes
Price: No -HeidiSQL is a useful and reliable tool designed for web developers using the popular MySQL server, Microsoft SQL databases and PostgreSQL. +HeidiSQL is a useful and reliable tool designed for web developers using the popular MariaDB, MySQL, Microsoft SQL, PostgreSQL and SQLite. It enables you to browse and edit data, create and edit tables, views, procedures, triggers and scheduled events. Also, you can export structure and data either to SQL file, clipboard or to other servers. @@ -621,7 +762,7 @@ ExpressProfiler (aka **SqlExpress Profiler**) is a simple and fast replacement f ## Data Migration Assistant Download page: [Data Migration Assistant]
-Release date: 2017-03-15
+Release date: 2020-04-23
Support Version: 2005/2008/2008R2/2012/2014/2016/Azure
Author: Microsoft
Free version: Yes
@@ -773,14 +914,14 @@ Avoid using this feature in new development work, and plan to modify application ## Ssms Utility -Download page: [Ssms Utility]
+Download page: [SSMS Utility]
Release date: -
Support Version: 2005/2008/2008R2/2012/2014/2016
Author: Microsoft
Free version: Yes
Price: No -The Ssms utility opens SQL Server Management Studio. +The SSMS utility opens SQL Server Management Studio. If specified, Ssms also establishes a connection to a server, and opens queries, scripts, files, projects, and solutions. You can specify files that contain queries, projects, or solutions. Files that contain queries are automatically connected to a server if connection information is provided and the file type is associated with that type of server. @@ -802,6 +943,18 @@ The dtexec utility provides access to all the package configuration and executio The dtexec utility lets you load packages from these sources: the Integration Services server, an .ispac project file, a Microsoft SQL Server database, the SSIS Package Store, and the file system. +## adutil Utility + +Download page: [adutil Utility]
+Release date: -
+Support Version: 2017-2019
+Author: Microsoft
+Free version: Yes
+Price: No + +Configure Active Directory authentication with SQL Server on Linux. + + ## SQL Server 2016 Report Builder Download page: [SQL Server 2016 Report Builder]
@@ -915,18 +1068,6 @@ Price: $495 SQL Data Compare is the industry-standard tool for comparing and deploying SQL Server database contents -## Red Gate SQL Prompt - -Download page: [Red Gate SQL Prompt]
-Release date: 2016-04-28
-Support Version: 2005/2008/2012/2014
-Author: Red Gate
-Free version: No
-Price: $369 - -Write, format and refactor SQL effortlessly - - ## Red Gate SQL Monitor Download page: [Red Gate SQL Monitor]
@@ -976,7 +1117,7 @@ Generate realistic test data fast ## Red Gate SQL Dependency Tracker - + Download page: [Red Gate SQL Dependency Tracker]
Release date: 2016-04-26
Support Version: 2005/2008/2012/2014
@@ -1027,7 +1168,7 @@ Compare and synchronize automatically database schemas and data Download page: [Red Gate SQL Clone]
Release date: 2017-02-27
-Support Version: 2008/2012/2014/2016/VNext
+Support Version: 2008-2017
Author: Red Gate
Free version: No
Price: $6955 @@ -1037,6 +1178,38 @@ Price: $6955 - Clones work just like normal databases. You can connect to them and edit them using any program. SQL Clone's web app provides an easy central place to create and manage clones. - With SQL Clone, your team can work locally on up-to-date, isolated copies of the database to speed up development, accurately test code, and fix issues faster. + +## Red Gate SQL Provision + +Download page: [Red Gate SQL Provision]
+Release date: 2018-02-26
+Support Version: 2008-2017
+Author: Red Gate
+Free version: No
+Price: $2955 + +Create, protect, and manage SQL Server database copies for compliant DevOps + + +## Red Gate SQL Data Masker + +Download page: [Red Gate SQL Data Masker]
+Release date: 2018-02-26
+Support Version: 2008-2017
+Author: Red Gate
+Free version: No
+Price: $2355 + +Replace sensitive data with realistic, anonymized, test data + + - Multiple methods to sanitize sensitive information + - Use templates to remain consistent with existing data formats + - Replacement data sets included, such as Names, Zip Codes, Emails + - Populate test data as well as sanitize existing information + - Simple, repeatable, fast, and easy to use + - Supports SQL Server and Oracle databases + + ## DLM Automation Download page: [DLM Automation]
@@ -1623,11 +1796,29 @@ Price: ? - Streamline incident management with native ServiceNow integration - ## dbForge Schema Compare +## SQL Data Profiler + +Download page: [SQL Data Profiler]
+Release date: ?
+Support Version: 2008-2019
+Author: Idera
+Free version: No
+Price: ? + + - Profile data in SQL Server tables + - Analyze subsets of data types at a time + - Adjust profiling thresholds to customize the analysis + - Display summary of data in selected table and its columns + - Receive recommendations based on data per column + - View summary of value distribution per column + - Export results to plain text file format + + +## dbForge Schema Compare Download page: [dbForge Schema Compare]
-Release date: 2017-09-15
-Support Version: SQL Azure/2000/2005/2008/2008R2/2012/2014/2016/2017
+Release date: 2019-10-10
+Support Version: 2005-2019/Amazon/Azure
Author: Devart
Free version: No
Price: $150 @@ -1639,9 +1830,9 @@ You can compare your SQL Server databases, analyze differences and synchronize y ## dbForge Data Compare -Download page: [dbForge Schema Compare]
-Release date: 2017-08-30
-Support Version: SQL Azure/2000/2005/2008/2008R2/2012/2014/2016
+Download page: [dbForge Data Compare]
+Release date: 2019-10-10
+Support Version: 2005-2019/Amazon/Azure
Author: Devart
Free version: No
Price: $149 @@ -1654,20 +1845,22 @@ and effortlessly synchronize data via a convenient wizard with additional option ## dbForge Data Generator Download page: [dbForge Data Generator]
-Release date: 2017-09-15
-Support Version: Amazon RDS/SQL Azure/2000/2005/2008/2008R2/2012/2014/2016
+Release date: 2019-10-10
+Support Version: 2005-2019/Amazon/Azure
Author: Devart
Free version: No
Price: $249 -dbForge Data Generator for SQL Server is a powerful GUI tool for fast generation of meaningful test data. The tool includes 190+ predefined generators with sensible configuration options, that allow emulating column-intelligent real-world data. dbForge Data Generator for SQL Server can save your time and effort by populating SQL Server tables with millions of rows of test data that looks just like real data. +dbForge Data Generator for SQL Server is a powerful GUI tool for fast generation of meaningful test data. +The tool includes 190+ predefined generators with sensible configuration options, that allow emulating column-intelligent real-world data. +dbForge Data Generator for SQL Server can save your time and effort by populating SQL Server tables with millions of rows of test data that looks just like real data. ## dbForge Query Builder Download page: [dbForge Query Builder]
-Release date: 2017-08-30
-Support Version: Amazon RDS/SQL Azure/2000/2005/2008/2008R2/2012/2014/2016
+Release date: 2019-10-10
+Support Version: 2005-2019/Amazon/Azure
Author: Devart
Free version: No
Price: $99 @@ -1681,8 +1874,8 @@ But even experienced users can save a lot of time on routine work. ## dbForge Event Profiler Download page: [dbForge Event Profiler]
-Release date: 2017-08-30
-Support Version: 2008/2012/2014/2016
+Release date: 2019-10-10
+Support Version: 2005-2019
Author: Devart
Free version: Yes
Price: No @@ -1695,8 +1888,8 @@ You can use this information to identify and troubleshoot many SQL Server-relate ## dbForge SQL Decryptor Download page: [dbForge SQL Decryptor]
-Release date: 2017-04-20
-Support Version: 2000/2005/2008/2008R2/2012/2014/2016
+Release date: 2017-09-19
+Support Version: 2005-2019
Author: Devart
Free version: Yes
Price: No @@ -1707,8 +1900,8 @@ Decrypt SQL Server Procedures, Functions, Triggers, and Views ## dbForge Studio Download page: [dbForge Studio]
-Release date: 2017-08-03
-Support Version: 2005/2008/2008R2/2012/2014/2016/2017/Amazon RDS/SQL Azure
+Release date: 2019-10-10
+Support Version: 2005-2019/Amazon/Azure
Author: Devart
Free version: Yes
Price: $249 @@ -1723,8 +1916,8 @@ Price: $249 ## dbForge Fusion Download page: [dbForge Fusion]
-Release date: 2016-12-27
-Support Version: Amazon RDS/SQL Azure/2000/2005/2008/2008R2/2012/2014
+Release date: 2019-11-08
+Support Version: 2005-2019/Amazon/Azure
Author: Devart
Free version: No
Price: $149 @@ -1737,83 +1930,56 @@ It provides an easier way to explore and maintain existing databases, design com ## dbForge Documenter Download page: [dbForge Documenter]
-Release date: 2017-08-30
-Support Version: 2005/2008/2008R2/2012/2014/2016
+Release date: 2020-04-23
+Support Version: 2005-2019
Author: Devart
Free version: No
Price: $149 dbForge Documenter for SQL Server is a big time saver when it comes to documentation of SQL Server databases. This tool automatically generates documentation of an entire SQL Server database in a few clicks. -The tool includes a wide range of options to customize the generated documentation to meet your specific requirements. +The tool includes a wide range of options to customize the generated documentation to meet your specific requirements. -## dbForge Developer Bundle - -Download page: [dbForge Developer Bundle]
-Release date: 2017-08-30
-Support Version: 2005/2008/2008R2/2012/2014/2016
+## dbForge SSIS Data Flow Components + +Download page: [dbForge SSIS Data Flow Components]
+Release date: 2020-03-31
+Support Version: 2014-2019
Author: Devart
Free version: No
-Price: $849 - -Developer Bundle for SQL Server is a tool pack that extends SSMS with many essential features aimed not only boost developers' productivity but also reduce expenses while performing routine tasks. - - Increase productivity, when creating complex queries and code writing with SQL Complete, Search, Documenter and Query Builder. - - Save your time while comparing and synchronizing data and schema with Source Control, Data Compare, and Schema Compare. - - Simplify the testing process drastically and generate intensional test data with Data Generator and Unit Test. - - Monitor SQL Server performance and troubleshoot database issues using Index Manager, Monitor, as well as Event Profiler. +Price: $500 +Devart SSIS Data Flow Components provide easy to set up cost-effective data integration using SSIS ETL engine. +They provide high performance data loading, convenient component editors, SQL support for cloud data sources and lots of data source specific features. -## dbForge Compare Bundle for SQL Server - -Download page: [dbForge Compare Bundle for SQL Server]
-Release date: 2017-08-30
-Support Version: 2005/2008/2008R2/2012/2014/2016
+## dbForge DevOps Automation for SQL Server + +Download page: [dbForge DevOps Automation for SQL Server]
+Release date: 2020-04-13
+Support Version: 2014-2019
Author: Devart
Free version: No
-Price: $299 +Price: $900 + +dbForge DevOps Automation for SQL Server is a cutting-edge solution that takes conventional database development and deployment to a whole new level. + -One solution to handle SQL data and schema diffs. - - A variety of supported schema objects. - - Convenient comparison wizards will help you to tune data and schema comparisons up to your needs.. - - Compare databases with different structures. - - Manage comparison results by applying filtering, grouping, exclude or include the needed objects to continue working with them, etc. - - Handy Synchronization wizards will help you to: create accurate synchronization scripts, migrate any schema differences, dependency check to script objects in the correct order for updates, resolve synchronization issues automatically, view warnings on controversial points prior to synchronization. - - Command-line interface. - - ## Devart Excel Add-in for SQL Server Download page: [Devart Excel Add-in for SQL Server]
-Release date: 2017-09-13
-Support Version: 2005/2008/2008R2/2012/2014/2016
+Release date: 2019-12-11
+Support Version: 2005-2019
Author: Devart
Free version: No
-Price: $100 +Price: $250 Devart Excel Add-ins allow you to work with database and cloud data in Microsoft Excel as with usual Excel spreadsheets. -## Minion Enterprise - -Download page: [Minion Enterprise]
-Release date: ?
-Support Version: 2008/2008R2/2012
-Author: MinionWare
-Free version: No
-Price: $1500 - -Minion Enterprise was designed by database administrators (DBAs) specifically to address the issues that waste the most time and cause the most problems. -Minion shrinks dozens of those one-at-a-time tasks down to a central process. And, it does this without the usual overhead of monitoring software. -When you install Minion Enterprise, it automatically begins gathering data from instances across your enterprise. -That single repository of data allows you to centrally audit, alert, report, and investigate your entire environment. -Even better, it opens up a new world of central management: audit SQL and AD security, clone user permissions across servers, -standardize and enforce SQL Server settings, automate error log searches, and so very much more. - - ## SQL Server Compression Estimator - + Download page: [SQL Server Compression Estimator]
Release date: 2011-06-02
Support Version: 2008/2008R2/2012
@@ -1831,21 +1997,38 @@ You can then use that information to perhaps choose a less aggresive compression Download page: [ClearTrace]
Release date: 2016-07-07
-Support Version: 2008/2012/2014/2016
+Support Version: 2000-2017
Author: Bill Graziano
Free version: Yes
Price: No -ClearTrace imports SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008, SQL Server 2005, SQL Server 2000 trace -and Profiler files into SQL Server and displays summary performance information. +ClearTrace imports SQL Server 2017, 2016, 2014, 2012, 2008, 2005, 2000 trace and Profiler files into SQL Server and displays summary performance information. +- Summarize SQL Server Query Performance +- Enhance SQL Server Performance Tuning -## Dell Security Explorer - -Download page: [Dell Security Explorer]
-Release date: 2015-06-25
-Support Version: 2008/2012/2014
-Author: Dell
+ +## ClearTraceXE + +Download page: [ClearTraceXE]
+Release date: 2019-09-04
+Support Version: 2008-2017
+Author: Bill Graziano
+Free version: Yes
+Price: No + +ClearTrace for Extended Events imports extended event files from SQL Server 2017, 2016, 2014, 2012, 2008. + +- Summarize SQL Server Query Performance +- Enhance SQL Server Performance Tuning + + +## Security Explorer + +Download page: [Security Explorer]
+Release date: 2008-2017
+Support Version: 2019-08-29
+Author: Quest Software
Free version: No
Price: $850 @@ -1854,12 +2037,12 @@ Plus, it complements Microsoft tools by solving key SQL Server challenges, so yo It also makes it easy to manage change, resolve issues quickly and promote the highest levels of code quality, performance and maintainability. -## Dell LiteSpeed for SQL Server - -Download page: [Dell Security Explorer]
-Release date: 2015-07-31
-Support Version: 2008/2012/2014
-Author: Dell
+## LiteSpeed for SQL Server + +Download page: [LiteSpeed for SQL Server]
+Release date: 2019-08-29
+Support Version: 2008-2017
+Author: Quest Software
Free version: No
Price: ? @@ -1868,12 +2051,12 @@ operations across the entire enterprise. Easily manage and monitor SQL Server pr With LiteSpeed, a complete workbench of SQL Server recovery tools are at your fingertips so you can get data back online — fast. -## Dell Toad for SQL Server - -Download page: [Dell Toad for SQL Server]
-Release date: 2015-05-12
-Support Version: 2008/2008R2/2012/2014
-Author: Dell
+## Toad for SQL Server + +Download page: [Toad for SQL Server]
+Release date: 2019-08-29
+Support Version: 2008-2017
+Author: Quest Software
Free version: No
Price: ? @@ -1884,12 +2067,12 @@ Unlike native tools, Security Explorer provides the ability to back up and resto Security Explorer provides on-the-fly reports to help meet auditing requirements. -## Dell Spotlight - -Download page: [Dell Spotlight]
-Release date: 2016-03-10
-Support Version: 2008/2008R2/2012/2014
-Author: Dell
+## Quest Spotlight + +Download page: [Quest Spotlight]
+Release date: 2019-08-29
+Support Version: 2008-2017
+Author: Quest Software
Free version: No
Price: $2561 @@ -1901,12 +2084,12 @@ an integrated Xpert tuning module and mobile device support, Spotlight on SQL Server Enterprise makes it easier than ever to obtain the data you need to ensure the health of your SQL Server databases. -## Dell Foglight - -Download page: [Dell Foglight]
-Release date: 2015-09-22
-Support Version: 2008/2008R2/2012/2014
-Author: Dell
+## Quest Foglight + +Download page: [Quest Foglight]
+Release date: 2019-08-29
+Support Version: 2008-2017
+Author: Quest Software
Free version: No
Price: ? @@ -1916,34 +2099,16 @@ multi-platform environments – even when you use native or third-party tools Get a wealth of information at a fraction of the impact of conventional collection methods. -## Dell Discovery Wizard - -Download page: [Dell Foglight]
-Release date: 2011-09-22
-Support Version: 2008/2008R2/2012/2014
-Author: Dell
-Free version: Yes
-Price: No - - - Take inventory of your network databases, including data amounts - - Choose the databases you want to consolidate - - Review database history, including installation and creation dates - - Find the SQL Server versions and service packs currently deployed - - Identify names of servers, instances and operating systems - - Learn the identity of your end users - - -## Dell Enterprise Reporter - -Download page: [Dell Enterprise Reporter]
+## Quest Enterprise Reporter + +Download page: [Quest Enterprise Reporter]
Release date: ?
-Support Version: 2008/2008R2/2012/2014
-Author: Dell
+Support Version: 2008-2017
+Author: Quest Software
Free version: No
Price: $511 -Dell Enterprise Reporter for SQL Server provides ad-hoc reporting for visibility database security configuration, -including users and logins, roles and database permissions +Quest Enterprise Reporter for SQL Server provides ad-hoc reporting for visibility database security configuration, including users and logins, roles and database permissions. ## SQL Scripter @@ -1979,7 +2144,7 @@ Simple Dynamic Scheduler is alternative scheduling utility which uses SQL Server Download page: [ApexSQL Audit]
Release date: 2017-07-11
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Author: ApexSQL
Free version: No
Price: $1699 @@ -1998,7 +2163,7 @@ Price: $1699 Download page: [ApexSQL Backup]
Release date: 2017-10-12
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Author: ApexSQL
Free version: No
Price: $499 @@ -2017,7 +2182,7 @@ Price: $499 Download page: [ApexSQL Defrag]
Release date: 2017-06-29
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Author: ApexSQL
Free version: No
Price: $499 @@ -2032,7 +2197,7 @@ Price: $499 Download page: [ApexSQL Log]
Release date: 2017-05-24
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Author: ApexSQL
Free version: No
Price: $1999 @@ -2051,7 +2216,7 @@ Price: $1999 Download page: [ApexSQL Monitor]
Release date: 2017-10-05
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Author: ApexSQL
Free version: No
Price: $499 @@ -2069,8 +2234,8 @@ Price: $499 ## ApexSQL Plan Download page: [ApexSQL Plan]
-Release date: 2017-10-26
-Support Version: 2008/2012/2014/2016/2017
+Release date: 2019-12-02
+Support Version: 2008-2017
Author: ApexSQL
Free version: Yes
Price: No @@ -2088,8 +2253,8 @@ Price: No ## ApexSQL Propagate Download page: [ApexSQL Propagate]
-Release date: 2017-09-25
-Support Version: 2008/2012/2014/2016/2017
+Release date: 2020-02-19
+Support Version: 2008-2017
Author: ApexSQL
Free version: Yes
Price: No @@ -2108,7 +2273,7 @@ Price: No Download page: [ApexSQL Build]
Release date: 2017-05-15
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Author: ApexSQL
Free version: No
Price: $399 @@ -2125,7 +2290,7 @@ Price: $399 Download page: [ApexSQL Clean]
Release date: 2017-09-28
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Author: ApexSQL
Free version: No
Price: $399 @@ -2144,7 +2309,7 @@ Price: $399 Download page: [ApexSQL Data Diff]
Release date: 2017-10-03
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Author: ApexSQL
Free version: No
Price: $599 @@ -2164,8 +2329,8 @@ Price: $599 ## ApexSQL Decrypt Download page: [ApexSQL Decrypt]
-Release date: 2017-08-16
-Support Version: 2008/2012/2014/2016/2017
+Release date: 2020-03-12
+Support Version: 2008-2017
Author: ApexSQL
Free version: Yes
Price: No @@ -2184,7 +2349,7 @@ Price: No Download page: [ApexSQL Diff]
Release date: 2017-10-26
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Author: ApexSQL
Free version: No
Price: $599 @@ -2202,7 +2367,7 @@ Price: $599 Download page: [ApexSQL Doc]
Release date: 2017-09-06
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Author: ApexSQL
Free version: No
Price: $699 @@ -2221,7 +2386,7 @@ Price: $699 Download page: [ApexSQL Generate]
Release date: 2017-07-13
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Author: ApexSQL
Free version: No
Price: $499 @@ -2240,7 +2405,7 @@ Price: $499 Download page: [ApexSQL Script]
Release date: 2017-05-08
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Author: ApexSQL
Free version: No
Price: $399 @@ -2278,7 +2443,7 @@ Price: $1299 Download page: [ApexSQL Trigger Viewer]
Release date: 2017-06-01
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Author: ApexSQL
Free version: Yes
Price: No @@ -2298,6 +2463,204 @@ Price: No Utility to create a lightweight 'snapshot' of a database schema, that can be used by ApexSQL Diff as a datasource +## ApexSQL Model + +Download page: [ApexSQL Model]
+Release date: 2019-05-22
+Support Version: 2008-2019
+Author: ApexSQL
+Free version: No
+Price: No + +Create database model diagrams and synchronize changes with existing databases. + - Forward and reverse engineer + - Customize the appearance of models + - Create new or modify existing object groups + - Navigate through model history + - Export database models as imagesCustomize print output + + +## ApexSQL Analyze + +Download page: [ApexSQL Analyze]
+Release date: 2017-12-13
+Support Version: 2008-2017
+Author: ApexSQL
+Free version: No
+Price: $299 + +Database dependency analysis + + - View and analyze SQL dependencies + - Customize the appearance of dependency diagrams + - Map dependencies down to the column level + - Visualize object dependencies graphically + - Export diagrams as image files + - Perform impact analysis on potential object deletions + + +## ApexSQL BI Monitor + +Download page: [ApexSQL BI Monitor]
+Release date: 2018-09-18
+Support Version: 2008-2017
+Author: ApexSQL
+Free version: No
+Price: $499 + + - Monitor SSAS, SSIS and SSRS performance + - Add custom performance counters + - Track system performanceUse baselines to customize alert thresholds + - View real-time and historical data + - Set up various alert actions for each counter + - Generate built-in and custom reportsTrack user activity + + +## ApexSQL VM Monitor + +Download page: [ApexSQL VM Monitor]
+Release date: 2018-05-09
+Support Version: 2008-2017
+Author: ApexSQL
+Free version: No
+Price: $999 + +Virtualization performance monitoring + + - Monitor multiple hypervisors - Hyper-V and ESXi + - View system performance metrics of monitored hosts + - Monitor virtual machines performance + - Monitor performance of host devices + - Use comprehensive dashboards for viewing metrics + - Calculate baselines and thresholds + - View top 5 loaded virtual machines for specific hosts + - Create and export comprehensive performance reports + + +## ApexSQL VM Job + +Download page: [ApexSQL Job]
+Release date: 2018-03-29
+Support Version: 2008-2017
+Author: ApexSQL
+Free version: No
+Price: $499 + + - Manage SQL Server Agent jobs across multiple servers + - Get a detailed job history overview + - Manage SQL Server services on managed servers + - Export job details to PDF, HTML, XML or CSV format + - Manage SQL Server schedulesControl the status of SQL Server Agent services + - Define and manage SQL Server alertsMonitor SQL Server Agent logs + + +## ApexSQL Enforce + +Download page: [ApexSQL Enforce]
+Release date: 2018-07-19
+Support Version: 2008-2017
+Author: ApexSQL
+Free version: No
+Price: $299 + + - Review databases and individual SQL scripts + - Import and export rulesProcess unattended via the CLI + - Seamlessly integrate into your CI/CD processLeverage a library of 100+ pre-written rules + - Create custom rules with a built in IDE + - Write custom rules in C# or VB.NETCreate HTML reports and XML exports + - Integrate with SSMS and Visual Studio + - Generate SQL to fix violations + + +## ApexSQL CI/CD toolkit + +Download page: [ApexSQL CI/CD toolkit]
+Release date: 2020-05-21
+Support Version: 2005-2017
+Author: ApexSQL
+Free version: Yes
+Price: No + + - Build from source control + - Include static data in builds + - Generate synthetic test data + - Automatically run SQL unit tests + - Add a data change audit trail + - Document and report on changes + - Create a data sync script + - Create a schema sync script + - Plug into popular build servers + - Enforce SQL coding standards + - Work with all popular SC systems + - Trigger manually or automatically + + +## ApexSQL Compare + +Download page: [ApexSQL Compare]
+Release date: 2020-03-17
+Support Version: 2005-2017
+Author: ApexSQL
+Free version: Yes
+Price: No + + - Two-way SQL code compare + - SSMS and Visual Studio integration + - Char-by-char compare + - Windows Explorer integration + - Line-by-line compare + - File and folder compare + - Block-by-block compare + - Database object compare + - Syntax highlighting + - Ignore script options + - HTML results report + - Automation and scheduling + + +## ApexSQL Complete + +Download page: [ApexSQL Complete]
+Release date: 2020-05-28
+Support Version: 2005-2017
+Author: ApexSQL
+Free version: Yes
+Price: No + + - Automatically complete SQL statements + - Review an object's script and description + - Improve productivity with snippets + - Identify the structure of complex SQL queries + - Keep track of all your tabs + - Log every executed query + - Easily navigate to SQL objects + - Check queries in test mode + - Color query tabs by environment + - Search and export query results + - Create CRUD procedures + - Guard against queries that may damage data + + +## ApexSQL Refactor + +Download page: [ApexSQL Refactor]
+Release date: 2020-06-09
+Support Version: 2005-2019
+Author: ApexSQL
+Free version: Yes
+Price: No + + - SQL formatter with over 160 options + - Qualify objects and expand wildcards + - Encapsulate SQL into procedures + - Add surrogate keys + - Replace one-to-many relationships + - Change procedure parameters + - Safely rename SQL objects + - Locate & highlight unused variables + - Format SQL objects + - Obfuscate SQL + ## DBBest T-SQL Analyzer @@ -2356,8 +2719,8 @@ SqlDiffFramework compares two data sources and highlights both row and column di ## DataGrip Download page: [DataGrip]
-Release date: 2017-02-21
-Support Version: 2008/2012/2014/2016
+Release date: 2018-02-21
+Support Version: 2008-2017
Author: Jet Brains
Free version: No
Price: $89 @@ -2474,7 +2837,7 @@ With SQLC you can perform Object comparison (Database schema) as well as Data co Download page: [Database Performance Analyzer]
Release date: ?
-Support Version: 2008/2012/2014/2016/2017/Azure/Amazon
+Support Version: 2008-2017/Azure/Amazon
Author: SolarWinds
Free version: No
Price: $1995 @@ -2486,7 +2849,7 @@ Monitor across your entire environment: physical servers, virtualized, and in th Download page: [Database Performance Analyzer for MSSQL]
Release date: ?
-Support Version: 2008/2012/2014/2016/2017/Azure/Amazon
+Support Version: 2008-2017/Azure/Amazon
Author: SolarWinds
Free version: No
Price: $1995 @@ -2516,8 +2879,8 @@ Price: $295 ## Aireforge Studio Download page: [Aireforge Studio]
-Release date: 2017-06-21
-Support Version: 2008/2012/2014/2016/Azure
+Release date: 2019-08-08
+Support Version: 2008-2019/Azure
Author: AireForge
Free version: Yes
Price: $299 @@ -2750,21 +3113,32 @@ Price: $810 ERwin Data Modeler is an industry-leading data modeling solution that provides a simple, visual interface to manage your complex data environment -## Toad Data Modeler - -Download page: [Toad Data Modeler]
+## Luna Modeler + +Download page: [Luna Modeler]
+Release date: 2022-10-05
+Support Version: 2019/2022
+Author: Ideamerit
+Free version: No
+Price: $99 + +Luna Modeler is a database design and data modeling tool for relational databases. With Luna Modeler, you can create ER diagrams, design and visualize database structures, generate SQL scripts, and document your data models. + + +## Toad Data Point + +Download page: [Toad Data Point]
Release date: 2016-06-16
-Support Version: 2008/2012/2014
-Author: Dell
+Support Version: 2008-2017
+Author: Quest Software
Free version: No
-Price: $562 +Price: ? -Easily create high-quality data models. Toad Data Modeler enables you to rapidly deploy accurate changes to data structures across more than 20 different platforms. -It allows you to construct logical and physical data models, compare and synchronize models, quickly generate complex SQL/DDL, create and modify scripts, as well as reverse and forward engineer both databases and data warehouse systems +Query and Reporting Software Tool for Data Analysts ## SQL Power Architect - + Download page: [SQL Power Architect]
Release date: 2016-02-11
Support Version: 2008/2012/2014
@@ -2779,8 +3153,8 @@ It allows users to reverse-engineer existing databases, perform data profiling o ## DbWrench Download page: [DbWrench]
-Release date: 2016-07-06
-Support Version: 2008/2012/2014
+Release date: 2019-09-17
+Support Version: 2008-2017
Author: Nizana Systems
Free version: No
Price: $99 @@ -2806,11 +3180,11 @@ It allows you to visually design database structures, perform reverse/forward en ## DeZign for Databases Download page: [DeZign for Databases]
-Release date: 2016-04-25
-Support Version: 2008/2012/2014
+Release date: 2019-04-01
+Support Version: 2008-2017
Author: Datanamic
Free version: No
-Price: $259 +Price: €29/month DeZign for Databases is an intuitive database design and modeling tool for developers and DBA's that can help you model, create and maintain databases. The software uses entity relationship diagrams (ERDs, data models) to graphically design databases and automatically generates the most popular SQL and desktop database. @@ -2883,9 +3257,9 @@ It supports all major database vendors, works on all major operating systems and ## RazorSQL Download page: [RazorSQL]
-Release date: 2016-09-29
-Support Version: 2008/2012/2014/2016
-Author: Richardson Software
+Release date: 2019-09-26
+Support Version: 2008-2019
+Author: Richardson Software
Free version: No
Price: $100 @@ -2912,8 +3286,8 @@ While sitting in the tray, you can format SQL in any editor like Microsoft Query ## Database .NET Download page: [Database .NET]
-Release date: 2017-01-13
-Support Version: 2008/2012/2014/2016
+Release date: 2018-08-20
+Support Version: 2008-2017
Author: fish's dotNET
Free version: Non-commercial
Price: $69 @@ -2925,8 +3299,8 @@ You can browse/grant objects, design tables, edit rows, run queries, generate sc ## dbMigration .NET Download page: [dbMigration .NET]
-Release date: 2017-01-13
-Support Version: 2008/2012/2014/2016
+Release date: 2018-08-20
+Support Version: 2008-2017
Author: fish's dotNET
Free version: Non-commercial
Price: $49 @@ -2954,10 +3328,10 @@ Price: No - Can run with no installation or it can be run as a service -## Database Experimentation Assistant Technical Preview 2 +## Database Experimentation Assistant Download page: [Database Experimentation Assistant]
-Release date: 2017-03-24
+Release date: 2020-03-20
Support Version: 2005/2008/2012/2014/2016
Author: Microsoft
Free version: Yes
@@ -2984,14 +3358,14 @@ Automatically, and in far less time than it takes to handle migrations manually, - Utilizes the MPP power of Azure SQL Data Warehouse to ingest the data quickly -## Flyway +## Flyway Download page: [Data Platform Studio]
-Release date: ?
+Release date: 2018-01-30
Support Version: Oracle, SQL Server, SQL Azure, MySQL, Other
Author: boxfuse
Free version: Open Source
-Price: No +Price: $950 Flyway is an open-source database migration tool. It strongly favors simplicity and convention over configuration. It is based around just 6 basic commands: Migrate, Clean, Info, Validate, Baseline and Repair. @@ -2999,10 +3373,10 @@ Migrations can be written in SQL (database-specific syntax (such as PL/SQL, T-SQ It has a Command-line client. If you are on the JVM, we recommend using the Java API (also works on Android) for migrating the database on application startup. Alternatively, you can also use the Maven plugin, Gradle plugin, SBT plugin or the Ant tasks. -## Liquibase +## Liquibase Download page: [Liquibase]
-Release date: 2016-10-24
+Release date: 2018-04-11
Support Version: Oracle, PostgreSQL, MySQL, Other
Author: Liquibase
Free version: Open Source
@@ -3017,10 +3391,10 @@ As a result, there is no database version number but this approach allows it to Liquibase automatically creates DatabaseChangeLog Table and DatabaseChangeLogLock Table when you first execute a changeLog File. -## My Batis +## My Batis Download page: [My Batis]
-Release date: 2016-06-22
+Release date: 2018-03-20
Support Version: Oracle, PostgreSQL, MySQL, Other
Author: My Batis
Free version: Open Source
@@ -3042,7 +3416,7 @@ MyBatis Schema Migration System (or MyBatis Migrations for short) seeks to: Download page: [SentryOne Plan Explorer]
Release date: 2017-05-25
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Author: SentryOne
Free version: Yes
Price: No @@ -3260,29 +3634,45 @@ SA MaaS Microsoft SQL Server for on-premise and virtual Microsoft SQL servers ga diagnostics to help network admins and DBAs keep SQL servers running at peak performance and find the logs they need. -## CatCompare v2 - -Download page: [CatCompare v2]
-Release date: 2017-01-07
+## SSIS Framework + +Download page: [SSIS Framework]
+Release date: 2019-01-07
Support Version: ?
Author: Andy Leonard
-Free version: No
-Price: $295 - -CatCompare provides automate-able command-line management of SSIS Catalog project configuration, deployment, migration, code promotion, and comparison. - +Free version: Yes
+Price: ? -## SSIS Catalog Compare v2.0 Bundle - -Download page: [SSIS Catalog Compare v2.0 Bundle]
+- Orchestrate SSIS Applications +- Execute SSIS Applications with a single command +- SSIS Catalog-integrated execution +- Works with SSMS Catalog Reporting +- Works with DILM Suite Catalog Reports +- SSIS Catalog-integrated logging +- SSIS Framework Reporting +- Restart SSIS Applications at Failed Application Package +- Application Package Parameter Support +- Metadata-Driven Data Tap Support +- Application Package Environment (References) Support +- Application Package Property Override Support +- Execute SSIS Applications / Packages on Different / Several Servers +- Support for “Enterprise Data Integration Farm” SSIS Scale-Out +- Enterprise Data Integration Reporting + + +## BimlExpress Metadata Framework + +Download page: [BimlExpress Metadata Framework]
Release date: 2017-01-06
Support Version: ?
Author: Andy Leonard
-Free version: No
-Price: $495 +Free version: Yes
+Price: No -Deploying SSIS Catalog Projects help deploying environments, references, mappings, and overrides. -The SSIS Catalog Compare Version 2.0 Bundle includes SSIS Catalog Compare and CatCompare, a CLI (Command-Line Interface) utility. +The BimlExpress Metadata Framework version 2 uses Business Intelligence Markup Language (Biml) to: +- Read metadata stored in a SQL Server database. +- Build SSIS projects that create the target database, schemas, and tables. +- Build an SSIS project that contains one SSIS package per table, plus a Controller package that executes each table-package. ## MS Kerberos Configuration Manager @@ -3312,11 +3702,11 @@ Can diagnose SQL Server performance issues quickly and accurately, ensuring a he ## DBConvert Studio Download page: [DBConvert Studio]
-Release date: 2017-03-01
-Support Version: ?
-Author: DMSoft Technologies
+Release date: 2020-05-11
+Support Version: 1.7.5
+Author: Slotix
Free version: Yes
-Price: 499 +Price: $499 DBConvert Studio Software combines familiar and powerful features from the mature DBConvert and DBSync product series along with a redesigned and improved UI. The following scenarios are available: @@ -3380,7 +3770,7 @@ Automatically upgrade objects within a SQL Server Instance from lower to higher Download page: [MS FoxPro to MS SQL Migration and Sync]
Release date: 2013-10-08
Support Version: 2005/2008/2012/Azure
-Author: DMSoft Technologies
+Author: Slotix
Free version: No
Price: $149 @@ -3395,7 +3785,7 @@ Approximately 1 Million of records from FoxPro to MSSQL Server with "Bulk" optio Download page: [MySQL to MS SQL Migration and Sync]
Release date: 2013-10-08
Support Version: 2005/2008/2012/Azure
-Author: DMSoft Technologies
+Author: Slotix
Free version: No
Price: $149 @@ -3413,7 +3803,7 @@ Integrated Data Types Mapping feature helps to find and map similar data types b Download page: [Oracle to MS SQL Migration and Sync]
Release date: 2013-10-09
Support Version: 2005/2008/2012/Azure
-Author: DMSoft Technologies
+Author: Slotix
Free version: No
Price: $149 @@ -3429,7 +3819,7 @@ Our tool easily handles huge databases and tables. A clear easy-to-use wizard in Download page: [PostgreSQL to MS SQL Migration and Sync]
Release date: 2013-10-08
Support Version: 2005/2008/2012/Azure
-Author: DMSoft Technologies
+Author: Slotix
Free version: No
Price: $149 @@ -3446,7 +3836,7 @@ Our software will save you hours of learning SQL commands as any large PostgreSQ Download page: [MS Excel to MS SQL Migration]
Release date: 2013-09-23
Support Version: 2005/2008/2012/Azure
-Author: DMSoft Technologies
+Author: Slotix
Free version: No
Price: $149 @@ -3462,7 +3852,7 @@ Saving data into a MS SQL Dump for export to MS SQL database Download page: [SQLite to MS SQL Migration and Sync]
Release date: 2014-05-08
Support Version: 2005/2008/2012/Azure
-Author: DMSoft Technologies
+Author: Slotix
Free version: No
Price: $149 @@ -3478,7 +3868,7 @@ If you have any restrictions on direct access to MS SQL server our product provi Download page: [IBM DB2 to MS SQL Migration and Sync]
Release date: 2013-09-09
Support Version: 2005/2008/2012/Azure
-Author: DMSoft Technologies
+Author: Slotix
Free version: No
Price: $149 @@ -3492,7 +3882,7 @@ Optionally target SQL Dump file may be generated if you haven’t a direct acces Download page: [IBM DB2 to MS SQL Migration and Sync]
Release date: 2013-10-08
Support Version: 2005/2008/2012/Azure
-Author: DMSoft Technologies
+Author: Slotix
Free version: No
Price: $149 @@ -3506,7 +3896,7 @@ The program allows migrating MS Access queries to MSSQL views automatically with Download page: [Firebird to MS SQL Migration and Sync]
Release date: 2013-09-11
Support Version: 2005/2008/2012/Azure
-Author: DMSoft Technologies
+Author: Slotix
Free version: No
Price: $149 @@ -3531,7 +3921,7 @@ Oracle, MariaDB, MySQL, PostgreSQL, IBM DB2, Sybase, Informix, Teradata, Greenpl ## SQLite & SQL Server Compact Toolbox - + Download page: [SQLite & SQL Server Compact Toolbox]
Release date: ?
Support Version: ?
@@ -3614,6 +4004,19 @@ Price: No Microsoft SQL Server Migration Assistant (SSMA) for Access is a tool to automate migration from Access database(s) to SQL Server and Azure SQL DB. +## SQL Server Migration Assistant for SAP ASE + +Download page: [SQL Server Migration Assistant for SAP ASE]
+Release date: 2020-06-29
+Support Version: 2012/2014/2016/2019/Azure
+Author: Microsoft
+Free version: Yes
+Price: No + +Microsoft SQL Server Migration Assistant (SSMA) for SAP ASE is a tool to automate migration from SAP ASE database(s) to SQL Server, Azure SQL Database and Azure SQL Database Managed Instance. +SSMA for SAP ASE is designed to support migration from SAP ASE version 11.9 and higher. + + ## mssql for Visual Studio Code Download page: [mssql for Visual Studio Code]
@@ -3632,11 +4035,11 @@ mssql for Visual Studio Code an extension for developing Microsoft SQL Server, A - Customizable extension options including command shortcuts and more -## Microsoft Assessment and Planning +## Microsoft Assessment and Planning (MAP) Toolkit -Download page: [Microsoft Assessment and Planning]
-Release date: 2017-02-10
-Support Version: 2008/2008R2/2012
+Download page: [Microsoft Assessment and Planning (MAP) Toolkit]
+Release date: 2020-05-26
+Support Version: 2008-2019
Author: Microsoft
Free version: Yes
Price: No @@ -3644,6 +4047,9 @@ Price: No The Microsoft Assessment and Planning Toolkit makes it easy to assess your current IT infrastructure for a variety of technology migration projects. This Solution Accelerator provides a powerful inventory, assessment, and reporting tool to simplify the migration planning process. +[Microsoft Assessment and Planning (MAP) Toolkit Wiki](https://social.technet.microsoft.com/wiki/contents/articles/1640.microsoft-assessment-and-planning-map-toolkit-getting-started.aspx) +[Microsoft Assessment and Planning (MAP) Toolkit Download]:https://www.microsoft.com/en-us/download/details.aspx?id=7826 + ## mssql-scripter @@ -3675,7 +4081,7 @@ This gives you the ability to explore information about your database (Dynamic M Download page: [Comparator]
Release date: 2017-06-06
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Author: Pumpet
Free version: Open Source
Price: No @@ -3687,7 +4093,7 @@ Simple application for compare data ## Navicat for SQL Server Download page: [Navicat for SQL Server]
Release date: 2017-06-14
-Support Version: 2008/2012/2014/2016/2017/Azure/AmazonRDS
+Support Version: 2008-2017/Azure/AmazonRDS
Author: PremiumSoft
Free version: No
Price: $699 @@ -3701,7 +4107,7 @@ Connect to any local/remote SQL Server, and compatible with cloud databases like ## Navicat Premium Download page: [Navicat Premium]
Release date: 2017-06-14
-Support Version: 2008/2012/2014/2016/2017/Azure/AmazonRDS
+Support Version: 2008-2017/Azure/AmazonRDS
Author: PremiumSoft
Free version: No
Price: $1299 @@ -3714,8 +4120,8 @@ You can quickly and easily build, manage and maintain your databases. ## DbVisualizer Download page: [DbVisualizer]
-Release date: 2017-11-16
-Support Version: 2008/2012/2014/2016/2017
+Release date: 2017-08-22
+Support Version: 2008-2017
Author: DbVis Software AB.
Free version: Yes
Price: $197 @@ -3728,7 +4134,7 @@ It is the perfect solution since the same tool can be used on all major operatin ## DbSchema Download page: [DbSchema]
Release date: 2017-06-19
-Support Version: 2008/2012/2014/2016/2017/Azure/Amazon
+Support Version: 2008-2017/Azure/Amazon
Author: Wise Coders Solutions
Free version: No
Price: $127 @@ -3780,10 +4186,10 @@ BimlExpress Visual Studio Add-in built specifically to work with SQL Server 2016 - Updates are released more rapidly to work with the most current versions of SQL Server. -## BIDS Helper - -Download page: [BIDS Helper]
-Release date: 2015-03-17
+## BI Developer Extensions + +Download page: [BI Developer Extensions]
+Release date: 2019-04-29
Support Version: ?
Author: Microsoft
Free version: Open Source
@@ -3793,7 +4199,7 @@ A Visual Studio add-in that enhances development functionality in Business Intel ## Azure Data Warehouse Migration Utility - + Download page: [Azure Data Warehouse Migration Utility]
Release date: ?
Support Version: ?
@@ -3806,9 +4212,9 @@ During schema migration, the tool automatically maps the corresponding schema fr After the schema has been migrated, the tools provides the option to move data with automatically generated scripts. - -## Dell Benchmark Factory -Download page: [Dell Benchmark Factory]
+ +## Benchmark Factory +Download page: [Benchmark Factory]
Release date: ?
Support Version: 2008/2012/2014/2016/Azure
Author: Quest Software
@@ -3842,7 +4248,7 @@ The Free Static code analyzer ## PowerBI Download page: [PowerBI Desktop]
Release date: 2017-07-11
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Author: Microsoft
Free version: Yes
Price: ? @@ -3881,7 +4287,7 @@ Recovery rate is the most important criterion of a SQL recovery product. Based on our comprehensive tests, DataNumen SQL Recovery has the best recovery rate, much more better than any other competitors in the market! - + ## Recovery Toolbox for SQL Server Download page: [Recovery Toolbox for SQL Server]
Release date: ?
@@ -3897,7 +4303,7 @@ Recovery Toolbox for SQL Server is a comprehensive recovery solution for damaged ## SQL MDF Viewer Download page: [SQL MDF Viewer]
Release date: ?
-Support Version: 2000/2005/2008/2008r2/2012/2014/2016
+Support Version: 2000-2016
Author: SysTools
Free version: No
Price: $129 @@ -4012,7 +4418,7 @@ SQL Cop is a static code analysis tool to automatically detect issues with your ## Dataedo Download page: [Dataedo]
Release date: 2017-09-15
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Author: Sqlbi
Free version: Yes
Price: $239 @@ -4024,7 +4430,7 @@ Document SQL Server, Oracle and MySQL databases ## Azure Database Migration Service Download page: [Dataedo]
Release date: 2017-12-01
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Author: Microsoft
Free version: Yes
Price: No @@ -4037,7 +4443,7 @@ The public preview release of Azure Database Migration Service is designed as a ## FlowHeater Download page: [flowheater]
Release date: 2017-10-02
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Author: FlowHeater GmbH
Free version: No
Price: $79 @@ -4049,7 +4455,7 @@ The FlowHeater functionality closely resembles the concept of a continuous-flow ## EDIS Download page: [EDIS]
Release date: ?
-Support Version: 2008/2012/2014/2016/2017
+Support Version: 2008-2017
Author: SQL ETL
Free version: Yes
Price: $599 @@ -4058,11 +4464,1775 @@ EDIS is an Extract-Transform-Load (ETL) application for Microsoft SQL Server. No 3rd Party Language, No Packages, Just SQL. -[SSMS]:https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms -[bcp Utility]:https://docs.microsoft.com/en-us/sql/tools/bcp-utility -[sqlcmd Utility]:https://docs.microsoft.com/en-us/sql/tools/sqlcmd-utility + +## SchemaSpy +Download page: [SchemaSpy]
+Release date: 2018-08-05
+Support Version: 2008-2017
+Author: Rafal Kasa
+Free version: Open Source
+Price: No + +Document your database simply and easily. +SchemaSpy is a Java-based tool (requires Java 8 or higher) that analyzes the metadata of a schema in a database and generates a visual representation of it in a browser-displayable format. +It lets you click through the hierarchy of database tables via child and parent table relationships as represented by both HTML links and entity-relationship diagrams. +It’s also designed to help resolve the obtuse errors that a database sometimes gives related to failures due to constraints. +It is free software that is distributed under the terms of the MIT License. + + + +## Adminer +Download page: [Adminer]
+Release date: 2019-08-27
+Support Version: 2005-2017
+Author: Adminer
+Free version: Open Source
+Price: No + +Adminer (formerly phpMinAdmin) is a full-featured database management tool written in PHP. Conversely to phpMyAdmin, it consist of a single file ready to deploy to the target server. +Adminer is available for MySQL, MariaDB, PostgreSQL, SQLite, MS SQL, Oracle, Firebird, SimpleDB, Elasticsearch and MongoDB. + + + +## Full Convert Enterprise +Download page: [Full Convert]
+Release date: 2018-08-20
+Support Version: 2005-2017
+Author: Spectral Core
+Free version: No
+Price: $699 + +Full Convert allows easy copying of tables and data between 40 or so supported databases. It will create all the tables, copy all of your data, then create indexes and foreign keys. +It has powerful mapping and customization features and uses optimal copying mode for each table separately to achieve the best possible throughput. + + + +## Replicator Pro +Download page: [Replicator]
+Release date: 2018-08-20
+Support Version: 2005-2017
+Author: Spectral Core
+Free version: No
+Price: $799 + +Replicator allows table data comparison and sync - even with heterogeneous databases. It is unique in the fact it can replicate changes only even if source is non-relational (CSV, DBF, Excel documents, Paradox...). +Replicator has a built-in scheduler for easy periodic change replication. + + + +## JackDB +Download page: [JackDB]
+Release date: ?
+Support Version: 2008-2017/Azure
+Author: JackDB
+Free version: No
+Price: $49 + +JackDB is a modern database client. Collaborate with data securely across your entire organization. + + + +## SQL Workbench +Download page: [SQL Workbench]
+Release date: 2018-08-20
+Support Version: 2008-2017
+Author: Thomas Kellerer
+Free version: Yes
+Price: No + +SQL Workbench/J is a free, DBMS-independent, cross-platform SQL query tool. It is written in Java and should run on any operating system that provides a Java Runtime Environment. +Its main focus is on running SQL scripts (either interactively or as a batch) and export/import features. +**Graphical query building or more advanced DBA tasks are not the focus and are not planned.** + + + +## Valentina Studio +Download page: [Valentina Studio]
+Release date: 2018-09-24
+Support Version: 2008-2017
+Author: Paradigma Software
+Free version: Yes
+Price: $200 + +Valentina Studio is your universal database management tool for working with MySQL, MariaDB, SQL Server, PostgreSQL, SQLite and Valentina DB databases. +Valentina Studio lets you connect with all major databases, run queries and generate diagrams to better understand your mission critical business data - and that is the free version of Valentina Studio. + + + +## SQL Plus Dot Net +Download page: [SQL Plus Dot Net]
+Release date: ?
+Support Version: ?
+Author: SQL+.NET
+Free version: No
+Price: ? + +SQL+ is a tool that generates a class library from stored procedures by utilizing a tagging system in the form of comments. +Does all the ADO stuff like setting up parameters and converting result sets into objects. + + + +## SQLIndexManager +Download page: [SQLIndexManager]
+Release date: 2019-05-19
+Support Version: 2008-2019/Azure
+Author: Sergey Syrovatchenko
+Free version: Yes
+Price: No + +Analyze and fix index fragmentation for SQL Server / Azure + + + +## JAMS Enterprise Job Scheduling +Download page: [JAMS Enterprise Job Scheduling]
+Release date: 2019-08-20
+Support Version: 2008-2019
+Author: HelpSystems
+Free version: No
+Price: ? + +Take control of SQL Agent sprawl. Automate smarter with JAMS and regain control over your critical SQL Server batch processes. + +- Monitor SQL Server Job Progress +- Customize SQL Job Schedules (Dates, times, triggers, dependencies and more) +- Send Alerts + + + +## Stitch Data Loader +Download page: [Stitch Data Loader]
+Release date: 2019-09-20
+Support Version: 2008-2019/Azure
+Author: Talend
+Free version: No
+Price: ? + +Stitch makes it simple to load data from dozens of cloud sources into cloud data warehouses and data lakes in minutes. + + + +## Talend Data Integration +Download page: [Talend Data Integration]
+Release date: 2019-06-20
+Support Version: 2008-2019/Azure
+Author: Talend
+Free version: Yes
+Price: ? + +Talend Data Integration an enterprise data integration software to connect, access, and transform any data across the cloud or on-premises. + + + +## Talend Data Preparation +Download page: [Talend Data Preparation]
+Release date: 2018-06-05
+Support Version: 2008-2019/Azure
+Author: Talend
+Free version: Yes
+Price: ? + +Talend Data Preparation empowers anyone to quickly prepare data for trusted insights throughout the organization. + + + +## Pentaho Data Integration +Download page: [Talend Data Integration]
+Release date: 2019-06-20
+Support Version: 2008-2019/Azure
+Author: Hitachi Vantara
+Free version: No
+Price: ? + +This end-to-end platform meets all data integration challenges. Its intuitive drag-and-drop graphical interface simplifies the creation of self-documented data pipelines. +For data transformation, easily use push-down processing to scale out compute platforms, such as Apache Hadoop. + + + +## Studio3T +Download page: [Studio3T]
+Release date: 2019-09-19
+Support Version: 2008-2019
+Author: Studio 3T
+Free version: No
+Price: $149 + +Speed up tasks like query building, data exploration, import/export, code generation, and more – with or without the knowledge of the MongoDB query language. +MongoDB from and to migrations with many RDBMS. + + + +## SQLGrease +Download page: [SQLGrease]
+Release date: 2019-09-20
+Support Version: 2008-2019/Azure/RDS
+Author: SQLGrease
+Free version: No
+Price: $948 + +SQLGrease was built from the ground up specifically for monitoring SQL Server. +Using the newest monitoring features in SQL Server, SQLGrease collects detailed information with extremely low overhead. + + +## QuickDBD + +Download page: [QuickDBD]
+Release date: ?
+Support Version: ?
+Author: Dovetail Technologies Ltd
+Free version: Yes
+Price: $95 + +Draw databases diagrams by typing online and collaborating. + + +## DB Designer + +Download page: [DB Designer]
+Release date: ?
+Support Version: ?
+Author: DB Designer
+Free version: Yes
+Price: $180 + +All The Features You Need For Database Design – Simple But Powerful. + + +## ESF Database Migration Toolkit + +Download page: [ESF Database Migration Toolkit]
+Release date: 2019-10-23
+Support Version: 2008-2017
+Author: DBSofts Inc
+Free version: No
+Price: $322 + +ESF Database Migration Toolkit is the most popular toolkit to help people migrate data across various database formats, supporting Oracle, MySQL, MariaDB, SQL Server, PostgreSQL, IBM DB2, IBM Informix, InterSystems Caché, Teradata, Visual Foxpro, SQLite, FireBird, InterBase, Microsoft Access, Microsoft Excel, Paradox, Lotus, dBase, CSV/Text and so on. + + +## MS SQL Migration Toolkit + +Download page: [MS SQL Migration Toolkit]
+Release date: 2019-04-22
+Support Version: 2008-2017
+Author: Intelligent Converters
+Free version: No
+Price: $99 + +MS SQL Migration Toolkit is a software pack to convert any data source to Microsoft SQL Server or Azure SQL and vice versa. The product has high performance because it does not use ODBC or any other middleware software. +Command line support allows to script, automate and schedule the conversion. + + +## DatabaseSpy + +Download page: [DatabaseSpy]
+Release date: 2019-10-09
+Support Version: 2008-2019
+Author: Altova
+Free version: No
+Price: €109 + +Altova DatabaseSpy is the unique multi-database query and design tool that even generates elegant charts directly from query results. + + +## DiffDog + +Download page: [DatabaseSpy]
+Release date: 2019-10-09
+Support Version: 2008-2019
+Author: Altova
+Free version: No
+Price: €109 + +Altova DiffDog® 2020 is a powerful diff/merge tool for files, folders, and databases. +This easy-to-use synchronization tool quickly compares and merges text or source code files, Microsoft Word documents, directories, CSV files, databases, and XML Schemas via its intuitive visual interface. +It indicates differences, intelligently merges content, and creates XSLT to convert XML data. + + +## ERBuilder data modeler + +Download page: [ERBuilder data modeler]
+Release date: 2019-11-14
+Support Version: 2008-2019/AzureSQL
+Author: Softbuilder
+Free version: Yes
+Price: $99 + +ERBuilder Data Modeler allows developers to graphically design databases by using entity relationship diagrams, and automatically generates the most popular SQL databases. +It also allows developers to easily deploy databases by offering a sophisticated visual data modeling environment. + + +## SQLDatabaseStudio + +Download page: [SQLDatabaseStudio]
+Release date: 2017-05-10
+Support Version: 2008-2017
+Author: Jan Pivarcek
+Free version: Yes
+Price: $215 + +- Attention to the details is what makes SQL Database Studio (SDS) perfect. SDS automates repetitive tasks such as filtering, sorting, searching and much more. You can stay focused on problem you are solving and be more productive. +- Start Up in No Time +- Smart and Modern IDE + + +## Enterprise Architect + +Download page: [Enterprise Architect]
+Release date: 2019-10-31
+Support Version: 2008-2017
+Author: Sparx Systems Pty Ltd
+Free version: No
+Price: $225 + +Integrated modeling platform. +Enterprise Architect, t's built-in Data Modeling tools and profiles extend UML to provide an intuitive mapping from the database concepts of tables and relationships onto the UML concepts of classes and associations. These extensions also enable you to model database keys, triggers, constraints, RI and other relational database features. +Enterprise Architect supports modeling of database schema and automatic generation of DDL scripts for eleven DBMS targets out-of-the-box: DB2, Firebird, MS Access, MySQL, MS SQL Server, Oracle, PostgreSQL + + +## MogwaiERDesignerNG + +Download page: [MogwaiERDesignerNG]
+Release date: 2019-08-22
+Support Version: 2008-2017
+Author: Mirko Sertic
+Free version: Yes
+Price: No + +Java 2D & 3D visual entity relationship design & modeling (ERD,SQL) for Oracle, MSSQL, Postgres and MySQL. + +The Mogwai ERDesigner is an entity relationship modeling/design tool(ERD) such as ERWin and co. +The only difference is that it is Open Source and does not cost anything. +It was designed to make database modeling as easy as it can be and to support the developer in the whole development process, from database design to schema and code generation. + + +## Xcase + +Download page: [Xcase]
+Release date: 2018-06-19
+Support Version: 2008-2017
+Author: Resolution Software Ltd
+Free version: No
+Price: $799 + +Xcase is a complete database design tool engineered to help you accomplish all your database-related tasks – from database design to modeling to daily modifications – with greater speed, higher quality, and better adherence to best practices. Its powerful automation and graphics features quickly and accurately complete tasks throughout the entire life cycle of your database, freeing you to focus on database strategy. + + +## Oracle SQL Developer Data Modeler + +Download page: [Oracle SQL Developer Data Modeler]
+Release date: 2019-08-01
+Support Version: 2008-2017
+Author: Oracle
+Free version: Yes
+Price: No + +Oracle SQL Developer Data Modeler is a free graphical tool that enhances productivity and simplifies data modeling tasks. +Using Oracle SQL Developer Data Modeler users can create, browse and edit, logical, relational, physical, multi-dimensional, and data type models. +The Data Modeler provides forward and reverse engineering capabilities and supports collaborative development through integrated source code control. +The Data Modeler can be used in both traditional and in Cloud environments. + + +## Exportizer + +Download page: [Exportizer]
+Release date: 2019-11-17
+Support Version: 2008-2017
+Author: Vitaliy Levchenko
+Free version: No
+Price: $29 + +You can export dbf to txt, csv to dbf, Paradox to xls, and make several other data conversions. +Beside that, in Exportizer Pro or Exportizer Enterprise, it is possible to export DB2 to xlsx, SQLite to dBase, Access to HTML, Excel to Access, migrate Interbase to SQL Server, FDB to Excel, Oracle to PostgreSQL, and much more. + + +## Reportizer + +Download page: [Reportizer]
+Release date: 2019-09-10
+Support Version: 2008-2017
+Author: Vitaliy Levchenko
+Free version: No
+Price: $39 + +Reportizer is a software tool to create database and file reports. +With Reportizer, you can create professional reports in a couple of minutes! + + +## Database Tour + +Download page: [Database Tour]
+Release date: 2019-11-20
+Support Version: 2008-2017
+Author: Vitaliy Levchenko
+Free version: No
+Price: $49 + +Database Tour is a multi-functional database tool for Windows. +In addition, Database Tour Pro provides powerful command line and reporting functionality. + + +## Ispirer MnMATK + +Download page: [Ispirer MnMATK]
+Release date: 2019-10-23
+Support Version: 2008-2017
+Author: Ispirer Systems
+Free version: No
+Price: ? + +Ispirer Migration and Modernization Assessment Toolkit (Ispirer MnMATK) is designed to collect statistical information about your database or application, as well as better realize the size of a migration project. +The software provides a full report on the number of tables, the amount of data, the number of database objects, and the number of lines of code in each type of database object. +The toolkit consists of Migration Assessment Wizard designed to collect and evaluate information about the database, and Migration Assessment Studio designed to collect and evaluate information about the application. + + +## SQL Database Recovery + +Download page: [SQL Database Recovery]
+Release date: 2019-09-10
+Support Version: 2008-2019
+Author: KernelApps Private
+Free version: No
+Price: $399 + +Repair corrupt and damaged MS SQL database files. + + +## SysTools SQL Log Analyzer + +Download page: [SysTools SQL Log Analyzer]
+Release date: 2019-01-01
+Support Version: 2000-2019
+Author: SysTools
+Free version: No
+Price: $999 + +SysTools SQL Log Analyzer - To Read & Analyze SQL Server Log File (.ldf) Transactions +- Complete analyses of SQL transaction Log (.ldf) file to identify critical changes in record +- Open, Read & Analyze all Microsoft SQL transactions: Insert, Update & Delete +- SQL LDF File Recovery to restore the modified database back into SQL Server +- Forensic Investigator can track who modified SQL table records with details provide by Log Analyzer +- Quick Scan to deeply examine log file & provide full visibility to database records +- Open & Analyze all operation of a transaction(LDF) file Without MS SQL Server application +- SQL Log Analyzer works on both Online & Offline SQL Database Environment +- Support to fetch & view records from Live SQL database environment +- Support For Advance SQL Data Type : Datetime2, datetimeoffset, sql_variant, hierarchyid, geometry & geography data types +- Dynamic Filters to export only Selective transaction records after complete analyses +- Display LDF information in SQL Scripts, CSV file or directly export to any SQL Server database +- Auto-locate MDF to read database schema of scanned Log File while opting Offline DB Option +- Provide support to Unicode (Collation) property after exporting database + + +## SysTools SQL Server Recovery Manager + +Download page: [SysTools SQL Server Recovery Manager]
+Release date: 2017-01-01
+Support Version: 2000-2016
+Author: SysTools
+Free version: No
+Price: $1499 + +- Recover & Export SQL Database: Primary (MDF) and Secondary (NDF) +- Analyze SQL Server LOG database transactions +- Scan, recover & Export database from corrupt SQL Server Backup File +- Recover & Reset SQL User Password from master.mdf file +- Decrypt Encryption of SQL Server Scripts & Database from Live Environ +- Recover Data from all Database Files : master.mdf/.ndf/.bak/.ldf etc. + + +## SysTools SQL Recovery + +Download page: [SysTools SQL Recovery]
+Release date: 2019-01-01
+Support Version: 2000-2019
+Author: SysTools
+Free version: No
+Price: $249 + +- Quick & Advanced Scan To Repair SQL Database : Both Primary & Secondary +- SQL Recovery Software will Recover Deleted SQL Server Database Table's Data +- Scan & Recover Multiple NDF Files (Secondary Database) +- Scan & Recover Triggers, Rules, Functions, Tables, Stored Procedures +- Export File into SQL Server Database or as SQL Server Compatible Scripts Using SQL Database Repair Tool +- Auto Fetches SQL Server Name while Exporting to SQL Server Database +- Desired Items Selection to Save File with Schema or Schema & Data Both +- Option to preview deleted records in red colour +- Support ASCII and Unicode XML datatype +- Recover data from Wallet Ransomware affected .mdf files. + + +## SysTools SQL Recovery + +Download page: [SysTools SQL Recovery]
+Release date: 2018-01-01
+Support Version: 2000-2017
+Author: SysTools
+Free version: No
+Price: $149 + +- Recover & Preview Tables, Views, Procedures, Triggers, Functions, Columns +- Supports to repair corrupt SQL Backup file without any modification +- Recover MDF & NDF files Saved within SQL Backup File +- Option of Auto-Detect to detect the version of SQL .bak file +- 2 Export Options: SQL Server Database or SQL Server Compatible Script +- Supports XML Data type in MS SQL server 2017, 2016, 2014, 2012, 2008 +- No File Size Limitation: Tested with 1.4 TB of SQL .bak file + + +## SysTools SQL Password Recovery + +Download page: [SysTools SQL Password Recovery]
+Release date: 2018-01-01
+Support Version: 2000-2017
+Author: SysTools
+Free version: No
+Price: $149 + +- Reset both Individual User & SA passwords from SQL master.mdf file +- Installation of MS SQL Server is not mandatory to reset SA password +- SQL Server services should be stopped while loading master.mdf file +- Recover & Reset SQL password of any length or type without any fail +- Provide facility to set new password for User Login within a software +- Capable to recover Multilingual Password of MDF Files successfully +- SQL Server SA Password Recovery can install on Windows OS + + +## SysTools SQL Decryptor + +Download page: [SysTools SQL Decryptor]
+Release date: 2019-01-01
+Support Version: 2000-2019
+Author: SysTools
+Free version: No
+Price: $69 + +- Remove encryption from complete MS SQL database +- Supports Dual Login Mode : Windows & SQL Server Authentication +- SQL Server credentials required to decrypt SQL database file +- Option Export SQL database: SQL Server & Compatible Scripts +- Able to Decrypt SQL Stored Procedure, Triggers, Functions, Views. +- SQL Server should be installed on machine for decryption +- Dedicated Admin Connection (DAC) is required to run the utility + + +## SysTools SQL Server Database Migrator + +Download page: [SysTools SQL Server Database Migrator]
+Release date: 2018-01-01
+Support Version: 2000-2017
+Author: SysTools
+Free version: No
+Price: $249 + +- Migrate Corrupted SQL Server Database from SQL Server 2008 to 2012, 2014, 2016, 2017 +- Move Tables, Functions, SPs etc from One database to Another In all SQL Server +- Migrate Database Objects (Tables, Functions, Stored Procedures etc) from One Server to Another +- Creates .sql Script File of All Database Objects of an MDF File One by One +- Migrate SQL Database Objects from One Server to Another With Only Schema +- Copy SQL Server Database from One Server to Another With Schema & Data +- Move & Export SQL Server Database on an Existing Database or as a New Database. + + +## SQL Server to Azure Database Migrator + +Download page: [SQL Server to Azure Database Migrator]
+Release date: 2018-01-01
+Support Version: 2000-2017
+Author: SysTools
+Free version: No
+Price: $169 + +- Able to Move all SQL database objects : Tables, Triggers, Stored Procedures etc. +- Migrate corrupted / inaccessible SQL database to Azure Database +- Preview all database components before migrating SQL Database to Azure +- Auto-detect SQL Server version while migrating data to Azure SQL database +- Allows to migrate selected data items 'With Schema' or 'With Schema & Data' option +- Provides facility to Migrate NDF file data to Azure SQL database +- Allows to Migrate deleted records to SQL Azure cloud database + + +## Commvault Complete Backup & Recovery + +Download page: [Commvault Complete Backup & Recovery]
+Release date: 2019-12-31
+Support Version: 2008-2019
+Author: Commvault
+Free version: No
+Price: ? + +Complete coverage starts and ends here. Commvault Complete Backup & Recovery is a single, powerful solution for data protection – wherever your data lives. +[Supported Technologies](https://www.commvault.com/supported-technologies) + + +## Veeam Backup & Recovery + +Download page: [Veeam Backup & Replication]
+Release date: 2019-12-31
+Support Version: 2008-2019
+Author: Veeam
+Free version: No
+Price: $600 + +Veeam Backup & Replication™ delivers Intelligent Data Management for ALL your virtual, physical and cloud-based workloads. +Through a single management console, you can manage fast, flexible and reliable backup, recovery and replication of all your applications and data to eliminate legacy backup solutions forever. + + +## Database Modeling Excel + +Download page: [Database Modeling Excel] +Release date: ? +Support Version: ? +Author: Yang Ning (Steven) +Free version: Yes +Prise: No + +The database modeling utility is a Microsoft Office Excel workbook which can help you to design databases. +It supports DB2, MariaDB, MySQL, Oracle, PostgreSQL, SQLite and SQL Server. +In the workbook, you can define database, generate DDL scripts, and import database definition from existing databases. + + +## DBAchecks + +Download page: [DBAchecks] +Release date: ? +Support Version: ? +Author: sqlcollaborative +Free version: Yes +Prise: No + +This open source module allows us to crowd-source our checklists using Pester tests. Such checks include: + - Backups are being performed + - Identity columns are not about to max out + - Servers have access to backup paths + - Database integrity checks are being performed and corruption does not exist + - Disk space is not about to run out + - All enabled jobs have succeeded + + +## DBComparer + +Download page: [DBComparer] +Release date: ? +Support Version: 2005-2008 +Author: DBComparer +Free version: Yes +Prise: No + + - Automate compare database + - Compare all database objects or selected ones only + - Compare database by all or selected properties of objects only + - A wide variety of options for comparison + - Compare databases using all or selected object properties + - Advanced visual build tree interface for an intuitive visual representation of any differences + - Built-in text differences control with SQL syntax highlighting + + +## DbViewSharp + +Download page: [DbViewSharp] +Release date: 2014-08-08 +Support Version: 2005 – 2014 +Author: David Moore +Free version: Yes +Prise: No + +DbViewSharp is a very useful application that is designed to provide you with a means of exploring and managing SQL databases. + + +## DTSQL + +Download page: [DTSQL] +Release date: 2017-08-18 +Support Version: ? +Author: DigerTech Inc +Free version: Yes +Prise: $69 + +DtSQL is an universal database tool for developers and database administrators to Query, Edit, Browse, and Manage database objects. +It can access most databases and can be used on all major operating systems. + + +## MSKerberos Configuration Manager + +Download page: [MSKerberos Configuration Manager] +Release date: 2020-02-25 +Support Version: 2008 – 2019 +Author: Microsoft +Free version: Yes +Prise: No + +Microsoft Kerberos Configuration Manager for SQL Server is a diagnostic tool that helps troubleshoot Kerberos related connectivity issues with SQL Server, SQL Server Reporting Services, and SQL Server Analysis Services. + + +## Partition Management + +Download page: [Partition Management] +Release date: ? +Support Version: ? +Author: ? +Free version: Yes +Prise: No + + - Remove all the data from one partition by switching it out to a staging table. It creates the required staging table. + - Create a staging table for loading data into a partition. The staging table can be created with or without indexes -- if created without indexes this utility provides a separate command to create appropriate indexes on the staging table, before SWITCHing it into the partitioned table. + + +## Powershell Scripts + +Download page: [Powershell Scripts] +Release date: ? +Support Version: 2008-2017 +Author: Idera +Free version: Yes +Prise: No + + - 147 sample PowerShell scripts to manage SQL Server and Azure SQL Database + - Scripts to initialize PowerShell modules + - Scripts for Database Engine, and for Analysis, Integration and Reporting Services + - Support for SQL Server 2016 and 2017, and Windows Server 2016 + - 15 New scripts for Azure SQL Database + + +## PSDatabaseClone + +Download page: [PSDatabaseClone] +Release date: ? +Support Version: ? +Author: Sander Stad +Free version: Yes +Prise: No + +PSDatabaseClone is a PowerShell module dedicated to the provisioning of databases using virtual disk technology. + + +## Pssdiag&Sqldiag Manager + +Download page: [Pssdiag&Sqldiag Manager] +Release date: 2020-05-04 +Support Version: ? +Author: Jack Li +Free version: Yes +Prise: No + +Pssdiag/Sqldiag Manager is a graphic interface that provides customization capabilities to collect data for SQL Server using sqldiag collector engine. The data collected can be used by SQL Nexus tool which help you troubleshoot SQL Server performance problems. This is the same tool Microsoft SQL Server support engineers use to for data collection to troubleshoot customer's performance problems. + + +## SQuirreL SQL Client + +Download page: [SQuirreL SQL Client] +Release date: 2020-04-30 +Support Version: ? +Author: Colin Bell, Gerd Wagner +Free version: Yes +Prise: No + +SQuirreL SQL Client is a JAVA-based database administration tool for JDBC compliant databases. It allows you to view the database structure and issue SQL commands. It provides an editor that offers code completion and syntax highlighting for standard SQL. + + +## Data Synchronisation Studio + +Download page: [Data Synchronisation Studio] +Release date: 2020-05-26 +Support Version: SQL Server 2014 or higher +Author: Simego Ltd +Free version: No +Prise: $999 + +The complete package for data integration and automation for SQL. + - Import + Export + - Data Reconciliation + - Data Preview + - Transformation + - Lookups + - Connection Library + - Schedule + + +## SQL Converter + +Download page: [SQL Converter] +Release date: 2015-12-15 +Support Version: ? +Author: Alaa Ben Fatma +Free version: Yes +Prise: No + +SQL Converter is the utility, allowing one to extract information from source servers selectively and save it to a variety of formats. + + +## SQLDBSearch + +Download page: [SQLDBSearch] +Release date: ? +Support Version: 2000-2019 +Author: Mohamed Bouarroudj +Free version: Yes +Prise: No + +SQLDBSearch is a SQL Server tool that lets you easily and quickly search for database objects or SQL statements across your databases. + + +## SQLDBSize + +Download page: [SQLDBSize] +Release date: ? +Support Version: 2000-2019 +Author: Mohamed Bouarroudj +Free version: Yes +Prise: No + +SQLDBSize is a SQL Server tool that allows you to display graphically the size used or reserved by tables, indexes, databases, transaction logs and physical files. + + +## SQLines Data + +Download page: [SQLines Data] +Release date: 2019-05-29 +Support Version: ? +Author: SQLines +Free version: Yes +Prise: No + +SQLines Data is an open source, scalable, parallel high performance data transfer and schema conversion tool that you can use for database migrations and ETL processes. + + +## SSqlDbAid + +Download page: [SqlDbAid] +Release date: 2018-02-10 +Support Version: 2005+ +Author: Miken +Free version: Yes +Prise: No + + - Text search inside code definition with highlitghting + - DBA reports (missing indexes, missing foreign key indexes, indexes status, top queries, table MBytes) + - One file per object or single file scripts (tables, views, triggers, procedures, functions, indexes...) + - Select, Insert and Update scripts + - Table data insert script creation + - Table/View data export + - Offline database compare tool + + +## sqlectron + +Download page: [sqlectron] +Release date: 2018-09-06 +Support Version: ? +Author: sqlectron +Free version: Yes +Prise: No + +A simple and lightweight SQL client with cross database and platform support. + + +## SQL ExecStats + +Download page: [SQL ExecStats] +Release date: ? +Support Version: ? +Author: Elemental Inc +Free version: Yes +Prise: No + +ExecStats started out with a focus on execution plan analysis with cross-referencing index usage to the SQL. Formerly separate programs for performance monitoring and server system architecture discovery via WMI have now been integrated into ExecStats. + + +## SQL-FineBuild + +Download page: [SQL-FineBuild] +Release date: 2017-10-28 +Support Version: 2005-2017 +Author: Edward Vassie +Free version: Yes +Prise: No + +SQL FineBuild provides 1-click install and best-practice configuration on Windows of SQL Server 2017 down to SQL Server 2005. + + +## SQL Health Monitor + +Download page: [SQL Health Monitor] +Release date: ? +Support Version: 2000-2014 +Author: Edward Vassie +Free version: Yes +Prise: No + + - Keep a tab on the performance parameters of both default and named instances + - Get a dashboard view of system resources used & MS SQL performance parameters + - Fetch the status of Winodws services related to your MS SQL Server + - Keep an eye on buffer, memory, lock and latch details of your MS SQL Server + - Generate real time performance reports in PDF format and Email it from the tool + + +## SQL Instance Check + +Download page: [SQL Instance Check] +Release date: ? +Support Version: 2008-2019 +Author: Idera +Free version: Yes +Prise: No + + + - Monitor 20 key performance metrics + - See throughput of varying types + - See "heartbeat" statistics at different intervals + - Up and running in minutes with easy installation wizard + - No agents required + - Connect to cloud and run in cloud (provisional) + + +## SQLPRep + +Download page: [SQLPRep] +Release date: ? +Support Version: ? +Author: Consequential Solutions +Free version: Yes +Prise: No + +SQLPRep 2015 aka SQL Performance Report is our newest software product that takes any TSQL and produces a concise, readable, highlighted performance report allowing you to greatly reduce your time spent in developing, debugging, optimising, testing and reviewing TSQL. + + +## SQL Server Monitoring + +Download page: [SQL Server Monitoring] +Release date: ? +Support Version: 2005 and higher +Author: Spiceworks +Free version: Yes +Prise: No + + - Auto collect data about the server + - Instantly access health info on the data + - Create multiple widgets to monitor what you want + - Monitor SQL Server size, connection, speed & more + + +## SQL Server Storage manager + +Download page: [SQL Server Storage manager] +Release date: ? +Support Version: ? +Author: Lepide Software +Free version: Yes +Prise: No + + - Removes the need to writing complex SQL Servers and stored procedures + - Provides real time alerts based on easy to configure criteria + - Provides a centralized platform to create consolidated reports of all SQL resources + - Provides simple graphical displays showing all elements of your SQL servers + + +## SysKit Pulse + +Download page: [SysKit Pulse] +Release date: ? +Support Version: ? +Author: SysKit Ltd +Free version: Yes +Prise: No + + - Track servers via interactive live dashboards. + - Server Auto-Discover Wizard + - Performance Counters Check + - A simplified way of looking at your servers. + + +## WhatsUp SQL Server Monitor + +Download page: [WhatsUp SQL Server Monitor] +Release date: ? +Support Version: ? +Author: Ipswitch +Free version: Yes +Prise: No + +The WhatsUp SQL Server Monitor is a free tool that shows off Ipswitch monitoring technology you can use to catch problems before they begin to affect users. + + +## YourSqlDba + +Download page: [YourSqlDba] +Release date: 2020-05-05 +Support Version: ? +Author: Maurice Pelchat +Free version: Yes +Prise: No + +YourSqlDba script creates a database named YourSqlDba packed with T-SQL modules (function, stored procedures, and views) on the server where it is run. +You don't need to be concerned by all of them, albeit some of them are interesting tools for exceptional day-to-day DBA tasks, out of regular maintenance tasks. + + +## POPSQL + +Download page: [POPSQL] +Release date: 2020-08-01 +Support Version: 2008-2019 +Author: POPSQL +Free version: Yes +Prise: $10 + +Collaborative SQL editor for your team. +Write queries, visualize data, and share your results. + + +## ApexSQL Search + +Download page: [ApexSQL Search]
+Release date: 2020-07-30
+Support Version: SQL Server 2005 and higher
+Author: ApexSQL
+Free version: Yes
+Price: No + + - Search for SQL objects + - Quickly find data in SQL tables + - Edit extended properties + - Easily navigate to result objects + - Rename SQL objects safely + - Export results to HTML, CSV and Excel + + +## ApexSQL Source Control + +Download page: [ApexSQL Source Control]
+Release date: 2020-01-20
+Support Version: SQL Server 2005 and higher
+Author: ApexSQL
+Free version: No
+Price: $299 + + - Integrate SQL source control directly into SSMS + - Use dedicated or shared development models + - View conflicts and resolve directly in the UI + - View a detailed history of changes + - Lock objects to prevent overwrites + - Set team policies for check outs and locks + - Apply changes with dependency aware scripts + - Create and apply labels from source control + - Create branch or merge branches directly from SSMS + - Associate a changeset with a TFS work item + + +## Azure Blob Studio 2011 + +Download page: [Azure Blob Studio 2011]
+Release date: 2010-12-25
+Support Version: ?
+Author: Alessandro Del Sole
+Free version: Yes
+Price: No + +Azure Blob Studio is a tool for managing files in the Windows Azure's Blob Storage +You can: + - Work with both the developer and on-line accounts + - Create containers (folders) + - Upload multiple blobs (files) + - Remove containers + - Remove multiple blobs + - Retrieve URI for each blob + - Copy the blob's URI to the clipboard right-clicking the Blob's name + - Retrieve metadata + - Open blobs via URI + + +## Azure Explorer + +Download page: [Azure Explorer]
+Release date: ?
+Support Version: ?
+Author: Monza Cloud
+Free version: Yes
+Price: No + + - Manage Azure blobs like local files + - Support for common blob operations + - Built for users with thousands of blob containers + - Designed for Microsoft Azure + + +## Azure SQL Agent + +Download page: [Azure SQL Agent]
+Release date: ?
+Support Version: ?
+Author: ?
+Free version: Yes
+Price: No + +Command line agent to automatically add your current public IP address to the Azure SQL firewall + + +## Azure SQL Database DTU Calculator + +Download page: [Azure SQL Database DTU Calculator]
+Release date: ?
+Support Version: ?
+Author: Justin Henriksen
+Free version: Yes
+Price: No + +This calculator will help you determine the number of DTUs for your existing SQL Server database(s) as well as a recommendation of the minimum performance level and service tier that you need before you migrate to Azure SQL Database. + + +## Azure SQL Database Stress Test Tool + +Download page: [Azure SQL Database Stress Test Tool]
+Release date: ?
+Support Version: ?
+Author: Kiyoaki Tsurutani
+Free version: Yes
+Price: No + +Azure SQL Database Stress Test Tool + + +## Azure SQL Dev Cloner + +Download page: [Azure SQL Dev Cloner]
+Release date: ?
+Support Version: ?
+Author: ?
+Free version: Yes
+Price: No + +Command line tool for cloning an Azure SQL Database from website instance to another. It optionally allows the target to be a Deployment Slot. + + +## Azure User Management Console + +Download page: [Azure User Management Console]
+Release date: ?
+Support Version: ?
+Author: ?
+Free version: Yes
+Price: No + +AUMC is a User Graphic Interface (GUI) that manages the users and logins of an Azure SQL database. The tool is simply convertin + + +## CloudMonix SQL Azure Database Management + +Download page: [CloudMonix SQL Azure Database Management]
+Release date: ?
+Support Version: ?
+Author: CloudMonix
+Free version: No
+Price: $15 + +CloudMonix monitors Azure SQL Databases by tracking their key performance indicators retrieved from Azure Management API and Dynamic Management Views. In addition, CloudMonix allows to automate maintenance tasks and automatically scale the database performance tier according to load. + +## DB Ghost Change Manager Professional + +Download page: [DB Ghost Change Manager Professional]
+Release date: ?
+Support Version: 2000-2019, Azure
+Author: Innovartis Ltd
+Free version: No
+Price: £430 + + - Scripts all object types into individual DROP/CREATE scripts, ready for check in to source control. + - Scripts data into boilerplate INSERT scripts. + - Builds databases from individual object scripts. + - Highlights syntax, dependency and data errors. + - Creates a single script for the database build that can be reused. + - Can synchronize two databases making them match precisely. + - Can synchronize an existing database to a set of base schema creation scripts in your Source Management System. This means that your Source Management System itself provides a complete audit trail. + - Can insert custom scripts at the end of the build, before and after the synch process. + - Creates a script of the differences between two databases or base schema scripts and a target database. + - Handles all types of database object and all complex interactions. + - Intuitive, straightforward wizard based interface. + - SessionSave facility lets you save your wizard answers for later reuse. + + +## dbForge Complete + +Download page: [dbForge Complete]
+Release date: 2020-09-01
+Support Version: 2000-2019, Azure
+Author: Devart
+Free version: No
+Price: $199 + + - Speed up SQL query writing with IntelliSense-style SQL code completion + - Beautify T-SQL code and unify code standards with smart SQL Formatter + - Get the essential information on DB objects while you are writing a code + - Format your SQL query right in Management Studio or Visual Studio + - Use rich SQL code snippet collection, manage and modify the existing snippets or create your own templates + - Navigate through the SQL document easily and synchronize it with the code + - Rename tables, columns, procedures, and functions safely with automatic correction of references to the renamed objects + - Boost your productivity significantly with convenient tabs and windows, as well as intuitive SQL statements management + + +## dbForge SQL Azure Backup + +Download page: [dbForge SQL Azure Backup]
+Release date: 2013-04-18
+Support Version: ?
+Author: Devart
+Free version: Yes
+Price: No + + - Create a copy of your SQL Azure database on local SQL Server + - Make an archive copy on your local hard drive + - Restore SQL Azure database from archive + - Schedule periodic backups to your Azure Blob storage + + +## Devart Transaction Log + +Download page: [Devart Transaction Log]
+Release date: 2020-10-16
+Support Version: 2008-2019
+Author: Devart
+Free version: No
+Price: $600 + +dbForge Transaction Log for SQL Server is a powerful transaction log reader tool and `.ldf` file viewer. +With its help, you can view and analyze SQL Server transaction logs and recover data from them. +The tool provides detailed information about all data changes in your database and gives you the ability to revert unwanted transactions on different levels depending on your current needs. + + +## Elastic database tools + +Download page: [Elastic database tools]
+Release date: ?
+Support Version: Azure
+Author: Microsoft
+Free version: Yes
+Price: No + +The elastic database client library helping you run a sample app. The sample app creates a simple sharded application and explores key capabilities of the Elastic Database Tools feature of Azure SQL Database. It focuses on use cases for shard map management, data-dependent routing, and multi-shard querying. The client library is available for .NET as well as Java. + + +## Microsoft Sync Framework + +Download page: [Microsoft Sync Framework]
+Release date: 2020-04-22
+Support Version: Azure
+Author: Microsoft
+Free version: Yes
+Price: No + +Microsoft Sync Framework is a comprehensive synchronization platform that enables collaboration and offline scenarios for applications, services, and devices. +Sync Framework 2.1 introduces new features that let you synchronize a SQL Server or SQL Server Compact database on your computer with a SQL Azure database. This release also introduces parameter-based filtering, the ability to remove synchronization scopes and templates from a database, and performance enhancements to make synchronization faster and easier. + + +## MSSQL-Maestro + +Download page: [MSSQL-Maestro]
+Release date: 2017-06-29
+Support Version: from 7.0 to 2019, Azure 11 and 12
+Author: SQL Maestro Group
+Free version: No
+Price: $229 + +Complete and powerful database management, admin and development tool for Microsoft SQL Server and Microsoft Azure SQL Database. + + +## MSSQLMerge + +Download page: [MSSQLMerge]
+Release date: 2021-02-26
+Support Version: 2008-2019, Azure
+Author: Konstantin Semenenkov
+Free version: Yes
+Price: $75 + +MssqlMerge is an easy to use diff & merge tool for Microsoft SQL Server databases. This tool allows users to compare and import/export the most common database programming objects and the data between any two databases. + + +## SQL Backup and FTP + +Download page: [SQL Backup and FTP]
+Release date: ?
+Support Version: ?
+Author: Pranas.NET
+Free version: Yes
+Price: $129 + +SQLBackupAndFTP is SQL Server, MySQL and PostgreSQL backup software that runs scheduled backups (full, differential or transaction log) of SQL Server or SQL Server Express databases (any version), runs file/folder backup, zips and encrypts the backups, stores them on a network or on an FTP server or in the cloud (Amazon S3 and others we're constantly adding more), removes old backups, and sends an e-mail confirmation on the job's success or failure. + + +## SQL Bak + +Download page: [SQL Bak]
+Release date: ?
+Support Version: ?
+Author: Pranas.NET
+Free version: Yes
+Price: $9 + + - Schedule and restore sql backup from any web browser on any device + - Send backups to a folder, FTP, Dropbox, Google Drive, OneDrive, Amazon S3 and more + - Monitor database performance and receive email alerts + - Install our app on Windows or Linux, connect to sqlbak.com, then manage backups via the web + + +## SQL Bulk Tools + +Download page: [SQL Bulk Tools]
+Release date: ?
+Support Version: ?
+Author: Greg Taylor
+Free version: Yes
+Price: No + +## SQL Data Examiner + +Download page: [SQL Data Examiner]
+Release date: ?
+Support Version: ?
+Author: Intelligent Database Solutions
+Free version: No
+Price: $400 + + - Migrate data between database servers + - Verify data migration success + - Consolidate data from slave databases to a master database + - Perform one-way master-slave or slave-master replication + + +## SQL Examiner + +Download page: [SQL Examiner]
+Release date: ?
+Support Version: ?
+Author: Intelligent Database Solutions
+Free version: No
+Price: $400 + + - Speed up the deployment of schema updates + - Eliminate a chance of a human error + - Quickly compare databases and find all the differences + - Work with MSSQL, Oracle, PostgreSQL, MySQL + - Keep your database schema under Source Control + - Set up a scheduled comparison and synchronization + - Performs cross-platform comparison and synchronization + + + +## SQL Database Backup + +Download page: [SQL Database Backup]
+Release date: ?
+Support Version: ?
+Author: Richard Astbury
+Free version: Yes
+Price: No + +Windows Azure SQL Database Backup Utility. +This utility will take a copy of your SQL Database, and once the copy has completed, will make a backup of the database to blob storage using the bacpac format. + + +## SQL Database Copy + +Download page: [SQL Database Copy]
+Release date: 2017-07-25
+Support Version: ?
+Author: ryanovic
+Free version: Yes
+Price: No + +Simple console tool uses SMO scripting capabilities and SqlBulkCopy for schema and data migration between different instances. +Available options: + - SQL Server database to Azure SQL database + - SQL Server database to SQL Server database + + +## SQL Delta Duo for SQL Server + +Download page: [SQL Delta Duo for SQL Server]
+Release date: ?
+Support Version: ?
+Author: The Australian Software Company
+Free version: No
+Price: $370 + +Compare and Sync Schema and Data for SQL Server databases. + + +## SQL Trace Replay + +Download page: [SQL Trace Replay]
+Release date: ?
+Support Version: ?
+Author: Mikhail Shilkov
+Free version: Yes
+Price: No + +Tool to capture and replay traces between SQL Server instances (and to Azure SQL Database in particular) + + +## SQL Workload Profiler + +Download page: [SQL Workload Profiler]
+Release date: 2014-10-01
+Support Version: 2008+, Azure
+Author: Chris Bailiss
+Free version: Yes
+Price: No + +SQL Workload Profiler is a free tool for capturing and logging workload performance information from SQL Server. Performance statistics can be captured minute-by-minute (or more frequently if you want, up to every ten seconds, depending on the type/size of workload). Data can be analysed as it is being collected and/or saved for later analysis. Workload Profiler supports both (on-premise) SQL Server and Azure SQL Database. + + +## SQLDBdiff + +Download page: [SQLDBdiff]
+Release date: ?
+Support Version: 2005-2019, Azure
+Author: SQLDBtools
+Free version: No
+Price: $60 + + - Tables and columns (with the possibility to respect or not columns order); + - Views (including their indexes and triggers); + - Stored procedures; + - User defined functions; + - Triggers; + - PK and Indexes (with the possibility to include or not statistic indexes); + - Relationships (FK); + - CHECK Constraints; + - Default Constraints; + - User Defined Data Type & User Defined Table Type + - DDL Triggers; + - Synonyms; + - In-Memory table + - System versioning (Temporal type) + - Permissions; + - User and Roles; + - Database properties; + - SQL Server properties. + + +## SQL Backup Master + +Download page: [SQL Backup Master]
+Release date: ?
+Support Version: 2005-2019
+Author: Key Metric Software
+Free version: Yes
+Price: $49 + + - Supports full, differential, and transaction log backups + - Simple yet powerful backup job scheduling + - Built-in email notifications for backup job successes, failures, and warnings + - Back up to local folders, network folders, or attached storage devices + - Back up to FTP servers with first-class FTP, SFTP, & FTPS support + - Back up to Dropbox, Google Drive, Box, Amazon S3, OneDrive, & Azure + + +## Handy Backup Server + +Download page: [Handy Backup Server]
+Release date: 2019-03-11
+Support Version: 2005-2019
+Author: Novosoft
+Free version: Yes
+Price: $39 + + - Automating All Operations + - Native and Generic Database Backup + - Other Server Data Backup + - Saving Snapshots of Virtual Machines + - Using Modern Local and Online Data Storages + - Dealing with OS older than Windows Server 2019 or other + + +## Veeam Explorer for Microsoft SQL Server + +Download page: [Veeam Explorer for Microsoft SQL Server]
+Release date: ?
+Support Version: ?
+Author: Veeam
+Free version: No
+Price: ? + + - Full database and table level recovery + - Perform quick point-in-time restore + - Delegate restore tasks to SQL DBAs + - Part of Veeam Backup & Replication + - Recover one or multiple databases simultaneously from a single-pass image level backup + - Restore entire Microsoft SQL databases down to the table level + - Microsoft SQL log backup provides transaction log replay to restore to a specific point in time + + +## EaseUS Todo Backup Server + +Download page: [EaseUS Todo Backup Server]
+Release date: ?
+Support Version: ?
+Author: EaseUS
+Free version: No
+Price: $39 + + - Add new backup tasks on disk, partition, system, mail and other data + - Select a source system/disk/partition, target a location to store copies and clone fast + - Create a bootable WinPE/Linux bootable USB/DVD/CD to restart the system from it + - Check backup logs, replicate backup issues, and restore data from exact backup files + - P2V copy, P2V recovery, P2V conversion. Clone, restore, and convert backup to the virtual machine + + +## SqlBackupFree + +Download page: [SqlBackupFree]
+Release date: ?
+Support Version: ?
+Author: pranas.net
+Free version: Yes
+Price: No + + - Schedule SQL Server Database Backups. Full backups + - Compress (zip) the backups + - Send backups to FTP, local, network folder or HDD drive + - Send e-mail confirmation on job success or failure + + +## ERDPlus + +Download page: [ERDPlus]
+Release date: ?
+Support Version: ?
+Author: ERDPlus
+Free version: ?
+Price: ? + +A database modeling tool for creating Entity Relationship Diagrams, Relational Schemas, Star Schemas, and SQL DDL statements. + + +## SentryOne Test + +Download page: [SentryOne Test]
+Release date: ?
+Support Version: ?
+Author: SQL Sentry
+Free version: No
+Price: $828 + + - Quickly build tests with wizards + - Simplify unit testing + - Build tests within Visual Studio + - Create custom testing modules + - Reconcile and verify data + - Conduct BI testing + + +## Query Performance Insight for Azure SQL Database + +Download page: [Query Performance Insight for Azure SQL Database]
+Release date: ?
+Support Version: Azure
+Author: Microsoft
+Free version: Yes
+Price: No + + - Deeper insight into your databases resource (DTU) consumption + - Details on top database queries by CPU, duration, and execution count (potential tuning candidates for performance improvements) + - The ability to drill down into details of a query, to view the query text and history of resource utilization + - Annotations that show performance recommendations from database advisors + + +## Code Quality and Security for T-SQL + +Download page: [Code Quality and Security for T-SQL]
+Release date: ?
+Support Version: ?
+Author: SonarSource
+Free version: Yes
+Price: €120 + +SonarSource provides static code analysis for T-SQL projects. Based on our own T-SQL compiler front-end, it uses the most advanced techniques (pattern matching, program flow analysis) to analyze code and find Code Smells, Bugs, and Security Vulnerabilities. As with everything we develop at SonarSource, it was built on the principles of depth, accuracy, and speed. + +## DBBALANCE + +Download page: [DBBALANCE]
+Release date: ?
+Support Version: ?
+Author: DBBalance
+Free version: No
+Price: ? + + - Data and Schema Synchronization + - Data and Schema Comparison + - Database Migration + - Database Development + + +## Convert SQL to Excel + +Download page: [Convert SQL to Excel]
+Release date: 2015-10-09
+Support Version: 2000-2014
+Author: MSSQL.TOOLS
+Free version: Yes
+Price: No + + - Easy way to convert SQL table or a subset of table to Excel. No programming. + - Convert / export a SQL Table to Excel file (.xlsx or .xls format) + - Convert multiple tables (multiple query results) to multiple Excel worksheets. + - Allow flexible TSQL query which can have multiple SELECT statements or other complex query statements. + - Supports command line execution (unattended mode). Useful for periodical scheduling. + - Allow user defined Excel worksheet names. + + +## Search string in Schema + +Download page: [Search string in Schema]
+Release date: 2015-10-09
+Support Version: 2005-2012
+Author: MSSQL.TOOLS
+Free version: Yes
+Price: No + + - This tool searches tables, columns, views, stored procedures, XPs, functions, triggers, constraints and SQL Agent Jobs in a database to find a given string. + - Simply input target server, target database, search keyword and you will get fast search results! + - Supports filterng by object type or schema user + - Supports easy switch between multiple SQL Servers. + - Supports SQL Agent Jobs search. + + +## Search string in SQL + +Download page: [Search string in SQL]
+Release date: 2015-10-09
+Support Version: 2005-2008
+Author: MSSQL.TOOLS
+Free version: Yes
+Price: No + +This tool helps you to search all columns of all tables in a database for a string keyword. In order to increase performance, it examines string type columns only in all tables to search for a given keyword. + + +## SQL Table Scripter + +Download page: [SQL Table Scripter]
+Release date: 2015-10-09
+Support Version: 2005, 2008
+Author: MSSQL.TOOLS
+Free version: Yes
+Price: No + +- Generates a CREATE SQL script for a table. +- Script can include all DRI (declarative referential integrity) such as Foreign Key, Constraints for the table. +- Script can include Indexes for the table. +- Generates INSERT SQL scripts for table data (optionally). + + +## SQLCLR Util + +Download page: [SQLCLR Util]
+Release date: 2015-10-09
+Support Version: 2005-2019r
+Author: MSSQL.TOOLS
+Free version: Yes
+Price: No + +- generates DLL file from SQL CLR assembly in the SQL Server. When creating SQL CLR assembly with its DLL file, SQL Server saves the DLL binary into SQL Server system table. This tool help you to recreate DLL file easily from the SQL Server system table. +- generates CREATE ASSEMBLY script from a DLL file. Once CREATE script is generated, one can run the script without physical .DLL file. This method will be useful when one has no permission to access physical disk on the server because there is no need to copy the file to server. + + +## Image To SQL + +Download page: [Image To SQL]
+Release date: 2015-10-09
+Support Version: 2005,2008 or later
+Author: MSSQL.TOOLS
+Free version: Yes
+Price: No + +- Save any image file such as `.JPG`, `.PNG`, `.BMP`, `.GIF` to SQL Server table. +- Image file is saved to any varbinary column (or image column) +- User can specify input image file and table/column target in easy UI. +- User can specify where to save image file by setting primary key value(s) of the user table in easy UI. + + +## dbdiagram + +Download page: [dbdiagram]
+Release date: ?
+Support Version: ?
+Author: holistics.io
+Free version: Yes
+Price: $9/mo + +A free, simple tool to draw ER diagrams by just writing code. Designed for developers and data analysts. + +- Generate SQL statements +- Export to Images and PDFs +- One Click Sharing +- Integrate with your SQL Databases +- Integrate with Popular Web Frameworks + + +## Beekeeper Studio + +Download page: [Beekeeper Studio]
+Release date: 2020-10-19
+Support Version: 2008-2019
+Author: Beekeeper Studio
+Free version: Yes
+Price: No + +Modern and easy to use SQL client for MySQL, Postgres, SQLite, SQL Server, and more. Linux, MacOS, and Windows. + +- Autocomplete SQL query editor with syntax highlighting +- Tabbed interface, so you can multitask +- Sort and filter table data to find just what you need +- Sensible keyboard-shortcuts +- Save queries for later +- Query run-history, so you can find that one query you got working 3 days ago +- Default dark theme + + +## Babelfish for Aurora PostgreSQL + +Download page: [Babelfish for Aurora PostgreSQL]
+Release date: 2020-12-01
+Support Version: 2008-2019
+Author: Amazon
+Free version: Yes
+Price: No + +Babelfish is a new translation layer for Amazon Aurora PostgreSQL that enables Aurora to understand commands from applications written for Microsoft SQL Server. + + +## DBA Dash + +Download page: [DBA Dash]
+Release date: 2022-01-13
+Support Version: 2005-2019
+Author: Trimble
+Free version: Yes
+Price: No + +DBA Dash is a tool for SQL Server DBAs to assist with daily checks, performance monitoring and change tracking. +- Waits, Running Queries, Performance Counters, CPU, IO, Object Execution, Extended Events, Azure DB +- Configuration, Trace Flags, Hardware, Patching, Schema +- HA/DR, Backups, Last Good DBCC, Drive Space, Agent Jobs, Corruption, Alerts + +## SQLWATCH + +Download page: [SQLWATCH]
+Release date: 2018-09-16
+Support Version: 2008-2019
+Author: Marcin Gminski
+Free version: Yes
+Price: No + +SQLWATCH is an Open Source (MIT License) Real-Time monitoring solution for SQL Server +- Grafana and Power BI Dashboards +- Real Time Alerts and Actions +- Central Repository +- Infinite scalability. SQLWATCH can collect data locally on the local SQL Server or into a central repository. + +[SSMS]:https://docs.microsoft.com/sql/ssms/download-sql-server-management-studio-ssms +[Azure Data Studio]:https://github.com/Microsoft/azuredatastudio +[bcp Utility]:https://docs.microsoft.com/sql/tools/bcp-utility +[sqlcmd Utility]:https://docs.microsoft.com/sql/tools/sqlcmd-utility [mssql-cli]:https://github.com/dbcli/mssql-cli -[SQL OPS Studio]:https://github.com/Microsoft/sqlopsstudio [RML Utilities for SQL Server]:https://www.microsoft.com/en-us/download/details.aspx?id=4511 [GraphView]:https://github.com/Microsoft/GraphView [Baseline Security Analyze]:https://www.microsoft.com/en-us/download/details.aspx?id=7558 @@ -4074,26 +6244,27 @@ No 3rd Party Language, No Packages, Just SQL. [Exchange Server Error Code Look-up]:https://www.microsoft.com/en-us/download/details.aspx?id=985 [LINQPad]:https://www.linqpad.net/ [SqlDynamite]:http://www.host-tracker.com/SqlDynamite -[SQL Server Data Tools]:https://msdn.microsoft.com/en-us/en-en/library/mt204009.aspx +[SQL Server Data Tools]:https://docs.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt [Database Health Monitor]:http://databasehealth.com/download/ [SchemaDrift]:http://databasehealth.com/schemadrift/ -[Dbeaver]:http://dbeaver.jkiss.org/ -[HeidiSQL]:http://www.heidisql.com +[Dbeaver]:https://dbeaver.io +[HeidiSQL]:https://www.heidisql.com [SQLExecStats]:http://www.qdpma.com/ExecStats/SQLExecStats.html [ExpressProfiler]:https://expressprofiler.codeplex.com/ -[Migration Assistant for Sybase]:https://msdn.microsoft.com/en-us/library/hh302795(v=sql.130).aspx -[Data Migration Assistant]:https://blogs.msdn.microsoft.com/datamigration/dma/ -[dta Utility]:https://msdn.microsoft.com/en-us/library/ms162812.aspx -[osql Utility]:https://msdn.microsoft.com/en-us/library/ms162806.aspx -[sqldiag Utility]:https://msdn.microsoft.com/en-us/library/ms162833.aspx -[sqldumper Utility]:https://support.microsoft.com/en-us/kb/917825 -[SqlLocalDB Utility]:https://msdn.microsoft.com/en-us/library/hh212961.aspx -[sqllogship Utility]:https://msdn.microsoft.com/en-us/library/bb283327.aspx -[sqlservr Application]:https://msdn.microsoft.com/en-us/library/ms162819.aspx -[sqlps Utility]: https://msdn.microsoft.com/en-us/library/cc280450.aspx -[sqlmaint Utility]: https://msdn.microsoft.com/en-us/library/ms162827.aspx -[Ssms Utility]: https://msdn.microsoft.com/en-us/library/ms162825.aspx -[dtexec Utility]: https://msdn.microsoft.com/en-us/library/hh231187.aspx +[Migration Assistant for Sybase]:https://docs.microsoft.com/en-us/sql/ssma/sybase/sql-server-migration-assistant-for-sybase-sybasetosql +[Data Migration Assistant]:https://docs.microsoft.com/en-us/sql/dma/dma-overview +[dta Utility]:https://docs.microsoft.com/en-us/sql/tools/dta/dta-utility +[osql Utility]:https://docs.microsoft.com/en-us/sql/tools/osql-utility +[sqldiag Utility]:https://docs.microsoft.com/en-us/sql/tools/sqldiag-utility +[sqldumper Utility]:https://docs.microsoft.com/en-us/troubleshoot/sql/tools/use-sqldumper-generate-dump-file +[SqlLocalDB Utility]:https://docs.microsoft.com/en-us/sql/tools/sqllocaldb-utility +[sqllogship Utility]:https://docs.microsoft.com/en-us/sql/tools/sqllogship-application +[sqlservr Application]:https://docs.microsoft.com/en-us/sql/tools/sqlservr-application +[sqlps Utility]:https://docs.microsoft.com/en-us/sql/tools/sqlps-utility +[sqlmaint Utility]:https://docs.microsoft.com/en-us/sql/tools/sqlmaint-utility +[SSMS Utility]:https://docs.microsoft.com/en-us/sql/ssms/ssms-utility +[dtexec Utility]:https://docs.microsoft.com/en-us/sql/integration-services/packages/dtexec-utility +[adutil Utility]:https://docs.microsoft.com/sql/linux/sql-server-linux-ad-auth-adutil-tutorial [SQL Server 2016 Report Builder]:https://www.microsoft.com/en-us/download/details.aspx?id=53613 [DLM Dashboard]:http://www.red-gate.com/products/dlm/dlm-dashboard/ [Red Gate SQL Compare]:http://www.red-gate.com/products/sql-development/sql-compare/ @@ -4108,6 +6279,8 @@ No 3rd Party Language, No Packages, Just SQL. [Red Gate SQL Index Manager]:http://www.red-gate.com/products/dba/sql-index-manager/ [Red Gate SQL Comparison SDK]:http://www.red-gate.com/products/sql-development/sql-comparison-sdk/ [Red Gate SQL Clone]:http://www.red-gate.com/products/dba/sql-clone/ +[Red Gate SQL Provision]:https://www.red-gate.com/products/dba/sql-provision/ +[Red Gate SQL Data Masker]: https://www.red-gate.com/products/dba/data-masker [DLM Automation]:http://www.red-gate.com/products/dlm/dlm-automation/ [ReadyRoll]:http://www.red-gate.com/products/sql-development/readyroll/ [Rapid Database Extractor]:https://www.idera.com/productssolutions/freetools/rapid-database-extractor @@ -4145,6 +6318,7 @@ No 3rd Party Language, No Packages, Just SQL. [SQL Comparison Toolset]:https://www.idera.com/productssolutions/sqlserver/sqlcomparisontoolset [ER/Studio Data Architect]:https://www.idera.com/er-studio-data-architect-software [DB Change Manager]:https://www.idera.com/database-change-management +[SQL Data Profiler]:https://www.idera.com/productssolutions/freetools/sql-data-profiler [dbForge Schema Compare]: https://www.devart.com/dbforge/sql/schemacompare/ [dbForge Data Compare]: https://www.devart.com/dbforge/sql/datacompare/ [dbForge Data Generator]: https://www.devart.com/dbforge/sql/data-generator/ @@ -4154,24 +6328,23 @@ No 3rd Party Language, No Packages, Just SQL. [dbForge Studio]:https://www.devart.com/dbforge/sql/studio/ [dbForge Fusion]:https://www.devart.com/dbforge/sql/fusion/ [dbForge Documenter]:https://www.devart.com/dbforge/sql/documenter/ -[dbForge Developer Bundle]:https://www.devart.com/dbforge/sql/developer-bundle/ -[dbForge Compare Bundle for SQL Server]:https://www.devart.com/dbforge/sql/compare-bundle/ +[dbForge SSIS Data Flow Components]:https://www.devart.com/ssis/ +[dbForge DevOps Automation for SQL Server]:https://www.devart.com/dbforge/sql/database-devops/ [Devart Excel Add-in for SQL Server]:https://www.devart.com/excel-addins/sql-server.html [dbMonitor]:https://www.devart.com/dbmonitor/download.html [BPA 2005]: https://www.microsoft.com/en-us/download/details.aspx?id=23864 [BPA 2000]: https://www.microsoft.com/en-us/download/details.aspx?id=15691 [BPA 2008]: https://www.microsoft.com/en-us/download/details.aspx?id=15289 [BPA 2012]: https://www.microsoft.com/en-us/download/details.aspx?id=29302 -[Minion Enterprise]:http://minionware.net/enterprise/ [SQL Server Compression Estimator]:http://ssce.codeplex.com [ClearTrace]:http://www.scalesql.com/cleartrace/download.html -[Dell Security Explorer]:http://software.dell.com/products/security-explorer/ -[Dell LiteSpeed for SQL Server]:http://software.dell.com/products/litespeed-for-sql-server/ -[Dell Toad for SQL Server]:http://software.dell.com/products/toad-for-sql-server/ -[Dell Spotlight]:http://software.dell.com/products/spotlight-on-sql-server-enterprise/ -[Dell Foglight]:http://software.dell.com/products/foglight-for-cross-platform-databases/ -[Dell Discovery Wizard]:http://software.dell.com/products/discovery-wizard-for-sql-server/ -[Dell Enterprise Reporter]:http://software.dell.com/products/enterprise-reporter-for-sql-server/ +[ClearTraceXE]:http://www.scalesql.com/cleartrace/download.html +[Security Explorer]:https://www.quest.com/products/security-explorer/ +[LiteSpeed for SQL Server]:https://www.quest.com/products/litespeed-for-sql-server/ +[Toad for SQL Server]:https://www.quest.com/products/toad-for-sql-server/ +[Quest Spotlight]:https://www.quest.com/products/spotlight-on-sql-server-enterprise/ +[Quest Foglight]:https://www.quest.com/products/foglight-for-cross-platform-databases/ +[Quest Enterprise Reporter]:https://www.quest.com/enterprise-reporter/ [SQL Scripter]:http://www.sqlscripter.com/ [Simple Dynamic Scheduler]:http://www.codeproject.com/Articles/1096104/Simple-Dynamic-Scheduler [ApexSQL Audit]:http://www.apexsql.com/sql_tools_audit.aspx @@ -4192,6 +6365,17 @@ No 3rd Party Language, No Packages, Just SQL. [ApexSQL Trigger]:https://www.apexsql.com/sql_tools_trigger.aspx [ApexSQL Trigger Viewer]:https://www.apexsql.com/Download.aspx?download=Search [ApexSQL Snapshot Utility]:https://www.apexsql.com/Download.aspx?download=Search +[ApexSQL Decrypt]:https://www.apexsql.com/sql_tools_decrypt.aspx +[ApexSQL Model]:https://www.apexsql.com/sql_tools_model.aspx +[ApexSQL Analyze]:https://www.apexsql.com/sql_tools_analyze.aspx +[ApexSQL BI Monitor]:https://www.apexsql.com/sql_tools_bi_monitor.aspx +[ApexSQL VM Monitor]:https://www.apexsql.com/sql_tools_vm_monitor.aspx +[ApexSQL Job]:https://www.apexsql.com/sql_tools_job.aspx +[ApexSQL Enforce]:https://www.apexsql.com/sql_tools_enforce.aspx +[ApexSQL CI/CD toolkit]:https://www.apexsql.com/sql-tools-devops.aspx +[ApexSQL Compare]:https://www.apexsql.com/sql-tools-compare.aspx +[ApexSQL Complete]:https://www.apexsql.com/sql-tools-complete.aspx +[ApexSQL Refactor]:https://www.apexsql.com/sql-tools-refactor.aspx [DBBest T-SQL Analyzer]:https://www.dbbest.com/products/t-sql-analyzer [DBBest Database Compare Suite]:https://www.dbbest.com/products/database-compare-suite/ [Advanced Query Tool]:http://www.querytool.com/ @@ -4225,7 +6409,8 @@ No 3rd Party Language, No Packages, Just SQL. [EMS Data Comparer]:http://www.sqlmanager.net/en/products/mssql/datacomparer [NitroAccelerator]:http://nitrosphere.com/nitroaccelerator/ [ERwin Data Modeler]:http://erwin.com/products/data-modeler -[Toad Data Modeler]:https://software.dell.com/products/toad-data-modeler/ +[Luna Modeler]:https://www.datensen.com/luna-modeler-for-relational-databases.html +[Toad Data Point]:https://www.quest.com/products/toad-data-point/ [SQL Power Architect]:http://www.sqlpower.ca/page/architect [DbWrench]:http://www.dbwrench.com/ [Navicat Data Modeler]:https://www.navicat.com/products/navicat-data-modeler @@ -4240,7 +6425,7 @@ No 3rd Party Language, No Packages, Just SQL. [Database .NET]:http://fishcodelib.com/Database.htm [dbMigration .NET]:http://fishcodelib.com/dbMigration.htm [Is It SQL]:http://www.scalesql.com/isitsql -[Database Experimentation Assistant]:https://blogs.msdn.microsoft.com/datamigration/2017/03/24/dea-2-0-release-overview-database-experimentation-assistant +[Database Experimentation Assistant]:https://www.microsoft.com/en-us/download/details.aspx?id=54090 [Data Platform Studio]:http://www.red-gate.com/products/azure-development/data-platform-studio [Flyway]:https://flywaydb.org [Liquibase]:http://www.liquibase.org @@ -4260,8 +6445,9 @@ No 3rd Party Language, No Packages, Just SQL. [Cloud-based DB Monitoring Platform]:https://www.sqltreeo.com [SchemaCrawler]:http://sualeh.github.io/SchemaCrawler/index.html [SA MaaS Microsoft SQL Server]:http://sentinelagent.com/maas/microsoft-sql-server -[CatCompare v2]:https://dilmsuite.com/downloads/cat-compare-v2 -[SSIS Catalog Compare v2.0 Bundle]:https://dilmsuite.com/downloads/ssis-catalog-compare-v2-bundle +[SSIS Framework]:https://dilmsuite.com/ssis-framework-editions/ +[SSIS Catalog Browser]:https://dilmsuite.com/product/catalog-browser/ +[BimlExpress Metadata Framework]:https://dilmsuite.com/product/biml-express-metadata-framework/ [MS Kerberos Configuration Manager]:https://www.microsoft.com/en-us/download/details.aspx?id=39046 [Spotlight]:https://www.spotlightessentials.com/home/Console [DBConvert Studio]:https://dbconvert.com/dbconvert-studio @@ -4288,7 +6474,7 @@ No 3rd Party Language, No Packages, Just SQL. [SQL Server Migration Assistant for Oracle]:https://www.microsoft.com/en-us/download/details.aspx?id=54258 [SQL Server Migration Assistant for Access]:https://www.microsoft.com/en-us/download/details.aspx?id=54255 [mssql for Visual Studio Code]:https://github.com/Microsoft/vscode-mssql -[Microsoft Assessment and Planning]:https://www.sqlshack.com/how-to-use-microsoft-assessment-and-planning-map-toolkit-for-sql-server +[Microsoft Assessment and Planning (MAP) Toolkit]:https://www.sqlshack.com/how-to-use-microsoft-assessment-and-planning-map-toolkit-for-sql-server [mssql-scripter]:https://github.com/Microsoft/sql-xplat-cli [DBFS]:https://github.com/Microsoft/dbfs [comparator]:https://github.com/Pumpet/comparator @@ -4299,9 +6485,9 @@ No 3rd Party Language, No Packages, Just SQL. [DBGhost]:http://www.dbghost.com [SQLAutomate]:http://www.sqlautomate.com [BimlExpress]:https://www.varigence.com/BimlExpress -[BIDS Helper]:https://bidshelper.codeplex.com +[BI Developer Extensions]:https://bideveloperextensions.github.io [Azure Data Warehouse Migration Utility]:https://docs.microsoft.com/en-us/azure/sql-data-warehouse/sql-data-warehouse-migrate-migration-utility -[Dell Benchmark Factory]:https://www.quest.com/products/benchmark-factory +[Benchmark Factory]:https://www.quest.com/products/benchmark-factory [manduka]:http://www.manduka.tech/#/home [PowerBI Desktop]:https://powerbi.microsoft.com/en-us/desktop/ [Stellar Phoenix SQL Database Repair]:https://www.stellarinfo.com/sql-recovery.php @@ -4319,6 +6505,130 @@ No 3rd Party Language, No Packages, Just SQL. [Azure Database Migration Service]:https://azure.microsoft.com/en-us/services/database-migration/ [FlowHeater]:https://flowheater.net/en [EDIS]:https://sqletl.com +[SchemaSpy]:https://github.com/schemaspy/schemaspy +[Adminer]:https://www.adminer.org/ +[Full Convert]:https://www.spectralcore.com/fullconvert +[Replicator]:https://www.spectralcore.com/replicator +[JackDB]:https://www.jackdb.com/ +[SQL Workbench]:http://www.sql-workbench.eu/ +[Valentina Studio]:https://www.valentina-db.com +[SQL Plus Dot Net]:https://sqlplusweb.azurewebsites.net +[SQLIndexManager]:https://github.com/sergeysyrovatchenko/SQLIndexManager +[JAMS Enterprise Job Scheduling]:https://info.jamsscheduler.com/jams-sql-wla-rethink +[Stitch Data Loader]:https://www.talend.com/products/data-loader/ +[Talend Data Integration]:https://www.talend.com/products/data-integration/ +[Talend Data Preparation]:https://www.talend.com/products/data-preparation/ +[Pentaho Data Integration]:https://www.hitachivantara.com/en-us/products/data-management-analytics/pentaho-data-integration.html +[Studio3T]:https://studio3t.com/ +[SQLGrease]:https://sqlgrease.com +[QuickDBD]:https://www.quickdatabasediagrams.com/ +[DB Designer]:https://www.dbdesigner.net +[ESF Database Migration Toolkit]:https://www.dbsofts.com/ +[MS SQL Migration Toolkit]:https://www.convert-in.com/msskit.htm +[DatabaseSpy]:https://www.altova.com/databasespy +[DiffDog]:https://www.altova.com/diffdog +[ERBuilder data modeler]:https://soft-builder.com/ +[SQLDatabaseStudio]:https://www.sqldatabasestudio.com/ +[Enterprise Architect]:https://sparxsystems.com/products/ea/index.html +[MogwaiERDesignerNG]:https://github.com/mirkosertic/MogwaiERDesignerNG +[Xcase]:https://www.xcase.com/ +[Oracle SQL Developer Data Modeler ]:https://www.oracle.com/database/technologies/appdev/datamodeler.html +[Exportizer]:https://www.vlsoftware.net/exportizer/ +[Reportizer]:https://www.reportizer.net/ +[Database Tour]:https://www.databasetour.net/ +[Ispirer MnMATK]:https://www.ispirer.com/download/download-sqlways-assessment +[SQL Database Recovery]:https://www.nucleustechnologies.com/sql-recovery.html +[SysTools SQL Log Analyzer]:https://www.systoolsgroup.com/sql-log-analyzer.html +[SysTools SQL Server Recovery Manager]:https://www.systoolsgroup.com/sql-server-recovery-manager.html +[SysTools SQL Recovery]:https://www.systoolsgroup.com/sql-recovery.html +[SQL Backup Recovery]:https://www.systoolsgroup.com/sql-backup-recovery.html +[SysTools SQL Password Recovery]:https://www.systoolsgroup.com/sql-password-recovery.html +[SysTools SQL Decryptor]:https://www.systoolsgroup.com/sql-decryptor.html +[SysTools SQL Server Database Migrator]:https://www.systoolsgroup.com/sql-server/migration/ +[SQL Server to Azure Database Migrator]:https://www.systoolsgroup.com/sql-server/azure/ +[Commvault Complete Backup & Recovery]:https://www.commvault.com/complete-backup +[Veeam Backup & Replication]:https://www.veeam.com/ru/vm-backup-recovery-replication-software.html +[Database Modeling Excel]:https://github.com/snyang/Database-Modeling-Excel +[DBAchecks]:https://github.com/sqlcollaborative/dbachecks +[DBComparer]:https://dbcomparer.com/default.aspx +[DbViewSharp]:https://www.softpedia.com/get/Internet/Servers/Database-Utils/DbViewSharp.shtml +[DTSQL]:http://www.dtsql.com/database_tools.htm +[MSKerberos Configuration Manager]:https://www.microsoft.com/en-us/download/details.aspx?id=39046 +[Partition Management]:https://archive.codeplex.com/?p=sqlpartitionmgmt +[Powershell Scripts]:https://www.idera.com/productssolutions/freetools/sqlpowershellscripts +[PSDatabaseClone]:https://psdatabaseclone.org/# +[Pssdiag&Sqldiag Manager]:https://github.com/microsoft/DiagManager/releases +[SQuirreL SQL Client]:http://squirrelsql.org +[Data Synchronisation Studio]:https://www.simego.com/solutions/sql +[SQL Converter]:https://sourceforge.net/projects/sql-converter +[SQLDBSearch]:https://www.sqldbtools.com/tools/sqldbsearch +[SQLDBSize]:https://www.sqldbtools.com/tools/sqldbsize +[SQLines Data]:http://www.sqlines.com/sqldata +[SqlDbAid]:http://sqlapproach.blogspot.com/2010/06/sqldbaid.html +[sqlectron]:https://sqlectron.github.io +[SQL ExecStats]:http://www.qdpma.com/execstats/sqlexecstats.html +[SQL-FineBuild]:https://github.com/SQL-FineBuild/v3.4 +[SQL Health Monitor]:https://www.manageengine.com/sql-performance-monitor/sql-server-monitoring-index.html +[SQL Instance Check]:https://www.idera.com/productssolutions/freetools +[SQLPRep]:https://www.csqls.com/products +[SQL Server Migration Assistant for SAP ASE]:https://www.microsoft.com/en-us/download/details.aspx?id=54256 +[SQL Server Backup]:https://ola.hallengren.com/sql-server-backup.html +[SQL Server Integrity Check]:https://ola.hallengren.com/sql-server-integrity-check.html +[SQL Server Monitoring]:https://www.spiceworks.com/free-sql-server-monitoring-tool +[SQL Server Storage manager]:https://www.lepide.com/sql-storage-manager +[SysKit Pulse]:https://www.syskit.com/products/insights-lite +[WhatsUp SQL Server Monitor]:https://www.ipswitch.com/resources/free-tools/whatsup-sql-server-monitor +[POPSQL]:https://popsql.com/ +[ApexSQL Search]:https://www.apexsql.com/sql-tools-search.aspx +[ApexSQL Source Control]:https://www.apexsql.com/sql-tools-source-control.aspx +[Azure Blob Studio 2011]:https://marketplace.visualstudio.com/items?itemName=AlessandroDelSoleMVP.AzureBlobStudio2011 +[Azure Explorer]:https://monzacloud.com/azure-cloud-explorer +[Azure SQL Agent]:https://www.npmjs.com/package/azure-sql-agent +[Azure SQL Database DTU Calculator]:https://dtucalculator.azurewebsites.net +[Azure SQL Database Stress Test Tool]:https://github.com/kiyoaki/AzurePerformanceTesting +[Azure SQL Dev Cloner]:https://github.com/cleanchoice/azure-sql-dev-cloner +[Azure User Management Console]:https://www.openhub.net/p/aumc +[CloudMonix SQL Azure Database Management]:https://cloudmonix.com/features/azure-management/sql-azure-database-monitoring +[DB Ghost Change Manager Professional]:http://www.dbghost.com/products/ChangeManager.aspx +[dbForge Complete]:https://www.devart.com/dbforge/sql/sqlcomplete +[dbForge SQL Azure Backup]:https://www.devart.com/dbforge/sql/sqlazurebackup +[Devart Transaction Log]:https://www.devart.com/dbforge/sql/transaction-log/ +[Elastic database tools]:https://docs.microsoft.com/en-us/azure/azure-sql/database/elastic-scale-get-started +[Microsoft Sync Framework]:https://www.microsoft.com/en-us/download/details.aspx?id=23217 +[MSSQL-Maestro]:https://www.sqlmaestro.com/products/mssql/maestro/about +[MSSQLMerge]:https://db-merge-tools.net/microsoft-sql-server-diff-merge-overview.html +[SQL Backup and FTP]:https://sqlbackupandftp.com +[SQL Bak]:https://sqlbak.com +[SQL Bulk Tools]:https://github.com/olegil/SqlBulkTools +[SQL Data Examiner]:https://www.sqlaccessories.com/sql-data-examiner +[SQL Examiner]:https://www.sqlaccessories.com/sql-examiner +[SQL Database Backup]:https://github.com/richorama/SQLDatabaseBackup +[SQL Database Copy]:https://github.com/ryanovic/SqlDatabaseCopy +[SQL Delta Duo for SQL Server]:https://sqldelta.com/products +[SQL Trace Replay]:https://github.com/mikhailshilkov/sql-trace-replay +[SQL Backup Master]:https://www.sqlbackupmaster.com +[Handy Backup Server]:https://www.handybackup.net/handybackup-server.shtml +[Veeam Explorer for Microsoft SQL Server]:https://www.veeam.com/microsoft-sql-server-explorer.html +[EaseUS Todo Backup Server]:https://www.easeus.com/backup-software/tb-enterprise.html +[SqlBackupFree]:http://sqlbackupfree.com +[ERDPlus]:https://erdplus.com +[SentryOne Test]:https://www.sentryone.com/products/sentryone-test +[Query Performance Insight for Azure SQL Database]:https://docs.microsoft.com/en-us/azure/azure-sql/database/query-performance-insight-use +[Code Quality and Security for T-SQL]:https://www.sonarsource.com/tsql +[DBBALANCE]:http://www.dbbalance.com +[Convert SQL to Excel]:http://mssql.tools/sql/Convert-SQL-to-Excel +[Search string in Schema]:http://mssql.tools/sql/Search-string-in-Schema +[Search string in SQL]:http://mssql.tools/sql/Search-string-in-SQL +[SQL Table Scripter]:http://mssql.tools/sql/SQL-Table-Scripter +[SQLCLR Util]:http://mssql.tools/sql/SQLCLR-Util +[Image To SQL]:http://mssql.tools/sql/Image-To-SQL +[dbdiagram]:https://dbdiagram.io/home +[Beekeeper Studio]:https://github.com/beekeeper-studio/beekeeper-studio +[Babelfish for Aurora PostgreSQL]:https://aws.amazon.com/rds/aurora/babelfish/ +[DBA Dash]:https://github.com/trimble-oss/dba-dash +[SQLWATCH]:https://sqlwatch.io [LGPL-3.0]:http://www.gnu.org/licenses/lgpl-3.0.txt [MIT]:https://opensource.org/licenses/MIT +[Apache]:http://www.apache.org/licenses/ +[BSD-3]:https://opensource.org/licenses/BSD-3-Clause diff --git a/Utilities/SSMS_Alternatives.md b/Utilities/SSMS_Alternatives.md new file mode 100644 index 00000000..6e5e99c8 --- /dev/null +++ b/Utilities/SSMS_Alternatives.md @@ -0,0 +1,57 @@ +# Microsoft SQL Server Management Studio Alternatives +Best free and paid SSMS alternatives - complete list of **23** SQL Server Utilities + + +| Name | Cross Database | Platform | Official/Download page | Release | Author | License | Free version | Price | +|------------------------------|-------------------------------|-----------|--------------------------------|------------|-----------------------|------------|----------------|------:| +| SSMS | No | No | [SSMS] | 2018-05-09 | Microsoft | | Yes | No | +| SQL OPS Studio | No | Linux,Mac | [SQL OPS Studio] | 2017-11-15 | Microsoft | | Yes | No | +| Log Parser Lizard GUI | Oracle,MySQL,PostgreSQL,Other | No | [Log Parser Lizard GUI] | 2017-06-01 | Lizard Labs | | Yes | $59 | +| SQL Server Data Tools | No | No | [SQL Server Data Tools] | 2018-04-10 | Microsoft | | Yes | No | +| Dbeaver | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [Dbeaver] | 2018-05-13 | Open Source | | Yes | No | +| HeidiSQL | Oracle,MySQL,PostgreSQL,Other | No | [HeidiSQL] | 2017-12-19 | Open Source | | Yes | No | +| Red Gate SQL Prompt | No | No | [Red Gate SQL Prompt] | 2016-04-28 | Red Gate | | No | $369 | +| Rapid SQL | Oracle,MySQL,PostgreSQL,Other | No | [Rapid SQL] | ? | Idera | | No | $710 | +| dbForge Studio | No | No | [dbForge Studio] | 2017-03-12 | Devart | Shareware | Yes | $250 | +| Dell Toad for SQL Serve | No | No | [Dell Toad for SQL Server] | 2015-05-12 | Dell | | No | ? | +| DataGrip | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [DataGrip] | 2017-02-21 | Jet Brains | | No | $89 | +| SQL Enlight | No | No | [SQL Enlight] | 2016-04-25 | UbitSoft | | No | $295 | +| SoftTree SQL Assistant | Oracle,MySQL,PostgreSQL,Other | No | [SoftTree SQL Assistant] | 2017-12-17 | SoftTree | | No | $215 | +| EMS SQL Management Studio | No | No | [EMS SQL Management Studio] | 2016-05-26 | EMS | | No | $257 | +| Aqua Data Studio | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [Aqua Data Studio] | 2016-07-06 | AquaFold | | No | $499 | +| RazorSQL | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [RazorSQL] | 2016-09-29 | Richardson Software | | No | $100 | +| Database .NET | Oracle,MySQL,PostgreSQL,Other | No | [Database .NET] | 2017-01-13 | fish's dotNET | | Non-commercial | $69 | +| SqlPad | Postgres,MySQL,Crate,Vertica | No | [SqlPad] | ? | Rickbergfalk | | Open Source | No | +| mssql for Visual Studio Code | No | Linux,Mac | [mssql for Visual Studio Code] | 2017-05-02 | Microsoft | | Open Source | No | +| Navicat for SQL Server | No | Mac | [Navicat for SQL Server] | 2017-06-14 | PremiumSoft | | No | $699 | +| Navicat Premium | Oracle,MySQL,PostgreSQL,Other | Mac | [Navicat Premium] | 2017-06-14 | PremiumSoft | | No | $1299 | +| DbVisualizer | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [DbVisualizer] | 2017-11-16 | DbVis Software AB. | | Yes | $197 | +| Adminer | Oracle,MySQL,PostgreSQL,Other | Linux,Mac | [Adminer] | 2018-02-20 | Jakub Vrána | [Apache] | Open Source | No | + +[SSMS]:https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms +[SQL OPS Studio]:https://github.com/Microsoft/sqlopsstudio +[Log Parser Lizard GUI]:http://lizard-labs.com/log_parser_lizard.aspx +[SQL Server Data Tools]:https://docs.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt +[Dbeaver]:http://dbeaver.jkiss.org/ +[HeidiSQL]:http://www.heidisql.com +[Red Gate SQL Prompt]:http://www.red-gate.com/products/sql-development/sql-prompt/ +[Rapid SQL]:https://www.idera.com/rapid-sql-ide/overview +[dbForge Studio]:https://www.devart.com/dbforge/sql/studio/ +[Dell Toad for SQL Server]:http://software.dell.com/products/toad-for-sql-server/ +[DataGrip]:https://www.jetbrains.com/datagrip/ +[SQL Enlight]:http://www.ubitsoft.com/products/sqlenlight/index.php +[SoftTree SQL Assistant]:https://www.softtreetech.com/sqlassist/ +[EMS SQL Management Studio]:http://www.sqlmanager.net/en/products/studio/mssql +[Aqua Data Studio]:http://www.aquafold.com/aquadatastudio.html +[RazorSQL]:https://www.razorsql.com/ +[Database .NET]:http://fishcodelib.com/Database.htm +[SqlPad]:https://github.com/rickbergfalk/sqlpad +[mssql for Visual Studio Code]:https://github.com/Microsoft/vscode-mssql +[Navicat for SQL Server]:https://www.navicat.com/en/products/navicat-for-sqlserver +[Navicat Premium]:https://www.navicat.com/en/products/navicat-premium +[DbVisualizer]:http://www.dbvis.com/ +[Adminer]:https://www.adminer.org/ + +[LGPL-3.0]:http://www.gnu.org/licenses/lgpl-3.0.txt +[MIT]:https://opensource.org/licenses/MIT +[Apache]:http://www.apache.org/licenses/