Hi @NachitoMax ,
Welcome to Microsoft Q&A!
is there a specific order in which to prioritize the criteria in the WHERE clause?
Per my knowledge, the answer of above question is NO.
You could refer below updated one based on yours which you could also execute this procedure successfully even when @Size is null.
ALTER PROC [dbo].[usp_tbl_PartListSelect]
@Size varchar(100) = NULL,
@Type varchar(100) = NULL,
@CategoryID varchar(100) = NULL
AS
SET NOCOUNT ON
SET XACT_ABORT ON
SELECT [id], [part_number], [description], [size], [type], [categoryID]
FROM dbo.tbl_PartList
WHERE ([size] = @Size OR @Size IS NULL) AND ([type] = @Type OR @Type IS NULL) AND ([categoryID] = @CategoryID OR @CategoryID IS NULL)
You could validate above with more conditions and check whether it is also working.
If above is still not working, please post CREATE TABLE statements for your table together with INSERT statements with sample data. We also need to see the expected result after execution.
Best regards,
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.