Adding stored procedure SQL code for data retrieval