Post Deployment Script, 72006: Fatal scripting error: Incorrect syntax was encountered while parsing

The Problem

You create a post deployment script, with a statement like;
[sql]
:r .\Static Data\Insert Seed Values.sql
[/sql]

The system throws an error and will not build:
[csharp][/csharp]
72006: Fatal scripting error: Incorrect syntax was encountered while parsing ‘Data\Insert’
[/chsharp]

The solution

There are two problems:

  1. The post deployment script does not like spaces in the file paths, so quote the file path in “double quotes”.
    [sql]
    :r ".\Static Data\Insert Seed Values.sql"
    [/sql]
  2. The post deployment script runs in SQL CMD mode, so whilst ever you have the script file open it will throw syntax errors either
    1. Close the post deployment script; or
    2. Turn on SQL CMD mode on the file, (in 2012 with latest SSDT this is the last icon in the toolbar

      SQLToolbar

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.