|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Monday, June 17, 2013 8:43 AM
Points: 75,
Visits: 304
|
|
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
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 3:43 AM
Points: 38,112,
Visits: 30,399
|
|
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
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Monday, June 17, 2013 8:43 AM
Points: 75,
Visits: 304
|
|
thank you is this correct then :
DBCC SHRINKFILE ('tempdev2' , emptyfile)
then run the
ALTER DATABASE tempdb REMOVE FILE tempdev2
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 3:43 AM
Points: 38,112,
Visits: 30,399
|
|
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
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Monday, June 17, 2013 8:43 AM
Points: 75,
Visits: 304
|
|
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 !
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Monday, June 17, 2013 8:43 AM
Points: 75,
Visits: 304
|
|
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
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 3:43 AM
Points: 38,112,
Visits: 30,399
|
|
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
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Monday, June 17, 2013 8:43 AM
Points: 75,
Visits: 304
|
|
| The initial size was 8mb - i obtained that info from the database properties by right clikcing in ssms - unless there is a better way ?
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Monday, June 17, 2013 8:43 AM
Points: 75,
Visits: 304
|
|
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)
|
|
|
|