Many of you are, hopefully, starting up projects to upgrade your current SQL Server to the shiny SQL Server 2017. One of the first things to do is run the Database Migration Assistant (DMA) (https://www.microsoft.com/en-us/download/details.aspx?id=53595)
What does it do? Nicely said on the MS website:
Data Migration Assistant (DMA) enables you to upgrade to a modern data platform by detecting compatibility issues that can impact database functionality on your new version of SQL Server. It recommends performance and reliability improvements for your target environment. It allows you to not only move your schema and data, but also uncontained objects from your source server to your target server.
Basically, it gives you a list of issues to tackle before you can go ahead with your migration. Not all of these issues are blocking, most might be warnings and won’t prevent you to upgrade to SQL Server 2017. Yet if you’re going to start with an innocent new (SQL) server, why not clean-up that dirty stuff along the way huh.
This article isn’t about how you use the tool, there’s plenty of information on that to be found online, but how you can make the results more readable.
After DMA has finished the assessment you’ll get an overview of all the issues found per compatibility. You also have the option to export this report as, which is good to know, DMA doesn’t save the results for later itself. Once you close DMA the results are gone.
Exporting the report can be done in two formats, as a .JSON file or as a .CSV file.
I dare you to export into a CSV file. I tried this, which resulted in a 6MB file with 58.000 lines of ‘data’. #Unreadable.
The other option provided is to export it as a .JSON file.
When you open the file, in notepad, you get something like this:
{
"Name": "DMATest",
"Databases": [
{
"ServerName": "JANVDP-SQL\\TEST",
"Name": "DMA_Test",
"CompatibilityLevel": "CompatLevel90",
"SizeMB": 242420.0,
"Status": "Completed",
"ServerVersion": "10.50.6529.0",
"AssessmentRecommendations": [
{
"CompatibilityLevel": "CompatLevel140",
"Category": "Compatibility",
"Severity": "Error",
"ChangeCategory": "BreakingChange",
Still, for the same assessment as mentioned earlier this generated a 2MB file with almost 19.000 lines of the above syntax. Not very readable either.
I decided to import the JSON file into a SQL Server table.
First I created a database, DMA, and the following table:
USE [DMA]
GO
DROP TABLE IF EXISTS DMA.dbo.ReportData
GO
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ReportData](
[ImportDate] [datetime] NULL,
[ServerName] [nvarchar](255) NULL,
[DatabaseName] [nvarchar](255) NULL,
[CurrentCompatibilityLevel] [nvarchar](30) NULL,
[ServerVersion] [nvarchar](255) NULL,
[TargetCompatibilityLevel] [nvarchar](30) NULL,
[Severity] [nvarchar](15) NULL,
[ChangeCategory] [nvarchar](50) NULL,
[Title] [nvarchar](max) NULL,
[Impact] [nvarchar](max) NULL,
[Recommendation] [nvarchar](max) NULL,
[MoreInfo] [nvarchar](max) NULL,
[ImpactedObjectName] [nvarchar](255) NULL,
[ImpactedObjectType] [nvarchar](50) NULL,
[ImpactDetail] [nvarchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
To import your JSON file into the table, put the file in a location accessible for your SQL Server.
Use the following script to import the data; don’t forget to alter the location\name of your file:
DECLARE @OpenJSON varchar(max)
SELECT @OpenJSON=BulkColumn
FROM OPENROWSET (BULK 'C:\Temp\DMA\DMATest.json', SINGLE_CLOB) as j
INSERT INTO DMA.dbo.ReportData
SELECT GETDATE() as ImportDate, ServerName, DatabaseName, CurrentCompatibilityLevel, ServerVersion, TargetCompatibilityLevel, Severity, ChangeCategory, Title, Impact, Recommendation, MoreInfo, ImpactedObjectName, ImpactedObjectType, ImpactDetail
FROM OPENJSON(@OpenJSON, '$.Databases')
WITH(
ServerName nvarchar(255) '$.ServerName',
DatabaseName nvarchar(255) '$.Name',
CurrentCompatibilityLevel nvarchar(30) '$.CompatibilityLevel',
SizeMB nvarchar(255) '$.SizeMB',
Status nvarchar(255) '$.Status',
ServerVersion nvarchar(255) '$.ServerVersion',
AssessmentRecommendations nvarchar(max) '$.AssessmentRecommendations' AS JSON
)
CROSS APPLY OPENJSON (AssessmentRecommendations)
WITH(
TargetCompatibilityLevel nvarchar(30) '$.CompatibilityLevel',
Category nvarchar(255) '$.Category',
Severity nvarchar(15) '$.Severity',
ChangeCategory nvarchar(50) '$.ChangeCategory',
RuleId nvarchar(255) '$.RuleId',
Title nvarchar(max) '$.Title',
Impact nvarchar(max) '$.Impact',
Recommendation nvarchar(max) '$.Recommendation',
MoreInfo nvarchar(max) '$.MoreInfo',
ImpactedObjects nvarchar(max) '$.ImpactedObjects' AS JSON
)
CROSS APPLY OPENJSON (ImpactedObjects)
WITH(
ImpactedObjectName nvarchar(255) '$.Name',
ImpactedObjectType nvarchar(50) '$.ObjectType',
ImpactDetail nvarchar(max) '$.ImpactDetail'
)
GO
There you go, simple as that.
The only “problem” now is that DMA generates duplicates for a lot of issues, based on the target compatibility level. For example, if your current compatibility level of your database is 90 (SQL Server 2005) it will report 5 times the same issue, once for target compatibility level 100, 110, 120, 130 and 140.
To retrieve only the latest version you can use this statement:
;WITH cte AS
(
SELECT [ImportDate]
,[ServerName]
,[DatabaseName]
,[CurrentCompatibilityLevel]
,[ServerVersion]
,[TargetCompatibilityLevel]
,[Severity]
,[ChangeCategory]
,[Title]
,[Impact]
,[Recommendation]
,[MoreInfo]
,[ImpactedObjectName]
,[ImpactedObjectType]
,[ImpactDetail]
, rn = ROW_NUMBER() OVER (PARTITION BY [ServerName], [DatabaseName], [ImpactedObjectName]
ORDER BY [ServerName], [DatabaseName], [ImpactedObjectName], [TargetCompatibilityLevel] DESC)
FROM [DMA].[dbo].[ReportData]
)
SELECT *
FROM cte
WHERE rn = 1
ORDER BY [ServerName], [DatabaseName], [ImpactedObjectName], [TargetCompatibilityLevel];
GO
You can use the same CTE to remove the different versions if that’s what you like. Or you can keep the duplicates in order to show your manager how much work there’s to do to get some more days for your project.
The results now are 547 records, coming from 58.000 in excel and 19.000 in the json file.
Happy new SQL Server upgrade!
© 2023 Kohera
Crafted by
© 2022 Kohera
Crafted by
Cookie | Duration | Description |
---|---|---|
ARRAffinity | session | ARRAffinity cookie is set by Azure app service, and allows the service to choose the right instance established by a user to deliver subsequent requests made by that user. |
ARRAffinitySameSite | session | This cookie is set by Windows Azure cloud, and is used for load balancing to make sure the visitor page requests are routed to the same server in any browsing session. |
cookielawinfo-checkbox-advertisement | 1 year | Set by the GDPR Cookie Consent plugin, this cookie records the user consent for the cookies in the "Advertisement" category. |
cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
CookieLawInfoConsent | 1 year | CookieYes sets this cookie to record the default button state of the corresponding category and the status of CCPA. It works only in coordination with the primary cookie. |
elementor | never | The website's WordPress theme uses this cookie. It allows the website owner to implement or change the website's content in real-time. |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |
Cookie | Duration | Description |
---|---|---|
__cf_bm | 30 minutes | Cloudflare set the cookie to support Cloudflare Bot Management. |
pll_language | 1 year | Polylang sets this cookie to remember the language the user selects when returning to the website and get the language information when unavailable in another way. |
Cookie | Duration | Description |
---|---|---|
_ga | 1 year 1 month 4 days | Google Analytics sets this cookie to calculate visitor, session and campaign data and track site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognise unique visitors. |
_ga_* | 1 year 1 month 4 days | Google Analytics sets this cookie to store and count page views. |
_gat_gtag_UA_* | 1 minute | Google Analytics sets this cookie to store a unique user ID. |
_gid | 1 day | Google Analytics sets this cookie to store information on how visitors use a website while also creating an analytics report of the website's performance. Some of the collected data includes the number of visitors, their source, and the pages they visit anonymously. |
ai_session | 30 minutes | This is a unique anonymous session identifier cookie set by Microsoft Application Insights software to gather statistical usage and telemetry data for apps built on the Azure cloud platform. |
CONSENT | 2 years | YouTube sets this cookie via embedded YouTube videos and registers anonymous statistical data. |
vuid | 1 year 1 month 4 days | Vimeo installs this cookie to collect tracking information by setting a unique ID to embed videos on the website. |
Cookie | Duration | Description |
---|---|---|
ai_user | 1 year | Microsoft Azure sets this cookie as a unique user identifier cookie, enabling counting of the number of users accessing the application over time. |
VISITOR_INFO1_LIVE | 5 months 27 days | YouTube sets this cookie to measure bandwidth, determining whether the user gets the new or old player interface. |
YSC | session | Youtube sets this cookie to track the views of embedded videos on Youtube pages. |
yt-remote-connected-devices | never | YouTube sets this cookie to store the user's video preferences using embedded YouTube videos. |
yt-remote-device-id | never | YouTube sets this cookie to store the user's video preferences using embedded YouTube videos. |
yt.innertube::nextId | never | YouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen. |
yt.innertube::requests | never | YouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen. |
Cookie | Duration | Description |
---|---|---|
WFESessionId | session | No description available. |