mirror of
https://github.com/Microsoft/sql-server-samples.git
synced 2025-12-08 14:58:54 +00:00
- Add descriptions for custom rule set concepts - Addd reference docs for custom rule sets - Update existing docs for 4-level severity
3.2 KiB
3.2 KiB
SQL Assessment API Quick Start Guide
Assess your SQL Server configuration in 2 simple steps.
1. Setup
Install the PowerShell SqlServer module using the following command.
Install-Module -Name SqlServer -AllowClobber
2. Invoke assessment
To invoke an assessment against a local SQL Server instance, run the following command.
Get-SqlInstance -ServerInstance 'localhost' | Invoke-SqlAssessment
Sample result:
PS:> Get-SqlInstance -ServerInstance localhost | Invoke-SqlAssessment
TargetPath: Server[@Name='LOCAL']
Sev. Message Check ID Origin
---- ------- -------- ------
Info Enable trace flag 834 to use large-page allocations to improve TF834 Microsoft Ruleset 0.1.202
analytical and data warehousing workloads.
Low Detected deprecated or discontinued feature uses: String literals DeprecatedFeatures Microsoft Ruleset 0.1.202
as column aliases, syscolumns, sysusers, SET FMTONLY ON, XP_API,
Table hint without WITH, More than two-part column name. We
recommend to replace them with features actual for SQL Server
version 14.0.1000.
Medi Amount of single use plans in cache is high (100%). Consider PlansUseRatio Microsoft Ruleset 0.1.202
enabling the Optimize for ad hoc workloads setting on heavy OLTP
ad-hoc workloads to conserve resources.
...
In the results, you will see that each rule has some properties (not the full list):
- Severity (info, low, medium, high)
- Message property explains the recommendation but if you need more info, there is a HelpLink property that points at documentation on the subject.
- Origin shows which ruleset and version the recommendation is coming from
See ruleset.json for a full list of rules and properties.
If you want to get recommendations for all databases on the local instance, run this command.
Get-SqlDatabase -ServerInstance 'localhost' | Invoke-SqlAssessment
Learn more about SQL Assessment API
To learn more about the SQL Assessment API such as customizing and extending rulesets, saving results to a table, etc., visit:
- Docs online page for SQL Assessment API PowerShell cmdlets: https://docs.microsoft.com/sql/sql-assessment-api/sql-assessment-api-overview
- SQL Assessment User Guide
- SQL Assessment API Tutorial notebook: SQLAssessmentAPITutorialNotebook.ipynb
- Azure Data Studio extension: https://techcommunity.microsoft.com/t5/sql-server/released-sql-server-assessment-extension-for-azure-data-studio/ba-p/1470603