Maystyle :
Admin : New post
Guestbook
Local
media
Catergories
Recent Articles
Recent Comments
Recent Trackbacks
Calendar
Tag
Archive
Link
Search
 
  tempdb의 ndf가 삭제가 되지 않는다. 
작성일시 : 2007. 11. 18. 03:14 | 분류 : SQL Server/Administration

[에러 메세지]
Server: Msg 5042, Level 16, State 1, Line 1
The file 'tempdev4' cannot be removed because it is not empty.
File 'E:\Microsoft SQL Server\MSSQL\data\tempdev4.ndf' modified in
sysaltfiles. Delete old file after restarting SQL Server.

tempdb의 ndf 파일이 삭제가 않된다는 애기를 듣는 경우가 있다.
원인은 해당 ndf에 table이 존제하기 때문인데, 간단한 쿼리를 통하여 해당 ndf를 삭제하는 방법을 공유하도록 하겠다.

[Action Item]
먼저  Tempdb의 file 구성을 확인 한다.
use tempdb
go
sp_helpfile

위의 커멘드를 통하여 Name 및 Filename을 확인 했으면 직접 삭제 해 보도록 하겠다.
dbcc shrinkfile(tempdev_1, emptfle) //  TempDB 내부 데이터를 삭제
go
alter database tempdb
remove file tempdev_1 // tempdb의 첫번째 ndf 삭제


이제 손쉽게 tempdb의 ndf를 삭제하도록 하자.

|