Deleting Data files from Data folder of SQL Server?

Asked By 0 points N/A Posted on -
qa-featured

There are few database files in my Data Folder of SQL Server directory. I want to delete those files, but when I try to delete them, system says that the files are being used. But those files are not associated with any database and are no longer showing in my Databases.

How can I delete those files because they are just occupying space on hard disk?

 

SHARE
Best Answer by oieccorxa
Answered By 0 points N/A #92769

Deleting Data files from Data folder of SQL Server?

qa-featured

Before exiting the Explorer you should launch first the “Command Prompt”

To be able to turn off Explorer:
 
– Go to the “Taskbar” then right-click it,
 
– Select “Task Manager”
 
– Access “process tab” then look for the “Explorer” in the directories
 
– Once you found it, right click “Explorer.exe.” then select “End Process” Any Explorer will shut down
 
After turning off the explorer you can now start to launch the “Command Prompt” by simply holding down CTRL+ALT+DEL to open the “Task Manager” from the menu tab, choose to start  the “Task Manger” from there select the “File” menu, click “Run” then input: cmd.exe tap “Ok”
 
To erase your desired files it is necessary to launch the “Command Prompt” acting as the “Administrator” after doing so, you may now begin selecting the start tab and in the search engine input: CMD without tapping “Enter”
 
Once you found the program in the list, right-click the cmd.exe
 
Then select “Run as Administrator” this will launch the “Command Prompt” window
 
Go to the “Explorer” window, click the folder from where you want to erase the file then tap on the “Address-field” to see the path of the folder.
 
After right-clicking the part that is highlighted press down CTRL+C
 
Return to the “Command Prompt” window and input: CD
 
This will lead you to open the “Root Folder”
 
Input again CDthen paste the one copied highlighted part.
 
It should be the same as this one: CD testfolder
 
Recheck if you are in the right folder by displaying the content folder, to display content, simply input: DIR
 
To finally delete the file, input: DEL[filename] /F /Q.
 
After erasing the files you should start again the Task Manager, from the “File” list click “Run” then input Explorer.exe
Best Answer
Best Answer
Answered By 0 points N/A #92770

Deleting Data files from Data folder of SQL Server?

qa-featured

SQL Server services are always using the files placed in Data folder of SQL Server installation directory. So whenever you try to delete a file from Data folder, this message is thrown by operating system that the files are being used. And SQL Server services are using those files. Therefore, if you want to delete those files, you have to stop the SQL Services and then delete the files and again start the services. To do so, please follow the steps:

Control Panel -> Administrative Tools -> Services.

Locate SQL Server (<Instance Name>) service, stop this service and delete the files. After deleting, start the service again.

 

Related Questions