where are SQL server database files located?
-
I am using SQL SERVER to create a database, but I can not find the files in my PC. if open it from SQL SERVER MANAGEMENT, it is shown as my-PC\SQLEXPRESS\database\system datatase\master\tables\dbo.TEST actually TEST is one table I CREATEED. but I CAN NOT FIND IT IN THE EXPLORER. who can tell me where is it located then? thanks.
-
I am using SQL SERVER to create a database, but I can not find the files in my PC. if open it from SQL SERVER MANAGEMENT, it is shown as my-PC\SQLEXPRESS\database\system datatase\master\tables\dbo.TEST actually TEST is one table I CREATEED. but I CAN NOT FIND IT IN THE EXPLORER. who can tell me where is it located then? thanks.
First and foremost. Never add tables to the master database. Create a new database and add it there. For express the default data location is usually C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data. Also, you cannot see specific tables in Windows Explorer, only the databases.
-
I am using SQL SERVER to create a database, but I can not find the files in my PC. if open it from SQL SERVER MANAGEMENT, it is shown as my-PC\SQLEXPRESS\database\system datatase\master\tables\dbo.TEST actually TEST is one table I CREATEED. but I CAN NOT FIND IT IN THE EXPLORER. who can tell me where is it located then? thanks.
I'm using the full version so there may be some differences in Express (I'm not familiar with that product). That said, one way to determine where your .mdf / .ldf files for your db are located is to script the database. Right click on the database you've created, select Script Database As from the popup menu. You may have to follow slightly different steps in Express, but the general idea here is to generate a CREATE DATABASE script. Having done so, you'll notice something along these lines: CREATE DATABASE [YourDbName] ON PRIMARY ( NAME = N'YourDbName', FILENAME = N'C:\Whatever\The\Path\Is\YourDbName.mdf' , SIZE = 45056KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )... There's more to the script of course, but the FILENAME portion will show you exactly where the db file lives. Sql Server uses .mdf files for the database, and .ldf for the log. If you want to move it to a new directory, be sure to move both files. Hope this helps -
Christopher Duncan www.PracticalUSA.com Author of The Career Programmer and Unite the Tribes Copywriting Services