Showing posts with label Sql-server database. Show all posts
Showing posts with label Sql-server database. Show all posts

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.

LinkWithin

Related Posts with Thumbnails