Monday, March 19, 2012

Cannot create index on view

Hi,
I have created a view but I cannot create index on it. My view is like this:
Create view v2 with schemabinding as
select distinct count_big(orderid) as MyCount from dbo.orders group by
orders.customerid
and my index command is:
create unique clustered index myidx2 on v2(MyCount)
I get this error:
Server: Msg 1936, Level 16, State 1, Line 1
Cannot index the view 'Northwind.dbo.v2'. It contains one or more disallowed
constructs.
Whats wrong?
Any help would be greatly appreciated.
AminConsult the documentation - distinct is not allowed.
"Amin Sobati" <amins@.morva.net> wrote in message
news:umwVwcECEHA.2308@.tk2msftngp13.phx.gbl...
> Hi,
> I have created a view but I cannot create index on it. My view is like
this:
> Create view v2 with schemabinding as
> select distinct count_big(orderid) as MyCount from dbo.orders group by
> orders.customerid
> and my index command is:
> create unique clustered index myidx2 on v2(MyCount)
> I get this error:
> Server: Msg 1936, Level 16, State 1, Line 1
> Cannot index the view 'Northwind.dbo.v2'. It contains one or more
disallowed
> constructs.
> Whats wrong?
> Any help would be greatly appreciated.
> Amin
>
>

No comments:

Post a Comment