April 24, 2008 at 7:52 am
All,
I've a primary key which is being referred by 3-4 foreign key tables.
I'd disabled the primary constraint using alter CASCADE command.
even while enabling the primary key constraint i'm able to do so, but the problem occurs with the foreign keys i need to enable them manually.
IS there anyway of enabling them generically?
Regards,
April 24, 2008 at 8:56 am
you can use the ALTER TABLE statement to disable or enable constraints.
ALTER TABLE my_table NOCHECK my_constraint -- disables the my_constraint constraint in my_table;
GO
ALTER TABLE my_table CHECK my_constraint -- re-enables the my_constraint constraint in my_table;
GO
I'm curious as to how you think you disabled the primary key constraint though. I've not heard of an ALTER CASCADE command. You'd need to drop the PK if you want it disabled.
April 24, 2008 at 10:40 pm
Yes we can disable the primary key which is when referred by foreign keys, using the following command:
ALTER TABLE employee DISABLE CONSTRAINT emp_id CASCADE;
this will disable the primary key with disabling the foreign key as well!!
April 25, 2008 at 1:23 am
Err. Are you sure? :ermm: That statement you provided doesn't work on any of my SQL Server installations (2000-2005). What version of SQL Server are you running?
That looks a bit like oracle syntax.
April 25, 2008 at 2:44 am
It's Oracle syntax.
It won't work in my SQL i believe.
but it does in oracle .
April 25, 2008 at 7:36 am
LOL. You could have said that to start with.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply