Why is this query throwing an “Invalid Column Name” error? [closed]
As i am trying to run a simple UPDATE query as follows:
UPDATE [TILL].[dbo].[appParameters] SET [TILL].[dbo].[appParameters].[ParameterValue] = "1" WHERE [TILL].[dbo].[appParameters].[ParameterName] = "StaffTablesRefreshed"
If the field [ParameterName] is the value "StaffTablesRefreshed", then set the value of [ParameterValue] to "1".
When executed, SQL Server throws an error:
Invalid column name 'StaffTablesRefreshed'
Both [ParameterName] and [ParameterValue] are nvarchar(255).
Am I missing something obvious here? Don’t know why getting an error SQL server invalid column name.
You need to replace the double quotes with single quote
There is a setting to change how the SQL servers handles double quotes: SET QUOTED_IDENTIFIER, but apparently, you are using the default setting, meaning go by my above recommendations.s. By default SQL Server treats double quotes as a delimiter for identifiers (for instance column names), and that is what happens for your query. Strings are enclosed in single quotes. As for the number (1), you probably want to just remove the double quotes (assuming the data type in the table is numeric, if it is a string, then use single quotes here too).