Here’s an SQL Script created to aid an archive process using DTS in SQL 7.0. The script works with both SQL Server 7.x & SQL Server 2000.

It has been designed with a specific function:

Spreadsheets containing source data are copied to a server, ready for import into a datawarehouse. The files are then moved, but kept on the same server. This script takes a table “filelist” (created from a piped DIR to a text file), and then changes the value of one column to be either 1 or null, depending on how long it has been since the file was last written to.

The first step prepares a table “tbl_date” to contain today’s date, and today’s date – 6 months. This can be any length of time you wish, just change the number of days taken off at the end of the GETDATE() function. It then updates the Archive_bit column in the filelist table (created as above).

Another DTS package then exports the filelist for those entries which have an archive_bit of 1, then uses Winzip to zip and move the spreadsheets to a different Server.

While quite complicated to explain, the script shows how the GETDATE() function can be used to create a deterministic value based on today’s date, then uses the calculated value in further processes.

Author: Richard Munn

Download Script:

We hope that the information on these script pages is
valuable to you. Your use of the information contained in these pages,
however, is at your sole risk. All information on these pages is provided
“as -is”, without any warranty, whether express or implied, of its accuracy,
completeness, or fitness for a particular purpose…

Disclaimer Continued

Back to Database Journal Home

Get the Free Newsletter!

Subscribe to Cloud Insider for top news, trends & analysis

Latest Articles