Events
Get certified in Microsoft Fabric—for free!
19 Nov, 23 - 10 Dec, 23
For a limited time, the Microsoft Fabric Community team is offering free DP-600 exam vouchers.
Prepare nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Applies to: SQL Server Azure SQL Managed Instance
This topic describes how to delete data or log files in SQL Server by using SQL Server Management Studio or Transact-SQL.
In This Topic
Before you begin:
To delete data or logs files from a database, using:
Requires ALTER permission on the database.
In Object Explorer, connect to an instance of the SQL Server Database Engine 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 Database Engine.
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
.
USE master;
GO
ALTER DATABASE AdventureWorks2022
REMOVE FILE test1dat4;
GO
For more examples, see ALTER DATABASE File and Filegroup Options (Transact-SQL).
Events
Get certified in Microsoft Fabric—for free!
19 Nov, 23 - 10 Dec, 23
For a limited time, the Microsoft Fabric Community team is offering free DP-600 exam vouchers.
Prepare nowTraining
Certification
Microsoft Certified: Azure Database Administrator Associate - Certifications
Administer an SQL Server database infrastructure for cloud, on-premises and hybrid relational databases using the Microsoft PaaS relational database offerings.
Documentation
Shrink a database - SQL Server
Learn how to shrink a database in SQL Server by using SQL Server Management Studio or Transact-SQL.
Learn how to shrink a data or log file in SQL Server by using SQL Server Management Studio or Transact-SQL.
Increase the Size of a Database - SQL Server
Increase the Size of a Database