SQL Server version from MDF

  • Is there a command to get the sql server version from which the give mdf file is deached.

    That is -

    Before attaching a SQL Server 2005 database (mdf+ldf files) to a SQL Server 2000 instance can we perform a test to make sure this is a SQL 2000 database.

    If you try to attach a SQL Server 2005 database (mdf+ldf files) to a SQL Server 2000 instance, error 602 comes up. -

    "Could not find row in sysindexes for database ID %d, object ID %ld, index ID %d. Run DBCC CHECKTABLE on sysindexes."

    But I want to prevent this to happen in the first place by checking for SQL server version from the mdf file.

     

  • Way back I used the command to read the .mdf file details... I don't remember at this time but if I get it I will post it..

    Meantime you can attach the mdf file to 2000 server and see what is the version.

     

    MohammedU
    Microsoft SQL Server MVP

  • Try this..

    dbcc checkprimaryfile (N'C:\Program Files\Microsoft SQL Server\MSSQL\Data\admin.mdf', 0)

    go

    dbcc checkprimaryfile (N'C:\Program Files\Microsoft SQL Server\MSSQL\Data\admin.mdf', 1)

    go

    dbcc checkprimaryfile (N'C:\Program Files\Microsoft SQL Server\MSSQL\Data\admin.mdf', 2)

    go

    dbcc checkprimaryfile (N'C:\Program Files\Microsoft SQL Server\MSSQL\Data\admin.mdf', 3)

    go

     

    MohammedU
    Microsoft SQL Server MVP

  • Try the RESTORE HEADERONLY command. Look up the syntax in BOL. I'm not sure that will give you what you want, but try it.

    -SQLBill

  • If I am not mistaken...

    RESTORE HEADERONLY for backup files not for mdf/ldf files.

     

    MohammedU
    Microsoft SQL Server MVP

  • You are correct....my mistake. I misread the request.

    -SQLBill

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply