.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Detach/Attach database question

Posted By:      Posted Date: August 28, 2010    Points: 0   Category :Sql Server
I recently restored a database from SQL7 to SQL2005.  When restoring the database I needed to create a c:\data\data folder or else it would not restore the mdf and ldf files. I would like to move these files to a new location.  Copied the the two files to a new folder, C:\database.  Using the sql studio manager, preformed a task to detach the database, then attach the database with the new location. This seemed to work, I am able to access my application that uses this database.  However, any changes I make to the program, are not writing changes back to the mdf file.  When I open the program, these changes are still in place, but the mdf file should be updated, correct?  When the database files were stored in the c:\data\data folder, any little change I made to the program changed the modified time for the mdf file. Is there something missing or where could these changes be written to?

View Complete Post

More Related Resource Links

database interface design question


For handy database interface, is it good to use SqldataSources exclusively intead of EntLib functions?

Thanks for any feedback.

unable to attach database, security setting?


Hi folks,

I am using VS 2010 Professional with SQL Server 2008 Developer.  I right click on the App_Data folder in solution explorer and add an existing item, then navigate to the correct database.  However, I receive a pop up that Access is Denied.  How do I fix this? 

cannot attach database from server explorer


Hello all,

In Server Management Studio, I am attempting to attach a database.  After selecting the database in the wizard

I receive an error: This file is in use, Enter a new name or close the file that's open in another program. 

I don't have SSMS open, and have restarted the computer to make sure the memory is cleared.  Not sure what to try next.  Any ideas?

Database CurrentUser Question

I am trying to check whether the user connected to a database is db_ownder so I am using the IsDbOwner property on the database object that was created from the Server object but it is setting the UserName to guest as opposed to the user connecting - any ideas? Thanks Scott

attach sample database failed in sql 2008 express RTM

I'm having a trouble attaching sample database northwnd database,screen show me the error attach database failed for server 'computername\sqlexpress' additional inforamtion: the database 'northwind' cannot be opended because it is version 661.this server supports version 655 and earlier.a downgrade path is not supported.could not open new database 'northwind',create database is aborted,()microsoft sql server,error:948) my os is xp sp3,sql express version is  Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86)   Jul  9 2008 14:43:34   Copyright (c) 1988-2008 Microsoft Corporation  Express Edition with Advanced Services on Windows NT 5.1 <X86> (Build 2600: Service Pack 3)  I 'm sure database 'northwind' is ok.I can used database 'northwind' on my other computer.the other computer install express 2008R2 .    install RTM computer  ,database route is C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS,not C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data. actually I 'm install sample database in sql express RTM on my computer.I just wonder why attach good database failed,how to solved this issue. http://sqlserversamples.codeplex.com/releases/view/45923 this link is avialable   thanks for you help

Move (detach/attach) db from 2008 Enterprise to 2008 Express

Hello I just thought about this question. Is it possible to create a database on a SQL 2008 Enterprise edition and move it to a SQL 2008 Express edition or would i run into the same version problems as when moving from 2008 to 2005? The reason for this is that i have a virtual Dev environment that has SQL 2008 Enterprise edition installed and now i get a project that is to run on SQL 2008 Express. It would be nice if i could skip installing the express edition and work against the Enterprise edition until deployment. Thanks ps. wasn't sure if this was the right forum to post this in. Please let me know if there was a more appropriate place for this.

Cannot crawl sharepoint site and mysite after database attach upgrade form sharepoint 2007 to 2010.

After database attach upgrade site and mysite from sharepoint 2007 to 2010 , I have full crawl and get "The crawler could not communicate with the server. Check that the server is available and that the firewall access is configured correctly. If the repository was temporarily unavailable, an incremental crawl will fix this error. ( Error from SharePoint site: HttpStatusCode ServiceUnavailable The request failed with HTTP status 503: Service Unavailable. )" for mysite and get "Access is denied. Verify that either the Default Content Access Account has access to this repository, or add a crawl rule to crawl this repository. If the repository being crawled is a SharePoint repository, verify that the account you are using has "Full Read" permissions on the SharePoint Web Application being crawled." for sharepoint site. The content access account for search is "db_owner" of both of site and mysite. How do I solved this problem ?

How to attach distribution database files

Hi  i am new to sql server. when i am exploring replication concepts, i did a small mistake i.e. i have deleted distribution database.after that i realised and try to create a new one but it still points to the old database named as "distribution" which is not available. i didnt take the backup of the database before dropping. But i have mdf and ldf files of the distribution database. so can i use the sp_attach method to add the  mdf and ldf files? or any other way to fix this issue? please help me on resolving this issue Thanks, Rock  

