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)
 HOW TO CREATE NON CLUSTERED INDEX on computed fied

Author  Topic 

imranabdulaziz
Yak Posting Veteran

83 Posts

Posted - 2008-04-08 : 01:15:38
hi all ,
I am using sql server 2005.
I want to create non clustered index speed up the query search.
but when i create index with this code

CREATE UNIQUE NONCLUSTERED INDEX TEST ON DOCTOR_MASTER( DR_CUST_DOCTORCODE)

i am getting error like
Column 'DR_CUST_DOCTORCODE' in table 'DOCTOR_MASTER' cannot be used in an index or statistics or as a partition key because it is non-deterministic.


This column is formulated column whose value is populated when record get inserted through function. It values is i format identity column value + category

Pleasse suggest.




pootle_flump

1064 Posts

Posted - 2008-04-08 : 04:41:59
Have you persisted the column? Can you show your SQL for the create table, including your function. If your function accesses data then this is correct - you cannot persist this column nor add an index as it is considered non-deterministic.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-08 : 04:56:41
Or you could change the "formulated"/calculated column to a ordinary column and have a trigger handling the content of the column.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -