Skip to content

Instantly share code, notes, and snippets.

@dazzag24
Created January 9, 2017 11:06
Show Gist options
  • Save dazzag24/f9863e12d1230b8caa9849703b8f7cf7 to your computer and use it in GitHub Desktop.
Save dazzag24/f9863e12d1230b8caa9849703b8f7cf7 to your computer and use it in GitHub Desktop.
If you have a column named Key then you will have issues when doing this:
select * from Sectors where Key = 'bagder'
"Incorrect syntax near the keyword 'Key'."
This is because Key is a reserved keyword in SQL. To resolve this, simply place the column name in square brackets e.g.
select * from Sectors where [Key] = 'bagder'
For in more complex examples:
select Email, Name from People P inner join Sectors S ON J.Sectorkey = S.[Key];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment