Maybe I am missing a step but this proc doesn't compile.
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near '?'.
Msg 102, Level 15, State 1, Line 57
Incorrect syntax near '?'.
Msg 102, Level 15, State 1, Line 146
....
edited out numerous errors.