sql server - SQL LIKE with int -


is there equivalent like use varchar can used int?

i want filter 3 parameters, 2 of them varchar can use like , in case empty string still can retrieve records. how can achieve similar thing int

i want retrieve if fkproducttypeid doesn't exist: query:

select * product  code '%'+ @code +'%' ,  name '%'+ @name +'%' , fkproducttypeid = @ptype 

i want able retrieve results when supply id doesn't exist. front-end, if pass ' ' in @code,' ' in @name , 0 in @ptype want retrieve records

you use this:

select * product  code '%'+ @code +'%' ,  name '%'+ @name +'%' , (@ptype null or fkproducttypeid = @ptype) 

if it's in stored-procedure should use if ... else:

create procedure dbo.sp_name(@ptype int, @code varchar(1000), @name varchar(1000)) begin     if @ptype null     begin         select * product          code '%'+ @code +'%' ,  name '%'+ @name +'%'     end     else     begin         select * product          code '%'+ @code +'%' ,  name '%'+ @name +'%'         , fkproducttypeid = @ptype     end end 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -