前期准备:
创建数据库
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:\ 移动到 E:\DB 目录下
--------------------------------------------------------------------------------------------------------------------------
分离语法:
execute sp_detach_db @dbname = 'database_name';
go
例子:
execute sp_detach_db @dbname = 'Studio';
go
附加语法:
create database studio
on filespec [,filespec]
for attach;
go
例子:
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
------------------------------------------------------------------------