IF OBJECT_ID('tempdb..#ABC') is not nulldrop table tempdb..#ABCcreate table #ABC(PATHNAME NVARCHAR(50))insert into #ABCSELECT N'/ABCDEFGHI' UNION ALL SELECT N'/ABCDGAFGASASSDFA' UNION ALL SELECT N'/ABCD' UNION ALL SELECT N'/ABCD/' UNION ALL SELECT N'/ABCD/JINJI' UNION ALL SELECT N'/ABCD/JINJI/MMMNNNN'UNION ALL SELECT N'XXXX/ABCD/JINJI/MMMNNNN'----查看PATHNAME中包含/ABCD/的记录SELECT * FROM #ABCWHERE PATHNAME LIKE N'%//ABCD//%' escape '/'
查询结果
PATHNAME--------------------------------------------------/ABCD//ABCD/JINJI/ABCD/JINJI/MMMNNNNXXXX/ABCD/JINJI/MMMNNNN