I have a stored proc with a basic query which is returned as a recordset.
However there are certain circumstances where the recordset may return no records. In which case i wish to execute anouther SQL db query instead. I wish to implement the 2nd query in the same stored proc how is this done?
My existing query is as follows.
The SQL i would like to run if the recorset is empty is something like this:
-Gus
However there are certain circumstances where the recordset may return no records. In which case i wish to execute anouther SQL db query instead. I wish to implement the 2nd query in the same stored proc how is this done?
My existing query is as follows.
Code:
ALTER PROCEDURE [dbo].[usp_CategorySectionGet]
@CategoryID int,
@SiteID int
AS
SELECT
[C].Section_ID,
[C].Section_Mask,
[S].SectionName
FROM
tblCategories AS [C]
JOIN
tblSections AS [S]
ON
[C].Section_ID = [S].SectionID
WHERE
[C].Category_ID = @CategoryID
AND
([S].SiteMask & @SiteID > 0)
The SQL i would like to run if the recorset is empty is something like this:
Code:
SELECT
[C].Section_ID,
[C].Section_Mask,
[S].SectionName
FROM
tblCategories AS [C]
JOIN
tblSections AS [S]
ON
[C].SectionMask_ID & [S].SectionMaskID
WHERE
[C].Category_ID = @CategoryID
AND
([S].SiteMask & @SiteID > 0)
-Gus