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!

attaching mdf files to a database

Status
Not open for further replies.

loo

Technical User
Nov 28, 2001
13
US
I need to know if after creating a database that I want to attach mdf files to from another database do I need to have the table structure the same in the new db. Also do I need to attach both the mdf file and the log file.
 

I'm not clear about your question so if my answers miss the point, let me know.

1) You can only attach an MDF to one database at a time.
2) A database can only have one MDF file. It can have additional NDF files.
3) You can detach a database and attach the files with another datbase name. Or you can copy the files to another file name or server and attach as another database.
4) You don't need to attach the LDF files. SQL will create LDF if not included in the attach. Use sp_attach_single_file_db if you don't want to attach the LDF. Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top