I'm executing sql query on my database. I have SQL Server 2008 installed on my D harddrive which has 55 GB free space.

I have also C drive which has sth like 150 MB free (right now).

While executing that query on quite a big table (16 GB) I have an error:

An error occurred while executing batch. Error message is: Not enough disk space.

I would like to know if there is any possibility that I can make SQL Server to use D drive instead of C

Or maybe there is any other problem with what I'm doing ?

Thanks for help


This is likely a logging issue. You can move the log file to a different drive and use a lower level logging.

  • Log file is set to be written on D drive, executing this query takes a lot of free space on my C drive dont even know which file is beeing modified, what else can I do ? – potatoMan Jun 16 '10 at 21:23
  • 3
    What about the TEMPDBs? – ITGuy24 Jun 16 '10 at 22:05
  • there are also stored on D drive according to options which are set :/ – potatoMan Jun 16 '10 at 22:13
  • Wild Guess: Try setting the TEMP and TMP system variables to a directory on the D drive. – joeqwerty Jun 17 '10 at 2:24

This is likely to be the TEMPDB, one of SQL Server's System databases. It will have been created in the default database location by the installer.

This article talks about moving the tempdb.

Equally you could add additional (expandable) files on D: to the tempdb database's primary filegroup, then set the default ones to fixed size (and eventually flush, then remove them).


Are you running the query using a client application on the SQL server, like SSMS? If so, it could be, probably is, using the C drive to store the output for display, especially if you're running the output to a grid. Try running the query using the SQLCMD command line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.