Attach File mdf to SQL Server using Command Prompt Sqlcmd | Sometimes we need to attach a database file * .mdf and * .ldf into the database sqlserver especially sqlserver express edition. Usually we use sqlserver management studio, but if there is some condition that does not possible to us to use SQL Server Management Studio, then we must use sqlcmd, SQL Server Command Prompt.
First, click Windows Start Button, at Run input type “cmd”, when “Command Prompt” menu show up, right click menu select Run as administrator.
Use Command Prompt SqlCmd
After the DOS command prompt show up, type the following command:
sqlcmd -S <server>\<instance name>