Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting .MDF and .LDF files into MSSQL?

Status
Not open for further replies.

JamesManke

Programmer
Jul 1, 2004
54
CA
Let me start by mentioning that this is the first time I have ever had to set a DB on MSSQL.

I have two files that I need to be upload? to MSSQL DataBase. I have already created the DB, username and password. I just need to know how to upload these files. I am used to MySQL where I would simple insert a dump and the tables would be created. I have two files, one is a .MDF file and the other is a .LDF file. How do I go about getting these files in MSSQL.

Thanks for you help,

James
 
you dont you need to attach them to SQL Server -
BOL said:
To attach a database

Expand a server group, and then expand a server.


Right-click Databases, and select All Tasks/Attach Database.


Enter the name of the MDF (master data file) of the database to attach. If you are not sure where the file is located, click browse (...) to search. There can only be up to 16 file names specified. For more information, see sp_attach_db.


To ensure that the specified MDF file is correct, click Verify. The Original File Name(s) column lists all the files in the database (data files and log files). The Current File(s) Location column lists the file names and paths. If Microsoft® SQL Server™ cannot find the files in the specified locations, the attach operation fails. The Current File(s) Location column can be edited, and the current location of the file must be in this column for the attach operation to work. For example, if you have changed the default location of the file before you detached it, you must specify the current location for the attach operation to be successful.


In the Attach as box, enter the name of the database. The database name must not match any existing database names.


Specify the database owner.


Click OK. A database node for the newly attached database is created in the Database folder.
To detach a database

Expand a server group, and then expand a server.


Expand Databases.


Right-click the database, and then select All Tasks/Detach Database. This menu is visible only if you are a member of the sysadmin fixed server role and the server to which you are connected is SQL Server 2000. The master, model, and tempdb databases cannot be detached.


In the Detach Database dialog box, check the status of the database. To successfully detach a database, STATUS should be: The database is ready to be detached. Optionally, you can select to update statistics prior to the detach operation.


To terminate any existing connections from the database, click Clear.


Click OK. The database node for the detached database is removed from the Database folder.

[bandito] [blue]DBomrrsm[/blue] [bandito]
 
How did you create these files? You can't just type up a file and add the .mdf and .ldf extensions and expect them to work (if that's what you did).

-SQLBill

Posting advice: FAQ481-4875
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top