Click here to Skip to main content
15,884,628 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)

SQL
declare @param as varchar(max)
declare @Pattern as varchar(max)
set @param='1001-COAKPL-DL_VSP-FC_RU2-HYDRC-1001'
set @Pattern = '%' + @param + '%'
SELECT ROW_NUMBER() OVER (ORDER BY RouteId) AS [S.No.],RouteId,RouteSummary FROM Ops_Route_Master  WHERE RouteSummary LIKE @Pattern;



in the above , i want to split @param parameter with "-" and retrieve data from Ops_Route_Master using like operator..

please help me...
Posted
Comments
Zoltán Zörgő 2-May-13 8:47am    
So you want to split the @param by "-", run the query with every fragment, and get the union of all results? But all return only rownums. What is the exact purpose of this?

1 solution

SQL
declare @param as varchar(max)
declare @Pattern as varchar(max)
set @param='1001-COAKPL-DL_VSP-FC_RU2-HYDRC-1001'
set @Pattern = '%' +SUBSTRING( @param,1,4) + '%'
SELECT ROW_NUMBER() OVER (ORDER BY RouteId) AS [S.No.],RouteId,RouteSummary FROM Ops_Route_Master  WHERE RouteSummary LIKE @Pattern;
 
Share this answer
 
Comments
nsvrao 2-May-13 9:57am    
Thanks for your fast reply...
Actually my question is different...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900