in my stored procedure I have a table variable contains rows ID. The are 2 scenarios – that table variable is empty and not.
declare @IDTable as table
(
number NUMERIC(18,0)
)
In the main query, I join that table:
inner join @IDTable tab on (tab.number = csr.id)
BUT:
as we know how inner join works, I need that my query returns some rows:
when @IDTable is empty
OR
return ONLY rows that exist in
@IDTable
I tried also with LEFT join but it doesn’t work. Any ideas how to solve it ?
If `@IDTable’ is empty then what rows do you return? Do you just ignore the Join on to the table?
I’m not sure I get what you’re trying to do but this might be easier.