| Author |
Topic |
|
qchau_98
Starting Member
6 Posts |
Posted - 2002-03-26 : 10:29:02
|
| From a temp table with one column and insert it into mutiple columns. For example in my temp table the record would be 8,ProdNM, ProdDesc,ProdNum,UnitCost,totalCost with this I would like to use the parsing and insert into a new table with 6 columns(fields). Below I have a some code by it seen like not working propertly.Thanks in advance,Quan select left(Items, charindex(',', Items)-1) Qty , left(substring (Items, charindex(',', Items)+1, len(Items)- charindex(',', Items, charindex(',', Items)+1)), charindex(',', substring (Items, charindex(',', Items)+1, len(Items)- charindex(',', Items, charindex(',', Items)+1)))-1 ) ProdNM , left(substring (Items, charindex(',', Items)+1, len(Items)- charindex(',', Items, charindex(',', Items)+1)), charindex(',', substring (Items, charindex(',', Items)+1, len(Items)- charindex(',', Items, charindex(',', Items)+1)))-1 ) ProdDesc , left(substring (Items, charindex(',', Items)+1, len(Items)- charindex(',', Items, charindex(',', Items)+1)), charindex(',', substring (Items, charindex(',', Items)+1, len(Items)- charindex(',', Items, charindex(',', Items)+1)))-1 ) ProdID , right(substring (Items, charindex(',', Items)+1, len(Items)- charindex(',', Items, charindex(',', Items)+1)-1), charindex(',', substring (Items, charindex(',', Items)+1, len(Items)- charindex(',', Items, charindex(',', Items)+1)-1))-1 ) UnitCost , right(Items, charindex(',', reverse(Items))-1) TotalCostfrom A_Items |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-03-26 : 10:35:57
|
| You need to post:- The table structures for the source table (temp table) being SELECTed from- The table structures for the destination table being INSERTed intoAlso check these articles on CSV:http://www.sqlteam.com/SearchResults.asp?SearchTerms=csv |
 |
|
|
qchau_98
Starting Member
6 Posts |
Posted - 2002-03-26 : 12:07:25
|
I did look into that link, but couldn't fine what I am looking for. I need insert it into a column not rows. What I am tring to do is I had a web page with Multi-Items. A user can order multi-Items at the same time or one. Then it capture the value such as Qty,ProdID,ProdNM,ProdDesc, and ect. Bease on the Semicolon(;) it will insert Mutiple or single record into a temp table. From a temp table a value define by a comma(,) such as Qty,ProdNM,ProdDesc,ProdID, ect. From the Temp table it will insert into the actual table with the mutil-columns such as Qty, ProdNM, ProdDesc, and ect.Thanks in advance.quote: You need to post:- The table structures for the source table (temp table) being SELECTed from- The table structures for the destination table being INSERTed intoAlso check these articles on CSV:http://www.sqlteam.com/SearchResults.asp?SearchTerms=csv
|
 |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2002-03-26 : 13:08:15
|
| have to agree with Rob...."You need to post: - The table structures for the source table (temp table) being SELECTed from - The table structures for the destination table being INSERTed into "and even some sample data and expected results....works wonders in getting responses!!!! |
 |
|
|
|
|
|