SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Attach a database error 5173


Attach a database error 5173

Author
Message
JC-170735
JC-170735
SSC Rookie
SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)

Group: General Forum Members
Points: 42 Visits: 1

We are trying to attach a database from another server. We are running the same service pak as the other server. The files were detached from the other server. We have both the .mdf and .ldf files, we can verify the files. However, when we try to attach the file we get the following error:

Error 5173: Cannot associate files with different databases.

Does anyone know why we would receive this error message or if we need to set some defaults prior to attaching the database?

Any help would be appreciated.

Thank You!


wz700
wz700
Hall of Fame
Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)

Group: General Forum Members
Points: 3015 Visits: 17

From knowledge base

SQL Server does not allow you to attach a single file of a database that contains multiple files. The attach looks for all files that belong to the database during the attach and if it cannot find the files with the corresponding GUID, it fails the attach. Similarly, if you create a blank database with the same filenames and filegroups as the original database, replace some of the files, and then attempt to let SQL recover the database upon startup, recovery fails as indicated by the errorlog.





Hanlie Steynberg
Hanlie Steynberg
SSC Rookie
SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)

Group: General Forum Members
Points: 39 Visits: 2

Does any one know of a workaround?

Thanks


Martin Mojzisek
Martin Mojzisek
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1275 Visits: 35

Are you sure that you have got all data files from the original db? Are you sure that your .mdf and .ldf files come from the same db? If the latter is not true, you can try attach only mdf file and new log will be created for you by sql server. If a datafile(s) is missing you should get a complete set of files and start again. If it's not possible you can try these steps to salvage your data:

we've got only primary data file, all secondary files and log files are lost
sp_attach_db doesn't work because it looks for all files that originally comprised db
a) backup the file before going any further
b) rename the file to filename_old
c) create new db that has one file of the same physical name and size as our file
(logical name of the file and name of db can be different from original)
d) stop Sql server
e) replace original file for mdf file of newly created db
f) start SQL server
g) in SQL Server logs are messages 'Log file does not match the primary file.',
'Cannot associate files with different databases.' and db is suspect
h) Set database in emergency mode:

sp_configure 'allow updates', 1
reconfigure with override
go
update sysdatabases
set status = 32768
where name = 'db_name'
go
sp_configure 'allow updates', 0
reconfigure with override
go
i) Now Data should by accessible - Export data out of the database using bcp or DTS
j) drop db created in step c


koti Reddy.Gurram
koti Reddy.Gurram
SSC-Enthusiastic
SSC-Enthusiastic (123 reputation)SSC-Enthusiastic (123 reputation)SSC-Enthusiastic (123 reputation)SSC-Enthusiastic (123 reputation)SSC-Enthusiastic (123 reputation)SSC-Enthusiastic (123 reputation)SSC-Enthusiastic (123 reputation)SSC-Enthusiastic (123 reputation)

Group: General Forum Members
Points: 123 Visits: 10

Hi,

This is really a good way of attaching database that contains only MDF file. I have done this.. In this process I have a small doubt i.e; Can we get the storeprocedures and all the functions that we have written?

Thank You

Koti Reddy


ajitanu
ajitanu
SSC-Enthusiastic
SSC-Enthusiastic (142 reputation)SSC-Enthusiastic (142 reputation)SSC-Enthusiastic (142 reputation)SSC-Enthusiastic (142 reputation)SSC-Enthusiastic (142 reputation)SSC-Enthusiastic (142 reputation)SSC-Enthusiastic (142 reputation)SSC-Enthusiastic (142 reputation)

Group: General Forum Members
Points: 142 Visits: 0
sir my database is suspected giving error attatching a database error 5173
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search