I want to check in SQL whether a given value exists in one of my tables inside a stored procedure. This is the method I used:
IF( (SELECT COUNT([ID]) FROM my_Table WHERE [Col] = @SP_Parameter) > 0)
BEGIN
--My Code
END
But that statement is never true no matter what. I made sure the row exists, but it never runs as true.
IFstatementIFstatement. Microsoft's SQL Server uses T-SQL which does indeed haveIFstatement - but that is not part of "SQL" (the standardized query language)