tsql or something to get if file exists and date of file

  • Something like this?

    CREATE TABLE #tmp( output nvarchar(max));

    INSERT INTO #tmp

    --Change Path

    EXEC xp_cmdshell 'dir C:\Users\lcazares\Documents\Statement.pdf /TC'; --Uses /TC for creation date

    SELECT CAST( LEFT( output, 10) AS datetime)

    FROM #tmp

    WHERE output LIKE '[0-9][0-9]/[0-9][0-9]/[0-9][0-9][0-9][0-9]%';

    DROP TABLE #tmp;

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • ahh yes big thank you 🙂

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

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