script using SQLOLEDB

  • Can anyone please help me with this script

    SELECT * FROM OPENROWSET('SQLOLEDB','mydb';'userid';'passwd', 'SELECT a.name, a.fileid, a.filename, b.groupname,

     a.size * 8 AS Size, [maxsize]= CASE a.maxsize WHEN -1 THEN 0 ELSE a.maxsize * 8 END, a.growth * 8,

    a.status,  b.status groupstatus, FILEPROPERTY ( a.name, ''SpaceUsed'') * 8 AS UsedSpace,

     CAST (1 AS VARCHAR(12))  ServerID

    from prod.dbo.sysfiles a LEFT JOIN prod.dbo.sysfilegroups b on b.groupid = a.groupid')

    somehow the spaceused doesnt seem to work. can anyone suggest something please??

    TIA

  • The code seems alright, the only small idea I have is to change the double quote with a pair of single quotes.

    The real question is what are you getting?

    What should you be getting?

  • Where i should be getting something > 0 i get all as NULL values

  • Is it possible that the user doesn't have permission to run FileProperty (can't find any info about the minimum permission required)?

  • Sorry but i am trying for a user with sa rights which should work theoretically. any other thoughts??

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply