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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Attach database after reinstall of SQL 7 1

Status
Not open for further replies.

bradmaunsell

Programmer
May 8, 2001
156
US
As you will soon see, I am new to SQL.

I have a SQL 7 installation on my laptop used for development (with Access 200 front-ends). My SQL installation failed and I could no longer connect to (local) SQL 7. I think the (local) server was OK because I could work on my web page application (non-SQL).

After hours of struggle, I uninstalled and then reinstalled SQL 7. That went OK but now I cannot "see" my custom databases. More specifically, the statndard Northwind etc are OK. However, if I look at my hard SQL directory under DATA, I do see my original SQL data tables and logs.

My question is, how to I get them to show up with the Enterprize Manger.

Thanks,
Brad
Sout Burlington, Vermont
 
You will need to use Query analyzer to reattach the databases. You will need to use the sp_attach_db procedure to attach the databases. The syntax is:
Code:
sp_attach_db @dbname='databasename', 
    @filename1='c:\path\to\file.mdf',
    @filename2='c:\path\to\file2.ndf',
    @filename3='c:\path\to\log\file\ldf'
You can specify from 2 to 16 files.

Unfornitually if I remember correctly with Enterprise Manager for SQL 7 there is no way to attach the databases from within Enterprise Manager.

Denny

--Anything is possible. All it takes is a little research. (Me)

[noevil]
 
Thanks for the quick response Denny.

One more thing.... do I create a new database to place and run this stored proceedure?
 
No, you run this from the master database.

Denny

--Anything is possible. All it takes is a little research. (Me)

[noevil]
 
Hello again Denny

I have tried creating the sp in the master db and don't seem to have the code correct.
This is what I have entered:

CREATE PROCEDURE sp_attach_dbPMS @dbname='PMS',
@filename1='C:\MSSQL7\PMS_Data.mdf',
@filename2='C:\MSSQL7\PMS_Log.ldf'

When I click OK in the SQL sp editor I get the error msg
ERROR 170: 'Line 1: Incorrect syntax near "=".

Sorry to be so dumb

Thanks again
Brad


BTW: PMS is for Policy Management System
 
You don't need to create a procedure, you need to run the procedure.
Code:
exec sp_attach_db @dbname='PMS', 
    @filename1='C:\MSSQL7\PMS_Data.mdf',
    @filename2='C:\MSSQL7\PMS_Log.ldf'

There are no dumb questions. Asking questions is how we all learned what we know today.

Denny

--Anything is possible. All it takes is a little research. (Me)

[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top