title: How to map a SQL profiler captured 'exec sp_executesql' to stored procedure name in sql server
body: <p>I have a huge SQL server database. I want to re-write an application. For that I want to reuse the database which has many tables, views and stored procedure. I am using SQL Profiler tool to map the application functionality to database. In Profiler, I am capturing </p>
  
  <pre><code>SP:Starting 
  SP:Completed 
  SP:StmtStarting 
  RPC:Completed
  SQL:BatchCompleted 
  SQL:BatchStarting
  </code></pre>
  
  <p>In my Profiler trace I have captured an <code>RPC:Completed</code> event class and the textdata contains </p>
  
  <blockquote>
    <p>exec sp_executesql N'Select Some query' @var=N'value'".</p>
  </blockquote>
  
  <p>What is <code>sp_executesql</code> and how can I know the exact name of the stored procedure called?</p>