October 14, 2016 at 1:12 pm
hello everyone,
trying to to find 2 things, 1. i am trying to write a tsql statement that will check if the file exists, but also check if the file exists today, like if it was created today... and 2nd, if it is not, and its an old file, like say from yesterday, then email me...
i got the 2nd part down, i am stuck on finding out how i can get the file date, i looked at:
INSERT INTO #tmp EXEC xp_cmdshell
the code above (and yes its not all complete) isnt cutting it, i need just to put the path, file and date created of the file into a temp table so i can query it... any ideas?
October 14, 2016 at 2:27 pm
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;
October 14, 2016 at 2:29 pm
ahh yes big thank you 🙂
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply