title: How to write string to a text file inside an ms sql statement
body: <p>I am trying to write some log data about my queries to a text file. I tried lots of code scripts from the internet but they didn't worked. How can I write strings to a text file?</p>
  
  <p>I tried <a href="https://www.red-gate.com/simple-talk/sql/t-sql-programming/reading-and-writing-files-in-sql-server-using-t-sql/" rel="nofollow noreferrer">this</a> one.</p>
  
  <p>I am sure this was asked for couple times in the past and I saw them but could not find a proper answer for it. Thanks</p>