我想将参数传递给存储过程但具有多个值并将其放置在 Where 条件中作为 IN (Values)
我的SP:
ALTER PROCEDURE [dbo].[GetPoliciesPageWise]
(
@PageIndex INT = 1
,@PageSize INT = 10
,@RecordCount INT OUTPUT
)
AS
BEGIN
SET NOCOUNT ON;
SELECT ROW_NUMBER() OVER
(ORDER BY [ID] ASC)AS RowNumber
,[ID]
,[PolicyNumber]
,[FileName]
,[FileBarcode]
,[BoxBarcode]
,[CityID]
,[DocTypeID]
,[ProdcutType]
,[CategoryID]
,[TotalImages]
,[PIN]
,[PolicyHolder]
,[IDNo]
,[BranchID]
,[IntroducerID]
,[IssueDate]
,[FilePath]
,[BranchName]
,[DocType]
INTO #Results
FROM dbo.Polices
SELECT @RecordCount = COUNT(*)
FROM #Results
SELECT * FROM #Results
WHERE RowNumber BETWEEN(@PageIndex -1) * @PageSize + 1 AND(((@PageIndex -1) * @PageSize + 1) + @PageSize) - 1
DROP TABLE #Results
END
我需要的是传递多个策略并基于此过滤结果。我也需要这个参数作为默认参数,如果它是空的,我需要选择而不将它插入到我正在使用 SQL Server 2008 R2 的 Where 条件中。