473,434 Members | 1,367 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,434 software developers and data experts.

how to split a row item n insert it in another table

hi
i have split the data using the split command now i want to insert the split data to be inserted into another table. there r many records in the previous table i want each record to be split and inserted into the other table one by one.....



25 123454756741 $GPRMC,093729.000,A,1301.7595,N,08015.2751,E,1.13, 69.84,080210,,*3E,BAUTO 0 3/9/2010 3:07:29 PM

i want to split the underlined data using "," and insert it into another table...
there r many such records i want to split each and every records and insert it to another table
Mar 22 '10 #1
6 3202
Soniad
66
Hi,

In SQL u can use CHARINDEX to split string.

check the following link :
http://www.databasejournal.com/featu...d-PATINDEX.htm

Regards,

"D"
Mar 22 '10 #2
Hi there,
i have split the underlined text using c# code now what i want is to insert it to another table but there would be several such records.
i want to split each record n insert it to another table.
Mar 22 '10 #3
ck9663
2,878 Expert 2GB
Is the text from a table? Or a form?

~~ CK
Mar 22 '10 #4
Hi CK

The text is from a table n not a form.
Mar 23 '10 #5
ck9663
2,878 Expert 2GB
Here's a pseudo-code...

1.. Parse your string on your SELECT statement using the comma as delimiter/identifier and the dollar sign as the marker to start the parsing.
2.Insert it using the INSERT INTO TABLE .... SELECT col1, ParsedColumnAlias FROM YourTable.

Happy Coding!!!

~~ CK
Mar 23 '10 #6
nbiswas
149 100+
Try this:

Solution 1(Using XQuery Approach)
Expand|Select|Wrap|Line Numbers
  1. DECLARE @xml as xml,@str as varchar(100),@delimiter as varchar(10)
  2. DECLARE @tblDestination(SplittedRecords varchar(100))
  3.  
  4.  
  5.  
  6. SET @str = '25 123454756741 $GPRMC,093729.000,A,1301.7595,N,08015.2751,E,1.13, 69.84,080210,,*3E,BAUTO 0 3/9/2010 3:07:29 PM'
  7. SET @delimiter =','
  8. SET @xml = cast(('<X>'+replace(@str,@delimiter ,'</X><X>')+'</X>') as xml)
  9. INSERT INTO @tblDestination
  10. SELECT N.value('.', 'varchar(10)') as value FROM @xml.nodes('X') as T(N)
OUTPUT

Expand|Select|Wrap|Line Numbers
  1. 25 123454756741 $GPRMC
  2. 093729.000
  3. A
  4. 1301.7595
  5. N
  6. 08015.2751
  7. E
  8. 1.13
  9. 69.84
  10. 080210
  11.  
  12. *3E
  13. BAUTO 0 3/9/2010 3:07:29 PM
Hope this helps
Mar 24 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Stu Cazzo | last post by:
I have the following: String myStringArray; String myString = "98 99 100"; I want to split up myString and put it into myStringArray. If I use this: myStringArray = myString.split(" "); it...
2
by: middletree | last post by:
Not really sure what the problem is, perhaps I am using split wrong. Page should get form fields form previous page and some of them will go into a tabel called Personal. Other items, to resolve...
3
by: twdo | last post by:
Let me see if I can explain my situation clearly. I have a table with the columns: answer_id, question_id, member_id, answer - answer_id is the primary key for the table. - question_id...
5
by: Willem | last post by:
Hello I am quite hopeless and of course a newbe. The situation: Sql2k / query I would like it ot break down the following string: 2004 Inventory:Ex.Plant Farm1:1st Cut:Premium:0094
1
by: gotcha | last post by:
I need to be able to split data such as this in a line: Part A23423 Price 45.00 into just this A23423 and put that into a form field that I can post. I have the following code, but I can't...
5
by: bu | last post by:
I have a database field that represents an item description and varying length. I am using the database to import the item description into another program (the other program is ODBC-aware ). The...
9
by: MrHelpMe | last post by:
Hello again experts, I have successfully pulled data from an LDAP server and now what I want to do is drop the data into a database table. The following is my code that will insert the data but...
1
by: clayalphonso | last post by:
Here is the code: <% dim testArray, testArray2 dim Conn, rs dim sSQL, sConnString 'response.write request.form("sel1") 'testArray = split(request.form("sel1"),",") 'for each gidstuff In...
1
by: Ben | last post by:
Hi, To simplify this request, we supposed this following sql script: "insert into table a values ('me;you','then'); insert into table a values ('you;me','so');" Note the semi-colon ( ; ) in...
21
by: bilgekhan | last post by:
After doing a succcessful insert() or find() on a set<Tcontainer is it possible to get the item number of this item in the set? (ie. its zero-based sequence number (position/location/rank/index)...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.