| title | Delete Data or Log Files from a Database | |||||||
|---|---|---|---|---|---|---|---|---|
| description | Learn how to delete data or log files in SQL Server by using SQL Server Management Studio or Transact-SQL. | |||||||
| author | WilliamDAssafMSFT | |||||||
| ms.author | wiassaf | |||||||
| ms.date | 03/14/2017 | |||||||
| ms.service | sql | |||||||
| ms.subservice | supportability | |||||||
| ms.topic | how-to | |||||||
| helpviewer_keywords |
|
[!INCLUDE SQL Server] This topic describes how to delete data or log files in [!INCLUDEssnoversion] by using [!INCLUDEssManStudioFull] or [!INCLUDEtsql].
In This Topic
-
Before you begin:
-
To delete data or logs files from a database, using:
- A file must be empty before it can be deleted. For more information, see Shrink a File.
Requires ALTER permission on the database.
-
In Object Explorer, connect to an instance of the [!INCLUDEssDEnoversion] and then expand that instance.
-
Expand Databases, right-click the database from which to delete the file, and then click Properties.
-
Select the Files page.
-
In the Database files grid, select the file to delete and then click Remove.
-
Click OK.
-
Connect to the [!INCLUDEssDE].
-
From the Standard bar, click New Query.
-
Copy and paste the following example into the query window and click Execute. This example removes the file
test1dat4.
:::code language="sql" source="codesnippet/tsql/delete-data-or-log-files_1.sql":::
For more examples, see ALTER DATABASE File and Filegroup Options (Transact-SQL).