We are using SQL SERVER 2005. I have a requirement to do a report for which I am using this stored procedure. It has 3 parameters like this:
StoredProcedure1 ( @param1 varchar(10) = NULL, @param2 varchar(11) = NULL, @param3 varachar(10) = NULL)
@Param1, @Param2, @Param3 values can be NULL, value.
ID Param fund
1 Hello 11
2 Good 12
3 Bad 13
4 Am 14
Hello, Good, bad belong to deposit category.
If Param1 value is NULL, then get all records from table.
If Param1 value = "Hello", get all records from table where param = @param1
If Param1 value = 'Deposit', then get all records Hello, good, bad.
The problem is 'Deposit' is not part of table. I am creating tmp table in SP and getting values of Hello, bad, good.
I am not sure how to build dynamic sql for where condition or inner join condition when Param1 value is deposit.
It is same for rest of parameters also.
Is summary, if parameters are null, get all records, have 1 values, get those records, if it is 'Deposit' get only certain records.
I need to create where conditions for all 3 params based on v
View Complete Post