How to read the file name , properties and insert the record in SQL Table

I have to read my daily log files which comes in the log folder from a third party application and make an entry in our log table as File Name, Date, File Folder Path.

How should i do this ? SQL has to run as a Trigger to read the folder on certain interval.
chokkaStudentAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lcohanDatabase AnalystCommented:
EXEC xp_dirtree 'C:\', 10, 1

You can get all into a #temp table and select * from it like:

CREATE TABLE #DirTree (
    Id int identity(1,1),
    SubDirectory nvarchar(255),
    Depth smallint,
    FileFlag bit,
    ParentDirectoryID int
   );

   INSERT INTO #DirTree (SubDirectory, Depth, FileFlag)
   EXEC master..xp_dirtree 'C:\', 10, 1;

SELECT * FROM #DirTree;

Obviously you can use a permanent table instead and I suggest use the code above in a SQL Scheduled job to check/populate the table periodically.
chokkaStudentAuthor Commented:
Is this in built stored procedure. master..xp_dirtree

Can we get the file name, date also along with  the file folder path
Jose TorresCertified Database AdministratorCommented:
If all you need to log is the file information write an powershell script which will parse the directory and insert the results to your table.  As much as I attempt to do everything in t-sql I have learned that sometimes there are other tools more suited for certain tasks although i generally reach that conclusion after several hours of hitting my head against the wall

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chokkaStudentAuthor Commented:
Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.