MSSQL DTS Batch file

User avatar
Jezza
5StarLounger
Posts: 847
Joined: 24 Jan 2010, 06:35
Location: A Magic Forest in Deepest, Darkest, Kent

MSSQL DTS Batch file

Post by Jezza »

I have created a small DTS package in an old SQL 2000 database that is used to deactivate accounts that have not logged on for 90 days and as an audit requirement have to output the accounts that have been been nullified to a log file.

As the auditing was a later requirement after deployment I went the log file route and used the following code. My strategy was to create a temporary output file (expireduser.log) which contents would then be copied into archive log and then expireduser.log was deleted for next runtime, like so:

Code: Select all

copy H:\UserArchive\archive.log+H:\UserArchive\expireduser.log
del H:\UserArchive\expireduser.log
Outside of the DTS shell this works fine but as soon as I ran the DTS package it failed so I changed the batch file to

Code: Select all

type H:\UserArchive\expireduser.log >>H:\UserArchive\archive.log
del H:\UserArchive\expireduser.log
and it works fine.

The question is why? :shrug:
Jerry
I’ll be more enthusiastic about encouraging thinking outside the box when there’s evidence of any thinking going on inside it

User avatar
HansV
Administrator
Posts: 78633
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: MSSQL DTS Batch file

Post by HansV »

Mysterious - perhaps our resident BATch file expert can shed some light on it.
Best wishes,
Hans

User avatar
John Gray
PlatinumLounger
Posts: 5421
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: MSSQL DTS Batch file

Post by John Gray »

The only thing I would do would be to specify the destination explicitly, as in
COPY A+B A
although it shouldn't be necessary.

But then again, I don't know what a "DTS shell" is!
John Gray

"(or one of the team)" - how your hospital appointment letter indicates that you won't be seeing the Consultant...

User avatar
Jezza
5StarLounger
Posts: 847
Joined: 24 Jan 2010, 06:35
Location: A Magic Forest in Deepest, Darkest, Kent

Re: MSSQL DTS Batch file

Post by Jezza »

Thanks John,
One thought I had was when the DTS package runs it may be going "too fast" for the batch file and the ony thing I can think of is that COPY requires more time to complete than TYPE. I placed a delay in the steps of the package to see if that would work and again it failed to append to the file...weird.
Jerry
I’ll be more enthusiastic about encouraging thinking outside the box when there’s evidence of any thinking going on inside it