Attach database with MSSMS

I have installed SQL 2008 R2 Express and want to attach a database stored in: C:\Users\Me\Documents\Visual Studio 2010\Projects\Databases\Databases\ACME however, when I try to open the Documents and Settings folder it doesn't show the child folders. This is a real pain and I have been unable to find a solution. Any ideas?Still trying to program

Recovery of Database Disabled SQL Agent, Cannot Detach Database, Etc... Please Help

I am a beginner SQL user, as the company laid off the IT guy and I am stuck with this.  So I really need some help on this one.  Any ideas would be appreciated. I was doing a merge join command to put data from one database to another.  These are 60GB databases with valuable data.  Halfway through I was told by client to just stop the query.  I did this but it left the good database with a large 80GB log file. When I rebooted the machine the recovery of this database took 5-10 minutes...  Thus the SQL Agent disabled itself waiting for recovery.  After recovery was 100% complete with no errors SQL Agent will not restart.  I can do a force turn on using a "1" statement, but the SQL Agent log file says it is still waiting for recovery. In any event, I cannot detach the database because it says 1 user connected.  I cannot backup, drop, etc...  I saw in one forum a guy said to turn service off, copy database to a new location, turn service back on, delete the database, attach copied database...  But I am a little worried about deleting. Once again - I am a SQL newbie and really need a pointer on this one.  I need to free this database and get a it back to a normal sized log file. Advice???

database attach method migration wss3.0 to foundation 2010

I am confused in data base attach migration method for the follwoing scenario .Can you please give me clarity? it is urgent. We have a production system in wss3.0. I took  backup of the content database using sql servr management studio tool. Can I restore this content DB to a test environment ( on sun Virtual box with 'windows 7' 64-bit host OS) and from test env't to new production system?  If my testing is done and ready to move to new production system then How can I add the data accumulated during testing period (one month) to new prod'n system from wss3.0 system. Best regards,

Attach Database Error 5120

Hi- I just started a SQL class and now have SQL Server 2005 and SQL Management Express.  The teacher gave out two databases to attach but I get the following error when trying to attach either database: Attach database failed for Server 'xxx\SQLEXPRESS'.  (Microsoft.SqlServer.Express.Smo) ------------------------------ An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo)      =================================== Unable to open the physical file "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AP_log.LDF". Operating system error 2: "2(The system cannot find the file specified.)". Microsoft SQL Server, Error:  5120)   ------------------------------ Any help would be appreciated as I have homework that's due this week.   Thanks!

unable to attach database

Unable to attach Database (SQL Express 2005):DATABASE-->When supposed to add new database by click right button of the mouse,clicking 'Attach and in window 'Attach Databse' when I click 'ADD' Button : I receive error: Failed to retrive data for this request.(MS.SqlServer.Express.SmoEnum) Additional Information: Failed to connect to Server .....(MS.Sqlserver.express.connectionInfo)   PLEASE HELP.    

how to attach sql database file to creating .exe setup in c#

I create a Setup file and put data folder, in data folder i put database file , but the problem is i have to mannualy attach database file in sql server 2005. I have to automatically attach database file when installing setup file.

An attempt to attach an auto-named database ....\aspnetdb.mdf failed

I've installed VWD 2005(Beta 2) and MS SQL Express and also followed the aspnet tour at http://beta.asp.net/guidedtour2. After trying new webcontrol (login control) and trying to execute the page, I've got an error such as below: An attempt to attach an auto-named database for file c:\inetpub\wwwroot\Demo\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file c:\inetpub\wwwroot\Demo\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  Stack Trace: [SqlException (0x80131904): An attempt to attach an auto-named database for file c:\inetpub\wwwroot\Demo\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.] Syste

Sharepoint Database size question

We have just installed Sharepoint 2010 in our network.  We currently have 2 users who are accessing the system, since we are in alpha stage.  What I have noticed is that  User Profile Service Application_SyncDB database size is at 800mb.  is this normal? In addtion, WSS_Logging database size is at 140mb. 

Problem trying to attach database file to Microsoft SQL Server Management Studio

I was trying to attach a database to SQL Server MGT Studio and got an exception error.  The message stated that the database file I was trying to attach could not be opened because it was version 661.  The SQL Server shows to support version 655 and earlier.  It states that a downgrade path is not supported. Question:  Is there some download ; fix; I can make to SQL Server 2008 that will allow me to attach the version 661????  I am not technical at all.  Please speak slowly.  :)  Thanks
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend