How To Attach Or Restore Db From .mdf And Ldf Files After Db Deleted

Aug 19, 2002

First, let me say that I have already reviewed information posted by experts within the chat area.

Someone completely deleted my SQL Server 7 database. I retrieved the .LDF and .MDF files from a network backup. Now I am trying to attach the database. I have tried this without creating an instance of the database by using the attach stored procedure to attache the .LDF and .MDF files I retrieved from the network backup. Also, I have tried it by creating an instance of the database and doing a detach of the newly created db .LDF and .MDF files and an attach of the .LDF and .MDF files I retrieved from the network backup. Neither of these approaches have worked.


Here is what I have tried in the Query Analyzer, but to no avail:


For the following example, I created a database instance called 'qarun_diamond_48_brett' with brand new .ldf and .mdf files and then tried to detach and then attach the .ldf and .mdf files from the network backup:

use master
go
sp_detach_db
'qarun_diamond_48_brett', 'F:APPSSQL 7.0DatabaseDataqarun_diamond_48_brett_log.ldf'

Message: Usage: sp_detachdb <dbname>, [TRUE|FALSE]


use master
go
sp_detach_db
'qarun_diamond_48_brett', 'F:APPSSQL 7.0DatabaseDataqarun_diamond_48_brett.mdf'

Message: Usage: sp_detachdb <dbname>, [TRUE|FALSE]


I tried the following attaches of the retrieved/recoverd .ldf and .mdf from the network to the newly created db instance. That didn't work, so I tried attaching to a db that had not yet been created.

use master
go
sp_attach_db
'qarun_diamond_48_brett2', 'F:APPSSQL 7.0DatabaseDataqarun_diamond_48_brett2_log.ldf'

Message: Server: Msg 1801, Level 16, State 3, Line 1
Database 'qarun_diamond_48_brett' already exists.

If I use a different db name I get the following error:
Server: Msg 5105, Level 16, State 13, Line 1
Device activation error. The physical file name 'qarun_diamond_48_brett' may be incorrect.


use master
go
sp_attach_db
'qarun_diamond_48_brett2', 'F:APPSSQL 7.0DatabaseDataqarun_diamond_48_brett2.mdf'

Message: Server: Msg 1801, Level 16, State 3, Line 1
Database 'qarun_diamond_48_brett' already exists.

I have also tried these statements wtih the EXEC sp_attach_db and EXEC sp_detach_db commands from within the Master db in Query Analyzer.

Any help would greatly be appreciated.

Thanks,

-Brett

View 2 Replies


ADVERTISEMENT

How To Restore The Deleted Records?

May 14, 2006

Hi,
Plz help me to restore deleted records.Pl zsuggest the ways to do it.
Thanks!!

View 2 Replies View Related

How To Restore Deleted Publications?

Apr 18, 2007

The setup is 3 sql 2000 servers, one with a number of publications, and two with transactional pull subscriptions.

The publications were accidentally deleted from the primary server when replication was removed from an older server that unfortunately had been cnamed to the primary server.

The subscriber servers now error "the subscription does not exist".

I had thought restoring the master and msdb on the publisher would bring the publications back but this has not happened. There are good backups of all the system and user databases on the publisher available, but not the scripts that created the publications for replication. Can anyone suggest how or what to restore to get the publications back on the primary server so we can restart replication?

Thank You!

[edit]
It also may be worth noting that the publisher is it's own distributor in this scenario.

View 5 Replies View Related

Restore Deleted Columns With Data

Jan 20, 2007

I need to restore a single table which one of my developers has deleted two columns from that table with all datas.

The copy of that database is on another server ,if some one can show me through EM, a step by step i will appreciate.

Thank you.

View 4 Replies View Related

How To Restore Deleted Records From Table

Jul 2, 2015

I want to delete some records from dbo.ABC table using where clause.

And would like to restore the deleted records back into the same table.

View 5 Replies View Related

Is Restore Or Detach/Attach Better?

Nov 5, 2007

Hello, everyone:

I want to move a database instance (about 50 user databases) to another server, both are running SQL Server 2000. Which method is better, retore from backup files or detach/attach? Some papers said restore amybe cause incorrect login and password transfer. Is it true?

Thanks

ZYT

View 5 Replies View Related

Please Save Me. (File Get Deleted In SQL Server, How To Restore?)

Jun 14, 2001

Hi All,

In SQL Server 2000(Sql Query Analyzer), I had opened a main program file for debugging purpose.

Somehow by mistake its entire contents get replaced/deleted.

I don't have the backup.

I would appreciate anyone who can save me by advising to restore this program.

View 4 Replies View Related

Restore Specific Row Set Accidentally Deleted From A Table

Feb 2, 2004

Hi!

Is there any way I can resore a specified set of deleted rows from a table? Most of these rows were created during the course of the day, but at the end a user deleted them accidentally. My latest full backup is from last night, but if I restore it, it will overwrite many other tables that already have correct informaiton entered during the day. Is there any to roll back only the transaction with which the rows were deleted?

View 2 Replies View Related

Restore Specific Row Set Accidentally Deleted From A Table

Feb 2, 2004

Hi!

Is there any way I can resore a specified set of deleted rows from a table? Most of these rows were created during the course of the day, but at the end of it a user deleted them accidentally. My latest full backup is from last night, but if I restore it, it will overwrite many other tables that already have correct informaiton entered during the day. Is there any to roll back only the transaction with which the rows were deleted?

Mnay thanks for your help!

av

View 1 Replies View Related

Database Restore && Attach Error

Apr 13, 2003

Database Restore & Attach Error
I have a problem with restoring or attaching DB files from different version of the engine. I Have a existing SQL server 7.x and another one is SQL 2000 but I try to backup my database and restore it into the 2000 engine This is the following Problem which occurs :-

1st Problem : During Restoration, The restoration process was runing fine until it reach the last inficatior tab and it fail and say Database terminated abnormal. I been try to restore into other machine also but it give me the same problem.

2nd Problem : Say I can't restore but I stop the engine and manual copy the *.mdf and *.ldf to another machine. I try to restore it but it "is on a network device not supported for database files." So what shall I Do with it.

Pls Advise If anything need to be done before I do the restoring and anything need to be done in both 7.x and 2000 Engine.

:confused:

View 1 Replies View Related

Attach Db With Same Files As Existing Db

Jun 3, 2004

In SQL Server 2000, I would like to attach a Database that is the file of the Database on another system. I made a copy of my Client's Database at his site. Now I would like to attach it to my server and then copy the data from my Client's DB to mine.

The only problem is they have the same file names, so when I try to attach the copy I get an error message. Is there any way to change the name of the data file and log file that a database points to so that I can attach it to my Server?

Thanks in advance for your help!

View 1 Replies View Related

Finding Files To Attach

Nov 1, 2007

Using Microsoft SQL Server Management Studio Express when trying to attach a database, and clicking the Add button, the folder hierarchy appears, but access to personal folders is restricted. How can this be fixed?

Thanks,

Grant

View 5 Replies View Related

Urgent - Unable To Restore/attach A MDF File

Jul 7, 2004

Hi,

I was having problems on myt PC so i did a fresh installation. However I had backed up my SQL database (I only have the MDF file and not the log file).

