Thursday, February 11, 2010

Installing Sql-server 2005 express edition using cmd (Silent Mode)

Today I am going to share how to install sql-server 2005 express edition using cmd (command prompt) which is also known as silent mode or non-interactive mode. Also refer to my post regarding performing silent install of sql-server 2005 using C#.net. This method of installation is very helpful if one is bundling the sql-server 2005 express edition with another product which is going to use it. The command prompt parameters are as follows:
start /wait C:\SQLSERVER2005\SQLEXPR32.EXE /qb username="CustomerUsername" companyname="OurCompany" addlocal=ALL  disablenetworkprotocols="0" instancename="MyInstance" SECURITYMODE="SQL" SAPWD="MyPassword"

This would successfully install the sql-server 2005 express edition to the system. Now to login into the sql-server use the following command in cmd:

sqlcmd -S PC100\MyInstance -U sa -P MyPassword

After successful login we would require to attach a database. To attach a database use following command:

CREATE DATABASE MyDBName ON
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\MyDB_Data.mdf' ),
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\MyDB_log.ldf' )
 FOR ATTACH ;
GO

This would successfully attach the database. Now you are ready to use the database.

5 comments:

  1. Quite a nice post. It really helped me in managing the installation at the client side. Thanks !:)

    ReplyDelete
  2. looks great. The parsing of corrupted documents can be also performed by the sql recovery tools, it is the fastest way to open affected files

    ReplyDelete
  3. This is brilliant !!! Thanks for the code. Just to add one more thing this type of silent installation is also known as unattended installation. Good work Jai.

    ReplyDelete
  4. Thanks @Meera for the update. You are right, the silent installation is also known as un-attended installation, no-interaction installation and one-click installation.

    ReplyDelete
  5. Thank you very much for your article.

    ReplyDelete

Comments to this post

LinkWithin

Related Posts with Thumbnails