Adicionar uma licença do SQL Server a um Windows Server que já existe
O Compute Engine permite instalar o SQL Server em instâncias do Windows e usar licenças de pagamento por uso (PAYG). Neste documento, descrevemos como é possível realizar as seguinte ações:
Depois de adicionar uma string de licença ao disco de inicialização da instância do Windows, você vai receber cobranças de acordo com o preço das imagens do SQL Server.
Limitações
Só é possível adicionar licenças PAYG para as seguintes edições do SQL Server:
SQL Server Web Edition
SQL Server Standard Edition
SQL Server Enterprise Edition
Adicionar uma licença do SQL Server
Os metadados de licença do SQL Server em um disco de inicialização permitem que o Trusted Cloud acompanhe, cobre e gere relatórios com precisão sobre o uso de licenças do SQL Server. Esses metadados são necessários ao usar licenças PAYG do SQL Server. Adicione uma licença do SQL Server a um disco de inicialização que já existe usando o seguinte procedimento:
Identifique a licença que você quer adicionar a uma instância. Para o SQL Server, a licença precisa corresponder à versão e à edição que você quer executar. Para ver a lista de strings de licenças válidas do SQL Server, consulte a guia
Strings de licença no documento Detalhes do sistema operacional para SQL
Server.
Interrompa a instância:
gcloud compute instances stop VM_NAME
Substitua VM_NAME pelo nome da instância a ser
interrompida.
CLONED_BOOT_DISK_NAME: o nome que você quer dar ao disco de livros clonado.
SQL_SERVER_LICENSE: a licença do SQL Server que você
quer adicionar ao disco de inicialização. Para informações sobre licenças do SQL Server,
consulte a guia "Licença" na seção SQL Server no Windows.
BOOT_DISK_NAME: o nome do disco de inicialização de origem que você quer clonar.
BOOT_DISK_ZONE: a zona do disco de inicialização de origem.
CLONED_BOOT_DISK_ZONE: a zona em que você quer criar o disco de inicialização clonado.
VM_INSTANCE_NAME: o nome da instância a que você quer anexar o disco de mídia do SQL Server
SQL_SERVER_MEDIA_DISK_NAME: o nome do disco de mídia do SQL Server
SQL_SERVER_ZONE: a zona da instância;
Depois que o disco de mídia do SQL Server for anexado a uma instância, na sua máquina Windows, abra a página Gerenciamento de Disco para ver se o disco tem uma letra de unidade atribuída a ele. Caso contrário, clique com o botão direito do mouse no disco e selecione Online para deixá-lo on-line. O disco de mídia do SQL Server agora é a unidade D: na página Gerenciamento de disco e no Windows Explorer.
Verifique se o disco de inicialização da instância tem pelo menos 5 GB de espaço livre em disco e copie a mídia do SQL Server para ele:
Aplicar uma chave do produto do SQL Server a uma instância do Compute Engine
Para fazer upgrade da mídia de instalação do SQL Server, é necessário conseguir e aplicar uma chave do produto à instância do Compute Engine em que o SQL Server está instalado. Para conseguir a chave do produto e fazer upgrade da mídia de instalação do SQL Server, faça isto:
Consiga a chave do produto na mídia de instalação do SQL Server:
C:\> type C:\sql_server_install\x64\DefaultSetup.ini
Conecte-se à instância em que o SQL Server está instalado usando a Área de trabalho remota e faça login com o usuário do domínio.
Clique com o botão direito do mouse no botão Iniciar (ou pressione Win+X) e selecione Executar.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Não contém as informações de que eu preciso","missingTheInformationINeed","thumb-down"],["Muito complicado / etapas demais","tooComplicatedTooManySteps","thumb-down"],["Desatualizado","outOfDate","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Problema com as amostras / o código","samplesCodeIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-19 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)"]]