Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Error attaching MdxStepByStep.mdf for SQL Server 2008 MDX Step by Step. Expand / Collapse
Author
Message
Posted Sunday, June 17, 2012 12:09 PM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: 2 days ago @ 7:06 AM
Points: 4,196, Visits: 4,268
When I try to attach the MdxStepByStep database I get the following error:

One or more files do not match the primary file of the database. [...] If this is an existing database, the file may be corrupted...

I tried to find another file. It could be that it is the wrong version?

I'm running SQL Server 2008 R2.


For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Post #1317069
Posted Sunday, June 17, 2012 12:27 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 10:05 AM
Points: 42,829, Visits: 35,961
When you attach, explicitly remove the ldf in the dialog (if they didn't provide it). Or use CREATE DATABASE ... FOR ATTACH_REBUILD_LOG


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1317072
Posted Sunday, June 17, 2012 12:36 PM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: 2 days ago @ 7:06 AM
Points: 4,196, Visits: 4,268
Thanks.

I executed the following

but it is trying to attach the log file.

How do I force it to ignore the log file?

CREATE DATABASE MdxStepByStep
ON (FILENAME = 'D:\MSSQL\MdxStepByStep.mdf')
FOR ATTACH;

sg 5173, Level 16, State 1, Line 1
One or more files do not match the primary file of the database. If you are attempting to attach a database, retry the operation with the correct files. If this is an existing database, the file may be corrupted and should be restored from a backup.
Log file 'C:\Microsoft Press\MDX SBS\Setup\SQL Server\MdxStepByStep_log.LDF' does not match the primary file. It may be from a different database or the log may have been rebuilt previously.
Msg 1813, Level 16, State 2, Line 1
Could not open new database 'MdxStepByStep'. CREATE DATABASE is aborted.




When I tried attaching in SSMS and removing the log file I got an error. The Log file does not match the primary file.

Thanks again.


For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Post #1317073
Posted Sunday, June 17, 2012 1:28 PM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: 2 days ago @ 7:06 AM
Points: 4,196, Visits: 4,268
Here is the link to the download.

I used the CD that came with the book.

http://examples.oreilly.com/9780735626188/


For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Post #1317077
Posted Sunday, June 17, 2012 1:29 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 10:05 AM
Points: 42,829, Visits: 35,961
Welsh Corgi (6/17/2012)
Thanks.

I executed the following

but it is trying to attach the log file.

How do I force it to ignore the log file?


GilaMonster (6/17/2012)
Or use CREATE DATABASE ... FOR ATTACH_REBUILD_LOG

and rename the existing log file if it's there

Dialog used to allow removal of the log. No enthusiasm to poke at it tonight



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1317078
Posted Sunday, June 17, 2012 1:42 PM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: 2 days ago @ 7:06 AM
Points: 4,196, Visits: 4,268
I missed the:

FOR ATTACH_REBUILD_LOG;

I tried it and still got the same error.

I not sure how I should go about renaming the log in T-SQL Syntax.

Thanks.



For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Post #1317080
Posted Sunday, June 17, 2012 2:13 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 10:05 AM
Points: 42,829, Visits: 35,961
Welsh Corgi (6/17/2012)
I missed the:

FOR ATTACH_REBUILD_LOG;

I tried it and still got the same error.


The attach just specifies only the mdf? Can't rebuild log if you're specifying the log.

I not sure how I should go about renaming the log in T-SQL Syntax.


Open Explorer, find file, right click-rename.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1317084
Posted Sunday, June 17, 2012 2:26 PM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: 2 days ago @ 7:06 AM
Points: 4,196, Visits: 4,268
I renamed the file and I get an error that the file does not exist.

I have never had so much trouble attaching a Database even when missing the log file.

What happens if you download the file in the link that I provided and try and attach?



For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Post #1317085
Posted Sunday, June 17, 2012 2:51 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 10:05 AM
Points: 42,829, Visits: 35,961
Welsh Corgi (6/17/2012)
I renamed the file and I get an error that the file does not exist.


What, in explorer when you rename the file you get an error?

What happens if you download the file in the link that I provided and try and attach?


Haven't tried.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1317087
Posted Sunday, June 17, 2012 2:59 PM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: 2 days ago @ 7:06 AM
Points: 4,196, Visits: 4,268
GilaMonster (6/17/2012)
Welsh Corgi (6/17/2012)
I renamed the file and I get an error that the file does not exist.


What, in explorer when you rename the file you get an error?

What happens if you download the file in the link that I provided and try and attach?


Haven't tried.


I get the error after renaming the file in Explorer when I attampt to run the script listed above to attach.

If you download the files and attampt to attach you will see what I mean.


For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Post #1317088
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse