sql - Unique clustered index on two columns for an indexed view -


i'm trying setup indexed view on table doesn't have unique id. has 2 unique identifiers if combined unique it's row. i'm having trouble creating unique clustered index indexed view requires when found thread on msdn folks agree possible create unique clustered index out of 2 columns indexed view @ http://social.msdn.microsoft.com/forums/en/transactsql/thread/f2c99845-3af1-46e8-9b52-363c24988744

but life of me, can't figure out how create it. i'm rolling query, doesn't seem cut it.

create unique clustered index  [pk] on myview ( myid1, myid2 ) 

error:

the create unique index statement terminated because duplicate key found object name 'dbo.myview' , index name 'pk'. duplicate key value (71cd9b68-1a9e-47bc-bc6b-0008b230a6d8, 0e64aa3a-0631-4caf-82d9-73609ee79b19).

the 2 ids listed duplicates ids myid2.

so, how create unique clustered index here?

well error message seems suggest there more 1 record myid1 = 71cd9b68-1a9e-47bc-bc6b-0008b230a6d8 , myid2 = 0e64aa3a-0631-4caf-82d9-73609ee79b19.

i recommend running query selects based on criteria , confirming returns 1 record. if returns more, cannot recreate unique constraint on these 2 columns unless eliminate duplicates.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -