all groups > sql server new users > june 2005 >
You're in the

sql server new users

group:

best way to move files?


best way to move files? jwflutterby
6/29/2005 1:26:02 PM
sql server new users: I am new to SQL server but I need to figure out how to monitor the contents
of a folder then move files from this folder to another folder when a new
file shows up. I do have experience with VB script and VB.Net and have
created both a script and an exe that do what I need. The trouble is that
they need to be run automatically during off hours at like 5 minute intervals
and I am looking for the best way to accomplish this.

Once all of the files have been moved over, a SQL server agent job needs to
be executed so I started looking into how these work. I saw that jobs could
be scheduled to run at certain intervals and could run scripts so I thought
this could solve my other problem. The trouble is that though the script runs
fine independantly, when I plug it into a job it gives a path not found error
like it is looking for the path in the database rather than on the hard drive
of the server. I also see that jobs can run commands. I also have a VB.Net
exe that does the same function but I'm not sure how to communcate to the job
whether the file copy attempted by the exe actually found and moved a file or
not.

I have also played with a DTS package a little as well to create a daily
log. I'm wondering if maybe this is another possibility...

Basically I just need to know what would be the best way to approch this
task and how to overcome the obstacles I have encountered so far. Thanks in
Re: best way to move files? Stu
6/29/2005 5:30:37 PM
There's a lot of ways you could do this; you can use DTS and job
scheduling to run the procedure every minute or so, or you could create
a service in VB to watch a file folder, and when the file shows up,
move it over to another directory and kick off a job on SQL Server.
(Look at SQL-DMO for ways of programming jobs:
http://msdn.microsoft.com/msdnmag/issues/01/05/sqldmo/ )

The important thing to remember when it comes to SQL Server jobs is
that they run under the credentials of the SQL Server Agent service.
Check the service to see what account its running under; it usually
defaults to a local system account, which has limited permissions.

If you want to use DTS, you can do a lot of this file manipulation
followed by SQL action all in one package; I recommend you get a copy
of Professional SQL Server 2000 DTS (Data Transformation Services)
(Programmer to Programmer). It's the only book I'm aware of that
focuses on DTS; it's targeted for DBA's, so it may be a bit elementary
for a programmer, but it will give you a quick overview of how DTS
works.

HTH,
Stu
AddThis Social Bookmark Button