Hello,

Is there a way to use the if exists select statement result ?

for example:
Code:
IF EXISTS (SELECT col1 FROM table1 where id = 1)
  BEGIN
      SELECT col1 FROM table1 where id = 1
  END
  ELSE
  BEGIN
   -- select from other table
  END
in my example above I had to select the same data twice, one for checking if the data exists and then select it again to use it..

so is there a way to use the data i've already selected in the "IF EXISTS" clause ?

thanks and best regards.