Saturday, April 23, 2011

ATTACH DB &&& ATTACH SINGLEFILE TO DB

ATTACH DB:
Use master
Go
Sp_attach_db ‘pubs’,’E: \Program Files\Microsoft SQL Server\MSSQL\Data\pubs.mdf'’


EXEC sp_attach_db @dbname = N'pubs',
   @filename1 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs.mdf',
   @filename2 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs_log.ldf'

ATTACH SINGLEFILE TO DB:
EXEC sp_detach_db @dbname = 'pubs'
EXEC sp_attach_single_file_db @dbname = 'pubs',
@physname = 'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs.mdf'

No comments:

Post a Comment