Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Problem creating unique clustered index on view

Author  Topic 

naveentnk
Starting Member

15 Posts

Posted - 2009-06-10 : 08:19:56
Hi everybody,

I have created a view from another view.

The create statement is:

CREATE VIEW [dbo].[SERVICEDESK_INCIDENTVIEW_TEMP] WITH SCHEMABINDING AS
SELECT Id,State, Title, Description, Resolution, Resp_Viol_Reason, Resol_Viol_Reason,
IncidentType, SourceType_ID, Parent_Incident_ID, FirstCallResolution, CompanyDeleted
FROM DBO.servicedesk_incidentview

The view SERVICEDESK_INCIDENTVIEW_TEMP is created successfully.

I wanted to create a unique clustered index on this view. MY statement is:

create unique clustered index INCIDENT_ID_SERVICEDESK_INCIDENTVIEW_TEMP on SERVICEDESK_INCIDENTVIEW_TEMP(Id)

When I run the above query I got the following error.

Cannot create index on view 'WIPRO_EHELPLINE.dbo.SERVICEDESK_INCIDENTVIEW_TEMP'
because it references another view 'DBO.servicedesk_incidentview'.
Consider expanding referenced view's definition by hand in indexed view definition.

I have performance issue in my application. This view contains more than 5 lakh records.

Please help me how to create unique clustered index on this view. So that my queries performance will increase.


Thanks in advance.


Who is wise? He that learns from everyone. Who is powerful? He that governs his passions. Who is rich? He that is content. Who is that? Nobody.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-10 : 08:28:07
An indexed view cannt reference other views, only base tables.
This is documented in Books Online. Do a search for "Indexed View".



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

naveentnk
Starting Member

15 Posts

Posted - 2009-06-10 : 10:37:02
Thanks

Who is wise? He that learns from everyone. Who is powerful? He that governs his passions. Who is rich? He that is content. Who is that? Nobody.
Go to Top of Page
   

- Advertisement -