title: Is SQL code faster than C# code?
body: <p>Few months ago i started to work at this programming company. One of the practices they use is to do as much work as possible in SQL rather than C#.</p>
  
  <p>So, lets say i have this simple example of writing a list of some files:</p>
  
  <p><strong>Is something like this:</strong></p>
  
  <pre><code>string SQL = @"
      SELECT f.FileID,
             f.FileName,
             f.FileExtension,
             '/files/' + CAST(u.UserGuid AS VARCHAR(MAX)) + '/' + (f.FileName + f.FileExtension) AS FileSrc,
             FileSize=
             CASE
                 WHEN f.FileSizeB &lt; 1048576 THEN CAST(CAST((f.FileSizeB / 1024) AS DECIMAL(6, 2)) AS VARCHAR(8)) + ' KB'
                 ELSE CAST(CAST((f.FileSizeB / 1048576) AS DECIMAL(6, 2)) AS VARCHAR(8)) + ' MB'
             END
        FROM Files f
  INNER JOIN Users u
          ON f.UserID = u.UserID
  ";
  
  // some loop for writing results {
  //     write...
  // }
  </code></pre>
  
  <p><strong>Faster or better then something like this:</strong></p>
  
  <pre><code>string SQL = @"
      SELECT u.UserGuid,
             f.FileID,
             f.FileName,
             f.FileExtension,
             f.FileSizeB
        FROM Files f
  INNER JOIN Users u
          ON f.UserID = u.UserID";
  
  // some loop for writing results {
         string FileSrc = "/Files/" + result["UserGuid"] + "/" + result["FileName"] + result["FileExtension"];
         string FileSize = ConvertToKbOrMb(result["FileSizeB"]);  
  //     write...
  // }
  </code></pre>
  
  <p><strong>This particular code doesn't matter (it's just some basic example) ... the question is about this kind of thing in general</strong> ... is it better to put more load on SQL or 'normal' code?</p>