How to add the @id
parameter with Like
operator after +
sign in Stored Procedure?
My Query:
create procedure gen_report_sp(@id int)
as begin
insert into report select * from cache where id like (@id+’%’)
end
Image:
How to add the @id
parameter with Like
operator after +
sign in Stored Procedure?
My Query:
create procedure gen_report_sp(@id int)
as begin
insert into report select * from cache where id like (@id+’%’)
end
Image:
You are adding a "%" to an integer - is this what you want to do?
If so, you would need to cast your integer to varchar (or similar) - see this article: SQL LIKE condition to check for integer?
Failing that, you should rethink what the process is doing and maybe use
id >= @id
depending on what you actually want to do.