April 26, 2012 at 10:04 am
SQL Server 2008 log file named changed
--------------------------------------------------------------------------------
Hi all,
Some how the log file name on one of my databases changed from dbname_log.ldf to dbname_1.LDF Can anyone explain why this happened? Just learning so need to know how to change it back to dbname_log.ldf. Can I just drop the database, rename the file,and then Attach the database with the renamed log file? Or is there something else I will need to do?
Bill
April 26, 2012 at 10:25 am
The _1 is typically default. Just curious... Why is it important for you to rename it?
Jared
CE - Microsoft
April 26, 2012 at 12:50 pm
When I try to execute the following with a _1 instead of _log it would not execute. So if I want to change it to _log, what do I need to do so I do not screw anything up?
April 26, 2012 at 12:51 pm
When you try to execute what?
The physical name of a log file is irrelevant, it can be anything you like.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 26, 2012 at 12:52 pm
What are you executing? What is the exact error you are getting?
Jared
CE - Microsoft
April 27, 2012 at 1:15 am
think your getting confused with the log file name and the physical log file name
April 27, 2012 at 4:52 am
wmlbill (4/26/2012)
SQL Server 2008 log file named changed--------------------------------------------------------------------------------
Hi all,
Some how the log file name on one of my databases changed from dbname_log.ldf to dbname_1.LDF Can anyone explain why this happened? Just learning so need to know how to change it back to dbname_log.ldf. Can I just drop the database, rename the file,and then Attach the database with the renamed log file? Or is there something else I will need to do?
Bill
sounds like the database has been restored.
If you realllllllllllly want to change the name do the following;
change the file name and path using the following;
ALTER DATABASE [yourdb] MODIFY FILE
(name=logical name, filename=N'drive:\path\dbname_log.ldf')
You can get the logical name and current file location from sys.master_files
take the database offline using
ALTER DATABASE [yourdb] SET OFFLINE
rename the physical OS file from dbname_1.LDF to dbname_log.ldf
bring the database back online using;
ALTER DATABASE [yourdb] SET ONLINE
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs"
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy