Showing posts with label installation. Show all posts
Showing posts with label installation. Show all posts

Friday, March 23, 2012

Recovering DB with only the .MDF file

I saw the other thread that is related, but let me give you our circumstances. A drive failed and that drive had the SQL installation and the *.ldf files on it. The MDF files were unscathed.

The drive has been rebuilt and I have reinstalled SQL 2000 SP3A on there (that is what was there before). I have tried attaching the MDF through the GUI and letting it create the log for me. This failed.

I tried sp_attach_single_file_db, but this failed since the db was never dettached.

I tried creating the db again, dettaching it, copying the old (good) MDF file over the newly created one and then attaching (using multiple attach approaches). It knows that the log file and mdf are not matched and won't let me do the attach.

I also found DBCC REBUILD_LOG, but the article in SQL Mag supposes that your instance is still in working order and that there is an entry for the db in sysdatabases. Such is not true in my case.

Can you help? We are trying to get old backup tapes shipped to the site, looking up our Gold Partner contact info, etc., but in the meantime, I am trying to get the data restored even if we lose some transactions.

Thanks for any help!

Here is what worked for me. Thanks for SQL Server Mag for the core pieces of this:

-- LISTING 1: Undocumented DBCC Command REBUILD_LOG

/* Create a new db named the same as the inaccessible one (in this case "Ops") */

EXEC sp_configure 'allow updates', 1
RECONFIGURE WITH OVERRIDE
GO

BEGIN TRAN

UPDATE master..sysdatabases
SET status = status | 32768
WHERE name = 'Ops'

IF @.@.ROWCOUNT = 1
BEGIN
COMMIT TRAN
RAISERROR('emergency mode set', 0, 1)
END
ELSE
BEGIN
ROLLBACK
RAISERROR('unable to set emergency mode', 16, 1)
END

GO

EXEC sp_configure 'allow updates', 0
RECONFIGURE WITH OVERRIDE
GO

-- 3. Stop SQL Server
-- 4. Replace the newly created Ops.mdf file with the old good one
-- 5. Rename the newly created Ops_log.ldf file
-- 6. Start SQL Server

-- 7. Run the following DBCC command:
DBCC REBUILD_LOG('Ops','E:\Program Files\Microsoft SQL Server\MSSQL\Data\Ops_log.LDF')

-- You should get the message:
-- Warning: The log for database 'Ops' has been rebuilt. Transactional consistency has been lost.

-- DBCC CHECKDB should be run to validate physical consistency. Database options will have to be reset,

-- and extra log files may need to be deleted.
-- DBCC execution completed. If DBCC printed error messages, contact your system administrator.


-- 8. Run data consistancy check
/*Perform physical and logical integrity checks at this point.
Bcp data out if your integrity checks demonstrate that problems exist.
*/
DBCC CHECKDB (Ops)


ALTER DATABASE Ops SET MULTI_USER
GO

-- Set database options and recovery model as desired.
GO

-- Make a backup and start to use the DB again

|||

Note that in SQL Server 2005, all of this can be accomplished using the

CREATE DATABASE FOR ATTACH_REBUILD_LOG command.

All of the same caveats apply: if you attach a database without a log, you stand a good chance of losing data and/or ending up with a corrupt database. If you've got no choice, you've got no choice. That's what backups are for.

|||

dear Mr.BusmasterJones

I know it was a long time since you posted this but can you help me with the same problem but in SQL SERVER 2005

I had a lot of error messages when i TRIED the way you described...
there was an error when I tried the first part and error message was about adding ad hoc is not allowed
then calling the method was rejected too.

Please help me!!!!

I posted this for the same problem http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1976457&SiteID=1

THANKS IN ADVANCE

Recovering DB with only the .MDF file

I saw the other thread that is related, but let me give you our circumstances. A drive failed and that drive had the SQL installation and the *.ldf files on it. The MDF files were unscathed.

The drive has been rebuilt and I have reinstalled SQL 2000 SP3A on there (that is what was there before). I have tried attaching the MDF through the GUI and letting it create the log for me. This failed.

I tried sp_attach_single_file_db, but this failed since the db was never dettached.

I tried creating the db again, dettaching it, copying the old (good) MDF file over the newly created one and then attaching (using multiple attach approaches). It knows that the log file and mdf are not matched and won't let me do the attach.

I also found DBCC REBUILD_LOG, but the article in SQL Mag supposes that your instance is still in working order and that there is an entry for the db in sysdatabases. Such is not true in my case.

Can you help? We are trying to get old backup tapes shipped to the site, looking up our Gold Partner contact info, etc., but in the meantime, I am trying to get the data restored even if we lose some transactions.

Thanks for any help!

Here is what worked for me. Thanks for SQL Server Mag for the core pieces of this:

-- LISTING 1: Undocumented DBCC Command REBUILD_LOG

/* Create a new db named the same as the inaccessible one (in this case "Ops") */

EXEC sp_configure 'allow updates', 1
RECONFIGURE WITH OVERRIDE
GO

BEGIN TRAN

UPDATE master..sysdatabases
SET status = status | 32768
WHERE name = 'Ops'

IF @.@.ROWCOUNT = 1
BEGIN
COMMIT TRAN
RAISERROR('emergency mode set', 0, 1)
END
ELSE
BEGIN
ROLLBACK
RAISERROR('unable to set emergency mode', 16, 1)
END

GO

EXEC sp_configure 'allow updates', 0
RECONFIGURE WITH OVERRIDE
GO

-- 3. Stop SQL Server
-- 4. Replace the newly created Ops.mdf file with the old good one
-- 5. Rename the newly created Ops_log.ldf file
-- 6. Start SQL Server

-- 7. Run the following DBCC command:
DBCC REBUILD_LOG('Ops','E:\Program Files\Microsoft SQL Server\MSSQL\Data\Ops_log.LDF')

-- You should get the message:
-- Warning: The log for database 'Ops' has been rebuilt. Transactional consistency has been lost.

-- DBCC CHECKDB should be run to validate physical consistency. Database options will have to be reset,

-- and extra log files may need to be deleted.
-- DBCC execution completed. If DBCC printed error messages, contact your system administrator.


-- 8. Run data consistancy check
/*Perform physical and logical integrity checks at this point.
Bcp data out if your integrity checks demonstrate that problems exist.
*/
DBCC CHECKDB (Ops)


ALTER DATABASE Ops SET MULTI_USER
GO

-- Set database options and recovery model as desired.
GO

-- Make a backup and start to use the DB again

|||

Note that in SQL Server 2005, all of this can be accomplished using the

CREATE DATABASE FOR ATTACH_REBUILD_LOG command.

All of the same caveats apply: if you attach a database without a log, you stand a good chance of losing data and/or ending up with a corrupt database. If you've got no choice, you've got no choice. That's what backups are for.

|||

dear Mr.BusmasterJones

I know it was a long time since you posted this but can you help me with the same problem but in SQL SERVER 2005

I had a lot of error messages when i TRIED the way you described...
there was an error when I tried the first part and error message was about adding ad hoc is not allowed
then calling the method was rejected too.

Please help me!!!!

I posted this for the same problem http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1976457&SiteID=1

THANKS IN ADVANCE
sql

Wednesday, March 21, 2012

Recover SQL Server Data/Agent Tasks from old Data folder

Hi,
I have got a sql server installation folder.. (data and log files
folder). The server crashed so installed a new OS and sql server
instance. I have recovered the old drive with the data and other
folders.
I tried copying all the files to the new data folder while the server
is not running and tried to start the server hoping that all my
databases and sql agent task will be there. But needless to say the sql
server wouldn't start like that. So i replaced the files back with the
newly installed files.
Now I have got these data folders with all my databases. I have copied
the mdf and ldf files and attached it to the newly installed server and
I have got back my databases. Is there a way to recover all the sql
agent tasks I used to have? How can I restore my msdb or master
databases..
Any tips would be appreciated..
Thanks
Sazzad
> I have got back my databases. Is there a way to recover all the sql
> agent tasks I used to have? How can I restore my msdb or master
> databases..
Did you back up them?
"Sumon" <sumon.net@.gmail.com> wrote in message
news:1160981526.080016.173980@.h48g2000cwc.googlegr oups.com...
> Hi,
> I have got a sql server installation folder.. (data and log files
> folder). The server crashed so installed a new OS and sql server
> instance. I have recovered the old drive with the data and other
> folders.
> I tried copying all the files to the new data folder while the server
> is not running and tried to start the server hoping that all my
> databases and sql agent task will be there. But needless to say the sql
> server wouldn't start like that. So i replaced the files back with the
> newly installed files.
> Now I have got these data folders with all my databases. I have copied
> the mdf and ldf files and attached it to the newly installed server and
> I have got back my databases. Is there a way to recover all the sql
> agent tasks I used to have? How can I restore my msdb or master
> databases..
> Any tips would be appreciated..
> Thanks
> Sazzad
>
|||Uri Dimant wrote:
[vbcol=seagreen]
> Did you back up them?
>
> "Sumon" <sumon.net@.gmail.com> wrote in message
> news:1160981526.080016.173980@.h48g2000cwc.googlegr oups.com...
If you have backup of MSDB you can restore its backup or if you have
mdf/ldf files you can attach files.
Which version of SQL Server you are using? 2000 or 2005?
Regards
Amish shah

