T-SQL has an if-else
statement. For the conditional, use the same syntax you would use for a WHERE
clause, e.g., AND
instead of &&
, =
instead of ==
and single quotes for strings. IF
expects a single statement; if you want to execute a block of code, wrap it in BEGIN
...END
.
In your case, the code could look like this:
IF @param1 = '2222' AND @param2 < 5
BEGIN
...
END
PS: When searching for SQL Server syntax elements, include t-sql
in your keywords. For example, a Google search for t-sql if
yields the description of the SQL Server IF-ELSE-Syntax as the first hit.
IF
.IF
keyword will solve this. Or simply reading the documentation. Or googling for said documentation