SQL error: Incorrect syntax near the keyword 'User'
User
is a reserved keyword, so you must use square brackets to make it explicit that you mean the object named "User" it, i.e. use [User]
instead of User
.
SQL Error: Incorrect Syntax near the keyword User
Why are you using double quotes at all? I would start with:
SELECT u.Disabled, u.UserName
FROM Database.dbo.User u
ORDER BY u.UserName ASC
You don't specify your database, but words like User
are often reserved words, so they make a poor choice for an identifier name.
Incorrect syntax near the keyword 'User'. error on SQL Server
User
is a reserved word and needs to be escaped, commonly by using square brackets e.g.
SELECT * FROM dbo.[User]
But double quotes also work:
SELECT * FROM dbo."User"
Although it will make your life (and any developers who follow) a lot easier if you just avoid using reserved words.
How to Solve Sql Command error invalid syntax near the keyword 'user'
user
is an SQL reserved word. Change the query to:
"SELECT * FROM dbo.[user]"
It is always preferred to decorate schema / table / column names with []
to avoid these errors.
Docs:
ODBC Reserved Keywords are reserved for use in
ODBC function calls. These words do not constrain the minimum SQL
grammar; however, to ensure compatibility with drivers that support
the core SQL grammar, applications should avoid using these keywords.
c# incorrect syntax near the keyword 'user'
user
is a reserve word and thus needs escaping like insert into [user] values...
Or insert into "user" values...
Related Topics
Converting Svg to Png Using C#
How to Read an Excel File in C# Without Using Microsoft.Office.Interop.Excel Libraries
How to Cast String to Int. Error Msg: Input String Was Not in a Correct Format
Convert Arabic"Unicode" Content HTML or Xml to PDF Using Itextsharp
How to Get Linq to Return the Object Which Has the Max Value for a Given Property
Unique File Identifier in Windows
Icollection<T> VS List<T> in Entity Framework
Best Way to Deploy Visual Studio Application That Can Run Without Installing
How to Exit a Wpf Application Programmatically
Sqldataadapter VS SQLdatareader
How to Create Deterministic Guids
Set Custom Path to Referenced Dll'S
Escape Curly Brace '{' in String.Format
How to Send HTML-Formatted Email