SQL Server DBA Tutorial 17 - How to Attach and Detach Databases in SQL Server

Published: 06 June 2022
on channel: Chirags Tutorial
21
like

[email protected] Chirag's SQL Server DBA Tutorial https://www.chirags.in
*****************************************************************************************
How to attach and detach databases? *
*****************************************************************************************

We will be using two ways attach and detach databases
1. Using SQL Server management studio graphic user interface GUI Version
2. Using T-SQL script

/**Detach Script**/
USE [master]
GO
ALTER DATABASE [DVDRental] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
USE [master]
GO
EXEC master.dbo.sp_detach_db @dbname = N'DVDRental'
GO

/**Attach Script**/
USE [master]
GO
CREATE DATABASE [DVDRental] ON
( FILENAME =N'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER1\MSSQL\DATA\DVDRental.mdf'),
( FILENAME =N'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER1\MSSQL\DATA\DVDRental_log.ldf')
FOR ATTACH
GO

Note : Flow the Process shown in video.

😉Subscribe and like for more videos:
   / @chiragstutorial  
💛Don't forget to, 💘Follow, 💝Like, 💖Share 💙&, Comment

Tutorial Link :
https://www.chirags.in/tutorials/micr...

Thanks & Regards,
Chitt Ranjan Mahto "Chirag"
_________________________________________________________________________________________
Note: All scripts used in this demo will be available in our website.
Link will be available in description.

#DBATutorial
#DBATutorialLearning
#DBAEducation
#DBATutorialFree
#DatabaseTutorial
#SQLServerDatabaseTutorial
#SQLServerDBATutorial
#MicrosoftSQLServerDatabaseTutorial
#ChiragsDBATutorial
#ChiragsDatabaseTutorial
#ChiragsSQLServerDatabaseTutorial
#ChiragsSQLServerDBATutorial
#Chirags.inSQLServerDBATutorial
#ChiragsMicrosoftSQLServerDatabaseTutorial
#CreateDatabaseinSQLServer
#CreateDatabasewithT-SQL
#chiragstutorial
#databasetutorial
#sqlserver
#sqlservertutorial
#sqlservermanagementstudio
#sql_server
#sqlservertutorial
#chiragstutorial
#databasetutorial
#sqlqueries
#sqldba
#database
#databasemanagement


Watch video SQL Server DBA Tutorial 17 - How to Attach and Detach Databases in SQL Server online without registration, duration hours minute second in high quality. This video was added by user Chirags Tutorial 06 June 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 21 once and liked it like people.