Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
SQL Server Analysis Services
Azure Analysis Services
Fabric/Power BI Premium
As a SQL Server Analysis Services database administrator (dba), you might need to take a database offline temporarily. When you're ready, you can bring the database back online on the same server instance or on a different one. Business needs often drive these situations. For example, you might want to move the database to a different disk for better performance, gain room for database growth, or upgrade a product. For these cases and more, use the Attach and Detach commands to take the database offline and bring it back online with minimal effort.
Attach and detach commands
Use the Attach command to bring online a database that you took offline. You can attach the database to the original server instance or to another instance. When you attach a database, specify the ReadWriteMode setting for the database. Use the Detach command to take a database offline from the server.
Attach and detach usage
Use the Attach command to bring an existing database structure online. If you attach the database in ReadWrite mode, you can attach it only once to a server instance. However, if you attach the database in ReadOnly mode, you can attach it multiple times to different server instances. You can't attach the same database more than once to the same server instance. An error occurs when you try to attach the same database more than once, even if you copy the data to separate folders.
Important
If a password is required to detach the database, you must provide the same password to attach the database.
Use the Detach command to take an existing database structure offline. When you detach a database, provide a password to protect confidential metadata.
Important
To protect the content of the data files, use an access control list for the folder, subfolders, and data files.
When you detach a database, the server follows these steps.
| Detaching a read/write database | Detaching a read-only database |
|---|---|
| 1) The server issues a request for a CommitExclusive Lock on the database 2) The server waits until all ongoing transactions are either committed or rolled back 3) The server builds all the metadata that it must have to detach the database 4) The database is marked as deleted 5) The server commits the transaction |
1) The database is marked as deleted 2) The server commits the transaction Note: The detaching password can't be changed for a read-only database. An error is raised if the password parameter is provided for an attached database that already contains a password. |
You must execute the Attach and Detach commands as single operations. You can't combine them with other operations in the same transaction. Also, the Attach and Detach commands are atomic transactional commands. This condition means the operation either succeeds or fails. No database is left in an uncompleted state.
Important
You need server or database administrator privileges to execute the Detach command.
Important
You need server administrator privileges to execute the Attach command.
See also
Move an Analysis Services Database
Database ReadWriteModes
Switch an Analysis Services database between ReadOnly and ReadWrite modes
Detach Element
Attach Element