Please i have two different procedure but it is displaying same result
in the first procedure o.producttype='3' and s.active='1'
in the second procedure o.producttype='3' and s.active='0'
CREATE PROCEDURE [dbo].[cylin12002]
@SearchTerm VARCHAR(100) = '',
@PageIndex INT = 1,
@PageSize INT = 20,
@RecordCount INT OUTPUT
AS
BEGIN
SET NOCOUNT ON;
SELECT DISTINCT s.id, DENSE_RANK() OVER (ORDER BY s.[id] DESC) AS RowNumber,
c.[circumference],c.[colour],c.[posino],s.[no],s.[totalrev],o.[deliverydate],o.[purchaseorderno],o.[supplier],o.[waybillno],o.[comment],j.[pid],j.[description],s.active,o.producttype
INTO #Results
from [job_cylinder101] c
inner join stock101 s on s.typeid = c.id
inner join orders101 o on o.orderid = s.orderid
inner join job101 j on j.id= c.pid
where (o.producttype='3' and s.active='1')
AND (
(c.[circumference] LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (c.[colour] LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (c.[posino] LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (s.[no] LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (s.[totalrev] LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (c.id LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (j.[pid] LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (c.[posino] LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (j.[description] LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (o.[purchaseorderno] LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (o.[deliverydate] LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (o.[supplier] LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (o.[waybillno] LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (o.[comment] LIKE @SearchTerm + '%' OR @SearchTerm = '')
)
SELECT @RecordCount = Count(*) FROM #Results
SELECT * FROM #Results WHERE
RowNumber BETWEEN (@PageIndex-1)*@PageSize + 1 AND (((@PageIndex-1)*@PageSize + 1)+@PageSize)-1 OR @PageIndex = -1
DROP TABLE #Results
END
GO
/****** Object: StoredProcedure [dbo].[cylin12003] Script Date: 9/28/2021 1:12:52 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[cylin12004]
@SearchTerm VARCHAR(100) = '',
@PageIndex INT = 1,
@PageSize INT = 20,
@RecordCount INT OUTPUT
AS
BEGIN
SET NOCOUNT ON;
SELECT DISTINCT s.id, DENSE_RANK() OVER (ORDER BY s.[id] DESC) AS RowNumber,
c.[circumference],c.[colour],c.[posino],s.[no],s.[totalrev],o.[deliverydate],o.[purchaseorderno],o.[supplier],o.[waybillno],o.[comment],j.[pid],j.[description],s.active,o.producttype
INTO #Results
from [job_cylinder101] c
inner join stock101 s on s.typeid = c.id
inner join orders101 o on o.orderid = s.orderid
inner join job101 j on j.id= c.pid
where (o.producttype='3' and s.active='0')
AND (
(c.[circumference] LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (c.[colour] LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (c.[posino] LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (s.[no] LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (s.[totalrev] LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (c.id LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (j.[pid] LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (c.[posino] LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (j.[description] LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (o.[purchaseorderno] LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (o.[deliverydate] LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (o.[supplier] LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (o.[waybillno] LIKE @SearchTerm + '%' OR @SearchTerm = '')
OR (o.[comment] LIKE @SearchTerm + '%' OR @SearchTerm = '')
)
SELECT @RecordCount = Count(*) FROM #Results
SELECT * FROM #Results WHERE
RowNumber BETWEEN (@PageIndex-1)*@PageSize + 1 AND (((@PageIndex-1)*@PageSize + 1)+@PageSize)-1 OR @PageIndex = -1
DROP TABLE #Results
END
GO
please help