<?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; Get a List of Fixed Hard Drive and Free Space on Server</title>
	<atom:link href="http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Sat, 25 May 2013 15:33:52 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Sundra</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-412832</link>
		<dc:creator><![CDATA[Sundra]]></dc:creator>
		<pubDate>Fri, 25 Jan 2013 12:30:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-412832</guid>
		<description><![CDATA[HI Pinal

How do you move databases to a bigger drive SQL2012 High Availabilty]]></description>
		<content:encoded><![CDATA[<p>HI Pinal</p>
<p>How do you move databases to a bigger drive SQL2012 High Availabilty</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: FRED W</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-382822</link>
		<dc:creator><![CDATA[FRED W]]></dc:creator>
		<pubDate>Wed, 28 Nov 2012 20:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-382822</guid>
		<description><![CDATA[I would really like to hear more about your approach as I have the same issue with Mount Points in my environment.]]></description>
		<content:encoded><![CDATA[<p>I would really like to hear more about your approach as I have the same issue with Mount Points in my environment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gaurav</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-361967</link>
		<dc:creator><![CDATA[Gaurav]]></dc:creator>
		<pubDate>Fri, 19 Oct 2012 12:00:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-361967</guid>
		<description><![CDATA[Hi PInal 

I have scenario relating to Tempdb .. in my server(test) i have 50 gb drive and 15 gb is free when i am running my SISS package to extract data from different source my tempdb size is reaching to 14 gb but the moment i stop job and re-start sql server services tempdb comes to 8 mb .. 

I have another server(dev) where c drive is 40 gb and 14 gb is free but there is d drive 700 gb but  i checked tempdb files are still in C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\tempdb.mdf

Now the SISS package take 4 hr to get completed in dev but its taking 3 days in  test can tempdb size increasing is reason for it .. if so how we can fix  it]]></description>
		<content:encoded><![CDATA[<p>Hi PInal </p>
<p>I have scenario relating to Tempdb .. in my server(test) i have 50 gb drive and 15 gb is free when i am running my SISS package to extract data from different source my tempdb size is reaching to 14 gb but the moment i stop job and re-start sql server services tempdb comes to 8 mb .. </p>
<p>I have another server(dev) where c drive is 40 gb and 14 gb is free but there is d drive 700 gb but  i checked tempdb files are still in C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\tempdb.mdf</p>
<p>Now the SISS package take 4 hr to get completed in dev but its taking 3 days in  test can tempdb size increasing is reason for it .. if so how we can fix  it</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-341474</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Thu, 06 Sep 2012 12:31:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-341474</guid>
		<description><![CDATA[Export the result to a temp table and exclude rows like where col not like &#039;your_Drive%&#039;]]></description>
		<content:encoded><![CDATA[<p>Export the result to a temp table and exclude rows like where col not like &#8216;your_Drive%&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mehdi</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-340408</link>
		<dc:creator><![CDATA[Mehdi]]></dc:creator>
		<pubDate>Mon, 03 Sep 2012 05:40:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-340408</guid>
		<description><![CDATA[I am using XP_fixeddrive for space monitoring of all the drives on a db server. But I want to exclude one drive from monitoring..How can I do so using xp_fixedrive? Suggestion would be highly appreciated.]]></description>
		<content:encoded><![CDATA[<p>I am using XP_fixeddrive for space monitoring of all the drives on a db server. But I want to exclude one drive from monitoring..How can I do so using xp_fixedrive? Suggestion would be highly appreciated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sandeep Charaya</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-320870</link>
		<dc:creator><![CDATA[Sandeep Charaya]]></dc:creator>
		<pubDate>Sun, 29 Jul 2012 05:04:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-320870</guid>
		<description><![CDATA[Hi All,

TRY THIS: but this will not give us the infomation about volumes. 

IF OBJECT_ID(&#039;#AvailableDiskSpace&#039;) IS NULL
	BEGIN
		CREATE TABLE dbo.#AvailableDiskSpace
		(	
			PK										INT IDENTITY CONSTRAINT PK_AvailableDiskSpace PRIMARY KEY,
			DriveLetter								CHAR(1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
			VolumeName								VARCHAR(32) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
			PercentFree								AS (CONVERT(DECIMAL(15, 4), AvailableMB) / CONVERT(DECIMAL(15, 4), TotalDiskSpaceMB) * 100),
			AvailableMB								BIGINT NOT NULL,
			TotalDiskSpaceMB						BIGINT NOT NULL,
			DTStamp									DATETIME NOT NULL
		) ON [PRIMARY]

		CREATE NONCLUSTERED INDEX NCndx_DTStamp
		ON dbo.#AvailableDiskSpace (DTStamp)

	END
-- Vars
DECLARE

	@AgeOutDate										DATETIME,		-- To prune the [AvailableDiskSpace] table
	@BATCHDATE										DATETIME,		-- Constant
	@DriveSize										BIGINT,			-- Drive size in bytes
	@DriveLetter									VARCHAR(2),		-- FSO drive letter
	@ErrorMessage									VARCHAR(500),	-- Error message
	@FSO											INT,			-- File System Object
	@AvailableMB									INT,			-- Available space MB
	@NO												BIT,			-- Constant
	@oDrive											INT,			-- FSO drive
	@OLE_AUTOMATION_PROCEDURES						INT,			-- Constant
	@PK												TINYINT,		-- Work-table primary key
	@RawFree										VARCHAR(20),	-- Available space bytes
	@RetVal											INT,			-- Return value
	@SQL											NVARCHAR(255),	-- Dynamic T-SQL
	@TwoToTheTwentieth								INT,			-- Convert bytes to MB
	@ValueInUse										SQL_VARIANT,	-- To test configuration settings
	@VolumeName										VARCHAR(32),	-- FSO volume name
	@YES											BIT				-- Constant


-- Constants
SET @BATCHDATE							= GETDATE()
SET @OLE_AUTOMATION_PROCEDURES			= 16388			-- SELECT configuration_id FROM master.sys.configurations
SET @NO									= 0
SET @TwoToTheTwentieth					= POWER(2, 20)
SET @YES								= 1

-- Create temp tables for disk space info
IF OBJECT_ID(&#039;tempdb.dbo.#Space&#039;) IS NOT NULL DROP TABLE #Space
CREATE TABLE #Space
(
	PK						TINYINT IDENTITY CONSTRAINT Space_PK PRIMARY KEY,
	DriveLetter				VARCHAR(2) NOT NULL,
	VolumeName				VARCHAR(32) NULL,
	DriveSize				BIGINT CONSTRAINT DF_Space_DriveSize DEFAULT(0),
	AvailableMB				BIGINT NOT NULL,
	Processed				BIT CONSTRAINT DF_Space_Processed DEFAULT (0)
)

-- We need OLE automation enabled to succeed.

BEGIN TRY
	-- Enable advanced options
	EXEC sp_configure &#039;show advanced option&#039;, &#039;1&#039;;
	RECONFIGURE;

	-- Ensure OLE Automation enabled
	EXEC sp_configure &#039;OLE Automation Procedures&#039;, @YES;
	RECONFIGURE

	-- Test...
	SELECT @ValueInUse = Value_In_Use
	FROM master.sys.configurations
	WHERE configuration_id = @OLE_AUTOMATION_PROCEDURES

	IF CONVERT(INT, @ValueInUse)  @YES
		BEGIN
			SET @ErrorMessage = CHAR(13) + &#039;Although we attempted to enable the &#039;&#039;OLE Automation Procedures&#039;&#039; server option, this option is still disabled.&#039; + CHAR(13)
				+ &#039;This script depends upon this extended stored procedure&#039;&#039;s availability. Please investigate.&#039;
				+ CHAR(13) + &#039;NOTE: &#039;&#039;OLE Automation Procedures&#039;&#039; execution requires &#039;&#039;CONTROL SERVER&#039;&#039; permission (See SQL Server Books Online for more information).&#039;

			RAISERROR(@ErrorMessage, 16, 1)
		END

END TRY

BEGIN CATCH
	SELECT
		ERROR_NUMBER() AS ErrorNumber
		,ERROR_MESSAGE() AS ErrorMessage
		,ERROR_SEVERITY() AS ErrorSeverity
		,ERROR_STATE() AS ErrorState
		,ERROR_LINE() AS ErrorLine
		,ERROR_PROCEDURE() AS ErrorProcedure

		GOTO Cleanup
END CATCH

-- 1) Remove records older than user-provided number of days

BEGIN TRY

	-- By default, I&#039;d like to keep 2 years of data
	SET @AgeOutDate = DATEADD(dd, (730 * -1), GETDATE())

	DELETE dbo.#AvailableDiskSpace
	WHERE DTStamp &lt; @AgeOutDate
	
END TRY

BEGIN CATCH
	SELECT
		ERROR_NUMBER() AS ErrorNumber
		,ERROR_MESSAGE() AS ErrorMessage
		,ERROR_SEVERITY() AS ErrorSeverity
		,ERROR_STATE() AS ErrorState
		,ERROR_LINE() AS ErrorLine
		,ERROR_PROCEDURE() AS ErrorProcedure

		GOTO Cleanup
END CATCH


-- 2) Get free space on drives

BEGIN TRY
	-- Populate temp table; this system proc gives us space in MB
	INSERT INTO #Space (DriveLetter, AvailableMB)
		EXEC master.dbo.xp_fixeddrives


-- 3) Loop through drives and get various attributes using OLE automation

	WHILE EXISTS (SELECT TOP 1 1 FROM #Space WHERE Processed = @No)
	
		BEGIN
		
			SELECT TOP 1
				@PK				= PK,
				@DriveLetter	= DriveLetter,
				@AvailableMB	= AvailableMB,
				@DriveSize		= DriveSize
			FROM #Space
			WHERE Processed = @No

			BEGIN TRY
				EXEC master.dbo.sp_OACreate &#039;Scripting.FileSystemObject&#039;, @FSO OUT
			END TRY
			
			BEGIN CATCH
				SELECT
					ERROR_NUMBER() AS ErrorNumber
					,ERROR_MESSAGE() AS ErrorMessage
					,ERROR_SEVERITY() AS ErrorSeverity
					,ERROR_STATE() AS ErrorState
					,ERROR_LINE() AS ErrorLine
					,ERROR_PROCEDURE() AS ErrorProcedure

					GOTO Cleanup
			END CATCH			

			BEGIN TRY

				-- Get disk info
				SET @DriveLetter = @DriveLetter + &#039;:\&#039;
				EXEC master.dbo.sp_OAMethod @FSO,			&#039;GetDrive&#039;,			@oDrive OUT, @DriveLetter
				EXEC master.dbo.sp_OAMethod @oDrive,		&#039;TotalSize&#039;,		@DriveSize OUT
				EXEC master.dbo.sp_OAMethod @oDrive,		&#039;AvailableSpace&#039;,	@RawFree OUT
				EXEC master.dbo.sp_OAGetProperty @oDrive,	&#039;VolumeName&#039;,		@VolumeName OUT			

			END TRY
			
			BEGIN CATCH
				SELECT
					ERROR_NUMBER() AS ErrorNumber
					,ERROR_MESSAGE() AS ErrorMessage
					,ERROR_SEVERITY() AS ErrorSeverity
					,ERROR_STATE() AS ErrorState
					,ERROR_LINE() AS ErrorLine
					,ERROR_PROCEDURE() AS ErrorProcedure

					GOTO Cleanup
			END CATCH			

			BEGIN TRY
				-- Update table
				UPDATE #Space
				SET
					VolumeName =
						CASE LOWER(@DriveLetter)
							WHEN &#039;c:&#039; THEN &#039;System&#039;
							ELSE @VolumeName
						END,
					-- Convert bytes to megabytes
					DriveSize		= CONVERT(BIGINT, @DriveSize) / @TwoToTheTwentieth,
					-- Convert bytes to megabytes
					AvailableMB		= CONVERT(BIGINT, @RawFree) / @TwoToTheTwentieth
				WHERE PK = @PK;

			END TRY

			BEGIN CATCH
				SELECT
					ERROR_NUMBER() AS ErrorNumber
					,ERROR_MESSAGE() AS ErrorMessage
					,ERROR_SEVERITY() AS ErrorSeverity
					,ERROR_STATE() AS ErrorState
					,ERROR_LINE() AS ErrorLine
					,ERROR_PROCEDURE() AS ErrorProcedure

					GOTO Cleanup
			END CATCH			

			BEGIN TRY

				-- Destroy oDrive
				EXEC master.dbo.sp_OADestroy @oDrive
		
			END TRY

			BEGIN CATCH
				SELECT
					ERROR_NUMBER() AS ErrorNumber
					,ERROR_MESSAGE() AS ErrorMessage
					,ERROR_SEVERITY() AS ErrorSeverity
					,ERROR_STATE() AS ErrorState
					,ERROR_LINE() AS ErrorLine
					,ERROR_PROCEDURE() AS ErrorProcedure

					GOTO Cleanup
			END CATCH			

			UPDATE #Space
			SET Processed = @YES
			WHERE PK = @PK

		END

	BEGIN TRY
	
		-- Destroy FSO
		EXEC master.dbo.sp_OADestroy @FSO
	
	END TRY

	BEGIN CATCH
		SELECT
			ERROR_NUMBER() AS ErrorNumber
			,ERROR_MESSAGE() AS ErrorMessage
			,ERROR_SEVERITY() AS ErrorSeverity
			,ERROR_STATE() AS ErrorState
			,ERROR_LINE() AS ErrorLine
			,ERROR_PROCEDURE() AS ErrorProcedure

			GOTO Cleanup
	END CATCH

-- 4) Load results in table

	-- Return disk-space info
	INSERT dbo.#AvailableDiskSpace
	(
       DriveLetter,
       VolumeName,
       AvailableMB,
       TotalDiskSpaceMB,
       DTStamp
	)

	SELECT
		DriveLetter														DriveLetter,
		CASE
			WHEN LEN(RTRIM(LTRIM(VolumeName))) = 0 THEN &#039;Unknown&#039;
			ELSE VolumeName
		END																VolumeName,
		AvailableMB														AvailableMB,
		DriveSize														TotalDiskSpaceMB,
		@BATCHDATE														LoadDate
		FROM #Space

END TRY

BEGIN CATCH
	SELECT
		ERROR_NUMBER() AS ErrorNumber
		,ERROR_MESSAGE() AS ErrorMessage
		,ERROR_SEVERITY() AS ErrorSeverity
		,ERROR_STATE() AS ErrorState
		,ERROR_LINE() AS ErrorLine
		,ERROR_PROCEDURE() AS ErrorProcedure

		GOTO Cleanup
END CATCH


Cleanup:

-- Ensure xp_cmdshell&#039;s off
	EXEC sp_configure &#039;OLE Automation Procedures&#039;, @NO;
	RECONFIGURE
	
	Select * From #AvailableDiskSpace
	drop table #AvailableDiskSpace
	drop table #Space]]></description>
		<content:encoded><![CDATA[<p>Hi All,</p>
<p>TRY THIS: but this will not give us the infomation about volumes. </p>
<p>IF OBJECT_ID(&#8216;#AvailableDiskSpace&#8217;) IS NULL<br />
	BEGIN<br />
		CREATE TABLE dbo.#AvailableDiskSpace<br />
		(<br />
			PK										INT IDENTITY CONSTRAINT PK_AvailableDiskSpace PRIMARY KEY,<br />
			DriveLetter								CHAR(1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,<br />
			VolumeName								VARCHAR(32) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,<br />
			PercentFree								AS (CONVERT(DECIMAL(15, 4), AvailableMB) / CONVERT(DECIMAL(15, 4), TotalDiskSpaceMB) * 100),<br />
			AvailableMB								BIGINT NOT NULL,<br />
			TotalDiskSpaceMB						BIGINT NOT NULL,<br />
			DTStamp									DATETIME NOT NULL<br />
		) ON [PRIMARY]</p>
<p>		CREATE NONCLUSTERED INDEX NCndx_DTStamp<br />
		ON dbo.#AvailableDiskSpace (DTStamp)</p>
<p>	END<br />
&#8211; Vars<br />
DECLARE</p>
<p>	@AgeOutDate										DATETIME,		&#8211; To prune the [AvailableDiskSpace] table<br />
	@BATCHDATE										DATETIME,		&#8211; Constant<br />
	@DriveSize										BIGINT,			&#8211; Drive size in bytes<br />
	@DriveLetter									VARCHAR(2),		&#8211; FSO drive letter<br />
	@ErrorMessage									VARCHAR(500),	&#8211; Error message<br />
	@FSO											INT,			&#8211; File System Object<br />
	@AvailableMB									INT,			&#8211; Available space MB<br />
	@NO												BIT,			&#8211; Constant<br />
	@oDrive											INT,			&#8211; FSO drive<br />
	@OLE_AUTOMATION_PROCEDURES						INT,			&#8211; Constant<br />
	@PK												TINYINT,		&#8211; Work-table primary key<br />
	@RawFree										VARCHAR(20),	&#8211; Available space bytes<br />
	@RetVal											INT,			&#8211; Return value<br />
	@SQL											NVARCHAR(255),	&#8211; Dynamic T-SQL<br />
	@TwoToTheTwentieth								INT,			&#8211; Convert bytes to MB<br />
	@ValueInUse										SQL_VARIANT,	&#8211; To test configuration settings<br />
	@VolumeName										VARCHAR(32),	&#8211; FSO volume name<br />
	@YES											BIT				&#8211; Constant</p>
<p>&#8211; Constants<br />
SET @BATCHDATE							= GETDATE()<br />
SET @OLE_AUTOMATION_PROCEDURES			= 16388			&#8211; SELECT configuration_id FROM master.sys.configurations<br />
SET @NO									= 0<br />
SET @TwoToTheTwentieth					= POWER(2, 20)<br />
SET @YES								= 1</p>
<p>&#8211; Create temp tables for disk space info<br />
IF OBJECT_ID(&#8216;tempdb.dbo.#Space&#8217;) IS NOT NULL DROP TABLE #Space<br />
CREATE TABLE #Space<br />
(<br />
	PK						TINYINT IDENTITY CONSTRAINT Space_PK PRIMARY KEY,<br />
	DriveLetter				VARCHAR(2) NOT NULL,<br />
	VolumeName				VARCHAR(32) NULL,<br />
	DriveSize				BIGINT CONSTRAINT DF_Space_DriveSize DEFAULT(0),<br />
	AvailableMB				BIGINT NOT NULL,<br />
	Processed				BIT CONSTRAINT DF_Space_Processed DEFAULT (0)<br />
)</p>
<p>&#8211; We need OLE automation enabled to succeed.</p>
<p>BEGIN TRY<br />
	&#8211; Enable advanced options<br />
	EXEC sp_configure &#8216;show advanced option&#8217;, &#8217;1&#8242;;<br />
	RECONFIGURE;</p>
<p>	&#8211; Ensure OLE Automation enabled<br />
	EXEC sp_configure &#8216;OLE Automation Procedures&#8217;, @YES;<br />
	RECONFIGURE</p>
<p>	&#8211; Test&#8230;<br />
	SELECT @ValueInUse = Value_In_Use<br />
	FROM master.sys.configurations<br />
	WHERE configuration_id = @OLE_AUTOMATION_PROCEDURES</p>
<p>	IF CONVERT(INT, @ValueInUse)  @YES<br />
		BEGIN<br />
			SET @ErrorMessage = CHAR(13) + &#8216;Although we attempted to enable the &#8221;OLE Automation Procedures&#8221; server option, this option is still disabled.&#8217; + CHAR(13)<br />
				+ &#8216;This script depends upon this extended stored procedure&#8221;s availability. Please investigate.&#8217;<br />
				+ CHAR(13) + &#8216;NOTE: &#8221;OLE Automation Procedures&#8221; execution requires &#8221;CONTROL SERVER&#8221; permission (See SQL Server Books Online for more information).&#8217;</p>
<p>			RAISERROR(@ErrorMessage, 16, 1)<br />
		END</p>
<p>END TRY</p>
<p>BEGIN CATCH<br />
	SELECT<br />
		ERROR_NUMBER() AS ErrorNumber<br />
		,ERROR_MESSAGE() AS ErrorMessage<br />
		,ERROR_SEVERITY() AS ErrorSeverity<br />
		,ERROR_STATE() AS ErrorState<br />
		,ERROR_LINE() AS ErrorLine<br />
		,ERROR_PROCEDURE() AS ErrorProcedure</p>
<p>		GOTO Cleanup<br />
END CATCH</p>
<p>&#8211; 1) Remove records older than user-provided number of days</p>
<p>BEGIN TRY</p>
<p>	&#8211; By default, I&#8217;d like to keep 2 years of data<br />
	SET @AgeOutDate = DATEADD(dd, (730 * -1), GETDATE())</p>
<p>	DELETE dbo.#AvailableDiskSpace<br />
	WHERE DTStamp &lt; @AgeOutDate</p>
<p>END TRY</p>
<p>BEGIN CATCH<br />
	SELECT<br />
		ERROR_NUMBER() AS ErrorNumber<br />
		,ERROR_MESSAGE() AS ErrorMessage<br />
		,ERROR_SEVERITY() AS ErrorSeverity<br />
		,ERROR_STATE() AS ErrorState<br />
		,ERROR_LINE() AS ErrorLine<br />
		,ERROR_PROCEDURE() AS ErrorProcedure</p>
<p>		GOTO Cleanup<br />
END CATCH</p>
<p>&#8211; 2) Get free space on drives</p>
<p>BEGIN TRY<br />
	&#8211; Populate temp table; this system proc gives us space in MB<br />
	INSERT INTO #Space (DriveLetter, AvailableMB)<br />
		EXEC master.dbo.xp_fixeddrives</p>
<p>&#8211; 3) Loop through drives and get various attributes using OLE automation</p>
<p>	WHILE EXISTS (SELECT TOP 1 1 FROM #Space WHERE Processed = @No)</p>
<p>		BEGIN</p>
<p>			SELECT TOP 1<br />
				@PK				= PK,<br />
				@DriveLetter	= DriveLetter,<br />
				@AvailableMB	= AvailableMB,<br />
				@DriveSize		= DriveSize<br />
			FROM #Space<br />
			WHERE Processed = @No</p>
<p>			BEGIN TRY<br />
				EXEC master.dbo.sp_OACreate &#039;Scripting.FileSystemObject&#039;, @FSO OUT<br />
			END TRY</p>
<p>			BEGIN CATCH<br />
				SELECT<br />
					ERROR_NUMBER() AS ErrorNumber<br />
					,ERROR_MESSAGE() AS ErrorMessage<br />
					,ERROR_SEVERITY() AS ErrorSeverity<br />
					,ERROR_STATE() AS ErrorState<br />
					,ERROR_LINE() AS ErrorLine<br />
					,ERROR_PROCEDURE() AS ErrorProcedure</p>
<p>					GOTO Cleanup<br />
			END CATCH			</p>
<p>			BEGIN TRY</p>
<p>				&#8211; Get disk info<br />
				SET @DriveLetter = @DriveLetter + &#039;:\&#039;<br />
				EXEC master.dbo.sp_OAMethod @FSO,			&#039;GetDrive&#039;,			@oDrive OUT, @DriveLetter<br />
				EXEC master.dbo.sp_OAMethod @oDrive,		&#039;TotalSize&#039;,		@DriveSize OUT<br />
				EXEC master.dbo.sp_OAMethod @oDrive,		&#039;AvailableSpace&#039;,	@RawFree OUT<br />
				EXEC master.dbo.sp_OAGetProperty @oDrive,	&#039;VolumeName&#039;,		@VolumeName OUT			</p>
<p>			END TRY</p>
<p>			BEGIN CATCH<br />
				SELECT<br />
					ERROR_NUMBER() AS ErrorNumber<br />
					,ERROR_MESSAGE() AS ErrorMessage<br />
					,ERROR_SEVERITY() AS ErrorSeverity<br />
					,ERROR_STATE() AS ErrorState<br />
					,ERROR_LINE() AS ErrorLine<br />
					,ERROR_PROCEDURE() AS ErrorProcedure</p>
<p>					GOTO Cleanup<br />
			END CATCH			</p>
<p>			BEGIN TRY<br />
				&#8211; Update table<br />
				UPDATE #Space<br />
				SET<br />
					VolumeName =<br />
						CASE LOWER(@DriveLetter)<br />
							WHEN &#039;c:&#039; THEN &#039;System&#039;<br />
							ELSE @VolumeName<br />
						END,<br />
					&#8211; Convert bytes to megabytes<br />
					DriveSize		= CONVERT(BIGINT, @DriveSize) / @TwoToTheTwentieth,<br />
					&#8211; Convert bytes to megabytes<br />
					AvailableMB		= CONVERT(BIGINT, @RawFree) / @TwoToTheTwentieth<br />
				WHERE PK = @PK;</p>
<p>			END TRY</p>
<p>			BEGIN CATCH<br />
				SELECT<br />
					ERROR_NUMBER() AS ErrorNumber<br />
					,ERROR_MESSAGE() AS ErrorMessage<br />
					,ERROR_SEVERITY() AS ErrorSeverity<br />
					,ERROR_STATE() AS ErrorState<br />
					,ERROR_LINE() AS ErrorLine<br />
					,ERROR_PROCEDURE() AS ErrorProcedure</p>
<p>					GOTO Cleanup<br />
			END CATCH			</p>
<p>			BEGIN TRY</p>
<p>				&#8211; Destroy oDrive<br />
				EXEC master.dbo.sp_OADestroy @oDrive</p>
<p>			END TRY</p>
<p>			BEGIN CATCH<br />
				SELECT<br />
					ERROR_NUMBER() AS ErrorNumber<br />
					,ERROR_MESSAGE() AS ErrorMessage<br />
					,ERROR_SEVERITY() AS ErrorSeverity<br />
					,ERROR_STATE() AS ErrorState<br />
					,ERROR_LINE() AS ErrorLine<br />
					,ERROR_PROCEDURE() AS ErrorProcedure</p>
<p>					GOTO Cleanup<br />
			END CATCH			</p>
<p>			UPDATE #Space<br />
			SET Processed = @YES<br />
			WHERE PK = @PK</p>
<p>		END</p>
<p>	BEGIN TRY</p>
<p>		&#8211; Destroy FSO<br />
		EXEC master.dbo.sp_OADestroy @FSO</p>
<p>	END TRY</p>
<p>	BEGIN CATCH<br />
		SELECT<br />
			ERROR_NUMBER() AS ErrorNumber<br />
			,ERROR_MESSAGE() AS ErrorMessage<br />
			,ERROR_SEVERITY() AS ErrorSeverity<br />
			,ERROR_STATE() AS ErrorState<br />
			,ERROR_LINE() AS ErrorLine<br />
			,ERROR_PROCEDURE() AS ErrorProcedure</p>
<p>			GOTO Cleanup<br />
	END CATCH</p>
<p>&#8211; 4) Load results in table</p>
<p>	&#8211; Return disk-space info<br />
	INSERT dbo.#AvailableDiskSpace<br />
	(<br />
       DriveLetter,<br />
       VolumeName,<br />
       AvailableMB,<br />
       TotalDiskSpaceMB,<br />
       DTStamp<br />
	)</p>
<p>	SELECT<br />
		DriveLetter														DriveLetter,<br />
		CASE<br />
			WHEN LEN(RTRIM(LTRIM(VolumeName))) = 0 THEN &#039;Unknown&#039;<br />
			ELSE VolumeName<br />
		END																VolumeName,<br />
		AvailableMB														AvailableMB,<br />
		DriveSize														TotalDiskSpaceMB,<br />
		@BATCHDATE														LoadDate<br />
		FROM #Space</p>
<p>END TRY</p>
<p>BEGIN CATCH<br />
	SELECT<br />
		ERROR_NUMBER() AS ErrorNumber<br />
		,ERROR_MESSAGE() AS ErrorMessage<br />
		,ERROR_SEVERITY() AS ErrorSeverity<br />
		,ERROR_STATE() AS ErrorState<br />
		,ERROR_LINE() AS ErrorLine<br />
		,ERROR_PROCEDURE() AS ErrorProcedure</p>
<p>		GOTO Cleanup<br />
END CATCH</p>
<p>Cleanup:</p>
<p>&#8211; Ensure xp_cmdshell&#039;s off<br />
	EXEC sp_configure &#039;OLE Automation Procedures&#039;, @NO;<br />
	RECONFIGURE</p>
<p>	Select * From #AvailableDiskSpace<br />
	drop table #AvailableDiskSpace<br />
	drop table #Space</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Elatesummer</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-282924</link>
		<dc:creator><![CDATA[Elatesummer]]></dc:creator>
		<pubDate>Tue, 08 May 2012 11:49:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-282924</guid>
		<description><![CDATA[For people having problems finding mount points: http://weblogs.sqlteam.com/tarad/archive/2007/12/18/60435.aspx]]></description>
		<content:encoded><![CDATA[<p>For people having problems finding mount points: <a href="http://weblogs.sqlteam.com/tarad/archive/2007/12/18/60435.aspx" rel="nofollow">http://weblogs.sqlteam.com/tarad/archive/2007/12/18/60435.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jim</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-272507</link>
		<dc:creator><![CDATA[jim]]></dc:creator>
		<pubDate>Thu, 05 Apr 2012 15:40:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-272507</guid>
		<description><![CDATA[As a previous poster commented, mount points do not display correctly using  the fixed drive stored procedure.  As a work-around for my current situation, I found that I can create a sql agent job to run a CmdExec type of job which just does a &quot;dir&quot; of the drive and stores it to a file.]]></description>
		<content:encoded><![CDATA[<p>As a previous poster commented, mount points do not display correctly using  the fixed drive stored procedure.  As a work-around for my current situation, I found that I can create a sql agent job to run a CmdExec type of job which just does a &#8220;dir&#8221; of the drive and stores it to a file.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-258289</link>
		<dc:creator><![CDATA[Mark]]></dc:creator>
		<pubDate>Thu, 01 Mar 2012 17:54:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-258289</guid>
		<description><![CDATA[Is there a way toQuery using XP_CmdShell to collect the used space and free space on a UNC path or mapped network drive?]]></description>
		<content:encoded><![CDATA[<p>Is there a way toQuery using XP_CmdShell to collect the used space and free space on a UNC path or mapped network drive?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Subba</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-232865</link>
		<dc:creator><![CDATA[Subba]]></dc:creator>
		<pubDate>Sat, 07 Jan 2012 10:55:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-232865</guid>
		<description><![CDATA[how to get the free space in GB]]></description>
		<content:encoded><![CDATA[<p>how to get the free space in GB</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RaviShankar</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-211389</link>
		<dc:creator><![CDATA[RaviShankar]]></dc:creator>
		<pubDate>Mon, 05 Dec 2011 14:50:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-211389</guid>
		<description><![CDATA[Thanks Raj..]]></description>
		<content:encoded><![CDATA[<p>Thanks Raj..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raj</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-209166</link>
		<dc:creator><![CDATA[Raj]]></dc:creator>
		<pubDate>Fri, 02 Dec 2011 05:48:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-209166</guid>
		<description><![CDATA[@Raj
19313/1024 = 18.8GB]]></description>
		<content:encoded><![CDATA[<p>@Raj<br />
19313/1024 = 18.8GB</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RaviShankar Kota</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-207823</link>
		<dc:creator><![CDATA[RaviShankar Kota]]></dc:creator>
		<pubDate>Wed, 30 Nov 2011 08:04:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-207823</guid>
		<description><![CDATA[Hi Pinal and All commentors,

The values in sql output are different from the OS drives actual values.
eg:D drive is showing 19313 MB in sql result.But OS drives shows 18.8 GB free..
How can we rectify the difference?]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal and All commentors,</p>
<p>The values in sql output are different from the OS drives actual values.<br />
eg:D drive is showing 19313 MB in sql result.But OS drives shows 18.8 GB free..<br />
How can we rectify the difference?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER &#8211; Powershell &#8211; Get a List of Fixed Hard Drive and Free Space on Server &#171; Journey to SQLAuthority</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-205236</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Powershell &#8211; Get a List of Fixed Hard Drive and Free Space on Server &#171; Journey to SQLAuthority]]></dc:creator>
		<pubDate>Sun, 27 Nov 2011 01:31:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-205236</guid>
		<description><![CDATA[[...] a List of Fixed Hard Drive and Free Space on Server. I recently received excellent comment by MVP Ravikanth. He demonstrated that how the same can be done using Powershell. It is very sweet and quick [...]]]></description>
		<content:encoded><![CDATA[<p>[...] a List of Fixed Hard Drive and Free Space on Server. I recently received excellent comment by MVP Ravikanth. He demonstrated that how the same can be done using Powershell. It is very sweet and quick [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rahul</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-204262</link>
		<dc:creator><![CDATA[Rahul]]></dc:creator>
		<pubDate>Fri, 25 Nov 2011 09:52:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-204262</guid>
		<description><![CDATA[SELECT ID,ROW_NUMBER() OVER (PARTITION BY ID,Co_Name ) AS Group, Co_Name 
FROM [your_table]]]></description>
		<content:encoded><![CDATA[<p>SELECT ID,ROW_NUMBER() OVER (PARTITION BY ID,Co_Name ) AS Group, Co_Name<br />
FROM [your_table]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ravikanth</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-204215</link>
		<dc:creator><![CDATA[ravikanth]]></dc:creator>
		<pubDate>Fri, 25 Nov 2011 08:03:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-204215</guid>
		<description><![CDATA[Good to know the T-SQL way of doing it but this is where PowerShell comes into picture. It is quite easy!

Get-WmiObject -Class Win32_LogicalDisk &#124; Select -Property DeviceID, @{Name=&#039;FreeSpaceMB&#039;;Expression={$_.FreeSpace/1MB} } &#124; Format-Table -AutoSize

This gives an output similar to:
DeviceID     FreeSpaceMB
--------     -----------
C:       258795.73046875
D:                     0
F:             3000.8125
H:              122916.5
Q:                     0

Now, you can easily extend this to query a remote server by just adding the -ComputerName parameter. For example:

Get-WmiObject -ComputerName Remoteserver -Class Win32_LogicalDisk &#124; Select -Property DeviceID, @{Name=&#039;FreeSpaceMB&#039;;Expression={$_.FreeSpace/1MB} } &#124; Format-Table -AutoSize

Simple!]]></description>
		<content:encoded><![CDATA[<p>Good to know the T-SQL way of doing it but this is where PowerShell comes into picture. It is quite easy!</p>
<p>Get-WmiObject -Class Win32_LogicalDisk | Select -Property DeviceID, @{Name=&#8217;FreeSpaceMB&#8217;;Expression={$_.FreeSpace/1MB} } | Format-Table -AutoSize</p>
<p>This gives an output similar to:<br />
DeviceID     FreeSpaceMB<br />
&#8212;&#8212;&#8211;     &#8212;&#8212;&#8212;&#8211;<br />
C:       258795.73046875<br />
D:                     0<br />
F:             3000.8125<br />
H:              122916.5<br />
Q:                     0</p>
<p>Now, you can easily extend this to query a remote server by just adding the -ComputerName parameter. For example:</p>
<p>Get-WmiObject -ComputerName Remoteserver -Class Win32_LogicalDisk | Select -Property DeviceID, @{Name=&#8217;FreeSpaceMB&#8217;;Expression={$_.FreeSpace/1MB} } | Format-Table -AutoSize</p>
<p>Simple!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bipin Singh</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-69173</link>
		<dc:creator><![CDATA[Bipin Singh]]></dc:creator>
		<pubDate>Wed, 05 May 2010 04:14:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-69173</guid>
		<description><![CDATA[Dear Madhivanan,

It returns something like this,

Volume in drive C has no label.
Volume Serial Number is 1CB7-C6C4
NULL
Directory of C:\WINDOWS\system32
NULL
File Not Found
NULL

which is not my desired output. I discovered something like this which is satisfying my requirement.

Script:




Alter PROCEDURE Proc_diskspace  
AS  
	SET NOCOUNT ON  

	DECLARE @hr int  
	DECLARE @fso int  
	DECLARE @drive char(1)  
	DECLARE @odrive int  
	DECLARE @TotalSize varchar(20)  
	DECLARE @MB bigint ; SET @MB = 1048576  

CREATE TABLE #drives (ServerName varchar(15),  
	drive char(1) PRIMARY KEY,  
	FreeSpace int NULL,  
	TotalSize int NULL,  
	FreespaceTimestamp DATETIME NULL)  

	INSERT #drives(drive,FreeSpace)  

	EXEC master.dbo.xp_fixeddrives  
	EXEC @hr=sp_OACreate &#039;Scripting.FileSystemObject&#039;,@fso OUT  

	IF @hr  0 EXEC sp_OAGetErrorInfo @fso  
	
	DECLARE dcur CURSOR LOCAL FAST_FORWARD  
	FOR SELECT drive from #drives  
	ORDER by drive  
	OPEN dcur  
	FETCH NEXT FROM dcur INTO @drive  
	WHILE @@FETCH_STATUS=0  
	BEGIN  
	EXEC @hr = sp_OAMethod @fso,&#039;GetDrive&#039;, @odrive OUT, @drive  
	IF @hr  0 EXEC sp_OAGetErrorInfo @fso  
	EXEC @hr = sp_OAGetProperty @odrive,&#039;TotalSize&#039;, @TotalSize OUT  
	IF @hr  0 EXEC sp_OAGetErrorInfo @odrive  
	UPDATE #drives SET TotalSize=@TotalSize/@MB, ServerName = @@servername, FreespaceTimestamp = (GETDATE())  
	WHERE drive=@drive  
	FETCH NEXT FROM dcur INTO @drive  
END  
CLOSE dcur  
DEALLOCATE dcur  
	EXEC @hr=sp_OADestroy @fso  

IF @hr  0 EXEC sp_OAGetErrorInfo @fso  
	SELECT	ServerName,  drive,  TotalSize as &#039;Total(MB)&#039;,  FreeSpace as &#039;Free(MB)&#039;,  
			CAST((FreeSpace/(TotalSize*1.0))*100.0 as int) as &#039;Free(%)&#039;,  
	FreespaceTimestamp  
	FROM #drives  
	ORDER BY drive  
	DROP TABLE #drives  
	RETURN  




Exec Proc_diskspace
--------------------------------------------------------------------

It results like this,

Servername C  38154 26468 69 2010-05-05 09:43:02.300

Thanks,
Bipin Singh]]></description>
		<content:encoded><![CDATA[<p>Dear Madhivanan,</p>
<p>It returns something like this,</p>
<p>Volume in drive C has no label.<br />
Volume Serial Number is 1CB7-C6C4<br />
NULL<br />
Directory of C:\WINDOWS\system32<br />
NULL<br />
File Not Found<br />
NULL</p>
<p>which is not my desired output. I discovered something like this which is satisfying my requirement.</p>
<p>Script:</p>
<p>Alter PROCEDURE Proc_diskspace<br />
AS<br />
	SET NOCOUNT ON  </p>
<p>	DECLARE @hr int<br />
	DECLARE @fso int<br />
	DECLARE @drive char(1)<br />
	DECLARE @odrive int<br />
	DECLARE @TotalSize varchar(20)<br />
	DECLARE @MB bigint ; SET @MB = 1048576  </p>
<p>CREATE TABLE #drives (ServerName varchar(15),<br />
	drive char(1) PRIMARY KEY,<br />
	FreeSpace int NULL,<br />
	TotalSize int NULL,<br />
	FreespaceTimestamp DATETIME NULL)  </p>
<p>	INSERT #drives(drive,FreeSpace)  </p>
<p>	EXEC master.dbo.xp_fixeddrives<br />
	EXEC @hr=sp_OACreate &#8216;Scripting.FileSystemObject&#8217;,@fso OUT  </p>
<p>	IF @hr  0 EXEC sp_OAGetErrorInfo @fso  </p>
<p>	DECLARE dcur CURSOR LOCAL FAST_FORWARD<br />
	FOR SELECT drive from #drives<br />
	ORDER by drive<br />
	OPEN dcur<br />
	FETCH NEXT FROM dcur INTO @drive<br />
	WHILE @@FETCH_STATUS=0<br />
	BEGIN<br />
	EXEC @hr = sp_OAMethod @fso,&#8217;GetDrive&#8217;, @odrive OUT, @drive<br />
	IF @hr  0 EXEC sp_OAGetErrorInfo @fso<br />
	EXEC @hr = sp_OAGetProperty @odrive,&#8217;TotalSize&#8217;, @TotalSize OUT<br />
	IF @hr  0 EXEC sp_OAGetErrorInfo @odrive<br />
	UPDATE #drives SET TotalSize=@TotalSize/@MB, ServerName = @@servername, FreespaceTimestamp = (GETDATE())<br />
	WHERE drive=@drive<br />
	FETCH NEXT FROM dcur INTO @drive<br />
END<br />
CLOSE dcur<br />
DEALLOCATE dcur<br />
	EXEC @hr=sp_OADestroy @fso  </p>
<p>IF @hr  0 EXEC sp_OAGetErrorInfo @fso<br />
	SELECT	ServerName,  drive,  TotalSize as &#8216;Total(MB)&#8217;,  FreeSpace as &#8216;Free(MB)&#8217;,<br />
			CAST((FreeSpace/(TotalSize*1.0))*100.0 as int) as &#8216;Free(%)&#8217;,<br />
	FreespaceTimestamp<br />
	FROM #drives<br />
	ORDER BY drive<br />
	DROP TABLE #drives<br />
	RETURN  </p>
<p>Exec Proc_diskspace<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>It results like this,</p>
<p>Servername C  38154 26468 69 2010-05-05 09:43:02.300</p>
<p>Thanks,<br />
Bipin Singh</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ahmed</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-69032</link>
		<dc:creator><![CDATA[Ahmed]]></dc:creator>
		<pubDate>Tue, 04 May 2010 17:18:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-69032</guid>
		<description><![CDATA[Hi Pinal,

Wat about mounted volume?

Thanks]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>Wat about mounted volume?</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhivanan</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-67742</link>
		<dc:creator><![CDATA[Madhivanan]]></dc:creator>
		<pubDate>Thu, 29 Apr 2010 13:11:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-67742</guid>
		<description><![CDATA[Try

EXEC xp_cmdshell &#039;Dir &quot;Driver&quot;&#039;]]></description>
		<content:encoded><![CDATA[<p>Try</p>
<p>EXEC xp_cmdshell &#8216;Dir &#8220;Driver&#8221;&#8216;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhivanan</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-67741</link>
		<dc:creator><![CDATA[Madhivanan]]></dc:creator>
		<pubDate>Thu, 29 Apr 2010 13:09:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-67741</guid>
		<description><![CDATA[Which version of SQL Server are you using?
If you use version 2005, use row_number() function
Refer this post
http://beyondrelational.com/blogs/madhivanan/archive/2007/08/27/multipurpose-row-number-function.aspx]]></description>
		<content:encoded><![CDATA[<p>Which version of SQL Server are you using?<br />
If you use version 2005, use row_number() function<br />
Refer this post<br />
<a href="http://beyondrelational.com/blogs/madhivanan/archive/2007/08/27/multipurpose-row-number-function.aspx" rel="nofollow">http://beyondrelational.com/blogs/madhivanan/archive/2007/08/27/multipurpose-row-number-function.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bipin Singh</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-67711</link>
		<dc:creator><![CDATA[Bipin Singh]]></dc:creator>
		<pubDate>Thu, 29 Apr 2010 09:40:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-67711</guid>
		<description><![CDATA[Dear Pinal &amp; Other members,

I want to find out full hard disk detail with space utilized (In MB) and percentage, space utilized in MB and % for a system.

it&#039;s really urgent so please co-operate.

Thanks in Advance.

Regards,
Bipin Singh]]></description>
		<content:encoded><![CDATA[<p>Dear Pinal &amp; Other members,</p>
<p>I want to find out full hard disk detail with space utilized (In MB) and percentage, space utilized in MB and % for a system.</p>
<p>it&#8217;s really urgent so please co-operate.</p>
<p>Thanks in Advance.</p>
<p>Regards,<br />
Bipin Singh</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jacob Sebastian</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-54738</link>
		<dc:creator><![CDATA[Jacob Sebastian]]></dc:creator>
		<pubDate>Tue, 11 Aug 2009 14:34:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-54738</guid>
		<description><![CDATA[Raj,
You can use the DENSE_RANK() function to achieve this. I am posting it here (even though you asked me to send by email) so that it can help other people as well.

DECLARE @t TABLE (Code CHAR(5), Name CHAR(3))
INSERT INTO @t (Code, Name) SELECT &#039;AX001&#039;,&#039;ABC&#039;
INSERT INTO @t (Code, Name) SELECT &#039;AX001&#039;,&#039;ABC&#039;
INSERT INTO @t (Code, Name) SELECT &#039;AX001&#039;,&#039;MNO&#039;
INSERT INTO @t (Code, Name) SELECT &#039;AX001&#039;,&#039;PQR&#039;
INSERT INTO @t (Code, Name) SELECT &#039;AX002&#039;,&#039;ABC&#039;
INSERT INTO @t (Code, Name) SELECT &#039;AX002&#039;,&#039;XXX&#039;
INSERT INTO @t (Code, Name) SELECT &#039;AX003&#039;,&#039;YYY&#039;
INSERT INTO @t (Code, Name) SELECT &#039;AX003&#039;,&#039;YYY&#039;
INSERT INTO @t (Code, Name) SELECT &#039;AX003&#039;,&#039;ZZZ&#039;
INSERT INTO @t (Code, Name) SELECT &#039;AX004&#039;,&#039;ZZZ&#039;

SELECT
	Code, Name, 
	DENSE_RANK() OVER(PARTITION BY Code ORDER BY Name) AS[ Group]
FROM @t

/*
Code  Name  Group
----- ---- --------------------
AX001 ABC  1
AX001 ABC  1
AX001 MNO  2
AX001 PQR  3
AX002 ABC  1
AX002 XXX  2
AX003 YYY  1
AX003 YYY  1
AX003 ZZZ  2
AX004 ZZZ  1
*/]]></description>
		<content:encoded><![CDATA[<p>Raj,<br />
You can use the DENSE_RANK() function to achieve this. I am posting it here (even though you asked me to send by email) so that it can help other people as well.</p>
<p>DECLARE @t TABLE (Code CHAR(5), Name CHAR(3))<br />
INSERT INTO @t (Code, Name) SELECT &#8216;AX001&#8242;,&#8217;ABC&#8217;<br />
INSERT INTO @t (Code, Name) SELECT &#8216;AX001&#8242;,&#8217;ABC&#8217;<br />
INSERT INTO @t (Code, Name) SELECT &#8216;AX001&#8242;,&#8217;MNO&#8217;<br />
INSERT INTO @t (Code, Name) SELECT &#8216;AX001&#8242;,&#8217;PQR&#8217;<br />
INSERT INTO @t (Code, Name) SELECT &#8216;AX002&#8242;,&#8217;ABC&#8217;<br />
INSERT INTO @t (Code, Name) SELECT &#8216;AX002&#8242;,&#8217;XXX&#8217;<br />
INSERT INTO @t (Code, Name) SELECT &#8216;AX003&#8242;,&#8217;YYY&#8217;<br />
INSERT INTO @t (Code, Name) SELECT &#8216;AX003&#8242;,&#8217;YYY&#8217;<br />
INSERT INTO @t (Code, Name) SELECT &#8216;AX003&#8242;,&#8217;ZZZ&#8217;<br />
INSERT INTO @t (Code, Name) SELECT &#8216;AX004&#8242;,&#8217;ZZZ&#8217;</p>
<p>SELECT<br />
	Code, Name,<br />
	DENSE_RANK() OVER(PARTITION BY Code ORDER BY Name) AS[ Group]<br />
FROM @t</p>
<p>/*<br />
Code  Name  Group<br />
&#8212;&#8211; &#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
AX001 ABC  1<br />
AX001 ABC  1<br />
AX001 MNO  2<br />
AX001 PQR  3<br />
AX002 ABC  1<br />
AX002 XXX  2<br />
AX003 YYY  1<br />
AX003 YYY  1<br />
AX003 ZZZ  2<br />
AX004 ZZZ  1<br />
*/</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raj</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-54733</link>
		<dc:creator><![CDATA[Raj]]></dc:creator>
		<pubDate>Tue, 11 Aug 2009 11:44:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-54733</guid>
		<description><![CDATA[Thank you very much Jacob for your reply. It resolved my problem.

Now i have some different requirement. Could you please help me out with it as well /



This is the query rewult which im getting as of now

======================
Code	Name	Group
--------------------------------
AX001	ABC	1
AX002	XXX	1
AX001	MNO	1
AX001	ABC	1
AX003	YYY	1
AX001	PQR	1
AX004	ZZZ	1
AX003	YYY	1
AX003	ZZZ	1
AX002	ABC	1



I need the result in the below format.. When Code &amp; Name are same then it shud start with 1, if same code &amp; diff Name then the  Gropu value should increment by 1. 

Expected Output
======================
Code	Name	Group
--------------------------------
AX001	ABC	1
AX001	ABC	1
AX001	MNO	2
AX001	PQR	3
AX002	ABC	1
AX002	XXX	2
AX003	YYY	1
AX003	YYY	1
AX003	ZZZ	2
AX004	ZZZ	1



Can you please reply to me on my id. I sent you the Linkedin request as well.

Thanks,
Awaiting your feedback / reply ASAP (TIA)]]></description>
		<content:encoded><![CDATA[<p>Thank you very much Jacob for your reply. It resolved my problem.</p>
<p>Now i have some different requirement. Could you please help me out with it as well /</p>
<p>This is the query rewult which im getting as of now</p>
<p>======================<br />
Code	Name	Group<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
AX001	ABC	1<br />
AX002	XXX	1<br />
AX001	MNO	1<br />
AX001	ABC	1<br />
AX003	YYY	1<br />
AX001	PQR	1<br />
AX004	ZZZ	1<br />
AX003	YYY	1<br />
AX003	ZZZ	1<br />
AX002	ABC	1</p>
<p>I need the result in the below format.. When Code &amp; Name are same then it shud start with 1, if same code &amp; diff Name then the  Gropu value should increment by 1. </p>
<p>Expected Output<br />
======================<br />
Code	Name	Group<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
AX001	ABC	1<br />
AX001	ABC	1<br />
AX001	MNO	2<br />
AX001	PQR	3<br />
AX002	ABC	1<br />
AX002	XXX	2<br />
AX003	YYY	1<br />
AX003	YYY	1<br />
AX003	ZZZ	2<br />
AX004	ZZZ	1</p>
<p>Can you please reply to me on my id. I sent you the Linkedin request as well.</p>
<p>Thanks,<br />
Awaiting your feedback / reply ASAP (TIA)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-54537</link>
		<dc:creator><![CDATA[Eric]]></dc:creator>
		<pubDate>Thu, 06 Aug 2009 14:15:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-54537</guid>
		<description><![CDATA[Mount Points don&#039;t show up with this... standard practice used for VLDB&#039;s... So, this shows that I have an E drive for example that is a couple hundred MB...but, I have 3 TB worth of mountpoints hanging off that E drive.  

http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=301832]]></description>
		<content:encoded><![CDATA[<p>Mount Points don&#8217;t show up with this&#8230; standard practice used for VLDB&#8217;s&#8230; So, this shows that I have an E drive for example that is a couple hundred MB&#8230;but, I have 3 TB worth of mountpoints hanging off that E drive.  </p>
<p><a href="http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=301832" rel="nofollow">http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=301832</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jacob Sebastian</title>
		<link>http://blog.sqlauthority.com/2009/08/05/sql-server-get-a-list-of-fixed-hard-drive-and-free-space-on-server/#comment-54509</link>
		<dc:creator><![CDATA[Jacob Sebastian]]></dc:creator>
		<pubDate>Thu, 06 Aug 2009 08:04:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6193#comment-54509</guid>
		<description><![CDATA[Raj,
Is this what you are looking for?

DECLARE @t TABLE (ID INT, Name CHAR(3))
INSERT INTO @t (ID, Name) SELECT 1, &#039;ABC&#039;
INSERT INTO @t (ID, Name) SELECT 2, &#039;PQR&#039;
INSERT INTO @t (ID, Name) SELECT 1, &#039;ABC&#039;
INSERT INTO @t (ID, Name) SELECT 3, &#039;MNO&#039;
INSERT INTO @t (ID, Name) SELECT 1, &#039;ABC&#039;

SELECT 
	ID, 
	ROW_NUMBER() OVER(
		PARTITION BY ID ORDER BY ID) AS [Group], 
	Name 
FROM @t

/*
ID          Group                Name
----------- -------------------- ----
1           1                    ABC
1           2                    ABC
1           3                    ABC
2           1                    PQR
3           1                    MNO
*/]]></description>
		<content:encoded><![CDATA[<p>Raj,<br />
Is this what you are looking for?</p>
<p>DECLARE @t TABLE (ID INT, Name CHAR(3))<br />
INSERT INTO @t (ID, Name) SELECT 1, &#8216;ABC&#8217;<br />
INSERT INTO @t (ID, Name) SELECT 2, &#8216;PQR&#8217;<br />
INSERT INTO @t (ID, Name) SELECT 1, &#8216;ABC&#8217;<br />
INSERT INTO @t (ID, Name) SELECT 3, &#8216;MNO&#8217;<br />
INSERT INTO @t (ID, Name) SELECT 1, &#8216;ABC&#8217;</p>
<p>SELECT<br />
	ID,<br />
	ROW_NUMBER() OVER(<br />
		PARTITION BY ID ORDER BY ID) AS [Group],<br />
	Name<br />
FROM @t</p>
<p>/*<br />
ID          Group                Name<br />
&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;-<br />
1           1                    ABC<br />
1           2                    ABC<br />
1           3                    ABC<br />
2           1                    PQR<br />
3           1                    MNO<br />
*/</p>
]]></content:encoded>
	</item>
</channel>
</rss>
