Something similar to this should work (not sure of the MSSQL syntax):

update table1 t1
set t1.date1 = '#currentdate#'
where t1.date1 is null
and exists (select 'x' from table2 t2 where t2.po = t1.po)

Dan


-----Original Message-----
From: Adrian Cesana [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 11, 2000 11:21 AM
To: [EMAIL PROTECTED]
Subject: SQL UPDATE


I am trying to update records where a field is NULL and another field from
that table matches to another field in a different table.  Im trying to use
somthing like this but it does not seem to work:

UPDATE table1,table2
SET table1.date1 = '#currentdate#'
WHERE table1.date1 IS NULL
AND table1.po = table2.po

I also noticed that table2.po could have several instances of the table1.po,
I guess this wouldn't matter, I just need to be sure that at least one match
exists.


This query will need to run every day, would it be better to make a Stored
Procedure and schedule it in MSSQL7 rather than scheduling it with CF....?
If I do run it in MSSQL7 what syntax do I use to get the current date...?

-Adrian


----------------------------------------------------------------------------
--
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to