A very long and complex query has to be converted to a stored procedure. The query uses very long list of parameters and case statements from more then 3 tables. Unable to understand how to do it. kindly guide.