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.
| Author |
Topic |
|
eddie
Starting Member
45 Posts |
Posted - 2001-05-03 : 14:54:40
|
| I am trying to check to see if a primary key exists and then delete it if it does but I will not necessarily know the table it is on. Here is my scenario, I am updating some tables, the database could possibly have two versions of the same table, an old one and a new one. I want to put a pk on the new one. I am running into trouble because the pk of the same name is on the old table. I want to delete this pk regardless of the table so that I can use it on the new table.I have the following code which seems to work but when I view the tables, they now both have primary keys of the same name..is this a problem?if object_id('ex.pk_example') is not null delete from sysobjects where name='pk_example' gowhereas I used to have this:if object_id('ex.pk_example') is not null alter table ex.example drop constraint pk_examplegoThanks,EddieEdited by - eddie on 05/03/2001 14:55:30 |
|
|
|
|
|