I have a query in sql that according to a combo search by families of the product, work shifts or code of a product, both the code and the work shift if I do the query but by the group or product family no. could you help me I'm a bit new to SQL
Here I declare a table variable to take the family code of the product and description
declare @in_producto as table
(
BOPRO_CODIGO nvarchar(50)
, BOPRO_DESCRIPCION nvarchar(90)
)
Here I make the query so that it will search according to a variable this variable come the values of the combo: Family code, product code, schedule
INSERT INTO @in_producto
SELECT BOPRO_CODIGO, BOPRO_DESCRIPCION FROM BO_PRODUCTO PRO
WHERE PRO.BOFPR_CODIGO = CASE WHEN ISNULL( @ou_Familia,'') = '' THEN PRO.BOFPR_CODIGO ELSE @ou_Familia END
AND PRO.BOPRO_CODIGO LIKE CASE WHEN ISNULL( @ou_Producto,'') = '' THEN '%' ELSE @ou_Producto END
OR PRO.BOPRO_DESCRIPCION LIKE CASE WHEN ISNULL( @ou_Producto,'') = '' THEN '%' ELSE @ou_Producto END
Then I insert it in a table to show the fields
SELECT
FROM #in_tablaTransaccion T with (nolock)
INNER JOIN @in_producto PRO ON T.BOPRO_CODIGO = PRO.BOPRO_CODIGO collate SQL_Latin1_General_CP1_CI_AS
Both filter per shift of work and product code if they are fine but for some reason that I do not find it by family does not filter me, they could help me thank you very much