473,378 Members | 1,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Strip out part of a text field in sql 2008 to leave the required part only

How can you remove a part of a text field in sql but leave the section that is needed such as
Expand|Select|Wrap|Line Numbers
  1. the cat went up the hill: the dog followed on behind    the mouse went the other way
(4 spaces between 'behind' and 'the mouse')

'the cat followed on behind' is the only bit I need

Also need to add that the text field varies in length so need to use ':' and ' the mouse' to identify the beginning and end
Oct 21 '13 #1
2 1542
Rabbit
12,516 Expert Mod 8TB
You can use the CHARINDEX function to find the location of those strings and the SUBSTRING function to extract the parts you need.
Oct 21 '13 #2
SimMed
2
Expand|Select|Wrap|Line Numbers
  1. DECLARE @X NVARCHAR(MAX) = 'the cat went up the hill: the dog followed on behind the mouse went the other way'
  2.  SELECT SUBSTRING(@X,0,8)+ SUBSTRING(@X,33,20)+ ': '+SUBSTRING(@X,55,9)
Something like that?
Oct 30 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Matthew Sickler | last post by:
I have a text field that contains abstract information formated in HTML, I'd like strip the HTML and insert the data in another Text field within a DTS package. Is this possible? any...
7
by: Rick Caborn | last post by:
Does anyone know of a way to execute sql code from a dynamically built text field? Before beginning, let me state that I know this db architecture is built solely for frustration and I hope to...
1
by: Barry | last post by:
Retoring Caret Position after text field correction -------------------------------------------------------------------------------- Hi, my code has the following form - function...
4
by: mitch-co2 | last post by:
What I am trying to do is when someone clicks on the YES radio button I want the text field called MYTEXT to equal the text field named DATE. The below code works as long as I do NOT UN-COMMENT...
4
by: Chuck | last post by:
Hello, I have an Access XP database that has several fields. One of the fields is a text field and has an account number that is preceeded by a text character, like: F102354. Every account...
1
by: MemphiDoug | last post by:
In my email field, I want to query only the aol.com users. I have tried ="**", I have tried LIKE "**", I have tried just "aol.com" I can't figure out how to have it give me only the people that...
8
by: Lyn | last post by:
Hi, Can anyone tell me how the initial value displayed in Combo Box is determined when a form is opened? I am loading the dropdown from one field ("CategoryName") of a table, with "ORDER BY ". ...
4
by: steph | last post by:
Hello, I've got a text field in an access form (Microsoft Access 2002, SP3), that the user has to fill out. Now I don't want the user to leave this field (and this record) until he has filled...
4
by: whitej77777 | last post by:
I am trying to write a user defined function that will allow me to strip off the last carriage return and line feed from a text field. We have address fields stored in a text field for our ERP...
4
anurag275125
by: anurag275125 | last post by:
Hello, can anyone please tell me how can I create a input text field in form that can only accept numbers. thanks
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.