August 18, 2010 at 6:51 am
want to create a table from this data, if possible.
i used this to check the number of columns,
SELECT MAX(LEN(FieldName) - LEN(REPLACE(FieldName, ' ', '')) +1) FROM TableName
is there a way to check the position of the next value in a string that looks like this
10 0 0 2 2 0 2 2 (one row data)
24W 529 22 132 110 123 -13 516 (another row data)
3102 DENIM 8 99 0 213 213 0 213 312 (another row data)
row one doesnt contain a style number, so that column would need to be null, but row 3 has a style number. so it would populate the first column.
i could then use a standard substring to populate based on position.
August 18, 2010 at 7:26 am
this thread is a follow up to ny66's need to parse a substring into seperate fields:
http://www.sqlservercentral.com/Forums/FindPost967451.aspx
in that post, I had assumed the data was single-space delimited, based on the example data he posted, but did not get correct data when he applied it to his actual data.
in that thread, you didn't post the requested actual INSERT INTO data, which would show the specific problem you might be having with the parsing;
it appears that in addition to that issue, you are saying that sometimes the first substring(the "style") might be missing? how can you determine if it is missing or not? because there should be 10 fileds(9 spaces to delimit them?)
your first row example has only 8 fields/7 delimiters, so it appears 2 "fields" are missing....how can you know which are missing?
Lowell
August 18, 2010 at 12:52 pm
i know what is missing by looking at the data.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply