Author |
Topic |
pradeepmanne
Starting Member
31 Posts |
Posted - 2012-01-09 : 06:06:05
|
hi,i want to insert comma separated values into datatable tablefor example the comma saperated string like '123,char,456,varh'has to be inserted into table like using a storeprocedurecol1 col2,col3 col4123 char 456 varhThanks in advance |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-01-09 : 06:12:33
|
you need a string parsing function to parse the values and then put it into tablebut few questions before thatwill there be always 4 values? will they always go into the same table fields?in case there are multiple sets, how do you distingush end of a set of values?below you can find a typical string parsing functionhttp://visakhm.blogspot.com/2010/02/parsing-delimited-string.html------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
pradeepmanne
Starting Member
31 Posts |
Posted - 2012-01-09 : 06:15:52
|
hi,thanks for the replythe values will be changing but the tablename will be same |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-01-09 : 06:18:35
|
do you mean number of values will change?then how will you determine which values should go to which fieldit would be much better if you can explain scenario with sample data and final output------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
pradeepmanne
Starting Member
31 Posts |
Posted - 2012-01-09 : 06:21:59
|
hi ,the sequence of data for columns am using a arraylist in my front endthat list values i have converted into a comma saperate stringlist[0]=123list[1]=char..this is the commsaperate value '123,char,456,varh'col1 will be '123'col2 will be 'char' so on ... |
 |
|
NeilG
Aged Yak Warrior
530 Posts |
Posted - 2012-01-09 : 06:44:56
|
look on BOL for BULK INSERT Command that may help you |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-01-09 : 06:46:54
|
quote: Originally posted by pradeepmanne hi ,the sequence of data for columns am using a arraylist in my front endthat list values i have converted into a comma saperate stringlist[0]=123list[1]=char..this is the commsaperate value '123,char,456,varh'col1 will be '123'col2 will be 'char' so on ...
so is it always a single record values you pass?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
pradeepmanne
Starting Member
31 Posts |
Posted - 2012-01-09 : 07:09:32
|
Yes,each time a single record into a table |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-01-09 : 09:45:00
|
quote: Originally posted by pradeepmanne Yes,each time a single record into a table
then just use a parsing function like one posted in first link------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|