Incorrect syntax near the keyword 'WITH'

来源:互联网 发布:淘宝禁止发布违背 编辑:程序博客网 时间:2024/06/11 19:33

I am using HRESULT Recordset15:: Open( const _variant_t & Source,...) function where

Source =  "WITH RowOrder AS (SELECT [Chart Number] FROM [dbo].[Patient] ) SELECT * FROM RowOrder" in C++ module on SQL 2005 version 2005.90.3233.0. The msado15.dll version is 2.81.1132.0.

 

It returns DB_E_ERRORSINCOMMAND -"Incorrect syntax near the keyword 'WITH' ".

 

Error Numbers: 0x80040E14, 0x00000C14

Short Error:

Incorrect syntax near the keyword 'WITH'

Error:

Source: Microsoft OLE DB Provider for SQL Server

Description: Incorrect syntax near the keyword 'WITH'

Error Message: IDispathch error #3092

 

This query works fine on Microsoft SQL Server Management Studio Express version 9.00.3042.00.

 

Standard query like "SELECT * FROM [dbo].[Patient]" works without problem.

Any suggestions?

-------------------------------------------------------------

Try adding a semi colon ; before your WITH statement

-------------------------------------------------------------

Unbelievable, but it works after.

Thank you.



原创粉丝点击