Hi,
I have a query that returns the following columns:
Col1 (varchar)
Col2 (varchar)
Col3 (int)
Col1 contains a comma-delimited list of values, e.g., "27664,34874,43409,49887".
How do I extract and return the value of the first item from the list (Col1)? For example, 27664.
NOTE: Not all rows return a list of values in Col3. In other words, certain rows may return only one value, e.g., 12345; some may return NULL. I've tried to use a combination of CHARINDEX searching for "," and SUBSTRING() but have been getting an error.
Please provide SQL statement.
Thanks a lot.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
This award recognizes a member of Experts Exchange who has made outstanding contributions to the community within their first year as an expert. The Rookie of the Year is awarded to a new expert who has the highest number of quality contributions.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.