Recover SQL Server Data/Agent Tasks from old Data folder

Hi,
I have got a sql server installation folder.. (data and log files
folder). The server crashed so installed a new OS and sql server
instance. I have recovered the old drive with the data and other
folders.
I tried copying all the files to the new data folder while the server
is not running and tried to start the server hoping that all my
databases and sql agent task will be there. But needless to say the sql
server wouldn't start like that. So i replaced the files back with the
newly installed files.
Now I have got these data folders with all my databases. I have copied
the mdf and ldf files and attached it to the newly installed server and
I have got back my databases. Is there a way to recover all the sql
agent tasks I used to have? How can I restore my msdb or master
databases..
Any tips would be appreciated..
Thanks
Sazzad> I have got back my databases. Is there a way to recover all the sql
> agent tasks I used to have? How can I restore my msdb or master
> databases..
Did you back up them?
"Sumon" <sumon.net@.gmail.com> wrote in message
news:1160981526.080016.173980@.h48g2000cwc.googlegroups.com...
> Hi,
> I have got a sql server installation folder.. (data and log files
> folder). The server crashed so installed a new OS and sql server
> instance. I have recovered the old drive with the data and other
> folders.
> I tried copying all the files to the new data folder while the server
> is not running and tried to start the server hoping that all my
> databases and sql agent task will be there. But needless to say the sql
> server wouldn't start like that. So i replaced the files back with the
> newly installed files.
> Now I have got these data folders with all my databases. I have copied
> the mdf and ldf files and attached it to the newly installed server and
> I have got back my databases. Is there a way to recover all the sql
> agent tasks I used to have? How can I restore my msdb or master
> databases..
> Any tips would be appreciated..
> Thanks
> Sazzad
>|||Uri Dimant wrote:
> > I have got back my databases. Is there a way to recover all the sql
> > agent tasks I used to have? How can I restore my msdb or master
> > databases..
> Did you back up them?
>
> "Sumon" <sumon.net@.gmail.com> wrote in message
> news:1160981526.080016.173980@.h48g2000cwc.googlegroups.com...
> > Hi,
> >
> > I have got a sql server installation folder.. (data and log files
> > folder). The server crashed so installed a new OS and sql server
> > instance. I have recovered the old drive with the data and other
> > folders.
> >
> > I tried copying all the files to the new data folder while the server
> > is not running and tried to start the server hoping that all my
> > databases and sql agent task will be there. But needless to say the sql
> > server wouldn't start like that. So i replaced the files back with the
> > newly installed files.
> >
> > Now I have got these data folders with all my databases. I have copied
> > the mdf and ldf files and attached it to the newly installed server and
> > I have got back my databases. Is there a way to recover all the sql
> > agent tasks I used to have? How can I restore my msdb or master
> > databases..
> >
> > Any tips would be appreciated..
> >
> > Thanks
> >
> > Sazzad
> >
If you have backup of MSDB you can restore its backup or if you have
mdf/ldf files you can attach files.
Which version of SQL Server you are using? 2000 or 2005?
Regards
Amish shah

Recover SQL Server Data/Agent Tasks from old Data folder

