How to find size of physical file in a drive

  • Hi,

    How can i get the size of a file using sql-server.

    I am generating transaction log using batch job. I want to keep track of the sizes of files. for this purpose i need the size in a text file.

    please suggest me.

     

    Thanks in advance.

    -surya

     

     

  • ALTER PROCEDURE GetFileSize @FileName varchar(8000)

    --@FileName is relative to the SQL Server

    AS

    BEGIN

    CREATE TABLE #info (

    alt_name varchar(255) null,

    size_in_bytes int null,

    creation_date int null,

    creation_time int null,

    last_written_date int null,

    last_written_time int null,

    last_accessed_date int null,

    last_accessed_time int null,

    attributes int null

    )

    INSERT #info EXEC master..xp_getfiledetails @FileName

    SELECT @FileName as file_name, size_in_bytes FROM #info

    DROP TABLE #info

    END

Viewing 2 posts - 1 through 1 (of 1 total)

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