; Microsoft SQL Server 2016 : Attach a database by using Transact-SQL | SQL Server

Internet Television

Watch World wide Tv Channels , Movies , Sports - Visit Here

Microsoft SQL Server 2016 : Attach a database by using Transact-SQL

Attach a database in SQL Server Management Studio 2016.  

















Before attaching the database

1 . Copy (two file e.g. the ‘database.MDF‘ file which contains the primary data, and the ‘database.LDF‘ file which logs) and 
2. Paste "C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA" -(copy the file into the default location for data files)

Now we are ready to attach them.

3. Open SQL Server Management Studio....Click on connect button
4.  Press Ctrl+N or Click on new query From the Standard bar...



 CREATE DATABASE AdventureWorks2012
ON 
 (FILENAME='C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\AdventureWorks2012_Data.mdf')
LOG ON 
 (FILENAME='C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\AdventureWorks2012_log.ldf')
FOR ATTACH

5. Copy above code and paste. After paste code click on execute or press F5


















Database is now attached.. the result is







Share on Google Plus

About Sujay Sharma

Hi ! I am Sujay Sharma. I am working in Indian Railway as Guard. I am sharing my experience about Microsoft SQL Server with ASP.NET ,VB.NET,C#.NET,XML "" Thanks.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment