From 61ddf297f954a8e9844edd36941d8bae9a38cd7c Mon Sep 17 00:00:00 2001 From: junierch <109680247+junierch@users.noreply.github.com> Date: Tue, 7 Feb 2023 12:48:56 -0500 Subject: [PATCH] Adding SQL tools team recommendations (#21866) --- extensions/sql-migration/src/api/sqlUtils.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions/sql-migration/src/api/sqlUtils.ts b/extensions/sql-migration/src/api/sqlUtils.ts index 818a57a58c..439d7068b4 100644 --- a/extensions/sql-migration/src/api/sqlUtils.ts +++ b/extensions/sql-migration/src/api/sqlUtils.ts @@ -44,12 +44,15 @@ const query_target_databases_sql = ` AND is_distributor <> 1 ORDER BY db.name;`; +// NOTES: Converting the size to BIGINT is need to handle the large database scenarios. +// Size column in sys.master_files represents the number of pages and each page is 8 KB +// The end result is size in MB, 8/1024 = 1/128. const query_databases_with_size = ` WITH db_size AS ( - SELECT database_id, CAST(SUM(size) / 128 AS bigint) size + SELECT database_id, CAST(SUM(CAST(size as BIGINT)) / 128 AS BIGINT) size FROM sys.master_files with (nolock) GROUP BY database_id )