how to check whether the backup files exists in a network drive with modified dates

  • Hi ,

    Can anyone tell me, what is the T-SQL to check whether the backup files exists in a network drive with modified dates.

    Thanks in advance.

  • Here is the query

    DECLARE @Tbl AS TABLE (Details VARCHAR(MAX))

    DECLARE @FilePath AS VARCHAR(100) = '\\NWDrive\FolderName\'

    DECLARE @Cmd AS VARCHAR(100) = 'DIR ' + @FilePath

    INSERT INTO @Tbl

    exec master..xp_cmdshell @Cmd

    SELECT Details,LEFT(Details,20) LastModifiedOn

    FROM @Tbl

  • Thank you, it really works for me.

  • welcome 🙂

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

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