Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 SQL Query Help !

Author  Topic 

sqldba20
Posting Yak Master

183 Posts

Posted - 2011-11-28 : 15:37:42
Folks:

I have a column with data type as 'ntext' and the data is in this format:

ColumnName
<div>TEST1</div>
<div>TEST3</div>
<div>TEST5</div>
<div>TEST4</div>
<div></div>

I want the output to be: How would be by Select statement?

ColumnName
TEST1
TEST3
TEST5
TEST4


Thanks !

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2011-11-28 : 16:12:06
There may be some clever XML solution that is much better than this:[CODE]select replace(replace(ColumnName, '<div>', ''), '</div>', '')
from MyTable[/CODE]OR, if you prefer[CODE]select SUBSTRING(ColumnName, 6, len(cast(ColumnName as nvarchar(max))) - 11)
from MyTable[/CODE]

=======================================
Faced with the choice between changing one's mind and proving that there is no need to do so, almost everyone gets busy on the proof. -John Kenneth Galbraith
Go to Top of Page
   

- Advertisement -