title: What is the preferred way to extract SQL from a tbl_dbi as a string?
body: <p>I would like to extract the SQL from a tbl_dbi and save it as a character vector.</p>
  
  <p>I have tried</p>
  
  <pre><code>library(dplyr)
  my_tbl_dbi &lt;- tbl(conn, "myTable")
  
  my_query &lt;- capture.output(show_query(my_tbl_dbi), type = message) %&gt;%
      paste0(collapse = " ")
  </code></pre>
  
  <p>This worked for me in the past but now is not working, perhaps because I was playing around with the sink function. My question is "Is there a more robust/standard way to pull out the SQL query from a tbl_dbi or is what I am doing the only way to do it?"</p>