title: TSQL - How do you search a column containing a string using another column?
body: <p>I am trying to isolate the school ID based on the most recent grade column.  This shows which schools a student is zoned for.  I'm not sure how to search a string based on a column result.  What's the best way to isolate the schoolid?</p>
  
  <p>Thank you.</p>
  
  <p><strong>Data:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/2WYLf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2WYLf.png" alt="enter image description here"></a></p>
  
  <p><strong>Desired Result:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/wNrtc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wNrtc.png" alt="enter image description here"></a></p>
  
  <p>SQL Fiddle code:  (I have trouble getting the schema to build without error.)</p>
  
  <pre><code>CREATE TABLE #T1 (
  StudentID varchar(10),
  AddressID varchar(10),
  SchoolID varchar(10),
  SchoolGrades varchar(100),
  MostRecentGrade varchar(10),
  )
  
  INSERT INTO #T1
  VALUES
  ('7777777','297','118','PK,KK,01,02,03,04,05,MG','10'),
  ('7777777','297','338','06,07,08,MG','10'),
  ('7777777','297','528','09,10,11,12,MG','10')
  
  SELECT *
  FROM #T1
  </code></pre>