sql - Take away the EXISTS but leave in the switch -
how can modify final script have exclusions switch? not want use exists
in final script:
select myfield = 'x' #data union select myfield = 'y' union select myfield = 'z' union select myfield = 'j' union select myfield = 'q' union select myfield = null; select myfield = 'j' #exclusions union select myfield = 'q' union select myfield = null; declare @showall tinyint = 1; -->>exceptions "switch" turned on data returned select * #data d @showall = 1 or ( exists ( select d.myfield except select myfield #exclusions ) ); --can simplify , rid of exists still include switch based on @showall ? select * #data d except select myfield #exclusions;
select * #data d except select myfield #exclusions @showall <> 1;
Comments
Post a Comment