I made a database for my project for ASP.NET in Visual Studio. Then I made a table however after updating the table, Visual Studio itself named it as ‘Table’. Now when I’m trying to run a query: select * from Table (.....)
but it is throwing an error
Incorrect syntax near the keyword ‘Table’.
I even tried writing the table name as [Table]
in the query but no effect.
Now what should I do?
Edit: I have found the solution myself after researching on this issue: If you are having similar issue then just rename the table and all should work fine:) Make sure to change this new table name in all the occurrences in your project.
2
Answers
If you ever want to use a reserved word as an identifier in SQL then you need to escape it. That’s always the case and will be covered in any SQL tutorial. In SQL Server, you escape an identifier using brackets, e.g.
Of course, you should change that table name immediately, then the issue goes away. That said, I tend to use singular names for my tables and I often end up with a
User
table. That’s a reserved word, so I have to escape it when I refer to it. No big deal.Check if your table name presents any schema or normal table.