When I try to use SQL Tuner I get an Invalid SQL Statement Only one select/insert/update/delete statment is allowed error.
I only have one query in the Tuner and it can be run in the editor.
Tuner only takes the query and does not handle Declare and Set statments that is included in a script.
Tuning only processes a single SELECT/SELECT INTO/INSERT/DELETE/UPDATE at a time.
If you remove the DECLARE/SET statements you should be able to tune your query. Tuning will pick up the @variables in your query and you will be prompt to enter values for these in a parameter window.
Sample:
Do not include...
DECLARE @someid int
...
SET @someid = 0
...
SELECT pr.[someid_code],
pr.[code_name]
FROM SomeCode_Tbl pr
WHERE pr.someid_code = @someid
This will run...
SELECT pr.[someid_code],
pr.[code_name]
FROM SomeCode_Tbl pr
WHERE pr.someid_code = @someid
You will be prompted by Tuning to set a value for @someid.