MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 23rd, 2004, 03:15 PM
Kadina Kadina is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: Pennsylvania, USA
Posts: 129 Kadina User rank is Sergeant (500 - 2000 Reputation Level)Kadina User rank is Sergeant (500 - 2000 Reputation Level)Kadina User rank is Sergeant (500 - 2000 Reputation Level)Kadina User rank is Sergeant (500 - 2000 Reputation Level)Kadina User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 6 h 3 m 58 sec
Reputation Power: 12
Send a message via AIM to Kadina
How to select string of specific pattern type

Hi,

I have a column in my table that is in the format %-_-___%.
Another way to think of it is 'junk1 dash char dash char char char char junk2'
Ex 1: 3gnrs9-C-5001 Late
Ex 2: 009-8-H63v-Terminated

What I need to do is return the part of the string that matches from the beginning up to the last wildcard. Or in other words 'junk1 dash char dash char char char char' Junk2 needs to be trimmed.
Ex 1 would return: 3gnrs9-C-5001
Ex 2 would return: 009-8-H63v

The first character of the last wildcard can be anything (number, letter, space, dash, ect). I've read the docs on MS SQL string functions, but can't seem to put them together to return what I need. I thought PATINDEX might work, but I need the index at the end of the pattern, not the beginning. I thought of using CHARINDEX, but the first char after the pattern is not static, so I cant search on it. LEFT wont work because the part before junk2 is not a static length.

I'll be using the returning string in the "ON" portion of a join. Any help or advice would be appreciated!

Thanks!

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > How to select string of specific pattern type


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway