title: Iterate through a list of string in sql and assign as a variable
body: <p>I have a list of strings which I would like to iterate and set as a variable in sql, I want to iterate a list of these strings ["one","two","three","four"] and then set each of these strings as a variable for a query. I have tried the following:</p>
  
  <pre><code>Declare @Ids Table (id integer primary Key not null)
  Insert @Ids(id) values(81570517139)
  Insert @Ids(id) values(81676666808)
  Insert @Ids(id) values(81496685880)
  Insert @Ids(id) values(81596620831)
  Insert @Ids(id) values(81254409851)
  Insert @Ids(id) values(81641592011)
  Insert @Ids(id) values(81690996037)
  Insert @Ids(id) values(81121685039)
  Insert @Ids(id) values(81527008494)
  Insert @Ids(id) values(81174933036)
  Insert @Ids(id) values(81081564187)
  
  Declare @Id Integer
  While exists (Select * From @Ids)
  Begin      
      select fileName
      from MarketMessage as a LEFT JOIN MessageType310 as b ON a.MarketMessageID = b.MarketMessageID
      where b.MPRN = @id
  End
  </code></pre>
  
  <p>But I am getting 'Arithmetic overflow error converting expression to data type int</p>