July 22, 2014 at 10:20 am
I did try shrink the tempdb database then file. Also, restart SQL Server to release tempdb space to OS. But it did not release. I deleted the tempdb files so that it will recreate.However, it recreated with same file size. How to shrink the tempdb?
Thanks
July 22, 2014 at 10:27 am
Why do you want to?
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
July 22, 2014 at 10:51 am
We had unusual growth happened for one bulk operation. Which we may run again. So the tempdb suppose to be 25 GB and it grow to 50 GB. So I am hoping after shrink it will grow back to 25 GB not 50 GB.However, restarting the sql server did not release the space. Do you suggest move the tempdb and then restart the SQL Server?
Thanks
July 22, 2014 at 1:03 pm
No. Won't do anything.
If you may run that operation again, leave TempDB as-is, unless you are major out of disk space now.
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
July 22, 2014 at 2:07 pm
You can adjust the tempdb file(s) size using the following commands. The changes will be in effect the next time SQL Server starts.
--EXEC tempdb.sys.sp_helpfile --to list the logical file names, if you need to
-- names in bold below must be the correct logical names
-- be sure to specify exactly the same size for all tempdb data files
ALTER DATABASE tempdb MODIFY FILE ( NAME = tempdev, SIZE = <nnnnnn>KB )
ALTER DATABASE tempdb MODIFY FILE ( NAME = tempdev2, SIZE = <nnnnnn>KB )
--...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
July 22, 2014 at 4:05 pm
Thanks it worked! So here we are not moving the file to different location.
That means we are just altering the file size with following command.
ALTER DATABASE tempdb MODIFY FILE ( NAME = tempdev, SIZE = 1024 ).
So this will resize after SQL Server restart? Please correct me if I am wrong?
Thanks
July 23, 2014 at 8:23 am
Admingod (7/22/2014)
Thanks it worked! So here we are not moving the file to different location.That means we are just altering the file size with following command.
ALTER DATABASE tempdb MODIFY FILE ( NAME = tempdev, SIZE = 1024 ).
So this will resize after SQL Server restart? Please correct me if I am wrong?
Thanks
Correct: that is not moving the file, it's just changing the initial size the next time SQL restarts.
If you want to move the file, you can do this:
ALTER DATABASE tempdb MODIFY FILE ( NAME = tempdev, FILENAME = 'x:\full\path\toew\tempdb\file\tempdb.mdf' /*, SIZE = .... */ )
And again when SQL restarts the new location will be used for tempdb, but you have to delete the old tempdb files yourself. For example, say you moved the file from c: to x: -- once SQL restarts, you have to delete the old tempdb files from the c: drive yourself.
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
July 23, 2014 at 10:33 am
Thanks so much!
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply