troubleshooting Question

Creating database (data and Log file) in SQL SERVER 2008 installed location

Avatar of sath350163
sath350163 asked on
Microsoft SQL Server 2008
4 Comments2 Solutions267 ViewsLast Modified:
I looking for a sample create database script that would create the database in same exact drive in which sql server is installed.

Example:
Say Person A has SQL SERVER 2008 installed in C:\
Person B has has SQL SERVER 2008 installed in D:\
and
Person C has SQL SERVER 2008 installed in E:\

Currently the create database script that I generated from SSMS has the path explicitly specified for both Data and Log file.

Here is a portion from the generated create database script:
BEGIN
CREATE DATABASE [test] ON  PRIMARY 
( NAME = N'TestInstance', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.TestInstance\MSSQL\DATA\test.mdf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'TestInstance_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.TestInstance\MSSQL\DATA\test_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
END
GO
How should I change my script, so that one single create database script could be used to create database in appropriate location in different PCs.

Thanks!
ASKER CERTIFIED SOLUTION
techhealth
Director

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros