Attach command (TMSL)

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

Attaches a tabular database file to a server.


      "folder":"C:\\Program Files\\Microsoft SQL Server\\MSAS13.Tabular\\OLAP\\Data\\",  

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

Property Default Description
database [Required] The name of the database object to be attached.
folder [Required] The folder that contains the attached database.
password Empty The password to use to encrypt secrets in the attached database.
readWriteMode readWrite An enumeration value that indicates the access modes allowed to the database.

The enumeration values are as follows:

readWrite – Read-write access is allowed.

readOnly – Read-only access is allowed.

readOnlyExclusive – Read-only exclusive access is allowed.


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 Attach Database dialog box.