E drive is the drive you wish to defragment
Put this in a bat file and run a scheuled task pointing the bat file.
defrag.exe -v e: >c:\temp\logfile.txt
To check the status you can look how long, etc in the log file under the Advanced / View Log of the scheduled task menu window.
Monday, October 10, 2011
Monday, October 3, 2011
Spaced Used by a table in a specific database.
Shows you how to get the SQL Server database table size
EXEC SP_SPACEUSED 'TABLE NAME'
Shows you how to get the size of a database
EXEC SP_SPACEUSED
Shows you how to get the all tables size from database
EXEC sp_MSforeachtable @command1="EXEC sp_spaceused '?'"
INSERT INTO #temptable
(tablename,
numberofrows,
reservedsize,
datasize,
indexsize,
unusedsize)
EXEC sp_MSforeachtable @command1="EXEC sp_spaceused '?'"
SELECT *
FROM #temptable
---drop the temporary table
DROP TABLE #temptable
EXEC SP_SPACEUSED 'TABLE NAME'
Shows you how to get the size of a database
EXEC SP_SPACEUSED
Shows you how to get the all tables size from database
EXEC sp_MSforeachtable @command1="EXEC sp_spaceused '?'"
–--create temp table to store the result
CREATE TABLE #temptable
(
tablename VARCHAR(100),
numberofrows VARCHAR(100),
reservedsize VARCHAR(50),
datasize VARCHAR(50),
indexsize VARCHAR(50),
unusedsize VARCHAR(50)
)
---Inserting into temp tableCREATE TABLE #temptable
(
tablename VARCHAR(100),
numberofrows VARCHAR(100),
reservedsize VARCHAR(50),
datasize VARCHAR(50),
indexsize VARCHAR(50),
unusedsize VARCHAR(50)
)
INSERT INTO #temptable
(tablename,
numberofrows,
reservedsize,
datasize,
indexsize,
unusedsize)
EXEC sp_MSforeachtable @command1="EXEC sp_spaceused '?'"
SELECT *
FROM #temptable
---drop the temporary table
DROP TABLE #temptable
Subscribe to:
Posts (Atom)