December 12, 2007 at 3:50 pm
In SQL 2005, is it possible to read the date modified of a file which is located on the hard drive of the server? Is there a procedure/function that would allow you to do so? I know it can be done using CLR Integration/SSIS/xp_cmdshell, but without using these?
December 12, 2007 at 4:06 pm
I haven't come across any. Last time I had to do that sort of thing I wrote a VBS script to handle it (delete files older than x). And that was easy because I didn't have to return anything back to SQL Server, just run it from a SQL Agent job.
MARCUS. Why dost thou laugh? It fits not with this hour.
TITUS. Why, I have not another tear to shed;
--Titus Andronicus, William Shakespeare
December 12, 2007 at 9:43 pm
You can probably do it with the sp_OACreate, but if you are in 2005 you are better off using a CLR function/procedure
December 12, 2007 at 10:21 pm
There is no way of doing it without going outside of SQL in some way, but there are several ways of doing.
My recommendation would be use xp_cmdshell with a simple directory command then extract the date stamp from the target file.
---
Timothy A Wiseman
SQL Blog: http://timothyawiseman.wordpress.com/
December 12, 2007 at 11:03 pm
timothyawiseman (12/12/2007)
There is no way of doing it without going outside of SQL in some way, but there are several ways of doing.
Ummm.... not quite true in 2k or 2k5, Timothy... try this just for grins 😉
EXEC Master.dbo.xp_GetFileDetails 'C:\Config.Sys'
--Jeff Moden
Change is inevitable... Change for the better is not.
December 13, 2007 at 7:33 am
this sp Master.dbo.xp_GetFileDetails only exists in SQL 2000
December 13, 2007 at 5:35 pm
Oh, crud... you're right... I just loaded 2k5 over the weekend and verified what you say to be true... it's not in 2k5... reportedly it was and I took someone's word for it. Thank you for the correction...
--Jeff Moden
Change is inevitable... Change for the better is not.
December 15, 2007 at 4:43 pm
Well, I stand corrected in 2K at least. I have only used 2K5 for a while now, but always good to learn things I didn't know before.
---
Timothy A Wiseman
SQL Blog: http://timothyawiseman.wordpress.com/
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply