470,811 Members | 1,268 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,811 developers. It's quick & easy.

divide a string

Hi,
I have a string:
mystring="1234,5678,985,21544,55524,11264, ... ,"

How can I divide this string into
1234
5678
985
....
11264
....

And then delete records corresponding to these separated strings?

delete from mytable where id = '1234'
....
delete from mytable where id = '11264'
....

Thanks for any help.

Atse
Jul 19 '05 #1
4 3906
mystring = "1234,5678,985,21544,55524,11264, ... ,"
arrData = Split(mystring ,",")
For intCount = 0 To UBound(arrData )
Delete arrData (intCount )
Next

'This is not the most efficient way.
-dlbjr

Discerning resolutions for the alms
Jul 19 '05 #2
Got it, thanks

"dlbjr" <do******@do.u> wrote in message
news:BO1jb.136$Qy4.11340@typhoon01...
mystring = "1234,5678,985,21544,55524,11264, ... ,"
arrData = Split(mystring ,",")
For intCount = 0 To UBound(arrData )
Delete arrData (intCount )
Next

'This is not the most efficient way.
-dlbjr

Discerning resolutions for the alms

Jul 19 '05 #3
On Wed, 15 Oct 2003 01:34:25 GMT, "atse" <du******@yahoo.com> wrote:
Hi,
I have a string:
mystring="1234,5678,985,21544,55524,11264, ... ,"

How can I divide this string into
1234
5678
985
...
11264
...

And then delete records corresponding to these separated strings?

delete from mytable where id = '1234'
...
delete from mytable where id = '11264'
...

Thanks for any help.

Atse


If the id is a string, you will need to build a string of comma
delimited single quoted values.

Once you get the string, use the Split command to get an array of
values.

A(0) will = "1234"
A(1) will = "5678"
etc.

From here, cycle through the array appending to a string
t = t & "'" & a(x) & &"',"

Now use an SQL state ment like
"delete from mytable where id in (" & t & ")"

However, if your id values are numeric, you are basically there. Use
the same method generate the sql statement, substituting the original
string for t.
Jul 19 '05 #4
How about using the string in the SQL statement

DELETE FROM myTable WHERE ID IN(12,23,34,45)

Simpler than deleting one record at a time.

--
Manohar Kamath
Editor, .netBooks
www.dotnetbooks.com
"atse" <du******@yahoo.com> wrote in message
news:Bu*********************@news01.bloor.is.net.c able.rogers.com...
Hi,
I have a string:
mystring="1234,5678,985,21544,55524,11264, ... ,"

How can I divide this string into
1234
5678
985
...
11264
...

And then delete records corresponding to these separated strings?

delete from mytable where id = '1234'
...
delete from mytable where id = '11264'
...

Thanks for any help.

Atse

Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Jack Smith | last post: by
3 posts views Thread by Dan | last post: by
6 posts views Thread by Nobody | last post: by
5 posts views Thread by per.nordlow | last post: by
8 posts views Thread by Kevin | last post: by
1 post views Thread by Justin.Velazquez | last post: by
2 posts views Thread by programmo | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.