You are here: Update Query containg static data and data from another table. « MsSQL Server « IT news, forums, messages
Update Query containg static data and data from another table.

Posted by holmm on 10/04/76 11:59

Hi,

First post so apologies if this sounds a bit confusing!!

I'm trying to run the following update. On a weekly basis i want to
insert all the active users ids from a users table into a timesheets
table along with the last day of the week and a submitted flag set to
0. I plan then on creating a schduled job so the script runs weekly.
The 3 queries i plan to use are below.

Insert statement:

INSERT INTO TBL_TIMESHEETS (TBL_TIMESHEETS.USER_ID,
TBL_TIMESHEETS.WEEK_ENDING, TBL_TIMESHEETS.IS_SUBMITTED)
VALUES ('user ids', 'week end date', '0')

Get User Ids:

SELECT TBL_USERS.USER_ID from TBL_USERS where TBL_USERS.IS_ACTIVE = '1'

Get last date of the week
SELECT DATEADD(wk, DATEDIFF(wk,0,getdate()), 6)

I'm having trouble combing them as i'm pretty new to this. Is the best
approach to use a cursor?

If you need anymore info let me know. Thanks in advance.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация