MS SQL bug: Compound PRIMARY KEY interpreted as 2 PKs and Heidi uses only the last PK when changing a value

FlavioSuar's profile image FlavioSuar posted 5 years ago in General Permalink

Hi!

I have a table with a PK made of 3 columns. If I set a filter to get 1 unique record and change the value of a column that isn't on the PK, the generated code to change the value uses only the LAST PK! On this case, the PRIMARY KEY ("Cod_PesJur", "Cod_PesFis") For example: UPDATE "SIGES"."dbo"."EvenEmprPrest" SET "CodFatEvento"='20459' WHERE "Cod_PesJur"=164 AND "Cod_PesFis"=383669;

There are other tables with compound PKs that don't have this issue... Any clue?? TIA!!

CREATE command on SQL Server Management Studio: CREATE TABLE [dbo].[EvenEmprPrest]( [Num_EVE] [int] NOT NULL, [Cod_PesJur] [int] NOT NULL, [Cod_PesFis] [int] NOT NULL, [CodFatEvento] [int] NULL, [PagtoLiberado] [tinyint] NULL, [Cod_EntConc] [int] NULL, [CodFatEvento_EC] [int] NULL, [PagtoLiberado_EC] [tinyint] NULL, CONSTRAINT [PorEventoPJurPrestador_PK] PRIMARY KEY CLUSTERED ( [Num_EVE] ASC, [Cod_PesJur] ASC, [Cod_PesFis] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY], CONSTRAINT [PorEventoPFis_U] UNIQUE NONCLUSTERED ( [Num_EVE] ASC, [Cod_PesFis] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]

CREATE command on HeidiSQL: CREATE TABLE "EvenEmprPrest" ( "Num_EVE" INT NOT NULL, "Cod_PesJur" INT NOT NULL, "Cod_PesFis" INT NOT NULL, "CodFatEvento" INT NULL DEFAULT NULL, "PagtoLiberado" TINYINT NULL DEFAULT NULL, "Cod_EntConc" INT NULL DEFAULT NULL, "CodFatEvento_EC" INT NULL DEFAULT NULL, "PagtoLiberado_EC" TINYINT NULL DEFAULT NULL, UNIQUE INDEX "UNIQUE" ("Num_EVE"), PRIMARY KEY ("Num_EVE"), UNIQUE INDEX "UNIQUE" ("Cod_PesFis"), PRIMARY KEY ("Cod_PesJur", "Cod_PesFis") ) ;

Please login to leave a reply, or register at first.