Solved

SQL Server 2005: How do i get the value from a field till i reach a particular string like <style>?

Posted on 2008-10-10
4
164 Views
Last Modified: 2012-05-05
i would like to retreive part of a string which is in a column of data type ntext. The column has a lot of html. I would like to retrieve the part till i reach '<style>'.

Everything  before '<style>' should be retrieved.

Please suggest with syntax.

0
Comment
Question by:nirisan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 3

Expert Comment

by:3abqari
ID: 22692202
substring(column, 0, charindex(column, '<style>'))

or something similar to this
0
 
LVL 5

Accepted Solution

by:
varungd earned 500 total points
ID: 22692616
select substring(columnName, 0, charindex('<style>', columnName))from tablename
0
 

Expert Comment

by:Saji_klm
ID: 22693351
You can use
select substring(columnname,0,charindex('<script>',columnname)) from tablename.

But it will return null if the the column doesnot contain '<script'>. If u want those result to u can use the following code
select case substring(columnname,0,charindex('<script>',columnname))
when '' then columnname
else substring(columnname,0,charindex('<script>',columnname)) end
 from tablename
0
 

Author Comment

by:nirisan
ID: 22727356
perfect
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question