DECLARE @a TABLE ( col NTEXT )INSERT INTO @a VALUES('<p>test</p>')select replace(replace(CAST(col AS VARCHAR(max)),'<p>',''),'</p>','') FROM @a
if OBJECT_ID('tempdb..#') is not null drop table #; go create table # (x ntext); go insert into # values('<p>test1</p>,<p>test2</p>'); go select cast(x as xml).value('for $p in /. return data($p)','nvarchar(max)') from #; /* test1,test2 */
replace(replace('<p>test</p>,<p>test2</p>','<p>',''),'</p>','')
----------------
test,test2*/
存储过程调用 clr 程序集去处理,
select replace(replace('<p>test</p>','<p>',''),'</p>','')
select replace(replace('<p>test2</p>','<p>',''),'</p>','')
DECLARE @a TABLE
(
col NTEXT
)INSERT INTO @a VALUES('<p>test</p>')select replace(replace(CAST(col AS VARCHAR(max)),'<p>',''),'</p>','') FROM @a
if OBJECT_ID('tempdb..#') is not null
drop table #;
go
create table # (x ntext);
go
insert into # values('<p>test1</p>,<p>test2</p>');
go
select cast(x as xml).value('for $p in /. return data($p)','nvarchar(max)') from #;
/*
test1,test2
*/