Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Removing a secondary tempdb file


Removing a secondary tempdb file

Author
Message
PearlJammer1
PearlJammer1
Old Hand
Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)

Group: General Forum Members
Points: 322 Visits: 1427
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
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47243 Visits: 44377
TRy a shrinkfile with emptyfile, then remove the second file.


Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
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


PearlJammer1
PearlJammer1
Old Hand
Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)

Group: General Forum Members
Points: 322 Visits: 1427
thank you
is this correct then :

DBCC SHRINKFILE ('tempdev2' , emptyfile)

then run the

ALTER DATABASE tempdb REMOVE FILE tempdev2
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47243 Visits: 44377
Should work.


Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
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


PearlJammer1
PearlJammer1
Old Hand
Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)

Group: General Forum Members
Points: 322 Visits: 1427
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 !
PearlJammer1
PearlJammer1
Old Hand
Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)

Group: General Forum Members
Points: 322 Visits: 1427
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
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47243 Visits: 44377
What was the initial, defined size of the first file before you ran that?


Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
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


PearlJammer1
PearlJammer1
Old Hand
Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)

Group: General Forum Members
Points: 322 Visits: 1427
The initial size was 8mb - i obtained that info from the database properties by right clikcing in ssms - unless there is a better way ?
PearlJammer1
PearlJammer1
Old Hand
Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)Old Hand (322 reputation)

Group: General Forum Members
Points: 322 Visits: 1427
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)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search