<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Shrinking NDF and MDF Files &#8211; A Safe Operation</title>
	<atom:link href="http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 17 May 2013 15:26:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Lax</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-433625</link>
		<dc:creator><![CDATA[Lax]]></dc:creator>
		<pubDate>Fri, 08 Mar 2013 01:23:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-433625</guid>
		<description><![CDATA[How to shrink mdf or ndf files on primary server(Dtabase is in mirroring) in sql 2008 r2? Kindly reply me]]></description>
		<content:encoded><![CDATA[<p>How to shrink mdf or ndf files on primary server(Dtabase is in mirroring) in sql 2008 r2? Kindly reply me</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rajasekhar</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-418519</link>
		<dc:creator><![CDATA[rajasekhar]]></dc:creator>
		<pubDate>Wed, 06 Feb 2013 08:59:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-418519</guid>
		<description><![CDATA[How can I shrink Transaction Log file on SQL Server 2012 Always on Instances?  I tried Backup with trunkcate and dbcc shrinkfile(,size). not worked. Please help me to shrink the log file on AON.]]></description>
		<content:encoded><![CDATA[<p>How can I shrink Transaction Log file on SQL Server 2012 Always on Instances?  I tried Backup with trunkcate and dbcc shrinkfile(,size). not worked. Please help me to shrink the log file on AON.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #013 &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-413093</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #013 &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Sat, 26 Jan 2013 01:31:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-413093</guid>
		<description><![CDATA[[...] Shrinking NDF and MDF Files – A Safe Operation First of all &#8211; Shinking database is very bad stuff thing &#8211; it reduces the performance as well does not help much. However, the question is different here. Is Shrinking NDF and MDF files is safe for data? I described the same in the blog post. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Shrinking NDF and MDF Files – A Safe Operation First of all &#8211; Shinking database is very bad stuff thing &#8211; it reduces the performance as well does not help much. However, the question is different here. Is Shrinking NDF and MDF files is safe for data? I described the same in the blog post. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Krish</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-343098</link>
		<dc:creator><![CDATA[Krish]]></dc:creator>
		<pubDate>Wed, 12 Sep 2012 08:34:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-343098</guid>
		<description><![CDATA[Thanks a lot Imran, for Wonderful explanation..]]></description>
		<content:encoded><![CDATA[<p>Thanks a lot Imran, for Wonderful explanation..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: maninder</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-341082</link>
		<dc:creator><![CDATA[maninder]]></dc:creator>
		<pubDate>Wed, 05 Sep 2012 10:27:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-341082</guid>
		<description><![CDATA[how to shrink in parts?]]></description>
		<content:encoded><![CDATA[<p>how to shrink in parts?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vijay Anand Madhuranayagam</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-298094</link>
		<dc:creator><![CDATA[Vijay Anand Madhuranayagam]]></dc:creator>
		<pubDate>Sat, 09 Jun 2012 12:45:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-298094</guid>
		<description><![CDATA[Hi Pinal,

One of our customers DB growth reached to 8 GB. I removed the unwanted column which stored the 5GB of Images in a table. Now I checked the table space by using the command

sp_spaceused

it is reduced normal. But the database size still remains 8 GB not even a KB reduced.

Shall I use the following batch? 
--------------------------Batch starts-------------------
ALTER DATABASE [databasename] SET RECOVERY Simple
WITH NO_WAIT
GO
–shrink the mdf file
DBCC SHRINKFILE (N’name of the MDF file’ , 3000)
GO

ALTER DATABASE [databasename] SET RECOVERY FULL

–rebuild index…
--------------------------Batch ends---------------------

Thanks &amp; regards,
Vijay]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>One of our customers DB growth reached to 8 GB. I removed the unwanted column which stored the 5GB of Images in a table. Now I checked the table space by using the command</p>
<p>sp_spaceused</p>
<p>it is reduced normal. But the database size still remains 8 GB not even a KB reduced.</p>
<p>Shall I use the following batch?<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;Batch starts&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
ALTER DATABASE [databasename] SET RECOVERY Simple<br />
WITH NO_WAIT<br />
GO<br />
–shrink the mdf file<br />
DBCC SHRINKFILE (N’name of the MDF file’ , 3000)<br />
GO</p>
<p>ALTER DATABASE [databasename] SET RECOVERY FULL</p>
<p>–rebuild index…<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;Batch ends&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Thanks &amp; regards,<br />
Vijay</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sushmita</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-289769</link>
		<dc:creator><![CDATA[Sushmita]]></dc:creator>
		<pubDate>Mon, 28 May 2012 06:20:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-289769</guid>
		<description><![CDATA[Hi Imran,

I stumbled upon this article through some clicks while searching for something else. This is amazing explanation! Thanks a lot.

Sushmita]]></description>
		<content:encoded><![CDATA[<p>Hi Imran,</p>
<p>I stumbled upon this article through some clicks while searching for something else. This is amazing explanation! Thanks a lot.</p>
<p>Sushmita</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anil</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-278087</link>
		<dc:creator><![CDATA[Anil]]></dc:creator>
		<pubDate>Sat, 21 Apr 2012 05:46:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-278087</guid>
		<description><![CDATA[Hello Pinal, Is shrinking logfile of tempdb database advisable. I have two tempdb log files each on different drive. Now one of my drive is full and it has other database datafiles. I want to shrink the templog file which is in this drive. And if I shrink the templog will I require disk free space on the drive for shrink operation?
Thanks,
Anil.]]></description>
		<content:encoded><![CDATA[<p>Hello Pinal, Is shrinking logfile of tempdb database advisable. I have two tempdb log files each on different drive. Now one of my drive is full and it has other database datafiles. I want to shrink the templog file which is in this drive. And if I shrink the templog will I require disk free space on the drive for shrink operation?<br />
Thanks,<br />
Anil.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aashish Vaghela</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-262797</link>
		<dc:creator><![CDATA[Aashish Vaghela]]></dc:creator>
		<pubDate>Wed, 14 Mar 2012 05:24:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-262797</guid>
		<description><![CDATA[@Mariyappan .... Here&#039;s what you&#039;ll need to do.

USE 
DBCC SHRINKDATABASE 
DBCC SHRINKFILE 

&#039; For e.g.... D:\MyLargeDBs\MyCustomerDB\Customers.NDF

/* ********** Hope it helps .... !   ********** 

Regards,
Aashish.Vaghela
******************************************** */]]></description>
		<content:encoded><![CDATA[<p>@Mariyappan &#8230;. Here&#8217;s what you&#8217;ll need to do.</p>
<p>USE<br />
DBCC SHRINKDATABASE<br />
DBCC SHRINKFILE </p>
<p>&#8216; For e.g&#8230;. D:\MyLargeDBs\MyCustomerDB\Customers.NDF</p>
<p>/* ********** Hope it helps &#8230;. !   ********** </p>
<p>Regards,<br />
Aashish.Vaghela<br />
******************************************** */</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aashish Vaghela</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-262796</link>
		<dc:creator><![CDATA[Aashish Vaghela]]></dc:creator>
		<pubDate>Wed, 14 Mar 2012 05:18:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-262796</guid>
		<description><![CDATA[Dear TPT,

Here&#039;s what you need to do.
1. Ask your client whether this BAK has been created with SQL 2k, 2k5, or 2k8 ?
2. Try to RESTORE the BAK to the Database using RESTORE wizard in SQL 2k5 or 2k8.

3. I could barely understand from your broken statements, what exactly are you trying to do when u say &quot;When i create .df and .ldf file when i execute to create .mdf and .ldf it is not created these two files.&quot;

4. .LDF is a Transaction file &amp; should be created once the MDF database is created &amp; ATTACHED. Try running a few SELECT queries &amp; you should be in business.

5. Right-click on the DB, after it is ATTACHED &amp; check its&#039; PROPERTIES to see if the SQL DB engine allocated a Transactions file to the DB.

6. Make sure, you have OWNER permission on the DB.

Hope this helps ... !


Regards,
Aashish Vaghela]]></description>
		<content:encoded><![CDATA[<p>Dear TPT,</p>
<p>Here&#8217;s what you need to do.<br />
1. Ask your client whether this BAK has been created with SQL 2k, 2k5, or 2k8 ?<br />
2. Try to RESTORE the BAK to the Database using RESTORE wizard in SQL 2k5 or 2k8.</p>
<p>3. I could barely understand from your broken statements, what exactly are you trying to do when u say &#8220;When i create .df and .ldf file when i execute to create .mdf and .ldf it is not created these two files.&#8221;</p>
<p>4. .LDF is a Transaction file &amp; should be created once the MDF database is created &amp; ATTACHED. Try running a few SELECT queries &amp; you should be in business.</p>
<p>5. Right-click on the DB, after it is ATTACHED &amp; check its&#8217; PROPERTIES to see if the SQL DB engine allocated a Transactions file to the DB.</p>
<p>6. Make sure, you have OWNER permission on the DB.</p>
<p>Hope this helps &#8230; !</p>
<p>Regards,<br />
Aashish Vaghela</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TPT</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-262586</link>
		<dc:creator><![CDATA[TPT]]></dc:creator>
		<pubDate>Tue, 13 Mar 2012 15:53:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-262586</guid>
		<description><![CDATA[Hi ,
Need help urgent.
Actually i  have got one file name as test.bak from my client.I donot that file they develop in sql server 2008 or sql server 2005 or 2000.
When i create .df and .ldf file when i execute to create .mdf and .ldf it is 
not created these two files.
Plz anyboyd help me plz]]></description>
		<content:encoded><![CDATA[<p>Hi ,<br />
Need help urgent.<br />
Actually i  have got one file name as test.bak from my client.I donot that file they develop in sql server 2008 or sql server 2005 or 2000.<br />
When i create .df and .ldf file when i execute to create .mdf and .ldf it is<br />
not created these two files.<br />
Plz anyboyd help me plz</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mariyappan</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-227315</link>
		<dc:creator><![CDATA[Mariyappan]]></dc:creator>
		<pubDate>Wed, 28 Dec 2011 10:10:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-227315</guid>
		<description><![CDATA[My Sql Server 2000 Data base Ndf file have 45 gb.Is it possible to reduce witout risk.]]></description>
		<content:encoded><![CDATA[<p>My Sql Server 2000 Data base Ndf file have 45 gb.Is it possible to reduce witout risk.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Subba</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-213550</link>
		<dc:creator><![CDATA[Subba]]></dc:creator>
		<pubDate>Thu, 08 Dec 2011 17:25:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-213550</guid>
		<description><![CDATA[Thanks Imran for your elaborated explanation on shrinking. Thanks lot]]></description>
		<content:encoded><![CDATA[<p>Thanks Imran for your elaborated explanation on shrinking. Thanks lot</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vikas</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-196833</link>
		<dc:creator><![CDATA[vikas]]></dc:creator>
		<pubDate>Wed, 16 Nov 2011 12:06:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-196833</guid>
		<description><![CDATA[Hi,
Is there any query to find out the initial size of database when it was created?]]></description>
		<content:encoded><![CDATA[<p>Hi,<br />
Is there any query to find out the initial size of database when it was created?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aashish Vaghela</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-148329</link>
		<dc:creator><![CDATA[Aashish Vaghela]]></dc:creator>
		<pubDate>Thu, 14 Jul 2011 19:47:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-148329</guid>
		<description><![CDATA[Kiran,
As long as I understand, the BAK file actually backs up the Database &amp; not individual files. Therefore whether MDF or LDF they are the part of the same DB. Hence I doubt that would be actually possible, unless you can come across some specific utility on the internet which can just extract the MDF &amp; not the LDF out of the BAK file. 

If I were in your position, I would rather restore that BAK file on a medium where there is lot of 
space available.]]></description>
		<content:encoded><![CDATA[<p>Kiran,<br />
As long as I understand, the BAK file actually backs up the Database &amp; not individual files. Therefore whether MDF or LDF they are the part of the same DB. Hence I doubt that would be actually possible, unless you can come across some specific utility on the internet which can just extract the MDF &amp; not the LDF out of the BAK file. </p>
<p>If I were in your position, I would rather restore that BAK file on a medium where there is lot of<br />
space available.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kiran</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-148195</link>
		<dc:creator><![CDATA[kiran]]></dc:creator>
		<pubDate>Thu, 14 Jul 2011 06:52:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-148195</guid>
		<description><![CDATA[Hi,

Is there any possibility of restoring a .bak file without .ldf...I mean to say .bak file containing .mdf and .ldf due to space constraint is it possible to restore only .mdf..]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Is there any possibility of restoring a .bak file without .ldf&#8230;I mean to say .bak file containing .mdf and .ldf due to space constraint is it possible to restore only .mdf..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mangesh</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-137322</link>
		<dc:creator><![CDATA[Mangesh]]></dc:creator>
		<pubDate>Sun, 29 May 2011 05:42:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-137322</guid>
		<description><![CDATA[hi all,

how much .ndf files create in one database?

Regards,
Mangesh]]></description>
		<content:encoded><![CDATA[<p>hi all,</p>
<p>how much .ndf files create in one database?</p>
<p>Regards,<br />
Mangesh</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dba</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-102258</link>
		<dc:creator><![CDATA[dba]]></dc:creator>
		<pubDate>Fri, 26 Nov 2010 07:54:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-102258</guid>
		<description><![CDATA[Hello Pinal dev,

How can we check , wehther the data presnt or not in the files?]]></description>
		<content:encoded><![CDATA[<p>Hello Pinal dev,</p>
<p>How can we check , wehther the data presnt or not in the files?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aashish Vaghela</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-89409</link>
		<dc:creator><![CDATA[Aashish Vaghela]]></dc:creator>
		<pubDate>Sat, 25 Sep 2010 14:38:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-89409</guid>
		<description><![CDATA[Thanks Brutus !

One more thing that I added to your script above was 

DBCC UpdateUsage(MyDBName)           &amp;&amp;  

SP_UpdateStats


However, my 2nd question on July 28th, 12:46am still remains ? Any idea of Automating this process of monitoring &amp; truncating the DB LOG (.ldf) file ... ? Is is possible to set some TRIGGER to monitor the LOG Size &amp; the moment it grows beyond a certain pre-defined limit, it gets truncated &amp; the DB is Shrunk .... ?

See if you can share some insight on to this part ??]]></description>
		<content:encoded><![CDATA[<p>Thanks Brutus !</p>
<p>One more thing that I added to your script above was </p>
<p>DBCC UpdateUsage(MyDBName)           &amp;&amp;  </p>
<p>SP_UpdateStats</p>
<p>However, my 2nd question on July 28th, 12:46am still remains ? Any idea of Automating this process of monitoring &amp; truncating the DB LOG (.ldf) file &#8230; ? Is is possible to set some TRIGGER to monitor the LOG Size &amp; the moment it grows beyond a certain pre-defined limit, it gets truncated &amp; the DB is Shrunk &#8230;. ?</p>
<p>See if you can share some insight on to this part ??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hardtoget410</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-89379</link>
		<dc:creator><![CDATA[hardtoget410]]></dc:creator>
		<pubDate>Sat, 25 Sep 2010 10:09:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-89379</guid>
		<description><![CDATA[Dear All please i want to know how to restore database after it has been overwritten by backing up restore.My case is as follows I have restored my database from old backup by I restored this database by mistake on last data base updated so it overwritten this updated database.so please tell me how to restore my original database before it&#039;s overwritten.]]></description>
		<content:encoded><![CDATA[<p>Dear All please i want to know how to restore database after it has been overwritten by backing up restore.My case is as follows I have restored my database from old backup by I restored this database by mistake on last data base updated so it overwritten this updated database.so please tell me how to restore my original database before it&#8217;s overwritten.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: brutus</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-89090</link>
		<dc:creator><![CDATA[brutus]]></dc:creator>
		<pubDate>Thu, 23 Sep 2010 10:03:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-89090</guid>
		<description><![CDATA[hi guys...as a lot of information exist on the saint internet i summarize this for shrinking the log file:
--first we backup the transaction log 
go
BACKUP LOG [database name] TO 
 DISK = &#039;d:\temp\aa.log&#039; WITH NOFORMAT, NOINIT,  
 NAME = N&#039;databasename-Transaction Log  Backup&#039;, SKIP, NOREWIND, NOUNLOAD,  
 STATS = 10
GO

--find the name for the log file
use database
select  name,physical_name from sys.database_files

--change the recovery model in order to shrink the database...otherwise it will not work...

ALTER DATABASE [databasename] SET RECOVERY Simple
WITH NO_WAIT
GO
--shrink the log file 
DBCC SHRINKFILE (N&#039;name of the log file&#039; , 50)
GO

ALTER DATABASE [databasename] SET RECOVERY FULL 

--rebuild index...

if this operation is done in the evening when nobody works it would be great:)]]></description>
		<content:encoded><![CDATA[<p>hi guys&#8230;as a lot of information exist on the saint internet i summarize this for shrinking the log file:<br />
&#8211;first we backup the transaction log<br />
go<br />
BACKUP LOG [database name] TO<br />
 DISK = &#8216;d:\temp\aa.log&#8217; WITH NOFORMAT, NOINIT,<br />
 NAME = N&#8217;databasename-Transaction Log  Backup&#8217;, SKIP, NOREWIND, NOUNLOAD,<br />
 STATS = 10<br />
GO</p>
<p>&#8211;find the name for the log file<br />
use database<br />
select  name,physical_name from sys.database_files</p>
<p>&#8211;change the recovery model in order to shrink the database&#8230;otherwise it will not work&#8230;</p>
<p>ALTER DATABASE [databasename] SET RECOVERY Simple<br />
WITH NO_WAIT<br />
GO<br />
&#8211;shrink the log file<br />
DBCC SHRINKFILE (N&#8217;name of the log file&#8217; , 50)<br />
GO</p>
<p>ALTER DATABASE [databasename] SET RECOVERY FULL </p>
<p>&#8211;rebuild index&#8230;</p>
<p>if this operation is done in the evening when nobody works it would be great:)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aashish Vaghela</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-81894</link>
		<dc:creator><![CDATA[Aashish Vaghela]]></dc:creator>
		<pubDate>Tue, 27 Jul 2010 19:16:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-81894</guid>
		<description><![CDATA[Hello Pinal,

One more thing, in reference to the request above.
Is there a way we can use OSQL (SQL 2000) or SQLCMD based scripts to accomplish this task of monitoring the LOG file.

I&#039;m planning to create a simple DOS BATch file to perform such a task. If regular DOS BAT file isn&#039;t going to be sufficient, then probably we can think of creating a VBScript file to do the same. What do you say ??

Regards,
Aashish. Vaghela]]></description>
		<content:encoded><![CDATA[<p>Hello Pinal,</p>
<p>One more thing, in reference to the request above.<br />
Is there a way we can use OSQL (SQL 2000) or SQLCMD based scripts to accomplish this task of monitoring the LOG file.</p>
<p>I&#8217;m planning to create a simple DOS BATch file to perform such a task. If regular DOS BAT file isn&#8217;t going to be sufficient, then probably we can think of creating a VBScript file to do the same. What do you say ??</p>
<p>Regards,<br />
Aashish. Vaghela</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aashish Vaghela</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-81890</link>
		<dc:creator><![CDATA[Aashish Vaghela]]></dc:creator>
		<pubDate>Tue, 27 Jul 2010 18:42:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-81890</guid>
		<description><![CDATA[Hello Pinal,

Once again, looks like I&#039;m running into some sorts of trouble
keeping the LDF Log file under check. I was wondering if I can
automate the process by some trigger. This trigger can fire, at a specific time whenever the size of the LOG file exceeds a particular value in MB. Lets say if the size of the LOG file (.LDF) reaches 100MB, it should be auto-truncated.

Can this be achieved...?? I think so. However, I&#039;m not much of a T-SQL Programmer. So, I&#039;d definitely appreciate if I can get help on such a TRIGGER.

Thanks.

Aashish. Vaghela]]></description>
		<content:encoded><![CDATA[<p>Hello Pinal,</p>
<p>Once again, looks like I&#8217;m running into some sorts of trouble<br />
keeping the LDF Log file under check. I was wondering if I can<br />
automate the process by some trigger. This trigger can fire, at a specific time whenever the size of the LOG file exceeds a particular value in MB. Lets say if the size of the LOG file (.LDF) reaches 100MB, it should be auto-truncated.</p>
<p>Can this be achieved&#8230;?? I think so. However, I&#8217;m not much of a T-SQL Programmer. So, I&#8217;d definitely appreciate if I can get help on such a TRIGGER.</p>
<p>Thanks.</p>
<p>Aashish. Vaghela</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hariom vats</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-77238</link>
		<dc:creator><![CDATA[hariom vats]]></dc:creator>
		<pubDate>Tue, 22 Jun 2010 05:30:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-77238</guid>
		<description><![CDATA[sir,

i go through your blog.and i use  


USE DatabaseName
GO
DBCC SHRINKFILE(, 100)
My log file size was 38 gb after this command it is 34 gb.

while it should be 100mb.

do the needfull for further steps]]></description>
		<content:encoded><![CDATA[<p>sir,</p>
<p>i go through your blog.and i use  </p>
<p>USE DatabaseName<br />
GO<br />
DBCC SHRINKFILE(, 100)<br />
My log file size was 38 gb after this command it is 34 gb.</p>
<p>while it should be 100mb.</p>
<p>do the needfull for further steps</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: calin</title>
		<link>http://blog.sqlauthority.com/2009/01/25/sql-server-shrinking-ndf-and-mdf-files-a-safe-operation/#comment-76290</link>
		<dc:creator><![CDATA[calin]]></dc:creator>
		<pubDate>Tue, 15 Jun 2010 07:15:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2118#comment-76290</guid>
		<description><![CDATA[Hello there.

It is more than mdf and ldf. 

First of all, let&#039;s discuss the shrinking of data files (data means mdf and ndf). You will encounter two different methods, that use the same mechanism internally: DBCC SHRINKFILE, DBCC SHRINKDATABASE.
Let me give you and example that actually happened a while ago to a customer: they were scripting a database, so we ended up having a database that was defined as having 100 GB data file (only one data file), but with no data in it. Because the customer wanted to save space, we tried to shrink the database by using DBCC SHRINKDATABASE. It had no effect whatsoever, because you cannot go lower than the initial definition of the database (100 GB in our case). By using DBCCSHRINKFILE we could actually modify the data file to a lower value, so the database size was lowered.

Second of all, for the log files (ldf). A transaction log file has a different structure and behavior compared to a data file. Every now and then, some portion of the transaction log is marked as &quot;not needed anymore&quot;, so it can be overwritten. This is called truncation. It simply tells SQL Server that there is space within transaction log that can be reused. If you need to recover that space and give it back to the OS, you can only do that after the log is truncated (which, in turn, relates to recovery model and whether you have taken a backup or not). 

I do apologize for making it a bit too technical.

best regards,
calin]]></description>
		<content:encoded><![CDATA[<p>Hello there.</p>
<p>It is more than mdf and ldf. </p>
<p>First of all, let&#8217;s discuss the shrinking of data files (data means mdf and ndf). You will encounter two different methods, that use the same mechanism internally: DBCC SHRINKFILE, DBCC SHRINKDATABASE.<br />
Let me give you and example that actually happened a while ago to a customer: they were scripting a database, so we ended up having a database that was defined as having 100 GB data file (only one data file), but with no data in it. Because the customer wanted to save space, we tried to shrink the database by using DBCC SHRINKDATABASE. It had no effect whatsoever, because you cannot go lower than the initial definition of the database (100 GB in our case). By using DBCCSHRINKFILE we could actually modify the data file to a lower value, so the database size was lowered.</p>
<p>Second of all, for the log files (ldf). A transaction log file has a different structure and behavior compared to a data file. Every now and then, some portion of the transaction log is marked as &#8220;not needed anymore&#8221;, so it can be overwritten. This is called truncation. It simply tells SQL Server that there is space within transaction log that can be reused. If you need to recover that space and give it back to the OS, you can only do that after the log is truncated (which, in turn, relates to recovery model and whether you have taken a backup or not). </p>
<p>I do apologize for making it a bit too technical.</p>
<p>best regards,<br />
calin</p>
]]></content:encoded>
	</item>
</channel>
</rss>