Hi,
I have got a sql server installation folder.. (data and log files
folder). The server crashed so installed a new OS and sql server
instance. I have recovered the old drive with the data and other
folders.
I tried copying all the files to the new data folder while the server
is not running and tried to start the server hoping that all my
databases and sql agent task will be there. But needless to say the sql
server wouldn't start like that. So i replaced the files back with the
newly installed files.
Now I have got these data folders with all my databases. I have copied
the mdf and ldf files and attached it to the newly installed server and
I have got back my databases. Is there a way to recover all the sql
agent tasks I used to have? How can I restore my msdb or master
databases..
Any tips would be appreciated..
Thanks
Sazzad> I have got back my databases. Is there a way to recover all the sql
> agent tasks I used to have? How can I restore my msdb or master
> databases..
Did you back up them?
"Sumon" <sumon.net@.gmail.com> wrote in message
news:1160981526.080016.173980@.h48g2000cwc.googlegroups.com...
> Hi,
> I have got a sql server installation folder.. (data and log files
> folder). The server crashed so installed a new OS and sql server
> instance. I have recovered the old drive with the data and other
> folders.
> I tried copying all the files to the new data folder while the server
> is not running and tried to start the server hoping that all my
> databases and sql agent task will be there. But needless to say the sql
> server wouldn't start like that. So i replaced the files back with the
> newly installed files.
> Now I have got these data folders with all my databases. I have copied
> the mdf and ldf files and attached it to the newly installed server and
> I have got back my databases. Is there a way to recover all the sql
> agent tasks I used to have? How can I restore my msdb or master
> databases..
> Any tips would be appreciated..
> Thanks
> Sazzad
>|||Uri Dimant wrote:
[vbcol=seagreen]
> Did you back up them?
>
> "Sumon" <sumon.net@.gmail.com> wrote in message
> news:1160981526.080016.173980@.h48g2000cwc.googlegroups.com...
If you have backup of MSDB you can restore its backup or if you have
mdf/ldf files you can attach files.
Which version of SQL Server you are using? 2000 or 2005?
Regards
Amish shah

Friday, March 9, 2012

Recover A Database From Another Hard Disk With A Corrupted Windows 2000 Installation.

Hello,

I am trying to recover a SQL Server 7 database from another hard disk
drive that has a corrupted Windows 2000 Advanced Server installation. I
am not able to repair the corrupted Windows 2000 Advanced Server
installation but the file system is intact. I have installed a new copy
of SQL Server 7 onto a new hard disk and have used the sp_attach_db
system stored procedure to attach the database from the old hard drive
into the new installation of SQL Server 7 on the new hard drive. The
database shows up in the Enterprise Manager View and all the data and
structure are there, but when I try to run a Web site that uses ODBC
connections to the database I get the following error:

ODBC Error Code = 08001 (Unable to connect to data source)

[Microsoft][ODBC SQL Server Driver][Named Pipes]Specified SQL server
not found.

I have double-checked that all the NTFS permissions, ODBC DSNs, and Web
Server settings are correct and when I run the SQL Server ODBC driver
test at the completion of each ODBC DSN setup, it is successfull.

1) Why am I getting this ODBC error?

2) What steps have I missed in the recovery process?

3) If I have done something wrong recovering my database, can I still
recover it since I still have: a) The old master database file and log
file; b) The old database (non-master) file and log file; c)A backed-up
(Enterprise Manager -> Right Click A Database -> All Tasks -> Backup
Database) copy of the old database (non-master) file; ?

My System Specifications:
-Windows 2000 Advanced Server
-SQL Server 7
-IIS 5.0
-Cold Fusion Server 4.5 Professional Full Edition
Thanks For Your Time,

NathanIn my first post, I gave the wrong error. The error should read:

ODBC Error Code = S0002 (Base table not found)
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name
'dboLogs'.

Sorry for the inconvenience. -Nate|||Nevermind...I have solved the problem myself. The problem was in the
ODBC DSN configuration. When I setup a SQL Server 7 ODBC DSN, there is
a checkbox "Change the default database to:" with a disabled drop-down
list showing the name of the database that I was trying to connect to.
The way the name is displayed, it looks as though SQL Server is
connecting to this database by default. In reality, I had to checkmark
the box for SQL Server to connect to this database.

I hope this helps the next database professional from wasting as much
time as I (...'d hate to admit that I...) did.