Incorrect syntax near the keyword User

作者:yaya | 时间:2008年7月17日 | 分类 随便写写 | 标签 keyword User 数据库 错误 问题 | 1回复

        不知怎么回事,非要去建立个user表,然后就出错了。网上一捞:

摘自:http://blog.csdn.net/sanking/archive/2007/10/31/1860190.aspx

Today I built one table named 'User' in sqlserver2000 and  found one problem.

When I type select * from User at SQL Query Analyzer, one message displayed as below:

Server: Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'User'.

O…I see "User" is the keyword of sql. So don't build User table into sql. If u must build one table named User.

The query should be  select * from "User"

But If in your java codes or other codes, how to do? I think it must be very complex..so…don't build User table in SQLserver2000.

But if u really must be use User table in programs.

The query statement should be  "select * from \"User\""  (Java)

In fact all the query statement can be "select * from \""+tableName+"\""

  1. 1