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

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

Cannot attach backup database

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :


I need to recover some specific table information and need to know how to attached a copy of a database. I restored the db from a backup, renamed it and then tried to attach it. I get the error: "Cannot attach a database with the same name as an existing database. I have also renamed the log file. This database is SQL2005Express. The main database is on a webserver, so I didn't want to restore it. I need to open the backup and then extract some information from it.

Thanks for any help!


Albert S

View Complete Post

More Related Resource Links

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?

SQL2008 - Cannot Restore a new database from a full backup of a different one, database in use

I am trying to restore a brand new database from a copy of another one and am encountering an error message stating: System.Data.SqlClient.SqlError: The file <Backup source database file location> cannot be overwritten.  It is being used by database <Backup Source Database>. (Microsoft.SqlServer.Smo) I am running the Restore procedure with the REPLACE option and am wondering why it is stating that the source database is the database in use when I am trying to restore and overwrite a completely different database. This issue happens when running the replace both in C# using SMO and when manually restoring with SqlServer Management Studio Interesting note is, the original source database is created / deployed using a database project within VisualStudios 2010 and then deployed to SqlServer through VisualStudios. Any thoughts on why this is happening? Thanks in advance for any help!

Detach/Attach database question

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?

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

Can't restore database backup file in my database ? using sql server 2005. please help

VERY IMPORTANT i am trying to restore database.bak in sql server 2005 (i know the database.bak was also generated in sql 2005 server) i am trying to restore back up database .bak into the new database i just created in sql server 2005 i have saved my database .bak into c drive and when i select database .bak "From Device", it doesn't get populated in the list below and i see nothing and it keeps on prompting a message "You must select a restore source" Here's the screen shot:   PLEASE HELP..it's really important (i tried restoring database in sql server 2008 and it was sucessful but i am facing this problem in sql server 2005 only)  

How to Include Password during Database Backup over Tape

Hi All, We have EMC Backup Solution in our organization which does backup of all the databases. I want to know is there any way that i can include the password option whenever Backup runs. I dont want to modify any script at the EMS Backup solution side. I want to do it on the fly.         Mohd Sufian www.sqlship.wordpress.com Please mark the post as Answered if it helped.

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  

Is there a way to backup all my store procedures under a particular SQL 2005 database?

hi all, Is there a script, doc, VBS script, SQL statement out there which will read all my store procedures and save them as a TXT file? Currently I have to save all of them in text files before I update them when I get a new web site release. Thank you  JCD

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

how to restore msdb database on sql 2008 from sql 2005 backup?

Currently, I am unable to do it. It gives me the error than I cannot be restored because it was created by a different version of the server. What is the work-around? I hate scripting all my maintenance plans and alerts, there are tonns of themJulieShop

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!

"The backup set holds a backup of a database other than existing database. Restore Database is term

I have a problem when i restore my .DAT_BAK file.  I am getting error like "The backup set holds a backup of a database other than existing database.  Restore Database is terminating abnormally".   I tried by using   RESTORE DATABASE <DATABASENAME> FROM DISK = 'D:\DATA\MYTEST.DAT_BAK' WITH MOVE 'VZAI_DATA' TO D:\PROGRAM FILES\..\MSSQL\TEST.MDF', MOVE 'VZAI_LOG' TO D:\PROGRAM FILES\..\MSSQL\TEST.LDF', REPLACE   And also i tried like   RESTORE DATABASE <DATABASENAME> FROM DISK = 'D:\DATA\MYTEST.DAT_BAK' WITH REPLACE   When i use like this,   RESTORE FILELISTONLY FROM DISK = 'D:\DATA\MYTEST.DAT_BAK'. I am able to get the output as LogicalName, PhysicalName, Type, FileGroupName, Size, etc.   Can i anyone please help me out?   Thanks in Advance, Anand Rajagopal

calculating the size required for backup of database

Hi, How to calculate the size required to take backup of a database in mssql 2000.the results returned by sp_spaceused differ too much from the actual size taken on the disk. Thanks in advance

: Exclusive access could not be obtained because the database is in use.could not applu log backup f

I have 50 databases all are log shippipped.i am getting below error for some databases some time 2010-09-07 15:45:21.04 *** Error: Could not apply log backup file '\\ds\M$\CT_20100907190004.trn' to secondary database 'dsCT'.(Microsoft.SqlServer.Management.LogShipping) *** 2010-09-07 15:45:21.04 *** Error: Exclusive access could not be obtained because the database is in use. I have selected option to disconnect all users when database is in restoring state also. Backup is schedule to run at every hour suppose 12 copy will run at 12:15 and restore will run a 12:45pm. Urgent because i am getting this error on all servers  
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