Add a SQL Server license to an existing Windows server
Compute Engine lets you install SQL Server on Windows instances and use
pay-as-you-go (PAYG) licenses. This document describes how you can perform the
following:
After adding a license string to the Windows instance's boot disk, you are
billed according to the pricing of SQL 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 Trusted Cloud to accurately
track, bill, and report on SQL Server license usage. This metadata is required
when using PAYG SQL Server licenses. Add a SQL Server license to an existing boot
disk using the following procedure:
Identify the license you want to add to an instance. For SQL Server, the
license needs to match both the version and edition you want to run. For the
list of valid SQL Server license strings, see the License strings tab in
the operating system details for SQL Server
document.
Stop the instance:
gcloud compute instances stop VM_NAME
Replace VM_NAME with the name of the instance to
stop.
Identify the boot disk:
gcloud compute instances describe VM_NAME
Replace VM_NAME with the name of the instance.
Verify that the output is similar to the following:
CLONED_BOOT_DISK_NAME: the name you want to
give the cloned book disk
SQL_SERVER_LICENSE: the SQL Server license you
want to add to the boot disk. For information on SQL Server licenses, see
the License tab in section SQL Server on Windows
BOOT_DISK_NAME: the name of the source boot
disk that you want to clone
BOOT_DISK_ZONE: the zone of the source boot
disk
CLONED_BOOT_DISK_ZONE: the zone in which you
want to create the cloned boot disk
VM_INSTANCE_NAME: the name of the instance to
which you want to attach the SQL Server media disk
SQL_SERVER_MEDIA_DISK_NAME: the name of the SQL
Server media disk
SQL_SERVER_ZONE: the zone of the instance
After the SQL Server media disk is attached to a instance, on your Windows
machine, open the Disk Management page to see if the disk has a drive
letter assigned to it. If not, right-click on the disk and select Online
to bring it online. The SQL Server media disk is now the D: drive on the
Disk Management page and in Windows Explorer.
Verify that the boot disk of your instance has at least 5 GB of free disk
space and copy the SQL Server media to your boot disk:
Apply a SQL server product key to a Compute Engine instance
In order to upgrade the SQL Server installation media, you must obtain and apply
a product key to the Compute Engine instance on which the SQL Server is
installed. To obtain the product key and upgrade the SQL Server installation
media, 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 installed using Remote Desktop and sign in using your domain user.
Right-click the Start button (or press Win+X) and select Run.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-26 UTC."],[[["\u003cp\u003eCompute Engine allows you to install SQL Server on Windows virtual machines (VMs) with pay-as-you-go (PAYG) licensing, which is tracked and billed through license metadata on the boot disk.\u003c/p\u003e\n"],["\u003cp\u003eAdding a SQL Server license to a VM's boot disk involves stopping the VM, detaching the existing boot disk, cloning it with the new license, and reattaching the cloned disk as the new boot disk, noting that once a license is added, it cannot be removed.\u003c/p\u003e\n"],["\u003cp\u003eSQL Server installation media can be obtained by creating a new disk from a SQL Server image, attaching it to a VM, and then copying the installation files to the VM's boot disk, after which the SQL server media disk can be detached.\u003c/p\u003e\n"],["\u003cp\u003eUpgrading the SQL Server edition on a VM requires obtaining a new product key from the installation media and applying it through the SQL Server setup process.\u003c/p\u003e\n"],["\u003cp\u003ePAYG SQL Server licenses are available for Web, Standard, and Enterprise editions.\u003c/p\u003e\n"]]],[],null,["# Add a SQL Server license to an existing Windows server\n\nWindows\n\n*** ** * ** ***\n\nCompute Engine lets you install SQL Server on Windows instances and use\npay-as-you-go (PAYG) licenses. This document describes how you can perform the\nfollowing:\n\n1. [Add SQL Server license metadata to a boot disk](#add-sql-server-license)\n2. [Obtain SQL Server media and install SQL Server](#obtain-sql-server-media)\n3. [Apply a SQL server product key to a Compute Engine instance](#apply-sql-server-product-key)\n\nBilling\n-------\n\nAfter adding a license string to the Windows instance's boot disk, you are\nbilled according to the pricing of [SQL Server images](/compute/disks-image-pricing#sql_server_pricing).\n\nLimitations\n-----------\n\n- You can only add PAYG licenses for the following editions of SQL Server:\n\n - SQL Server Web edition\n - SQL Server Standard edition\n - SQL Server Enterprise edition\n\nAdd a SQL Server license\n------------------------\n\nSQL Server license metadata on a boot disk allows Google Cloud to accurately\ntrack, bill, and report on SQL Server license usage. This metadata is required\nwhen using PAYG SQL Server licenses. Add a SQL Server license to an existing boot\ndisk using the following procedure:\n| **Caution:** After you add a license to an instance, the license is bound to the instance and you cannot remove the license from the instance.\n\n1. Identify the license you want to add to an instance. For SQL Server, the\n license needs to match both the version and edition you want to run. For the\n list of valid SQL Server license strings, see the **License strings** tab in\n the [operating system details for SQL Server](/compute/docs/images/os-details#sql_server)\n document.\n\n2. Stop the instance:\n\n ```\n gcloud compute instances stop VM_NAME\n ```\n\n Replace \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e with the name of the instance to\n stop.\n3. Identify the boot disk:\n\n ```\n gcloud compute instances describe VM_NAME\n ```\n\n Replace \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e with the name of the instance.\n4. Verify that the output is similar to the following:\n\n disks:\n - autoDelete: true\n boot: true\n deviceName: \u003cvar translate=\"no\"\u003eBOOT_DISK_NAME\u003c/var\u003e\n diskSizeGb: '20'\n guestOsFeatures:\n - type: UEFI_COMPATIBLE\n index: 0\n interface: SCSI\n kind: compute#attachedDisk\n licenses:\n - \u003cvar translate=\"no\"\u003eBOOT_DISK_LICENSE_STRING\u003c/var\u003e\n mode: READ_WRITE\n source: https://www.googleapis.com/compute/v1/projects/\u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e/zones/\u003cvar translate=\"no\"\u003eZONE\u003c/var\u003e/disks/\u003cvar translate=\"no\"\u003eBOOT_DISK_NAME\u003c/var\u003e\n type: PERSISTENT\n\n5. Detach the boot disk:\n\n ```\n gcloud compute instances detach-disk VM_NAME --disk=BOOT_DISK_NAME\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e: the name of the instance\n - \u003cvar translate=\"no\"\u003eBOOT_DISK_NAME\u003c/var\u003e: the name of the boot disk\n6. Clone the boot disk and add the additional license:\n\n ```\n gcloud compute disks create CLONED_BOOT_DISK_NAME \\\n --licenses=SQL_SERVER_LICENSE \\\n --source-disk=BOOT_DISK_NAME \\\n --source-disk-zone=BOOT_DISK_ZONE \\\n --zone=CLONED_BOOT_DISK_ZONE\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eCLONED_BOOT_DISK_NAME\u003c/var\u003e: the name you want to give the cloned book disk\n - \u003cvar translate=\"no\"\u003eSQL_SERVER_LICENSE\u003c/var\u003e: the SQL Server license you want to add to the boot disk. For information on SQL Server licenses, see the License tab in section [SQL Server on Windows](/compute/docs/images/os-details#sql_server_on_windows)\n - \u003cvar translate=\"no\"\u003eBOOT_DISK_NAME\u003c/var\u003e: the name of the source boot disk that you want to clone\n - \u003cvar translate=\"no\"\u003eBOOT_DISK_ZONE\u003c/var\u003e: the zone of the source boot disk\n - \u003cvar translate=\"no\"\u003eCLONED_BOOT_DISK_ZONE\u003c/var\u003e: the zone in which you want to create the cloned boot disk\n7. Verify that the new disk has the correct license:\n\n ```\n gcloud compute disks describe CLONED_BOOT_DISK_NAME \\\n --zone=CLONED_BOOT_DISK_ZONE\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eCLONED_BOOT_DISK_NAME\u003c/var\u003e: the name of the cloned book disk\n - \u003cvar translate=\"no\"\u003eCLONED_BOOT_DISK_ZONE\u003c/var\u003e: the zone of the cloned boot disk\n8. Attach the new disk as the boot disk for the instance:\n\n ```\n gcloud compute instances attach-disk VM_NAME \\\n --disk=CLONED_BOOT_DISK_NAME\n --boot\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e: the name of the instance to which you want to attach the cloned boot disk\n - \u003cvar translate=\"no\"\u003eCLONED_BOOT_DISK_NAME\u003c/var\u003e: the name of the cloned book disk\n9. Verify that the instance's boot disk is the new cloned disk with SQL Server\n licensing.\n\n ```\n gcloud compute instances describe VM_NAME\n ```\n\n Replace \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e with the name of the instance.\n10. Start the instance.\n\n ```\n gcloud compute instances start VM_NAME\n ```\n\n Replace \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e with the name of the instance.\n11. (Optional) When you are sure that you don't want to revert back to the earlier\n boot disk, you can delete the disk.\n\n ```\n gcloud compute disks delete BOOT_DISK_NAME \\\n --zone=BOOT_DISK_ZONE\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eBOOT_DISK_NAME\u003c/var\u003e: the name of the boot disk that you want to delete\n - \u003cvar translate=\"no\"\u003eBOOT_DISK_ZONE\u003c/var\u003e: the zone of the boot disk\n\nObtain the SQL Server media and install SQL Server\n--------------------------------------------------\n\nTo obtain the SQL Server installation media and copy it to a Compute Engine\ninstance boot disk, do the following:\n\n1. Create a new disk containing the SQL Server installation media using any\n version of SQL server (for example, 2019 Enterprise):\n\n ```\n gcloud compute disks create SQL_SERVER_MEDIA_DISK_NAME \\\n --image-family=sql-ent-2019-win-2022 \\\n --image-project=windows-sql-cloud \\\n --zone=SQL_SERVER_ZONE\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eSQL_SERVER_MEDIA_DISK_NAME\u003c/var\u003e: the name of the SQL Server media disk that you want to create\n - \u003cvar translate=\"no\"\u003eSQL_SERVER_ZONE\u003c/var\u003e: the zone in which you want to create the SQL Server media disk\n2. Attach the disk to any existing Compute Engine instance:\n\n ```\n gcloud compute instances attach-disk VM_INSTANCE_NAME \\\n --disk=SQL_SERVER_MEDIA_DISK_NAME\n --zone=SQL_SERVER_ZONE\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eVM_INSTANCE_NAME\u003c/var\u003e: the name of the instance to which you want to attach the SQL Server media disk\n - \u003cvar translate=\"no\"\u003eSQL_SERVER_MEDIA_DISK_NAME\u003c/var\u003e: the name of the SQL Server media disk\n - \u003cvar translate=\"no\"\u003eSQL_SERVER_ZONE\u003c/var\u003e: the zone of the instance\n\n After the SQL Server media disk is attached to a instance, on your Windows\n machine, open the **Disk Management** page to see if the disk has a drive\n letter assigned to it. If not, right-click on the disk and select **Online**\n to bring it online. The SQL Server media disk is now the `D:` drive on the\n **Disk Management** page and in Windows Explorer.\n3. Verify that the boot disk of your instance has at least 5 GB of free disk\n space and copy the SQL Server media to your boot disk:\n\n ```\n robocopy /mir d:\\sql_server_install\\ c:\\sql_server_install\n ```\n4. Detach the SQL Server media disk from the instance:\n\n ```\n gcloud compute instances detach-disk VM_INSTANCE_NAME \\\n --disk=SQL_SERVER_MEDIA_DISK_NAME\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eVM_INSTANCE_NAME\u003c/var\u003e: the name of the instance you from which you want to detach the SQL Server media disk\n - \u003cvar translate=\"no\"\u003eSQL_SERVER_MEDIA_DISK_NAME\u003c/var\u003e: the name of the SQL Server media disk that you want to detach from the instance\n\nFor more information, see [Microsoft SQL Server installation guide](https://learn.microsoft.com/en-us/sql/database-engine/install-windows/install-sql-server?view=sql-server-ver16#sql-server-installation).\n\nApply a SQL server product key to a Compute Engine instance\n-----------------------------------------------------------\n\nIn order to upgrade the SQL Server installation media, you must obtain and apply\na product key to the Compute Engine instance on which the SQL Server is\ninstalled. To obtain the product key and upgrade the SQL Server installation\nmedia, do the following:\n\n1. Obtain the product key from the SQL Server installation media:\n\n ```\n C:\\\u003e type C:\\sql_server_install\\x64\\DefaultSetup.ini\n ```\n2. Connect to the instance on which the SQL Server is installed [using Remote Desktop](/compute/docs/instances/connecting-to-windows) and sign in using your domain user.\n\n3. Right-click the **Start** button (or press **Win+X** ) and select **Run**.\n\n4. Confirm the elevation prompt by clicking **Yes**.\n\n5. Start the SQL Server setup:\n\n ```\n & c:\\sql_server_install\\setup.exe\n ```\n\nWhat's next\n-----------\n\n- [Learn about licenses](/compute/docs/licenses/about)\n\n- [View the SQL Server tutorials](/compute/docs/tutorials#sql-server)\n\n- [View the supported editions of SQL Server](/compute/docs/images/os-details#sql_server)"]]