How to Edit the MDF Database

By Jim Campbell

An MDF file is a SQL Server database file used to store data. You edit the MDF file by logging in to the SQL Server and editing the data in the tables. This is accomplished using the SQL Server Management Studio. An MDF file can be a very large file if you have several millions of rows in the database tables, but SQL Server edits and adds data in only seconds.

Click the Windows "Start" button and select "All Programs." Click "SQL Server" to view a list of programs for the database. Click "SQL Server Management Studio" to open the console.

Click the database name on the left side of the window. The database is "attached" to the MDF file. Any edits done to the database server change the MDF file.

Click "New Query" to open an editor. You edit data using the "update" statement. For instance, if you want to edit customer data and change the last name of a customer, use the following code:

update customer set last_name='Smiths' where last_name='Smith'

In this statement, any customer with a last name of "Smith" is changed to "Smiths."

Press the "F5" key after you create your update statement. The F5 key executes the statement and edits the MDF file and its data.

×