Note that there are some explanatory texts on larger screens.

plurals
  1. POPivot Table query from SQL tables gives error - sometimes
    primarykey
    data
    text
    <p>Running Excel 2010 with PowerPivot 10.50.1747.0, accessing SQL Server 2005 SP2.</p> <p>I am modifying an Excel pivot table. It gets its data from a SQL table, via a query. I am making changes to the query under "Table Properties." When I enter my new query, and click the "Validate" button, I get "The SQL statement is valid." If I click the "Design" button and in the resulting window click the Run ("!") button, I get the proper data. BUT, when I get out of the Design window and click the Save button, I get the error:</p> <pre><code>============== The refresh operation failed because the source data base or the table does not exist, or because you do not have access to the source More Details: OLE DB or ODBC error. An error occurred while processing the 'Query' table. The operation has been cancelled. ============== </code></pre> <p>What is going on here? (I am using a table variable - would that be causing the problem?) Thanks for any assistance.</p> <p>Here is the code:</p> <pre><code>declare @WCsWithDups TABLE( WOStatus Char(1) not null, WOCreated DateTime not null, WorkOrderNo VarChar(15) not null, WorkCenterID VarChar(6) not null, ItemClassID VarChar(12) not null, StockItem Char(1) not null, FirstChar Char(1) not null, MaxWODays SmallInt not null ) insert into @WCsWithDups(WOStatus, WOCreated, WorkOrderNo, WorkCenterID, ItemClassID, StockItem, FirstChar, MaxWODays) select DISTINCT case when wocompleted is null then 'O' else 'C' end as WOstatus, wocreated, WorkOrderNo, workcenterid, itemclassid, case when timinventory.minstockqty&gt;0 then 'Y' when timinventory.maxstockqty&gt;0 then 'Y' when timinventory.safetystockqty&gt;0 then 'Y' when timinventory.stdordqty&gt;0 then 'Y' else 'N' end as stockitem, left(itemproduced,1) as FirstChar, (select max(datediff(day,wocreated,transdate)+1) from vdvMT b where TR1.workorderno=b.workorderno) as maxwodays from vdvMT as TR1 left join tInv on TR1.itemkeyproduced=tInv.itemkey and TR1.whsekey=tInv.whsekey where type='L' and wocreated&gt;=(getdate()-365) and (workcenterid = 'Shed' or workcenterid = 'OP') delete from @WCsWithDups where WorkOrderNo in ( select WorkOrderNo from @WCsWithDups group by WorkOrderNo having count(WorkOrderNo) = 1); select distinct WOStatus, WOCreated, WorkOrderNo, 'Shed+OP' as WorkCenterID, ItemClassID, StockItem, FirstChar, MaxWODays from @WCsWithDups </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload