【发布时间】:2018-03-29 06:26:02
【问题描述】:
我们有一个服务器,其中包含一个完整的财务记录数据库,其中信息是通过一个名为 MDA 的财产管理程序获取的。 MDA 具有报告功能。
是否可以查看程序正在查询数据库的具体内容,以便我可以在 Excel 等中复制该特定报告表。
MDA 帮助页面确实提供了一些报告的 sql 代码,但不是全部,并且提供的一些代码没有提供相同的信息。那么是否有可能从服务器端确切地看到正在做什么?
编辑:
以下是捕获的查询:
Update tmp Set
tmp.TenantReceipts = a.TenantReceipts,
tmp.OtherReceipts = a.OtherReceipts,
tmp.Disbursments = a.Disbursments,
tmp.AgentFeesCollectionCommission = a.AgentFeesCollectionCommission,
tmp.AgentFeesManagementFee = a.AgentFeesManagementFee,
tmp.AgentFeesBankCharges = a.AgentFeesBankCharges,
tmp.AgentOnlyCashMovements = a.AgentOnlyCashMovements,
tmp.PaidToOwners = a.PaidToOwners
From #tmpResultSet tmp
Inner Join
(Select PropertyID, IsNull(CashBookID, 0) as CashBookID,
--Tenant Receipts Sum of tenant receipts (type = 2) and tenant payments (type = 3), excluding agent only transactions, for either financial or owner statement period.
Sum (Case When TransactionTypeID in (2,3) and ExcludeFromOwnerReports = 0 then InclusiveAmount else 0 end) as TenantReceipts,
--Other Receipts Sum of suppier receipts (type = 12 not used) and property receipts (type = 22), excluding agent only transactions, for either financial or owner statement period.
Sum (Case When TransactionTypeID in (12,22) and ExcludeFromOwnerReports = 0 then InclusiveAmount else 0 end) as OtherReceipts,
--Disbursements Sum of suppier payments (type = 13) and property payments (type = 23), excluding agent only transactions, for either financial or owner statement period.
--Excludes transactions designated as Agent Fees in Global Options i.e Collection Commission, Management Fee, Bank Charge son Cash, Bank Charges on Cheques (includes all payments) and Bank Charges on Cash, as well as amounts Paid to Owners.
Sum (Case When TransactionTypeID in (13,23)
--and IsNull(afgo.TransactionCodeID, 0 ) = 0
and tx.TransactionCodeID not in (@CollectionCommissionID)
and tx.TransactionCodeID not in (@ManagementFeeID)
and tx.TransactionCodeID not in (@BankChargesOnCashID)
and tx.TransactionCodeID not in (@BankChargesOnChequesID)
and tx.TransactionCodeID not in (@OwnerPaymentsID)
and ExcludeFromOwnerReports = 0 then InclusiveAmount else 0 end) as Disbursments,
--Agent Fees For Amounts Paid:
--If any of the Agent Fee components are unchecked on the parameter screen, they will be excluded from the calculation.
--Sum of supplier payments (type = 13) and property payments (type =23), excluding agent only transactions, for either financial or owner statement period.
--Further restricted to transactions designated in Global Options as Collection Commission, Management Fee and Bank Charges, and if ticked on the parameter form.
--Agent Fees Collection Commission
Sum (Case When TransactionTypeID in (13, 23) and ExcludeFromOwnerReports = 0 and @AmountsAccrued = 0 and @ShowCollectionCommission = 1
and tx.TransactionCodeID in (@CollectionCommissionID) then InclusiveAmount else 0 end) as AgentFeesCollectionCommission,
--Agent Fees Management Fee
Sum (Case When TransactionTypeID in (13, 23) and ExcludeFromOwnerReports = 0 and @AmountsAccrued = 0 and @ShowManagementFee = 1
and tx.TransactionCodeID in (@ManagementFeeID) then InclusiveAmount else 0 end) as AgentFeesManagementFee,
--Agent Fees Bank Charges
Sum (Case When TransactionTypeID in (13, 23) and ExcludeFromOwnerReports = 0 and @AmountsAccrued = 0 and @ShowBankCharges = 1
and (tx.TransactionCodeID in (@BankChargesOnCashID) or tx.TransactionCodeID in (@BankChargesOnChequesID))
then InclusiveAmount else 0 end) as AgentFeesBankCharges,
--Agent Only (Cash) Movements Sum of cash transactions (types = 2, 3, 12, 13, 22 and 23) and where such transactions are designated as ‘agent only, for either financial or owner statement period.
Sum (Case When TransactionTypeID in (2, 3, 12, 13, 22, 23) and ExcludeFromOwnerReports = 1 then InclusiveAmount else 0 end) as AgentOnlyCashMovements,
--Paid to Owners Sum of property payments (type = 23) allocated to the Owner Payment transaction code in Global Options, excluding agent only transactions, for either financial or owner statement period.
Sum (Case When TransactionTypeID in (13, 23) --RB 05/08/2009 Added Transaction Type 13 where expense accruals are paid to owner payment codes
and ExcludeFromOwnerReports = 0
and tx.TransactionCodeID = @OwnerPaymentsID
then InclusiveAmount else 0 end) as PaidToOwners
From Transactions tx (NoLock)
Where ( (@UseFinPeriod = 1 and tx.Period = @Period) or (@UseFinPeriod = 0 and tx.OwnerStatPeriod = @Period) )
and ((@IncludeRegularTransactions = 1 and @IncludeAgentOnlyTransactions = 1)
or (tx.ExcludeFromOwnerReports = 0 and @IncludeRegularTransactions = 1)
or (tx.ExcludeFromOwnerReports = 1 and @IncludeAgentOnlyTransactions = 1)
)
and (@GenerateOwnerPayments = 0 or @PropertyDefaultCashBookID = tx.CashBookID)
and tx.PropertyID in (Select PropertyID from #tmpProperties)
Group By tx.PropertyID, tx.CashBookID
--Order by tx.PropertyID
) a on a.PropertyID = tmp.PropertyID and a.CashBookID = tmp.CashBookID
如何通过 Powerbi 或 PowerQuery 使用上述查询?因为它不能只是添加,因为我假设上面的“tmp”添加了临时表,并且从查询端无法修改数据库。并且所有的@都必须被赋予值?
【问题讨论】:
标签: sql powerbi powerquery