Solved

Filesystem data to SQL Server table ...

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL query for highest sequence 4 63
SCOM to SQL port 14xx failed? 1 31
how to make geography query faster?  SQL 7 45
SQL Syntax 6 41
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

749 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