Showing posts with label LDF file. Show all posts
Showing posts with label LDF file. Show all posts

Wednesday, March 4, 2009

How to setup Database from MDF file

Dear Reader,

I was writing a user manual for a client, A part of it is about setting up a database in SQL Server 2008 from .MDF file. Thought let me blog this simultaneously so that it could be useful for surfer who look for a way to setup a database in SQL Server.Necessary measures are taken to protect sensitive information :)

Following are the steps to be done to setup database in SQL Server 2008.

Step #1: Right click on Database, Select Attach…

Step #2: A window with title Attach Databases will be shown to add the database files. Click on Add button.

Step #3: A window with title Local Database files – Computer Name, will be displayed. Browse and select the respective .mdf file for which you need to add the Database.


(Click to view full screen)



















Step #4: The select database file with the .mdf life & the .ldf file will be loaded. Please refer Screen #48. There are two options either we can click OK to finish adding the Database or If you want to reset log file .ldf file, select and remove the second file as shown in screen #48 and click OK to add file Database with log file. When this activity is done the SQL Server automatically creates a .ldf file.

(Click to view full screen)



















Hope it helps...

Cheers :)

Fauzi

Friday, February 13, 2009

SQL Server: How to reduce LDF file size

Hi...

I use SQL Server 2005 in my development server and the Database files (.MDF & .LDF) were in C drive. As we were working on the development the LDF (Transaction log files) increased drastically.
So i thought its times to reduce it or later it might make the system slow or space crunch would be there.

The tried following options to reduce the LDF file:

1. Right click on Database -> Tasks -> Shrink -> Files -> Choose File type : Log > Selected Shrink action : Release unused space & later Reorganize pages, Both did not help as the log was more than 1 GB whihc is not so much because i have seen some people had it more 40 GB when log file was not monitored frequently.

2. Used DBCC shrinkfile some time before, which was also not helpful.

Then found from the forums & did the following which worked:

Steps:
1. Make the database offline.
2. Right click & did 'Detach...' for the respective database.
3. Went to the file system where the LDF file resides and moved to a safer place.
4. Then on databases folder (below the Server icon), did right click & clicked Attach.
5. In Attach database window, selected the database & attached it without LDF file. So that system automatically created a new one which is of very small size :)

Thus the issue was solved. I believe there are other options as well to reduce LDF files,
If you are aware of any other options feel free to write it down :)

[Update: July 12 2009]

Now there seems to be much more easier way to reduce LDF file :)
http://mohammedfauzi.blogspot.com/2009/07/moss-sharepointconfig-ldf-file-grows.html

Thanks
Fauzi