我正在使用存储过程在我的数据库中搜索并筛选参数上的结果,我需要筛选未知的多个参数。在SQL Server中处理多个参数
我该如何编写一个处理这个问题的存储过程?
这里是我的存储过程:
CREATE PROCEDURE ComplaintRefListOnDistrict
@District nvarchar(max) = ''
AS
BEGIN
SET NOCOUNT ON;
SELECT
ComplaintFullID, CustomerName, Customer_Address, CustomerEmail,
Date, ContractID, CustomerPhoneNumber,ID, Complaintreference_ID, State
FROM
dbo.ComplaintsSmartObject
LEFT JOIN
dbo.UsersDistricts ON dbo.UsersDistricts.District = dbo.ComplaintsSmartObject.District
WHERE
(dbo.UsersDistricts.District = @District)
END
GO
谢谢!
你的意思是,如果@District包含“dist1,dist2”,以及如何获得基于此结果? – 2014-09-25 10:05:49
通过存储过程中的参数,我们指输入/输出参数。就像你的情况一样'@District'是输入参数。当你说多个参数时,我相信你是指@District中的多个和未知值。如果这是正确的,那么请分享您希望传递给此sproc的字符串。 – Deepshikha 2014-09-25 10:30:44
是啊! – 2014-09-25 10:30:47