In a stored procedure I want to check if a column value is not equal to a string, but not seem to work and I get syntax error.
This is what I am trying,
WHERE Table.ColumnName != "someText"
I also tried,
WHERE Table.ColumnName IS NOT LIKE "string"
Error:
Invalid column name 'someText'.
Replace the double quotes " with single quotes ' - then both snippets should work just fine.
WHERE Table.ColumnName != 'someText'
or
WHERE Table.ColumnName <> 'someText'
or
WHERE Table.ColumnName IS NOT LIKE 'someText'
What is the datatype of your column? If it's NVARCHAR, you might need to use a N prefix to signal Unicode: WHERE Table.ColumnName <> N'string'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With