Ajouter une licence SQL Server à un serveur Windows existant
Compute Engine vous permet d'installer SQL Server sur des instances Windows et d'utiliser des licences de paiement à l'usage (PAYG). Ce document explique comment effectuer les opérations suivantes :
Après avoir ajouté une chaîne de licence au disque de démarrage de l'instance Windows, vous êtes facturé selon les tarifs des images SQL Server.
Limites
Vous ne pouvez ajouter des licences PAYG que pour les éditions suivantes de SQL Server :
SQL Server Web Edition
SQL Server Standard Edition
SQL Server Enterprise Edition
Ajouter une licence SQL Server
Les métadonnées de licence SQL Server sur un disque de démarrage permettent à Trusted Cloud de suivre, de facturer et de générer des rapports précis sur l'utilisation des licences SQL Server. Ces métadonnées sont requises lors de l'utilisation de licences SQL Server PAYG. Ajoutez une licence SQL Server à un disque de démarrage existant en procédant comme suit :
Identifiez la licence que vous souhaitez ajouter à une instance. Pour SQL Server, la licence doit correspondre à la fois à la version et à l'édition que vous souhaitez exécuter. Pour obtenir la liste des chaînes de licence SQL Server valides, consultez l'onglet Chaînes de licence du document Détails des systèmes d'exploitation pour SQL Server.
Arrêtez l'instance :
gcloud compute instances stop VM_NAME
Remplacez VM_NAME par le nom de l'instance à arrêter.
CLONED_BOOT_DISK_NAME : nom que vous souhaitez attribuer au disque de démarrage cloné.
SQL_SERVER_LICENSE : licence SQL Server que vous souhaitez ajouter au disque de démarrage. Pour plus d'informations sur les licences SQL Server, consultez l'onglet "Licence" dans la section SQL Server sous Windows.
BOOT_DISK_NAME : nom du disque de démarrage source que vous souhaitez cloner.
BOOT_DISK_ZONE : zone du disque de démarrage source.
CLONED_BOOT_DISK_ZONE : zone dans laquelle vous souhaitez créer le disque de démarrage cloné.
Vérifiez que le nouveau disque dispose de la bonne licence :
VM_INSTANCE_NAME : nom de l'instance à laquelle vous souhaitez associer le disque multimédia SQL Server.
SQL_SERVER_MEDIA_DISK_NAME : nom du disque multimédia SQL Server.
SQL_SERVER_ZONE : zone de l'instance
Une fois le disque multimédia SQL Server associé à une instance, sur votre machine Windows, ouvrez la page Gestion des disques pour vérifier si une lettre de lecteur est attribuée au disque. Si ce n'est pas le cas, effectuez un clic droit sur le disque et sélectionnez En ligne pour le mettre en ligne. Le disque multimédia SQL Server est désormais le lecteur D: sur la page Gestion du disque et dans l'Explorateur Windows.
Vérifiez que le disque de démarrage de votre instance dispose d'au moins 5 Go d'espace disque disponible et copiez le support SQL Server sur votre disque de démarrage :
Appliquer une clé produit SQL Server à une instance Compute Engine
Pour mettre à niveau le support d'installation SQL Server, vous devez obtenir et appliquer une clé de produit à l'instance Compute Engine sur laquelle SQL Server est installé. Pour obtenir la clé produit et mettre à niveau le support d'installation de SQL Server, procédez comme suit :
Obtenez la clé de produit à partir du support d'installation SQL Server :
C:\> type C:\sql_server_install\x64\DefaultSetup.ini
Connectez-vous à l'instance sur laquelle SQL Server est installé à l'aide du Bureau à distance, puis connectez-vous à l'aide de votre utilisateur de domaine.
Effectuez un clic droit sur le bouton Démarrer (ou appuyez sur Win+X) et sélectionnez Exécuter.
Confirmez l'invite d'élévation en cliquant sur Yes (Oui).
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/08/19 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Il n'y a pas l'information dont j'ai besoin","missingTheInformationINeed","thumb-down"],["Trop compliqué/Trop d'étapes","tooComplicatedTooManySteps","thumb-down"],["Obsolète","outOfDate","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Mauvais exemple/Erreur de code","samplesCodeIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 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)"]]