我的数据库中有一个字段的内容是:<pre>aabbccddee</pre>
我想显示的时候显示的是aabbccddee,请问SQL语句应该怎么写select substring(col , charindex('>' , col) + 1 , charindex('</' , col) - charindex('>' , col) - 1)
我想显示的时候显示的是aabbccddee,请问SQL语句应该怎么写select substring(col , charindex('>' , col) + 1 , charindex('</' , col) - charindex('>' , col) - 1)
set @str = '<pre>aabbccddee</pre>'select substring(@str , charindex('>' , @str) + 1 , charindex('</' , @str) - charindex('>' , @str) - 1)/*
--------------------------------------------------
aabbccddee(所影响的行数为 1 行)
*/
dawugui(潇洒老乌龟) ( ) 信誉:100
select substring(col , charindex('>' , col) + 1 , charindex('</' , col) - charindex('>' , col) - 1) from tb
======================================
服务器: 消息 536,级别 16,状态 3,行 1
向 substring 函数传递了无效的 length 参数。==========================================
select replace(replace('<pre>aabbccddee</pre>','<pre>',''),'</pre>','')这句行不通啊,是可以去掉<pre>可是数据是从数据库里提的,我怎么可能把aabbccddee加上去
from tb
where charindex('>' , col) > 0 and charindex('</' , col) > 0 and charindex('</' , col) > charindex('>' , col)