title: dynamic query return zero value
body: <p>i am trying to return some result from my table but my query return none result</p>
  
  <p>here is how i execute my stored procedure</p>
  
  <pre><code>EXEC spLog '145',' ','2531'
  </code></pre>
  
  <p>and this is my stored procedure example, the concert is the same, return some value from my table</p>
  
  <pre><code>Created Procedure spLog
   @logID nvarchar(400),
   @logAction nvarchar(400),
   @userId nvarchar(400)
  AS
  Begin
  DECLARE @query nvarchar(4000)
  
  if(LEN(@logID)&gt;0)
  BEGIN
  SET @query = @query + 'Select * From LogTable where logID in ('+@logID+') AND userID = '+@userId + ''
  END
  if (LEN(@logAction)&gt;0)
  BEGIN
  SET @query = @query + 'Select * From logAction where logAction in ('+@logAction+') AND userID = '+@userId + ''
  END
  
  EXEC sp_executesql @query
  
  END
  </code></pre>
  
  <p>the column naming and table naming is just an example, ignore it, my 2 table consist of item that i want but my return result was none, it should return me something instead of none =(</p>
  
  <p>my expected result is [logTable result]+[LogAction result] or [logTable result] or [LogAction result]</p>