Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Looking for pointers

Author  Topic 

Elmo5621
Starting Member

2 Posts

Posted - 2009-10-06 : 09:40:57
Hi all,

It is a long long time since I did any SQL and am looking for general information on how to achieve the following, I am guessing a stored proc

- I have a table with two dates, create date and maint date and guid
- I would like to read through the whole take and fing all records that were created today
- Once I have those I would like to update another table with the maint date where the two guids are equal
- I would like to run this on a regular basis i.e 04:00 but also have the ability to execute on the fly

Thanks in advance

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-10-06 : 10:07:39
UPDATE dt
SET maintDate = s.mainDate
FROM
DestinationTable d
INNER JOIN
SourceTable s
ON
d.guid = s.guid
WHERE
s.CreateDate >= dateadd(day,datediff(day,0,getdate()),0)
and s.CreateDate < dateadd(day,datediff(day,0,getdate()),1)

Jim


Everyday I learn something that somebody else already knew
Go to Top of Page

Elmo5621
Starting Member

2 Posts

Posted - 2009-10-06 : 10:12:53
Thanks Jim,

That seems a lot easier than I seem to remember, will give that a try

Cheers
Go to Top of Page
   

- Advertisement -