When I reindex a particular table
DBCC DBREINDEX(@TableName, '',90)
I get an error
Level 17, State 2, Procedure aareindex, Line 21 [Batch Start Line 0]
Could not allocate space for object ‘dbo.SORT temporary run storage:
422738479742976’ in database ‘mydatabase’ because the ‘PRIMARY’
filegroup is full. Create disk space by deleting unneeded files,
dropping objects in the filegroup, adding additional files to the
filegroup, or setting autogrowth on for existing files in the
filegroup.
So I want to try increasing the size of TempDb
I can see the size using SSMS by looking at the database properties but I don't see how to set it.
[Update]
select type_desc, name, size, max_size, growth from tempdb.sys.database_files
returns
The file size is already 10236 Mb and the Express limit is 10 Gig
However the Disk Usage report shows that 26% of the diskspace is unallocated, 40% is data and 32% is index.
Best Answer
If your user database
data file size
reached it's limit (10Gb in Express Edition) but 26% of the diskspace is unallocated, you can try torebuild
your indexes withsort
intempdb
.DBCC DBREINDEX
isdeprecated
and there is no reason to use inSQL Server 2017
, and withalter index..rebuild
you can indicate that you want to performsort
intempdb
:When you
rebuild
an index, you first need thespace
to build the copy of yourindex
(and this space will be allocated in yourdb
) and to build it you also need space to dosort
, this space can be allocated intempd
. In your case the error clearly said that there was nospace
to dosort
in your db, so maybe you'll resolve your problem if thesort
will be performed intempdb
.You can read more on that here: SORT_IN_TEMPDB Option For Indexes