I have a comments field that has certain values I want to extract into it's own field(new must be created). What is the syntax for doing this?
the data looks like this:
5321025 HOLLAND BL 60X210 20 Unts $5.91 Unt
5321032 HOLLAND BL 60X210 6 Unts $5.91 Unt
5321124 HOLLAND BL 120X210 13 Unts $8.64 Unt
your limited example data implies an order to the comments, so you could use the DelimitedSplit8K function
to split the values out to related rows, and insert/update based on that.
With MyCTE (Comments)
SELECT '5321025 HOLLAND BL 60X210 20 Unts $5.91 Unt' UNION ALL
SELECT '5321032 HOLLAND BL 60X210 6 Unts $5.91 Unt' UNION ALL
SELECT '5321124 HOLLAND BL 120X210 13 Unts $8.64 Unt'
CROSS APPLY dbo.DelimitedSplit8K(Comments,' ') T1
--help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!