Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Missing LDF

Author  Topic 

damicog
Starting Member

3 Posts

Posted - 2008-10-15 : 04:35:51
Hi we are using SQL 2005.

We have a database but no log file. Is anyway to create new log file with out restoring. The last backu-up of the database we have is several months old. I will like to see if i can get the database working before i have to restore

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-10-15 : 04:52:06
sp_attach_single_file_db


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

damicog
Starting Member

3 Posts

Posted - 2008-10-15 : 05:20:04
Can you plese be more specific, i am more used to use the gui interface then the query analiser.
Many thanks
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-10-15 : 06:11:26
Copied from Books Online:

sp_attach_single_file_db works only on databases that have a single log file. When sp_attach_single_file_db attaches the database to the server, it builds a new log file. If the database is read-only, the log file is built in its previous location.

How to use the sp:

EXEC sp_attach_single_file_db @dbname = 'MyDatabaseName',
@physname = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Data\xyz.mdf';


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

damicog
Starting Member

3 Posts

Posted - 2008-10-15 : 07:14:10
Thanks it worked. Very much appreciated
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-10-15 : 07:20:38
Thank you.

Books Online is a powerful friend.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -