1

I 'am trying to import database into sqlserver 2008 using this query

EXEC sp_attach_db @dbname = 'LIQ_DEV_V9',  
@filename1='/home/elsayedawd/DATA/databasedumbs/database9/LIQ_DEV_V9.mdf',  
@filename2='/home/elsayedawd/DATA/databasedumbs/database9/LIQ_DEV_V9_log.LDF';

but it failed with

Error: The header for file '/home/elsayedawd/DATA/data-base-dumbs/database-9/LIQ_DEV_V9_log.LDF' is not a valid database file header. The PageAudit property is incorrect. SQLState: S00015 ErrorCode: 5172

2
  • ,There could be two possibility the log file or data file is damaged or you are attching a higer version database to a lower version server. Commented Jun 8, 2017 at 10:57
  • Ok , is it possible to import without log file?
    – Elsayed
    Commented Jun 8, 2017 at 11:00

1 Answer 1

3

Ok , is it possible to import without log file?

Yes, but stop using deprecated procedures like sp_attach_db (see the big warning at the top).

Next, you need to supply paths to SQL Server that make sense. Can you get to /home/ in Windows Explorer? Can you do that when logged in as the SQL Server service account?

CREATE DATABASE LIQ_DEV_V9
  ON 
  (
    name = LIQ_DEV_V9, 
    filename = 'C:\...\LIQ_DEV_V9.mdf'
  )
  FOR ATTACH_REBUILD_LOG;

This might fail if SQL Server attempts to create a new log file in a location where that file already exists; so if the damaged LDF file is in that same folder, you may want to rename it, move it, or delete it.

More importantly, you really shouldn't be relying on mdf/ldf files as backups; please read this post:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.