我正在尝试将此查询复制到SQL Server中的视图中但我一直收到错误。查询运行正常,但是当我复制并粘贴到视图中时,我在查询的底端出现错误:
无效的对象名称'BVSFWarehouse.dbo.sf_OPPORTUNITYHISTORY'
我做错了什么?请帮忙。
SELECT
H.OpportunityID, H.CREATEDDATE, H.STAGENAME AS 'Q1-14 Stage',
H.CLOSEDATE AS 'Q1-14 Close Date'
FROM
(SELECT
OpportunityID, MAX(CREATEDDATE) AS MaxDate
FROM
BVSFWarehouse.dbo.sf_OPPORTUNITYHISTORY
WHERE
(CREATEDDATE <= '2013-05-01')
GROUP BY
OpportunityID) AS X
INNER JOIN
**BVSFWarehouse.dbo.sf_OPPORTUNITYHISTORY** AS H ON H.OpportunityID = X.OpportunityID
AND X.MaxDate = H.CREATEDDATE
答案 0 :(得分:0)
SSMS -> Edit -> IntelliSense -> Refresh Local Cache
或
Ctrl + Shift + R
再试一次。
答案 1 :(得分:0)
在运行ALTER
之前,您没有尝试CREATE
视图,是吗?