Mina Gabriel
Mina Gabriel

Reputation: 25070

SQL select where like using query string

if i have these two complicated query strings

 ALM_frmTopAlarmHistoryReport.aspx?strAlarmConnection=AlarmSystem

AND

 http://1.1.4.1/xyz/ALM_frmAlarmHistoryReport.aspx?ViewPDF=
 1&dtmStartDate={0}&dtmEndDate={1}& + '&lngAlarmGroup=' + 
 $('#ddlAlarmGroup').val() + '&lngProcessor=' + $('#ddlProcessor').val() + 
 '&intCategory=' + $('#ddlCategory').val()

how can i excuete a select WHERE LIKE condition i tried

 SELECT * FROM [tablename] WHERE string1 LIKE '%string2%' 

and i got the following error

   Msg 103, Level 15, State 4, Line 1
   The identifier that starts with'%string2 ' is too long. Maximum length is 128.

any help will be very welcome thanks in advance

Upvotes: 0

Views: 166

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269445

Use locate or instr instead:

select *
from tablename
where instr(string2, string1)  > 0

Upvotes: 1

Related Questions