Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Filesystem data to SQL Server table ...

Posted on 2003-12-03
5
Medium Priority
?
364 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 60 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
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

670 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