title: SSDT Generate Script Producing Syntax Error on SET AUTO_CREATE_STATISTICS
body: <p>I'm using the "Generate Script" feature in SSDT to create a database script.  However, the script that is generated has a syntax error, according to SSMS when I execute the script.  The code with the error is: </p>
  
  <pre><code>IF EXISTS (SELECT 1
         FROM   [master].[dbo].[sysdatabases]
         WHERE  [name] = N'$(DatabaseName)')
  BEGIN
      ALTER DATABASE [$(DatabaseName)]
          SET AUTO_CREATE_STATISTICS ON(INCREMENTAL = OFF),
              MEMORY_OPTIMIZED_ELEVATE_TO_SNAPSHOT = OFF,
              DELAYED_DURABILITY = DISABLED 
          WITH ROLLBACK IMMEDIATE;
  END
  </code></pre>
  
  <p>The error is: </p>
  
  <blockquote>
    <p>Msg 102, Level 15, State 1, Line 208 Incorrect syntax near
    'INCREMENTAL'. Msg 319, Level 15, State 1, Line 211 Incorrect syntax
    near the keyword 'with'. If this statement is a common table
    expression, an xmlnamespaces clause or a change tracking context
    clause, the previous statement must be terminated with a semicolon.
    Msg 102, Level 15, State 1, Line 211 Incorrect syntax near
    'IMMEDIATE'.</p>
  </blockquote>
  
  <p>As far as I can tell, the syntax being generated was deprecated in SQL Server 2012 CTP1.</p>
  
  <p>I'm using Visual Studio version 14.0.25431.01 Update 3 with SSDT version 14.0.609.18.  I'm executing this script against SQL Server 11.0.6020.</p>
  
  <p>Note that I'm able to publish from Visual Studio, Schema Compare from Visual Studio, apply this schema via a DACPAC upgrade in SSMS or VS, and I'm also able to apply the build's DACPAC via DacFx without error.  I only get this error when executing the raw script.</p>
  
  <p>If I remove the offending code it works as expected.  I do <strong>need</strong> to have the script for one particular case.  I'm just trying to figure out why SSDT is creating bad syntax.  I would prefer to not have to have a checklist of manual edits I need to do to the generated script before deployment.</p>
  
  <p>Does anyone have any ideas?  Thank you!</p>