????????????????????SQL Server???????????????????????????????洢??????????λ??????????C????????????????洢λ???????????????????????????C???е????λ???????????????λ???????????????64λ?????????????洢??C:Program FilesMicrosoft SQL ServerMSSQL11.MSSQLSERVERMSSQLDATA?С????????????????????????????д????????????LDF??????????????C?????????С???????????????????????????????????????????????????????Tasks --> Shrink????????????

??????????????????C???????б???????????????????С???????????????????????????????????????????????C?????????????????????????????
??????????裬???????????????????C???????????(pubs)???·??????D??????????loc1?У? ?????????SQL Server??????????μ?query????????????′???
USE MASTER;
GO
-- Take database in single user mode -- if you are facing errors
-- This may terminate your active transactions for database
ALTER DATABASE pubs
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE;
GO
-- Detach DB
EXEC MASTER.dbo.sp_detach_db @dbname = N'pubs'
GO
??????????????????????????????

??????????????·???μ?MDF ?? LDF????????????С????

??????????????????MDF??LDF???????????????????????????У???????D:loc1:

???????????????SQL Server?????????′???
????CREATE DATABASE pubs ON
????( FILENAME = N'D:loc1pubs.mdf' )??
????( FILENAME = N'D:loc1pubs_log.ldf' )
????FOR ATTACH
????GO
??????д?????????????????Command(s) completed successfully.
???????????????????????????????????????C??????????????????
?????????????СС???????????????ROLLBACK IMMEDIATE????????????????????????????У????????????????????????????????鷢?????κ??????????????????????????????????????~