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»»

Attach database file failed Expand / Collapse
Author
Message
Posted Thursday, January 17, 2013 2:49 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 9:03 AM
Points: 2,415, Visits: 3,374
Hi Experts,

I tried moving one of our user DB using
1.mode database offline..moved files run alter database modify files and made database online..it didnt took old .ldf file instead created a new file in old path.
2.detach\attach method. It threw error and failed to attach. then successfully added the file using sp_attach_single_file_db but the problem is my old 21gb ldf file is not using now.

How can i move the ldf file successfully attach the old ldf file
Post #1408249
Posted Thursday, January 17, 2013 3:04 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 5:49 PM
Points: 37,671, Visits: 29,925
If you attached just the data file and had SQL rebuild the log, that old log file is now useless.


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 #1408256
Posted Thursday, January 17, 2013 3:08 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 9:47 AM
Points: 5,201, Visits: 11,151
Ratheesh.K.Nair (1/17/2013)
Hi Experts,

I tried moving one of our user DB using
1.mode database offline..moved files run alter database modify files and made database online..it didnt took old .ldf file instead created a new file in old path.

Oh dear, you too have fallen fowl of moving database files under SQL Server. Keep an eye out for my SSC article coming soon on how to carry out this process successfully


-----------------------------------------------------------------------------------------------------------

"Ya can't make an omelette without breaking just a few eggs"
Post #1408258
Posted Thursday, January 17, 2013 3:11 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 9:03 AM
Points: 2,415, Visits: 3,374
Thanks Gail and Perry.

What i have to do now?? I followed http://msdn.microsoft.com/en-us/library/ms345483(v=sql.105).aspx this article which caused all this issues.. How can i move the .ldf file now to another drive??
Post #1408261
Posted Thursday, January 17, 2013 3:19 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 5:49 PM
Points: 37,671, Visits: 29,925
If the DB was brought online and a new log file created, the old one is completely useless and cannot be used.

Correct your alter database statements (I guess you didn't specify move for the log file), take the DB offline, move the new log file there (the old one will be useless) and bring the DB online.



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 #1408270
Posted Thursday, January 17, 2013 3:22 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 9:03 AM
Points: 2,415, Visits: 3,374
Thanks Gail,

i used the command

ALTER DATABASE ABC MODIFY FILE ( NAME = ABC_log FILENAME = 'H:\Log\SQL8\ABC_log' )
Post #1408274
Posted Thursday, January 17, 2013 3:24 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 9:47 AM
Points: 5,201, Visits: 11,151
Well, if you really can't wait for my guide to be published perform the following;

  • get details of the current paths\filenames using this query
    select name, physical_name from sys.master_files where database_id = DB_ID('yourDB')


  • For each file you wish to move build a MODIFY FILE command. For the log file for instance use
    ALTER DATABASE [yourDB] MODIFY FILE(name=yourDB_Log,
    physical_name = 'new drive:\ new path\ new path\yourdb_data.ldf')


  • issue the ALTER DATABASE statement

  • take the database offline

  • copy the file to the new location

  • bring the database online

  • delete the original file from the original location



-----------------------------------------------------------------------------------------------------------

"Ya can't make an omelette without breaking just a few eggs"
Post #1408276
Posted Thursday, January 17, 2013 3:27 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 9:03 AM
Points: 2,415, Visits: 3,374
Thanks Perry,

So first we have to run the ALTER database MODIFY FILE and then only we have to take database offline right?
Post #1408279
Posted Thursday, January 17, 2013 3:44 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 9:47 AM
Points: 5,201, Visits: 11,151
That's the order i prefer to do it in. Set the paths and confirm that sql server has updated the system catalogs, you will receive a meesage indicating that the new paths have been accepted and will be used next time the database restarts

-----------------------------------------------------------------------------------------------------------

"Ya can't make an omelette without breaking just a few eggs"
Post #1408293
Posted Thursday, January 17, 2013 4:03 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 9:03 AM
Points: 2,415, Visits: 3,374
Perry Whittle (1/17/2013)
That's the order i prefer to do it in. Set the paths and confirm that sql server has updated the system catalogs, you will receive a meesage indicating that the new paths have been accepted and will be used next time the database restarts


Did everything on that order by failed.


SQL error log is showing this.
FileMgr::StartLogFiles: Operating system error 2(The system cannot find the file specified.)
Post #1408309
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse