0
我正在嘗試創建一個Excel電子表格,該電子表格將運行一些SQL代碼,這是我在過去爲簡單的選擇語句所做的,但現在還有一些更高級的代碼,我不斷收到錯誤當我嘗試從Excel運行SQL Server存儲過程時,即使它在SQL Server Management Studio中運行良好。從Excel運行SQL Server存儲過程問題
存儲過程的代碼是:
truncate table LAS_RPT_IST;
insert into LAS_RPT_IST (IST_Ref_no, IST_Inv_no, LDC_ACCT_ID, IST_Commodity, IST_Tax, IST_STRS, START_DT, END_DT)
(Select
th.user1_tx, th.user4_tx, ldc.ldc_acct_id,
sum(case when th.trans_sub_ty_cd = 'ISTC' then th.trans_am end) as ISTC,
sum(case when th.trans_sub_ty_cd = 'TAX' then th.trans_am end) as TAX,
sum(case when th.trans_sub_ty_cd = 'STRS' then th.trans_am end) as STRS,
th.generic1_dt, th.generic2_dt
from
transaction_history th, ldc_Account ldc
where
th.trans_creation_dt > = Convert(varchar(8),DateAdd(d, -1, Convert(datetime, N'20140930', 101)), 112)
and th.user10_tx = 'IST'
and th.ldc_acct_id = ldc.ldc_acct_id
group by
th.user1_tx, th.user4_tx, ldc.ldc_acct_id, th.generic1_dt, th.generic2_dt);
但是,當我把這個成Excel和嘗試,並運行它,我得到這個錯誤
我可以運行對SELECT語句來自Excel的數據庫沒有問題。
誰能告訴我我失蹤了什麼?
你爲什麼要把這段代碼放到你的Excel電子表格中?把它變成一個存儲過程並從Excel中執行它。 – 2014-09-30 15:45:16
向我們提供有關如何運行這些查詢的更多信息。我首先想到的是,在Excel ADO中一次不能運行超過1個查詢 - 您必須單獨運行它們。 – 2014-09-30 15:51:25
我其實正試圖讓一個商店程序運行上面的代碼就是SP中的內容。 – 2014-09-30 16:12:04