Home > Archive > MS SQL Server > October 2006 > Update with Left out join









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Update with Left out join
News.Microsoft.com

2006-10-24, 6:29 pm

Can I do an update to A based upon a left outer join with another table?

ex.
update tableA from tableA, tableB
left outer join tableB on tableA.fieldE = tableB.fieldE
set fieldC = 0 where tableB.FieldD is null

Bill


Arnie Rowland

2006-10-24, 6:29 pm

You could try something like: (untested)

UPDATE a
SET FieldC = isnull( b.FieldD, 0 )
FROM TableA a
LEFT JOIN TableB b
ON a.FieldE = b.FieldE


--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous


"News.Microsoft.com" <billgower@charter.net> wrote in message news:eyOF7v12GHA.3428@TK2MSFTNGP05.phx.gbl...
> Can I do an update to A based upon a left outer join with another table?
>
> ex.
> update tableA from tableA, tableB
> left outer join tableB on tableA.fieldE = tableB.fieldE
> set fieldC = 0 where tableB.FieldD is null
>
> Bill
>
>

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com