M
Max
Hi,
I have the following problem. In one table in Access db I have a field
(Name) which is a combination of "LastName FirstName". I am trying to
split this field and insert data into another table in two different
fields. I want to accomplish this with SQL in VB.
The problem is that sometimes FirstName(which will always be 1 char)
may not exist. So I might have something like this "Williams J" or
just "Williams".
So something like this won't work since I don't know if there is a
space after LastName or not:
"INSERT INTO table2 (LAST_NAME, FIRST_NAME) " & _
"SELECT " & _
"Left$([FULL_NAME], InStr([FULL_NAME], ' ')-1), " & _
"Right$([FULL_NAME], Len([FULL_NAME]) - InStr([FULL_NAME], ' ')) " & _
"FROM table1"
Can somebody please tell me if it is possible to do this test using
just SQL statement or do I have to fetch my table into a recordset and
spit it there.
Also VB complains about that -1 (or - InStr) that I have in my example
can you tell me what would a correct syntax be here.
Thanks for your help!
I have the following problem. In one table in Access db I have a field
(Name) which is a combination of "LastName FirstName". I am trying to
split this field and insert data into another table in two different
fields. I want to accomplish this with SQL in VB.
The problem is that sometimes FirstName(which will always be 1 char)
may not exist. So I might have something like this "Williams J" or
just "Williams".
So something like this won't work since I don't know if there is a
space after LastName or not:
"INSERT INTO table2 (LAST_NAME, FIRST_NAME) " & _
"SELECT " & _
"Left$([FULL_NAME], InStr([FULL_NAME], ' ')-1), " & _
"Right$([FULL_NAME], Len([FULL_NAME]) - InStr([FULL_NAME], ' ')) " & _
"FROM table1"
Can somebody please tell me if it is possible to do this test using
just SQL statement or do I have to fetch my table into a recordset and
spit it there.
Also VB complains about that -1 (or - InStr) that I have in my example
can you tell me what would a correct syntax be here.
Thanks for your help!