none
There was an error parsing the query RRS feed

  • Question

  • Hi all,

    I got problem when execute the query:

    if not exists( SELECT * 
                     FROM INFORMATION_SCHEMA.TABLES 
                     WHERE  TABLE_NAME = 'M_EDI_Party')
                     print '123';

    Then I got error :

    HResult=-2147467259
      Message=There was an error parsing the query. [ Token line number = 1,Token line offset = 1,Token in error = if ]
      Source=SQL Server Compact ADO.NET Data Provider
      ErrorCode=-2147467259.

    But this query works well in sql management studio.

    I want to know is the "if" schema doesn't work in sqlce? 

    Thanks.

    Friday, June 16, 2017 3:56 AM

Answers

All replies

  • Hello William,

    If you mean with SSMS running the query against a SQL Server (not Compact Edition), then it will work, but SQL Server Compact Edition supports only a small subset of Transact-SQL commands, see Differences Between SQL Server Compact and SQL Server and SQL Reference (SQL Server Compact) ; PRINT is not supported.

    At all, what should the PRINT be good for? If you what to get a result for your application use a SELECT instead


    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    Friday, June 16, 2017 5:40 AM
  • Hello Olaf,

    I think I should find other way to determine the table exists or not. anyway, thanks for help.

    Friday, June 16, 2017 8:16 AM
  • Just run: SELECT *
                    
    FROM INFORMATION_SCHEMA.TABLES
                    
    WHERE  TABLE_NAME = 'M_EDI_Party'

    And check the result in code - SQL Compact does not support IF and PRINT


    Please mark as answer, if this was it. Visit my SQL Server Compact blog http://erikej.blogspot.com

    Thursday, June 22, 2017 7:09 AM
    Moderator