---
title: "Delete Data or Log Files from a Database | Microsoft Docs"
ms.custom: ""
ms.date: "03/14/2017"
ms.prod: "sql"
ms.prod_service: "database-engine"
ms.service: ""
ms.component: "databases"
ms.reviewer: ""
ms.suite: "sql"
ms.technology:
- "database-engine"
ms.tgt_pltfrm: ""
ms.topic: "article"
helpviewer_keywords:
- "logs [SQL Server], files"
- "deleting files"
- "removing files"
- "removing data"
- "data deletions [SQL Server]"
- "file deletion [SQL Server]"
- "deleting data"
ms.assetid: 0db4018c-ce2c-4ba1-bb29-1e4f3791c925
caps.latest.revision: 33
author: "stevestein"
ms.author: "sstein"
manager: "craigg"
ms.workload: "Active"
---
# Delete Data or Log Files from a Database
[!INCLUDE[appliesto-ss-xxxx-xxxx-xxx-md](../../includes/appliesto-ss-xxxx-xxxx-xxx-md.md)]
This topic describes how to delete data or log files in [!INCLUDE[ssCurrent](../../includes/sscurrent-md.md)] by using [!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)] or [!INCLUDE[tsql](../../includes/tsql-md.md)].
**In This Topic**
- **Before you begin:**
[Prerequisites](#Prerequisites)
[Security](#Security)
- **To delete data or logs files from a database, using:**
[SQL Server Management Studio](#SSMSProcedure)
[Transact-SQL](#TsqlProcedure)
## Before You Begin
### Prerequisites
- A file must be empty before it can be deleted. For more information, see [Shrink a File](../../relational-databases/databases/shrink-a-file.md).
### Security
#### Permissions
Requires ALTER permission on the database.
## Using SQL Server Management Studio
#### To delete data or log files from a database
1. In **Object Explorer**, connect to an instance of the [!INCLUDE[ssDEnoversion](../../includes/ssdenoversion-md.md)] and then expand that instance.
2. Expand **Databases**, right-click the database from which to delete the file, and then click **Properties**.
3. Select the **Files** page.
4. In the **Database files** grid, select the file to delete and then click **Remove**.
5. Click **OK**.
## Using Transact-SQL
#### To delete data or log files from a database
1. Connect to the [!INCLUDE[ssDE](../../includes/ssde-md.md)].
2. From the Standard bar, click **New Query**.
3. Copy and paste the following example into the query window and click **Execute**. This example removes the file `test1dat4`.
[!code-sql[DatabaseDDL#AlterDatabase4](../../relational-databases/databases/codesnippet/tsql/delete-data-or-log-files_1.sql)]
For more examples, see [ALTER DATABASE File and Filegroup Options (Transact-SQL)](../../t-sql/statements/alter-database-transact-sql-file-and-filegroup-options.md).
## See Also
[Shrink a Database](../../relational-databases/databases/shrink-a-database.md)
[Add Data or Log Files to a Database](../../relational-databases/databases/add-data-or-log-files-to-a-database.md)