Declaration of 2 PK Sql

0

Good afternoon.

I have the Icms table that has the IcmClaFiscal as the PK, I need to pass the IcmEmpresa column also as PK, but SQL returns me an alert. As I already managed to do this procedure in other cases through Design and it worked, I was afraid to do the same for this case because, in the others did not return this alert. Could you advise me how to proceed?

Thank you.

    
asked by anonymous 10.05.2017 / 19:07

1 answer

1

First you will have to drop your PK and then recreate it, to do this you will need to execute the following commands.

ALTER TABLE Icms
DROP CONSTRAINT <constraint_name>

ALTER TABLE Icms
ADD CONSTRAINT <constraint_name> PRIMARY KEY (IcmClaFiscal,IcmEmpresa )

Where you have <constraint_name> you have to put the name of your PK, just as it is in the database

    
10.05.2017 / 19:32