• I think this'll give you the same result with a lot less work:

    declare @Foo table (drive char(1),mbfree int)

    INSERT INTO @Foo EXEC master..xp_fixeddrives

    IF @@rowcount = 26

    SELECT '*' as drive

    ELSE

    SELECT TOP 1 drive FROM @Foo ORDER BY drive

    Or to see all the details:

    declare @Foo table (drive char(1),mbfree int)

    INSERT INTO @Foo EXEC master..xp_fixeddrives

    SELECT * FROM @Foo

    Warning; xp_fixeddrives IS undocumented


    Cursors are useful if you don't know SQL