|
-
Jun 3rd, 2007, 02:54 AM
#1
Thread Starter
Lively Member
Database Restore
Friends,
Can I restore my SQL Server 2000 database only by data file. Actually my log file is lost.
What can I do now.
Rajib
Please Rate every reply if it is useful to u
-
Jun 3rd, 2007, 08:59 AM
#2
Re: Database Restore
Does this mean you have a .BAK file of the database? That would be a full backup...
Please explain further what you have.
-
Jun 3rd, 2007, 11:23 PM
#3
Thread Starter
Lively Member
Re: Database Restore
Thanks for ur quick response.
I don't have any backup.
I just have the data file that is generated when database is created. And also the log file is damaged.
Is it possible to reload the database only by the data file of the database?
-Rajib
Please Rate every reply if it is useful to u
-
Jun 4th, 2007, 06:16 AM
#4
Re: Database Restore
I believe you can attach the DB without the log in Enterprise Manager - it will create a new and empty log.
Hopefully the damaged log didn't have any unwritten cached data in it.
-
Jun 4th, 2007, 07:22 AM
#5
Re: Database Restore
Actually, you can't from Enterprise Manager....
BUT you CAN from Query analyzer..... first delete the log file. Make sure it is NOT the data file.
Then from Query Analyzer, connect to the server.... and issue this command:
sp_attach_single_file_db 'dbname' , 'physical_name'
Here's the entry from BOL
 Originally Posted by SQL Books Online
Syntax
sp_attach_single_file_db [ @dbname = ] 'dbname'
, [ @physname = ] 'physical_name'
Arguments
[@dbname =] 'dbname'
Is the name of the database to be attached to the server. dbname is sysname, with a default of NULL.
[@physname =] 'phsyical_name'
Is the physical name, including path, of the database file. physical_name is nvarchar(260), with a default of NULL.
Return Code Values
0 (success) or 1 (failure)
Result Sets
None
Remarks
When sp_attach_single_file_db attaches the database to the server, it builds a new log file and performs additional cleanup work to remove replication from the newly attached database.
Used sp_attach_single_file_db only on databases that were previously detached from the server using an explicit sp_detach_db operation.
Permissions
Only members of the sysadmin and dbcreator fixed server roles can execute this procedure.
Examples
This example detaches pubs and then attaches one file from pubs to the current server.
EXEC sp_detach_db @dbname = 'pubs'
EXEC sp_attach_single_file_db @dbname = 'pubs',
@physname = 'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs.mdf'
You should get a message that state the Log file couldn't be found, so a new one was created. THat's good.
-tg
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|