Add a SQL Server license to an existing Windows server Stay organized with collections Save and categorize content based on your preferences.
Compute Engine lets you install SQL Server on Windows instances and usepay-as-you-go (PAYG) licenses. This document describes how you can perform thefollowing:
- Add SQL Server license metadata to a boot disk
- Obtain SQL Server media and install SQL Server
- Apply a SQL server product key to a Compute Engine instance
Billing
After adding a license string to the Windows instance's boot disk, you arebilled according to the pricing ofSQL Server images.
Limitations
You can only add PAYG licenses for the following editions of SQL Server:
- SQL Server Web edition
- SQL Server Standard edition
- SQL Server Enterprise edition
Add a SQL Server license
SQL Server license metadata on a boot disk allows Google Cloud to accuratelytrack, bill, and report on SQL Server license usage. This metadata is requiredwhen using PAYG SQL Server licenses. Add a SQL Server license to an existing bootdisk using the following procedure:
Caution: After you add a license to an instance, you cannot remove the licensefrom the instance.Identify the license you want to add to an instance. For SQL Server, thelicense needs to match both the version and edition you want to run. For thelist of valid SQL Server license strings, see theLicense strings tab intheoperating system details for SQL Serverdocument.
Stop the instance:
gcloud compute instances stopVM_NAME
Replace
VM_NAME
with the name of the instance tostop.Identify the boot disk:
gcloud compute instances describeVM_NAME
Replace
VM_NAME
with the name of the instance.Verify that the output is similar to the following:
disks:- autoDelete: true boot: true deviceName:BOOT_DISK_NAME diskSizeGb: '20' guestOsFeatures: - type: UEFI_COMPATIBLE index: 0 interface: SCSI kind: compute#attachedDisk licenses: -BOOT_DISK_LICENSE_STRING mode: READ_WRITE source: https://www.googleapis.com/compute/v1/projects/PROJECT_NAME/zones/ZONE/disks/BOOT_DISK_NAME type: PERSISTENT
Detach the boot disk:
gcloud compute instances detach-diskVM_NAME --disk=BOOT_DISK_NAME
Replace the following:
VM_NAME
: the name of the instanceBOOT_DISK_NAME
: the name of the boot disk
Clone the boot disk and add the additional license:
gcloud compute disks createCLONED_BOOT_DISK_NAME \ --licenses=SQL_SERVER_LICENSE \ --source-disk=BOOT_DISK_NAME \ --source-disk-zone=BOOT_DISK_ZONE \ --zone=CLONED_BOOT_DISK_ZONE
Replace the following:
CLONED_BOOT_DISK_NAME
: the name you want togive the cloned book diskSQL_SERVER_LICENSE
: the SQL Server license youwant to add to the boot disk. For information on SQL Server licenses, seethe License tab in sectionSQL Server on WindowsBOOT_DISK_NAME
: the name of the source bootdisk that you want to cloneBOOT_DISK_ZONE
: the zone of the source bootdiskCLONED_BOOT_DISK_ZONE
: the zone in which youwant to create the cloned boot disk
Verify that the new disk has the correct license:
gcloud compute disks describeCLONED_BOOT_DISK_NAME \ --zone=CLONED_BOOT_DISK_ZONE
Replace the following:
CLONED_BOOT_DISK_NAME
: the name of the clonedbook diskCLONED_BOOT_DISK_ZONE
: the zone of the clonedboot disk
Attach the new disk as the boot disk for the instance:
gcloud compute instances attach-diskVM_NAME \ --disk=CLONED_BOOT_DISK_NAME --boot
Replace the following:
VM_NAME
: the name of the instance to which youwant to attach the cloned boot diskCLONED_BOOT_DISK_NAME
: the name of the clonedbook disk
Verify that the instance's boot disk is the new cloned disk with SQL Serverlicensing.
gcloud compute instances describeVM_NAME
Replace
VM_NAME
with the name of the instance.Start the instance.
gcloud compute instances startVM_NAME
Replace
VM_NAME
with the name of the instance.(Optional) When you are sure that you don't want to revert back to the earlierboot disk, you can delete the disk.
gcloud compute disks deleteBOOT_DISK_NAME \ --zone=BOOT_DISK_ZONE
Replace the following:
BOOT_DISK_NAME
: the name of the boot disk thatyou want to deleteBOOT_DISK_ZONE
: the zone of the boot disk
Obtain the SQL Server media and install SQL Server
To obtain the SQL Server installation media and copy it to a Compute Engineinstance boot disk, do the following:
Create a new disk containing the SQL Server installation media using anyversion of SQL server (for example, 2019 Enterprise):
gcloud compute disks createSQL_SERVER_MEDIA_DISK_NAME \ --image-family=sql-ent-2019-win-2022 \ --image-project=windows-sql-cloud \ --zone=SQL_SERVER_ZONE
Replace the following:
SQL_SERVER_MEDIA_DISK_NAME
: the name of the SQLServer media disk that you want to createSQL_SERVER_ZONE
: the zone in which youwant to create the SQL Server media disk
Attach the disk to any existing Compute Engine instance:
gcloud compute instances attach-diskVM_INSTANCE_NAME \ --disk=SQL_SERVER_MEDIA_DISK_NAME --zone=SQL_SERVER_ZONE
Replace the following:
VM_INSTANCE_NAME
: the name of the instance towhich you want to attach the SQL Server media diskSQL_SERVER_MEDIA_DISK_NAME
: the name of the SQLServer media diskSQL_SERVER_ZONE
: the zone of the instance
After the SQL Server media disk is attached to a instance, on your Windowsmachine, open theDisk Management page to see if the disk has a driveletter assigned to it. If not, right-click on the disk and selectOnlineto bring it online. The SQL Server media disk is now the
D:
drive on theDisk Management page and in Windows Explorer.Ensure the boot disk of your instance has at least 5 GB of free disk spaceand copy the SQL Server media to your boot disk:
robocopy /mir d:\sql_server_install\ c:\sql_server_install
Detach the SQL Server media disk from the instance:
gcloud compute instances detach-diskVM_INSTANCE_NAME \ --disk=SQL_SERVER_MEDIA_DISK_NAME
Replace the following:
VM_INSTANCE_NAME
: the name of the instance youfrom which you want to detach the SQL Server media diskSQL_SERVER_MEDIA_DISK_NAME
: the name of the SQLServer media disk that you want to detach from the instance
For more information, seeMicrosoft SQL Server installation guide.
Apply a SQL server product key to a Compute Engine instance
In order to upgrade the SQL Server installation media, you must obtain and applya product key to the Compute Engine instance on which the SQL Server isinstalled. To obtain the product key and upgrade the SQL Server installationmedia, do the following:
Obtain the product key from the SQL Server installation media:
C:\> type C:\sql_server_install\x64\DefaultSetup.ini
Connect to the instance on which the SQL Server is installedusing Remote Desktop and sign in using your domain user.
Right-click theStart button (or pressWin+X) and selectRun.
Confirm the elevation prompt by clickingYes.
Start the SQL Server setup:
& c:\sql_server_install\setup.exe
What's next
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-09 UTC.