Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1015631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:25:47+00:00 2026-05-16T10:25:47+00:00

In SQL Server Management Studio, there is an option to set the default database

  • 0

In SQL Server Management Studio, there is an option to set the default database path for a given instance:

alt text

This works. When I say

CREATE DATABASE test

it gets created in the path I specify, E:\data. Great.

But how do I get this path in T-SQL (for use in setup scripts)?

Contrary to what many pages say, there is no registry key (on my machine) for DefaultData or DefaultLog. I am running SQL Server 2005 Express on XP 64.

This value has got to be stored somewhere. Where?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T10:25:47+00:00Added an answer on May 16, 2026 at 10:25 am

    Do you have access to SQL Profiler?

    I don’t have SQL 2005 Express installed but when I view that properties page on my machine with Profiler running I can see where SQL Server retrieves it from on my SQL 2008 instance.

    declare @SmoDefaultFile nvarchar(512)
    
    exec master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', 
     N'Software\Microsoft\MSSQLServer\MSSQLServer', N'DefaultData', 
      @SmoDefaultFile OUTPUT
    
    select ISNULL(@SmoDefaultFile,N'') AS [DefaultFile]
    

    Edit: The above also works for me on SQL Server 2005 Developer edition but only after I changed the default path to something other than the default.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Microsoft SQL Server Management Studio 2008 there is a Generate scripts... option under
In SQL Server Management Studio, there is an option to 'Generate Scripts'. The way
In SQL Server Management Studio is there a property to set so you can
In SQL Server Management Studio there is an option to refresh a table /
Diagrams created with Microsoft SQL Server Management Studio have their default schema set to
I am new to SQL Server Management Studio and am wondering: is there is
Is there a way to prevent users from getting into SQL Server Management Studio
Is there a keyboard shortcut to close a tab in SQL Server Management Studio
I'm using Microsoft SQL Server Management Studio to work with a database. I'm only
I can use the sql server management studio to open a sqlserver 2000 database,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.