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

  • Home
  • SEARCH
  • 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 1050551
In Process

The Archive Base Latest Questions

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

I have a Sql Server 2008 Express database file that’s currently being used by

  • 0

I have a Sql Server 2008 Express database file that’s currently being used by an ASP.NET application, and I’m not sure how to query the database without taking the website down.

I’m unable to copy the database files (.mdf and .ldf files) to another directory, since they’re in use by the web server. Also, if I attach the databases to an instance of the sql server (using the ‘Create Database [DB name] on (filename = ‘[DB filename.mdf]’) for attach;’ command at the sqlcmd prompt), then the application pool user becomes unable to access the database (i.e. the webpages start producing http 500 errors. I think this might have to do with the username for the application pool becoming somehow divorced from the login credentials in the sql server database).

Any suggestions? I realize this is probably a newbie question, since it seems like a rather fundamental task. However, due to my inexperience, I really don’t know what the answer is, and I’m pretty stumped at this point, since I’ve tried a couple of different things.

Thanks!

Andrew

  • 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-16T16:47:14+00:00Added an answer on May 16, 2026 at 4:47 pm

    if I attach the databases to an instance of the sql server (using the ‘Create Database [DB name] on (filename = ‘[DB filename.mdf]’) for attach;’ command at the sqlcmd prompt),

    Don’t do this to a live database – it’s attempting to be setup an MDF to be written to by two different databases…

    Use Backup/Restore

    As you’ve found, Attach/ReAttach requires the database to be offline – use the Backup/Restore functionality:

    • MSDN: Using SSMS to Backup the Database
    • MSDN: Using SSMs to Restore the Backup

    Be aware that the backup/restore doesn’t maintain logins (& jobs if you have any associated with the database) – you’ll have to recreate & sync if using an account other than those with uber access.

    Maybe Linked Server would work?

    Another alternative would be to setup another SQL Server Express/etc instance on a different box, and use the Linked Server functionality to create a connection to the live/prod data. Use a different account than the one used for the ASP application…

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

Sidebar

Related Questions

I have a application that uses LocalDataCache to synchronise a SQL Server 2008 Express
I have a web application that uses a local SQL Server Express database (a.k.a.
Ok, I'm using SQL Server Express 2008 and .Net 3.5 (c#) I have a
I have a piece of code that creates an SQL Server Express 2008 in
Greeting all. I have a SQL Server 2008 Express database with a table called
First a little introduction. We have an SQL Server Express 2008 database, which schema
I have an existing MVC3 application and database that is on a SQL Server
I have the following installed: VS 2008 SP 1 ASP.NET MVC 1.0 SQL Express
I have a WinForm application built with VS 2008 (C#) and SQL Server Express
I have a SQL Server 2008 Database running on Express. I want to copy

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.