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
 General SQL Server Forums
 New to SQL Server Programming
 referential integrity problem

Author  Topic 

naren4it
Starting Member

2 Posts

Posted - 2009-09-21 : 08:17:49
Hi all i am facing problem for creating clustered index. Already i have nonclustured index on the tables of my database but i would like to modify them to clustered... for this i need to disable all foreign key constraints in my database and for this i wrote a stored procedure and disabled constraints and even after that when i run the syntax for creating clustered index i am thrown with error
"Cannot convert a nonclustered index to a clustered index because a foreign key constraint references the index. Remove the foreign key constraint and then retry the operation."

please help me out....

Thanks
Narendar

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2009-09-21 : 09:34:35
Script the Foregin Key out for the table you are tryign to create the key on, drop the FK, then create your Clustered Index and re-apply the FK's from the script.
Go to Top of Page

naren4it
Starting Member

2 Posts

Posted - 2009-09-21 : 09:52:29
Thanks a lot.. it is possible to do that way.. but i am confused why i am unable to make out by just disabling the foreign keys instead of droppping any reason..

Please let me know.

Regards
Narendar


Narendar
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2009-09-21 : 11:21:06
If you are just disabling the keys, they still exist and therefore will still be checked on schema changes.
Go to Top of Page
   

- Advertisement -