In my code, I have a routine does some database maintenance upon startup and I use the following code to drop a primary key from a table.
USE Students EXCLUSIVE
ALTER TABLE Students DROP PRIMARY KEY
Life is good if this runs only once and the key is there. However, if it has already been removed, it generates the error code 1879 which I test for and just do a RETURN and things work.
However, I'd like to be able to test for the existence of the key prior to issuing the ALTER TABLE command.
I've searched the help file and MSDN to no avail,I can't imagine that there isn't code to check for the existence of the primary key,but I sure can't find it.
Thanks