Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Select Statement error

Author  Topic 

davidR
Starting Member

5 Posts

Posted - 2008-04-24 : 19:48:56
In SQL Sever 2005, I am trying to retrieve data using this simple query from a table called 'User':

select *
from dbo.User
where UserID='sam'



And, I keep getting the following error:
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'User'.


Thank you for your help

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-04-24 : 19:54:38
User is a reserved word, so you have to surround the name with square brackets.

select *
from dbo.[User]
where UserID='sam'

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -