all groups > sql server dts > july 2006 >
You're in the

sql server dts

group:

inserting a file list into a SQL table


inserting a file list into a SQL table jaylou
7/19/2006 12:26:01 PM
sql server dts:
Is there a way to grab all the file names in a directory and populating a SQL
table with them? I am trying to create 2 different jobs:
1) I want to get a list of all my backup files in my directory and move all
files over one week old to an archive folder.
2) I want to grab zip files that are over 3GIG and move them off to a
different folder as well.

I need a way to grab the files by name and also by size.
Is this possible?
TIA,
Re: inserting a file list into a SQL table jaylou
7/19/2006 1:44:01 PM
Thank you! That did it.

One thing use /B instead of /-C and there is no need for modification it
will only bring in file names.

Thanks again!
Joe


[quoted text, click to view]
Re: inserting a file list into a SQL table Roy Harvey
7/19/2006 4:25:32 PM
create table #dir (line varchar(255) NULL)

INSERT #dir
exec master..xp_cmdshell 'dir "C:\WINDOWS" /-C'

select *
from #dir
where line IS NOT NULL
and line NOT LIKE '%<DIR>%'
and substring(line,1,1) <> ' '

Using SUBSTRING and CONVERT against #dir.line I leave to you.

Roy Harvey
Beacon Falls, CT

On Wed, 19 Jul 2006 12:26:01 -0700, jaylou
[quoted text, click to view]
Re: inserting a file list into a SQL table Roy Harvey
7/19/2006 5:41:42 PM
On Wed, 19 Jul 2006 13:44:01 -0700, jaylou
[quoted text, click to view]

The original post indicated "I need a way to grab the files by name
and also by size" so I used a format that included the size. Certainly
of all you need is the name then /B is simpler by far.

AddThis Social Bookmark Button