Hi, I have a table where I want to remove the Primary key. I run the sql command of "ALTER TABLE table_name DROP CONSTRAINT Primary_key"
The error I get is "CHECK constraint Primary_Key does not exist.
When I added the Primary key, I used the sql command of "ALTER TABLE table_name ALTER COLUMN column_name varchar(30) PRIMARY KEY"
This added fine because I now cannot drop the column.
I am trying to find the constraint name so I can delete it. I have run code to try to find the constraint name. This is what I have run:
Dim cs As Constraint
For Each cs In dsBudget.Tables.Item(0).Constraints
Console.WriteLine(cs.ConstraintName)
Next cs
The problem I am facing is that this code cannot pickup any constraints. If I use code to find a primary key, the array returns -1 indicating that there is no primary key.
The table or column definitely has a primary key.
My question is, if I cant find out the name of the constraint, how can I remove it?
Thank you for your assistance
The error I get is "CHECK constraint Primary_Key does not exist.
When I added the Primary key, I used the sql command of "ALTER TABLE table_name ALTER COLUMN column_name varchar(30) PRIMARY KEY"
This added fine because I now cannot drop the column.
I am trying to find the constraint name so I can delete it. I have run code to try to find the constraint name. This is what I have run:
Dim cs As Constraint
For Each cs In dsBudget.Tables.Item(0).Constraints
Console.WriteLine(cs.ConstraintName)
Next cs
The problem I am facing is that this code cannot pickup any constraints. If I use code to find a primary key, the array returns -1 indicating that there is no primary key.
The table or column definitely has a primary key.
My question is, if I cant find out the name of the constraint, how can I remove it?
Thank you for your assistance