Roger Alcindor
asked on
sp_attach_db problem
I successfully detached a database from the server so that I could dispose of the large log file that had filled up the disk.
I then proceeded to re-attach the database, using the following query in MSSQL Server 7
exec sp_attach_db @dbname = 'Stamps', @filename1 = 'D:\MSSQL7\Data\Stamps_Dat a.MDF'
this gives the following error, how can I re-attach the database ? ( I have double checked the file name and path)
I have also tried the following but get the same error
exec sp_attach_db @dbname = N'Stamps', @filename1 = N'D:\MSSQL7\Data\Stamps_Da ta.MDF'
Server: Msg 945, Level 14, State 2, Line 1
Database 'Stamps' cannot be opened because some of the files could not be activated.
Server: Msg 1813, Level 16, State 2, Line 1
Could not open new database 'Stamps'. CREATE DATABASE is aborted.
I have also posted in SQL 2005 because SQL server 7 is not listed in ee ?
I then proceeded to re-attach the database, using the following query in MSSQL Server 7
exec sp_attach_db @dbname = 'Stamps', @filename1 = 'D:\MSSQL7\Data\Stamps_Dat
this gives the following error, how can I re-attach the database ? ( I have double checked the file name and path)
I have also tried the following but get the same error
exec sp_attach_db @dbname = N'Stamps', @filename1 = N'D:\MSSQL7\Data\Stamps_Da
Server: Msg 945, Level 14, State 2, Line 1
Database 'Stamps' cannot be opened because some of the files could not be activated.
Server: Msg 1813, Level 16, State 2, Line 1
Could not open new database 'Stamps'. CREATE DATABASE is aborted.
I have also posted in SQL 2005 because SQL server 7 is not listed in ee ?
Aside from the fact that this is not the safest way to shrink your log file have you tried using the Enterprise Manager to attach the database?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
aneeshattingal, I get the same error message when I use sp_attach_single_file_db ???
I have re-booted the server but still no luck. Is there any other way that I can restorre the database from the MDF file ?
Thanks,
Roger
Crag, There is no way of attaching a databse with Entrprise manager that ships with SQL server 7
I have re-booted the server but still no luck. Is there any other way that I can restorre the database from the MDF file ?
Thanks,
Roger
Crag, There is no way of attaching a databse with Entrprise manager that ships with SQL server 7
If the ldf file is gone, at this point I think it is a lost cause.
I was never able to get a DB to attach with the MDF alone in SQL 7.
At this point your only real hope is to restore from backup.
For future reference change your database's recovery mode to 'Simple' and it will automatically truncate the transaction log.
I was never able to get a DB to attach with the MDF alone in SQL 7.
At this point your only real hope is to restore from backup.
For future reference change your database's recovery mode to 'Simple' and it will automatically truncate the transaction log.
ASKER
aneeshattingal, I re-attached the database with sp_attach_db and the original log file that I had moved rather than deleted.
I then detached and then did sp_attach_single_file_db and it worked the second time.
Thanks for your prompt help, I can go home now !
Best tegards,
Roger
I then detached and then did sp_attach_single_file_db and it worked the second time.
Thanks for your prompt help, I can go home now !
Best tegards,
Roger