I am trying to perform a simple task in SQL Server and receiving an error. I have a table called World.Internet_CountryYear. The table has year columns (i.e. 1960, 1965, etc.) with numerical data in the fields, but the data type for the columns is varchar(max). Currently, the fields that do not have data have “” in them, which I would like to replace with 0.00. So, I try to run a simple update command as follows:
UPDATE World.Internet_CountryYear
SET 1960 = '0.00'
WHERE 1960 = '""'
For some reason, I receive an error saying “Incorrect syntax near ‘1960’”
Is there a problem with the DDL of this table? What am I missing here? I have tried specifying World.Internet_CountryYear.1960 as well, but still receive a similar error: Incorrect syntax near ‘.1960’
Any suggestions?
Enclose the column name with square brackets (you need to use the square brackets when you are using skeywords, special characters in the column names)
Try this: