EXEC sp_attach_db @dbname = N'exam',
@filename1 = N'D:\yyks\Data\exam_Data.MDF',
@filename2 = N'D:\yyks\Data\exam_Log.LDF'
附加数据库
CREATE DATABASE REC2005_Test
ON PRIMARY (FILENAME = 'c:\dir\test.mdf')
FOR ATTACH
GO
创建并附加数据库