title: How to use cross apply string split result to update a table in sql?
body: <p>I am trying to split a <strong>column('categories') of a Table 'movies_titles'</strong> which has string separated data values in it.</p>
  <pre><code>e.g:
  ID title     categories
  1  Movie A   Comedy, Drama, Romance
  2  Movie B   Animation
  3  Movie C   Documentary, Life changing
  </code></pre>
  <p>I want to split the comma delimited string and place each values in a separate rows and update the table</p>
  <pre><code>-- this query shows the splitted strings as I want it
  SELECT *
  FROM dbo.movies_titles
  CROSS APPLY
  string_split(categories, ',') 
  
  O/P:
  ID title     categories                   value
  1  Movie A   Comedy, Drama, Romance       Comedy
  1  Movie A   Comedy, Drama, Romance       Drama
  1  Movie A   Comedy, Drama, Romance       Romance
  2  Movie B   Animation                    Animation
  3  Movie C   Documentary, Life changing   Documentary
  3  Movie C   Documentary, Life changing   Life changing
  
  </code></pre>
  <p>I want to use UPDATE query to set the result obtained from <strong>value</strong> column. I just don't want to use SELECT query to view the result but permanently update the changes to the table. How do I achieve this in sql server?</p>