|
-
Jan 23rd, 2004, 09:20 AM
#1
Thread Starter
Member
Pattern Matching Query in SQL
I have the following query
SELECT PATINDEX('%[A-Z][A-X0-9][0-9]% [0-9][A-Z][A-Z]', LTRIM(RTRIM(Address))), Address, IDNumber
FROM <MYTABLE>
What I want to be able to do is ensure there is white space before the first part of my PATINDEX , PATINDEX('[A-Z]….
I’ve tried
PATINDEX(' [A-Z]….
PATINDEX('%[A-Z]….
PATINDEX('% [A-Z]….
PATINDEX('[ ][A-Z]….
What I want to ensure is that the PATINDEX doesn’t look in the middle of a word and find a match, which is what it is currently doing.
I'm using SQL Server 2000.
Thanks
Last edited by Gin_bee; Jan 23rd, 2004 at 09:52 AM.
-
Jan 23rd, 2004, 10:52 AM
#2
Thread Starter
Member
Managed to work around problem but would be interested to know if any of you know how to solve this issue. Suspect the problem may be to do with leading whitespace.
-
Jan 23rd, 2004, 08:40 PM
#3
Hyperactive Member
Assuming you want this kind of white space noise ( tab, CRT, vtab, page, LF, etc.)
and those that match your lead criteria in position one, this may give you an idea.
Code:
patindex('%[' char(9) + char(10) + char(11)+ char(12)+ char(13) + char(32)
+ char(160) + '][A-Z][A-X0-9][0-9]% [0-9][A-Z][A-Z]', ' ' + RTRIM(Address)), ...
HTH.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|