How to write storedprocedure for search?
I have one tabe Name Product
ApplicationId uniqueidentifier
ProductId int
ProductTypeId int
ProductCode nvarchar(100)
ProductName nvarchar(max)
ProductFor nvarchar(max)
summary nvarchar(max)
Price money
TaggedPrice money
Keyword nvarchar(max)
Active Bit
My requirement is i want to write single procedure for search based on productCode,ProductName,ProductFor.
I have written for one search based on Productname
create procedure search
@ApplicationId Uniqueidentifier,
@Search nvarchar(max)
@Active Bit
As
Begin
select @searchLike=CASE WHEN @Search <> '' THEN 'AND product.productName LIKE ''' +@Search+'%' '' ELSE '' END
EXEC ('SELECT ProductId,ProductName from Products where ApplicationId=''' @Application+''' AND Active=''' +@Active+''''+
@searchLike+' order by productid')
ENd
but i want to write for three Fields single proc.(Productname,ProductFor,ProductCode)
plz help me
Thanks inadvance