?
Solved

SQL Serv 2005 Create instance through code...

Posted on 2006-06-30
2
Medium Priority
?
270 Views
Last Modified: 2008-02-26
Hi...

I want to know how difficult it is to:

1- Create a new instance of the SQL SERVER 2005 on a computer
2- Attach a bunch of *.mdf files.

I need a way to perform this outside the Management Studio.
A batch file, thru command prompt commands... you name it.

I just need to trigger it from a .net application.

Thanks!
Alex
0
Comment
Question by:Alexandre Simões
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 13

Accepted Solution

by:
devsolns earned 2000 total points
ID: 17019939
if you are looking to do a silent install of SQL Server express edition look here:

Done through cmd prompt.
http://www.haidongji.com/2006/02/05/silent-install-command-line-install-of-sql-server-2005-part-4/

Then to attach a database is easy:

From cmd prompt:
sqlcmd -S Server\Instance

USE [master]
GO
CREATE DATABASE [database_name] ON
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\<database name>.mdf' ),
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\<database name>.ldf' )
 FOR ATTACH ;
GO


http://msdn2.microsoft.com/en-us/library/ms165673.aspx

Hope this helps:

--DS
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17020050
>1- Create a new instance of the SQL SERVER 2005 on a computer
as devsolns indicates, this is only possibly by installing sql server (silently)


0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question