You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/relational-databases/databases/create-a-database-snapshot-transact-sql.md
+15-9Lines changed: 15 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
1
---
2
-
title: "Create a database snapshot (Transact-SQL)"
2
+
title: "Create a Database Snapshot (Transact-SQL)"
3
3
description: "Find out how to create a SQL Server database snapshot by using Transact-SQL. Learn about prerequisites and best practices for creating snapshots."
4
4
author: WilliamDAssafMSFT
5
5
ms.author: wiassaf
6
6
ms.reviewer: randolphwest
7
-
ms.date: 10/02/2023
7
+
ms.date: 01/26/2026
8
8
ms.service: sql
9
9
ms.subservice: configuration
10
10
ms.topic: how-to
@@ -32,7 +32,7 @@ The source database, which can use any recovery model, must meet the following p
32
32
- Prior to [!INCLUDE [sssql19-md](../../includes/sssql19-md.md)], the source database couldn't contain a `MEMORY_OPTIMIZED_DATA` filegroup. Support for in-memory database snapshots was added in [!INCLUDE [sssql19-md](../../includes/sssql19-md.md)].
33
33
34
34
> [!IMPORTANT]
35
-
> For information about other significant considerations, see [Database Snapshots (SQL Server)](database-snapshots-sql-server.md).
35
+
> For information about other significant considerations, see [Database snapshots (SQL Server)](database-snapshots-sql-server.md).
36
36
37
37
## Recommendations
38
38
@@ -42,7 +42,9 @@ This section discusses the following best practices:
42
42
-[Best practice: limiting the number of database snapshots](#limiting-number)
43
43
-[Best practice: client connections to a database snapshot](#client-connections)
44
44
45
-
#### <aid="naming"></a> Best practice: naming database snapshots
45
+
<aid="naming"></a>
46
+
47
+
#### Best practice: naming database snapshots
46
48
47
49
Before creating snapshots, it's important to consider how to name them. Each database snapshot requires a unique database name. For administrative ease, the name of a snapshot can incorporate information that identifies the database, such as:
48
50
@@ -68,24 +70,28 @@ AdventureWorks_snapshot_noon
68
70
AdventureWorks_snapshot_evening
69
71
```
70
72
71
-
#### <aid="limiting-number"></a> Best practice: limiting the number of database snapshots
73
+
<aid="limiting-number"></a>
74
+
75
+
#### Best practice: limiting the number of database snapshots
72
76
73
-
Creating a series of snapshots over time captures sequential snapshots of the source database. Each snapshot persists until it's explicitly dropped. Because each snapshot will continue to grow as original pages are updated, you may want to conserve disk space by deleting an older snapshot after creating a new snapshot.
77
+
Creating a series of snapshots over time captures sequential snapshots of the source database. Each snapshot persists until it's explicitly dropped. Because each snapshot will continue to grow as original pages are updated, you might want to conserve disk space by deleting an older snapshot after creating a new snapshot.
74
78
75
79
> [!NOTE]
76
80
> To revert to a database snapshot, you need to delete any other snapshots from that database.
77
81
78
-
#### <aid="client-connections"></a> Best practice: client connections to a database snapshot
82
+
<aid="client-connections"></a>
83
+
84
+
#### Best practice: client connections to a database snapshot
79
85
80
-
To use a database snapshot, clients need to know where to find it. Users can read from one database snapshot while another is being created or deleted. However, when you substitute a new snapshot for an existing one, you need to redirect clients to the new snapshot. Users can manually connect to a database snapshot with [!INCLUDE [ssManStudioFull](../../includes/ssmanstudiofull-md.md)] or Azure Data Studio. However, to support a production environment, you should create a programmatic solution that transparently directs report-writing clients to the latest database snapshot of the database.
86
+
To use a database snapshot, clients need to know where to find it. Users can read from one database snapshot while another is being created or deleted. However, when you substitute a new snapshot for an existing one, you need to redirect clients to the new snapshot. Users can manually connect to a database snapshot with [!INCLUDE [ssManStudioFull](../../includes/ssmanstudiofull-md.md)]. However, to support a production environment, you should create a programmatic solution that transparently directs report-writing clients to the latest database snapshot of the database.
81
87
82
88
## Permissions
83
89
84
90
Any user who can create a database can create a database snapshot; however, to create a snapshot of a mirror database, you must be a member of the **sysadmin** fixed server role.
85
91
86
92
## Create a database snapshot using Transact-SQL
87
93
88
-
1. Based on the current size of the source database, ensure that you have sufficient disk space to hold the database snapshot. The maximum size of a database snapshot is the size of the source database at snapshot creation. For more information, see [View the Size of the Sparse File of a Database Snapshot (Transact-SQL)](view-the-size-of-the-sparse-file-of-a-database-snapshot-transact-sql.md).
94
+
1. Based on the current size of the source database, ensure that you have sufficient disk space to hold the database snapshot. The maximum size of a database snapshot is the size of the source database at snapshot creation. For more information, see [View the Size of the Sparse File of a Database Snapshot](view-the-size-of-the-sparse-file-of-a-database-snapshot-transact-sql.md).
89
95
90
96
1. Issue a `CREATE DATABASE` statement on the files using the `AS SNAPSHOT OF` clause. Creating a snapshot requires specifying the logical name of every database file of the source database. The syntax is as follows:
Copy file name to clipboardExpand all lines: docs/relational-databases/databases/delete-a-database.md
+70-77Lines changed: 70 additions & 77 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,8 @@ title: "Delete a Database"
3
3
description: Learn how to delete a user-defined database in SQL Server Management Studio in SQL Server by using SQL Server Management Studio or Transact-SQL.
[!INCLUDE [SQL Server Azure SQL Database Azure SQL Managed Instance](../../includes/applies-to-version/sql-asdb-asdbmi.md)]
21
23
22
-
This article describes how to delete a user-defined database in [!INCLUDE[ssnoversion](../../includes/ssnoversion-md.md)] by using [!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)] or [!INCLUDE[tsql](../../includes/tsql-md.md)].
23
-
24
-
## <aname="Prerequisites"></a> Prerequisites
25
-
26
-
- Delete any database snapshots that exist on the database. For more information, see [Drop a Database Snapshot (Transact-SQL)](../../relational-databases/databases/drop-a-database-snapshot-transact-sql.md).
27
-
28
-
- If the database is involved in log shipping, remove log shipping.
29
-
30
-
- If the database is published for transactional replication, or published or subscribed to merge replication, remove replication from the database.
31
-
32
-
> [!WARNING]
33
-
> Consider taking a full backup of the database before dropping it. A deleted database can be re-created only by restoring a full backup. For more information, see [Quickstart: Backup and restore a SQL Server database on-premises](../backup-restore/quickstart-backup-restore-database.md).
34
-
35
-
### <aname="Security"></a> Security
36
-
37
-
#### <aname="Permissions"></a> Permissions
38
-
39
-
To execute DROP DATABASE, at a minimum, a user must have CONTROL permission on the database.
40
-
41
-
## <aname="ADSProcedure"></a> Using Azure Data Studio (preview)
42
-
43
-
#### To delete a database
44
-
45
-
1. In **Object Explorer**, connect to an instance of the [!INCLUDE[ssDEnoversion](../../includes/ssdenoversion-md.md)], and then expand that instance.
46
-
47
-
2. Expand **Databases**, right-click the database to delete, and then select **Delete**.
48
-
49
-
3. To confirm you want to delete the database, select **Yes**.
50
-
51
-
## <aname="SSMSProcedure"></a> Using SQL Server Management Studio
52
-
53
-
#### To delete a database
54
-
55
-
1. In **Object Explorer**, connect to an instance of the [!INCLUDE[ssDEnoversion](../../includes/ssdenoversion-md.md)], and then expand that instance.
56
-
57
-
1. Expand **Databases**, right-click the database to delete, and then select **Delete**.
58
-
59
-
1. Confirm the correct database is selected, and then select **OK**.
60
-
61
-
## <aname="TsqlProcedure"></a> Using Transact-SQL
62
-
63
-
For more information, see [DROP DATABASE (Transact-SQL)](../../t-sql/statements/drop-database-transact-sql.md).
64
-
65
-
#### To delete a database
66
-
67
-
1. Connect to the [!INCLUDE[ssDE](../../includes/ssde-md.md)].
68
-
69
-
1. From the Standard bar, select **New Query**.
70
-
71
-
1. Copy and paste the following example into the query window and select **Execute**. This example removes the `Sales` and `NewSales` databases.
72
-
73
-
```sql
74
-
USE master ;
75
-
GO
76
-
DROPDATABASE Sales, NewSales ;
77
-
GO
78
-
```
79
-
80
-
## <aname="FollowUp"></a> Follow Up: After deleting a database
81
-
82
-
Back up the `master` database. If `master` must be restored, any database that has been deleted since the last backup of `master` will still have references in the system catalog views and may cause error messages to be raised.
83
-
84
-
## <aname="Restrictions"></a> Limitations and Restrictions
85
-
86
-
- System databases cannot be deleted.
87
-
- For more information, see [DROP DATABASE (Transact-SQL)](../../t-sql/statements/drop-database-transact-sql.md).
88
-
89
-
## Next steps
90
-
91
-
-[CREATE DATABASE (SQL Server Transact-SQL)](../../t-sql/statements/create-database-transact-sql.md)
-[Restore and recovery overview (SQL Server)](../backup-restore/restore-and-recovery-overview-sql-server.md)
95
-
24
+
This article describes how to delete a user-defined database in [!INCLUDE [ssnoversion](../../includes/ssnoversion-md.md)] by using [!INCLUDE [ssManStudioFull](../../includes/ssmanstudiofull-md.md)] or [!INCLUDE [tsql](../../includes/tsql-md.md)].
25
+
26
+
<aid="Prerequisites"></a>
27
+
28
+
## Prerequisites
29
+
30
+
- Delete any database snapshots that exist on the database. For more information, see [Drop a Database Snapshot](drop-a-database-snapshot-transact-sql.md).
31
+
32
+
- If the database is involved in log shipping, remove log shipping.
33
+
34
+
- If the database is published for transactional replication, or published or subscribed to merge replication, remove replication from the database.
35
+
36
+
> [!WARNING]
37
+
> Consider taking a full backup of the database before dropping it. You can recreate a deleted database only by restoring a full backup. For more information, see [Quickstart: Backup and restore a SQL Server database with SSMS](../backup-restore/quickstart-backup-restore-database.md).
38
+
39
+
## Permissions
40
+
41
+
To run `DROP DATABASE`, you need `CONTROL` permission on the database.
42
+
43
+
<aid="SSMSProcedure"></a>
44
+
45
+
## Use SQL Server Management Studio
46
+
47
+
1. In **Object Explorer**, connect to an instance of the [!INCLUDE [ssDEnoversion](../../includes/ssdenoversion-md.md)], and then expand that instance.
48
+
49
+
1. Expand **Databases**, right-click the database to delete, and then select **Delete**.
50
+
51
+
1. Confirm the correct database is selected, and then select **OK**.
52
+
53
+
<aid="TsqlProcedure"></a>
54
+
55
+
## Use Transact-SQL
56
+
57
+
For more information, see [DROP DATABASE](../../t-sql/statements/drop-database-transact-sql.md).
58
+
59
+
1. Connect to the [!INCLUDE [ssDE](../../includes/ssde-md.md)].
60
+
61
+
1. From the Standard bar, select **New Query**.
62
+
63
+
1. Copy and paste the following example into the query window and select **Execute**. This example removes the `Sales` and `NewSales` databases.
64
+
65
+
```sql
66
+
USE master;
67
+
GO
68
+
DROPDATABASE Sales, NewSales;
69
+
```
70
+
71
+
<aid="FollowUp"></a>
72
+
73
+
## Follow up: After deleting a database
74
+
75
+
Back up the `master` database. If you need to restore `master`, any database that you deleted since the last backup of `master` still has references in the system catalog views and might cause error messages.
76
+
77
+
<aid="Restrictions"></a>
78
+
79
+
## Limitations
80
+
81
+
You can't delete system databases. For more information, see [DROP DATABASE](../../t-sql/statements/drop-database-transact-sql.md).
0 commit comments