Thanks. I have that and this select hypathetically returns a code that I want to then say select value from table where (if not not exist .. etc) -< this returns a code I want to use in a where. This does not work.
A value I was to use in a where exists in 1 of two places (table). I need to check if it exists in table 1 use it otherwise check place 2 where it's guaranteed to be. The value returned from this I need to pass to a where clause. Has to be within a select statement and not transact sql.
I changed my code to a union but I still have 1 problem.
select col1 from tablea union select col1 from tableb
I need to apply precedence where if result is found in first select, I don't care about results from secomd select
I tried - select top 1 * from (select col1 from tablea union select col1 from tableb) but top 1 returned the highest value from col1 which is an int return type