title: Find All Consecutive Dates in SQL
body: <p>I am having trouble figuring out a query to only display consecutive dates (minimum 3) in SQL. After searching stack exchange, there are a few solutions but I can't get them to work exactly how I want it to. Consider the following table (actual data and table names changed for security):</p>
  
  <pre><code>code         food         date   
  ------       ------      ------
  ABC123       Sushi       09/28/2013
  ABC123       Sushi       09/29/2013
  ABC123       Sushi       09/30/2013
  ABC123       Sushi       10/01/2013
  BCD234       Burger      10/05/2013
  BCD234       Burger      10/10/2013
  BCD234       Burger      10/27/2013
  BCD234       Fries       10/05/2013
  BCD234       Fries       10/06/2013
  BCD234       Fries       10/10/2013
  CDE345       Steak       10/15/2013
  CDE345       Steak       10/16/2013
  CDE345       Steak       10/17/2013
  CDE345       Steak       10/19/2013
  CDE345       Steak       10/20/2013
  DEF456       Pasta       09/05/2013
  DEF456       Pasta       09/06/2013
  DEF456       Pasta       09/10/2013
  DEF456       Burrito     09/09/2013
  DEF456       Burrito     09/10/2013
  DEF456       Burrito     09/11/2013
  </code></pre>
  
  <p>Only this should be displayed:</p>
  
  <pre><code>code         food         date   
  ------       ------      ------
  ABC123       Sushi       09/28/2013
  ABC123       Sushi       09/29/2013
  ABC123       Sushi       09/30/2013
  ABC123       Sushi       10/01/2013
  CDE345       Steak       10/15/2013
  CDE345       Steak       10/16/2013
  CDE345       Steak       10/17/2013
  DEF456       Burrito     09/09/2013
  DEF456       Burrito     09/10/2013
  DEF456       Burrito     09/11/2013
  </code></pre>
  
  <p>Considering that the code, food, and date are all variable at any given time, what would be the query to create a result as shown above? The query should only find minimum 3 consecutive dates for each given code and food pair (key).</p>
  
  <p>I tried messing around with one of the queries on Stack Exchange:</p>
  
  <pre><code>select code, grp, count(*) as NumInSequence, min(date), max(date)
  from (select t.*, (date - row_number() over (partition by code order by date)) as grp
    from #TempTable t
      ) t
  group by code, grp
  </code></pre>
  
  <p>...but I get an error regarding converting data type varchar to bigint (which is probably due to the code being alphanumeric as opposed to just a regular int ID). Also, I am assuming that the above code wouldn't give me the exact result anyway.</p>
  
  <p>Please advise, and thank you for your help.</p>