日期:2014-05-18 浏览次数:20471 次
create table #tmp(col nvarchar(10))--建表 go insert into #tmp select N'012³456789' union all select N'0123456789' select * from #tmp --查询 where charindex(N'³',col)<>0 --where col like '%³%'
WITH cte AS ( SELECT ROW_NUMBER() OVER ( ORDER BY col ) AS row , col FROM #tmp ) SELECT col FROM cte WHERE row IN ( SELECT row FROM ( SELECT a.row , SUBSTRING(a.col, b.number + 1, 1) AS col FROM cte a , master.dbo.spt_values b WHERE LEN(a.col) > b.number AND b.type = 'p' ) a WHERE UNICODE(col) = UNICODE(N'³') ) /* col ---------- 012³456789 (1 個資料列受到影響) */
------解决方案--------------------
create table #tmp(col nvarchar(10))--建表 go insert into #tmp select N'012³456789' union all select N'0123456789' select * from #tmp --查询 where charindex(N'³' COLLATE Chinese_PRC_CI_AS_KS_WS,col) > 0 drop table #tmp /************ col ---------- 012³456789 (1 行受影响) 排序规则,区分假名!