1

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:

enter image description here

Sathiya
  • 157
  • 1
  • 2
  • 10

1 Answers1

0

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.

Community
  • 1
  • 1
gsc_dba
  • 103
  • 8