Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Removing a secondary tempdb file Expand / Collapse
Author
Message
Posted Thursday, February 28, 2013 4:55 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: 2 days ago @ 8:30 AM
Points: 247, Visits: 976
Hello.
I created a secondary tempdb file on our testing server the other day and i wish now to remove it.
I have run
Use tempdb
alter database tempdb
remove file tempdev2

and i got an error saying

The file “D:\tempdb\tempdb2.ndf” has been modified in the system catalog. The new path will be used the next time the database is started.
Msg 5042, Level 16, State 1, Line 1
The file ‘tempdb2′ cannot be removed because it is not empty.

When i restared the instance - sure enough the file was still there.
Do i need to run some kind of shrink operation first ?

Any help would be great - thanks very much
Steven
Post #1424990
Posted Thursday, February 28, 2013 4:59 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 3:37 PM
Points: 40,210, Visits: 36,619
TRy a shrinkfile with emptyfile, then remove the second file.


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1424991
Posted Thursday, February 28, 2013 5:20 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: 2 days ago @ 8:30 AM
Points: 247, Visits: 976
thank you
is this correct then :

DBCC SHRINKFILE ('tempdev2' , emptyfile)

then run the

ALTER DATABASE tempdb REMOVE FILE tempdev2

Post #1424996
Posted Thursday, February 28, 2013 6:03 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 3:37 PM
Points: 40,210, Visits: 36,619
Should work.


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1425014
Posted Thursday, February 28, 2013 8:02 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: 2 days ago @ 8:30 AM
Points: 247, Visits: 976
apologies for this i am having problems !
when i try to run a dbcc shrinkfile i get an error saying
"Could not locate file 'tempdev2' for database tempdb in sys.database_files. The file either does not exist or was dropped.

When i browse to the location i can see the physical file - am i ok just to delete this ?
the properties of the database when using SSMS show the file as well !
Post #1425053
Posted Thursday, February 28, 2013 9:48 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: 2 days ago @ 8:30 AM
Points: 247, Visits: 976
I have got rid off the extra file now!!

I then run the following to resize the original file to 650 mb and add a secondary.
ALTER DATABASE TEMPDB
MODIFY file
(NAME = TEMPDEV , SIZE = 650MB
,MAXSIZE = UNLIMITED,
FILEGROWTH = 10% )


ALTER DATABASE TEMPDB
ADD FILE (NAME = N'TempDev2',
filename = N'D:\DEV\MSSQL10_50.dev\MSSQL\DATA\tempdb2.ndf',
SIZE = 650 MB,
MAXSIZE = UNLIMITED,
FILEGROWTH = 10% )


The second part of the code adds the file with no problems, however the first part of the code does not rezise the primary tempdev (logical name) to 650mb, it stays at 8192kb and this is after i restart the instance

Post #1425140
Posted Thursday, February 28, 2013 10:31 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 3:37 PM
Points: 40,210, Visits: 36,619
What was the initial, defined size of the first file before you ran that?


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1425182
Posted Thursday, February 28, 2013 3:19 PM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: 2 days ago @ 8:30 AM
Points: 247, Visits: 976
The initial size was 8mb - i obtained that info from the database properties by right clikcing in ssms - unless there is a better way ?
Post #1425296
Posted Friday, March 1, 2013 7:59 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: 2 days ago @ 8:30 AM
Points: 247, Visits: 976
Can anybody please advise on the last few comments ? The original file has not grown when i restart the sql server instance - the second file has been added and sized correctly. The code i typed was:
ALTER DATABASE TEMPDB
MODIFY file
(NAME = TEMPDEV , SIZE = 650MB
,MAXSIZE = UNLIMITED,
FILEGROWTH = 10% )


ALTER DATABASE TEMPDB
ADD FILE (NAME = N'TempDev2',
filename = N'D:\DEV\MSSQL10_50.dev\MSSQL\DATA\tempdb2.ndf',
SIZE = 650 MB,
MAXSIZE = UNLIMITED,
FILEGROWTH = 10% )

The original size of the primary file was 8mb - when the server started again it was still 8mb and not 650mb. I have noticed that we only have Service Pack 1 installed - would this be the reason the file is not growing to 650mb when i restart the server ? (By the way when i say restart the server i dont mean a hard reboot i just mean by clicking restart on the instance)
Post #1425523
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse