zoukankan      html  css  js  c++  java
  • SSDT – Error SQL70001 This statement is not recognized in this context-摘自网络

    One of the most common errors I get asked about when using SQL Server Data Tools (SSDT) Database Projects is the error “This statement is not recognized in this context”. This is actually a pretty simple error to fix.

    Envision this scenario. You have a simple table:

    CREATE TABLE [dbo].[Test]  ( [Id] INT IDENTITY NOT NULL PRIMARY KEY  , [SomeData] NVARCHAR(20) NOT NULL  ) 

    Great. So then you want to have a post deployment script which will populate it with some default value. Because we are following best practices we creating a post deployment script which then calls the script to populate the default data.

    :r .InsertSomeData.sql

    Then we have the script InsertSomeData.sql itself:

    INSERT INTO [dbo].[Test] ([SomeData])   VALUES (‘Arcane Code’)   

    After inserting the code, or doing a build, you get this ugly error pop up in the error window:

    image

    So what happened? Well, when you went to insert the script you had these options in the dialog:

    image

    If you aren’t careful, you could accidentally pick the “Script (Build)” option (highlighted in blue). This option attempts to compile and run the code as DDL (Data Definition Language, the T-SQL syntax which creates tables, indexes, etc.) syntax. Things like Insert statements though are considered DML (Data Manipulation Language) code, and aren’t eligible to be compiled as part of the project. This is what generates the “This statement is not recognized in this context” error. You are essentially putting DML code where only DDL is allowed.

    But don’t despair, this is extremely simple to fix. In SSDT, simply bring up the Properties dialog for the SQL script (click in the SQL script, then View, Properties in the menu). Pick the Build Action property, and change it to None.

    image

    And that’s it, the error “SQL70001 This statement is not recognized in this context” should now vanish from your error list.

    摘自:http://arcanecode.com/2013/03/28/ssdt-error-sql70001-this-statement-is-not-recognized-in-this-context/

  • 相关阅读:
    HDU-3555-Bomb
    hihoCoder-1015-KMP
    HDU-1251-统计难题
    hihoCoder-1014-Trie树
    BZOJ-4326: NOIP2015 运输计划 (二分+LCA+树上差分)
    BZOJ-1607: [Usaco2008 Dec]Patting Heads 轻拍牛头 (筛法暴力)
    BZOJ-1419: Red is good (期望DP)
    BZOJ-1798: [Ahoi2009]Seq 维护序列seq & BZOJ-5039: [Jsoi2014]序列维护 (线段树)
    BZOJ-3732: Network (kruskal+LCA)
    BZOJ-1787: [Ahoi2008]Meet 紧急集合 (LCA)
  • 原文地址:https://www.cnblogs.com/haoliansheng/p/3298455.html
Copyright © 2011-2022 走看看