0
我遇到了一個問題,我想將列添加到使用派生表的表中,我最終希望能夠填充但是,當我將列添加到表中時,出現以下錯誤:無法找到對象「TEST」,因爲它不存在或者您沒有權限。我有權限,但我沒有理解爲什麼我正與錯誤提示時腳本沒有錯誤執行沒有「ALTER TABLE TEST ADD THEMEVALUE INT(50)補充說:」行項目找不到對象'TABLE',因爲它不存在,或者您沒有權限
以下是我的代碼:
DECLARE @weeksPriorToConversion INT
DECLARE @periodenddate VARCHAR(50)
SET @weeksPriorToConversion = 5
SET @periodenddate = '2016-10-26'
SELECT TEST.[Casino]
FROM (SELECT C.Casino AS 'Casino',
TML.ID AS 'ID',
TML.[Themes or Game Titles] AS 'Theme',
COUNT(DISTINCT SM.[Serial Number]) AS 'Title Count',
SUM(SMD.[StandardizedCasinoHoldv2])/SUM(CASE
WHEN SMD.[StandardizedCasinoHoldv2] <> 0
THEN 7
ELSE NULL
END) AS 'Casino Index'
FROM [slot machine data] SMD
INNER JOIN [slot machines] SM
ON SM .ID = SMD.[serial number]
INNER JOIN [slot machine configurations] SMC
ON SM .ID = SMC.[serial number]
AND SMC. [Configuration Starting Date] = (SELECT MAX([Configuration Starting Date]) AS Expr1
FROM [Slot Machine Configurations] AS SMC2
WHERE ([Serial Number] = SM.ID)
AND ([Configuration Starting Date] <= SMD.[data calendar start date]))
INNER JOIN [casino] C
ON C .ID = SMC.[casino where slot in operation]
INNER JOIN [Themes Master List] TML
ON TML.ID = SMC.[Theme or Game Title]) AS TEST
ALTER TABLE TEST
ADD THEMEVALUE INT(50);