|
 |
sql_language thread: Parsing Names
Message #1 by henryh@p... on Thu, 28 Feb 2002 18:52:37
|
|
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C1C0AA.3D220EA0
Content-Type: text/plain
Here is a vbs/vb function that get the extension from a file name. Use this
structure and edit it for SQL. You might want to look up the following
things in BOL:
BEGIN
END
LEFT
RIGHT
CHARINDEX
WHILE
IF
ELSE
Function GetExtension(ByVal File)
Dim intPosit1, intPosit2
File = Trim(File)
' Check for a empty string
If Len(File) = 0 Then
GetExtension = ""
Exit Function
End If
' Intialise the position variables
intPosit1 = 0
intPosit2 = InStr(intPosit1 + 1, File, ".")
' Check that there was a "." in the string
If intPosit2 <> 0 Then
' Loop until we have the position of the last "." in the
string
Do
' We have reached the end of the string, and have
the position
If intPosit2 = 0 Then
Exit Do
Else
' Get the location of the next "."
intPosit1 = intPosit2
intPosit2 = InStr(intPosit1 + 1, File, ".")
End If
Loop
' Return empty string, there was no extension
Else
GetExtension = ""
Exit Function
End If
' If the . is the last character in the string
If intPosit1 = Len(File) Then
GetExtension = ""
Exit Function
Else
If intPosit1 = 0 Then
GetExtension = ""
Exit Function
Else
GetExtension = Right(File, Len(File) - intPosit1)
Exit Function
End If
End If
End Function
regards
David Cameron
nOw.b2b
dcameron@i...
-----Original Message-----
From: henryh@p... [mailto:henryh@p...]
Sent: Friday, 1 March 2002 5:53 AM
To: sql language
Subject: [sql_language] Parsing Names
OK here is the deal
I have a field called NAME
it contains "BOB JOE SMITH" or "BOB SMITH"
I need to know a script to go from the end of the name and go backwards to
get the last name out of it
Like to pull out "SMITH"
I can pull first name and I can pull middle and last together but i can't
get it to skip from the end to the front.
ANY HELP WOULD BE GREAT.
Thanks
Henry
$subst('Email.Unsub').
|
|
 |