开发者

Why is this syntax error in select statement SQL Server 2008

开发者 https://www.devze.com 2023-02-11 04:03 出处:网络
When I use a select statement inside store procedured like SELECT * FROM tableName 开发者_开发技巧

When I use a select statement inside store procedured like

SELECT * FROM tableName
开发者_开发技巧

it executes but it is marked as syntax a error,

But if I write

SELECT * FROM 'tableName'

it´s not mark as a syntax error, but when executed, it says:

Msg 102, Level 15, State 1, Procedure proc, Line 264

Incorrect syntax near 'tableName'

How to correct it


As the OP stated in a comment, the syntax error occurs because the table does not exist at design time. The table is created by the stored procedure. I'd consider this to be an acceptable syntax error so long as it is documented inline where it occurs.

0

精彩评论

暂无评论...
验证码 换一张
取 消