我想在視圖上創建一個索引,並且它保持失敗,我很確定它的B/C我使用列的別名。不知道如何或如果我可以這樣做。以下是一個簡化的場景。索引視圖索引創建失敗
CREATE VIEW v_contracts WITH SCHEMABINDING
AS
SELECT
t1.contractid as 'Contract.ContractID'
t2.name as 'Customer.Name'
FROM contract t1
JOIN customer t2
ON t1.contractid = t2.contractid
GO
CREATE UNIQUE CLUSTERED INDEX v_contracts_idx ON v_contracts(t1.contractid)
GO
---------------------------
Incorrect syntax near '.'.
CREATE UNIQUE CLUSTERED INDEX v_contracts_idx ON v_contracts(contractid)
GO
---------------------------
Column name 'contractid' does not exist in the target table or view.
CREATE UNIQUE CLUSTERED INDEX v_contracts_idx ON v_contracts(Contract.ContractID)
GO
---------------------------
Incorrect syntax near '.'.
任何人都知道如何使用別名列創建索引視圖,請讓我知道。
是的,這是它的!我無法相信我忘記了[]。我在各地使用它們。謝謝! – aBetterGamer 2010-06-10 15:50:00