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

jwcolby jwcolby at colbyconsulting.com
Sat Jul 4 09:52:24 CDT 2009


Very cool.

Thanks Stuart!

John W. Colby
www.ColbyConsulting.com


Stuart McLachlan wrote:
> OK, that was very quick air code with lots of bugs.  This one is tested and actually works:
> 
> Update MyTbl 
>  Set AddrValid =
>    (CASE 
>         WHEN (ANK IS NOT NULL)  THEN 'ANK'
>         WHEN (AddrValid IS NULL) AND (Addr Like 'PO%')  THEN 'PO'
>         WHEN (AddrValid IS NULL) AND (Addr Like 'MOVED%') THEN 'MOV'
>    END)
> 
> It works like a VBA "Select Case" in that once a condition is met, it drops straight through to 
> the END
> 



More information about the dba-SQLServer mailing list