diff --git a/internal/services/mssql/mssql_database_resource.go b/internal/services/mssql/mssql_database_resource.go
index bdbd1fb1514a..def827ee6282 100644
--- a/internal/services/mssql/mssql_database_resource.go
+++ b/internal/services/mssql/mssql_database_resource.go
@@ -1894,18 +1894,19 @@ func resourceMsSqlDatabaseSchema() map[string]*pluginsdk.Schema {
 }
 
 func calculateMaxSizeBytes(v float64) (*int64, error) {
-	maxSizeBytes := int64(0)
+	var maxSizeBytes int64
 	integer := isPositiveInteger(v)
 	if integer {
 		maxSizeBytes = int64(math.Round(v)) * 1073741824
 	} else {
 		// When `max_size_gb` is below 1GB, the API only accepts 100MB and 500MB. 100MB is 104857600, and 500MB is 524288000.
 		// Since 100MB != 0.1 * 1073741824 and 500MB != 0.5 * 1073741824, directly specify the Bytes when `max_size_gb` is specified `0.1` or `0.5`.
-		if int64(math.Round(v*10)) == 1 {
+		switch int64(math.Round(v * 10)) {
+		case 1:
 			maxSizeBytes = 104857600
-		} else if int64(math.Round(v*10)) == 5 {
+		case 5:
 			maxSizeBytes = 524288000
-		} else {
+		default:
 			return nil, fmt.Errorf("`max_size_gb` allows `0.1`, `0.5` and positive integers greater than or equal to 1")
 		}
 	}
diff --git a/internal/services/mssql/mssql_database_resource_test.go b/internal/services/mssql/mssql_database_resource_test.go
index 0e8faf2b61d6..c8a34a53457f 100644
--- a/internal/services/mssql/mssql_database_resource_test.go
+++ b/internal/services/mssql/mssql_database_resource_test.go
@@ -2409,10 +2409,10 @@ func (r MsSqlDatabaseResource) maxSizeGB(data acceptance.TestData, maxSizeGb flo
 %[1]s
 
 resource "azurerm_mssql_database" "test" {
-  name      = "acctest-db-%[2]d"
-  server_id = azurerm_mssql_server.test.id
-  sku_name       = "Basic"
-  max_size_gb    = %[3]f
+  name        = "acctest-db-%[2]d"
+  server_id   = azurerm_mssql_server.test.id
+  sku_name    = "Basic"
+  max_size_gb = %[3]f
 }
 `, r.template(data), data.RandomInteger, maxSizeGb)
 }