請幫我調試下面的存儲過程的錯誤。 Whenevere我試圖執行我收到錯誤的SP作爲錯誤信息存儲過程中的錯誤已經有一個對象名爲
(受影響的142行(S)) 消息2714,級別16,狀態6,第16行 已經有一個數據庫名爲「AOP_Monthly_GrowthRate_Acquisition」對象。
if exists (select * from INFORMATION_SCHEMA.TABLES where TABLE_NAME =
'AOP_Monthly_GrowthRate_Acquisition' AND TABLE_SCHEMA = 'dbo')
drop table BudgetWorld_temp.dbo.AOP_Monthly_GrowthRate_Acquisition
GO
SELECT dbo.LTM_ACQUISITION_MONTHLY.Year,
dbo.LTM_ACQUISITION_MONTHLY.Month,
dbo.LTM_ACQUISITION_MONTHLY.SALES_MANAGER_CODE,
dbo.LTM_ACQUISITION_MONTHLY.SALES_GROUP,
dbo.LTM_ACQUISITION_MONTHLY.NetProductSales,
dbo.LTM_ACQUISITION_MONTHLY.AverageCostBasedProfit,
dbo.LTM_ACQUISITION_MONTHLY.ReplacementCostBasedProfit,
isnull(dbo.[Provided 2016 AOP Values_Acquisition].[AOP Sales],0) as 'AOP Sales',
isnull(dbo.[Provided 2016 AOP Values_Acquisition].[AOP
Profit Based On Average Cost],0) as 'AOP Profit Based On Average Cost'
INTO #TEMP3
FROM dbo.LTM_ACQUISITION_MONTHLY LEFT OUTER JOIN
dbo.[Provided 2016 AOP Values_Acquisition] ON
dbo.LTM_ACQUISITION_MONTHLY.Month = dbo.[Provided 2016 AOP
Values_Acquisition].Month AND
dbo.LTM_ACQUISITION_MONTHLY.SALES_MANAGER_CODE =
dbo.[Provided 2016 AOP Values_Acquisition].[Sales Manager] AND
dbo.LTM_ACQUISITION_MONTHLY.SALES_GROUP = dbo.
[Provided 2016 AOP Values_Acquisition].[Sales Group]
SELECT *,
SALES_GROWTH = CASE
WHEN ([NetProductSales] + [AOP Sales]) = 0 THEN 0
WHEN ([AOP Sales]) > 0 AND ([NetProductSales]) = 0 THEN 1
ELSE
(([AOP Sales] -[NetProductSales])/[NetProductSales]) END
,
Margin_Growth =
CASE
WHEN ([AverageCostBasedProfit] + [AOP Profit Based On Average Cost]) = 0
THEN 0
WHEN ([AOP Profit Based On Average Cost]) > 0 AND
([AverageCostBasedProfit]) = 0 THEN 1
else
(([AOP Profit Based On Average Cost] -
[AverageCostBasedProfit])/[AverageCostBasedProfit]) END
INTO AOP_Monthly_GrowthRate_Acquisition
FROM #TEMP3
DROP TABLE #TEMP3
由於一噸
我剛剛在工作時遇到了這個問題。請檢查是否已經有一個名爲'AOP_Monthly_GrowthRate_Acquisition'的表,但具有**不同的模式**。 – t1t1an0