Pre-Preparation:
Create a database
Create DATABASE Studio
On primary
(name = ' Studio ', filename = ' E:\Studio.mdf '),
Filegroup FG2
(name = ' Studio_fg2_file_1 ', filename= ' E:\Studio_FG2_file_1.ndf ')
Log on
(Name= ' Studio_log ', filename= ' E:\Studio_log.ldf ');
Go
E:\ the database file from the Move to the E:\DB directory
--------------------------------------------------------------------------------------------------------------- -----------
Separation syntax:
Execute sp_detach_db @dbname = ' database_name ';
Go
Example:
Execute sp_detach_db @dbname = ' Studio ';
Go
Additional syntax:
Create DATABASE Studio
On filespec [, filespec]
for attach;
Go
Example:
Create DATABASE Studio
On
(Name= ' Studio ', filename= ' E:\DB\Studio.mdf '),
(Name= ' studio_fg2_file_1 ', filename= ' E:\DB\Studio_FG2_file_1.ndf ')
for attach;
Go
------------------------------------------------------------------------
SQL Server detach and attach Database