Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing old database 1

Status
Not open for further replies.

ITGL72

MIS
Jul 2, 2001
105
US

Today I had a webserver completely die on me. After rebuilding it and
loading up SQL7 I need to find a way to import the old database. I currently
have the two files saved as:

database_log.ldf
database_data.mdf

Can someone point me in the right direction on how to get this database into
the new database? My knowledge of administering a SQL Server after a
disaster is basic at best. Thanks for your assistance.

-George
 
You need to use sp_attach_db. Example:

EXEC sp_attach_db @dbname = N'Database',
@filename1 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\Database_data.mdf',
@filename2 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\Database_log.ldf'

Hope this helps.
 
Do I enter

EXEC sp_attach_db @dbname = N'Database',
@filename1 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\Database_data.mdf',
@filename2 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\Database_log.ldf'


in the query analyzer?
 
Yes. Place your two files in your normal database data area then run the command within Query Analyzer using the data location for the two entries. Should take at most a minute to complete and you will have your database. It is late here, so please let me know if it works or not so I can go to bed.

Hope this helps. (vote if it did!)
 
No problem. Glad to hear it worked.

Have a nice night.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top