MSSQL中Escape转义的使用
2012-08-10 14:20:51 来源:WEB开发网核心提示:IF OBJECT_ID('tempdb..#ABC') is not nulldrop table tempdb..#ABCcreate table #ABC(PATHNAME NVARCHAR(50))insert into #ABCSELECT N'/ABCDEFGHI' UNIO
IF OBJECT_ID('tempdb..#ABC') is not null drop table tempdb..#ABC create table #ABC ( PATHNAME NVARCHAR(50) ) insert into #ABC SELECT 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 #ABC WHERE PATHNAME LIKE N'%//ABCD//%' escape '/'
PATHNAME -------------------------------------------------- /ABCD/ /ABCD/JINJI /ABCD/JINJI/MMMNNNN XXXX/ABCD/JINJI/MMMNNNN
更多精彩
赞助商链接