Returns the logical size in bytes of the file at the specified location at compile time.


long? LENGTH(
    string path


  • path
    A constant-foldable string expression. path can be any supported file path Universal Resource Identifier (URI). If path is not constant-foldable, the error E_CSC_USER_EXPRESSIONNOTCONSTANTFOLDABLE is raised. If path is empty (null or the zero-length string), the error E_CSC_USER_EMPTYFILEPATH is raised. If path contains invalid characters, the error E_CSC_USER_INVALIDFILENAME is raised.

Return Value

The logical size in bytes of path at compile time. Null if path does not exists, refers to a folder or the user has no access to it.


DECLARE @filepath_good = "/Samples/Data/SearchLog.tsv";
DECLARE @filepath_bad = "/Samples/Data/zzz.tsv";
@result =
    SELECT  FILE.LENGTH(@filepath_good) AS length_good,
            FILE.LENGTH(@filepath_bad) AS length_bad
    FROM (VALUES (1)) AS T(dummy);
OUTPUT @result
TO "/Output/ReferenceGuide/BuiltInFunctions/SystemFunctions/FileLength.txt"
USING Outputters.Csv();

See Also