Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Chirpy
Starting Member
2 Posts |
Posted - 2007-04-17 : 17:29:25
|
Hi,I have a problem with importing text into a database.I have an application in .net where I fill a textbox with a certain text. When I press a button the text shall be separated and inserted into a database. The big question here is: how do I seperate the text so I get it into different colums in the database?I know there is someting called InString, should I use this or is there an other way? I was thinking I could use a stored procedure.Thanks in advance. |
|
mfemenel
Professor Frink
1421 Posts |
Posted - 2007-04-17 : 19:28:27
|
That depends a lot on how your data is formatted in the text box. Is it delimited by something or is it just a big block of text. If it's just a big set of text then pass it in with an ado object to the database via a stored procedure that takes a text parameter and call it a day. If it's delimited data then do the same thing but write a stored procedure to break apart the text based on that delimiter. If you can provide an example of the data for folks here that wouldd be helpful we can probably give you a more accurate answer.Mike"oh, that monkey is going to pay" |
 |
|
Chirpy
Starting Member
2 Posts |
Posted - 2007-04-18 : 02:33:46
|
Ok, here is a taste of how the text looks like (The bold text is the different colums I have in the db):KTH:25732230 KUNDNR KONTONR KDAG TRANSBEL KASSALÖPNR IDNR NAMN VDAG HANDL /KUNDANSV PRODUKT 2120-294790 82578 36189552 070416 1.118.388,76 990000000000 190342Pelle Nykvist 070417 N257TRB/B257JAN TKK06601558796-5698 82578 38447488 070416 533.966,00 990000000000 187952Gert Stenberg 070417 N257TRB/B257JAN PMK02401 |
 |
|
mfemenel
Professor Frink
1421 Posts |
Posted - 2007-04-18 : 16:10:29
|
If the space is what's delimiting your values then I'd reccomend passing the string to your stored procedure and then parsing the string based on the space. Charindex or Split would be useful methods for accomplishing this.Mike"oh, that monkey is going to pay" |
 |
|
|
|
|