Adjuntar archivos mdf sin ldf - sqlserver

Solo disponible en BuenasTareas
  • Páginas : 2 (281 palabras )
  • Descarga(s) : 0
  • Publicado : 19 de julio de 2010
Leer documento completo
Vista previa del texto
SQL SERVER – Attach mdf file without ldf file in Database

Technical Talk:
If the database is shutdown gracefully and there was no abrupt shutdown (power outrages,pulling plugs to machines, machine crashes or any other reasons), it is possible (there’s no guarantee) to attach .mdf file only to the server. Please note that there can bemany more reasons for a database that is not getting attached or restored. In my case, the database had a clean shutdown and there were no complex issues. I was able torecreate a transaction log file and attached the received .mdf file.
There are multiple ways of doing this. I am listing all of them here. Before using any of them, pleaseconsult the Domain Expert in your company or industry. Also, never attempt this on live/production server without the presence of a Disaster Recovery expert.
USE [master]
GO-- Method 1: I use this method
EXEC sp_attach_single_file_db @dbname='TestDb',@physname=N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\TestDb.mdf'
-- Method 2:
(FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\TestDb.mdf')
GOMethod 2: If one or more log files are missing, they are recreated again.
There is one more method which I am demonstrating here but I have not used myself before.According to Book Online, it will work only if there is one log file that is missing. If there are more than one log files involved, all of them are required to undergo the sameprocedure.
-- Method 3:
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\TestDb.mdf')
tracking img