DelphiFAQ Home Search:
General :: Databases :: MS-SQL
Tricks how to deal with Microsoft SQL Server (MS-SQL).


This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Simple SQL query fails with Invalid Column Name (MS-SQL)


I want to delete all records in my MS-SQL database that contain the city "Alexandria".
The SQL looks like this:

delete from plants where city_name = "Alexandria"

I get this error message that something does not match with a table name or alias name used in the query or that I use an Invalid Column Name 'Alexandria'.


Many SQL parsers will allow strings to be escaped either by ' or " (single or double quote).
If you write SQL for Microsoft SQL Server, you have to use single quotes instead of double-quotes.

// bad in Microsoft SQL
 delete from plants where city_name = "Alexandria"
 // correct
 delete from plants where city_name = 'Alexandria'

Generated 0:00:25 on Sep 21, 2020