Ranga_The_Donga Posted October 18, 2011 Report Posted October 18, 2011 nenu primary key create chesthuna kuda naku e error vasthundhii.... After passing "Primary Key creation" it is going for foreign key creation....... [b]Begin Tran[/b] [b]Alter table dbo.OwnerPart[/b] [b]Add ownerSupplierCode ownersupplier default '' not null[/b] [b]Alter table dbo.OwnerPartUnassigned[/b] [b]drop constraint FK_OwnerPartActions_OwnerPart[/b] [b]Alter table dbo.PartXref[/b] [b]drop constraint FK_PartXref_OwnerPart[/b] [b]Alter table dbo.OwnerPart[/b] [b]drop constraint PK_OwnerPart[/b] [b]Alter table dbo.OwnerPart[/b] [b]Add constraint PK_OwnerPart PRIMARY KEY([ownerCode],[ownerPartCode],[ownerPartRevision],[ownerSupplierCode])[/b] [b]ALTER TABLE dbo.OwnerPartUnassigned [/b] [b]ADD CONSTRAINT FK_OwnerPartActions_OwnerPart FOREIGN KEY([ownerCode], [ownerPartCode], [ownerPartRevision])[/b] [b]REFERENCES dbo.OwnerPart ([ownerCode], [ownerPartCode], [ownerPartRevision])[/b] [b]--ON UPDATE CASCADE[/b] [b]--ON DELETE CASCADE[/b] [b]ALTER TABLE [dbo].[PartXref] ADD CONSTRAINT [FK_PartXref_OwnerPart] FOREIGN KEY([ownerCode], [ownerPartCode], [ownerPartRevision])[/b] [b]REFERENCES [dbo].[OwnerPart] ([ownerCode], [ownerPartCode], [ownerPartRevision])[/b] [b]ON UPDATE CASCADE[/b] [b]ON DELETE CASCADE[/b] execute([color=#ff0000] 'select ownerSupplierCode from dbo.OwnerPart[/color] [color=#ff0000]Update OwnerPart[/color] [color=#ff0000]SET OwnerPart.ownerSupplierCode=PartXref.ownerSupplierCode[/color] [color=#ff0000]From OwnerPart, PartXref[/color] [color=#ff0000]Where[/color] [color=#ff0000]PartXref.ownerCode = OwnerPart.ownerCode[/color] [color=#ff0000]And PartXref.ownerPartCode = OwnerPart.ownerPartCode[/color] [color=#ff0000]And PartXref.ownerPartRevision = OwnerPart.ownerPartRevision[/color] [color=#ff0000]Select onwnerSupplierCode from dbo.OwnerPart'[/color]) Rollback Error:- Msg 1776, Level 16, State 0, Line 19 There are no primary or candidate keys in the referenced table 'dbo.OwnerPart' that match the referencing column list in the foreign key 'FK_OwnerPartActions_OwnerPart'. Msg 1750, Level 16, State 0, Line 19 Could not create constraint. See previous errors.
zerokool1290 Posted October 18, 2011 Report Posted October 18, 2011 sql ayithe kastam baa. poni ademaina sinnaga unda ante adhi . all i can do is taduni paiki lepadam..
Ranga_The_Donga Posted October 18, 2011 Author Report Posted October 18, 2011 [quote name='zerokool1290' timestamp='1318965819' post='3004392'] sql ayithe kastam baa. poni ademaina sinnaga unda ante adhi . all i can do is taduni paiki lepadam.. [/quote] ponile ba...nuvvaina paiki lepav......thnx...
charygaru Posted October 18, 2011 Report Posted October 18, 2011 naaku sakkaga DBA ne raadu developing ante [img]http://i43.tinypic.com/9jhqw1.gif[/img]
demo Posted October 18, 2011 Report Posted October 18, 2011 help nuvu PK ki FK reference sariga ichi undaka povachu....
Ranga_The_Donga Posted October 18, 2011 Author Report Posted October 18, 2011 [quote name='demo' timestamp='1318966697' post='3004503'] help nuvu PK ki FK reference sariga ichi undaka povachu.... [/quote] FK ki PK reference kavali ba.......deeni gurinchi nuvvu matladuthundhi ayithe...na doubt kuda adhe.... antha correct gane vundhi.....extra one column tappa....
demo Posted October 18, 2011 Report Posted October 18, 2011 naku kuda anta telvadu...first table lo check chesko avi correct ga PK assign ayava leda ani and then the next table try chesi chudu for FK.. e lopala evarina experts vaste adagachu..[quote name='Jeedeelu' timestamp='1318966878' post='3004523'] FK ki PK reference kavali ba.......deeni gurinchi nuvvu matladuthundhi ayithe...na doubt kuda adhe.... antha correct gane vundhi.....extra one column tappa.... [/quote]
pandugadu999 Posted October 18, 2011 Report Posted October 18, 2011 [quote name='Jeedeelu' timestamp='1318966878' post='3004523'] FK ki PK reference kavali ba.......deeni gurinchi nuvvu matladuthundhi ayithe...na doubt kuda adhe.... antha correct gane vundhi.....extra one column tappa.... [/quote] nuvvu PK lo 4 columns pina create chesi, FK lo matram 3 columns e reference chesav kada...that must be wrong.. endukante... if the primary key is a set of columns (a composite key), then the foreign key also must be a set of columns that corresponds to the composite key.
Ranga_The_Donga Posted October 19, 2011 Author Report Posted October 19, 2011 [quote name='pandugadu999' timestamp='1318972520' post='3004999'] nuvvu PK lo 4 columns pina create chesi, FK lo matram 3 columns e reference chesav kada...that must be wrong.. endukante... if the primary key is a set of columns (a composite key), then the foreign key also must be a set of columns that corresponds to the composite key. [/quote] Ya add chesa...ayina gani error isthundhii... Alter table conflict ani.....
Recommended Posts