title: Getting query / execution plan for dynamic sql in SQL Server
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/7359702/how-do-i-obtain-a-query-execution-plan">How do I obtain a Query Execution Plan?</a>  </p>
  </blockquote>
  
  
  
  <p>how can I see the execution plan in SQL Server 2005 for a dynamic sql that is executed? I cannot save any files on the computer where the database resides. Here's a small example:</p>
  
  <pre><code>declare @sqlcmd nvarchar(1000)
  declare @param1 nvarchar(14)
  
  set @param1 = '11111111%'
  set @sqlcmd = 'SELECT * FROM myTable WHERE customer_id LIKE @customer_id'
  EXECUTE sp_executesql @sqlcmd, N'@customer_id nvarchar(14)', @customer_id = @param1
  </code></pre>
  
  <p>So I would like to see the execution plan that actually is used for SELECT query.</p>