×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
Enhance the WHERE clause of the base UPDATE statement (i.e. part that does
the EXISTance check), using Birgitta's example:
UPDATE TableA a
SET (a.Field1,
a.Field2, ... ,
a.FieldN) = (SELECT b.Field1, b.Field2, ... , FieldN
FROM TableB b
WHERE a.Key1 = b.Key1
and a.Key2 = b.Key2)
WHERE EXISTS (SELECT 1 FROM TableB c
WHERE a.Key1 = c.Key2
a.Key1 = c.Key2) AND
A.FIELD1 IS NOT NULL AND A.FIELD1 <> ' '
Check out the "Anatomy of a joined UPDATE" article on page 9 in this
Centerfield newsletter for a 400 centric SQL UPDATE illustration:
http://www.centerfieldtechnology.com/publications/archive%5CDecember%202006.
pdf
HTH, Elvis.
Celebrating 10-Years of SQL Performance Excellence
http://centerfieldtechnology.com/training.asp
-----Original Message-----
Subject: RE: SQL Gurus Wanted
Yeah, it's called RPG <grin>.
Yup - I wholeheartedly agree Joe. It is just that I keep hearing that SQL
is the answer to everything so I was trying to see how to use it here. It
is fundamentally a very simple task and yet I just couldn't see how to make
it work.
I'm still not seeing how your or Birgitta's solution identifies _which_
columns in A are empty (i.e. they are blanks or nulls) and only update them
from B when they are currently empty. But I'll try to get my head around it
this morning.
Thanks to both yourself and Birgitta.
Jon Paris
As an Amazon Associate we earn from qualifying purchases.