1
我有用於選擇行的存儲過程。我想一個參數傳遞到動態過濾行是這樣的:動態TSQL中的WHERE子句並阻止SQL注入
Create Procedure CustomerSelectAll
@FilterExpresion NVARCHAR(MAX)
DECLARE @CMD NVARCHAR(MAX)
SET @CMD = N'SELECT * FROM dbo.Customers '[email protected];
EXEC(@CMD)
上面的代碼工作正常,但它是在對SQL注入風險,所以我希望能夠通過多個列與任何WHERE語句,如:
exec CustomerSelectAll
@FilterExpresion = N' where Name = 'abc' and family = ''xyz'''
過濾表達式來自哪裏? – Joe