0

I have a table, a column has something as it

EXECUTE grabaped '2013-11-19' , '1',921,45986,' 639 780 988 1018 1076 1868 2141' ,' 2 1 4 1 1 1 1',7,1,0,1,40,131

I want to get the bold text, but

EXECUTE grabaped '2013-11-19' , '1',921,45986, can to have N characteres

But always it is going to have 4 commas and always it is going to have 2 varchar and 2 int.

I have the column in table.

enter image description here

PowerStat
  • 3,757
  • 8
  • 32
  • 57
angel
  • 4,474
  • 12
  • 57
  • 89
  • just look into the string functions available to you... this should be fairly straightforward. what database are you using? – gloomy.penguin Dec 07 '13 at 00:11
  • As long as the varchars themselves don't contain commas, then use substring() to extract the string and use charindex() (once for each comma) to calculate the parameters for substring(). – acfrancis Dec 07 '13 at 00:17
  • http://stackoverflow.com/questions/8726111/sql-server-find-nth-occurrence-in-a-string – gloomy.penguin Dec 07 '13 at 00:20
  • http://stackoverflow.com/questions/12387559/select-from-3rd-comma-in-string?lq=1 – gloomy.penguin Dec 07 '13 at 00:21
  • first, find the position of the 4th comma. do a substring from that +1 to the end. in that substring, find the occurrence of the _second_ comma. do a substring from the start to the position of that (now) _second_ comma. – gloomy.penguin Dec 07 '13 at 00:22
  • or write a function. which would be easier. and just split the data up... you could even pass in a parameter that determines what index or indices get returned. you could either return the value or return a table format. it should only take 15-45 minutes depending on skills. – gloomy.penguin Dec 07 '13 at 00:25

0 Answers0