Reputation: 7618
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'.
Upvotes: 3
Views: 11176
Reputation: 9947
Use <>
, Replace " with single quotes ' Problem Identifier marc_s thanks
WHERE Table.ColumnName <> 'string' or Table.ColumnName is null
Also i think for not like
where Table.ColumnNamenot like '%string%'
Upvotes: 0
Reputation: 754468
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'
Upvotes: 5