Solved

Filesystem data to SQL Server table ...

Posted on 2003-12-03
5
344 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

840 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