need a bit of help with this sql injection issue:
The following is a version of a parameterised stored procedure. Excluding how it is called from an application, is there anyway to prevent @v_string from being treated as dynamic SQL?
I think this is fairly water tight - there's no execute or concatenated sql, but still inserting a semicolon allows additional data to be returned.
I know there are multiple levels to consider this question on, but I want to know if there is some simple solution I am missing here as the majority of injection fixes involve dynamic queries.
create table dbo.Employee (EmpID int,EmpName varchar(60))
declare
@v_id int,
@v_string varchar(60)
begin
set @v_string='test'''; waitfor delay '0:0:5' --
if @v_id is null
begin
set @v_id = (select EmpID
from Abc.Employee
where EmpName=@v_string);
end
print @v_id
end