title: Need help adding WHERE clause in pre-written SQL statement
body: <p>Preface: my SQL is rudimentary. I received a SQL query from a vendor, it selects and exports every single employee comment and other data from a few different DBs as CSV meant for import, it was written by them but they're not helping with this request. The query is pulling so much data it makes a large time consuming file for import. So I want to add to / modify the query to have a "WHERE date > whateverdate" to narrow my results to recent data. For example, I want to pull only comments entered in the past 2 days.</p>
  
  <p>The column I'm looking to add the clause for is the column "A.CMS502", defined as datetime. I believe this is the only relevant column in this query. An example date in this column is "2003-10-06 17:05:21.000". I am using SQL Server 2008 if it helps. Is it possible here? Thank you.</p>
  
  <pre><code>SELECT 
      'ID,Acct/LnNbr,NoteCreatedDate,CollectorId,ApplytoAll,Note'
  UNION ALL
  SELECT 
      ID + ',' + ID + ',' + NoteCreatedDate + ',' + CollectorId + ',' + 'No' + ',' + Note
  FROM
      (SELECT 
           CASE WHEN SUBSTRING(A.CMS301,LEN(A.CMS301),1) = 'S' 
                   THEN SUBSTRING(A.CMS301,1,LEN(A.CMS301) - 1) 
                   ELSE A.CMS301 
           END + '-' + 
           CASE WHEN SUBSTRING(A.CMS301,LEN(A.CMS301),1) = 'S' 
                   THEN 'S' ELSE 'L'
           END AS [ID],
           REPLACE(CONVERT(VARCHAR, A.CMS501, 10), '-', '') AS [NoteCreatedDate],
           CASE WHEN U.CMS1201 IS NOT NULL 
                   THEN U.CMS1205 + ' ' + U.CMS1204 
                   ELSE (SELECT CMS1205 + ' ' + CMS1204 FROM sysUSER WHERE CMS1201 = 'PSUSER')
           END AS CollectorId,
           CAST(A.CMS512 AS NVARCHAR(MAX)) AS [Note]
       FROM 
           ACTIVITY AS A
       LEFT JOIN 
           sysUSER AS U ON A.CMS503 = U.CMS1201
       WHERE 
           A.CMS504 NOT IN (411,500,511,711,804,900,901,903,907,2000,999777)
           AND A.CMS504 NOT BETWEEN 1102 AND 1199) AS S
  </code></pre>