Can we build dynamic queries based on the values passed in the parameters.
Example:
I want pass in 3 parameters to a stored procedure.
1) Start Date
2) End Date
3) Field Name (created_date, order_date, delivered_date)
Based on the values passed in the parameters, I want to build the WHERE clause of my query.
So if Field Name value is created_date, I want WHERE clause to be
[created_date >= 'Start Date' AND created_date <= 'End Date']
if Field Name value is order_date, I want WHERE clause to be
[order_date >= 'Start Date' AND order_date <= 'End Date']