I have a query vhere user can select a product code from a drop dow list like:*AllV96V97V98Here is the query that is called:select l.[load] as Bol#, convert(char(10), l.date, 101) as Date, p.petroexcode as PetroEXCode, l.branded as Product, substring(p.name,1,30) as Name, cast(sum(l.gross) as decimal(15, 2)) AS GrossTotal, cast(sum(l.net) as decimal(15,2)) as NetTotalfrom [SFM-TP6000-1].TP6000.dbo.product as pinner join [SFM-TP6000-1].TP6000.dbo.loadcomp as l on l.branded = p.productwhere (@Product IS null or p.petroexcode = @Product) and (@DateFrom IS Null or l.date >= @DateFrom) and (@DateTo IS Null or l.date <= DATEADD(DAY, 1, @DateTo))group by l.[load], convert(char(10), l.date, 101), p.petroexcode, l.branded, p.name
Now user wants to expand the query options and be able to search by wild card. If user keys in V*, I need to query all product codes that starts with "V" (I guess using "like"). How can this be done using the existing query? The product code is passed to my stored procedure as a parameter.