Create Table 留言表
(id Int,
title Varchar(100),
content Varchar(1000))
Insert 留言表 Select 1, 'A', 'ABC<img src="1.jpg" width=xx height=xx>zz'
Union All Select 2, 'B', 'dsad'
Union All Select 3, 'C', 'KKK<img src="2.jpg" width=xx height=xx>'
Union All Select 4, 'D', 'MM<img src="3.jpg" width=xx height=xx>'
Union All Select 5, 'E', 'KKK'
select * from 留言表
GO
--測試
Select id, title,
(Case When CharIndex('<img src', content) > 0 Then
Stuff(content, CharIndex('<img src', content), CharIndex('>', content, CharIndex('<img src', content) + 1) - CharIndex('<img src', content) + 1, '')
Else content End) As content From 留言表
Gop