Showing posts with label mistakenly. Show all posts
Showing posts with label mistakenly. Show all posts

Sunday, February 19, 2012

error attaching single db .mdf file

Hi,
The dev deleted some of the ldf files mistakenly and are unable to attach the mdf file.
How can i re-create the db with the existing mdf file and a new ldf file. Can someone suggest.
Thanks,
Arzan
http://www.sqlservercentral.com/scri...p?scriptid=599
Restoring a .mdf
Andrew J. Kelly SQL MVP
"Arzan" <Arzan@.discussions.microsoft.com> wrote in message
news:8A81A4E5-F699-4552-A0C0-8310527A7EA5@.microsoft.com...
> Hi,
> The dev deleted some of the ldf files mistakenly and are unable to attach
the mdf file.
> How can i re-create the db with the existing mdf file and a new ldf file.
Can someone suggest.
> Thanks,
> Arzan
|||Hi,
Try using the procedure "sp_attach_single_file_db" to attach the database
with specifying the MDF file only.
EXEC sp_attach_single_file_db 'dbname', 'c:\mssql\data\dbname.mdf'
THis will create a new database with exiting mdf and new ldf file.
This command will fail in below scenarios:-
1. If the database is not detached using sp_detach_db
2. If you have multiple LDF files in your old database.
If your sp_attach_single_file_db command fails then probaly you have to
restore the database from good backup available.
Thanks
Hari
MCDBA
"Arzan" <Arzan@.discussions.microsoft.com> wrote in message
news:8A81A4E5-F699-4552-A0C0-8310527A7EA5@.microsoft.com...
> Hi,
> The dev deleted some of the ldf files mistakenly and are unable to attach
the mdf file.
> How can i re-create the db with the existing mdf file and a new ldf file.
Can someone suggest.
> Thanks,
> Arzan
|||Thanks Hari, the problem has been resolved.
"Hari Prasad" wrote:

> Hi,
> Try using the procedure "sp_attach_single_file_db" to attach the database
> with specifying the MDF file only.
> EXEC sp_attach_single_file_db 'dbname', 'c:\mssql\data\dbname.mdf'
> THis will create a new database with exiting mdf and new ldf file.
> This command will fail in below scenarios:-
> 1. If the database is not detached using sp_detach_db
> 2. If you have multiple LDF files in your old database.
> If your sp_attach_single_file_db command fails then probaly you have to
> restore the database from good backup available.
> Thanks
> Hari
> MCDBA
>
> "Arzan" <Arzan@.discussions.microsoft.com> wrote in message
> news:8A81A4E5-F699-4552-A0C0-8310527A7EA5@.microsoft.com...
> the mdf file.
> Can someone suggest.
>
>

Friday, February 17, 2012

error attaching single db .mdf file

Hi,
The dev deleted some of the ldf files mistakenly and are unable to attach th
e mdf file.
How can i re-create the db with the existing mdf file and a new ldf file. Ca
n someone suggest.
Thanks,
Arzanhttp://www.sqlservercentral.com/scr...sp?scriptid=599
Restoring a .mdf
Andrew J. Kelly SQL MVP
"Arzan" <Arzan@.discussions.microsoft.com> wrote in message
news:8A81A4E5-F699-4552-A0C0-8310527A7EA5@.microsoft.com...
> Hi,
> The dev deleted some of the ldf files mistakenly and are unable to attach
the mdf file.
> How can i re-create the db with the existing mdf file and a new ldf file.
Can someone suggest.
> Thanks,
> Arzan|||Hi,
Try using the procedure "sp_attach_single_file_db" to attach the database
with specifying the MDF file only.
EXEC sp_attach_single_file_db 'dbname', 'c:\mssql\data\dbname.mdf'
THis will create a new database with exiting mdf and new ldf file.
This command will fail in below scenarios:-
1. If the database is not detached using sp_detach_db
2. If you have multiple LDF files in your old database.
If your sp_attach_single_file_db command fails then probaly you have to
restore the database from good backup available.
Thanks
Hari
MCDBA
"Arzan" <Arzan@.discussions.microsoft.com> wrote in message
news:8A81A4E5-F699-4552-A0C0-8310527A7EA5@.microsoft.com...
> Hi,
> The dev deleted some of the ldf files mistakenly and are unable to attach
the mdf file.
> How can i re-create the db with the existing mdf file and a new ldf file.
Can someone suggest.
> Thanks,
> Arzan|||Thanks Hari, the problem has been resolved.
"Hari Prasad" wrote:

> Hi,
> Try using the procedure "sp_attach_single_file_db" to attach the database
> with specifying the MDF file only.
> EXEC sp_attach_single_file_db 'dbname', 'c:\mssql\data\dbname.mdf'
> THis will create a new database with exiting mdf and new ldf file.
> This command will fail in below scenarios:-
> 1. If the database is not detached using sp_detach_db
> 2. If you have multiple LDF files in your old database.
> If your sp_attach_single_file_db command fails then probaly you have to
> restore the database from good backup available.
> Thanks
> Hari
> MCDBA
>
> "Arzan" <Arzan@.discussions.microsoft.com> wrote in message
> news:8A81A4E5-F699-4552-A0C0-8310527A7EA5@.microsoft.com...
> the mdf file.
> Can someone suggest.
>
>

error attaching single db .mdf file

Hi,
The dev deleted some of the ldf files mistakenly and are unable to attach the mdf file.
How can i re-create the db with the existing mdf file and a new ldf file. Can someone suggest.
Thanks,
Arzanhttp://www.sqlservercentral.com/scripts/scriptdetails.asp?scriptid=599
Restoring a .mdf
--
Andrew J. Kelly SQL MVP
"Arzan" <Arzan@.discussions.microsoft.com> wrote in message
news:8A81A4E5-F699-4552-A0C0-8310527A7EA5@.microsoft.com...
> Hi,
> The dev deleted some of the ldf files mistakenly and are unable to attach
the mdf file.
> How can i re-create the db with the existing mdf file and a new ldf file.
Can someone suggest.
> Thanks,
> Arzan|||Hi,
Try using the procedure "sp_attach_single_file_db" to attach the database
with specifying the MDF file only.
EXEC sp_attach_single_file_db 'dbname', 'c:\mssql\data\dbname.mdf'
THis will create a new database with exiting mdf and new ldf file.
This command will fail in below scenarios:-
1. If the database is not detached using sp_detach_db
2. If you have multiple LDF files in your old database.
If your sp_attach_single_file_db command fails then probaly you have to
restore the database from good backup available.
Thanks
Hari
MCDBA
"Arzan" <Arzan@.discussions.microsoft.com> wrote in message
news:8A81A4E5-F699-4552-A0C0-8310527A7EA5@.microsoft.com...
> Hi,
> The dev deleted some of the ldf files mistakenly and are unable to attach
the mdf file.
> How can i re-create the db with the existing mdf file and a new ldf file.
Can someone suggest.
> Thanks,
> Arzan