arichins
01-15-2010, 02:35 PM
This is probably a simple solution, but I can't figure it out!
In T-SQL, stored procedure, want to tell it that if query A returns no results, use query B, otherwise use query A. My problem is, I cannot find the syntax for determining if a query returned records or not.
I'm doing this, because I have a Parent form with two subforms. One subform will always have a record with associated with item the user selected, but the 2nd will only have a record if the user manually adds it. And in access, if the source of a subform has no records, the form will not render. So I'm tricking it into rendering by linking it to a bs record, and then I'll write VB script to add the functionality to allow the user to create a new record from within the form.
if
( Select count(evalID)
from SFT_Safety_Requests_stopeval
where requestID = (@RequestID)
) = '0'
select *
from SFT_Requests_stopeval
where EvalID = '2'
else
(Select *
from SFT_Safety_Requests_stopeval
where requestID = (@RequestID))
In T-SQL, stored procedure, want to tell it that if query A returns no results, use query B, otherwise use query A. My problem is, I cannot find the syntax for determining if a query returned records or not.
I'm doing this, because I have a Parent form with two subforms. One subform will always have a record with associated with item the user selected, but the 2nd will only have a record if the user manually adds it. And in access, if the source of a subform has no records, the form will not render. So I'm tricking it into rendering by linking it to a bs record, and then I'll write VB script to add the functionality to allow the user to create a new record from within the form.
if
( Select count(evalID)
from SFT_Safety_Requests_stopeval
where requestID = (@RequestID)
) = '0'
select *
from SFT_Requests_stopeval
where EvalID = '2'
else
(Select *
from SFT_Safety_Requests_stopeval
where requestID = (@RequestID))