Hi Mariam
>I’m wondering may I use CASE or IF statement in Where clause when I’m writing stored procedure ?
>Is there any way to check inside the procedure if any of parameters is empty ?
You can, as Sergey suggests, test the LEN() of a variable. However, you can also assign default values to the variables in the CREATE PROCEDURE statement like this:
CREATE PROCEDURE dbo.usp_test @corpname varchar(30) = '%', @corpdba varchar(30) = '%'
This has a double benefit and one drawback! The benfits are that you will not get an error if either one or both parameters are omitted, and you don't have to worry about testing them for empty values in the procedure, you can do that in VFP and only pass non-empty values.
The drawback, of course, is that the default condition (both values = '%') will return all rows from the database!
----
Regards
Andy Kramek