Search code examples
sqlsql-serverreserved-words

How to select "Group" column name from another table in an SQL Server?


Group is column in one of the table. I am using below query. As Group is reserve keyword, getting error while executing below query:

select o.group as group,
 p.id as id 
from
product p left join org o on p.id=o.id

Could anyone guide?


Solution

  • Regular SQL Server way:

    select o.[group] as [group],
    

    And SQL Server does also support the ANSI SQL way (perhaps some setting needed?)

    select o."group" as "group",