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
162 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Parsing the XML data to SQL Server 4 70
Replace Dates in query 14 55
Addition to SQL for dynamic fields 6 56
How do I subtract date and time within a same column in SQL 4 50
I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

756 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