sp_SetArchive | Database Journal

sp_SetArchive

Jul 20, 2001
2 minute read

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:
sp_SetArchive



Disclaimer:
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

Database Journal Logo

DatabaseJournal.com publishes relevant, up-to-date and pragmatic articles on the use of database hardware and management tools and serves as a forum for professional knowledge about proprietary, open source and cloud-based databases--foundational technology for all IT systems. We publish insightful articles about new products, best practices and trends; readers help each other out on various database questions and problems. Database management systems (DBMS) and database security processes are also key areas of focus at DatabaseJournal.com.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.