title: Sql server select - varchar containing column name and value
body: <p>I need to add a bunch of c# code to test values against a table. Connecting directly to the data source is out of the question (this needs to be static code).</p>
  
  <p>The output is </p>
  
  <pre><code>X.AddColumn("ColumnName",ColumnValue);
  </code></pre>
  
  <p>I would like to get a SQL statement that, for a table returns the above pattern, listing each column of a row, iterating through every row in the table.</p>
  
  <p>I was hoping for a select statement in the db that I could copy and paste result set of, ideally one that went through columns dynamically to save me doing something like below for each table I wish to output.</p>
  
  <pre><code>SELECT 'X.AddColumn("ColumnName1", ' + CONVERT(VARCHAR, ColumnName1, 100) +');' AS Col1
  ...
  'X.AddColumn("ColumnNameN", ' + CONVERT(VARCHAR, ColumnNameN, 100) +');' AS ColN
  FROM
  Schema.Table1
  </code></pre>