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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.