WEB开发网
开发学院数据库MSSQL Server MSSQL中Escape转义的使用 阅读

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

Tags:MSSQL Escape 转义

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接