The code is not working. There are numbers of errors like the following even you parse the query
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near '?'.
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near '?'.
Msg 102, Level 15, State 1, Line 5
Incorrect syntax near '?'.
Msg 102, Level 15, State 1, Line 6
Incorrect syntax near '?'.
Msg 102, Level 15, State 1, Line 7
Incorrect syntax near '?'.
Msg 102, Level 15, State 1, Line 8
Incorrect syntax near '?'.
Msg 102, Level 15, State 1, Line 10
Incorrect syntax near '?'.
Msg 137, Level 15, State 1, Line 12
Must declare the scalar variable "@UsrName".
Msg 137, Level 15, State 1, Line 13
Must declare the scalar variable "@srv".
Msg 137, Level 15, State 2, Line 21
Must declare the scalar variable "@DbName".
Msg 102, Level 15, State 1, Line 23
Incorrect syntax near '?'.
Msg 137, Level 15, State 2, Line 24
Must declare the scalar variable "@tck".
Msg 137, Level 15, State 2, Line 26
Must declare the scalar variable "@dbname".
Msg 102, Level 15, State 1, Line 28
Incorrect syntax near '?'.
Msg 137, Level 15, State 2, Line 30
Must declare the scalar variable "@srv".
Msg 102, Level 15, State 1, Line 32
Incorrect syntax near '?'.
Msg 137, Level 15, State 2, Line 36
Must declare the scalar variable "@command".
Msg 137, Level 15, State 2, Line 39
Must declare the scalar variable "@command2".
Msg 137, Level 15, State 2, Line 42
Must declare the scalar variable "@DbName".