I have got an working IF/Else Stored Procedure but it is going to really complex, what I want to do is add to my SQL statement until it is complete and then execute it, whilst I can do this in .NET I am unsure how to get it to work in a stored procedure.
Example:
Dim vSQL As String
IF LTRIM(RTRIM(@sSomeValue)) = 'DefaultValue'
vSQL = "or SomeValue = @sSomeValue"
Else
vSQL = "and SomeValue = @sSomeValue"
END
SELECT * FROM TblMainTable
WHERE
Firstname LIKE '%' + @sFirstName + '%'
& vSQL
Go to the complete details ...