title: How can I fix this SQL error on this query
body: <pre><code>DECLARE @providerIdList varchar(400)
  DECLARE @q varchar(400)
  
  SELECT @q  =  ''
  
  SELECT @providerIdList = '(1, 5, 15)'
  
  
  SET @q = 'SELECT u.Id FROM [user] u
      LEFT JOIN Provider p ON u.Provider_FK = p.Id
      LEFT JOIN  Providers2Users pu ON pu.user_FK = u.Id 
      LEFT JOIN Provider ap ON ap.Id = pu.provider_fk
      WHERE p.Id  IN ' + @providerIdList
  
  
  
  
  exec @q
  </code></pre>
  
  <p>Here is the exception that I am getting when I tried to execute query shown above</p>
  
  <hr>
  
  <pre><code>Msg 203, Level 16, State 2, Line 18
  The name 'SELECT u.Id FROM [user] u
      LEFT JOIN Provider p ON u.Provider_FK = p.Id
      LEFT JOIN  Providers2Users pu ON pu.user_FK = u.Id 
      LEFT JOIN Provider ap ON ap.Id = pu.provider_fk
      WHERE p.Id  IN (1, 5, 15)' is not a valid identifier.
  </code></pre>
  
  <hr>
  
  <p>I would really appreciate if somebody can point me the cause of these errors</p>