Quickly Retrieve a List of Available Media Resources

Downloads
49251.zip

The sp_GetAllSQLMediaTypes stored procedure lists the names of all the available media (i.e., drives) and their types (e.g., hard disk, tape, floppy, CD-ROM) on a SQL Server machine. As Listing 1 shows, sp_GetAllSQLMediaTypes uses a relatively unknown extended procedure called xp_availableMedia. After GetAllSQLMediaTypes runs xp_availableMedia, sp_GetAllSQLMediaTypes fills a temporary table with the results. It then decodes the media type values into meaningful terms based on the information under Media Type Constants (SQLDMO_MEDIA_TYPE) in SQL Server Books Online (BOL).

To use sp_GetAllSQLMediaTypes, you run the code

USE master
GO
EXEC GetAllSQLMediaTypes

I wrote and tested sp_GetAllSQLMediaTypes on a Windows XP machine running SQL Server 2000 Service Pack 1 (SP1). Figure 1 shows the results when I ran it on my machine.

Editor's Note
Share your SQL Server discoveries, comments, problems, solutions, and experiences with products and reach out to other SQL Server Magazine readers. Email your contributions (400 words or less) to r2r@sqlmag.com. Please include your phone number. We edit submissions for style, grammar, and length. If we print your submission, you'll get $50.

Please or Register to post comments.

IT/Dev Connections

Las Vegas
September 30th - October 4th

Paul ThurottOur Experts will show you:
• Common SQL Server
Problems
• Best Practices for T-SQL
• SQL Server Integration
Services
• Database Development

Come See Michael Otey & Tim Ford in Person!

Early Registration Now Open

From the Blogs
May 21, 2013
blog

A Common Misconception about MAXDOP

Out of the box, SQL Server is (and has been) able to take advantage of multiple processors/cores without any effort on behalf of administrators....More
May 9, 2013
blog

My ISO 8601-Compliant Signature 2

My family recently just "officially" announced that we're in the process of adopting a child from South Africa. We're quite excited, of course, but there's a ton of paperwork to do—along with the need for gobs of signatures....More
May 8, 2013
blog

Use SSIS for ETL from Hadoop

In this blog post, Mark Kromer walks you through using SSIS as a way to use ETL techniques using Microsoft's Hadoop on Windows (HDInsight) as a source using Hive connectors...More
SQL Server Pro Forums

Get answers to questions, share tips, and engage with the SQL Server community in our Forums.