Skip to content

Latest commit

 

History

History
45 lines (35 loc) · 4.15 KB

File metadata and controls

45 lines (35 loc) · 4.15 KB
title Locking and Unlocking Databases (XMLA) | Microsoft Docs
ms.custom
ms.date 03/06/2017
ms.prod sql-server-2014
ms.reviewer
ms.technology analysis-services
ms.topic reference
helpviewer_keywords
locking [XML for Analysis]
XML for Analysis, locking
XMLA, locking
unlocking objects
ms.assetid 451afa58-ce03-4ecc-8dd3-9e7e8559b5f1
author minewiskan
ms.author owend
manager craigg

Locking and Unlocking Databases (XMLA)

You can lock and unlock databases using, respectively, the Lock and Unlock commands in XML for Analysis (XMLA). Typically, other XMLA commands automatically lock and unlock objects as needed to complete the command during execution. You can explicitly lock or unlock a database to perform multiple commands within a single transaction, such as a Batch command, while preventing other applications from committing a write transaction to the database.

Locking Databases

The Lock command locks an object, either for shared or exclusive use, within the context of the currently active transaction. A lock on an object prevents transactions from committing until the lock is removed. [!INCLUDEmsCoName] [!INCLUDEssNoVersion] [!INCLUDEssASnoversion] supports two types of locks, shared locks and exclusive locks. For more information about the lock types supported by [!INCLUDEssASnoversion], see Mode Element (XMLA).

[!INCLUDEssASnoversion] allows only databases to be locked. The Object element must contain an object reference to an [!INCLUDEssASnoversion] database. If the Object element is not specified or if the Object element refers to an object other than a database, an error occurs.

Important

Only database administrators or server administrators can explicitly issue a Lock command.

Other commands implicitly issue a Lock command on an [!INCLUDEssASnoversion] database. Any operation that reads data or metadata from a database, such as any Discover method or an Execute method running a Statement command, implicitly issues a shared lock on the database. Any transaction that commits changes in data or metadata to an object on an [!INCLUDEssASnoversion] database, such as an Execute method running an Alter command, implicitly issues an exclusive lock on the database.

Unlocking Objects

The Unlock command removes a lock established within the context of the currently active transaction.

Important

Only database administrators or server administrators can explicitly issue an Unlock command.

All locks are held in the context of the current transaction. When the current transaction is committed or rolled back, all locks defined within the transaction are automatically released.

See Also

Lock Element (XMLA)
Unlock Element (XMLA)
Developing with XMLA in Analysis Services