Re: using if exists result?
Just iterate through result of query, if iteration count is zero then there were no records.
Re: using if exists result?
Something like this?
Code:
SELECT PatientNum FROM tabPatientRecords WHERE PatientNum = 'X'
IF @@ROWCOUNT = 0
SELECT PatientNum FROM tabPatientRecords WHERE PatientNum = 'PN1'
Re: using if exists result?
Haven't actually tried this and it's a bit on the cludgy side but I think you could use an ISNULL and Sub Selects:-
SELECT ISNULL(
(SELECT col1 FROM table1 where id = 1),
(SELECT col1 FROM table2 where id = 1))
if the record doesn't exist in table 1 the first subselect will return a null so the isnull will cause the second select to be run instead.