Код Visual Basic Code для хранимой процедуры CLR
Imports System
Imports System.Data
Imports System.Data.Sql
Imports System.Data.SqlServer
Imports System.Data.SqlTypes
Imports System.IO

Partial Public Class StoredProcedures
     _
    Public Shared Sub clr_FixedDrives()
        Try
            ? Get the SQL Pipe context for stored procedure execution.
            Dim oSqlPipe As SqlPipe
            oSqlPipe = SqlContext.GetPipe()

            ? Creating the MetaData / Column definition we?re going to send back.
            Dim metadata(1) As SqlMetaData
            metadata(0) = New SqlMetaData(«drive», SqlDbType.Char, 1)
            metadata(1) = New SqlMetaData(«MB free», SqlDbType.BigInt)

            Dim oRecord As New SqlDataRecord(metadata)
            oSqlPipe.SendResultsStart(oRecord, False)

            Dim oDvInfo As DriveInfo
            For Each oDvInfo In DriveInfo.GetDrives()
                If oDvInfo.DriveType = DriveType.Fixed And oDvInfo.IsReady Then
                    oRecord.SetString(0, oDvInfo.Name.Substring(0, 1))
                    oRecord.SetInt64(1, oDvInfo.TotalFreeSpace / 1048576)
                    oSqlPipe.SendResultsRow(oRecord)
                End If
            Next

            oSqlPipe.SendResultsEnd()

        Catch e As Exception
            Throw New Exception(«Error executing clr_FixedDrives.», e)
        End Try
        ? Other properties we can get include
        ?oDvInfo.AvailableFreeSpace,
        ?oDvInfo.DriveFormat,
        ?oDvInfo.TotalSize, and
        ?oDvInfo.VolumeLabel.
    End Sub

End Class