Solved

importing MSSQL database into new installation

Posted on 1998-05-29
10
335 Views
Last Modified: 2008-02-01
I had to reinstall SQL Server due to a HD crash.
I have a backup of my database and log on a different drive. Unfortunately I didn't back up the Master database
Is there a way to import my old database into the new installation?

Help appreciated

Ion
0
Comment
Question by:iamari
10 Comments
 
LVL 9

Expert Comment

by:cymbolic
ID: 1091376
I'ts nice to have a current master database, but you shouldn't need one to restore your database.  In case of media failure, It's recommended that you drop your existing database and recreate the database and device files before restoring anyway. Without a current master, if you recreate your database and devices using enterprise manager, then you should be able to restore to the recreated database.  Just make sure the database and devices you create are as big or bigger than the one you dumped.

It's always good practice to document your database and device settings as you create them, just so you know the specifics when the hard drive hits the fan!   But it's worth a try to recreate from memory or overshoot just to get your data back.
0
 
LVL 9

Expert Comment

by:cymbolic
ID: 1091377
It's a good practice to backup the master database every time a database is created, modified (size change) or devices are added, etc.  Even so, we keep a separate text file that documents each device and states what database is allocated to it, etc, in a text file for potential use, just in case.
0
 
LVL 2

Author Comment

by:iamari
ID: 1091378
I've recreated the devices and database (without defining tables). How do I restore now the old one?
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 2

Expert Comment

by:threshold
ID: 1091379
To rebuild same database on other host/database, there is two ways:

1. Build a new empty database as target,
    use Enterprise Manager,
    and right-click the source database ,
    then transfer it to target.

2. Build a new empty database as target, it has the same size as source database
    backup the source database into disk backup device,
    and find the .dat file in ...Mssql/Backup/
    copy the .dat file to target host
    then restore the target database by the file.
    finally, change the size of target database , if you need.
   

0
 
LVL 2

Author Comment

by:iamari
ID: 1091380
I'm afraid I still don't understand.
In Enterprise Manager, I can't see the source database, since it no longer belongs to a server. So when I go to Tools/Database/Object_Transfer it prompts me for a server name for the source. But there is no server name, just two files named MyData.DAT and MyLog.DAT
If I could simply import the two files into the new devices, I would be all set. But I couldn't find a way to do this

Regards,

Ion
0
 
LVL 2

Author Comment

by:iamari
ID: 1091381
I've recreated the two devices and the database. Then I've stopped the MSSql service and copied the old files over the newly created ones. Now I see the database but is grayed out and marked "suspect". When I try to open it says "The database is marked inaccessible and cannot be edited.

Any more help appreciated

Ion
0
 
LVL 2

Author Comment

by:iamari
ID: 1091382
Let's start over. I had a crash that deleted everything except the database files, MyData.DAT and MyLog.DAT
I've reinstalled SQL Server and I'm trying to recreate my database using the two files I have left. It looks like there is no direct way to import my old files into the new installation.

I've created two new devices, same name and size as the original ones. I've created a new database, with Data and Log on the two new devices. I've created a backup device for the new database and use it to backup Data and Log. After this, I delete the new database in order to use the backup device to restore it. (If I don't do this, the database will be marked as "suspect" and prevent me from restoring)

Now I close SQL Server, close SQL Services and manually copy my old files over the new ones.
I reopen the services and reopen the Enterprise Manager. The way I figure it, if I create now a new database For Load, I should be able to use the old file for restore. But what happens, even though I recreate it for Load (using the same Data and Log devices) it REWRITES the two (old) files with new, useless information. So when I use the backup device, I get nothing but a generic database.

I'm beginning to think it's imposible to do this type of restore, but this would be insane!

Please help!

Ion
0
 
LVL 2

Accepted Solution

by:
Ezhil earned 250 total points
ID: 1091383
What threshold says is correct , but follow the steps
1. Creata DB device and LOG device with same size as the old one.
2. Create a DB .
3. Create logins , users , groups if any.
5. Stop SQL Server.
4. Now copy the old DB & LOG files into the new one.
5. STOP & START Your SQL Server
0
 
LVL 2

Author Comment

by:iamari
ID: 1091384
Well, that's exactly whta I did the first time. But when I do this, the database is marked as "suspect" and cannot be edited.
Any other ideas?
0
 
LVL 2

Author Comment

by:iamari
ID: 1091385
I found a bit of code that gets rid of the "suspect" mark. It goes like:
use master
go
sp_configure "allow updates", 1
reconfigure with override
go
update sysdatabases
set status = status - 256
where name = "MyDatabase"
and status & 256 = 256
go
sp_configure "allow updates", 0
reconfigure
go

I get rid of "suspect" but instead, I get "recovering", so the database is still inaccessible. Perhaps this IS insane!

Ion
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Slow Connectivity over ODBC 8 38
Sql server function help 15 31
Whats wrong in this query - Select * from tableA,tableA 11 32
Sql Query 6 68
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

822 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question