I have created a parameter query using Microsoft query as mentioned here. But when I want to pass parameters to temporary variables and create table variables and edit them to get the desired result instead of doing 10 to 15 Joins and mentioning the parameters in the where clause I get errors
[Microsoft] [ODBC SQL Server Driver] Invalid Parameter number
and
[Microsoft] [ODBC SQL Server Driver] Invalid Descriptor Index
My code looks something like this it is way complex with many temp tables and temp variables
BEGIN
SET NOCOUNT ON
DECLARE @sDate DATETIME, @eDate DATETIME; --used in many places to manipulate temp table
SET @sdate = ?
SET @edate = ?
DECLARE @Temptable TABLE (Variable1 INT ,...... VariableN DECIMAL(18,4));
Manipulate @temptable
Select * from @Temptable
END
How is it possible to pass parameters to temp variables in Excel 2007 for a database in SQL Server 2005? I have no permission to create stored procedures in the database and pass them as parameters to it.
UPDATE
I have figured a way through VBA as suggested by David Vandenbos. I am still curious to know if this can be done without the help of VBA.