[dba-SQLServer] SPAM-LOW: Re: Is there a better way

jwcolby jwcolby at colbyconsulting.com
Sat Jul 4 09:22:34 CDT 2009


Yes, I guess so.  Thanks for that suggestion, it is much simpler.  Does the next case only execute 
if the first case fails?  Or does the (addrValid is null) pick up the fact that previous cases set 
AddrValid?

This syntax is nothing like VBA and so I am completely in the dark as to how to use it.

John W. Colby
www.ColbyConsulting.com


Stuart McLachlan wrote:
> Can't you use something like:
> 
> Update MyTbl 
> Set AddrValid =
> (CASE WHEN (ANK IS NOT NULL  THEN 'ANK'
> CASE WHEN (AddrValid IS NULL) AND (Addr Like 'PO%')  THEN 'PO'
> CASE WHEN (AddrValid IS NULL) AND (Addr Like 'MOVED%') THEN 'MOV'
> CASE WHEN (AddrValid IS NULL) AND (Addr Like '.........%') THEN '...'
> )
> 



More information about the dba-SQLServer mailing list