Excel> Microsoft Query> SQL Server>多个参数

时间:2010-04-22 16:31:35

标签: sql-server excel

我对sql server和excel / microsoft查询相对较新,

我有这样的查询

Select ...[data]...B1.b,B2.b,B3.b From TABLEA 
Inner join (
 SELECT ---[data]...sum(...) as b From TABLEB
 WHERE Date between [startdate] and [enddate]
) as B1
Inner join (
 SELECT ---[data]...sum(...) as b From TABLEB
 WHERE Date between [startdate-1week] and [enddate]
) as B2
Inner join (
 SELECT ---[data]...sum(...) as b From TABLEB
 WHERE Date between [startdate-2weeks] and [enddate]
) as B3
Where Date between [startdate] and [enddate]

当我手动引入日期时它有效,但我需要它们是“动态”(从excel引入)但是,当我把“?” (对于所有日期的参数),它会抛出错误。

“无效的参数编号”

:D我怎样才能在excel中完成这项工作?

我正在使用SQL Server和Microsoft Query Connection Data。

1 个答案:

答案 0 :(得分:1)

查看this thread,然后this page查看使用ADO参数的示例。

你应该尝试命名这样的参数:@ parameter1