Detach command (TMSL)

Applies to: SQL Server 2016 and later Analysis Services Azure Analysis Services Power BI Premium

Detaches a tabular database from a server.


   "detach": {    
      "password": "secret"  

The properties accepted by the JSON detach command are as follows.

Property Default Description
database [Required] The name of the database object to be detached.
password Empty The password to use to encrypt secrets in the detached database.


Returns an empty result when the command succeeds. Otherwise, an XMLA exception is returned.

Usage (endpoints)

This command element is used in a statement of the Execute Method (XMLA) call over an XMLA endpoint, exposed in the following ways:

  • As an XMLA window in SQL Server Management Studio (SSMS)

  • As an input file to the invoke-ascmd PowerShell cmdlet

  • As an input to an SSIS task or SQL Server Agent job

You can generate a ready-made script for this command from SSMS by clicking the Script button on the Detach dialog box.