I have tried restoring and attaching options but nothing works :(

I also get the error saying

"Can not open backup device.... Device error or device off-line. See the SQL server error log for more details. RESTORE database is terminating abnormally".

Please this is urgent. WIll be VERY grateful for your urgent reply.

View 7 Replies View Related

Urgent - Unable To Restore/attach A MDF File

Jul 7, 2004

Hi,

I was having problems on myt PC so i did a fresh installation. However I had backed up my SQL database (I only have the MDF file and not the log file).

I have tried restoring and attaching options but nothing works :(

I also get the error saying

"Can not open backup device.... Device error or device off-line. See the SQL server error log for more details. RESTORE database is terminating abnormally".

Please this is really urgent. Will be VERY grateful for your urgent reply.

View 13 Replies View Related

Attach/restore Databases In SQL Server 2000

Jun 19, 2007

Hi,

I've got a question regarding attaching/restoring of DBs and wonder if anyone could help me out.



Does SQL Server 2000 provide a functionality to attach/restore DB automatically? ie, some kind of polling service to attach/restore DB that were detached previously?





Thanks

Danny.

View 6 Replies View Related

Automatically Enable Broker After Restore Or Attach

Aug 22, 2007

Is there a way to automatically enable Service Broker on SQL Server 2005 Express Edition after a database has been attached or restored?
My initial idea was to check if broker is disabled whenever the client application starts and enable it from there but the problem with this is that the current user might not have the required permissions. So now I'm looking for another way to enable it right after restore/attach if at all possible. Any ideas would be appreciated.

View 3 Replies View Related

Physical Files Can Not Be Deleted After Database Detached

Oct 10, 2007

I have detached the database via sp_detach_db in a job, (I was trying to use a job to detach the database, then make copies of the mdf file, then attach the databases as different copies, somehow the job failed due to file locked) I tried to delete the physical files, but they were still locked. I tried several times, two of them I was able to delete the mdf files, but not the ldf file. The other one both mdf file and ldf file can not be deleted. I was not able to see the database via Management studio.

Can anyone help?

Thanks

View 3 Replies View Related

Manipulate The 'deleted Record' Flag On DBF Files

May 7, 2007

Hi,



I am using OLE DB provider for Foxpro (VFPOLEDB.1) to query DBF files. I need to migrate the content of these files to a SQL Server 2005 database.



These DBF files have some (actually a lot) records marked as deleted using the DBF 'deleted' flag. When I submit a SELECT command to the OLE DB Provider, it returns me all the non-deleted records from the file.



It is very Ok as long as the 'deleted' rows actually have no more business value, but in my case, I need to do some processing on them, and even to migrate their data.



What are the options available for me to be able to query and differentiate the 'deleted' records ?



Thank you in advance,



Bertrand Larsy

View 6 Replies View Related

SQL 2012 :: Attach / Detach Versus Backup And Restore

Mar 20, 2014

We have 5 databases which will sum up to 8+TB, housed in our EDW server. We are planning to migrate to another storage system for better performance.

I am planning Full backup and Differential backup and detach the DB and restore the DB in the new storage system.

Or should I detach,copy the data and log file and attach the files, will this approach have any advantages ?

View 5 Replies View Related

Waht Is Tempdb Database Used For? And How Can We Determine What Files Can Be Deleted From It?

Jun 25, 2007

Hi, all experts here,



Thank you very much for your kind attention.



Just found that my tempdb is always full whenever I run a query against a large database. Could please any experts here give me any advices on what is tempdb database used for and how to determine what files can be deleted from it?



I am looking forward to hearing from you and thanks a lot in advance.



With best regards,



Yours sincerely,



View 3 Replies View Related

Backup/Restore Vs Attach/Detach 2000 Database To 2005

Jul 15, 2006

I'm trying to see the differences between Backup/Restore and Attach/Detach. I backup and detach a database from SQL Server 2000 SP3 and then attach and restore it to SQL Server 2005 SP1.

The differences I noticed are:

1. The restored database has a much larger initial size (database size is same) for data and log.
2. The attached database has a last backup date
3. If the backup is restored over a database, the restored database is showing owned by the database owner of the database restored over but syslogins and sysusers do not match.

I don't understand why #1 happens.

Are there any other differences between Backup/Restore and Attach/Detach?



Thanks,

Peter

View 2 Replies View Related

Send E-mail Attach All Files In A Folder

Dec 8, 2006

Is there a way to send an e-mail from SSIS that attaches all the files in a specified folder?

View 5 Replies View Related

Trying To Attach Database In VS2005 And All DB Files Say They Are Being Used And To Close...they Are NOT Open.

Apr 13, 2008



Just to verify that this was an issue, I downloaded web developer 2008 and I do not experience this same problem.


BUT when I go to add a dataset in vs2005 for an asp website - all my db files come up in the dialogue box but everyone that click (every db file) I get "This file is in use. Please enter a new name or close the file that's open in another program."



But, like I said, I downloaded 2008 and it does not occur. Plus I KNOW that the db's are not being used. Can someone give me a remedy to this?

View 1 Replies View Related

SQL Server 2008 :: Count Number Of Files Deleted From Share Path?

Apr 23, 2015

SET NOCOUNT ON
Declare @daysOld int,@deletedate nvarchar(19) ,@strDir varchar(250)
declare @cmd11 nvarchar(2000)
declare @mainBackupDir varchar(2000),
@result1 nvarchar(max);

[Code] ....

View 1 Replies View Related

SQL Server Express: Restore, Backup And Attach Do Not Work Anymore &&amp; Database Locations Fault

May 7, 2008

Hello there,

I've some really big problems with SQL Server 2005 Express. I Recently, I had 2 instances on my machine, one was a SQL Server 2000 Developer and the other a 2005 Express Version. The 2000 version was not necessary anymore, so I unstalled it, since then, the Express version keeps having probems.

Under the Server Properties -> Database settings -> Database Locations I've changed the path to D:sqldatamssql, but now, the programm always takes the "C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLData" to store and load the databases, no matter what I do.

And there are more problems see here:

Restoring does not work=======================
I wanted to restore a database called "fw40_admin" from a backup file (.bak), but that didn't work at all, it always says this as an error:

"System.Data.SqlClient.SqlError: The operating system returned the error '5(error not found)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'D:sqldatamssqlfw40_admin.mdf'. (Microsoft.SqlServer.Express.Smo)"

But as soon as I type in the installation path "C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLData" inside the "Restore As" under "Options", it works.

Why does the backup only work in "C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLData", BUT the database locations under the server properties is indicated with "D:sqldatamssql"????


Attaching does not work=======================
Attaching an existing database does not work either. Most databases (mdf) are located on the path D:sqldatamssql, but as soon as I press

Attach Databases -> Add

The dialog window appears with the "D:sqldatamssql" path, but it is unable to find any *.mdfs altough THERE ARE .mdfs in this directory. But Express can find databases in the selected installation: "C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLData".
Why can't Express see the directory on the D: partition???


What is wrong? Here? Can anybody help me?

View 5 Replies View Related

Can Multiple Workstations Running SQL 2005 Server Express Attach To The Same Database Files On A Shared Network Location?

Mar 15, 2007

Can multiple instances of SQL 2005 Express attach to the same database files on a network share? I have seen this done before with MSDE where the database files are stored on the server, but instead of having a SQL server running on the network and then connecting to it, only the database files exist on the network share and the users connect through MSDE running on the local machine. Is this possible with SQL2005Express? I do not have the ability to share an SQL instance from one workstation to another nor do I have the ability to install an instance on the corporate server. Is it as simple as creating the database and storing the files on the share then attaching the database to the SQL Instance on each workstation?

View 3 Replies View Related

SQL Server 2008 :: Count Number Of Backup Files Deleted From A Default Backup Location

Mar 13, 2015

I've written a custom script to delete backup files from location. But unable to modify now to count the number of files are deleted. How to modify the script...

/* Script to delete older than N days backup from a specific directory */

USE [db_admin]
GO
IF OBJECT_ID('usp_DeleteBackup', 'P') IS NOT NULL
DROP PROC usp_DeleteBackup
GO

[Code] .....

View 2 Replies View Related

Detach-copy-attach: Can Not Copy Files - Getting Access Denied

Feb 28, 2008



Hi!
I did:
alter database mydb set single_user with rollback immediate;
exec sp_detach_db @dbname='mydb', @keepfulltextindexfile='true';

then I tried to copy files to new location on other drives, same server but got
>>Cannot copy <myfile>: Access is denied
Make sure the disk is not full or write-protected and that the file is not currently in use<<

I also tried rename of file without success.
I also tried with db service stoppet (not preferred) without success.

How to find out, which process locks the files?
Best regards

View 7 Replies View Related

Restore Db From Several .bak Files

Mar 21, 2007

Hi,

I backup db into several .bak files to reduce backup time. but how can I restore them back? Do I have to do it by scripts? Can I restore it by using management studio?

cheers

View 4 Replies View Related

Restore A DB From .mdb And .ldb Files.

Jan 21, 2008

I have troubles with my computer, in the pc I have some databases but the only thing that they can recover were the .mdb and .ldb files.
How can I restore a database from these files?

View 7 Replies View Related

Restore From Log Files

Mar 11, 2008

i accidentally restored a db to a backup from last year and i don't have a recent backup - is there anyway to restore from log files?

View 2 Replies View Related

Attach Aspnetdb.mdf Failed, But I Can't Find Attach Statement In The Web.config

Nov 21, 2007

An attempt to attach an auto-named database for file C:WebApp_Dataaspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.  
My web.config file, the connection strings
<connectionStrings>
  <add name="POAdatabaseConnectionString1" connectionString="Data Source=sss;Persist Security Info=True;Initial Catalog=POAdatabase.mdf;Integrated Security=SSPI"   providerName="System.Data.SqlClient" />
 </connectionStrings>
I cann't really find the statement for attaching aspnetdb.mdf. I don't where to find it. Is there any other web.config file in the C drive? Thanks for help!
 

View 3 Replies View Related

Restore Files And Filegroups

Sep 26, 2000

hi

To restore files and filegroups in a different server. First, Do i have to create the database with same name as the old one? or it doesn't matter... Can we use Enterprise Manager to do this restore?

Thanks in advance

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved