In this article, We will see how to use reserved keyword in SQL query. There are couple of scenarios when customer has table fields which are reserved keyword such as select, date, max and group.
Reserved Keywords
Here is the list of reserved keyword list
https://docs.microsoft.com/en-us/sql/t-sql/language-elements/reserved-keywords-transact-sql?view=sql-server-ver15
How to use reserved keyword in SQL query
Wrap the column name in brackets like so, group
becomes [group].
select [group] from table;
It is also possible to use the following (useful when querying multiple tables):
select table.[group] from table;
Summary
In this way, we can use reserved keyword by wrapping [] bracket for reserved field in SQL query.
If you like this article, feel free to share it with others who might find it helpful! If you have any questions, feel free to reach out to me.