Your parameters to both your stored procedure and the dynamic sql you are building should match the data types of the columns in your table/view.Also, the way you wrote your last dynamic sql you do not even need the parameters you defined, you are not using them.