title: From .NET can I get the full SQL string generated by a SqlCommand object (with SQL Parameters)?
body: <p>From the .NET environment can I get access to the full SQL string that is generated by a <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.aspx" rel="noreferrer">SqlCommand</a> object? </p>
  
  <p><em>Note: The full SQL string shows up in Intellisense hover, in VisualStudio, while in debug mode.</em></p>
  
  <p>I'm willing to use reflection techniques if I must. I'm sure somebody here knows a way to get at it. </p>
  
  <hr>
  
  <p><strong>Update 1</strong>:<br>
  I'm calling a stored procedure having parameters with <code>cmd.CommandType = CommandType.StoredProcedure</code> and am trying to acquire the full SQL generated and run. 
  I wonder if the cmd.<a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.prepare.aspx" rel="noreferrer">Prepare()</a> method might not prove useful in this circumstance, if it might store the full string in a state field or something like that. </p>
  
  <hr>
  
  <p><strong>Update 2:</strong></p>
  
  <p>In light of answers below (and referenced) that indicate no complete SQL string is generated internally during preparation or execution, I did a bit of poking around using .NET Reflector.  Even the internal connection classes seem to pass objects rather than boiling them down to strings, for example:</p>
  
  <p>internal abstract void AddPreparedCommand(<strong>SqlCommand cmd</strong>);<br>
   Declaring Type: System.Data.SqlClient.SqlInternalConnection<br>
  Assembly: System.Data, Version=2.0.0.0   </p>
  
  <hr>
  
  <p>In general, thanks to everybody for the level of detail you got into to prove what can be done and show what's actually happening. Much appreciated. I like thorough explanations; they add surety and lend credence to the answers.</p>