Showing posts with label wrotegt. Show all posts
Showing posts with label wrotegt. Show all posts

Friday, March 23, 2012

Moving .ldf to new drive, doesn't work gives "Cannot associate fil

The procedure you described should work fine. But I suspect your .ldf file is
not really from that database.
Linchi
"caperneus@.gmail.com" wrote:

> I am trying to move a log file to a non-RAID drive. I have detached
> the database and made a copy of the .ldf file. I have taken this copy
> of the .ldf file and placed it where I want it to be. I would like to
> keep the .mdf file where it is located on the RAID drive, but for some
> reason I can only reattach if the .ldf file is in the same location as
> the .mdf file.
> I have then run:
> USE MASTER
> GO
> EXEC sp_attach_db @.dbname = N'Corporate',
> @.filename1 = N'F:\Web\MSSQL$WEB\Data\Corporate_Data.mdf',
> @.filename2 = N'E:\Web\Corporate\Corporate_Log.ldf'
> And it returns:
> Server: Msg 5173, Level 16, State 2, Line 1
> Cannot associate files with different databases.
> Is this possible?
>
Instead of detached and attached try backup and restore ...
BACKUP DATABASE Corporate
TO DISK = 'E:\backup_corporate.bak'
WITH INIT
Drop the database, and delete the mdf and ldf file (or just back it up)
Then the Restore:
RESTORE DATABASE Corporate
FROM DISK = 'E:\backup_corporate.bak'
WITH RECOVERY,
MOVE '[datafilelogicalname]' TO 'F:\Web\MSSQL$WEB\Data\Corporate_Data.mdf',
MOVE '[loglogicalname]' TO 'E:\Web\Corporate\Corporate_Log.ldf'
Hope that works.
Lucas
<caperneus@.gmail.com> wrote in message
news:1181852163.020692.243720@.a26g2000pre.googlegr oups.com...
> On Jun 14, 2:44 pm, Linchi Shea <LinchiS...@.discussions.microsoft.com>
> wrote:
> It is really from that database. I can attach it back with no problems
> if the files are in the same directory.
>

Saturday, February 25, 2012

Move database to another partition

25degc wrote:
> I have recently installed SQL Server 2005 Standard Edition on a server wit
h 2
> partitions. I then installed Sharepoint which installed a database and put
it
> in the default location on the c: partition. I would like to move this to
d:.
> I have tried to do this by detaching and attaching, and also by backing an
d
> restoring, but both the attach and the backup dialog boxes only allow me t
o
> browse the c: drive. Is this a feature of Standard Edition? Do I need to u
se
> Enterprise? Or is there a configuration setting I can change somewhere?
> TIA
Not sure why you can't browse your other drive, but a workaround would
be to not use the GUI to do this. Instead use the SQL commands to
detach/reattach the database:
EXEC sp_detach_db DBname, 'true'
Copy the files from C: to D:
EXEC sp_attach_db @.dbname = 'DBName', @.filename1 = 'D:\MDFFile',
@.filename2 = 'D:\LDFFile'I have recently installed SQL Server 2005 Standard Edition on a server with
2
partitions. I then installed Sharepoint which installed a database and put i
t
in the default location on the c: partition. I would like to move this to d:
.
I have tried to do this by detaching and attaching, and also by backing and
restoring, but both the attach and the backup dialog boxes only allow me to
browse the c: drive. Is this a feature of Standard Edition? Do I need to use
Enterprise? Or is there a configuration setting I can change somewhere?
TIA|||25degc wrote:
> I have recently installed SQL Server 2005 Standard Edition on a server wit
h 2
> partitions. I then installed Sharepoint which installed a database and put
it
> in the default location on the c: partition. I would like to move this to
d:.
> I have tried to do this by detaching and attaching, and also by backing an
d
> restoring, but both the attach and the backup dialog boxes only allow me t
o
> browse the c: drive. Is this a feature of Standard Edition? Do I need to u
se
> Enterprise? Or is there a configuration setting I can change somewhere?
> TIA
Not sure why you can't browse your other drive, but a workaround would
be to not use the GUI to do this. Instead use the SQL commands to
detach/reattach the database:
EXEC sp_detach_db DBname, 'true'
Copy the files from C: to D:
EXEC sp_attach_db @.dbname = 'DBName', @.filename1 = 'D:\MDFFile',
@.filename2 = 'D:\LDFFile'|||Thanks. This highlighted an issue with the d: drive. Although
readable/writable through Windows I decided to reformat, and now it is
working fine.
Thanks for your help.
"Tracy McKibben" wrote:

> 25degc wrote:
> Not sure why you can't browse your other drive, but a workaround would
> be to not use the GUI to do this. Instead use the SQL commands to
> detach/reattach the database:
> EXEC sp_detach_db DBname, 'true'
> Copy the files from C: to D:
> EXEC sp_attach_db @.dbname = 'DBName', @.filename1 = 'D:\MDFFile',
> @.filename2 = 'D:\LDFFile'
>|||Thanks. This highlighted an issue with the d: drive. Although
readable/writable through Windows I decided to reformat, and now it is
working fine.
Thanks for your help.
"Tracy McKibben" wrote:

> 25degc wrote:
> Not sure why you can't browse your other drive, but a workaround would
> be to not use the GUI to do this. Instead use the SQL commands to
> detach/reattach the database:
> EXEC sp_detach_db DBname, 'true'
> Copy the files from C: to D:
> EXEC sp_attach_db @.dbname = 'DBName', @.filename1 = 'D:\MDFFile',
> @.filename2 = 'D:\LDFFile'
>