Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comma delimited,

Status
Not open for further replies.

ts2032

Technical User
Mar 26, 2002
115
US
hello all,

I have a webpage that stores changes to a table's cells. I store the changes in a javascript array and then pass them to a textbox as a comma delimited string. the string consists of multiple 4 value segments with each element separated by a comma. ie...
id,val1,val2,val3,id2,val1,val2,val3,id3,val1,val2,val3....

I know there is a limit to the number of characters a varchar can contain(8000 I think). My question is I want to pass this comma delimited string to a stored procedure that would update a table with the fields ID,VAL1,VAL2,VAL3. Is there some type of command that would allow me to pass a comma delimited string as a parameter?

Any help or suggestions would be appreciated.

tsmith
 
You can pass the comma delimted string as a varchar parameter easily enough. It is the parsing of the string that causes problems. SQL doesn't have an array data type.

There are several parsing scripts available for download from the WEB. Check the following.


If you have SQL 2000, you'll want to check out the fn_split function. It is described in an article on the MS web site. You can even download the code.

Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
 
Thanks Terry, I will try those.

tsmith
 
Hello!
This is so close to what I'm trying to do, and not being an SQL guy, yet :), I hope you can clarify the above functions.

Have a column that contains comma-delimited data and I'm looking for a UDF and/or a Query that will parse out the data and return it as seperate rows.

I've seen many pages like the links above, but I'm not able to pass a column name into the function, only static text.

So here’s what I have/want:

Current Table:
table1
ID Data

1 Dog, Cat, Cat in the Hat
2 Purple Rain, White Album, Candy
...


Data I want:
query1
ID Data

1 Dog
1 Cat
1 Cat in the Hat
2 Purple Rain
2 White Album
2 Candy


Any ideas?

Small words are appreciated, I'm no expert, but I'm learning!

Thank you!
-Andrew

alien.gif

[TAG]
anongod@hotmail.com
"Drawing on my fine command of language, I said nothing."
 
TSMith,

Since you are already using asp why not have the vbscript or javascript parse the data into the relevant column and the pass these values as seperate variables into a stored procedure?

"Shoot Me! Shoot Me NOW!!!"
- Daffy Duck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top