MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old April 22nd, 2004, 12:55 PM
sj1187534 sj1187534 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 13 sj1187534 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Periodical execution and global variables

Hi..I have table that has the following fields:

ID, S, M, T, W, Th, F, Sa, LW, LM, Tmp, Tot

I think you can guess what the first 8 fields stand for. The others:
LW - Last Week
LM - Last Month
Tmp - TempTotal
Tot - Total

What I want to achieve :
1) Once every week, I want to sum up the values for all days of week and store them in LW. And I want to store the sum of values for that month in the Tmp field.

2) Once every month, I want to update 'total' from 'tmp'.


What do you think is the best way to do it. I am not so convinced with the way I designed the table. If the design is OK, how can we perform the the required task periodically, like once every week and every month. I have an idea of using some sort of global variables but I have no idea of how to store a global variable in SQL server.

Thanks,
SJ

Reply With Quote
  #2  
Old April 23rd, 2004, 07:25 AM
punkisdead's Avatar
punkisdead punkisdead is offline
Moron
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Michigan, USA
Posts: 170 punkisdead User rank is Private First Class (20 - 50 Reputation Level)punkisdead User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 10 h 31 m 37 sec
Reputation Power: 5
I think you might want to look into DTS, which allows you to schedule jobs.

Reply With Quote
  #3  
Old April 23rd, 2004, 07:36 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 25th Plane (17000 - 17499 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,149 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 4 Days 14 h 39 m 56 sec
Reputation Power: 883
the best way to design the table is not to have fields like S, M, T, W, Th, F, Sa, LW, LM, Tmp, or Tot

i'm sorry, that only leaves ID

which you don't need either

what you do need is some kind of date field, and a quantity field

from those two fields alone, you should be able to extract wekkday numbers, weekly number, monthly numbers, etc.

never store into the database totals that can be calculated
__________________
r937.com | rudy.ca

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Periodical execution and global variables


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway