Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Links Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS SQL
Oracle
DB2
MS Access
MySQL
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» Sitemap
Free Newsletters:
DatabaseDaily  
News Via RSS Feed


follow us on Twitter
Database Journal |DBA Support |SQLCourse |SQLCourse2
 

Featured Database Articles

SQL Scripts & Samples

Posted Jul 20, 2001

sp_SetArchive

By DatabaseJournal.com Staff



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



SQL Scripts & Samples Archives

Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 




Latest Forum Threads
SQL Scripts & Samples Forum
Topic By Replies Updated
sql help!! add 1 August 22nd, 11:58 AM
How To Combine These 2 Queries into 1 Query ? tarek_land 1 June 7th, 08:37 AM
solving query svibuk 1 February 3rd, 06:08 AM
converting from a character string to uniqueidentifier saturnius 4 January 4th, 05:56 AM


















Thanks for your registration, follow us on our social networks to keep up-to-date