├── .vscode └── settings.json ├── CreateNewSQL1.ps1 ├── CreateSQLonAzureVM.ps1 ├── README.md ├── SQL Operations and Support ├── Chapter 1 Getting Started │ ├── Media │ │ ├── CH-1Runwith.jpg │ │ ├── CH1-ADS.png │ │ ├── CH1-ADS2.jpg │ │ ├── CH1-Azure.png │ │ ├── CH1-ConnectSQL.jpg │ │ ├── CH1-Explain.jpg │ │ ├── CH1-Logo-sql.png │ │ ├── CH1-Plan.jpg │ │ ├── CH1-WelcomeScreen.jpg │ │ └── Ch1-Operations.jpg │ ├── STRT-Introduction.ipynb │ ├── STRT-QueryExecutions.ipynb │ └── readme.md ├── Chapter 10 Azure SQL Managed Instance │ ├── ASMI-Getting Started with Azure SQL Managed Instance.ipynb │ └── readme.md ├── Chapter 11 High Availbility │ ├── SSHA-Getting Started with High Availbility.ipynb │ └── readme.md ├── Chapter 2 Using Extension Packs │ ├── Media │ │ ├── CH2-ADS.png │ │ ├── CH2-Extensions.jpg │ │ ├── CH2-FirstResponder.jpg │ │ ├── CH2-InstallExtension.jpg │ │ ├── CH2-MissingModules.jpg │ │ ├── CH2-NewQuery.jpg │ │ ├── CH2-Run.jpg │ │ ├── CH2-SlowQueryWidget.jpg │ │ ├── CH2-ViewPalette.jpg │ │ ├── CH2-dashboard.jpg │ │ ├── CH2-filters.jpg │ │ ├── CH2-icon.jpg │ │ ├── CH2-preferences.jpg │ │ └── CH2-widgets.png │ ├── PACK-FirstResponderKit.ipynb │ ├── PACK-UsingExtensionPacks.ipynb │ ├── PACK-UsingWidgets.ipynb │ └── readme.md ├── Chapter 3 General Information │ ├── GEN-GatherInformation.ipynb │ ├── GEN-GetBPConsumers.ipynb │ ├── GEN-GetBufferPool.ipynb │ ├── GEN-GetCPULast2Hours.ipynb │ ├── GEN-GetDBGrowth.ipynb │ ├── GEN-GetDBInfo.ipynb │ ├── GEN-GetDBTriggers.ipynb │ ├── GEN-GetDiskSpace.ipynb │ ├── GEN-GetFeatureUsage.ipynb │ ├── GEN-GetHAInfo.ipynb │ ├── GEN-GetInstanceInfo.ipynb │ ├── GEN-GetLPIM.ipynb │ ├── GEN-GetLinkedServers.ipynb │ ├── GEN-GetLogonTriggers.ipynb │ ├── GEN-GetLowMemoryEvents.ipynb │ ├── GEN-GetMAXDOP.ipynb │ ├── GEN-GetMemoryAlloc.ipynb │ ├── GEN-GetOSVersion.ipynb │ ├── GEN-GetProcNUMA.ipynb │ ├── GEN-GetRecentBackups.ipynb │ ├── GEN-GetResourceGov.ipynb │ ├── GEN-GetServerMemory.ipynb │ ├── GEN-GetSockets.ipynb │ ├── GEN-GetSystemConfig.ipynb │ ├── GEN-GetUptime.ipynb │ ├── GEN-PreReqs.ipynb │ ├── Media │ │ └── CH3-ADS.png │ └── readme.md ├── Chapter 4 Diagnostics │ ├── DIAG-Database.ipynb │ ├── DIAG-HighAvailability.ipynb │ ├── DIAG-Indexes.ipynb │ ├── DIAG-Instance.ipynb │ ├── DIAG-Memory.ipynb │ ├── DIAG-SQLAgent.ipynb │ ├── DIAG-Server.ipynb │ ├── DIAG-StoredProcedures.ipynb │ ├── Media │ │ └── CH4-ADS.png │ └── readme.md ├── Chapter 5 Database Corruptions │ ├── CRPN-About-Corruptions.ipynb │ ├── CRPN-ConsistencyChecks.ipynb │ ├── CRPN-DBCC-CHECKDB-Internals.ipynb │ ├── CRPN-DBCC-CHECKDB.ipynb │ ├── CRPN-Interpreting-CHECKDB-Output.ipynb │ ├── CRPN-Simple-Repair-Techniques.ipynb │ ├── CRPN-Simple-Restore-Techniques.ipynb │ ├── CRPN-Torn-Page.ipynb │ ├── CRPN-Undocumented-DBCC-Commands.ipynb │ ├── Chapter 5B Database Corruptions Advanced.md │ ├── Media │ │ ├── CH5-ADS.png │ │ ├── CH5-Backup-Sequence.jpg │ │ ├── CH5-DBCC-IND.jpg │ │ ├── CH5-Delete-MDF.jpg │ │ ├── CH5-Diff-3.jpg │ │ ├── CH5-FactProcessing.jpg │ │ ├── CH5-FactProcessing2.jpg │ │ ├── CH5-Offline.jpg │ │ ├── CH5-Page-IND.jpg │ │ ├── CH5-Parallelism.jpg │ │ ├── CH5-Recovery-Pending.jpg │ │ ├── CH5-STOPAT-Miss.jpg │ │ ├── CH5-Standby-Update-Error.jpg │ │ ├── CH5-Standby.jpg │ │ └── CH5-TornPage.jpg │ └── readme.md ├── Chapter 6 Maintenance Routines │ ├── MAINT-CapacityPlanning.ipynb │ ├── MAINT-DailyTasks.ipynb │ ├── MAINT-Database-Maintenance-Tips.ipynb │ ├── MAINT-Dedicated-Administrators-Connection.ipynb │ ├── MAINT-Interpreting-Performance-Counters.ipynb │ ├── MAINT-Ports-and-Protocols.ipynb │ ├── MAINT-RoutineSQLMaintenance.ipynb │ ├── MAINT-Working-With-TempDB.ipynb │ ├── Media │ │ ├── CH6-ADS.png │ │ ├── CH6-AdminConnect.jpg │ │ ├── CH6-CMDConnect.jpg │ │ ├── CH6-CPUNum.jpg │ │ ├── CH6-Error.jpg │ │ ├── CH6-ExecutionLog.jpg │ │ ├── CH6-FixedLength.jpg │ │ ├── CH6-LogSpace.jpg │ │ ├── CH6-NewAdminQuery.jpg │ │ └── CH6-VariableLength.jpg │ └── readme.md ├── Chapter 7 Troubleshooting │ ├── TRBL-TShooting_LogFull.ipynb │ ├── Test.ipynb │ └── readme.md ├── Chapter 8 SQL Server on Azure VM │ ├── Media │ │ ├── CH8-ADS.png │ │ ├── CH8-AddNewPackage.jpg │ │ ├── CH8-AzureAccount.jpg │ │ ├── CH8-Basics.jpg │ │ ├── CH8-ChooseImage.jpg │ │ ├── CH8-DNSlabel.jpg │ │ ├── CH8-DeploymentChoices.jpg │ │ ├── CH8-Ecosystem.jpg │ │ ├── CH8-Gallery.jpg │ │ ├── CH8-ManagePackage.jpg │ │ ├── CH8-RayOzzie.jpg │ │ ├── CH8-Results.jpg │ │ ├── CH8-Review.jpg │ │ ├── CH8-SSMS.jpg │ │ └── CH8-Timeline.jpg │ ├── SSOA-Deploy-Azure-SQL-VM-From-Portal.ipynb │ ├── SSOA-Deploy-Azure-SQL-VM-From-PowerShell.ipynb │ ├── SSOA-SQL-Server-Iaas-Extension.ipynb │ ├── SSOA-The-History-of-Azure-SQL.ipynb │ └── readme.md ├── Chapter 9 Azure SQL Database │ ├── ASDB-Getting Started with Azure SQL Database.ipynb │ └── readme.md ├── CreateNewSQL2.ps1 ├── _config.yml └── _toc.yml └── debug.log /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "markdownlint.config": { 3 | "MD028": false, 4 | "MD025": { 5 | "front_matter_title": "" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /CreateNewSQL1.ps1: -------------------------------------------------------------------------------- 1 | # Make Initial Connection. Azure Commercial by defultt 2 | # If connecting to Azure Gov, it must be specified. 3 | Connect-AzAccount -EnvironmentName AzureUSGovernment 4 | 5 | #Get a list of your subscriptions. If you have more than one, the particular target subscription needs to be set. 6 | #Get-AzSubscription 7 | 8 | # If you forget to set the scope (or context) of the Azure PowerSell Az commands to the correct Azure Subscription, then you may end up provisioning or deleting resources in the wrong Azure Subscription 9 | Set-AzContext -SubscriptionName "US Gov FedCon" 10 | 11 | # Get a list of Azure Locations so you know which location to add to your globar variable 12 | Get-AzLocation 13 | 14 | ## Global variables 15 | $Location = "usgovvirginia" 16 | $ResourceGroupName = "rgazsqlvm" 17 | 18 | ## Storage 19 | $StorageName = $ResourceGroupName + "storage" 20 | $StorageSku = "Premium_LRS" 21 | 22 | ## Network Properties 23 | $InterfaceName = $ResourceGroupName + "ServerInterface" 24 | $NsgName = $ResourceGroupName + "nsg" 25 | $VNetName = $ResourceGroupName + "VNet" 26 | $SubnetName = "Default" 27 | $VNetAddressPrefix = "10.0.0.0/16" 28 | $VNetSubnetAddressPrefix = "10.0.0.0/24" 29 | $TCPIPAllocationMethod = "Dynamic" 30 | $DomainName = $ResourceGroupName 31 | 32 | ##Compute 33 | $VMName = $ResourceGroupName + "VM" 34 | $ComputerName = $ResourceGroupName + "Server" 35 | $VMSize = "Standard_DS1_V2" 36 | $OSDiskName = $VMName + "OSDisk" 37 | 38 | ##Image 39 | $PublisherName = "MicrosoftSQLServer" 40 | $OfferName = "SQL2017-WS2016" 41 | $Sku = "SQLDEV" 42 | $Version = "latest" 43 | 44 | # Resource Group 45 | New-AzResourceGroup -Name $ResourceGroupName -Location $Location 46 | 47 | # Storage 48 | $StorageAccount = New-AzStorageAccount -ResourceGroupName $ResourceGroupName -Name $StorageName -SkuName $StorageSku -Kind "Storage" -Location $Location 49 | 50 | # Network 51 | $SubnetConfig = New-AzVirtualNetworkSubnetConfig -Name $SubnetName -AddressPrefix $VNetSubnetAddressPrefix 52 | $VNet = New-AzVirtualNetwork -Name $VNetName -ResourceGroupName $ResourceGroupName -Location $Location -AddressPrefix $VNetAddressPrefix -Subnet $SubnetConfig 53 | $PublicIp = New-AzPublicIpAddress -Name $InterfaceName -ResourceGroupName $ResourceGroupName -Location $Location -AllocationMethod $TCPIPAllocationMethod -DomainNameLabel $DomainName 54 | $NsgRuleRDP = New-AzNetworkSecurityRuleConfig -Name "RDPRule" -Protocol Tcp -Direction Inbound -Priority 1000 -SourceAddressPrefix * -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 3389 -Access Allow 55 | $NsgRuleSQL = New-AzNetworkSecurityRuleConfig -Name "MSSQLRule" -Protocol Tcp -Direction Inbound -Priority 1001 -SourceAddressPrefix * -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 1433 -Access Allow 56 | $Nsg = New-AzNetworkSecurityGroup -ResourceGroupName $ResourceGroupName -Location $Location -Name $NsgName -SecurityRules $NsgRuleRDP,$NsgRuleSQL 57 | $Interface = New-AzNetworkInterface -Name $InterfaceName -ResourceGroupName $ResourceGroupName -Location $Location -SubnetId $VNet.Subnets[0].Id -PublicIpAddressId $PublicIp.Id -NetworkSecurityGroupId $Nsg.Id 58 | 59 | # Compute 60 | $VirtualMachine = New-AzVMConfig -VMName $VMName -VMSize $VMSize 61 | $Credential = Get-Credential -Message "Type the name and password of the local administrator account." 62 | $VirtualMachine = Set-AzVMOperatingSystem -VM $VirtualMachine -Windows -ComputerName $ComputerName -Credential $Credential -ProvisionVMAgent -EnableAutoUpdate #-TimeZone = $TimeZone 63 | $VirtualMachine = Add-AzVMNetworkInterface -VM $VirtualMachine -Id $Interface.Id 64 | $OSDiskUri = $StorageAccount.PrimaryEndpoints.Blob.ToString() + "vhds/" + $OSDiskName + ".vhd" 65 | $VirtualMachine = Set-AzVMOSDisk -VM $VirtualMachine -Name $OSDiskName -VhdUri $OSDiskUri -Caching ReadOnly -CreateOption FromImage 66 | 67 | # Image 68 | $VirtualMachine = Set-AzVMSourceImage -VM $VirtualMachine -PublisherName $PublisherName -Offer $OfferName -Skus $Sku -Version $Version 69 | 70 | # Create the VM in Azure 71 | New-AzVM -ResourceGroupName $ResourceGroupName -Location $Location -VM $VirtualMachine 72 | 73 | # Add the SQL IaaS Extension, and choose the license type 74 | New-AzSqlVM -ResourceGroupName $ResourceGroupName -Name $VMName -Location $Location -LicenseType PAYG -------------------------------------------------------------------------------- /CreateSQLonAzureVM.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/CreateSQLonAzureVM.ps1 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SQL911 Jupyter Notebook for Azure Data Studio 2 | ## For the day-to-day care and feeding of your SQL Server enterprise 3 | 4 | Did you know that Jupyter Notebooks can help you manage your SQL Server enterprise no matter how large or small? This Jupyter Notebook in Azure Data Studio was created to be a DBA’s handbook of resources, knowledge, code, trouble-shooting tips, and step-by-step examples on how to Administer, Monitor, Troubleshoot, Fix and Repair issues you may encounter in your day-to-day life as a DBA. This notebook brings you content developed over a career of consulting at some of the world’s largest SQL customers. 5 | 6 | COVID19 was the Inspiration for this Notebook. Most Microsoft Consultants were prevented from traveling on site to our customers during the first year of the pandemic. I needed to create some sort of remote-delivery mechanism that will be as close as possible to actually being on site, to help customers continue to deploy, manage, and provide for the day to day “care and feeding” of their SQL Server and data platforms, even when we could not be on-site and the DBA’s had to work from home or operate with limited staff in the data center. 7 | 8 | Now that you have cloned this notebook locally, you will notice that it is not complete. There are so many aspects of SQL Server and Data, that if I tried to capture them all on day-1, before making this notebook public, it would never get published. So, this notebook is a work in progress. Feel free to check back from time to time for new content as I add sections for Azure SQL DB, Azure SQL Managed Instance, SQL Server on Azure VM's and so much more. 9 | 10 | Dedicated to all of the Data Gunslingers who love SQL Server. 11 | 12 | All my best in your journey! 13 | 14 | Kevin 15 | -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 1 Getting Started/Media/CH-1Runwith.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 1 Getting Started/Media/CH-1Runwith.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 1 Getting Started/Media/CH1-ADS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 1 Getting Started/Media/CH1-ADS.png -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 1 Getting Started/Media/CH1-ADS2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 1 Getting Started/Media/CH1-ADS2.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 1 Getting Started/Media/CH1-Azure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 1 Getting Started/Media/CH1-Azure.png -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 1 Getting Started/Media/CH1-ConnectSQL.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 1 Getting Started/Media/CH1-ConnectSQL.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 1 Getting Started/Media/CH1-Explain.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 1 Getting Started/Media/CH1-Explain.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 1 Getting Started/Media/CH1-Logo-sql.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 1 Getting Started/Media/CH1-Logo-sql.png -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 1 Getting Started/Media/CH1-Plan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 1 Getting Started/Media/CH1-Plan.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 1 Getting Started/Media/CH1-WelcomeScreen.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 1 Getting Started/Media/CH1-WelcomeScreen.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 1 Getting Started/Media/Ch1-Operations.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 1 Getting Started/Media/Ch1-Operations.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 1 Getting Started/STRT-QueryExecutions.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | } 12 | }, 13 | "nbformat_minor": 2, 14 | "nbformat": 4, 15 | "cells": [ 16 | { 17 | "cell_type": "markdown", 18 | "source": [ 19 | "![CH1-ADS.png](./Media/CH1-ADS.png)" 20 | ], 21 | "metadata": { 22 | "azdata_cell_guid": "b2464540-aba7-417f-89ae-3b89f142c90f" 23 | }, 24 | "attachments": {} 25 | }, 26 | { 27 | "cell_type": "markdown", 28 | "source": [ 29 | "# Query Executions\n", 30 | "\n", 31 | "Just like in SQL Server Management Studio, the execution of statements, and Stored Procedures we are able to:\n", 32 | "\n", 33 | "- Troubleshoot performance issues with statements using XEvent Profilier (Command Palette - Profilier - New Profiler)\n", 34 | "- Result Set Random Copy to Excel Review Execution Plans\n", 35 | " - Actual (Command Palette - Run Current query with actual plan)\n", 36 | " - Estimated (Query Window - explain)\n", 37 | "- Change Result set output (Query Window)\n", 38 | " - Save as CSV\n", 39 | " - Save as Excel\n", 40 | " - Save as JSON\n", 41 | " - Save as XML\n", 42 | " - Save as Chart\n", 43 | "\n", 44 | "In this section, we will view the performance of a query using the Azure Data Studio Query Execution Plan.  \n", 45 | "\n", 46 | " \n", 47 | "## Estimated Query Plan\n", 48 | "\n", 49 | " \n", 50 | "\n", 51 | "The Estimated Query Execution shows you a visual representation of what the query plan would look like 'if' you were to run it. It is able to do so with out actually running it. Now, if the query below looks a bit funny, it does as I have joined a very simple 4 record table to itself, so as to show a more interesting plan for instructional purposes. \n", 52 | "\n", 53 | "1. Copy the code snippet below\n", 54 | "2. Click your Servers in the top left of Azure Data Studio and right-click on your test server that has the TutorialDB database created in the previous notebook, and click \"New Query\"\n", 55 | "Paste this snippet into the query\n", 56 | "3. Do not run the query, simply click the \"Explain\" button to see how ADS can predict how your query will perform\n", 57 | "" 58 | ], 59 | "metadata": { 60 | "azdata_cell_guid": "92a81a61-a885-4270-abeb-084ade2ec174" 61 | }, 62 | "attachments": {} 63 | }, 64 | { 65 | "cell_type": "code", 66 | "source": [ 67 | "SELECT\r\n", 68 | " C.[Name] as 'First Name',\r\n", 69 | " E.Email as 'Personal Email'\r\n", 70 | "FROM dbo.Customers as C\r\n", 71 | "JOIN dbo.Customers as E\r\n", 72 | "on C.CustomerID = E.CustomerId" 73 | ], 74 | "metadata": { 75 | "azdata_cell_guid": "bf53969f-b323-43e6-a446-00adc70d0a30", 76 | "tags": [] 77 | }, 78 | "outputs": [], 79 | "execution_count": null 80 | }, 81 | { 82 | "cell_type": "markdown", 83 | "source": [ 84 | "4. After clicking the Explain button on the right\n", 85 | "\n", 86 | "![CH1-Explain.jpg](./Media/CH1-Explain.jpg)\n", 87 | "\n", 88 | "5. You will see the estimated query Plan. Notice you can hover over the Operations to view more details\n", 89 | "\n", 90 | "![CH1-Plan.jpg](./Media/CH1-Plan.jpg)\n", 91 | "\n", 92 | "6. In your New Query Window, click the \"Top Opeations\" tab and you can see that this is just an estimation as the Actural Rows column is displaying 0 results for each Operation Type\n", 93 | "\n", 94 | "![CH1-Operations.jpg](./Media/CH1-Operations.jpg)\n", 95 | "\n", 96 | "7. As an added benefit you can click the Results Tab, then click the XML Showplan link to display the XML of your Plan. You can do a Cntrl-A , Cntrl C to copy the entire XML to your clip board, then paste it into notepad. Save it with the .sqlplan extension and you can view this Query plan at a later date.\n", 97 | "" 98 | ], 99 | "metadata": { 100 | "azdata_cell_guid": "ff66d81a-5abf-4511-8218-3d7becad9a38" 101 | }, 102 | "attachments": {} 103 | }, 104 | { 105 | "cell_type": "markdown", 106 | "source": [ 107 | "To learn more about Query Plans you an get started here: [Execution Plans - SQL Server | Microsoft Docs](https://docs.microsoft.com/en-us/sql/relational-databases/performance/execution-plans?view=sql-server-ver15)\n", 108 | "\n", 109 | "Brent Ozar has a lot of good youtube videos on the subject: [Brent Ozar Unlimited - YouTube](https://www.youtube.com/c/BrentOzarUnlimited/search?query=query%20tuning)" 110 | ], 111 | "metadata": { 112 | "azdata_cell_guid": "5b38ffa6-9268-4c5b-8f9d-c6a592b8d0c5" 113 | }, 114 | "attachments": {} 115 | } 116 | ] 117 | } -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 1 Getting Started/readme.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 |

5 | 6 |

7 | 8 | 9 | # Welcome to Chapter 1: Getting Started with Azure Data Studio 10 | 11 | Chapter 1 contains notebooks providing you with helpful links to articles, videos, and on-line learning content to help you get up to speed quickly with Azure Data Stucio You can either click the hyperlink below, or click directly on the notebook in the naviation pane. 12 | 13 | Add more content here 14 | 15 | ## Notebooks in this Chapter 16 | 17 | - [STRT-Introduction](../Chapter 1 Getting Started/STRT-Introduction.ipynb) 18 | - [STRT-QueryExecutions](../Chapter 1 Getting Started/STRT-QueryExecutions.ipynb) 19 | 20 | 21 | -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 10 Azure SQL Managed Instance/ASMI-Getting Started with Azure SQL Managed Instance.ipynb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 10 Azure SQL Managed Instance/ASMI-Getting Started with Azure SQL Managed Instance.ipynb -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 10 Azure SQL Managed Instance/readme.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 10 Azure SQL Managed Instance/readme.md -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 11 High Availbility/SSHA-Getting Started with High Availbility.ipynb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 11 High Availbility/SSHA-Getting Started with High Availbility.ipynb -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 11 High Availbility/readme.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 11 High Availbility/readme.md -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-ADS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-ADS.png -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-Extensions.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-Extensions.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-FirstResponder.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-FirstResponder.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-InstallExtension.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-InstallExtension.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-MissingModules.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-MissingModules.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-NewQuery.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-NewQuery.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-Run.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-Run.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-SlowQueryWidget.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-SlowQueryWidget.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-ViewPalette.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-ViewPalette.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-dashboard.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-dashboard.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-filters.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-filters.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-icon.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-preferences.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-preferences.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-widgets.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 2 Using Extension Packs/Media/CH2-widgets.png -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 2 Using Extension Packs/PACK-FirstResponderKit.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | } 12 | }, 13 | "nbformat_minor": 2, 14 | "nbformat": 4, 15 | "cells": [ 16 | { 17 | "cell_type": "markdown", 18 | "source": [ 19 | "![CH2-ADS.png](.\\Media\\CH2-ADS.png)\r\n", 20 | "\r\n", 21 | "# Using the First Responder Kit Extension\r\n", 22 | "\r\n", 23 | "" 24 | ], 25 | "metadata": { 26 | "azdata_cell_guid": "17813ff7-8bef-478d-87da-58b5cd313604" 27 | } 28 | }, 29 | { 30 | "cell_type": "markdown", 31 | "source": [ 32 | "My amazing Microsoft colleague Drew Skwiers-Koballa created an Azure Data Studio based off of Global MVP Brent Ozar's First Responder kit.   If you are not familiar with Brent Ozar, you can easily find him on YouTube.  His work on the First Responder Kit is an incredible contribution to the SQL Server community and I am going to use this notebook to provide you with some guidance on how to use it in Azure Data Studio.\n", 33 | "\n", 34 | "Just like the two preceeding notebooks on \"Using Extention Packs\" and \"Using Widgets\", this will be a similar walk-thru of how to use this extension.  Likely after you have completed this notebook and the two preceeding one's, you will be able to take it from here when you install other Extension Packs from the Gallery.\n", 35 | "\n", 36 | "## Add the Azure Data Studio extension for the First Responder Kit\n", 37 | "\n", 38 | "1. Access the available extensions by selecting the Extensions Icon, or by selecting Extensions in the View menu. You can use the View: Show Extensions command, available in the Command Palette (F1 or Ctrl+Shift+P).\n", 39 | "\n", 40 | "![CH2-icon.jpg](.\\Media\\Ch2-icon.jpg)\n", 41 | "\n", 42 | "2. Browse for First Responder kit and click the Install button\n", 43 | "\n", 44 | "![CH2-FirstResponder.jpg](.\\Media\\Ch2-FirstResponder.jpg)" 45 | ], 46 | "metadata": { 47 | "azdata_cell_guid": "1c4dcc34-df4d-46b7-bb17-f25c35db397c" 48 | }, 49 | "attachments": {} 50 | }, 51 | { 52 | "cell_type": "markdown", 53 | "source": [ 54 | "## Use the First Responder Kit\n", 55 | "\n", 56 | "After you have installed the Extension, the way to interact with the kit is through the Command Palette.  \n", 57 | "\n", 58 | "From your menu bar, select View \\> Command Palette\n", 59 | "\n", 60 | "Then Enter \"First\" in the Search bar\n", 61 | "\n", 62 | "I will select \"First Responder Kit: Import sp\\_BlitzFirst.  For this notebook I am going to import just the single sp\\_BlitzFirst.  You may want to test each one individually, or download the entire dump into one window by choosing \"First Responder Kit: Import sp\\_Blitz and all its friends\"  Since that one is very large, I am just going to stick wiith sp\\_BlitzFirst.\n", 63 | "\n", 64 | "Click on your choice\n", 65 | "\n", 66 | "![CH2-ViewPalette.jpg](.\\Media\\Ch2-ViewPalette.jpg)\n", 67 | "\n", 68 | "This will load the sp\\_BlitzFirst SQL Stored Procedure code into a new query window for you\n", 69 | "\n", 70 | "Notice that you need to set the Connection and Select the database. This stored procedure can be created and run against any database on your instance and it will work, but I like to keep my master database as clean as posible so I will use one of my user databases.\n", 71 | "\n", 72 | "![CH2-NewQuery.jpg](.\\Media\\Ch2-NewQuery.jpg)\n", 73 | "\n", 74 | "Once you have connected to your SQL instance and then selected the desired database, select \"Run\"\n", 75 | "\n", 76 | " \n", 77 | "\n", 78 | "![CH2-Run.jpg](.\\Media\\Ch2-Run.jpg)\n", 79 | "\n", 80 | " \n", 81 | "\n", 82 | "I run the dbo.sp\\_BlitzFirst stored proceedure against a user database and it compiles successfully.  But, I see in the output that I am missing 2 dependencies.  (sp\\_BlitzWho and sp\\_BlitzCache)\n", 83 | "\n", 84 | " \n", 85 | "\n", 86 | "![CH2-MissingModules.jpg](.\\Media\\Ch2-MissingModules.jpg)\n", 87 | "\n", 88 | "So, repeat the steps above to install sp\\_BlitzWho and sp\\_BlitzCache\n", 89 | "\n", 90 | "Once those are installed you can re-connect to dbo.sp\\_BlitzFirst by searcing the Command Pallete again and re-establising your connection.\n", 91 | "\n", 92 | "It will not be necessary re-run the Create Script, but if you scroll all they way to the bottom, you will see use usage guidance\n", 93 | "\n", 94 | "/* How to run it:\n", 95 | "\n", 96 | "EXEC dbo.sp_BlitzFirst\n", 97 | "\n", 98 | "With extra diagnostic info:\n", 99 | "\n", 100 | "EXEC dbo.sp_BlitzFirst @ExpertMode = 1;\n", 101 | "\n", 102 | "Saving output to tables:\n", 103 | "\n", 104 | "EXEC sp_BlitzFirst\n", 105 | "\n", 106 | "   @OutputDatabaseName = 'DBAtools'\n", 107 | "\n", 108 | ", @OutputSchemaName = 'dbo'\n", 109 | "\n", 110 | ", @OutputTableName = 'BlitzFirst'\n", 111 | "\n", 112 | ", @OutputTableNameFileStats = 'BlitzFirst_FileStats'\n", 113 | "\n", 114 | ", @OutputTableNamePerfmonStats = 'BlitzFirst_PerfmonStats'\n", 115 | "\n", 116 | ", @OutputTableNameWaitStats = 'BlitzFirst_WaitStats'\n", 117 | "\n", 118 | ", @OutputTableNameBlitzCache = 'BlitzCache'\n", 119 | "\n", 120 | ", @OutputTableNameBlitzWho = 'BlitzWho'\n", 121 | "\n", 122 | ", @OutputType = 'none'\n", 123 | "\n", 124 | "*/" 125 | ], 126 | "metadata": { 127 | "azdata_cell_guid": "015e20fe-b75a-4981-bf13-0f69e26a1075" 128 | }, 129 | "attachments": {} 130 | }, 131 | { 132 | "cell_type": "markdown", 133 | "source": [ 134 | "The results give you some extremely helpful information on what might be slowing your SQL Server down.   Brent recommends that sp\\_BlitzFirst be the 'first' of his free stored procedures in this kit." 135 | ], 136 | "metadata": { 137 | "azdata_cell_guid": "d0157d43-02e0-403f-8a11-57a3d423190e" 138 | }, 139 | "attachments": {} 140 | }, 141 | { 142 | "cell_type": "code", 143 | "source": [ 144 | "-- To test, just run sp_BlitzFirst with out any parameters\r\n", 145 | "EXEC dbo.sp_BlitzFirst" 146 | ], 147 | "metadata": { 148 | "azdata_cell_guid": "3208b67a-bf91-4d7d-91e4-410026cdebec" 149 | }, 150 | "outputs": [], 151 | "execution_count": null 152 | }, 153 | { 154 | "cell_type": "markdown", 155 | "source": [ 156 | "I recommend that you watch this video by Brent on sp\\_BlitzFirst where he gives a description of what this stored proceedure does, and how to use it.\n", 157 | "\n", 158 | "[How to Use sp\\_BlitzFirst - YouTube](https://www.youtube.com/watch?v=pQcdbbmTqX4)\n", 159 | "\n", 160 | "Then, after you watch that video, consider testing some of the various options to see more thorough results." 161 | ], 162 | "metadata": { 163 | "azdata_cell_guid": "0d74266f-31be-4f9c-be3e-569ebf70232d" 164 | }, 165 | "attachments": {} 166 | } 167 | ] 168 | } -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 2 Using Extension Packs/PACK-UsingExtensionPacks.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | }, 12 | "extensions": { 13 | "azuredatastudio": { 14 | "version": 1, 15 | "views": [] 16 | } 17 | } 18 | }, 19 | "nbformat_minor": 2, 20 | "nbformat": 4, 21 | "cells": [ 22 | { 23 | "cell_type": "markdown", 24 | "source": [ 25 | "![CH2-Extensions.jpg](.\\Media\\Ch2-Extensions.jpg)\n", 26 | "\n", 27 | "# Getting Started with Extension Packs in Azure Data Studio\n", 28 | "\n", 29 | "Extensions in Azure Data Studio provide you with an easy way to add more functionality to the base Azure Data Studio installation.  Extensions are provided by the Azure Data Studio team (Microsoft), as well as the third-party community.\n", 30 | "\n", 31 | "## Add Azure Data Studio extensions\n", 32 | "\n", 33 | "1. Access the available extensions by selecting the Extensions Icon, or by selecting Extensions in the View menu. You can use the View: Show Extensions command, available in the Command Palette (F1 or Ctrl+Shift+P).\n", 34 | "\n", 35 | "![CH2-icon.jpg](.\\Media\\Ch2-icon.jpg)\n", 36 | "\n", 37 | "2. Select an available extension to view the details of the selected extension\n", 38 | "3. After revewing the details, click the install button if you wish to install it into Azure Data Studio\n", 39 | "\n", 40 | "![CH2-InstallExtension.jpg](.\\Media\\Ch2-InstallExtension.jpg)\n", 41 | "\n", 42 | "## Manually install an Extension from a VSIX\n", 43 | "\n", 44 | "You can manually install an Azure Data Studio extension packaged in a .vsix file using the Install from VSIX command in the Extensions view command drop-down, or the Extensions: Install from VSIX command in the Command Palette and point to the extension's .vsix file.\n", 45 | "\n", 46 | "### Access installed Azure Data Studio extensions\n", 47 | "\n", 48 | "Each extension enhances your experience in Azure Data Studio in a different way. As a result, the entry point for extensions can vary. Refer to your installed extension's individual documentation for information on how its features can be accessed once it's installed.\n", 49 | "\n", 50 | "### Extensions view filters\n", 51 | "\n", 52 | "The Extensions view search box supports filters to help you find and manage extensions. The commands Show Installed Extensions and Show Recommended Extensions use filters such as @installed and @recommended in the search box.\n", 53 | "\n", 54 | "You can see a complete listing of all filters and sort commands by typing @ in the extensions search box and navigating through the suggestions:\n", 55 | "\n", 56 | "![CH2-filters.jpg](.\\Media\\Ch2-filters.jpg)\n", 57 | "\n", 58 | "Here are the Extensions view filters:\n", 59 | "\n", 60 | "- @builtin - Show extensions that come with Azure Data Studio. Grouped by type (Programming Languages, Themes, etc.).\n", 61 | "- @disabled - Show disabled installed extensions.\n", 62 | "- @enabled - Show enabled installed extensions. Extensions can be individually enabled/disabled.\n", 63 | "- @installed - Show installed extensions.\n", 64 | "- @outdated - Show outdated installed extensions. A newer version is available on the Marketplace.\n", 65 | "- @recommended - Show recommended extensions. Grouped as Workspace specific or general use.\n", 66 | "- @category - Show extensions belonging to specified category. Below are a few of supported categories. For a complete list, type @category and follow the options in the suggestion list:\n", 67 | "- @category:themes\n", 68 | "- @category:formatters\n", 69 | "- @category:snippets These filters can be combined as well. For example, @installed - @category:themes displays all installed themes.\n", 70 | "\n", 71 | "If no filter is provided, the Extensions view displays currently installed and recommended extensions.\n", 72 | "\n", 73 | "### Where are extensions installed?\n", 74 | "\n", 75 | "Extensions are installed in a per user extensions folder. Depending on your platform, the location is in the following folder:\n", 76 | "\n", 77 | "- Windows %USERPROFILE%.azuredatastudio\\\\extensions\n", 78 | "- macOS ~/.azuredatastudio/extensions\n", 79 | "- Linux ~/.azuredatastudio/extensions\n", 80 | "\n", 81 | "Here's a list of currently available Azure Data Studio Extension on GitHub: [List of Extensions · microsoft/azuredatastudio Wiki (github.com)](https://github.com/Microsoft/azuredatastudio/wiki/List-of-Extensions)\n", 82 | "\n", 83 | "Here are some helpful youtube videos of using Azure Data Studio Extensions: [Extensions in Azure Data Studio - YouTube](https://www.youtube.com/results?search_query=Extensions+in+Azure+Data+Studio)" 84 | ], 85 | "metadata": { 86 | "azdata_cell_guid": "a7f51ad7-fad8-4210-8525-dabc746cd592" 87 | }, 88 | "attachments": {} 89 | } 90 | ] 91 | } -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 2 Using Extension Packs/PACK-UsingWidgets.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | } 12 | }, 13 | "nbformat_minor": 2, 14 | "nbformat": 4, 15 | "cells": [ 16 | { 17 | "cell_type": "markdown", 18 | "source": [ 19 | "![CH2-widgets.png](./Media/CH2-widgets.png)\n", 20 | "![CH2-ADS.png](./Media/CH2-ADS.png)\n", 21 | "\n", 22 | "\n", 23 | "\n", 24 | "# Getting Started with Widgets in Azure Data Studio\n", 25 | "\n", 26 | "This notebook demonstrates the process of adding one of the built-in Azure Data Studio sample widgets to the database dashboard to quickly view a database's five slowest queries. You also learn how to view the details of the slow queries and query plans using Azure Data Studio features. \n", 27 | "\n", 28 | "During this lesson, you learn how to:\n", 29 | "- Enable Query Store on a database\n", 30 | " -Add a pre-built insight widget to the database dashboard\n", 31 | "- View details about the database's slowest queries\n", 32 | "- View query execution plans for the slow queries\n", 33 | "\n", 34 | "Azure Data Studio includes several insight widgets out-of-the-box. This notebook shows how to add the query-data-store-db-insight widget, but the steps are basically the same for adding any widget.\n", 35 | "\n", 36 | "We will be using the TutorialDB Test Database created in the Query Executions Notebook. But you can use any database you wish.\n", 37 | "\n", 38 | "## Turn on the Query Store for your database\n", 39 | "\n", 40 | "The widget in this example requires Query Store to be enabled.\n", 41 | "1. Right-click the TutorialDB database (in the SERVERS sidebar) and select New Query.\n", 42 | "2. Paste the following Transact-SQL (T-SQL) statement in the query editor, and click Run:\n", 43 | "\n", 44 | "\n", 45 | "\n", 46 | "" 47 | ], 48 | "metadata": { 49 | "azdata_cell_guid": "88b77feb-29ac-4cf6-86b0-259f582c8cd6" 50 | }, 51 | "attachments": {} 52 | }, 53 | { 54 | "cell_type": "code", 55 | "source": [ 56 | "ALTER DATABASE TutorialDB SET QUERY_STORE = ON" 57 | ], 58 | "metadata": { 59 | "azdata_cell_guid": "038170a7-de64-43f6-8db6-c9e9d7405ee3" 60 | }, 61 | "outputs": [], 62 | "execution_count": null 63 | }, 64 | { 65 | "cell_type": "markdown", 66 | "source": [ 67 | "To add the slow queries widget to your dashboard, edit the dashboard.database.widgets setting in your User Settings file.\n", 68 | "\n", 69 | "- Open User Settings by pressing Ctrl+Shift+P to open the Command Palette.\n", 70 | "- Type settings in the search box and select Preferences:\n", 71 | "- Scroll down to \"Open User Settings\"\n", 72 | "\n", 73 | "![CH2-preferences.jpg](./Media/Ch2-preferences.jpg)\n", 74 | "" 75 | ], 76 | "metadata": { 77 | "azdata_cell_guid": "bf41f1c4-d00f-4479-908e-319fece3be4f" 78 | }, 79 | "attachments": {} 80 | }, 81 | { 82 | "cell_type": "markdown", 83 | "source": [ 84 | "3. Type dashboard into the User Preference Setting.  In the Dashboard \\> Database: Widgets section, click on Edit in settings.json link\"CH2-dashboard.jpg\"\n", 85 | "4. Copy this code to your clipboard into the\n", 86 | "\n", 87 | "\"dashboard.database.widgets\": \\[\n", 88 | "\n", 89 | "\\--paste into here in your settings.json-----\n", 90 | "\n", 91 | "\\]" 92 | ], 93 | "metadata": { 94 | "azdata_cell_guid": "750f4f52-a2b2-4ff0-aa84-e97ea082cad8" 95 | }, 96 | "attachments": {} 97 | }, 98 | { 99 | "cell_type": "code", 100 | "source": [ 101 | " {\r\n", 102 | " \"name\": \"slow queries widget\",\r\n", 103 | " \"gridItemConfig\": {\r\n", 104 | " \"sizex\": 2,\r\n", 105 | " \"sizey\": 1\r\n", 106 | " },\r\n", 107 | " \"widget\": {\r\n", 108 | " \"query-data-store-db-insight\": null\r\n", 109 | " }\r\n", 110 | " },\r\n", 111 | " {\r\n", 112 | " \"name\": \"Tasks\",\r\n", 113 | " \"gridItemConfig\": {\r\n", 114 | " \"sizex\": 1,\r\n", 115 | " \"sizey\": 1\r\n", 116 | " },\r\n", 117 | " \"widget\": {\r\n", 118 | " \"tasks-widget\": {}\r\n", 119 | " }\r\n", 120 | " },\r\n", 121 | " {\r\n", 122 | " \"gridItemConfig\": {\r\n", 123 | " \"sizex\": 1,\r\n", 124 | " \"sizey\": 2\r\n", 125 | " },\r\n", 126 | " \"widget\": {\r\n", 127 | " \"explorer-widget\": {}\r\n", 128 | " }\r\n", 129 | " }" 130 | ], 131 | "metadata": { 132 | "azdata_cell_guid": "be299ee5-10f1-466a-90f5-8c64c3b81af5" 133 | }, 134 | "outputs": [], 135 | "execution_count": null 136 | }, 137 | { 138 | "cell_type": "markdown", 139 | "source": [ 140 | "5. Press Ctrl+S to save the User Modified Settings\r\n", 141 | "6. Open the new Database Dashboard by navigating to the TutorialDB database in the Servers Sidebar, right-click and select \"Manage\" and view your new slow query widget.\r\n", 142 | "![CH2-SlowQueryWidget](./Media/CH2-SlowQueryWidget.jpg)\r\n", 143 | "\r\n", 144 | "7. Click the elipses on the top right of the widget and you will see three options:\r\n", 145 | "- Show Details\r\n", 146 | "- Run Query\r\n", 147 | "- Refresh\r\n", 148 | "\r\n", 149 | "\r\n", 150 | "" 151 | ], 152 | "metadata": { 153 | "azdata_cell_guid": "7acc739c-9e89-4b4b-9857-d28841fd7b37" 154 | }, 155 | "attachments": {} 156 | } 157 | ] 158 | } -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 2 Using Extension Packs/readme.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 |

6 | 7 |

8 | 9 | 10 | 11 | # Welcome to Chapter 2: Using Extension Packs 12 | 13 | Chapter 2 contains notebooks providing you with helpful links to articles, videos, and on-line learning content to help you get up to speed quickly with Azure Data Stucio. You can either click the hyperlink below, or click directly on the notebook in the naviation pane. Extension packs are a community-driven process to make managing and developing SQL solutions quickly. 14 | 15 | 16 | ## Notebooks in this Chapter 17 | 18 | - [PACK-UsingExtensionPacks](../Chapter 2 Using Extension Packs/PACK-UsingExtensionPacks.ipynb) 19 | - [PACK-UsingWidgets](../Chapter 2 Using Extension Packs/PACK-UsingWidgets.ipynb) 20 | - [PACK-FirstResponderKit](../Chapter 2 Using Extension Packs/PACK-FirstResponderKit.ipynb) 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 3 General Information/GEN-GetBPConsumers.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | }, 12 | "extensions": { 13 | "azuredatastudio": { 14 | "version": 1, 15 | "views": [] 16 | } 17 | } 18 | }, 19 | "nbformat_minor": 2, 20 | "nbformat": 4, 21 | "cells": [ 22 | { 23 | "cell_type": "markdown", 24 | "source": [ 25 | "![CH3-ADS.png](./Media/CH3-ADS.png)" 26 | ], 27 | "metadata": { 28 | "azdata_cell_guid": "439042cb-8105-4890-b235-c2411f142995" 29 | }, 30 | "attachments": {} 31 | }, 32 | { 33 | "cell_type": "markdown", 34 | "source": [ 35 | "# Gather Buffer Pool Consumers\n", 36 | "\n", 37 | "The purpose of this notebook is to query the sys.dm\\_os\\_buffer\\_descriptors dynamic management view.  It returns information about all the data pages that are currently in the SQL Server buffer pool. The output of this view can be used to determine the distribution of database pages in the buffer pool according to database, object, or type. In SQL Server, this dynamic management view also returns information about the data pages in the buffer pool extension file. For more information, see Buffer Pool Extension, read this excellent doc on the [Buffer pool extension - SQL Server | Microsoft Docs](https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/buffer-pool-extension?view=sql-server-ver15)\n", 38 | "\n", 39 | "When a data page is read from disk, the page is copied into the SQL Server buffer pool and cached for reuse. Each cached data page has one buffer descriptor. Buffer descriptors uniquely identify each data page that is currently cached in an instance of SQL Server. sys.dm\\_os\\_buffer\\_descriptors returns cached pages for all user and system databases. This includes pages that are associated with the Resource database.\n", 40 | "\n", 41 | " \n", 42 | "\n", 43 | "| Column name | Data type | Description |\n", 44 | "| --- | --- | --- |\n", 45 | "| database\\_id | int | ID of database associated with the page in the buffer pool. Is nullable. |\n", 46 | "| file\\_id | int | ID of the file that stores the persisted image of the page. Is nullable. |\n", 47 | "| page\\_id | int | ID of the page within the file. Is nullable. |\n", 48 | "| page\\_level | int | Index level of the page. Is nullable. |\n", 49 | "| allocation\\_unit\\_id | bigint | ID of the allocation unit of the page. This value can be used to join sys.allocation\\_units. Is nullable. |\n", 50 | "| page\\_type | nvarchar(60) | Type of the page, such as: Data page or Index page. Is nullable. |\n", 51 | "| row\\_count | int | Number of rows on the page. Is nullable. |\n", 52 | "| free\\_space\\_in\\_bytes | int | Amount of available free space, in bytes, on the page. Is nullable. |\n", 53 | "| is\\_modified | bit | 1 = Page has been modified after it was read from the disk. Is nullable. |\n", 54 | "| numa\\_node | int | Nonuniform Memory Access node for the buffer. Is nullable. |\n", 55 | "| read\\_microsec | bigint | The actual time (in microseconds) required to read the page into the buffer. This number is reset when the buffer is reused. Is nullable. |\n", 56 | "| is\\_in\\_bpool\\_extension | bit | 1 = Page is in buffer pool extension. Is nullable. |\n", 57 | "| pdw\\_node\\_id | int | Applies to: Azure Synapse Analytics, Analytics Platform System (PDW)

The identifier for the node that this distribution is on. |\n", 58 | "\n", 59 | "### Run the Code block below\n", 60 | "\n", 61 | "1. Click the run icon below\n", 62 | "2. If ADS prompts you for a connection, enter the correct SQL Server and authentication account\n", 63 | "3. View the results of the query by scrolling down to the results set" 64 | ], 65 | "metadata": { 66 | "azdata_cell_guid": "9e8a0cf1-94c8-4502-8e1a-ce17d59912a3" 67 | }, 68 | "attachments": {} 69 | }, 70 | { 71 | "cell_type": "code", 72 | "source": [ 73 | "SET NOCOUNT ON;\r\n", 74 | "SET ANSI_WARNINGS ON;\r\n", 75 | "SET QUOTED_IDENTIFIER ON;\r\n", 76 | "\r\n", 77 | "DECLARE @sqlcmd NVARCHAR(max), @params NVARCHAR(600)\r\n", 78 | "DECLARE @sqlmajorver int\r\n", 79 | "\r\n", 80 | "SELECT @sqlmajorver = CONVERT(int, (@@microsoftversion / 0x1000000) & 0xff);\r\n", 81 | "\r\n", 82 | "-- Note: in case of NUMA architecture, more than one entry per database is expected\r\n", 83 | "\r\n", 84 | "SET @sqlcmd = 'SELECT ''Memory_checks'' AS [Category], ''Buffer_Pool_Consumers'' AS [Information], \r\n", 85 | "numa_node, COUNT_BIG(DISTINCT page_id)*8/1024 AS total_pages_MB, \r\n", 86 | "CASE database_id WHEN 32767 THEN ''ResourceDB'' ELSE DB_NAME(database_id) END AS database_name,\r\n", 87 | "SUM(CONVERT(BIGINT,row_count))/COUNT_BIG(DISTINCT page_id) AS avg_row_count_per_page, \r\n", 88 | "SUM(CONVERT(BIGINT, free_space_in_bytes))/COUNT_BIG(DISTINCT page_id) AS avg_free_space_bytes_per_page\r\n", 89 | "' + CASE WHEN @sqlmajorver >= 12 THEN ',is_in_bpool_extension' ELSE '' END + '\r\n", 90 | "' + CASE WHEN @sqlmajorver = 10 THEN ',numa_node' ELSE '' END + '\r\n", 91 | "' + CASE WHEN @sqlmajorver >= 11 THEN ',AVG(read_microsec) AS avg_read_microsec' ELSE '' END + '\r\n", 92 | "FROM sys.dm_os_buffer_descriptors\r\n", 93 | "--WHERE bd.page_type IN (''DATA_PAGE'', ''INDEX_PAGE'')\r\n", 94 | "GROUP BY database_id' + CASE WHEN @sqlmajorver >= 10 THEN ', numa_node' ELSE '' END + CASE WHEN @sqlmajorver >= 12 THEN ', is_in_bpool_extension' ELSE '' END + '\r\n", 95 | "ORDER BY total_pages_MB DESC;'\r\n", 96 | "EXECUTE sp_executesql @sqlcmd;\r\n", 97 | "" 98 | ], 99 | "metadata": { 100 | "azdata_cell_guid": "209a1ee5-36d3-4af2-8a3e-631e7754a9ba" 101 | }, 102 | "outputs": [], 103 | "execution_count": null 104 | } 105 | ] 106 | } -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 3 General Information/GEN-GetBufferPool.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | }, 12 | "extensions": { 13 | "azuredatastudio": { 14 | "version": 1, 15 | "views": [] 16 | } 17 | } 18 | }, 19 | "nbformat_minor": 2, 20 | "nbformat": 4, 21 | "cells": [ 22 | { 23 | "cell_type": "markdown", 24 | "source": [ 25 | "![CH3-ADS.png](./Media/CH3-ADS.png)\n", 26 | "\n", 27 | " \n", 28 | "\n", 29 | "" 30 | ], 31 | "metadata": { 32 | "azdata_cell_guid": "ff645c44-4952-4cd2-8f07-0e8de77c73da" 33 | }, 34 | "attachments": {} 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "source": [ 39 | "# Gather Buffer Pool Configuration\n", 40 | "\n", 41 | "## Benefits of the buffer pool extension\n", 42 | "\n", 43 | "The primary purpose of a SQL Server database is to store and retrieve data, so intensive disk I/O is a core characteristic of the Database Engine. Because disk I/O operations can consume many resources and take a relatively long time to finish, SQL Server focuses on making I/O highly efficient. The buffer pool serves as a primary memory allocation source of SQL Server.  Buffer management is a key component in achieving this efficiency. The buffer management component consists of two mechanisms: the buffer manager to access and update database pages, and the buffer pool, to reduce database file I/O.\n", 44 | "\n", 45 | "Data and index pages are read from disk into the buffer pool and modified pages (also known as dirty pages) are written back to disk. Memory pressure on the server and database checkpoints cause hot (active) dirty pages in the buffer cache to be evicted from the cache and written to mechanical disks and then read back into the cache. These I/O operations are typically small random reads and writes on the order of 4 to 16 KB of data. Small random I/O patterns incur frequent seeks, competing for the mechanical disk arm, increasing I/O latency, and reducing aggregate I/O throughput of the system.\n", 46 | "\n", 47 | "The typical approach to resolving these I/O bottlenecks is to add more RAM, or alternatively, added high-performance SAS spindles. While these options are helpful, they have significant drawbacks: RAM is more expensive than data storage drives and adding spindles increases capital expenditure in hardware acquisition and increases operational costs by increased power consumption and increased probability of component failure.\n", 48 | "\n", 49 | "The buffer pool extension feature extends the buffer pool cache with nonvolatile storage (usually SSD). Because of this extension, the buffer pool can accommodate a larger database working set, which forces the paging of I/Os between RAM and the SSDs. This effectively offloads small random I/Os from mechanical disks to SSDs. Because of the lower latency and better random I/O performance of SSDs, the buffer pool extension significantly improves I/O throughput.\n", 50 | "\n", 51 | "The following list describes the benefits of the buffer pool extension feature.\n", 52 | "\n", 53 | "- Increased random I/O throughput\n", 54 | "- Reduced I/O latency\n", 55 | "- Increased transaction throughput\n", 56 | "- Improved read performance with a larger hybrid buffer pool\n", 57 | "\n", 58 | "## Concepts\n", 59 | "\n", 60 | "The following terms are applicable to the buffer pool extension feature.\n", 61 | "\n", 62 | "Solid-state drive (SSD) -- Solid-state drives store data in memory (RAM) in a persistent manner.\n", 63 | "\n", 64 | "Buffer -- In SQL Server, A buffer is an 8-KB page in memory, the same size as a data or index page. Thus, the buffer cache is divided into 8-KB pages. A page remains in the buffer cache until the buffer manager needs the buffer area to read in more data. Data is written back to disk only if it is modified. These in-memory modified pages are known as dirty pages. A page is clean when it is equivalent to its database image on disk. Data in the buffer cache can be modified multiple times before being written back to disk.\n", 65 | "\n", 66 | "Buffer pool -- Also called buffer cache. The buffer pool is a global resource shared by all databases for their cached data pages.  The maximum and minimum size of the buffer pool cache is determined during startup or when the instance of SQL server is dynamically reconfigured by using sp\\_configure.  This size determines the maximum number of pages that can be cached in the buffer pool at any time in the running instance.  The maximum memory that can be committed by buffer pool extension can be limited by the other applications running on the machine in case those create significant memory pressure.\n", 67 | "\n", 68 | "Checkpoint --A checkpoint creates a known good point from which the Database Engine can start applying changes contained in the transaction log during recovery after an unexpected shutdown or crash.  A checkpoint writes the dirty pages and transaction log information from memory to disk and, also, records information about the transaction log. \n", 69 | "\n", 70 | "### Run the Code block below\n", 71 | "\n", 72 | "1. Click the run icon below\n", 73 | "2. If ADS prompts you for a connection, enter the correct SQL Server and authentication account\n", 74 | "3. View the results of the query by scrolling down to the results set" 75 | ], 76 | "metadata": { 77 | "azdata_cell_guid": "9018bf7b-21e6-4fe0-a483-3718bb98d800" 78 | }, 79 | "attachments": {} 80 | }, 81 | { 82 | "cell_type": "code", 83 | "source": [ 84 | "SET NOCOUNT ON;\r\n", 85 | "SET ANSI_WARNINGS ON;\r\n", 86 | "SET QUOTED_IDENTIFIER ON;\r\n", 87 | "\r\n", 88 | "DECLARE @sqlmajorver int\r\n", 89 | "\r\n", 90 | "SELECT @sqlmajorver = CONVERT(int, (@@microsoftversion / 0x1000000) & 0xff);\r\n", 91 | "\r\n", 92 | "IF @sqlmajorver > 11\r\n", 93 | "BEGIN\r\n", 94 | "\tSELECT 'Information' AS [Category], 'BP_Extension' AS [Information], \r\n", 95 | "\t\tCASE WHEN state = 0 THEN 'BP_Extension_Disabled' \r\n", 96 | "\t\t\tWHEN state = 1 THEN 'BP_Extension_is_Disabling'\r\n", 97 | "\t\t\tWHEN state = 3 THEN 'BP_Extension_is_Enabling'\r\n", 98 | "\t\t\tWHEN state = 5 THEN 'BP_Extension_Enabled'\r\n", 99 | "\t\tEND AS state, \r\n", 100 | "\t\t[path], current_size_in_kb\r\n", 101 | "\tFROM sys.dm_os_buffer_pool_extension_configuration\r\n", 102 | "END\r\n", 103 | "ELSE\r\n", 104 | "BEGIN\r\n", 105 | "\tSELECT 'Information' AS [Category], 'BP_Extension' AS [Information], 'NA' AS state\r\n", 106 | "END;" 107 | ], 108 | "metadata": { 109 | "azdata_cell_guid": "f21506f7-560e-43ff-a5a5-60c50234c931" 110 | }, 111 | "outputs": [], 112 | "execution_count": null 113 | } 114 | ] 115 | } -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 3 General Information/GEN-GetDBGrowth.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | }, 12 | "extensions": { 13 | "azuredatastudio": { 14 | "version": 1, 15 | "views": [] 16 | } 17 | } 18 | }, 19 | "nbformat_minor": 2, 20 | "nbformat": 4, 21 | "cells": [ 22 | { 23 | "cell_type": "markdown", 24 | "source": [ 25 | "![CH3-ADS.png](.\\Media\\CH3-ADS.png)\n", 26 | "\n", 27 | "# Get Database Growth\n", 28 | "\n", 29 | "## The primary purpose is to query the database growth of all databases on this instance for the last 72 hours\n", 30 | "\n", 31 | "### Run the Code block below\n", 32 | "\n", 33 | "1. Click the run icon below\n", 34 | "2. If ADS prompts you for a connection, enter the correct SQL Server and authentication account\n", 35 | "3. View the results of the query by scrolling down to the results set" 36 | ], 37 | "metadata": { 38 | "azdata_cell_guid": "5aef2dc3-0e0a-41c1-af16-482d70d3eee5" 39 | }, 40 | "attachments": {} 41 | }, 42 | { 43 | "cell_type": "code", 44 | "source": [ 45 | "SET NOCOUNT ON;\r\n", 46 | "SET ANSI_WARNINGS ON;\r\n", 47 | "SET QUOTED_IDENTIFIER ON;\r\n", 48 | "\r\n", 49 | "DECLARE @sqlcmd NVARCHAR(max), @params NVARCHAR(600)\r\n", 50 | "DECLARE @sqlmajorver int, @sqlminorver int, @sqlbuild int\r\n", 51 | "DECLARE @ErrorMessage NVARCHAR(4000)\r\n", 52 | "DECLARE @ostype VARCHAR(10)\r\n", 53 | "\r\n", 54 | "SELECT @sqlmajorver = CONVERT(int, (@@microsoftversion / 0x1000000) & 0xff);\r\n", 55 | "SELECT @sqlminorver = CONVERT(int, (@@microsoftversion / 0x10000) & 0xff);\r\n", 56 | "SELECT @sqlbuild = CONVERT(int, @@microsoftversion & 0xffff);\r\n", 57 | "\r\n", 58 | "IF (@sqlmajorver >= 11) OR (@sqlmajorver = 10 AND @sqlminorver = 50 AND @sqlbuild >= 2500)\r\n", 59 | "BEGIN\r\n", 60 | "\tSET @sqlcmd = N'SELECT @ostypeOUT = ''Windows'' FROM sys.dm_os_windows_info (NOLOCK)';\r\n", 61 | "\tSET @params = N'@ostypeOUT VARCHAR(10) OUTPUT';\r\n", 62 | "\tEXECUTE sp_executesql @sqlcmd, @params, @ostypeOUT=@ostype OUTPUT;\r\n", 63 | "END\r\n", 64 | "ELSE\r\n", 65 | "BEGIN\r\n", 66 | "\tSET @ostype = 'Windows'\r\n", 67 | "END;\r\n", 68 | "\r\n", 69 | "IF EXISTS (SELECT TOP 1 id FROM sys.traces WHERE is_default = 1)\r\n", 70 | "BEGIN\r\n", 71 | "\tDECLARE @tracefilename VARCHAR(500)\r\n", 72 | "\tIF @ostype = 'Windows'\r\n", 73 | "\tSELECT @tracefilename = LEFT([path],LEN([path]) - PATINDEX('%\\%', REVERSE([path]))) + '\\log.trc' FROM sys.traces WHERE is_default = 1;\r\n", 74 | "\t\r\n", 75 | "\tIF @ostype <> 'Windows'\r\n", 76 | "\tSELECT @tracefilename = LEFT([path],LEN([path]) - PATINDEX('%/%', REVERSE([path]))) + '/log.trc' FROM sys.traces WHERE is_default = 1;\r\n", 77 | "\r\n", 78 | "\tWITH AutoGrow_CTE (databaseid, [filename], Growth, Duration, StartTime, EndTime)\r\n", 79 | "\tAS\r\n", 80 | "\t(\r\n", 81 | "\tSELECT databaseid, [filename], SUM(IntegerData*8) AS Growth, Duration, StartTime, EndTime--, CASE WHEN EventClass =\r\n", 82 | "\tFROM sys.fn_trace_gettable(@tracefilename, default)\r\n", 83 | "\tWHERE EventClass >= 92 AND EventClass <= 95 AND DATEDIFF(hh,StartTime,GETDATE()) < 72 -- Last 24h\r\n", 84 | "\tGROUP BY databaseid, [filename], IntegerData, Duration, StartTime, EndTime\r\n", 85 | "\t)\r\n", 86 | "\tSELECT 'Information' AS [Category], 'Recorded_Autogrows_Lst72H' AS [Information], DB_NAME(database_id) AS Database_Name, \r\n", 87 | "\t\tmf.name AS logical_file_name, mf.size*8 / 1024 AS size_MB, mf.type_desc,\r\n", 88 | "\t\tag.Growth AS [growth_KB], CASE WHEN is_percent_growth = 1 THEN 'Pct' ELSE 'MB' END AS growth_type,\r\n", 89 | "\t\tDuration/1000 AS Growth_Duration_ms, ag.StartTime, ag.EndTime\r\n", 90 | "\tFROM sys.master_files mf\r\n", 91 | "\tLEFT OUTER JOIN AutoGrow_CTE ag ON mf.database_id=ag.databaseid AND mf.name=ag.[filename]\r\n", 92 | "\tWHERE ag.Growth > 0 --Only where growth occurred\r\n", 93 | "\tGROUP BY database_id, mf.name, mf.size, ag.Growth, ag.Duration, ag.StartTime, ag.EndTime, is_percent_growth, mf.growth, mf.type_desc\r\n", 94 | "\tORDER BY Database_Name, logical_file_name, ag.StartTime;\r\n", 95 | "END\r\n", 96 | "ELSE\r\n", 97 | "BEGIN\r\n", 98 | "\tSELECT 'Information' AS [Category], 'Recorded_Autogrows_Lst72H' AS [Information], 'WARNING: Could not gather information on autogrow times' AS [Comment]\r\n", 99 | "END;" 100 | ], 101 | "metadata": { 102 | "azdata_cell_guid": "6bdcd292-9114-4d83-9f47-d29af923b75e" 103 | }, 104 | "outputs": [], 105 | "execution_count": null 106 | } 107 | ] 108 | } -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 3 General Information/GEN-GetDiskSpace.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | }, 12 | "extensions": { 13 | "azuredatastudio": { 14 | "version": 1, 15 | "views": [] 16 | } 17 | } 18 | }, 19 | "nbformat_minor": 2, 20 | "nbformat": 4, 21 | "cells": [ 22 | { 23 | "cell_type": "markdown", 24 | "source": [ 25 | "![CH3-ADS.png](.\\Media\\CH3-ADS.png)\n", 26 | "\n", 27 | "# Get Disk Space\n", 28 | "\n", 29 | "## The primary purpose of this notebook is to return total space and free space of each logical volume.\n", 30 | "\n", 31 | "### Run the Code block below\n", 32 | "\n", 33 | "1. Click the run icon below\n", 34 | "2. If ADS prompts you for a connection, enter the correct SQL Server and authentication account\n", 35 | "3. View the results of the query by scrolling down to the results set" 36 | ], 37 | "metadata": { 38 | "azdata_cell_guid": "2155bb88-cebc-42bf-aa26-dab1c3b3efff" 39 | }, 40 | "attachments": {} 41 | }, 42 | { 43 | "cell_type": "code", 44 | "source": [ 45 | "SET NOCOUNT ON;\r\n", 46 | "SET ANSI_WARNINGS ON;\r\n", 47 | "SET QUOTED_IDENTIFIER ON;\r\n", 48 | "\r\n", 49 | "DECLARE @sqlmajorver int\r\n", 50 | "DECLARE @ErrorMessage NVARCHAR(4000)\r\n", 51 | "\r\n", 52 | "SELECT @sqlmajorver = CONVERT(int, (@@microsoftversion / 0x1000000) & 0xff);\r\n", 53 | "\r\n", 54 | "IF @sqlmajorver > 9\r\n", 55 | "BEGIN\r\n", 56 | "\tSELECT DISTINCT 'Information' AS [Category], 'Disk_Space' AS [Information], vs.logical_volume_name,\r\n", 57 | "\t\tvs.volume_mount_point, vs.file_system_type, CONVERT(int,vs.total_bytes/1048576.0) AS TotalSpace_MB,\r\n", 58 | "\t\tCONVERT(int,vs.available_bytes/1048576.0) AS FreeSpace_MB, vs.is_compressed\r\n", 59 | "\tFROM sys.master_files mf\r\n", 60 | "\tCROSS APPLY sys.dm_os_volume_stats(mf.database_id, mf.[file_id]) vs\r\n", 61 | "\tORDER BY FreeSpace_MB ASC\r\n", 62 | "END;" 63 | ], 64 | "metadata": { 65 | "azdata_cell_guid": "d59cc263-c192-4730-b04b-d95a71612fff" 66 | }, 67 | "outputs": [], 68 | "execution_count": null 69 | } 70 | ] 71 | } -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 3 General Information/GEN-GetHAInfo.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | }, 12 | "extensions": { 13 | "azuredatastudio": { 14 | "version": 1, 15 | "views": [] 16 | } 17 | } 18 | }, 19 | "nbformat_minor": 2, 20 | "nbformat": 4, 21 | "cells": [ 22 | { 23 | "cell_type": "markdown", 24 | "source": [ 25 | "![CH3-ADS.png](.\\Media\\CH3-ADS.png)\n", 26 | "\n", 27 | "# Get High Availablity Information\n", 28 | "\n", 29 | "## The primary purpose of this notebook is to show if high availability like Windows Server Failover Clustering or Always On Availibility Groups has been configured.   This notebook provides just a quick look into HA.  There is an entire section of this book dedicated to High Availability.  \n", 30 | "\n", 31 | "### Run the Code block below\n", 32 | "\n", 33 | "1. Click the run icon below\n", 34 | "2. If ADS prompts you for a connection, enter the correct SQL Server and authentication account\n", 35 | "3. View the results of the query by scrolling down to the results set" 36 | ], 37 | "metadata": { 38 | "azdata_cell_guid": "b3446297-8515-4084-a3d4-69c8e188cf37" 39 | }, 40 | "attachments": {} 41 | }, 42 | { 43 | "cell_type": "code", 44 | "source": [ 45 | "SET NOCOUNT ON;\r\n", 46 | "SET ANSI_WARNINGS ON;\r\n", 47 | "SET QUOTED_IDENTIFIER ON;\r\n", 48 | "\r\n", 49 | "DECLARE @sqlcmd NVARCHAR(max), @params NVARCHAR(600)\r\n", 50 | "DECLARE @sqlmajorver int, @sqlminorver int, @sqlbuild int, @clustered bit\r\n", 51 | "DECLARE @ptochecks bit\r\n", 52 | "\r\n", 53 | "SET @ptochecks = 1 --(1 = ON; 0 = OFF)\r\n", 54 | "\r\n", 55 | "SELECT @sqlmajorver = CONVERT(int, (@@microsoftversion / 0x1000000) & 0xff);\r\n", 56 | "SELECT @sqlminorver = CONVERT(int, (@@microsoftversion / 0x10000) & 0xff);\r\n", 57 | "SELECT @sqlbuild = CONVERT(int, @@microsoftversion & 0xffff);\r\n", 58 | "SELECT @clustered = CONVERT(bit,ISNULL(SERVERPROPERTY('IsClustered'),0))\r\n", 59 | "\r\n", 60 | "IF @clustered = 1\r\n", 61 | "BEGIN\r\n", 62 | "\tIF @sqlmajorver < 11\r\n", 63 | "\t\tBEGIN\r\n", 64 | "\t\t\tEXEC ('SELECT ''Information'' AS [Category], ''Cluster'' AS [Information], NodeName AS node_name FROM sys.dm_os_cluster_nodes (NOLOCK)')\r\n", 65 | "\t\tEND\r\n", 66 | "\tELSE\r\n", 67 | "\t\tBEGIN\r\n", 68 | "\t\t\tEXEC ('SELECT ''Information'' AS [Category], ''Cluster'' AS [Information], NodeName AS node_name, status_description, is_current_owner FROM sys.dm_os_cluster_nodes (NOLOCK)')\r\n", 69 | "\t\tEND\r\n", 70 | "\tSELECT 'Information' AS [Category], 'Cluster' AS [Information], DriveName AS cluster_shared_drives FROM sys.dm_io_cluster_shared_drives (NOLOCK)\r\n", 71 | "END\r\n", 72 | "ELSE\r\n", 73 | "BEGIN\r\n", 74 | "\tSELECT 'Information' AS [Category], 'Cluster' AS [Information], 'NOT_CLUSTERED' AS [Status]\r\n", 75 | "END;\r\n", 76 | "\r\n", 77 | "IF @sqlmajorver > 10\r\n", 78 | "BEGIN\r\n", 79 | "\tDECLARE @IsHadrEnabled tinyint, @HadrManagerStatus tinyint\r\n", 80 | "\tSELECT @IsHadrEnabled = CASE WHEN SERVERPROPERTY('EngineEdition') = 8 THEN 1 ELSE CONVERT(tinyint, SERVERPROPERTY('IsHadrEnabled')) END;\r\n", 81 | "\tSELECT @HadrManagerStatus = CASE WHEN SERVERPROPERTY('EngineEdition') = 8 THEN 1 ELSE CONVERT(tinyint, SERVERPROPERTY('HadrManagerStatus')) END;\r\n", 82 | "\t\r\n", 83 | "\tSELECT 'Information' AS [Category], 'AlwaysOn_AG' AS [Information], \r\n", 84 | "\t\tCASE @IsHadrEnabled WHEN 0 THEN 'Disabled'\r\n", 85 | "\t\t\tWHEN 1 THEN 'Enabled' END AS [AlwaysOn_Availability_Groups],\r\n", 86 | "\t\tCASE WHEN @IsHadrEnabled = 1 THEN\r\n", 87 | "\t\t\tCASE @HadrManagerStatus WHEN 0 THEN '[Not started, pending communication]'\r\n", 88 | "\t\t\t\tWHEN 1 THEN '[Started and running]'\r\n", 89 | "\t\t\t\tWHEN 2 THEN '[Not started and failed]'\r\n", 90 | "\t\t\tEND\r\n", 91 | "\t\tEND AS [Status];\r\n", 92 | "\t\r\n", 93 | "\tIF @IsHadrEnabled = 1\r\n", 94 | "\tBEGIN\t\r\n", 95 | "\t\tIF EXISTS (SELECT 1 FROM sys.dm_hadr_cluster) \r\n", 96 | "\t\tSELECT 'Information' AS [Category], 'AlwaysOn_Cluster' AS [Information], cluster_name, quorum_type_desc, quorum_state_desc \r\n", 97 | "\t\tFROM sys.dm_hadr_cluster;\r\n", 98 | "\r\n", 99 | "\t\tIF EXISTS (SELECT 1 FROM sys.dm_hadr_cluster_members) \r\n", 100 | "\t\tSELECT 'Information' AS [Category], 'AlwaysOn_Cluster_Members' AS [Information], member_name, member_type_desc, member_state_desc, number_of_quorum_votes \r\n", 101 | "\t\tFROM sys.dm_hadr_cluster_members;\r\n", 102 | "\t\t\r\n", 103 | "\t\tIF EXISTS (SELECT 1 FROM sys.dm_hadr_cluster_networks) \r\n", 104 | "\t\tSELECT 'Information' AS [Category], 'AlwaysOn_Cluster_Networks' AS [Information], member_name, network_subnet_ip, network_subnet_ipv4_mask, is_public, is_ipv4 \r\n", 105 | "\t\tFROM sys.dm_hadr_cluster_networks;\r\n", 106 | "\tEND;\r\n", 107 | "\t\r\n", 108 | "\tIF @ptochecks = 1 AND @IsHadrEnabled = 1\r\n", 109 | "\tBEGIN\r\n", 110 | "\t\t-- Note: If low_water_mark_for_ghosts number is not increasing over time, it implies that ghost cleanup might not happen.\r\n", 111 | "\t\tSET @sqlcmd = 'SELECT ''Information'' AS [Category], ''AlwaysOn_Replicas'' AS [Information], database_id, group_id, replica_id, group_database_id, is_local, synchronization_state_desc, \r\n", 112 | "\tis_commit_participant, synchronization_health_desc, database_state_desc, is_suspended, suspend_reason_desc, last_sent_time, last_received_time, last_hardened_time, \r\n", 113 | "\tlast_redone_time, log_send_queue_size, log_send_rate, redo_queue_size, redo_rate, filestream_send_rate, last_commit_time, \r\n", 114 | "\tlow_water_mark_for_ghosts' + CASE WHEN @sqlmajorver > 12 THEN ', secondary_lag_seconds' ELSE '' END + ' \r\n", 115 | "FROM sys.dm_hadr_database_replica_states'\r\n", 116 | "\t\tEXECUTE sp_executesql @sqlcmd\r\n", 117 | "\r\n", 118 | "\t\tSELECT 'Information' AS [Category], 'AlwaysOn_Replica_Cluster' AS [Information], replica_id, group_database_id, database_name, is_failover_ready, is_pending_secondary_suspend, \r\n", 119 | "\t\t\tis_database_joined, recovery_lsn, truncation_lsn \r\n", 120 | "\t\tFROM sys.dm_hadr_database_replica_cluster_states;\r\n", 121 | "\tEND\r\n", 122 | "END" 123 | ], 124 | "metadata": { 125 | "azdata_cell_guid": "491b7de4-dc7c-45db-9882-8680fdf4d87a" 126 | }, 127 | "outputs": [], 128 | "execution_count": null 129 | } 130 | ] 131 | } -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 3 General Information/GEN-GetLinkedServers.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | }, 12 | "extensions": { 13 | "azuredatastudio": { 14 | "version": 1, 15 | "views": [] 16 | } 17 | } 18 | }, 19 | "nbformat_minor": 2, 20 | "nbformat": 4, 21 | "cells": [ 22 | { 23 | "cell_type": "markdown", 24 | "source": [ 25 | "![CH3-ADS.png](.\\Media\\CH3-ADS.png)\n", 26 | "\n", 27 | "# Get SQL Linked Servers\n", 28 | "\n", 29 | "## The primary purpose of this notebook is to return a list of Linked Servers if any have been configured for your Instance.\n", 30 | "\n", 31 | "### Run the Code block below\n", 32 | "\n", 33 | "1. Click the run icon below\n", 34 | "2. If ADS prompts you for a connection, enter the correct SQL Server and authentication account\n", 35 | "3. View the results of the query by scrolling down to the results set" 36 | ], 37 | "metadata": { 38 | "azdata_cell_guid": "909bdeab-ca8c-4f5b-a53e-448195e42843" 39 | }, 40 | "attachments": {} 41 | }, 42 | { 43 | "cell_type": "code", 44 | "source": [ 45 | "SET NOCOUNT ON;\r\n", 46 | "SET ANSI_WARNINGS ON;\r\n", 47 | "SET QUOTED_IDENTIFIER ON;\r\n", 48 | "\r\n", 49 | "DECLARE @sqlcmd NVARCHAR(max), @params NVARCHAR(600)\r\n", 50 | "DECLARE @sqlmajorver int\r\n", 51 | "\r\n", 52 | "SELECT @sqlmajorver = CONVERT(int, (@@microsoftversion / 0x1000000) & 0xff);\r\n", 53 | "\r\n", 54 | "IF (SELECT COUNT(*) FROM sys.servers AS s INNER JOIN sys.linked_logins AS l (NOLOCK) ON s.server_id = l.server_id INNER JOIN sys.server_principals AS p (NOLOCK) ON p.principal_id = l.local_principal_id WHERE s.is_linked = 1) > 0\r\n", 55 | "BEGIN\r\n", 56 | "\tSET @sqlcmd = 'SELECT ''Information'' AS [Category], ''Linked_servers'' AS [Information], s.name, s.product, \r\n", 57 | "\ts.provider, s.data_source, s.location, s.provider_string, s.catalog, s.connect_timeout, \r\n", 58 | "\ts.query_timeout, s.is_linked, s.is_remote_login_enabled, s.is_rpc_out_enabled, \r\n", 59 | "\ts.is_data_access_enabled, s.is_collation_compatible, s.uses_remote_collation, s.collation_name, \r\n", 60 | "\ts.lazy_schema_validation, s.is_system, s.is_publisher, s.is_subscriber, s.is_distributor, \r\n", 61 | "\ts.is_nonsql_subscriber' + CASE WHEN @sqlmajorver > 9 THEN ', s.is_remote_proc_transaction_promotion_enabled' ELSE '' END + ',\r\n", 62 | "\ts.modify_date, CASE WHEN l.local_principal_id = 0 THEN ''local or wildcard'' ELSE p.name END AS [local_principal], \r\n", 63 | "\tCASE WHEN l.uses_self_credential = 0 THEN ''use own credentials'' ELSE ''use supplied username and pwd'' END AS uses_self_credential, \r\n", 64 | "\tl.remote_name, l.modify_date AS [linked_login_modify_date]\r\n", 65 | "FROM sys.servers AS s (NOLOCK)\r\n", 66 | "INNER JOIN sys.linked_logins AS l (NOLOCK) ON s.server_id = l.server_id\r\n", 67 | "INNER JOIN sys.server_principals AS p (NOLOCK) ON p.principal_id = l.local_principal_id\r\n", 68 | "WHERE s.is_linked = 1'\r\n", 69 | "\tEXECUTE sp_executesql @sqlcmd\r\n", 70 | "END\r\n", 71 | "ELSE\r\n", 72 | "BEGIN\r\n", 73 | "\tSELECT 'Information' AS [Category], 'Linked_servers' AS [Information], 'None' AS [Status]\r\n", 74 | "END;" 75 | ], 76 | "metadata": { 77 | "azdata_cell_guid": "c36b0fd3-cf05-4a96-8506-45df223ed77b" 78 | }, 79 | "outputs": [ 80 | { 81 | "output_type": "display_data", 82 | "data": { 83 | "text/html": "Commands completed successfully." 84 | }, 85 | "metadata": {} 86 | }, 87 | { 88 | "output_type": "display_data", 89 | "data": { 90 | "text/html": "Total execution time: 00:00:00.023" 91 | }, 92 | "metadata": {} 93 | }, 94 | { 95 | "output_type": "execute_result", 96 | "metadata": {}, 97 | "execution_count": 1, 98 | "data": { 99 | "application/vnd.dataresource+json": { 100 | "schema": { 101 | "fields": [ 102 | { 103 | "name": "Category" 104 | }, 105 | { 106 | "name": "Information" 107 | }, 108 | { 109 | "name": "Status" 110 | } 111 | ] 112 | }, 113 | "data": [ 114 | { 115 | "0": "Information", 116 | "1": "Linked_servers", 117 | "2": "None" 118 | } 119 | ] 120 | }, 121 | "text/html": [ 122 | "", 123 | "", 124 | "", 125 | "
CategoryInformationStatus
InformationLinked_serversNone
" 126 | ] 127 | } 128 | } 129 | ], 130 | "execution_count": 1 131 | } 132 | ] 133 | } -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 3 General Information/GEN-GetLogonTriggers.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | }, 12 | "extensions": { 13 | "azuredatastudio": { 14 | "version": 1, 15 | "views": [] 16 | } 17 | } 18 | }, 19 | "nbformat_minor": 2, 20 | "nbformat": 4, 21 | "cells": [ 22 | { 23 | "cell_type": "markdown", 24 | "source": [ 25 | "![CH3-ADS.png](.\\Media\\CH3-ADS.png)\n", 26 | "\n", 27 | "# Get SQL Logon Triggers\n", 28 | "\n", 29 | "## The primary purpose of this notebook is to return a list of Logon Triggers if any have been configured.\n", 30 | "\n", 31 | "### Run the Code block below\n", 32 | "\n", 33 | "1. Click the run icon below\n", 34 | "2. If ADS prompts you for a connection, enter the correct SQL Server and authentication account\n", 35 | "3. View the results of the query by scrolling down to the results set" 36 | ], 37 | "metadata": { 38 | "azdata_cell_guid": "5cdb9565-8020-4c4f-9c6d-33c4f34cdde0" 39 | }, 40 | "attachments": {} 41 | }, 42 | { 43 | "cell_type": "code", 44 | "source": [ 45 | "\r\n", 46 | "SET NOCOUNT ON;\r\n", 47 | "SET ANSI_WARNINGS ON;\r\n", 48 | "SET QUOTED_IDENTIFIER ON;\r\n", 49 | "\r\n", 50 | "IF (SELECT COUNT([name]) FROM sys.server_triggers WHERE is_disabled = 0 AND is_ms_shipped = 0) > 0\r\n", 51 | "BEGIN\r\n", 52 | "\tSELECT 'Information' AS [Category], 'Logon_Triggers' AS [Information], name AS [Trigger_Name], type_desc AS [Trigger_Type],create_date, modify_date\r\n", 53 | "\tFROM sys.server_triggers WHERE is_disabled = 0 AND is_ms_shipped = 0\r\n", 54 | "\tORDER BY name;\r\n", 55 | "END\r\n", 56 | "ELSE\r\n", 57 | "BEGIN\r\n", 58 | "\tSELECT 'Information' AS [Category], 'Logon_Triggers' AS [Information], 'NA' AS [Comment]\r\n", 59 | "END;" 60 | ], 61 | "metadata": { 62 | "azdata_cell_guid": "0a6d6546-de81-4f13-9d72-b22223a64c47" 63 | }, 64 | "outputs": [], 65 | "execution_count": null 66 | } 67 | ] 68 | } -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 3 General Information/GEN-GetLowMemoryEvents.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | }, 12 | "extensions": { 13 | "azuredatastudio": { 14 | "version": 1, 15 | "views": [] 16 | } 17 | } 18 | }, 19 | "nbformat_minor": 2, 20 | "nbformat": 4, 21 | "cells": [ 22 | { 23 | "cell_type": "markdown", 24 | "source": [ 25 | "![CH3-ADS.png](.\\Media\\CH3-ADS.png)\n", 26 | "\n", 27 | "# Get Low Memory Events\n", 28 | "\n", 29 | "## This Query is from the Windows Internals book by David Solomon and Mark Russinovich:\n", 30 | "\n", 31 | "\"The default level of available memory that signals a low-memory-resource notification event is approximately 32 MB per 4 GB,  to a maximum of 64 MB. The default level that signals a high-memory-resource notification event is three times the default low-memory value.\" \n", 32 | "\n", 33 | "### Run the Code block below\n", 34 | "\n", 35 | "1. Click the run icon below\n", 36 | "2. If ADS prompts you for a connection, enter the correct SQL Server and authentication account\n", 37 | "3. View the results of the query by scrolling down to the results set" 38 | ], 39 | "metadata": { 40 | "azdata_cell_guid": "0b25ec34-8c4b-4cb2-89dc-8c79e39ec421" 41 | }, 42 | "attachments": {} 43 | }, 44 | { 45 | "cell_type": "code", 46 | "source": [ 47 | "\r\n", 48 | "SET NOCOUNT ON;\r\n", 49 | "SET ANSI_WARNINGS ON;\r\n", 50 | "SET QUOTED_IDENTIFIER ON;\r\n", 51 | "SET DATEFORMAT mdy;\r\n", 52 | "\r\n", 53 | "DECLARE @masterpid int, @RegKey NVARCHAR(255), @LowMemoryThreshold int, @systemmem bigint\r\n", 54 | "DECLARE @permstbl TABLE ([name] sysname);\r\n", 55 | "\r\n", 56 | "DECLARE @sqlcmd NVARCHAR(max), @params NVARCHAR(600)\r\n", 57 | "DECLARE @sqlmajorver int\r\n", 58 | "DECLARE @ErrorMessage NVARCHAR(4000)\r\n", 59 | "\r\n", 60 | "SELECT @sqlmajorver = CONVERT(int, (@@microsoftversion / 0x1000000) & 0xff);\r\n", 61 | "\r\n", 62 | "SELECT @masterpid = principal_id FROM master.sys.database_principals (NOLOCK) WHERE sid = SUSER_SID()\r\n", 63 | "\r\n", 64 | "INSERT INTO @permstbl\r\n", 65 | "SELECT a.name\r\n", 66 | "FROM master.sys.all_objects a (NOLOCK) INNER JOIN master.sys.database_permissions b (NOLOCK) ON a.[OBJECT_ID] = b.major_id\r\n", 67 | "WHERE a.type IN ('P', 'X') AND b.grantee_principal_id <>0\r\n", 68 | "AND b.grantee_principal_id <>2\r\n", 69 | "AND b.grantee_principal_id = @masterpid;\r\n", 70 | "\r\n", 71 | "IF @sqlmajorver = 9\r\n", 72 | "BEGIN\r\n", 73 | "\tSET @sqlcmd = N'SELECT @systemmemOUT = t1.record.value(''(./Record/MemoryRecord/TotalPhysicalMemory)[1]'', ''bigint'')/1024\r\n", 74 | "FROM (SELECT MAX([TIMESTAMP]) AS [TIMESTAMP], CONVERT(xml, record) AS record \r\n", 75 | "\tFROM sys.dm_os_ring_buffers (NOLOCK)\r\n", 76 | "\tWHERE ring_buffer_type = N''RING_BUFFER_RESOURCE_MONITOR''\r\n", 77 | "\t\tAND record LIKE ''%RESOURCE_MEMPHYSICAL%''\r\n", 78 | "\tGROUP BY record) AS t1';\r\n", 79 | "END\r\n", 80 | "ELSE\r\n", 81 | "BEGIN\r\n", 82 | "\tSET @sqlcmd = N'SELECT @systemmemOUT = total_physical_memory_kb/1024 FROM sys.dm_os_sys_memory';\r\n", 83 | "END\r\n", 84 | "\r\n", 85 | "SET @params = N'@systemmemOUT bigint OUTPUT';\r\n", 86 | "\r\n", 87 | "EXECUTE sp_executesql @sqlcmd, @params, @systemmemOUT=@systemmem OUTPUT;\r\n", 88 | "\r\n", 89 | "IF (ISNULL(IS_SRVROLEMEMBER(N'sysadmin'), 0) = 1) OR ((SELECT COUNT([name]) FROM @permstbl WHERE [name] = 'xp_regread') = 1)\r\n", 90 | "BEGIN\r\n", 91 | "\tBEGIN TRY\r\n", 92 | "\t\tSELECT @RegKey = N'System\\CurrentControlSet\\Control\\SessionManager\\MemoryManagement'\r\n", 93 | "\t\tEXEC master.sys.xp_regread N'HKEY_LOCAL_MACHINE', @RegKey, N'LowMemoryThreshold', @LowMemoryThreshold OUTPUT, NO_OUTPUT\r\n", 94 | "\t\t\r\n", 95 | "\t\tIF @LowMemoryThreshold IS NULL\r\n", 96 | "\t\tSELECT @LowMemoryThreshold = CASE WHEN @systemmem <= 4096 THEN 32 ELSE 64 END\r\n", 97 | "\tEND TRY\r\n", 98 | "\tBEGIN CATCH\r\n", 99 | "\t\tSELECT ERROR_NUMBER() AS ErrorNumber, ERROR_MESSAGE() AS ErrorMessage;\r\n", 100 | "\t\tSELECT @ErrorMessage = 'Server Memory subsection - Error raised in TRY block. ' + ERROR_MESSAGE()\r\n", 101 | "\t\tRAISERROR (@ErrorMessage, 16, 1);\r\n", 102 | "\tEND CATCH\r\n", 103 | "END\r\n", 104 | "ELSE\r\n", 105 | "BEGIN\r\n", 106 | "\tRAISERROR('WARNING: Missing permissions for full \"Instance info\" checks. Bypassing LowMemoryThreshold check', 16, 1, N'sysadmin')\r\n", 107 | "\t--RETURN\r\n", 108 | "END;\r\n", 109 | "\r\n", 110 | "IF @LowMemoryThreshold IS NOT NULL\r\n", 111 | "SELECT 'Memory_checks' AS [Category], 'Memory_RM_Tresholds' AS [Information], @LowMemoryThreshold AS [MEMPHYSICAL_LOW_Threshold], @LowMemoryThreshold * 3 AS [MEMPHYSICAL_HIGH_Threshold]\r\n", 112 | "\r\n", 113 | "SELECT 'Memory_checks' AS [Category], 'Memory_RM_Notifications' AS [Information], \r\n", 114 | "CASE WHEN x.[TIMESTAMP] BETWEEN -2147483648 AND 2147483647 AND si.ms_ticks BETWEEN -2147483648 AND 2147483647 THEN DATEADD(ms, x.[TIMESTAMP] - si.ms_ticks, GETDATE()) \r\n", 115 | " ELSE DATEADD(s, ([TIMESTAMP]/1000) - (si.ms_ticks/1000), GETDATE()) END AS Event_Time,\r\n", 116 | " record.value('(./Record/ResourceMonitor/Notification)[1]', 'VARCHAR(max)') AS [Notification],\r\n", 117 | " record.value('(./Record/MemoryRecord/TotalPhysicalMemory)[1]', 'bigint')/1024 AS [Total_Physical_Mem_MB],\r\n", 118 | " record.value('(./Record/MemoryRecord/AvailablePhysicalMemory)[1]', 'bigint')/1024 AS [Avail_Physical_Mem_MB],\r\n", 119 | " record.value('(./Record/MemoryRecord/AvailableVirtualAddressSpace)[1]', 'bigint')/1024 AS [Avail_VAS_MB],\r\n", 120 | " record.value('(./Record/MemoryRecord/TotalPageFile)[1]', 'bigint')/1024 AS [Total_Pagefile_MB],\r\n", 121 | " record.value('(./Record/MemoryRecord/AvailablePageFile)[1]', 'bigint')/1024 AS [Avail_Pagefile_MB]\r\n", 122 | "FROM (SELECT [TIMESTAMP], CONVERT(xml, record) AS record \r\n", 123 | " FROM sys.dm_os_ring_buffers (NOLOCK)\r\n", 124 | " WHERE ring_buffer_type = N'RING_BUFFER_RESOURCE_MONITOR') AS x\r\n", 125 | "CROSS JOIN sys.dm_os_sys_info si (NOLOCK)\r\n", 126 | "--WHERE CASE WHEN x.[timestamp] BETWEEN -2147483648 AND 2147483648 THEN DATEADD(ms, x.[timestamp] - si.ms_ticks, GETDATE()) \r\n", 127 | "--\tELSE DATEADD(s, (x.[timestamp]/1000) - (si.ms_ticks/1000), GETDATE()) END >= DATEADD(hh, -12, GETDATE())\r\n", 128 | "ORDER BY 2 DESC;" 129 | ], 130 | "metadata": { 131 | "azdata_cell_guid": "61fe15d9-0989-43d2-8ad7-4b2be331d5a0" 132 | }, 133 | "outputs": [], 134 | "execution_count": null 135 | } 136 | ] 137 | } -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 3 General Information/GEN-GetMemoryAlloc.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | }, 12 | "extensions": { 13 | "azuredatastudio": { 14 | "version": 1, 15 | "views": [] 16 | } 17 | } 18 | }, 19 | "nbformat_minor": 2, 20 | "nbformat": 4, 21 | "cells": [ 22 | { 23 | "cell_type": "markdown", 24 | "source": [ 25 | "![CH3-ADS.png](.\\Media\\CH3-ADS.png)\n", 26 | "\n", 27 | "# Get Memory Allocations\n", 28 | "\n", 29 | "This notebook will display a list of memory allocations by 'type' in descending order.\n", 30 | "\n", 31 | "The SQL Server memory manager consists of a three-layer hierarchy. At the bottom of the hierarchy are memory nodes. The middle level consists of memory clerks, memory caches, and memory pools. The top layer consists of memory objects. These objects are used to allocate memory in an instance of SQL Server. \n", 32 | "\n", 33 | "Memory nodes provide the interface and the implementation for low-level allocators. Inside SQL Server, only memory clerks have access to memory nodes. Memory clerks access memory node interfaces to allocate memory. Memory nodes also track the memory allocated by using the clerk for diagnostics. Every component that allocates a significant amount of memory must create its own memory clerk and allocate all its memory by using the clerk interfaces. Frequently, components create their corresponding clerks at the time SQL Server is started. \n", 34 | "\n", 35 | "These Memory Clerks or Cache Stores are used for obects in SQL Server like the Service Broker, Query Plans, Temporary Tables, Backups, Compression, and so many more.  You can read more about these allocations here: [sys.dm\\_os\\_memory\\_clerks (Transact-SQL) - SQL Server | Microsoft Docs](https://docs.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-os-memory-clerks-transact-sql?view=sql-server-ver15)\n", 36 | "\n", 37 | "### Run the Code block below\n", 38 | "\n", 39 | "1. Click the run icon below\n", 40 | "2. If ADS prompts you for a connection, enter the correct SQL Server and authentication account\n", 41 | "3. View the results of the query by scrolling down to the results set" 42 | ], 43 | "metadata": { 44 | "azdata_cell_guid": "41017961-0a37-4087-bb3f-80c9d63fbc8f" 45 | }, 46 | "attachments": {} 47 | }, 48 | { 49 | "cell_type": "code", 50 | "source": [ 51 | "SET NOCOUNT ON;\r\n", 52 | "SET ANSI_WARNINGS ON;\r\n", 53 | "SET QUOTED_IDENTIFIER ON;\r\n", 54 | "\r\n", 55 | "DECLARE @sqlcmd NVARCHAR(max), @params NVARCHAR(600)\r\n", 56 | "DECLARE @sqlmajorver int, @xtp bit\r\n", 57 | "\r\n", 58 | "SELECT @sqlmajorver = CONVERT(int, (@@microsoftversion / 0x1000000) & 0xff);\r\n", 59 | "\r\n", 60 | "SET @sqlcmd = N'SELECT ''Memory_checks'' AS [Category], [type] AS Alloc_Type, \r\n", 61 | "' + CASE WHEN @sqlmajorver < 11 THEN 'SUM(single_pages_kb + multi_pages_kb + virtual_memory_committed_kb + shared_memory_committed_kb + awe_allocated_kb) AS Alloc_Mem_KB'\r\n", 62 | "\tELSE 'SUM(pages_kb + virtual_memory_committed_kb + shared_memory_committed_kb + awe_allocated_kb) AS Alloc_Mem_KB' END + '\r\n", 63 | "FROM sys.dm_os_memory_clerks \r\n", 64 | "WHERE type IN (''CACHESTORE_COLUMNSTOREOBJECTPOOL'',''CACHESTORE_CLRPROC'',''CACHESTORE_OBJCP'',''CACHESTORE_PHDR'',''CACHESTORE_SQLCP'',''CACHESTORE_TEMPTABLES'',\r\n", 65 | "''MEMORYCLERK_SQLBUFFERPOOL'',''MEMORYCLERK_SQLCLR'',''MEMORYCLERK_SQLGENERAL'',''MEMORYCLERK_SQLLOGPOOL'',''MEMORYCLERK_SQLOPTIMIZER'',\r\n", 66 | "''MEMORYCLERK_SQLQUERYCOMPILE'',''MEMORYCLERK_SQLQUERYEXEC'',''MEMORYCLERK_SQLQUERYPLAN'',''MEMORYCLERK_SQLSTORENG'',''MEMORYCLERK_XTP'',\r\n", 67 | "''OBJECTSTORE_LOCK_MANAGER'',''OBJECTSTORE_SNI_PACKET'',''USERSTORE_DBMETADATA'',''USERSTORE_OBJPERM'')\r\n", 68 | "GROUP BY [type]\r\n", 69 | "UNION ALL\r\n", 70 | "SELECT ''Memory_checks'' AS [Category], ''Others'' AS Alloc_Type, \r\n", 71 | "' + CASE WHEN @sqlmajorver < 11 THEN 'SUM(single_pages_kb + multi_pages_kb + virtual_memory_committed_kb + shared_memory_committed_kb) AS Alloc_Mem_KB'\r\n", 72 | "\tELSE 'SUM(pages_kb + virtual_memory_committed_kb + shared_memory_committed_kb) AS Alloc_Mem_KB' END + '\r\n", 73 | "FROM sys.dm_os_memory_clerks \r\n", 74 | "WHERE type NOT IN (''CACHESTORE_COLUMNSTOREOBJECTPOOL'',''CACHESTORE_CLRPROC'',''CACHESTORE_OBJCP'',''CACHESTORE_PHDR'',''CACHESTORE_SQLCP'',''CACHESTORE_TEMPTABLES'',\r\n", 75 | "''MEMORYCLERK_SQLBUFFERPOOL'',''MEMORYCLERK_SQLCLR'',''MEMORYCLERK_SQLGENERAL'',''MEMORYCLERK_SQLLOGPOOL'',''MEMORYCLERK_SQLOPTIMIZER'',\r\n", 76 | "''MEMORYCLERK_SQLQUERYCOMPILE'',''MEMORYCLERK_SQLQUERYEXEC'',''MEMORYCLERK_SQLQUERYPLAN'',''MEMORYCLERK_SQLSTORENG'',''MEMORYCLERK_XTP'',\r\n", 77 | "''OBJECTSTORE_LOCK_MANAGER'',''OBJECTSTORE_SNI_PACKET'',''USERSTORE_DBMETADATA'',''USERSTORE_OBJPERM'')\r\n", 78 | "ORDER BY Alloc_Mem_KB DESC'\r\n", 79 | "EXECUTE sp_executesql @sqlcmd;\r\n", 80 | "\r\n", 81 | "IF @sqlmajorver >= 12\r\n", 82 | "BEGIN\r\n", 83 | "\tSET @sqlcmd = N'SELECT @xtpOUT = COUNT(*) FROM sys.dm_db_xtp_memory_consumers';\r\n", 84 | "\tSET @params = N'@xtpOUT int OUTPUT';\r\n", 85 | "\tEXECUTE sp_executesql @sqlcmd, @params, @xtpOUT = @xtp OUTPUT;\r\n", 86 | "\t\r\n", 87 | "\tIF @xtp > 0\r\n", 88 | "\tBEGIN\r\n", 89 | "\t\tSET @sqlcmd = N'SELECT ''Memory_checks'' AS [Category], ''InMemory_Consumers'' AS Alloc_Type, \r\n", 90 | "OBJECT_NAME([object_id]) AS [Object_Name], memory_consumer_type_desc, [object_id], index_id, \r\n", 91 | "allocated_bytes/(1024*1024) AS Allocated_MB, used_bytes/(1024*1024) AS Used_MB, \r\n", 92 | "CASE WHEN used_bytes IS NULL THEN ''used_bytes_is_varheap_only'' ELSE '''' END AS [Comment]\r\n", 93 | "FROM sys.dm_db_xtp_memory_consumers\r\n", 94 | "WHERE [object_id] > 0\r\n", 95 | "ORDER BY Allocated_MB DESC' -- Only user objects; system objects are negative numbers\r\n", 96 | "\t\tEXECUTE sp_executesql @sqlcmd;\r\n", 97 | "\r\n", 98 | "\t\tSET @sqlcmd = N'SELECT ''Memory_checks'' AS [Category], ''InMemory_Alloc'' AS Alloc_Type, \r\n", 99 | "SUM(allocated_bytes)/(1024*1024) AS total_allocated_MB, SUM(used_bytes)/(1024*1024) AS total_used_MB\r\n", 100 | "FROM sys.dm_db_xtp_memory_consumers\r\n", 101 | "ORDER BY total_allocated_MB DESC'\r\n", 102 | "\t\tEXECUTE sp_executesql @sqlcmd;\r\n", 103 | "\tEND;\r\n", 104 | "END;" 105 | ], 106 | "metadata": { 107 | "azdata_cell_guid": "3edafec7-cdfb-4806-b658-129cdec4bb08" 108 | }, 109 | "outputs": [], 110 | "execution_count": null 111 | } 112 | ] 113 | } -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 3 General Information/GEN-GetOSVersion.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | }, 12 | "extensions": { 13 | "azuredatastudio": { 14 | "version": 1, 15 | "views": [] 16 | } 17 | } 18 | }, 19 | "nbformat_minor": 2, 20 | "nbformat": 4, 21 | "cells": [ 22 | { 23 | "cell_type": "markdown", 24 | "source": [ 25 | "![CH3-ADS.png](.\\Media\\CH3-ADS.png)\n", 26 | "\n", 27 | "# Get Operating System Information\n", 28 | "\n", 29 | "## This notebook will return information about the operating system that this SQL Server is running on.   \n", 30 | "\n", 31 | "### Run the Code block below\n", 32 | "\n", 33 | "1. Click the run icon below\n", 34 | "2. If ADS prompts you for a connection, enter the correct SQL Server and authentication account\n", 35 | "3. View the results of the query by scrolling down to the results set" 36 | ], 37 | "metadata": { 38 | "azdata_cell_guid": "affa4c78-c877-4436-8437-48478d662830" 39 | }, 40 | "attachments": {} 41 | }, 42 | { 43 | "cell_type": "code", 44 | "source": [ 45 | "SET NOCOUNT ON;\r\n", 46 | "SET ANSI_WARNINGS ON;\r\n", 47 | "SET QUOTED_IDENTIFIER ON;\r\n", 48 | "\r\n", 49 | "DECLARE @sqlcmd NVARCHAR(max), @params NVARCHAR(600)\r\n", 50 | "DECLARE @sqlmajorver int, @sqlminorver int, @sqlbuild int\r\n", 51 | "DECLARE @ErrorMessage NVARCHAR(4000)\r\n", 52 | "DECLARE @clustered bit, @osver VARCHAR(5), @ostype VARCHAR(10), @osdistro VARCHAR(20), @server VARCHAR(128), @instancename NVARCHAR(128)\r\n", 53 | "DECLARE @arch smallint, @ossp VARCHAR(25), @SystemManufacturer VARCHAR(128)\r\n", 54 | "\r\n", 55 | "SELECT @sqlmajorver = CONVERT(int, (@@microsoftversion / 0x1000000) & 0xff);\r\n", 56 | "SELECT @sqlminorver = CONVERT(int, (@@microsoftversion / 0x10000) & 0xff);\r\n", 57 | "SELECT @sqlbuild = CONVERT(int, @@microsoftversion & 0xffff);\r\n", 58 | "\r\n", 59 | "IF (@sqlmajorver >= 11 AND @sqlmajorver < 14) OR (@sqlmajorver = 10 AND @sqlminorver = 50 AND @sqlbuild >= 2500)\r\n", 60 | "BEGIN\r\n", 61 | "\tSET @sqlcmd = N'SELECT @ostypeOUT = ''Windows'', @osdistroOUT = ''Windows'', @osverOUT = CASE WHEN windows_release IN (''6.3'',''10.0'') AND (@@VERSION LIKE ''%Build 10586%'' OR @@VERSION LIKE ''%Build 14393%'') THEN ''10.0'' ELSE windows_release END, @osspOUT = windows_service_pack_level, @archOUT = CASE WHEN @@VERSION LIKE ''%%'' THEN 64 WHEN @@VERSION LIKE ''%%'' THEN 128 ELSE 32 END FROM sys.dm_os_windows_info (NOLOCK)';\r\n", 62 | "\tSET @params = N'@osverOUT VARCHAR(5) OUTPUT, @ostypeOUT VARCHAR(10) OUTPUT, @osdistroOUT VARCHAR(20) OUTPUT, @osspOUT VARCHAR(25) OUTPUT, @archOUT smallint OUTPUT';\r\n", 63 | "\tEXECUTE sp_executesql @sqlcmd, @params, @osverOUT=@osver OUTPUT, @ostypeOUT=@ostype OUTPUT, @osdistroOUT=@osdistro OUTPUT, @osspOUT=@ossp OUTPUT, @archOUT=@arch OUTPUT;\r\n", 64 | "END\r\n", 65 | "ELSE IF @sqlmajorver >= 14\r\n", 66 | "BEGIN\r\n", 67 | "\tSET @sqlcmd = N'SELECT @ostypeOUT = host_platform, @osdistroOUT = host_distribution, @osverOUT = CASE WHEN host_platform = ''Windows'' AND host_release IN (''6.3'',''10.0'') THEN ''10.0'' ELSE host_release END, @osspOUT = host_service_pack_level, @archOUT = CASE WHEN @@VERSION LIKE ''%%'' THEN 64 ELSE 32 END FROM sys.dm_os_host_info (NOLOCK)';\r\n", 68 | "\tSET @params = N'@osverOUT VARCHAR(5) OUTPUT, @ostypeOUT VARCHAR(10) OUTPUT, @osdistroOUT VARCHAR(20) OUTPUT, @osspOUT VARCHAR(25) OUTPUT, @archOUT smallint OUTPUT';\r\n", 69 | "\tEXECUTE sp_executesql @sqlcmd, @params, @osverOUT=@osver OUTPUT, @ostypeOUT=@ostype OUTPUT, @osdistroOUT=@osdistro OUTPUT, @osspOUT=@ossp OUTPUT, @archOUT=@arch OUTPUT;\r\n", 70 | "END\r\n", 71 | "ELSE\r\n", 72 | "BEGIN\r\n", 73 | "\tBEGIN TRY\r\n", 74 | "\t\tDECLARE @str VARCHAR(500), @str2 VARCHAR(500), @str3 VARCHAR(500)\r\n", 75 | "\t\tDECLARE @sysinfo TABLE (id int, \r\n", 76 | "\t\t\t[Name] NVARCHAR(256), \r\n", 77 | "\t\t\tInternal_Value bigint, \r\n", 78 | "\t\t\tCharacter_Value NVARCHAR(256));\r\n", 79 | "\t\t\t\r\n", 80 | "\t\tINSERT INTO @sysinfo\r\n", 81 | "\t\tEXEC xp_msver;\r\n", 82 | "\t\t\r\n", 83 | "\t\tSELECT @osver = LEFT(Character_Value, CHARINDEX(' ', Character_Value)-1) -- 5.2 is WS2003; 6.0 is WS2008; 6.1 is WS2008R2; 6.2 is WS2012, 6.3 is WS2012R2, 6.3 (14396) is WS2016\r\n", 84 | "\t\tFROM @sysinfo\r\n", 85 | "\t\tWHERE [Name] LIKE 'WindowsVersion%';\r\n", 86 | "\t\t\r\n", 87 | "\t\tSELECT @arch = CASE WHEN RTRIM(Character_Value) LIKE '%x64%' OR RTRIM(Character_Value) LIKE '%AMD64%' THEN 64\r\n", 88 | "\t\t\tWHEN RTRIM(Character_Value) LIKE '%x86%' OR RTRIM(Character_Value) LIKE '%32%' THEN 32\r\n", 89 | "\t\t\tWHEN RTRIM(Character_Value) LIKE '%IA64%' THEN 128 END\r\n", 90 | "\t\tFROM @sysinfo\r\n", 91 | "\t\tWHERE [Name] LIKE 'Platform%';\r\n", 92 | "\t\t\r\n", 93 | "\t\tSET @str = (SELECT @@VERSION)\r\n", 94 | "\t\tSELECT @str2 = RIGHT(@str, LEN(@str)-CHARINDEX('Windows',@str) + 1)\r\n", 95 | "\t\tSELECT @str3 = RIGHT(@str2, LEN(@str2)-CHARINDEX(': ',@str2))\r\n", 96 | "\t\tSELECT @ossp = LTRIM(LEFT(@str3, CHARINDEX(')',@str3) -1))\r\n", 97 | "\t\tSET @ostype = 'Windows'\r\n", 98 | "\tEND TRY\r\n", 99 | "\tBEGIN CATCH\r\n", 100 | "\t\tSELECT ERROR_NUMBER() AS ErrorNumber, ERROR_MESSAGE() AS ErrorMessage;\r\n", 101 | "\t\tSELECT @ErrorMessage = 'Windows Version and Architecture subsection - Error raised in TRY block. ' + ERROR_MESSAGE()\r\n", 102 | "\t\tRAISERROR (@ErrorMessage, 16, 1);\r\n", 103 | "\tEND CATCH\r\n", 104 | "END;\r\n", 105 | "\r\n", 106 | "DECLARE @machineinfo TABLE ([Value] NVARCHAR(256), [Data] NVARCHAR(256))\r\n", 107 | "\r\n", 108 | "IF @ostype = 'Windows'\r\n", 109 | "BEGIN\r\n", 110 | "\tINSERT INTO @machineinfo\r\n", 111 | "\tEXEC xp_instance_regread 'HKEY_LOCAL_MACHINE','HARDWARE\\DESCRIPTION\\System\\BIOS','SystemManufacturer';\r\n", 112 | "\tINSERT INTO @machineinfo\r\n", 113 | "\tEXEC xp_instance_regread 'HKEY_LOCAL_MACHINE','HARDWARE\\DESCRIPTION\\System\\BIOS','SystemProductName';\r\n", 114 | "\tINSERT INTO @machineinfo\r\n", 115 | "\tEXEC xp_instance_regread 'HKEY_LOCAL_MACHINE','HARDWARE\\DESCRIPTION\\System\\BIOS','SystemFamily';\r\n", 116 | "\tINSERT INTO @machineinfo\r\n", 117 | "\tEXEC xp_instance_regread 'HKEY_LOCAL_MACHINE','HARDWARE\\DESCRIPTION\\System\\BIOS','BIOSVendor';\r\n", 118 | "\tINSERT INTO @machineinfo\r\n", 119 | "\tEXEC xp_instance_regread 'HKEY_LOCAL_MACHINE','HARDWARE\\DESCRIPTION\\System\\BIOS','BIOSVersion';\r\n", 120 | "\tINSERT INTO @machineinfo\r\n", 121 | "\tEXEC xp_instance_regread 'HKEY_LOCAL_MACHINE','HARDWARE\\DESCRIPTION\\System\\BIOS','BIOSReleaseDate';\r\n", 122 | "\tINSERT INTO @machineinfo\r\n", 123 | "\tEXEC xp_instance_regread 'HKEY_LOCAL_MACHINE','HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0','ProcessorNameString';\r\n", 124 | "END\r\n", 125 | "\r\n", 126 | "SELECT @SystemManufacturer = [Data] FROM @machineinfo WHERE [Value] = 'SystemManufacturer';\r\n", 127 | "\r\n", 128 | "SELECT 'Information' AS [Category], 'Machine' AS [Information], \r\n", 129 | "\tCASE @osver WHEN '5.2' THEN 'XP/WS2003'\r\n", 130 | "\t\tWHEN '6.0' THEN 'Vista/WS2008'\r\n", 131 | "\t\tWHEN '6.1' THEN 'W7/WS2008R2'\r\n", 132 | "\t\tWHEN '6.2' THEN 'W8/WS2012'\r\n", 133 | "\t\tWHEN '6.3' THEN 'W8.1/WS2012R2'\r\n", 134 | "\t\tWHEN '10.0' THEN 'W10/WS2016'\r\n", 135 | "\t\tELSE @ostype + ' ' + @osdistro\r\n", 136 | "\tEND AS [OS_Version],\r\n", 137 | "\tCASE WHEN @ostype = 'Windows' THEN @ossp ELSE @osver END AS [Service_Pack_Level],\r\n", 138 | "\t@arch AS [Architecture],\r\n", 139 | "\tSERVERPROPERTY('MachineName') AS [Machine_Name],\r\n", 140 | "\tSERVERPROPERTY('ComputerNamePhysicalNetBIOS') AS [NetBIOS_Name],\r\n", 141 | "\t@SystemManufacturer AS [System_Manufacturer],\r\n", 142 | "\t(SELECT [Data] FROM @machineinfo WHERE [Value] = 'SystemFamily') AS [System_Family],\r\n", 143 | "\t(SELECT [Data] FROM @machineinfo WHERE [Value] = 'SystemProductName') AS [System_ProductName],\r\n", 144 | "\t(SELECT [Data] FROM @machineinfo WHERE [Value] = 'BIOSVendor') AS [BIOS_Vendor],\r\n", 145 | "\t(SELECT [Data] FROM @machineinfo WHERE [Value] = 'BIOSVersion') AS [BIOS_Version],\r\n", 146 | "\t(SELECT [Data] FROM @machineinfo WHERE [Value] = 'BIOSReleaseDate') AS [BIOS_Release_Date],\r\n", 147 | "\t(SELECT [Data] FROM @machineinfo WHERE [Value] = 'ProcessorNameString') AS [Processor_Name];" 148 | ], 149 | "metadata": { 150 | "azdata_cell_guid": "43904f2e-6b5b-4952-9b63-c5f2b5d94225" 151 | }, 152 | "outputs": [], 153 | "execution_count": null 154 | } 155 | ] 156 | } -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 3 General Information/GEN-GetRecentBackups.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | }, 12 | "extensions": { 13 | "azuredatastudio": { 14 | "version": 1, 15 | "views": [] 16 | } 17 | } 18 | }, 19 | "nbformat_minor": 2, 20 | "nbformat": 4, 21 | "cells": [ 22 | { 23 | "cell_type": "markdown", 24 | "source": [ 25 | "![CH3-ADS.png](.\\Media\\CH3-ADS.png)\n", 26 | "\n", 27 | "# Get Recent Backup Information\n", 28 | "\n", 29 | "This notebook provides a list of database backups and the type of backups that have recently been performed on this SQL instance.\n", 30 | "\n", 31 | "### Run the Code block below\n", 32 | "\n", 33 | "1. Click the run icon below\n", 34 | "2. If ADS prompts you for a connection, enter the correct SQL Server and authentication account\n", 35 | "3. View the results of the query by scrolling down to the results set" 36 | ], 37 | "metadata": { 38 | "azdata_cell_guid": "4905b175-4e5d-4e4f-9958-aafb4faecf8b" 39 | }, 40 | "attachments": {} 41 | }, 42 | { 43 | "cell_type": "code", 44 | "source": [ 45 | "SET NOCOUNT ON;\r\n", 46 | "SET ANSI_WARNINGS ON;\r\n", 47 | "SET QUOTED_IDENTIFIER ON;\r\n", 48 | "SET DATEFORMAT mdy;\r\n", 49 | "\r\n", 50 | "DECLARE @sqlcmd NVARCHAR(max), @params NVARCHAR(600)\r\n", 51 | "DECLARE @sqlmajorver int\r\n", 52 | "\r\n", 53 | "SELECT @sqlmajorver = CONVERT(int, (@@microsoftversion / 0x1000000) & 0xff);\r\n", 54 | "\r\n", 55 | "IF @sqlmajorver > 10\r\n", 56 | "BEGIN\r\n", 57 | "\tSET @sqlcmd = N'SELECT ''Information'' AS [Category], ''Backups_since_last_Full'' AS [Information], \r\n", 58 | "[database_name] AS [Database_Name], CASE WHEN type = ''D'' THEN ''Database''\r\n", 59 | "\tWHEN type = ''I'' THEN ''Diff_Database''\r\n", 60 | "\tWHEN type = ''L'' THEN ''Log''\r\n", 61 | "\tWHEN type = ''F'' THEN ''File''\r\n", 62 | "\tWHEN type = ''G'' THEN ''Diff_file''\r\n", 63 | "\tWHEN type = ''P'' THEN ''Partial''\r\n", 64 | "\tWHEN type = ''Q'' THEN ''Diff_partial''\r\n", 65 | "\tELSE NULL END AS [bck_type],\r\n", 66 | "[backup_start_date], [backup_finish_date],\r\n", 67 | "CONVERT(decimal(20,2),backup_size/1024.00/1024.00) AS [backup_size_MB],\r\n", 68 | "CONVERT(decimal(20,2),compressed_backup_size/1024.00/1024.00) AS [compressed_backup_size_MB],\r\n", 69 | "[recovery_model], [user_name],\r\n", 70 | "database_backup_lsn AS [full_base_lsn], [differential_base_lsn], [expiration_date], \r\n", 71 | "[is_password_protected], [has_backup_checksums], [is_readonly], is_copy_only, [has_incomplete_metadata] AS [Tail_log]\r\n", 72 | "FROM msdb.dbo.backupset bck1 (NOLOCK)\r\n", 73 | "WHERE is_copy_only = 0 -- No COPY_ONLY backups\r\n", 74 | "AND backup_start_date >= (SELECT MAX(backup_start_date) FROM msdb.dbo.backupset bck2 (NOLOCK) WHERE bck2.type IN (''D'',''F'',''P'') AND is_copy_only = 0 AND bck1.database_name = bck2.database_name)\r\n", 75 | "ORDER BY database_name, backup_start_date DESC'\r\n", 76 | "END\r\n", 77 | "ELSE \r\n", 78 | "BEGIN\r\n", 79 | "\tSET @sqlcmd = N'SELECT ''Information'' AS [Category], ''Backups_since_last_Full'' AS [Information], \r\n", 80 | "[database_name] AS [Database_Name], CASE WHEN type = ''D'' THEN ''Database''\r\n", 81 | "\tWHEN type = ''I'' THEN ''Diff_Database''\r\n", 82 | "\tWHEN type = ''L'' THEN ''Log''\r\n", 83 | "\tWHEN type = ''F'' THEN ''File''\r\n", 84 | "\tWHEN type = ''G'' THEN ''Diff_file''\r\n", 85 | "\tWHEN type = ''P'' THEN ''Partial''\r\n", 86 | "\tWHEN type = ''Q'' THEN ''Diff_partial''\r\n", 87 | "\tELSE NULL END AS [bck_type],\r\n", 88 | "[backup_start_date], [backup_finish_date], \r\n", 89 | "CONVERT(decimal(20,2),backup_size/1024.00/1024.00) AS [backup_size_MB],\r\n", 90 | "''NA'' AS [compressed_backup_size_MB], \r\n", 91 | "[recovery_model], [user_name],\r\n", 92 | "database_backup_lsn AS [full_base_lsn], [differential_base_lsn], [expiration_date], \r\n", 93 | "[is_password_protected], [has_backup_checksums], [is_readonly], is_copy_only, [has_incomplete_metadata] AS [Tail_log]\r\n", 94 | "FROM msdb.dbo.backupset bck1 (NOLOCK)\r\n", 95 | "WHERE is_copy_only = 0 -- No COPY_ONLY backups\r\n", 96 | "AND backup_start_date >= (SELECT MAX(backup_start_date) FROM msdb.dbo.backupset bck2 (NOLOCK) WHERE bck2.type IN (''D'',''F'',''P'') AND is_copy_only = 0 AND bck1.database_name = bck2.database_name)\r\n", 97 | "ORDER BY database_name, backup_start_date DESC'\r\n", 98 | "END;\r\n", 99 | "\r\n", 100 | "EXECUTE sp_executesql @sqlcmd;" 101 | ], 102 | "metadata": { 103 | "azdata_cell_guid": "3b899108-8db0-4405-8869-f188f20d2a74", 104 | "tags": [] 105 | }, 106 | "outputs": [], 107 | "execution_count": null 108 | } 109 | ] 110 | } -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 3 General Information/GEN-GetResourceGov.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | }, 12 | "extensions": { 13 | "azuredatastudio": { 14 | "version": 1, 15 | "views": [] 16 | } 17 | } 18 | }, 19 | "nbformat_minor": 2, 20 | "nbformat": 4, 21 | "cells": [ 22 | { 23 | "cell_type": "markdown", 24 | "source": [ 25 | "![CH3-ADS.png](.\\Media\\CH3-ADS.png)\n", 26 | "\n", 27 | "# Get Resource Governor Information\n", 28 | "\n", 29 | "This notebook provides a list of Classifier Functions, Resource Pools, and Workload Groups associated with the Resource Governor on this SQL Instance if configured.   \n", 30 | "\n", 31 | "Resource Governor enables you to manage SQL Server workloads and resources by specifying limits on resource consumption by incoming requests. In the Resource Governor context, workload is a set of similarly sized queries or requests that can, and should be, treated as a single entity. This is not a requirement, but the more uniform the resource usage pattern of a workload is, the more benefit you are likely to derive from Resource Governor. Resource limits can be reconfigured in real time with minimal impact on workloads that are executing. \n", 32 | "\n", 33 | "In an environment where multiple distinct workloads are present on the same server, Resource Governor enables you to differentiate these workloads and allocate shared resources as they are requested, based on the limits that you specify. These resources are CPU, physical I/O, and memory. \n", 34 | "\n", 35 | "By using Resource Governor, you can:\n", 36 | "\n", 37 | "- Provide multitenancy and resource isolation on single instances of SQL Server that serve multiple client workloads. That is, you can divide the available resources on a server among the workloads and minimize the problems that can occur when workloads compete for resources.\n", 38 | "- Provide predictable performance and support SLAs for workload tenants in a multi-workload and multi-user environment.\n", 39 | "- Isolate and limit runaway queries or throttle I/O resources for operations such as DBCC CHECKDB that can saturate the I/O subsystem and negatively impact other workloads.\n", 40 | "- Add fine-grained resource tracking for resource usage chargebacks and provide predictable billing to the consumers of the server resources.\n", 41 | "\n", 42 | "### Run the Code block below\n", 43 | "\n", 44 | "1. Click the run icon below\n", 45 | "2. If ADS prompts you for a connection, enter the correct SQL Server and authentication account\n", 46 | "3. View the results of the query by scrolling down to the results set" 47 | ], 48 | "metadata": { 49 | "azdata_cell_guid": "e7860574-c524-492e-bf4b-7eda82b7e916" 50 | }, 51 | "attachments": {} 52 | }, 53 | { 54 | "cell_type": "code", 55 | "source": [ 56 | "SET NOCOUNT ON;\r\n", 57 | "SET ANSI_WARNINGS ON;\r\n", 58 | "SET QUOTED_IDENTIFIER ON;\r\n", 59 | "\r\n", 60 | "DECLARE @sqlmajorver int\r\n", 61 | "DECLARE @sqlcmd NVARCHAR(max), @params NVARCHAR(600)\r\n", 62 | "\r\n", 63 | "SELECT @sqlmajorver = CONVERT(int, (@@microsoftversion / 0x1000000) & 0xff);\r\n", 64 | "\r\n", 65 | "IF @sqlmajorver > 9\r\n", 66 | "BEGIN\r\n", 67 | "\tSELECT 'Information' AS [Category], 'RG_Classifier_Function' AS [Information], CASE WHEN classifier_function_id = 0 THEN 'Default_Configuration' ELSE OBJECT_SCHEMA_NAME(classifier_function_id) + '.' + OBJECT_NAME(classifier_function_id) END AS classifier_function, is_reconfiguration_pending\r\n", 68 | "\tFROM sys.dm_resource_governor_configuration\r\n", 69 | "\r\n", 70 | "\tSET @sqlcmd = 'SELECT ''Information'' AS [Category], ''RG_Resource_Pool'' AS [Information], rp.pool_id, name, statistics_start_time, total_cpu_usage_ms, cache_memory_kb, compile_memory_kb, \r\n", 71 | "\tused_memgrant_kb, total_memgrant_count, total_memgrant_timeout_count, active_memgrant_count, active_memgrant_kb, memgrant_waiter_count, max_memory_kb, used_memory_kb, target_memory_kb, \r\n", 72 | "\tout_of_memory_count, min_cpu_percent, max_cpu_percent, min_memory_percent, max_memory_percent' + CASE WHEN @sqlmajorver > 10 THEN ', cap_cpu_percent, rpa.processor_group, rpa.scheduler_mask' ELSE '' END + '\r\n", 73 | "FROM sys.dm_resource_governor_resource_pools rp' + CASE WHEN @sqlmajorver > 10 THEN ' LEFT JOIN sys.dm_resource_governor_resource_pool_affinity rpa ON rp.pool_id = rpa.pool_id' ELSE '' END\r\n", 74 | "\tEXECUTE sp_executesql @sqlcmd\r\n", 75 | "\r\n", 76 | "\tSET @sqlcmd = 'SELECT ''Information'' AS [Category], ''RG_Workload_Groups'' AS [Information], group_id, name, pool_id, statistics_start_time, total_request_count, total_queued_request_count, \r\n", 77 | "\tactive_request_count, queued_request_count, total_cpu_limit_violation_count, total_cpu_usage_ms, max_request_cpu_time_ms, blocked_task_count, total_lock_wait_count, \r\n", 78 | "\ttotal_lock_wait_time_ms, total_query_optimization_count, total_suboptimal_plan_generation_count, total_reduced_memgrant_count, max_request_grant_memory_kb, \r\n", 79 | "\tactive_parallel_thread_count, importance, request_max_memory_grant_percent, request_max_cpu_time_sec, request_memory_grant_timeout_sec, \r\n", 80 | "\tgroup_max_requests, max_dop' + CASE WHEN @sqlmajorver > 10 THEN ', effective_max_dop' ELSE '' END + ' \r\n", 81 | "FROM sys.dm_resource_governor_workload_groups'\r\n", 82 | "\tEXECUTE sp_executesql @sqlcmd\r\n", 83 | "END;" 84 | ], 85 | "metadata": { 86 | "azdata_cell_guid": "7a402665-7117-4f32-adc0-e884830d4e4a" 87 | }, 88 | "outputs": [], 89 | "execution_count": null 90 | } 91 | ] 92 | } -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 3 General Information/GEN-GetSockets.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | }, 12 | "extensions": { 13 | "azuredatastudio": { 14 | "version": 1, 15 | "views": [] 16 | } 17 | } 18 | }, 19 | "nbformat_minor": 2, 20 | "nbformat": 4, 21 | "cells": [ 22 | { 23 | "cell_type": "markdown", 24 | "source": [ 25 | "![CH3-ADS.png](.\\Media\\CH3-ADS.png)\n", 26 | "\n", 27 | "# Get CPU and Socket Information\n", 28 | "\n", 29 | "This notebook displays information about the CPU's, Sockets, and NUMA nodes on this SQL Server.\n", 30 | "\n", 31 | "### Run the Code block below\n", 32 | "\n", 33 | "1. Click the run icon below\n", 34 | "2. If ADS prompts you for a connection, enter the correct SQL Server and authentication account\n", 35 | "3. View the results of the query by scrolling down to the results set" 36 | ], 37 | "metadata": { 38 | "azdata_cell_guid": "7abe18cd-7f86-457a-923f-dad49f1ac3f1" 39 | }, 40 | "attachments": {} 41 | }, 42 | { 43 | "cell_type": "code", 44 | "source": [ 45 | "SET NOCOUNT ON;\r\n", 46 | "SET ANSI_WARNINGS ON;\r\n", 47 | "SET QUOTED_IDENTIFIER ON;\r\n", 48 | "\r\n", 49 | "DECLARE @cpucount int, @numa int, @affined_cpus int, @affinitymask NVARCHAR(64), @affinity64mask NVARCHAR(1024)--, @cpuover32 int\r\n", 50 | "DECLARE @i int, @cpuaffin VARCHAR(300), @cpuaffin_fixed VARCHAR(300), @ostype VARCHAR(10), @SystemManufacturer VARCHAR(128)\r\n", 51 | "DECLARE @sqlcmd NVARCHAR(max), @params NVARCHAR(600)\r\n", 52 | "DECLARE @sqlmajorver int, @sqlminorver int, @sqlbuild int\r\n", 53 | "DECLARE @ErrorMessage NVARCHAR(4000)\r\n", 54 | "DECLARE @machineinfo TABLE ([Value] NVARCHAR(256), [Data] NVARCHAR(256))\r\n", 55 | "\r\n", 56 | "SELECT @sqlmajorver = CONVERT(int, (@@microsoftversion / 0x1000000) & 0xff);\r\n", 57 | "SELECT @sqlminorver = CONVERT(int, (@@microsoftversion / 0x10000) & 0xff);\r\n", 58 | "SELECT @sqlbuild = CONVERT(int, @@microsoftversion & 0xffff);\r\n", 59 | "\r\n", 60 | "SELECT @numa = COUNT(DISTINCT parent_node_id) FROM sys.dm_os_schedulers WHERE scheduler_id < 255 AND parent_node_id < 64;\r\n", 61 | "SELECT @cpucount = COUNT(cpu_id) FROM sys.dm_os_schedulers WHERE scheduler_id < 255 AND parent_node_id < 64;\r\n", 62 | "\r\n", 63 | "IF (@sqlmajorver >= 11 AND @sqlmajorver < 14) OR (@sqlmajorver = 10 AND @sqlminorver = 50 AND @sqlbuild >= 2500)\r\n", 64 | "BEGIN\r\n", 65 | "\tSET @ostype = 'Windows'\r\n", 66 | "END\r\n", 67 | "ELSE IF @sqlmajorver >= 14\r\n", 68 | "BEGIN\r\n", 69 | "\tSET @sqlcmd = N'SELECT @ostypeOUT = host_platform FROM sys.dm_os_host_info (NOLOCK)';\r\n", 70 | "\tSET @params = N'@ostypeOUT VARCHAR(10) OUTPUT';\r\n", 71 | "\tEXECUTE sp_executesql @sqlcmd, @params, @ostypeOUT=@ostype OUTPUT;\r\n", 72 | "END\r\n", 73 | "\r\n", 74 | "IF @ostype = 'Windows'\r\n", 75 | "BEGIN\r\n", 76 | "\tINSERT INTO @machineinfo\r\n", 77 | "\tEXEC xp_instance_regread 'HKEY_LOCAL_MACHINE','HARDWARE\\DESCRIPTION\\System\\BIOS','SystemManufacturer';\r\n", 78 | "\tINSERT INTO @machineinfo\r\n", 79 | "\tEXEC xp_instance_regread 'HKEY_LOCAL_MACHINE','HARDWARE\\DESCRIPTION\\System\\BIOS','BIOSVendor';\r\n", 80 | "\tINSERT INTO @machineinfo\r\n", 81 | "\tEXEC xp_instance_regread 'HKEY_LOCAL_MACHINE','HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0','ProcessorNameString';\r\n", 82 | "END;\r\n", 83 | "\r\n", 84 | "SELECT @SystemManufacturer = [Data] FROM @machineinfo WHERE [Value] = 'SystemManufacturer';\r\n", 85 | "\r\n", 86 | ";WITH bits AS \r\n", 87 | "(SELECT 7 AS N, 128 AS E UNION ALL SELECT 6, 64 UNION ALL \r\n", 88 | "SELECT 5, 32 UNION ALL SELECT 4, 16 UNION ALL SELECT 3, 8 UNION ALL \r\n", 89 | "SELECT 2, 4 UNION ALL SELECT 1, 2 UNION ALL SELECT 0, 1), \r\n", 90 | "bytes AS \r\n", 91 | "(SELECT 1 M UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL \r\n", 92 | "SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL \r\n", 93 | "SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9)\r\n", 94 | "-- CPU Affinity is shown highest to lowest CPU ID\r\n", 95 | "SELECT @affinitymask = CASE WHEN [value] = 0 THEN REPLICATE('1', @cpucount)\r\n", 96 | "\tELSE RIGHT((SELECT ((CONVERT(tinyint, SUBSTRING(CONVERT(binary(9), [value]), M, 1)) & E) / E) AS [text()] \r\n", 97 | "\t\tFROM bits CROSS JOIN bytes\r\n", 98 | "\t\tORDER BY M, N DESC\r\n", 99 | "\t\tFOR XML PATH('')), @cpucount) END\r\n", 100 | "FROM sys.configurations (NOLOCK)\r\n", 101 | "WHERE name = 'affinity mask';\r\n", 102 | "\r\n", 103 | "IF @cpucount > 32\r\n", 104 | "BEGIN\r\n", 105 | "\t;WITH bits AS \r\n", 106 | "\t(SELECT 7 AS N, 128 AS E UNION ALL SELECT 6, 64 UNION ALL \r\n", 107 | "\tSELECT 5, 32 UNION ALL SELECT 4, 16 UNION ALL SELECT 3, 8 UNION ALL \r\n", 108 | "\tSELECT 2, 4 UNION ALL SELECT 1, 2 UNION ALL SELECT 0, 1), \r\n", 109 | "\tbytes AS \r\n", 110 | "\t(SELECT 1 M UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL \r\n", 111 | "\tSELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL \r\n", 112 | "\tSELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9)\r\n", 113 | "\t-- CPU Affinity is shown highest to lowest CPU ID\r\n", 114 | "\tSELECT @affinity64mask = CASE WHEN [value] = 0 THEN REPLICATE('1', @cpucount)\r\n", 115 | "\t\tELSE RIGHT((SELECT ((CONVERT(tinyint, SUBSTRING(CONVERT(binary(9), [value]), M, 1)) & E) / E) AS [text()] \r\n", 116 | "\t\t\tFROM bits CROSS JOIN bytes\r\n", 117 | "\t\t\tORDER BY M, N DESC\r\n", 118 | "\t\t\tFOR XML PATH('')), @cpucount) END\r\n", 119 | "\tFROM sys.configurations (NOLOCK)\r\n", 120 | "\tWHERE name = 'affinity64 mask';\r\n", 121 | "END;\r\n", 122 | "\r\n", 123 | "/*\r\n", 124 | "IF @cpucount > 32\r\n", 125 | "SELECT @cpuover32 = ABS(LEN(@affinity64mask) - (@cpucount-32))\r\n", 126 | "\r\n", 127 | "SELECT @cpuaffin = CASE WHEN @cpucount > 32 THEN REVERSE(LEFT(REVERSE(@affinity64mask),@cpuover32)) + RIGHT(@affinitymask,32) ELSE RIGHT(@affinitymask,@cpucount) END\r\n", 128 | "*/\r\n", 129 | "\r\n", 130 | "SELECT @cpuaffin = CASE WHEN @cpucount > 32 THEN @affinity64mask ELSE @affinitymask END\r\n", 131 | "SELECT @affined_cpus = COUNT(cpu_id) FROM sys.dm_os_schedulers WHERE is_online = 1 AND scheduler_id < 255 AND parent_node_id < 64;\r\n", 132 | "\r\n", 133 | "SET @cpuaffin_fixed = @cpuaffin\r\n", 134 | "SET @i = CEILING(@cpucount*1.00/@numa) + 1\r\n", 135 | "WHILE @i < @cpucount + @numa\r\n", 136 | "BEGIN\r\n", 137 | "\tIF (@cpucount + @numa) - @i >= CEILING(@cpucount*1.00/@numa)\r\n", 138 | "\tBEGIN\r\n", 139 | "\t\tSELECT @cpuaffin_fixed = STUFF(@cpuaffin_fixed, @i, 1, '_' + SUBSTRING(@cpuaffin_fixed, @i, 1))\r\n", 140 | "\tEND\r\n", 141 | "\tELSE\r\n", 142 | "\tBEGIN\r\n", 143 | "\t\tSELECT @cpuaffin_fixed = STUFF(@cpuaffin_fixed, @i, CEILING(@cpucount*1.00/@numa), SUBSTRING(@cpuaffin_fixed, @i, CEILING(@cpucount*1.00/@numa)))\r\n", 144 | "\tEND\r\n", 145 | "\r\n", 146 | "\tSET @i = @i + CEILING(@cpucount*1.00/@numa) + 1\r\n", 147 | "END;\r\n", 148 | "\r\n", 149 | "SELECT 'Processor_checks' AS [Category], 'Processor_Summary' AS [Information], cpu_count AS [Logical_CPU_Count], hyperthread_ratio AS [Cores2Socket_Ratio],\r\n", 150 | "\tcpu_count/hyperthread_ratio AS [CPU_Sockets], \r\n", 151 | "\tCASE WHEN @numa > 1 THEN (SELECT COUNT(DISTINCT parent_node_id) FROM sys.dm_os_schedulers WHERE scheduler_id < 255 AND parent_node_id < 64) ELSE 0 END AS [NUMA_Nodes],\r\n", 152 | "\t@affined_cpus AS [Affined_Processors], \r\n", 153 | "\t-- Processor Affinity is shown highest to lowest Processor ID\r\n", 154 | "\t@cpuaffin_fixed AS Affinity_Mask_Bitmask\r\n", 155 | "FROM sys.dm_os_sys_info (NOLOCK)\r\n", 156 | "OPTION (RECOMPILE);" 157 | ], 158 | "metadata": { 159 | "azdata_cell_guid": "ca599c6a-bf78-43c4-b765-6e989fce9be3" 160 | }, 161 | "outputs": [], 162 | "execution_count": null 163 | } 164 | ] 165 | } -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 3 General Information/GEN-GetSystemConfig.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | }, 12 | "extensions": { 13 | "azuredatastudio": { 14 | "version": 1, 15 | "views": [] 16 | } 17 | } 18 | }, 19 | "nbformat_minor": 2, 20 | "nbformat": 4, 21 | "cells": [ 22 | { 23 | "cell_type": "markdown", 24 | "source": [ 25 | "![CH3-ADS.png](.\\Media\\CH3-ADS.png)\n", 26 | "\n", 27 | "# Get System Confuration Information\n", 28 | "\n", 29 | "This notebook queries the sys.configurations catalog view.  This view can be used to determine the config\\_value (the value column), the run\\_value (the value\\_in\\_use column), and whether the configuration option is dynamic (does not require a server engine restart or the is\\_dynamic column).\n", 30 | "\n", 31 | "If the value equals the change for the configuration option you made but the value\\_in\\_use is not the same, either the RECONFIGURE command was not run or has failed, or the server engine must be restarted.  There are configuration options where the value and value\\_in\\_use may not be the same and this is expected behavior. For example:\n", 32 | "\n", 33 | "- \"max server memory (MB)\" - The default configured value of 0 shows up as value\\_in\\_use = 2147483647\n", 34 | "- \"min server memory (MB)\" - The default configured value of 0 may show up as value\\_in\\_use = 8 (32bit) or 16 (64bit). In some cases, the value\\_in\\_use is 0. In this situation, the \"true\" value\\_in\\_use is 8 (32bit) or 16 (64bit).\n", 35 | "\n", 36 | "The is\\_dynamic column can be used to determine if the configuration option requires a restart. is\\_dynamic=1 means that when the RECONFIGURE(T-SQL) commnad is executed, the new value will take effect \"immediately\" (in some cases the server engine may not evaluate the new value immediately but will do so in the normal course of its execution). is\\_dynamic=0 means the the changed configuration value will not take effect until the server is restarted even though the RECONFIGURE(T-SQL) command was executed. \n", 37 | "\n", 38 | "For a configuration option that is not dynamic there is no way to tell if the RECONFIGURE(T-SQL) command has been run to perform the first step of installing the configuration change. Before you restart SQL Server to install a configuration change, run the RECONFIGURE(T-SQL) command to ensure all configuration changes will take effect after a SQL Server restart. \n", 39 | "\n", 40 | "Run the Code block below\n", 41 | "\n", 42 | "1. Click the run icon below\n", 43 | "2. If ADS prompts you for a connection, enter the correct SQL Server and authentication account\n", 44 | "3. View the results of the query by scrolling down to the results set" 45 | ], 46 | "metadata": { 47 | "azdata_cell_guid": "161cba2f-40fd-4d57-84d4-8c4dd5bc7489" 48 | }, 49 | "attachments": {} 50 | }, 51 | { 52 | "cell_type": "code", 53 | "source": [ 54 | "SET NOCOUNT ON;\r\n", 55 | "SET ANSI_WARNINGS ON;\r\n", 56 | "SET QUOTED_IDENTIFIER ON;\r\n", 57 | "\r\n", 58 | "SELECT 'Information' AS [Category], 'All_System_Configurations' AS [Information],\r\n", 59 | "\tname AS [Name],\r\n", 60 | "\tconfiguration_id AS [Number],\r\n", 61 | "\tminimum AS [Minimum],\r\n", 62 | "\tmaximum AS [Maximum],\r\n", 63 | "\tis_dynamic AS [Dynamic],\r\n", 64 | "\tis_advanced AS [Advanced],\r\n", 65 | "\tvalue AS [ConfigValue],\r\n", 66 | "\tvalue_in_use AS [RunValue],\r\n", 67 | "\tdescription AS [Description]\r\n", 68 | "FROM sys.configurations (NOLOCK)\r\n", 69 | "ORDER BY name OPTION (RECOMPILE);" 70 | ], 71 | "metadata": { 72 | "azdata_cell_guid": "7606324c-0fbb-4f2d-9870-b84f9268df56" 73 | }, 74 | "outputs": [], 75 | "execution_count": null 76 | } 77 | ] 78 | } -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 3 General Information/GEN-GetUptime.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | }, 12 | "extensions": { 13 | "azuredatastudio": { 14 | "version": 1, 15 | "views": [] 16 | } 17 | } 18 | }, 19 | "nbformat_minor": 2, 20 | "nbformat": 4, 21 | "cells": [ 22 | { 23 | "cell_type": "markdown", 24 | "source": [ 25 | "![CH3-ADS.png](.\\Media\\CH3-ADS.png)\n", 26 | "\n", 27 | "# Get Uptime Information\n", 28 | "\n", 29 | "This notebook provides details on how long this SQL Server has been online since last reboot.\n", 30 | "\n", 31 | "### Run the Code block below\n", 32 | "\n", 33 | "1. Click the run icon below\n", 34 | "2. If ADS prompts you for a connection, enter the correct SQL Server and authentication account\n", 35 | "3. View the results of the query by scrolling down to the results set" 36 | ], 37 | "metadata": { 38 | "azdata_cell_guid": "a148d234-76f3-4599-b724-b1b38d1a7d91" 39 | }, 40 | "attachments": {} 41 | }, 42 | { 43 | "cell_type": "code", 44 | "source": [ 45 | "SET NOCOUNT ON;\r\n", 46 | "SET ANSI_WARNINGS ON;\r\n", 47 | "SET QUOTED_IDENTIFIER ON;\r\n", 48 | "\r\n", 49 | "DECLARE @sqlcmd NVARCHAR(max), @params NVARCHAR(600), @sqlmajorver int\r\n", 50 | "DECLARE @UpTime VARCHAR(12),@StartDate DATETIME\r\n", 51 | "\r\n", 52 | "SELECT @sqlmajorver = CONVERT(int, (@@microsoftversion / 0x1000000) & 0xff);\r\n", 53 | "\r\n", 54 | "IF @sqlmajorver < 10\r\n", 55 | "BEGIN\r\n", 56 | "\tSET @sqlcmd = N'SELECT @UpTimeOUT = DATEDIFF(mi, login_time, GETDATE()), @StartDateOUT = login_time FROM master..sysprocesses (NOLOCK) WHERE spid = 1';\r\n", 57 | "END\r\n", 58 | "ELSE\r\n", 59 | "BEGIN\r\n", 60 | "\tSET @sqlcmd = N'SELECT @UpTimeOUT = DATEDIFF(mi,sqlserver_start_time,GETDATE()), @StartDateOUT = sqlserver_start_time FROM sys.dm_os_sys_info (NOLOCK)';\r\n", 61 | "END\r\n", 62 | "\r\n", 63 | "SET @params = N'@UpTimeOUT VARCHAR(12) OUTPUT, @StartDateOUT DATETIME OUTPUT';\r\n", 64 | "\r\n", 65 | "EXECUTE sp_executesql @sqlcmd, @params, @UpTimeOUT=@UpTime OUTPUT, @StartDateOUT=@StartDate OUTPUT;\r\n", 66 | "\r\n", 67 | "SELECT 'Information' AS [Category], 'Uptime' AS [Information], GETDATE() AS [Current_Time], @StartDate AS Last_Startup, CONVERT(VARCHAR(4),@UpTime/60/24) + 'd ' + CONVERT(VARCHAR(4),@UpTime/60%24) + 'hr ' + CONVERT(VARCHAR(4),@UpTime%60) + 'min' AS Uptime" 68 | ], 69 | "metadata": { 70 | "azdata_cell_guid": "8627f902-902a-4715-a21d-6b93b0cb0723" 71 | }, 72 | "outputs": [], 73 | "execution_count": null 74 | } 75 | ] 76 | } -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 3 General Information/Media/CH3-ADS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 3 General Information/Media/CH3-ADS.png -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 3 General Information/readme.md: -------------------------------------------------------------------------------- 1 | # Welcome to Chapter 3: General Information Queries 2 | 3 | Chapter 3 contains notebooks providing you with general informational and some diagnostice information. You can either click the hyperlink below, or click directly on the notebook in the naviation pane. 4 | 5 | Add more content here 6 | 7 | ## Notebooks in this Chapter 8 | 9 | - [GEN-GatherInformation](../Chapter 3 General Information/GEN-GatherInformation.ipynb) 10 | - [GEN-GetBPConsumers](../Chapter 3 General Information/GEN-GetBPConsumers.ipynb) 11 | - [GEN-GetBufferPool](../Chapter 3 General Information/GEN-GetBufferPool.ipynb) 12 | - [GEN-GetCPULast2Hours](../Chapter 3 General Information/GEN-GetCPULast2Hours.ipynb) 13 | - [GEN-GetDBGrowth](../Chapter 3 General Information/GEN-GetDBGrowth.ipynb) 14 | - [GEN-GetDBInfo](../Chapter 3 General Information/GEN-GetDBInfo.ipynb) 15 | - [GEN-GetDBTriggers](../Chapter 3 General Information/GEN-GetDBTriggers.ipynb) 16 | - [GEN-GetDiskSpace](../Chapter 3 General Information/GEN-GetDiskSpace.ipynb) 17 | - [GEN-GetFeatureUsage](../Chapter 3 General Information/GEN-GetFeatureUsage.ipynb) 18 | - [GEN-GetHAInfo](../Chapter 3 General Information/GEN-GetHAInfo.ipynb) 19 | - [GEN-GetInstanceInfo](../Chapter 3 General Information/GEN-GetInstanceInfo.ipynb) 20 | - [GEN-GetLinkedServers](../Chapter 3 General Information/GEN-GetLinkedServers.ipynb) 21 | - [GEN-GetLogonTriggers](../Chapter 3 General Information/GEN-GetLogonTriggers.ipynb) 22 | - [GEN-GetLowMemoryEvents](../Chapter 3 General Information/GEN-GetLowMemoryEvents.ipynb) 23 | - [GEN-GetLPIM](../Chapter 3 General Information/GEN-GetLPIM.ipynb) 24 | - [GEN-GetMAXDOP](../Chapter 3 General Information/GEN-GetMAXDOP.ipynb) 25 | - [GEN-GetMemoryAlloc](../Chapter 3 General Information/GEN-GetMemoryAlloc.ipynb) 26 | - [GEN-GetOSVersion](../Chapter 3 General Information/GEN-GetOSVersion.ipynb) 27 | - [GEN-GetProcNUMA](../Chapter 3 General Information/GEN-GetProcNUMA.ipynb) 28 | - [GEN-GetRecentBackups](../Chapter 3 General Information/GEN-GetRecentBackups.ipynb) 29 | - [GEN-GetResourceGov](../Chapter 3 General Information/GEN-GetResourceGov.ipynb) 30 | - [GEN-GetServerMemory](../Chapter 3 General Information/GEN-GetServerMemory.ipynb) 31 | - [GEN-GetSockets](../Chapter 3 General Information/GEN-GetSockets.ipynb) 32 | - [GEN-GetSystemConfig](../Chapter 3 General Information/GEN-GetSystemConfig.ipynb) 33 | - [GEN-GetUptime](../Chapter 3 General Information/GEN-GetUptime.ipynb) 34 | - [GEN-PreReqs](../Chapter 3 General Information/GEN-PreReqs.ipynb) 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 4 Diagnostics/DIAG-Memory.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | }, 12 | "extensions": { 13 | "azuredatastudio": { 14 | "version": 1, 15 | "views": [] 16 | } 17 | } 18 | }, 19 | "nbformat_minor": 2, 20 | "nbformat": 4, 21 | "cells": [ 22 | { 23 | "cell_type": "markdown", 24 | "source": [ 25 | "![CH4-ADS.png](.\\Media\\CH4-ADS.png)\r\n", 26 | "\r\n", 27 | "## Get information on location, time and size of any memory dumps from SQL Server (Memory Dump Info)\r\n", 28 | "\r\n", 29 | "### Run the Code block below\r\n", 30 | "\r\n", 31 | "1. Click the run icon below\r\n", 32 | "2. If ADS prompts you for a connection, enter the correct SQL Server and authentication account\r\n", 33 | "3. View the results of the query by scrolling down to the results set" 34 | ], 35 | "metadata": { 36 | "azdata_cell_guid": "cef9eefa-83b0-4b80-b8d4-0bb5731f9689" 37 | }, 38 | "attachments": {} 39 | }, 40 | { 41 | "cell_type": "code", 42 | "source": [ 43 | "-- Get information on location, time and size of any memory dumps from SQL Server (Memory Dump Info)\r\n", 44 | "SELECT [filename], creation_time, size_in_bytes/1048576.0 AS [Size (MB)]\r\n", 45 | "FROM sys.dm_server_memory_dumps WITH (NOLOCK) \r\n", 46 | "ORDER BY creation_time DESC OPTION (RECOMPILE);" 47 | ], 48 | "metadata": { 49 | "azdata_cell_guid": "2f766f9a-3fa7-4c5f-a30f-7425be48ceb3" 50 | }, 51 | "outputs": [], 52 | "execution_count": null 53 | }, 54 | { 55 | "cell_type": "markdown", 56 | "source": [ 57 | "This will not return any rows if you have not had any memory dumps (which is a good thing)\n", 58 | "\n", 59 | "[sys.dm\\_server\\_memory\\_dumps (Transact-SQL)](https://bit.ly/2elwWll)" 60 | ], 61 | "metadata": { 62 | "azdata_cell_guid": "9ae6d18e-c310-491f-a83c-2e701dbcad21" 63 | }, 64 | "attachments": {} 65 | }, 66 | { 67 | "cell_type": "markdown", 68 | "source": [ 69 | "## Page Life Expectancy (PLE) value for each NUMA node in current instance (PLE by NUMA Node)\r\n", 70 | "\r\n", 71 | "### Run the Code block below\r\n", 72 | "\r\n", 73 | "1. Click the run icon below\r\n", 74 | "2. If ADS prompts you for a connection, enter the correct SQL Server and authentication account\r\n", 75 | "3. View the results of the query by scrolling down to the results set" 76 | ], 77 | "metadata": { 78 | "azdata_cell_guid": "5d8642aa-031d-4dbd-9886-1663ec6edabe" 79 | }, 80 | "attachments": {} 81 | }, 82 | { 83 | "cell_type": "code", 84 | "source": [ 85 | "-- Page Life Expectancy (PLE) value for each NUMA node in current instance (PLE by NUMA Node)\r\n", 86 | "SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], \r\n", 87 | " instance_name, cntr_value AS [Page Life Expectancy]\r\n", 88 | "FROM sys.dm_os_performance_counters WITH (NOLOCK)\r\n", 89 | "WHERE [object_name] LIKE N'%Buffer Node%' -- Handles named instances\r\n", 90 | "AND counter_name = N'Page life expectancy' OPTION (RECOMPILE);" 91 | ], 92 | "metadata": { 93 | "azdata_cell_guid": "2db2acbe-7742-4f96-bfcb-9d7fb33eee3c" 94 | }, 95 | "outputs": [], 96 | "execution_count": null 97 | }, 98 | { 99 | "cell_type": "markdown", 100 | "source": [ 101 | "PLE is a good measurement of internal memory pressure\n", 102 | "\n", 103 | "- Higher PLE is better. Watch the trend over time, not the absolute value\n", 104 | "- This will only return one row for non-NUMA systems\n", 105 | "\n", 106 | "[Page Life Expectancy isn’t what you think…](https://bit.ly/2EgynLa)" 107 | ], 108 | "metadata": { 109 | "azdata_cell_guid": "ee74b25d-73b5-4452-9a53-83b38a075adb" 110 | }, 111 | "attachments": {} 112 | }, 113 | { 114 | "cell_type": "markdown", 115 | "source": [ 116 | "## Memory Grants Pending value for current instance (Memory Grants Pending)\r\n", 117 | "\r\n", 118 | "### Run the Code block below\r\n", 119 | "\r\n", 120 | "1. Click the run icon below\r\n", 121 | "2. If ADS prompts you for a connection, enter the correct SQL Server and authentication account\r\n", 122 | "3. View the results of the query by scrolling down to the results set" 123 | ], 124 | "metadata": { 125 | "azdata_cell_guid": "131ef0a0-1325-4852-a0e7-1aa219337ed7" 126 | }, 127 | "attachments": {} 128 | }, 129 | { 130 | "cell_type": "code", 131 | "source": [ 132 | "-- Memory Grants Pending value for current instance (Memory Grants Pending)\r\n", 133 | "SELECT @@SERVERNAME AS [Server Name], RTRIM([object_name]) AS [Object Name], cntr_value AS [Memory Grants Pending] \r\n", 134 | "FROM sys.dm_os_performance_counters WITH (NOLOCK)\r\n", 135 | "WHERE [object_name] LIKE N'%Memory Manager%' -- Handles named instances\r\n", 136 | "AND counter_name = N'Memory Grants Pending' OPTION (RECOMPILE);" 137 | ], 138 | "metadata": { 139 | "azdata_cell_guid": "f121f60e-d608-4506-8585-9eac9865099e" 140 | }, 141 | "outputs": [], 142 | "execution_count": null 143 | }, 144 | { 145 | "cell_type": "markdown", 146 | "source": [ 147 | "Run multiple times, and run periodically if you suspect you are under memory pressure\n", 148 | "\n", 149 | "- Memory Grants Pending above zero for a sustained period is a very strong indicator of internal memory pressure" 150 | ], 151 | "metadata": { 152 | "azdata_cell_guid": "0fcbc76d-d9e2-46e9-8e0c-2766566265ff" 153 | }, 154 | "attachments": {} 155 | }, 156 | { 157 | "cell_type": "markdown", 158 | "source": [ 159 | "## Memory Clerk Usage for instance (Memory Clerk Usage)\r\n", 160 | "\r\n", 161 | "### Run the Code block below\r\n", 162 | "\r\n", 163 | "1. Click the run icon below\r\n", 164 | "2. If ADS prompts you for a connection, enter the correct SQL Server and authentication account\r\n", 165 | "3. View the results of the query by scrolling down to the results set" 166 | ], 167 | "metadata": { 168 | "azdata_cell_guid": "3807d86e-4bdf-4d3a-9e31-2fdab82f3f1c" 169 | }, 170 | "attachments": {} 171 | }, 172 | { 173 | "cell_type": "code", 174 | "source": [ 175 | "-- Memory Clerk Usage for instance (Memory Clerk Usage)\r\n", 176 | "-- Look for high value for CACHESTORE_SQLCP (Ad-hoc query plans)\r\n", 177 | "SELECT TOP(10) mc.[type] AS [Memory Clerk Type], \r\n", 178 | " CAST((SUM(mc.pages_kb)/1024.0) AS DECIMAL (15,2)) AS [Memory Usage (MB)] \r\n", 179 | "FROM sys.dm_os_memory_clerks AS mc WITH (NOLOCK)\r\n", 180 | "GROUP BY mc.[type] \r\n", 181 | "ORDER BY SUM(mc.pages_kb) DESC OPTION (RECOMPILE);" 182 | ], 183 | "metadata": { 184 | "azdata_cell_guid": "fdbc0467-c329-4786-892c-4646e6e1fae4", 185 | "tags": [] 186 | }, 187 | "outputs": [], 188 | "execution_count": null 189 | }, 190 | { 191 | "cell_type": "markdown", 192 | "source": [ 193 | "**MEMORYCLERK\\_SQLBUFFERPOOL** was new for SQL Server 2012. It should be your highest consumer of memory\n", 194 | "\n", 195 | "**CACHESTORE\\_SQLCP** - SQL Plans\n", 196 | "\n", 197 | "- These are cached SQL statements or batches that aren't in stored procedures, functions and triggers\n", 198 | "- Watch out for high values for CACHESTORE\\_SQLCP\n", 199 | "- Enabling 'optimize for ad hoc workloads' at the instance level can help reduce this\n", 200 | "- Running DBCC FREESYSTEMCACHE ('SQL Plans') periodically may be required to better control this\n", 201 | "\n", 202 | "**CACHESTORE\\_OBJCP** - Object Plans\n", 203 | "\n", 204 | "- These are compiled plans for stored procedures, functions and triggers\n", 205 | "\n", 206 | "[sys.dm\\_os\\_memory\\_clerks (Transact-SQL)](https://bit.ly/2H31xDR)" 207 | ], 208 | "metadata": { 209 | "azdata_cell_guid": "788eb638-c508-44c7-9c69-d721ea51fb3b" 210 | }, 211 | "attachments": {} 212 | } 213 | ] 214 | } -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 4 Diagnostics/DIAG-SQLAgent.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | }, 12 | "extensions": { 13 | "azuredatastudio": { 14 | "version": 1, 15 | "views": [] 16 | } 17 | } 18 | }, 19 | "nbformat_minor": 2, 20 | "nbformat": 4, 21 | "cells": [ 22 | { 23 | "cell_type": "markdown", 24 | "source": [ 25 | "![CH4-ADS.png](.\\Media\\CH4-ADS.png)\r\n", 26 | "\r\n", 27 | "Get SQL Server Agent jobs and Category information (SQL Server Agent Jobs)\r\n", 28 | "\r\n", 29 | "### Run the Code block below\r\n", 30 | "\r\n", 31 | "1. Click the run icon below\r\n", 32 | "2. If ADS prompts you for a connection, enter the correct SQL Server and authentication account\r\n", 33 | "3. View the results of the query by scrolling down to the results set" 34 | ], 35 | "metadata": { 36 | "azdata_cell_guid": "5b23b7c9-b4fc-446e-a3ad-280623aac5fa" 37 | }, 38 | "attachments": {} 39 | }, 40 | { 41 | "cell_type": "code", 42 | "source": [ 43 | "-- Get SQL Server Agent jobs and Category information (SQL Server Agent Jobs)\r\n", 44 | "SELECT sj.name AS [Job Name], sj.[description] AS [Job Description], SUSER_SNAME(sj.owner_sid) AS [Job Owner],\r\n", 45 | "sj.date_created AS [Date Created], sj.[enabled] AS [Job Enabled], \r\n", 46 | "sj.notify_email_operator_id, sj.notify_level_email, sc.name AS [CategoryName],\r\n", 47 | "s.[enabled] AS [Sched Enabled], js.next_run_date, js.next_run_time\r\n", 48 | "FROM msdb.dbo.sysjobs AS sj WITH (NOLOCK)\r\n", 49 | "INNER JOIN msdb.dbo.syscategories AS sc WITH (NOLOCK)\r\n", 50 | "ON sj.category_id = sc.category_id\r\n", 51 | "LEFT OUTER JOIN msdb.dbo.sysjobschedules AS js WITH (NOLOCK)\r\n", 52 | "ON sj.job_id = js.job_id\r\n", 53 | "LEFT OUTER JOIN msdb.dbo.sysschedules AS s WITH (NOLOCK)\r\n", 54 | "ON js.schedule_id = s.schedule_id\r\n", 55 | "ORDER BY sj.name OPTION (RECOMPILE);" 56 | ], 57 | "metadata": { 58 | "azdata_cell_guid": "44d92ee5-5680-44b2-af17-5057ae3dedb5" 59 | }, 60 | "outputs": [], 61 | "execution_count": null 62 | }, 63 | { 64 | "cell_type": "markdown", 65 | "source": [ 66 | "Gives you some basic information about your SQL Server Agent jobs, who owns them and how they are configured\n", 67 | "\n", 68 | "- Look for Agent jobs that are not owned by sa\n", 69 | "- Look for jobs that have a notify\\_email\\_operator\\_id set to 0 (meaning no operator)\n", 70 | "- Look for jobs that have a notify\\_level\\_email set to 0 (meaning no e-mail is ever sent)\n", 71 | "\n", 72 | "[MSDN sysjobs documentation](https://bit.ly/2paDEOP)\n", 73 | "\n", 74 | "[SQL Server Maintenance Solution- Ola Hallengren](https://bit.ly/1pgchQu)\n", 75 | "\n", 76 | "[You can use this script to add default schedules to the standard Ola Hallengren Maintenance Solution jobs](https://bit.ly/3ane0gN)" 77 | ], 78 | "metadata": { 79 | "azdata_cell_guid": "40ec667b-dae3-4f88-ab2e-1d449659ee71" 80 | }, 81 | "attachments": {} 82 | }, 83 | { 84 | "cell_type": "markdown", 85 | "source": [ 86 | "Get SQL Server Agent Alert Information (SQL Server Agent Alerts)\r\n", 87 | "\r\n", 88 | "### Run the Code block below\r\n", 89 | "\r\n", 90 | "1. Click the run icon below\r\n", 91 | "2. If ADS prompts you for a connection, enter the correct SQL Server and authentication account\r\n", 92 | "3. View the results of the query by scrolling down to the results set" 93 | ], 94 | "metadata": { 95 | "azdata_cell_guid": "b6f97dc7-1ea1-4205-96a3-2ed91dd0d77a" 96 | }, 97 | "attachments": {} 98 | }, 99 | { 100 | "cell_type": "code", 101 | "source": [ 102 | "-- Get SQL Server Agent Alert Information (SQL Server Agent Alerts)\r\n", 103 | "SELECT name, event_source, message_id, severity, [enabled], has_notification, \r\n", 104 | " delay_between_responses, occurrence_count, last_occurrence_date, last_occurrence_time\r\n", 105 | "FROM msdb.dbo.sysalerts WITH (NOLOCK)\r\n", 106 | "ORDER BY name OPTION (RECOMPILE);" 107 | ], 108 | "metadata": { 109 | "azdata_cell_guid": "7bd5b25a-aa40-48a9-ad90-21b718b28651" 110 | }, 111 | "outputs": [], 112 | "execution_count": null 113 | }, 114 | { 115 | "cell_type": "markdown", 116 | "source": [ 117 | "Gives you some basic information about your SQL Server Agent Alerts, which are different from SQL Server Agent jobs\n", 118 | "\n", 119 | "- Read more about Agent Alerts [here](https://bit.ly/2v5YR37)\n", 120 | "\n", 121 | "Check this out and maybe add another Agent Page or better yet, add this to an Azure Chapter.  Managing SQL Server Agent Jobs with Notebook Jobs in ADS [Managing SQL Server Agent jobs with Notebook Jobs in Azure Data Studio | Data Exposed: MVP Edition - YouTube](https://www.youtube.com/watch?v=wQU7zUYxUW8)" 122 | ], 123 | "metadata": { 124 | "azdata_cell_guid": "69230655-985c-4aa2-a33b-45e7485fb016" 125 | }, 126 | "attachments": {} 127 | } 128 | ] 129 | } -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 4 Diagnostics/Media/CH4-ADS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 4 Diagnostics/Media/CH4-ADS.png -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 4 Diagnostics/readme.md: -------------------------------------------------------------------------------- 1 | # Welcome to Chapter 4: Diagnostics 2 | 3 | Chapter 4 contains notebooks providing you with diagnostic queries. You can either click the hyperlink below, or click directly on the notebook in the naviation pane. 4 | 5 | 6 | ## Notebooks in this Chapter 7 | 8 | - [DIAG-Database](../Chapter 4 Diagnostics/DIAG-Database.ipynb) 9 | - [DIAG-HighAvailability](../Chapter 4 Diagnostics/DIAG-HighAvailability.ipynb) 10 | - [DIAG-Indexes](../Chapter 4 Diagnostics/DIAG-Indexes.ipynb) 11 | - [DIAG-Instance](../Chapter 4 Diagnostics/DIAG-Instance.ipynb) 12 | - [DIAG-Memory](../Chapter 4 Diagnostics/DIAG-Memory.ipynb) 13 | - [DIAG-Server](../Chapter 4 Diagnostics/DIAG-Server.ipynb) 14 | - [DIAG-SQLAgent](../Chapter 4 Diagnostics/DIAG-SQLAgent.ipynb) 15 | - [DIAG-StoredProcedures](../Chapter 4 Diagnostics/DIAG-StoredProcedures.ipynb) -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 5 Database Corruptions/CRPN-About-Corruptions.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | }, 12 | "extensions": { 13 | "azuredatastudio": { 14 | "version": 1, 15 | "views": [] 16 | } 17 | } 18 | }, 19 | "nbformat_minor": 2, 20 | "nbformat": 4, 21 | "cells": [ 22 | { 23 | "cell_type": "markdown", 24 | "source": [ 25 | "# Introduction\n", 26 | "\n", 27 | "Credit and thanks to Paul Randal for the content of this chapter.\n", 28 | "\n", 29 | "Corruption does happen, many times per day, all around the world\n", 30 | "\n", 31 | "Check out the SQL Server [SQLTeam.com Forums](https://forums.sqlteam.com/) data corruption forums.  Many people don’t realize they have corruption until too late. Either they don’t know how to check for corruption or they miss the warning signs that corruption has occurred.  The faster you realize you have corruption, the more likely you will be able to recover with minimal downtime and data loss\n", 32 | "\n", 33 | "Why is this a critical subject to learn?\n", 34 | "\n", 35 | "Many people don't realize they have corruption until it is too late.  Either they don't know how to check for corruption or they miss the warning signs that corruption has occured.  The faster you realize you have corruption, the more likely you will be able to recover with minimal downtime and dataloss.  \n", 36 | "\n", 37 | "Many people don’t know what to do when they do have corruption, leading to:\n", 38 | "\n", 39 | "- Additional data loss than necessary\n", 40 | "- Additional downtime than necessary\n", 41 | "- Monetary penalties and even job losses\n", 42 | "\n", 43 | "### Things that People many times do first\n", 44 | "\n", 45 | "- Panic\n", 46 | " - This causes adrenaline to flow, can cause you to make a rash decision, or succomb to pressure for others\n", 47 | "- Restart SQL Server\n", 48 | " - Just wastes time and delays getting back online\n", 49 | " - Especially if the physical server is rebooted too\n", 50 | "- Immediately jump to the “last resort” and then cause further data loss without working through options\n", 51 | " - E.g. running repair instead of using backups\n", 52 | " - E.g. removing the transaction log\n", 53 | "- Forcibly detach/drop a damaged or SUSPECT database\n", 54 | " - it will fail to attach again so now you have made the situation is even worse\n", 55 | "\n", 56 | "### Practice Makes Perfect\n", 57 | "\n", 58 | "If you’re recovering from corruption, or helping a client recover from some corruption:\n", 59 | "\n", 60 | "- You must know what you’re doing\n", 61 | "- You must have practiced\n", 62 | "- You must NOT make things worse by making mistakes\n", 63 | "\n", 64 | "Even if you’ve never run consistency checks before, a little bit of knowledge means you’ll have a good idea what to do and when to ask for help from someone more experienced.\n", 65 | "\n", 66 | "### Root Cause Analysis\n", 67 | "\n", 68 | "No matter what method you use to recover from corruption, you should always determine why it happened to avoid future problems.  It may be obvious what happened.  For example a known SAN problem or power failure.  It also be possible that you have have no idea what happened, so what to do?\n", 69 | "\n", 70 | "- Bing/Google for the corruption message you saw\n", 71 | "- Run I/O subsystem and server memory diagnostics\n", 72 | "- Examine the SQL Server error log and Windows event logs for clues\n", 73 | "- Check that firmware is up-to-date\n", 74 | "- Investigate NTFS filter drivers\n", 75 | "- Possibly contact Microsoft Customer Support for assistance\n", 76 | "\n", 77 | "### How Does Corruption Occur?\n", 78 | "\n", 79 | "If a data file page is “good” when written out of SQL Server’s memory, but “bad” when read back into memory, that’s corruption.  Where these is code, there is the potential for bugs.  There are a lot of moving 'parts' underneath SQL Server.  Transaction Log files can become currupt too, but this scenario will be covered in a later notebook.  Here are the most common causes of Corruption?\n", 80 | "\n", 81 | "- It’s almost always the I/O subsystem\n", 82 | "- The I/O subsystem means anything “underneath” SQL Server\n", 83 | " - Windows operating system\n", 84 | " - File system filter drivers\n", 85 | " - Antivirus, defraggers, encryption\n", 86 | " - Network cards, switches, cables\n", 87 | " - SAN controllers\n", 88 | " - RAID controllers\n", 89 | " - Disks\n", 90 | "- Consider the Mean Time Between Failure (MTBF) of disks\n", 91 | " - Various sources online give figures around 1.5 million hours as MTBFas long as the operating environment is ideal\n", 92 | " - Dust, high/low temperature, vibration, power cycling are not ideal\n", 93 | " - It’s a mean, which means there’s a bell-curve of failure times.  Likely you will find yourself on the low end of the bell curve\n", 94 | "\n", 95 | "Jim Gray likened a disk head in a 15,000 rpm disk to a Boeing 747 flying at 500mph about ¼ inch above the ground.  What are the tolerances involved?  What happens in a crash?  A disk head is essentially floating on a couple of microns of air above the disk and the slightest vibration or dust can cause corruption.\n", 96 | "\n", 97 | "What if it’s not the I/O subsystem?  Here are a few more examples:\n", 98 | "\n", 99 | "- Memory corruption\n", 100 | "- Bad memory chips\n", 101 | "- Memory Scribblers\n", 102 | "- SQL Server bugs\n", 103 | "- Human error\n", 104 | "- Manually trying to edit a database\n", 105 | "- Manually deleting a transaction log\n", 106 | "\n", 107 | "### What does not cause corruption?\n", 108 | "\n", 109 | "There are many myths and misconceptions about what can cause database corruption.  Corruptions are not caused by:\n", 110 | "\n", 111 | "- Anything an application can do (unless it is malicious code from a bad actor)\n", 112 | "- Anything you can do in SQL Server with supported, documented commands\n", 113 | "- Interrupting a database shrink, index rebuild, or long-running batch.   SQL Server is designed to 'crash' and self-recover from it by means of the transaction log\n", 114 | "- Shutting down SQL Server\n", 115 | "\n", 116 | "### What about propogation of Corruption to remote servers?\n", 117 | "\n", 118 | "- SQL Server redundancy technologies do not propagate data file corruptions caused by the I/O subsystem\n", 119 | " - Database mirroring, log shipping, replication, Always On Availability Groups\n", 120 | "- These technologies send log records (or actions based on log records), not data file pages from disk\n", 121 | "- It is possible to have a “second-order” corruption propagated\n", 122 | " - Corrupt page is not detected on the local server and used to calculate a result which is stored locally, and sent to the remote server\n", 123 | "- Backing up a database should detect corruption, preventing propagation to a remote server during restore\n", 124 | "- SAN replication should also not propagate corruption\n", 125 | " - Replicating changed disk blocks as they’re written, not read from disk\n", 126 | "\n", 127 | "### What is Disappearing Corruption?\n", 128 | "\n", 129 | "- Typical description of the phenomenon\n", 130 | " - Consistency-checking job fails during the night\n", 131 | " - DBA runs a consistency check again in the morning, but no corruption!\n", 132 | " - DBA questions where the initial report of corruption was correct\n", 133 | "- What’s really happening:\n", 134 | " - Corruption is reported on some pages allocated to an index for instance\n", 135 | " - After the consistency-checking job runs, an index maintenance job runs\n", 136 | " - The index containing the corrupt pages is rebuilt, which builds a new index with new data pages, and then de-allocates the old index and data pages\n", 137 | " - Another consistency check runs but doesn’t find any corruption\n", 138 | " - The second consistency check is reading different pages from the first one, so doesn’t see the corrupt pages\n", 139 | "- Consistency checks validate those data file pages that are allocated to tables and indexes in the database" 140 | ], 141 | "metadata": { 142 | "azdata_cell_guid": "83a47819-71cc-4e08-8236-bdea4b6d7231" 143 | }, 144 | "attachments": {} 145 | } 146 | ] 147 | } -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 5 Database Corruptions/CRPN-DBCC-CHECKDB-Internals.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | } 12 | }, 13 | "nbformat_minor": 2, 14 | "nbformat": 4, 15 | "cells": [ 16 | { 17 | "cell_type": "markdown", 18 | "source": [ 19 | "![CH5-ADS.png](.\\Media\\CH5-ADS.png)\r\n", 20 | "# DBCC CHECKDB Internals and Performance" 21 | ], 22 | "metadata": { 23 | "azdata_cell_guid": "8e09fb2e-f468-4374-bd57-43a248a8443b" 24 | } 25 | }, 26 | { 27 | "cell_type": "markdown", 28 | "source": [ 29 | "In order for you to gain a more advanced knowledge of working with and correcting SQL Server corruptions, also involves knowing a bit more about how DBCC CHECKDB works and how to enhance its performance.  If you jumped right to this notebook and you have not already mastered the basics of handling corruption, it is recommended that you go through the previous notebooks in this chapter first.\n", 30 | "\n", 31 | "This notebook will cover:\n", 32 | "\n", 33 | "- Various internals of DBCC CHECKDB\n", 34 | "- Trace flags to aid DBCC CHECKDB performance\n", 35 | "- Parallelism and memory settings for DBCC CHECKDB\n", 36 | "\n", 37 | "## What exactly does DBCC CHECKDB do?\n", 38 | "\n", 39 | "- The first thing it does is perform Primitive checks of critical system tables\n", 40 | " - The 3 critical system Storage Engine metadata tables it checkes are sys.allocation\\_units, sys.sysrowsets and sys.sysrscols\n", 41 | " - Makes sure that the leaf-level clustered index pages of these 3 metadata tables can be read into memory and looks for any improper loops in the linkage\n", 42 | "- Allocation checks.  This is the equivalent of DBCC CHECKALLOC\n", 43 | " - Validates the GAM, SGAM, PFS and IAM Pages bit settings are correct and that no two pages have an identical bit set\n", 44 | "- Logical checks of critical system tables\n", 45 | "- Logical checks of all other tables in the database\n", 46 | "- Metadata checks.  This is the Equivalent to DBCC CHECKCATALOG\n", 47 | "- Service Broker data validation\n", 48 | "- Indexed view, XML index, spatial index checks\n", 49 | " - Only when the WITH EXTENDED\\_LOGICAL\\_CHECKS option is used, from SQL Server 2008 onward\n", 50 | "- If a repair option is specified, repairs are done at each stage if necessary and possible\n", 51 | "- Uses the Query Processor extensively\n", 52 | "\n", 53 | "Fact Processing\n", 54 | "\n", 55 | "- DBCC CHECKDB reads all allocated pages in the database in a very efficient manner\n", 56 | "- It reads the pages in allocation order, driving its own readahead, and generates “facts” about what it has seen, which is O(n\\*log(n))\n", 57 | " - E.g. facts about pages, b-tree linkages, off-row text linkages\n", 58 | " - Driven by an internal structure called the MultiObjectScanner\n", 59 | "- Each fact has a multi-part key\n", 60 | " - Including object ID, index ID, allocation unit ID, page ID\n", 61 | "- Facts are passed to the Query Processor for efficient sorting and hashing, then passed back to DBCC for aggregation\n", 62 | " - Aggregation means that facts cancel each other out\n", 63 | " - When extra or missing facts are detected, that’s a corruption\n", 64 | " \n", 65 | " \n", 66 | " ![CH5-FactProcessing.jpg](.\\Media\\CH5-FactProcessing.jpg)\n", 67 | " ![CH5-FactProcessing2.jpg](.\\Media\\CH5-FactProcessing2.jpg)\n", 68 | " \n", 69 | "\n", 70 | "Batch Processing\n", 71 | "\n", 72 | "- The fact-storage worktable usually requires more memory than is available so it spills into tempdb\n", 73 | "- The batch size is limited to prevent excessive tempdbspace usage\n", 74 | " - A batch’s “size” is the number of tables and associated indexes\n", 75 | "- The minimum batch size is a single table and its nonclustered indexes as everything about a table must be checked at the same time\n", 76 | "- Tables are added to the batch until one of the following occurs:\n", 77 | " - The total number of indexes in the batch becomes more than 512\n", 78 | " - The estimate for all necessary facts for the batch becomes more than 32 MB\n", 79 | " - If a repair option is specified, the batch size is always limited to a single table\n", 80 | "- Read and write performance of tempdb can greatly affect the run time\n", 81 | "\n", 82 | "Parallelism\n", 83 | "\n", 84 | "- DBCC CHECKDB will run in parallel on Enterprise Edition\n", 85 | " \n", 86 | " - Also applies to DBCC CHECKTABLE and DBCC CHECKFILEGROUP\n", 87 | " - DBCC CHECKALLOCand DBCC CHECKCATALOG are always single-threaded\n", 88 | "- Each batch executes the DBCC CHECKDB internal “query” and the Query Processor decides how far to parallelize\n", 89 | " \n", 90 | " - Up to the limit imposed by the sp\\_configure MAXDOP setting or the Resource Governor workload group MAX\\_DOP setting\n", 91 | " - There is no option to set DBCC CHECKDB’s degree of parallelism\n", 92 | "- Each thread is given a page to generate facts for, and then calls into the MultiObjectScanner to get the next page to process\n", 93 | " \n", 94 | "- Threads then participate in fact aggregation once all pages have been read and processed for facts\n", 95 | " \n", 96 | "- Parallelism can be disabled using documented trace flag 2528\n", 97 | " \n", 98 | " - Greatly increases run time, but greatly decreases the resources required\n", 99 | " \n", 100 | " ![CH5-Parallelism.jpg](.\\Media\\CH5-Parallelism.jpg)" 101 | ], 102 | "metadata": { 103 | "azdata_cell_guid": "4b85aee2-5d18-4293-83a5-7dd03d5f4cfb" 104 | }, 105 | "attachments": {} 106 | }, 107 | { 108 | "cell_type": "markdown", 109 | "source": [ 110 | "## Making DBCC CHECKDB go Faster\n", 111 | "\n", 112 | "- Work has been done to improve the performance of DBCC CHECKDB by:\n", 113 | " - Allowing it to check all tables as a single batch\n", 114 | " - Slightly changing the I/O pattern it generates\n", 115 | " - Reducing contention on the DBCC\\_MULTIOBJECT\\_SCANNER latch\n", 116 | "- KB article describing these is at [KB2634571 - Improvements for the DBCC CHECKDB command may result in faster performance when you use the PHYSICAL\\_ONLY option (microsoft.com)](https://support.microsoft.com/en-us/topic/kb2634571-improvements-for-the-dbcc-checkdb-command-may-result-in-faster-performance-when-you-use-the-physical-only-option-e49ca6f4-8a5a-7a09-40d3-266ca513177f)\n", 117 | "- Ported to SQL Server 2008 R2 and later\n", 118 | " - Uses documented trace flags 2549 and 2562\n", 119 | " - Check the above KB article to see which trace flags are required in which versions\n", 120 | " - Be aware these changes may push the I/O subsystem much harder, and you may not see any changes at all\n", 121 | "- Consider reducing DOP to lower run time when using the option WITH PHYSICAL\\_ONLY\n", 122 | "- On systems with high numbers of physical cores (32+), consider reducing DOP to 4 or 8 to lower run time even without using PHYSICAL\\_ONLY\n", 123 | "\n", 124 | "- Consider reducing the memory available to DBCC CHECKDB\n", 125 | "- The Query Processor by default will grant DBCC CHECKDB a very large query execution memory grant, potentially causing buffer pool shrinkage\n", 126 | " - Requested grant is many terabytes because of unknown cardinality\n", 127 | " - On a system with 100 GB of memory, grant may be as high as 10 GB\n", 128 | "- Performance testing by Jonathan Kehayias has shown that limiting the amount of memory for DBCC CHECKDB to 1 GB can lead to 5-10% performance increase, and very limited buffer pool pressure\n", 129 | "- Use Resource Governor to do this\n", 130 | "- Jonathan’s blog post at [DBCC CHECKDB Execution Memory Grants - Not Quite What You Expect - Jonathan Kehayias (sqlskills.com)](https://www.sqlskills.com/blogs/jonathan/dbcc-checkdb-execution-memory-grants-not-quite-what-you-expect/)\n", 131 | "\n", 132 | "- Indexes on computed columns drastically slow down DBCC CHECKDB\n", 133 | " - Also applies to DBCC CHECKTABLEand DBCC CHECKFILEGROUP\n", 134 | "- Any time a table has an index on a computed column, all threads bottleneck on the DBCC\\_OBJECT\\_METADATAlatch\n", 135 | " - This controls access to an Expression Evaluator construct in the Query Processor that evaluates computed column expressions\n", 136 | " - The latch can only be acquired in EX mode, hence the bottleneck\n", 137 | "- This can lead to 20x performance decrease\n", 138 | "- Solution is to disable such indexes while DBCC CHECKDB is running" 139 | ], 140 | "metadata": { 141 | "azdata_cell_guid": "50549c03-6f9a-4c97-a3f7-3c60ef6ef8f5" 142 | }, 143 | "attachments": {} 144 | } 145 | ] 146 | } -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 5 Database Corruptions/Chapter 5B Database Corruptions Advanced.md: -------------------------------------------------------------------------------- 1 | - [CRPN-DBCC-CHECKDB-Internals](../Chapter 5 Database Corruptions/CRPN-DBCC-CHECKDB-Internals.ipynb) 2 | - [CRPN-Undocumented-DBCC-Commands](../Chapter 5 Database Corruptions/CRPN-Undocumented-DBCC-Commands.ipynb) -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-ADS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-ADS.png -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-Backup-Sequence.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-Backup-Sequence.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-DBCC-IND.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-DBCC-IND.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-Delete-MDF.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-Delete-MDF.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-Diff-3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-Diff-3.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-FactProcessing.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-FactProcessing.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-FactProcessing2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-FactProcessing2.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-Offline.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-Offline.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-Page-IND.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-Page-IND.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-Parallelism.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-Parallelism.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-Recovery-Pending.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-Recovery-Pending.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-STOPAT-Miss.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-STOPAT-Miss.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-Standby-Update-Error.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-Standby-Update-Error.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-Standby.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-Standby.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-TornPage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 5 Database Corruptions/Media/CH5-TornPage.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 5 Database Corruptions/readme.md: -------------------------------------------------------------------------------- 1 | # Welcome to Chapter 5: Database Corruptions 2 | 3 | Chapter 5 contains notebooks providing you with information about database corruptions, some reasons for why this can happen and some demo's on how to recover. You can either click the hyperlink below, or click directly on the notebook in the naviation pane. 4 | 5 | 6 | ## Notebooks in this Chapter 7 | 8 | - [CRPN-About-Corruptions](../Chapter 5 Database Corruptions/CRPN-About-Corruptions.ipynb) 9 | - [CRPN-Torn-Page](../Chapter 5 Database Corruptions/CRPN-Torn-Page.ipynb) 10 | - [CRPN-ConsistencyChecks](../Chapter 5 Database Corruptions/CRPN-ConsistencyChecks.ipynb) 11 | - [CRPN-DBCC-CHECKDB](../Chapter 5 Database Corruptions/CRPN-DBCC-CHECKDB.ipynb) 12 | - [CRPN-Interpreting-CHECKDB-Output](../Chapter 5 Database Corruptions/CRPN-Interpreting-CHECKDB-Output.ipynb) 13 | - [CRPN-Simple-Restore-Techniques](../Chapter 5 Database Corruptions/CRPN-Simple-Restore-Techniques.ipynb) 14 | - [CRPN-Simple-Repair-Techniques](../Chapter 5 Database Corruptions/CRPN-Simple-Repair-Techniques.ipynb) 15 | - [CRPN-DBCC-CHECKDB-Internals](../Chapter 5 Database Corruptions/CRPN-DBCC-CHECKDB-Internals.ipynb) 16 | - [CRPN-Undocumented-DBCC-Commands](../Chapter 5 Database Corruptions/CRPN-Undocumented-DBCC-Commands.ipynb) 17 | -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 6 Maintenance Routines/Media/CH6-ADS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 6 Maintenance Routines/Media/CH6-ADS.png -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 6 Maintenance Routines/Media/CH6-AdminConnect.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 6 Maintenance Routines/Media/CH6-AdminConnect.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 6 Maintenance Routines/Media/CH6-CMDConnect.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 6 Maintenance Routines/Media/CH6-CMDConnect.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 6 Maintenance Routines/Media/CH6-CPUNum.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 6 Maintenance Routines/Media/CH6-CPUNum.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 6 Maintenance Routines/Media/CH6-Error.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 6 Maintenance Routines/Media/CH6-Error.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 6 Maintenance Routines/Media/CH6-ExecutionLog.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 6 Maintenance Routines/Media/CH6-ExecutionLog.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 6 Maintenance Routines/Media/CH6-FixedLength.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 6 Maintenance Routines/Media/CH6-FixedLength.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 6 Maintenance Routines/Media/CH6-LogSpace.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 6 Maintenance Routines/Media/CH6-LogSpace.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 6 Maintenance Routines/Media/CH6-NewAdminQuery.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 6 Maintenance Routines/Media/CH6-NewAdminQuery.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 6 Maintenance Routines/Media/CH6-VariableLength.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 6 Maintenance Routines/Media/CH6-VariableLength.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 6 Maintenance Routines/readme.md: -------------------------------------------------------------------------------- 1 | 2 | Chapter 6 contains notebooks providing you with information about database maintenance, administration and helpful sizing and capacity planning guidance. You can either click the hyperlink below, or click directly on the notebook in the naviation pane. 3 | 4 | 5 | ## Notebooks in this Chapter 6 | 7 | - [MAINT-RoutineSQLMaintenance](../Chapter 6 Maintenance Routines/MAINT-RoutineSQLMaintenance.ipynb) 8 | - [MAINT-CapacityPlanning](../Chapter 6 Maintenance Routines/MAINT-CapacityPlanning.ipynb) 9 | - [MAINT-DailyTasks](../Chapter 6 Maintenance Routines/MAINT-DailyTasks.ipynb) 10 | - [MAINT-Ports-and-Protocols](../Chapter 6 Maintenance Routines/MAINT-Ports-and-Protocols.ipynb) 11 | - [MAINT-Dedicated-Administrators-Connection](../Chapter 6 Maintenance Routines/MAINT-Dedicated-Administrators-Connection.ipynb) 12 | - [MAINT-Interpreting-Performance-Counters](../Chapter 6 Maintenance Routines/MAINT-Interpreting-Performance-Counters.ipynb) 13 | - [MAINT-Database-Maintenance-Tips](../Chapter 6 Maintenance Routines/MAINT-Database-Maintenance-Tips.ipynb) 14 | - [MAINT-Working-With-TempDB](../Chapter 6 Maintenance Routines/MAINT-Working-With-TempDB.ipynb) -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 7 Troubleshooting/Test.ipynb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 7 Troubleshooting/Test.ipynb -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 7 Troubleshooting/readme.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 7 Troubleshooting/readme.md -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-ADS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-ADS.png -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-AddNewPackage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-AddNewPackage.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-AzureAccount.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-AzureAccount.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-Basics.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-Basics.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-ChooseImage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-ChooseImage.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-DNSlabel.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-DNSlabel.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-DeploymentChoices.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-DeploymentChoices.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-Ecosystem.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-Ecosystem.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-Gallery.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-Gallery.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-ManagePackage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-ManagePackage.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-RayOzzie.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-RayOzzie.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-Results.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-Results.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-Review.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-Review.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-SSMS.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-SSMS.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-Timeline.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 8 SQL Server on Azure VM/Media/CH8-Timeline.jpg -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 8 SQL Server on Azure VM/SSOA-SQL-Server-Iaas-Extension.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "kernelspec": { 4 | "name": "SQL", 5 | "display_name": "SQL", 6 | "language": "sql" 7 | }, 8 | "language_info": { 9 | "name": "sql", 10 | "version": "" 11 | } 12 | }, 13 | "nbformat_minor": 2, 14 | "nbformat": 4, 15 | "cells": [ 16 | { 17 | "cell_type": "markdown", 18 | "source": [ 19 | "![CH8-ADS.png](.\\Media\\CH8-ADS.png)\r\n", 20 | "# The SQL Server IaaS Agent Extension" 21 | ], 22 | "metadata": { 23 | "azdata_cell_guid": "03e838c7-e698-41ea-8dfe-9c91fb9400be" 24 | }, 25 | "attachments": {} 26 | }, 27 | { 28 | "cell_type": "markdown", 29 | "source": [ 30 | "The SQL Server IaaS Agent extension (SqlIaasExtension) runs on SQL Server on Windows Azure Virtual Machines (VMs) to automate management and administration tasks.  If you performed the exercise in the previous notebook \"SSOA-Deploy-Azure-SQL-VM-From-PowerShell\" you actually installed the SQL Server IaaS Agent Extension.  It was there very last like of code in the script.  Here's the snippet:\n", 31 | "\n", 32 | "# Add the SQL IaaS Extension, and choose the license type\n", 33 | "\n", 34 | "New-AzSqlVM -ResourceGroupName $ResourceGroupName -Name $VMName -Location $Location -LicenseType PAYG\n", 35 | "\n", 36 | "## Overview\n", 37 | "\n", 38 | "The SQL Server IaaS Agent extension allows for integration with the Azure portal, and depending on the management mode, unlocks a number of feature benefits for SQL Server on Azure VMs:\n", 39 | "\n", 40 | "- Feature benefits: The extension unlocks a number of automation feature benefits, such as portal management, license flexibility, automated backup, automated patching and more\n", 41 | "- Compliance: The extension offers a simplified method to fulfill the requirement of notifying Microsoft that the Azure Hybrid Benefit has been enabled as is specified in the product terms. This process negates needing to manage licensing registration forms for each resource.\n", 42 | "- Free: The extension in all three manageability modes is completely free. There is no additional cost associated with the extension, or with changing management modes.\n", 43 | "- Simplified license management: The extension simplifies SQL Server license management, and allows you to quickly identify SQL Server VMs with the Azure Hybrid Benefit enabled using the Azure portal, PowerShell or the Azure CLI:\n", 44 | "\n", 45 | "## Feature Benefits\n", 46 | "\n", 47 | "The SQL Server IaaS Agent extension unlocks a number of feature benefits for managing your SQL Server VM. You can register your SQL Server VM in lightweight management mode, which unlocks a few of the benefits, or in full management mode, which unlocks all available benefits.\n", 48 | "\n", 49 | "The following table details these benefits:" 50 | ], 51 | "metadata": { 52 | "azdata_cell_guid": "1ee49ef7-3e61-45c4-a991-88ca83a38f73" 53 | }, 54 | "attachments": {} 55 | } 56 | ] 57 | } -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 8 SQL Server on Azure VM/readme.md: -------------------------------------------------------------------------------- 1 | ## Notebooks in this Chapter 2 | 3 | - [SSOA-The-History-of-Azure-SQL](../Chapter 8 SQL Server on Azure VM/SSOA-The-History-of-Azure-SQL.ipynb) 4 | - [SSOA-Deploy-Azure-SQL-VM-From-Portal](../Chapter 8 SQL Server on Azure VM/SSOA-Deploy-Azure-SQL-VM-From-Portal.ipynb) 5 | 6 | -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 9 Azure SQL Database/ASDB-Getting Started with Azure SQL Database.ipynb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 9 Azure SQL Database/ASDB-Getting Started with Azure SQL Database.ipynb -------------------------------------------------------------------------------- /SQL Operations and Support/Chapter 9 Azure SQL Database/readme.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/Chapter 9 Azure SQL Database/readme.md -------------------------------------------------------------------------------- /SQL Operations and Support/CreateNewSQL2.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RhinoDBA/SQL911/2c8663be4ead2435527e90c4d0f8e6ed6bd58237/SQL Operations and Support/CreateNewSQL2.ps1 -------------------------------------------------------------------------------- /SQL Operations and Support/_config.yml: -------------------------------------------------------------------------------- 1 | title: SQL Operations and Support 2 | -------------------------------------------------------------------------------- /SQL Operations and Support/_toc.yml: -------------------------------------------------------------------------------- 1 | - title: Chapter 1 Getting Started 2 | file: /Chapter 1 Getting Started/readme 3 | expand_sections: true 4 | numbered: false 5 | sections: 6 | - title: STRT-Introduction 7 | file: /Chapter 1 Getting Started/STRT-Introduction 8 | - title: STRT-QueryExecutions 9 | file: /Chapter 1 Getting Started/STRT-QueryExecutions 10 | - title: Chapter 2 Using Extension Packs 11 | file: /Chapter 2 Using Extension Packs/readme 12 | expand_sections: true 13 | numbered: false 14 | sections: 15 | - title: PACK-UsingExtensionPacks 16 | file: /Chapter 2 Using Extension Packs/PACK-UsingExtensionPacks 17 | - title: PACK-UsingWidgets 18 | file: /Chapter 2 Using Extension Packs/PACK-UsingWidgets 19 | - title: PACK-FirstResponderKit 20 | file: /Chapter 2 Using Extension Packs/PACK-FirstResponderKit 21 | - title: Chapter 3 General Information Queries 22 | file: /Chapter 3 General Information/readme 23 | expand_sections: true 24 | numbered: false 25 | sections: 26 | - title: GEN-GatherInformation 27 | file: /Chapter 3 General Information/GEN-GatherInformation 28 | - title: GEN-GetBPConsumers 29 | file: /Chapter 3 General Information/GEN-GetBPConsumers 30 | - title: GEN-GetBufferPool 31 | file: /Chapter 3 General Information/GEN-GetBufferPool 32 | - title: GEN-GetCPULast2Hours 33 | file: /Chapter 3 General Information/GEN-GetCPULast2Hours 34 | - title: GEN-GetDBGrowth 35 | file: /Chapter 3 General Information/GEN-GetDBGrowth 36 | - title: GEN-GetDBInfo 37 | file: /Chapter 3 General Information/GEN-GetDBInfo 38 | - title: GEN-GetDBTriggers 39 | file: /Chapter 3 General Information/GEN-GetDBTriggers 40 | - title: GEN-GetDiskSpace 41 | file: /Chapter 3 General Information/GEN-GetDiskSpace 42 | - title: GEN-GetFeatureUsage 43 | file: /Chapter 3 General Information/GEN-GetFeatureUsage 44 | - title: GEN-GetHAInfo 45 | file: /Chapter 3 General Information/GEN-GetHAInfo 46 | - title: GEN-GetInstanceInfo 47 | file: /Chapter 3 General Information/GEN-GetInstanceInfo 48 | - title: GEN-GetLinkedServers 49 | file: /Chapter 3 General Information/GEN-GetLinkedServers 50 | - title: GEN-GetLogonTriggers 51 | file: /Chapter 3 General Information/GEN-GetLogonTriggers 52 | - title: GEN-GetLowMemoryEvents 53 | file: /Chapter 3 General Information/GEN-GetLowMemoryEvents 54 | - title: GEN-GetLPIM 55 | file: /Chapter 3 General Information/GEN-GetLPIM 56 | - title: GEN-GetMAXDOP 57 | file: /Chapter 3 General Information/GEN-GetMAXDOP 58 | - title: GEN-GetMemoryAlloc 59 | file: /Chapter 3 General Information/GEN-GetMemoryAlloc 60 | - title: GEN-GetOSVersion 61 | file: /Chapter 3 General Information/GEN-GetOSVersion 62 | - title: GEN-GetProcNUMA 63 | file: /Chapter 3 General Information/GEN-GetProcNUMA 64 | - title: GEN-GetRecentBackkups 65 | file: /Chapter 3 General Information/GEN-GetRecentBackups 66 | - title: GEN-GetResourceGov 67 | file: /Chapter 3 General Information/GEN-GetResourceGov 68 | - title: GEN-GetServerMemory 69 | file: /Chapter 3 General Information/GEN-GetServerMemory 70 | - title: GEN-GetSockets 71 | file: /Chapter 3 General Information/GEN-GetSockets 72 | - title: GEN-GetSystemConfig 73 | file: /Chapter 3 General Information/GEN-GetSystemConfig 74 | - title: GEN-GetUptime 75 | file: /Chapter 3 General Information/GEN-GetUptime 76 | - title: GEN-PreReqs 77 | file: /Chapter 3 General Information/GEN-PreReqs 78 | - title: Chapter 4 Diagnostics 79 | file: /Chapter 4 Diagnostics/readme 80 | expand_sections: true 81 | numbered: false 82 | sections: 83 | - title: DIAG-Database 84 | file: /Chapter 4 Diagnostics/DIAG-Database 85 | - title: DIAG-HighAvailability 86 | file: /Chapter 4 Diagnostics/DIAG-HighAvailability 87 | - title: DIAG-Indexes 88 | file: /Chapter 4 Diagnostics/DIAG-Indexes 89 | - title: DIAG-Instance 90 | file: /Chapter 4 Diagnostics/DIAG-Instance 91 | - title: DIAG-Memory 92 | file: /Chapter 4 Diagnostics/DIAG-Memory 93 | - title: DIAG-Server 94 | file: /Chapter 4 Diagnostics/DIAG-Server 95 | - title: DIAG-SQLAgent 96 | file: /Chapter 4 Diagnostics/DIAG-SQLAgent 97 | - title: DIAG-StoredProcedures 98 | file: /Chapter 4 Diagnostics/DIAG-StoredProcedures 99 | - title: Chapter 5 Database Corruptions 100 | file: /Chapter 5 Database Corruptions/readme 101 | expand_sections: true 102 | numbered: false 103 | sections: 104 | - title: CRPN-About-Corruptions 105 | file: /Chapter 5 Database Corruptions/CRPN-About-Corruptions 106 | - title: CRPN-Torn-Page 107 | file: /Chapter 5 Database Corruptions/CRPN-Torn-Page 108 | - title: CRPN-ConsistencyChecks 109 | file: /Chapter 5 Database Corruptions/CRPN-ConsistencyChecks 110 | - title: CRPN-DBCC-CHECKDB 111 | file: /Chapter 5 Database Corruptions/CRPN-DBCC-CHECKDB 112 | - title: CRPN-Interpreting-CHECKDB-Output 113 | file: /Chapter 5 Database Corruptions/CRPN-Interpreting-CHECKDB-Output 114 | - title: CRPN-Simple-Restore-Techniques 115 | file: /Chapter 5 Database Corruptions/CRPN-Simple-Restore-Techniques 116 | - title: CRPN-Simple-Repair-Techniques 117 | file: /Chapter 5 Database Corruptions/CRPN-Simple-Repair-Techniques 118 | - title: Chapter 5B Database Corruptions Advanced 119 | file: /Chapter 5 Database Corruptions/Chapter 5B Database Corruptions Advanced 120 | sections: 121 | - title: CRPN-DBCC-CHECKDB-Internals 122 | file: /Chapter 5 Database Corruptions/CRPN-DBCC-CHECKDB-Internals 123 | - title: CRPN-Undocumented-DBCC-Commands 124 | file: /Chapter 5 Database Corruptions/CRPN-Undocumented-DBCC-Commands 125 | - title: Chapter 6 Maintenance Routines 126 | file: /Chapter 6 Maintenance Routines/readme 127 | expand_sections: true 128 | numbered: false 129 | sections: 130 | - title: MAINT-RoutineSQLMaintenance 131 | file: /Chapter 6 Maintenance Routines/MAINT-RoutineSQLMaintenance 132 | - title: MAINT-CapacityPlanning 133 | file: /Chapter 6 Maintenance Routines/MAINT-CapacityPlanning 134 | - title: MAINT-DailyTasks 135 | file: /Chapter 6 Maintenance Routines/MAINT-DailyTasks 136 | - title: MAINT-Ports-and-Protocols 137 | file: /Chapter 6 Maintenance Routines/MAINT-Ports-and-Protocols 138 | - title: MAINT-Dedicated-Administrators-Connection 139 | file: /Chapter 6 Maintenance Routines/MAINT-Dedicated-Administrators-Connection 140 | - title: MAINT-Interpreting-Performance-Counters 141 | file: /Chapter 6 Maintenance Routines/MAINT-Interpreting-Performance-Counters 142 | - title: MAINT-Database-Maintenance-Tips 143 | file: /Chapter 6 Maintenance Routines/MAINT-Database-Maintenance-Tips 144 | - title: MAINT-Working-With-TempDB 145 | file: /Chapter 6 Maintenance Routines/MAINT-Working-With-TempDB 146 | - title: Chapter 7 Troubleshooting 147 | file: /Chapter 7 Troubleshooting/readme 148 | expand_sections: true 149 | numbered: false 150 | sections: 151 | - title: TRBL-TShooting_LogFull 152 | file: /Chapter 7 Troubleshooting/TRBL-TShooting_LogFull 153 | - title: Chapter 8 SQL Server on Azure VM 154 | file: /Chapter 8 SQL Server on Azure VM/readme 155 | expand_sections: true 156 | numbered: false 157 | sections: 158 | - title: SSOA-The-History-of-Azure-SQL 159 | file: /Chapter 8 SQL Server on Azure VM/SSOA-The-History-of-Azure-SQL 160 | - title: SSOA-Deploy-Azure-SQL-VM-From-Portal 161 | file: /Chapter 8 SQL Server on Azure VM/SSOA-Deploy-Azure-SQL-VM-From-Portal 162 | - title: SSOA-Deploy-Azure-SQL-VM-From-PowerShell 163 | file: /Chapter 8 SQL Server on Azure VM/SSOA-Deploy-Azure-SQL-VM-From-PowerShell 164 | - title: SSOA-SQL-Server-Iaas-Extension 165 | file: /Chapter 8 SQL Server on Azure VM/SSOA-SQL-Server-Iaas-Extension 166 | - title: Chapter 9 Azure SQL Database 167 | file: /Chapter 9 Azure SQL Database/readme 168 | expand_sections: true 169 | numbered: false 170 | sections: 171 | - title: ASDB-Getting Started with Azure SQL Database 172 | file: /Chapter 9 Azure SQL Database/ASDB-Getting Started with Azure SQL Database 173 | - title: Chapter 10 Azure SQL Managed Instance 174 | file: /Chapter 10 Azure SQL Managed Instance/readme 175 | expand_sections: true 176 | numbered: false 177 | sections: 178 | - title: ASMI-Getting Started with Azure SQL Managed Instance 179 | file: /Chapter 10 Azure SQL Managed Instance/ASMI-Getting Started with Azure SQL Managed Instance 180 | - title: Chapter 11 High Availbility 181 | file: /Chapter 11 High Availbility/readme 182 | expand_sections: true 183 | numbered: false 184 | sections: [] 185 | -------------------------------------------------------------------------------- /debug.log: -------------------------------------------------------------------------------- 1 | [0307/125845.915:ERROR:registration_protocol_win.cc(102)] CreateFile: The system cannot find the file specified. (0x2) 2 | --------------------------------------------------------------------------------