特定の行を特定の順序で返すように SQL ストアド プロシージャを設定しただけです (重要度の高いものから低いものへ)。
-- 1st Level -> Query a more detailed object...
SELECT ... WHERE something
-- if a result is find, the SP is returning the correct row.
-- if rowcount = 0 then, the SP is returning an empty row
-- and continues with the next query (less specific than the 1st one).
IF @@ROWCOUNT = 0
BEGIN
SELECT .... WHERE something else...
-- Again, if a result exists, the SP returns the correct row, but also
-- the result of the 1st query is returned without rows...
IF @@ROWCOUNT = 0
BEGIN
SELECT .... WHERE something else again...
END
END
空でない行を返す SELECT ステートメントのみを返すオプションはありますか? 空の行を返したくありません...そして、行が最初のクエリの「サブレベル」であるたびに、正しい行の前に空の結果が得られます。
テーブル変数を作成することを考えていました。より良い方法はありますか?