Solved

Filesystem data to SQL Server table ...

Posted on 2003-12-03
5
316 Views
Last Modified: 2007-12-19
Hi All.

How to scans "on-line" server filesystem directories (e.g. D:\Data\ and the subdirectories) and insert them to SQL server table? I need to have file list data as filename, modification date, size,... in SQL table.

I DON'T want to scan files every xy minutes but I want to create really "on-line" connection between filesystem and SQL server - when file is modified, data about this file in SQL Server record is changed immediately. Is there any system services or any COM components?

***

Or have anybody any tested script for scaning directory structure and insert data to table?

Thanks Martin
0
Comment
Question by:martin_mmj
  • 3
5 Comments
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 9865239
don't know of 1

but
declare table #t (dirdata varchar(8000))
insert into #t
 exec sp_cmdexec "Dir D:\*.*"

should do what you want....


you can set up a linked server to read actual text files ...  its described in BOL...  
0
 
LVL 18

Accepted Solution

by:
ShogunWade earned 20 total points
ID: 9865893
Personally I would do this by having a .NET service using the filewatcher to which will raise events when any thing happens.  then you can post the relevent details into SQL from the Service.

I do a similar thing for processing inbound FTP files automatically.
0
 

Author Comment

by:martin_mmj
ID: 9866253
And "xp_getfiledetails" and "xp_dirtree"? Is it possible to use for this problem? How to use it?
0
 
LVL 18

Expert Comment

by:ShogunWade
ID: 9866269
yes you could use these however, if as you are suggesting in your question "I DON'T want to scan files every xy minutes "  then how do you invoke SQL to perform if in an event driven mannor?  you cant.    

which is why I suggest a service using the filewatcher events.











0
 
LVL 18

Expert Comment

by:ShogunWade
ID: 10021186
Has your question been answered?   If so could you please close it.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

In this article—a derivative of my DaytaBase.org blog post (http://daytabase.org/2011/06/18/what-week-is-it/)—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now