RE: NTFS Defrag

RE: NTFS Defrag

 

  

Assuming that the original poster wants to defrag SQL Server files
(.mdf/.ldf/.ndf), the database must either be closed, or the SQL Server
service must be stopped. You cannot defrag a file if it is open by
another process.

The best method I found for this is to use Sysinternal's Contig utility
to defrag one file at a time. I often just manually close the database
(i.e. Take Offline), run the contig utility at the command prompt, then
re-open (Bring Online) the database. For one client, I did setup a
VBScript to automatically execute that using SQL-DMO, so that they could
schedule the operation once a week. But I do not have that script handy
anymore.

=======================
Mark Harr


> -----Original Message-----
> From: Shrikant S. Patil
> [mailto:mssqldba-ezmlmshield-x52408689.[Email address protected]
> Sent: Monday, May 31, 2004 4:48 AM
> To: LazyDBA.com Discussion
> Subject: RE: NTFS Defrag
>
> SQL Server does not need to be shut down, for the defrag to work as
> defrag involves rearranging the data on the hard disk.
>
>
> Regds,
> Shrikant Patil
> MCDBA
>
> -----Original Message-----
> From: Ryan_Froman
> [mailto:mssqldba-ezmlmshield-x61595478.[Email address protected]
> Sent: Monday, May 31, 2004 1:57 PM
> To: LazyDBA.com Discussion
> Subject: RE: NTFS Defrag
>
>
>
> For the defrag to actually be useful, wouldnt sql server have
> to be shut
> down in which case how are you going to execute the command?
>
> Ryan
> Database Administrator
> Support and Development Services
>
>
>
> |---------+-------------------------------------------------------->
> | | "Shrikant S. Patil " |
> | | <mssqldba-ezmlmshield-x15032482.[Email Address Removed] | | azydba.com> |
> | | |
> | | |
> | | |
> | | 31/05/2004 03:58 PM |
> | | |
> |---------+-------------------------------------------------------->
>
> >-------------------------------------------------------------
> ----------
> ------------------------|
> |
> |
> | To: "LazyDBA.com Discussion" <[Email address
> protected]
> |
> | cc:
> |
> | Subject: RE: NTFS Defrag
> |
>
> >-------------------------------------------------------------
> ----------
> ------------------------|
>
>
>
>
> It is possible to initiate defrag from SQL.
>
> -- to defrag for example drive d
> Exec xp_cmdshell 'defrag d:'
>
> Regds,
> Shrikant Patil
> MCDBA
>
> -----Original Message-----
> From: Jason Volpe
> [mailto:mssqldba-ezmlmshield-x16349430.[Email address protected]
> Sent: Monday, May 31, 2004 6:56 AM
> To: LazyDBA.com Discussion
> Subject: NTFS Defrag
>
> Is there a way that I can initiate an NTFS level defrag from SQL?
>
> Would it be as simple as running it thru xp_cmdshell? If so,
>
> what would the command be?
>
>
>
> Jason Volpe
> Information Systems Management
> intesource Powering Procurement, Advancing Business
> office: 602-445-2291
> mobile: 720-938-0926
>
>
>
>
>
>
> ---------------------------------------------------------------------
> TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
> Website :
> http://www.LazyDBA.com To unsubscribe:
> http://www.lazydba.com/unsubscribe.html
> For additional commands, e-mail: mssqldba-[Email address protected]
>
>
>
> ---------------------------------------------------------------------
> TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
> Website :
> http://www.LazyDBA.com To unsubscribe:
> http://www.lazydba.com/unsubscribe.html
> For additional commands, e-mail: mssqldba-[Email address protected]
>
>
>
>
>
>
>
>
> ______________________________________________________________
> __________
> _______
> Unencrypted electronic mail is not secure and may not be authentic.
> If you have any doubts as to the contents please telephone to confirm.
>
> This electronic transmission is intended only for those to whom it is
> addressed. It may contain information that is confidential, privileged
> or exempt from disclosure by law. Any claim to privilege is
> not waived
> or lost by reason of mistaken transmission of this information.
> If you are not the intended recipient you must not distribute or copy
> this transmission and should please notify the sender. Your costs for
> doing this will be reimbursed by the sender.
> ______________________________________________________________
> __________
> _______
>
>
>
> ---------------------------------------------------------------------
> TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
> Website :
> http://www.LazyDBA.com To unsubscribe:
> http://www.lazydba.com/unsubscribe.html
> For additional commands, e-mail: mssqldba-[Email address protected]
>
>
>
> ---------------------------------------------------------------------
> TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
> Website : http://www.LazyDBA.com
> To unsubscribe: http://www.lazydba.com/unsubscribe.html
> For additional commands, e-mail: mssqldba-[Email address protected]
>
>
>

MS Sql Server LazyDBA home page