[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

SQL Serv 2005 Create instance through code...

Posted on 2006-06-30
2
Medium Priority
?
272 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

650 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