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

Move Log file Expand / Collapse
Author
Message
Posted Monday, July 1, 2013 7:28 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 2:24 AM
Points: 1,926, Visits: 2,356

Hi,

I have data file and log file at different location.

data file at location:
D:\Folder1\test.mdf

while log file at place
D:\folder2\test_log.ldf

Now I want to move this log file to D\folder1\test_log.ldf

How can I achieve this?



_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1469056
Posted Monday, July 1, 2013 7:33 AM


Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Today @ 10:27 AM
Points: 708, Visits: 3,293
If you can afford some downtime then you can detach database, move log file to new location then reattach and point the database to the new location of the log file.

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


It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
David Edwards - Media lens

Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
Howard Zinn
Post #1469058
Posted Monday, July 1, 2013 7:39 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 7:51 AM
Points: 2,404, Visits: 2,941
1. Take the database OFFLINE
2. copy the LOG file to the new location
3. Change the location in the master database with code:
ALTER DATABASE [dbname] MODIFY FILE (NAME = 'logical_name', FILENAME = 'drive_path_filename')
4. bring the database ONLINE (if this doesn't succeed then step 2 has failed)
5. remove the old (original) file (if this file is blocked, then step 3 has failed)


** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **
Post #1469060
Posted Monday, July 1, 2013 7:40 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 2:24 AM
Points: 1,926, Visits: 2,356
kapil_kk (7/1/2013)

Hi,

I have data file and log file at different location.

data file at location:
D:\Folder1\test.mdf

while log file at place
D:\folder2\test_log.ldf

Now I want to move this log file to D\folder1\test_log.ldf

How can I achieve this?


I first detach the databse
EXEC sp_detach_db @dbname = N'dump';

Then move the data and logfile to new path
after I run this script

EXEC sp_attach_db @dbname = N'dump',
@filename1 = N'D:\test\dump.mdf', \
@filename2 = N'D:\test\dump_log.ldf';
GO

But its gives me error:
Unable to open the physical file "D:\test\dump.mdf". Operating system error 5: "5(failed to retrieve text for this error. Reason: 15105)".



_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1469063
Posted Monday, July 1, 2013 7:50 AM


Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Today @ 10:27 AM
Points: 708, Visits: 3,293
Possibly the security settings on the folder?

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


It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
David Edwards - Media lens

Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
Howard Zinn
Post #1469067
Posted Monday, July 1, 2013 7:52 AM


SSC-Forever

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

Group: General Forum Members
Last Login: Yesterday @ 6:05 AM
Points: 40,258, Visits: 36,681
Operating system error 5 is Access Denied. The SQL Server service does not have full rights on that folder.

p.s. sp_attach_db is deprecated and should not be used. Use CREATE DATABASE ... FOR ATTACH.



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 #1469070
Posted Monday, July 1, 2013 7:53 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 2:24 AM
Points: 1,926, Visits: 2,356
GilaMonster (7/1/2013)
Operating system error 5 is Access Denied. The SQL Server service does not have full rights on that folder.

How to grant it ful rights?



_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1469071
Posted Monday, July 1, 2013 7:57 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 2:24 AM
Points: 1,926, Visits: 2,356
HanShi (7/1/2013)
1. Take the database OFFLINE
2. copy the LOG file to the new location
3. Change the location in the master database with code:
ALTER DATABASE [dbname] MODIFY FILE (NAME = 'logical_name', FILENAME = 'drive_path_filename')
4. bring the database ONLINE (if this doesn't succeed then step 2 has failed)
5. remove the old (original) file (if this file is blocked, then step 3 has failed)


i tried these steps but got error at step 4
Operating system error 5: "5(failed to retrieve text for this error. Reason: 15105)".



_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1469072
Posted Monday, July 1, 2013 8:00 AM


Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Today @ 10:27 AM
Points: 708, Visits: 3,293
RIGHT-CLICK folder, click properties then Security tab, click EDIT then give the SQL Server Service account Full control of the folder.

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


It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
David Edwards - Media lens

Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
Howard Zinn
Post #1469073
Posted Monday, July 1, 2013 8:10 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 2:24 AM
Points: 1,926, Visits: 2,356
Abu Dina (7/1/2013)
RIGHT-CLICK folder, click properties then Security tab, click EDIT then give the SQL Server Service account Full control of the folder.


ohhh yes, that was permission issue with the folder i have correct that..

thanks for your help :)



_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1469079
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse