fn_virtualfilestats

  • Can anyone tell me why the following query will run against a database with a compatibility level of 90 but not 80?

    SELECT BytesOnDisk FROM ::fn_virtualfilestats((DB_ID()), 1)

    The error message being:

    Msg 102, Level 15, State 1, Line 1

    Incorrect syntax near '('.

    Both functions are available in SQL 2000 so I don't understand why this is returning an error.

    Thanks in advance.

  • Try with the following gives the current database status

    Select bytesondisk from fn:virtualfilestats(1,1);

  • The reason is that SQL Server 2000 has much stricter rules on what it allows as parameters to table returning functions. So no function results, no variables, .... SQL Server 2005 has removed this limitation.

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • That doesn't give the size of the current database. It relates to the database with an ID of 1.

    I took the information from sys.sysaltfiles instead but thanks for the replies.

  • You could change the SQL compatibility setting from sql 2000 to 2005, if the app will allow it?

    I have never come across an app that has issues with an higher setting, but that is no guarantee 🙂

  • Please note: 6 year old thread

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

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

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