VilemRousi
VilemRousi

Reputation: 2142

How to DROP PRIMARY KEY from Column in SQL Server 2008 R2

I have a one more question about T-SQL

I´d like to DROP a PRIMARY KEY in database [COST_mesta_test].[dbo].['1965$'] ,table '1965$'

I have primary key on column obec (it´s varchar column) and this doesn´t work

ALTER TABLE [COST_mesta_test].[dbo].['1965$'] 
DROP CONSTRAINT obec

It´s give me an error

'obec' is not a constraint. Msg 3727, Level 16, State 0, Line 1 Could not drop constraint. See previous errors.

Really don´t know why, because 'obec' is really PK.

Thanks a lot for help!

Upvotes: 0

Views: 7088

Answers (1)

Bennor McCarthy
Bennor McCarthy

Reputation: 11675

The name of your primary key isn't likely to be the name of the constraint.

You can use exec [COST_mesta_test]..sp_help '1965$' to find the name of the constraint (it will be in the last line of the results).

Upvotes: 2

Related Questions