Sunday, March 11, 2012

Error 5171 when attaching database

I am having an issue attaching a database. I am getting Error 5171 - ls is
not a primary database file.
We did not have a backup of a database, so I am not able to restore a
backup. The reason we do not have a backup of the database is a long story.
Anyways, somehow the SQL Server installation got corrupted and I was not able
to take a backup of the database. I had the mdf and ldf files. Once I
unsinstalled and installed SQL Server 2000 SP4, I was able to restore all
databases from a backup except for one, the one that did not have a backup.
But I had the mdf and ldf files. When I tried to attach the database, I got
the error above. Any help in this matter will be greatly appreciated.
Thanks,
BillA full backup would be very helpful, but anyway, take a look here:
http://www.sqlservercentral.com/scripts/scriptdetails.asp?scriptid=599
HTH, Jens Suessmeyer.|||>From the BOL:
sp_attach_db should only be executed on databases that were previously
detached from the database server using an explicit sp_detach_db
operation. If more than 16 files must be specified, use CREATE DATABASE
with the FOR ATTACH clause.
The database attached must have been created using the same code page
and sort order as SQL Server.
So check your collation on the server and if it is different than the
database (hopefully you have documented somewhere), find a SQL Server
that is on the same code page and attach there, change the collation of
the database, then detach and re-attach to the intended server.
Hope it will help.
Mel|||Thank you guys for your help. I tried a few things and it did not work. If
one problem was fixed then another was created. Anyways, the users have said
they do not need that database and they will probably recreate it if needed.
Bill
"MSLam" wrote:
> >From the BOL:
> sp_attach_db should only be executed on databases that were previously
> detached from the database server using an explicit sp_detach_db
> operation. If more than 16 files must be specified, use CREATE DATABASE
> with the FOR ATTACH clause.
> The database attached must have been created using the same code page
> and sort order as SQL Server.
> So check your collation on the server and if it is different than the
> database (hopefully you have documented somewhere), find a SQL Server
> that is on the same code page and attach there, change the collation of
> the database, then detach and re-attach to the intended server.
> Hope it will help.
> Mel
>

No comments:

Post a Comment