Attach the mdf file in sql server 2005

Posted by under Sql Server on 4/27/2010 | Views : 6045 | Status : [Member] | Replies : 3

Why we need to attach the "mdf" file in sql server 2005? And how to attach and paste the "mdf" file?

Please help me

Gopi A


Posted by: Vuyiswamb on: 4/27/2010 [Member] [MVP] [Administrator] NotApplicable

We do that in SQL Express. Look at how its done here

Thank you for posting at DotnetFunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator], if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naveenmanam on: 4/28/2010 [Member] Starter

1. The SQLClient logic opens a connection to the parent SQL Server Express instance (.\SQLEXPRESS by default).
2. SQL Server Express detects that the User Instance option is set and that there is no user instance for this user.
3. The master and msdb system database files are copied to the user's directory. In Sally's case, the directory will be:

C:\Documents and Settings\Sally\Local Settings\Application
Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS

These files are copied from a template directory that is created when the parent instance is installed. When the user instance starts, the tempdb, log, and trace files are written to this same user directory.
4. The parent instance impersonates the Windows user who is opening the connection and starts a copy of sqlservr.exe running as that user. The location of the system databases is passed as a parameter. The name of the instance is generated. For example: 69651E0A-5550-46.
5. A Named Pipe database connection is established for the new instance. The name is based on the instance name. For example:


6. The database file specified in the AttachDBFilename parameter is attached to the new instance and named with the full path to the file:


7. The name of the named pipe is passed back to the SqlClient that is opening the connection.
8. When SqlClient receives the name of the connection, it closes the connection to the parent instance. It opens a new connection to the user instance using the returned named pipe name.

NaveenKumar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pavanandey on: 4/28/2010 [Member] Bronze

Dear Gopi,

Right click on the database on the left hand side of the sql management studio there u will find a option attach click on it,
u will find attache mdf point to the physical location of the mdf file
and click attach

u will find the db attached

Pavan Kumar
Mark Answer if this fits the need, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response