473,385 Members | 1,465 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,385 software developers and data experts.

How to find Uppercase text in a text field

1
I've a table column that stores the two digit uppercase state and city codes (example: FL for Florida; KC for Kansas City). I want to run a SQL query (not function or procedure) to extract these uppercase codes from the text.

Example: Here are 3 records showing values of the desciption column:

1. KC manufacutring unit provide LCDAD equipments.
2. All the tests are performed at FL unit.
3. The biggest TIN35 plant is in CA.

Here is the output I am trying to get:

State/City Description
---------- ---------------------------------------
KC KC manufacutring unit provide LCDAD equipments.
FL All the tests are performed at FL unit.
CA The biggest TIN35 plant is in CA.

I would greatly appreciate your time and input.

Thanks,
AN
Apr 6 '12 #1
2 2936
Rabbit
12,516 Expert Mod 8TB
Do you mean match a certain set of upper case two letter abbreviations? Or return any upper case two letter abbreviations?

Either way you will need to collate the field in the query as case sensitive if it's not already stored that way. You can use COLLATE SQL_Latin1_General_CP1_CS_AS to do that. Then you can use the PATINDEX() function to find the location. Now that you know where it occurs in the string, you can use the SUBSTRING() function to pull out the two letter code.

Whether or not you have a preset list of abbreviations will only affect how you set up the pattern to match.

There are some caveats like how to account for strings that don't have any such pattern or how to account for when the pattern occurs at the beginning or end of a sentence. But those can be worked out as we come to them. The important part is to get the main logic worked out.
Apr 6 '12 #2
You first need the field(s) to be case sensitive, as Rabbit mentioned, then you might want to list all the abbreviations in a separate table, then replace all non-alphabet characters with " " using a CLR function, adding " " to the front and back, then joining to your abbreviations table using a join condition that looks like field1 like "% " + field2 + " %".
Apr 7 '12 #3

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

Similar topics

13
by: Eddie | last post by:
I need to validate a text input field. I just want to say if user enters 93101 or 93102 or 93103 or 93105 or 93106 or 93107 or 93108 or 93109 or 93110 or 93111 or 93116 or 93117 or 93118 or...
2
by: Kai Grossjohann | last post by:
I would like to put a text input field (in the sense of <input type="text">) and an image next to each other, where I know the size in pixels of the image, and I know the total width in em. I...
5
by: simon_s_li | last post by:
Hi, I have 5 fields in line where I need to drag and drop the text from one field to another field and then all the fields need to re-order themselves. So for instance if I drag the text in...
1
by: Mike Moore | last post by:
I would like to set focus to a text box field on a user web control. Does anyone have suggestions on how I should approach this?
1
by: Mark | last post by:
Hello, Can anyone help me on how to find and replace text within a .txt file using vb.net? Any help would be greatly appreciated! Thanks in advance.
4
by: David Garamond | last post by:
What is "text + text" supposed to do right now? It doesn't seem very useful to me. What about making "text + text" as an equivalent for "text || text"? Most strongly-typed programming languages do...
3
mmarif4u
by: mmarif4u | last post by:
Hi everyone, I have a little problem in php coding. i have mysql table guestbook: Fields are Id,name,email,comment,datetime. Now i want to search the database by php query using a Dropdown menu...
2
by: Gozil | last post by:
Hello, im having a problem with the text input field im working with. I've made an ajax application that will suggest different links below the input field but if the user already searched something...
2
by: jerald m | last post by:
Hi, how can i pass the user input value of ( in text box field) to the another Jsp in url? Form Code <td> <input type="text" name="dil_ProjectCode" id="dil_ProjectCode"> </td>
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.