# mes.spAdminDeleteAssetWithHistory

## Description
Recursively deletes an asset and its descendant hierarchy, along with all historical records including counters, events, and linked metadata across MES, SCH, SEC, and QDS schemas.

## Syntax
<b>mes.spAdminDeleteAssetWithHistory @assetId</b>  
<br /><br />

<b>Parameters:</b><br />
@assetId (int): The root asset to delete, along with all descendants.<br /><br />

<b>Returns:</b><br />
int: Total number of rows deleted or updated across all affected tables.

### Code Example

```sql
-- Delete an asset and all historical data
EXEC mes.spAdminDeleteAssetWithHistory @assetId = 2076;
