Hi,
my stored accept a string parameter with the id (separated with comma) of the elements to filter . I convert this parameter into a temporary table (with only one column ID).
Now, i would that when the parameter isn't set the procedure returns all the elements from a table, when it is set (to one or more value) the procedure returns only the data that match that filter.
this is what i use now, but it's too slow.
SELECT col1,col2,...
FROM myTAB
WHERE (@id='' or exists(select ID from #tmpTab where #tempTab.ID = myTab.ID))
#temptab is filled with the value of the parameter @id.
How can i get the same result with better performance ?
thank you
my stored accept a string parameter with the id (separated with comma) of the elements to filter . I convert this parameter into a temporary table (with only one column ID).
Now, i would that when the parameter isn't set the procedure returns all the elements from a table, when it is set (to one or more value) the procedure returns only the data that match that filter.
this is what i use now, but it's too slow.
SELECT col1,col2,...
FROM myTAB
WHERE (@id='' or exists(select ID from #tmpTab where #tempTab.ID = myTab.ID))
#temptab is filled with the value of the parameter @id.
How can i get the same result with better performance ?
thank you