I have a stored procedure that will search the whole database. This is the procedure
CREATE PROCEDURE spGetSearchResults
@table varchar(50) = null,
@case varchar(50) = null,
@value varchar(100) = null
as
exec('Select * from ' + @table + ' WHERE ' + @case + 'like ''%'+ @value +'%''')
But for some reason it gives me an error Incorrect syntax near ‘%(value text)%’
but if i do a normal select statement with the values hard coded then it works fine
You’re missing some white-space. Put a space before
like…That said, this procedure raises a sql injection flag…