|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Can not save relationshipHi
I am using Sqlserver 2005 and in management I created some relations. One of them fale with the below error. I have tried to look for unmatched data and dublicates etc, but still keep gettitng this error message. What do you recommend me to do? Thank you in advance - Unable to create relationship 'FK_Transaktionsrader_Transaktionhuvud'. The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_Transaktionsrader_Transaktionhuvud". The conflict occurred in database "MbaseMuseumServerNetSQL", table "dbo.Transaktionhuvud", column 'TransaktionhuvudTransaktionsnr'. It would help us better assist you if you could include table DDL for both
tables; without it, we cannot help you. (For help with that refer to: http://www.aspfaq.com/5006 and to http://classicasp.aspfaq.com/general/how-do-i-make-sure-my-asp-question-gets-answered.html ) The less 'set up' work we have to do, the more likely you are going to have folks tackle your problem and help you. Without this effort from you, we are just playing guessing games. -- Show quoteArnie Rowland, Ph.D. Westwood Consulting, Inc Most good judgment comes from experience. Most experience comes from bad judgment. - Anonymous "Mattias" <Matt***@discussions.microsoft.com> wrote in message news:3EAD7DFC-C005-4415-A17F-5FD29EF8D4A2@microsoft.com... > Hi > > I am using Sqlserver 2005 and in management I created some relations. > One of them fale with the below error. > I have tried to look for unmatched data and dublicates etc, but still keep > gettitng this error message. > > What do you recommend me to do? > > Thank you in advance > > - Unable to create relationship 'FK_Transaktionsrader_Transaktionhuvud'. > The ALTER TABLE statement conflicted with the FOREIGN KEY constraint > "FK_Transaktionsrader_Transaktionhuvud". > The conflict occurred in database "MbaseMuseumServerNetSQL", table > "dbo.Transaktionhuvud", column 'TransaktionhuvudTransaktionsnr'. Hi and thanks for your reply.
I have the DDL for both tables ready here. Can it be attached to the post or shall I send it separatly somewhere? I tried to use sql code you recommend to generate inserts, sample data but I receive the error below "Could not find stored procedure sp_generate_inserts'." What do you recommend me to do? Mattias Show quote "Arnie Rowland" wrote: > It would help us better assist you if you could include table DDL for both > tables; without it, we cannot help you. (For help with that refer to: > http://www.aspfaq.com/5006 and to > http://classicasp.aspfaq.com/general/how-do-i-make-sure-my-asp-question-gets-answered.html ) > > > > The less 'set up' work we have to do, the more likely you are going to have > folks tackle your problem and help you. Without this effort from you, we are > just playing guessing games. > > > -- > Arnie Rowland, Ph.D. > Westwood Consulting, Inc > > Most good judgment comes from experience. > Most experience comes from bad judgment. > - Anonymous > > > "Mattias" <Matt***@discussions.microsoft.com> wrote in message > news:3EAD7DFC-C005-4415-A17F-5FD29EF8D4A2@microsoft.com... > > Hi > > > > I am using Sqlserver 2005 and in management I created some relations. > > One of them fale with the below error. > > I have tried to look for unmatched data and dublicates etc, but still keep > > gettitng this error message. > > > > What do you recommend me to do? > > > > Thank you in advance > > > > - Unable to create relationship 'FK_Transaktionsrader_Transaktionhuvud'. > > The ALTER TABLE statement conflicted with the FOREIGN KEY constraint > > "FK_Transaktionsrader_Transaktionhuvud". > > The conflict occurred in database "MbaseMuseumServerNetSQL", table > > "dbo.Transaktionhuvud", column 'TransaktionhuvudTransaktionsnr'. > > > Please include (copy and paste) the DDL in a post.
-- Show quoteArnie Rowland, Ph.D. Westwood Consulting, Inc Most good judgment comes from experience. Most experience comes from bad judgment. - Anonymous "Mattias" <Matt***@discussions.microsoft.com> wrote in message news:14FF1450-A7AB-4D25-BE5C-4D75B50845F7@microsoft.com... > Hi and thanks for your reply. > > I have the DDL for both tables ready here. > > Can it be attached to the post or shall I send it separatly somewhere? > > I tried to use sql code you recommend to generate inserts, sample data but > I > receive the error below > > "Could not find stored procedure sp_generate_inserts'." What do you > recommend me to do? > > Mattias > > > "Arnie Rowland" wrote: > >> It would help us better assist you if you could include table DDL for >> both >> tables; without it, we cannot help you. (For help with that refer to: >> http://www.aspfaq.com/5006 and to >> http://classicasp.aspfaq.com/general/how-do-i-make-sure-my-asp-question-gets-answered.html ) >> >> >> >> The less 'set up' work we have to do, the more likely you are going to >> have >> folks tackle your problem and help you. Without this effort from you, we >> are >> just playing guessing games. >> >> >> -- >> Arnie Rowland, Ph.D. >> Westwood Consulting, Inc >> >> Most good judgment comes from experience. >> Most experience comes from bad judgment. >> - Anonymous >> >> >> "Mattias" <Matt***@discussions.microsoft.com> wrote in message >> news:3EAD7DFC-C005-4415-A17F-5FD29EF8D4A2@microsoft.com... >> > Hi >> > >> > I am using Sqlserver 2005 and in management I created some relations. >> > One of them fale with the below error. >> > I have tried to look for unmatched data and dublicates etc, but still >> > keep >> > gettitng this error message. >> > >> > What do you recommend me to do? >> > >> > Thank you in advance >> > >> > - Unable to create relationship >> > 'FK_Transaktionsrader_Transaktionhuvud'. >> > The ALTER TABLE statement conflicted with the FOREIGN KEY constraint >> > "FK_Transaktionsrader_Transaktionhuvud". >> > The conflict occurred in database "MbaseMuseumServerNetSQL", table >> > "dbo.Transaktionhuvud", column 'TransaktionhuvudTransaktionsnr'. >> >> >> Ok here it comes!
Mattias USE [MbaseMuseumServerNetSQL] GO /****** Objekt: Table [dbo].[Transaktionhuvud] Skriptdatum: 10/09/2006 16:13:57 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Transaktionhuvud]( [TransaktionhuvudTransaktionsnr] [int] IDENTITY(1,1) NOT NULL, [Transaktionskategorinummer] [int] NULL, [TransaktionhuvudTransaktionhuvudKontaktnr] [int] NULL, [ForetagsregisterGRUNDNR] [int] NULL, [TransaktionhuvudTransaktionhuvudAnstalldHandlaggesnr] [int] NULL, [TransaktionhuvudTransaktionhuvudAnstalldFramtagesnr] [int] NULL, [TransaktionhuvudTransaktionhuvudAnstalldAvsynasnr] [int] NULL, [TransaktionhuvudTransaktionhuvudAnstalldPackasnr] [int] NULL, [TransaktionhuvudTransaktionhuvudAnstalldKurirnr] [int] NULL, [UtskriftsstatusSTATUSNR] [int] NULL, [BetalningsStatusSTATUSNR] [int] NULL, [TransaktionhuvudRegistreringsdatum] [datetime] NULL, [DatumPreliminarRetur] [datetime] NULL, [UtstallningStartdatum] [datetime] NULL, [UtstallningSlutdatum] [datetime] NULL, [Utstallning] [nvarchar](70) COLLATE Finnish_Swedish_CI_AS NULL, [TransaktionhuvudTransaktionhuvudKontaktTransportorAvhamtningnr] [int] NULL, [TransaktionhuvudTransaktionhuvudKontaktTransportorReturnr] [int] NULL, [TransaktionhuvudTransaktionhuvudTransportsattAvhamtningnr] [int] NULL, [TransaktionhuvudTransaktionhuvudTransportsattReturnr] [int] NULL, [TransaktionhuvudDefinitivRetur] [bit] NULL, [TransaktionhuvudDatumDefinitivRetur] [datetime] NULL, [TransaktionhuvudAnmarkningar] [nvarchar](max) COLLATE Finnish_Swedish_CI_AS NULL, PRIMARY KEY CLUSTERED ( [TransaktionhuvudTransaktionsnr] ASC )WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] GO ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT [ITransaktionhuvud] FOREIGN KEY([TransaktionhuvudTransaktionhuvudKontaktTransportorAvhamtningnr]) REFERENCES [dbo].[Kontakter] ([Kontaktnummer]) GO ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud] GO ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT [ITransaktionhuvud1] FOREIGN KEY([TransaktionhuvudTransaktionhuvudKontaktTransportorReturnr]) REFERENCES [dbo].[Kontakter] ([Kontaktnummer]) GO ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud1] GO ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT [ITransaktionhuvud10] FOREIGN KEY([TransaktionhuvudTransaktionhuvudAnstalldAvsynasnr]) REFERENCES [dbo].[Anstallda] ([AnstalldaAnstalldnr]) GO ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud10] GO ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT [ITransaktionhuvud11] FOREIGN KEY([TransaktionhuvudTransaktionhuvudAnstalldPackasnr]) REFERENCES [dbo].[Anstallda] ([AnstalldaAnstalldnr]) GO ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud11] GO ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT [ITransaktionhuvud12] FOREIGN KEY([TransaktionhuvudTransaktionhuvudAnstalldKurirnr]) REFERENCES [dbo].[Anstallda] ([AnstalldaAnstalldnr]) GO ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud12] GO ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT [ITransaktionhuvud13] FOREIGN KEY([TransaktionhuvudTransaktionhuvudKontaktnr]) REFERENCES [dbo].[Kontakter] ([Kontaktnummer]) GO ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud13] GO ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT [ITransaktionhuvud2] FOREIGN KEY([BetalningsStatusSTATUSNR]) REFERENCES [dbo].[BetalningsStatus] ([BetalningsStatusSTATUSNR]) GO ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud2] GO ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT [ITransaktionhuvud3] FOREIGN KEY([UtskriftsstatusSTATUSNR]) REFERENCES [dbo].[Utskriftsstatus] ([UtskriftsstatusSTATUSNR]) GO ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud3] GO ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT [ITransaktionhuvud4] FOREIGN KEY([ForetagsregisterGRUNDNR]) REFERENCES [dbo].[Foretagsregister] ([ForetagsregisterGRUNDNR]) GO ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud4] GO ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT [ITransaktionhuvud5] FOREIGN KEY([Transaktionskategorinummer]) REFERENCES [dbo].[Transaktionskategori] ([Transaktionskategorinummer]) GO ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud5] GO ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT [ITransaktionhuvud6] FOREIGN KEY([TransaktionhuvudTransaktionhuvudTransportsattAvhamtningnr]) REFERENCES [dbo].[TRANSPORTSATT] ([TRANSPORTSATTNR]) GO ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud6] GO ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT [ITransaktionhuvud7] FOREIGN KEY([TransaktionhuvudTransaktionhuvudTransportsattReturnr]) REFERENCES [dbo].[TRANSPORTSATT] ([TRANSPORTSATTNR]) GO ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud7] GO ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT [ITransaktionhuvud8] FOREIGN KEY([TransaktionhuvudTransaktionhuvudAnstalldHandlaggesnr]) REFERENCES [dbo].[Anstallda] ([AnstalldaAnstalldnr]) GO ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud8] GO ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT [ITransaktionhuvud9] FOREIGN KEY([TransaktionhuvudTransaktionhuvudAnstalldFramtagesnr]) REFERENCES [dbo].[Anstallda] ([AnstalldaAnstalldnr]) GO ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud9] USE [MbaseMuseumServerNetSQL] GO /****** Objekt: Table [dbo].[Transaktionsrader] Skriptdatum: 10/09/2006 16:17:38 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Transaktionsrader]( [TransaktionsraderTransaktionsraderTransaktionsrad] [int] IDENTITY(1,1) NOT NULL, [TransaktionsraderTransaktionsnr] [int] NULL, [TransaktionsraderTransaktionsraderAvgiftsnr] [int] NULL, [TransaktionsraderTransaktionsraderAvgiftsnr2] [int] NULL, [TransaktionsraderTransaktionsraderAvgiftsnr3] [int] NULL, [TransaktionsraderTransaktionsraderAvgiftsnr4] [int] NULL, [TransaktionsraderTransaktionsraderEmballagenr] [int] NULL, [Artikelnummer] [int] NULL, [Bildnr] [int] NULL, [TransaktionsraderForetagsnr] [int] NULL, [TransaktionsraderAntal] [int] NULL, [ExaktPlacering] [nvarchar](200) COLLATE Finnish_Swedish_CI_AS NULL, [TillfalligRetur] [bit] NOT NULL, [DatumTillfalligRetur] [datetime] NULL, [TransaktionsraderForsakringsvarde] [decimal](17, 6) NULL, [TransaktionsraderDefinitivRetur] [bit] NOT NULL, [TransaktionsraderDatumDefinitivRetur] [datetime] NULL, [AterDeposition] [bit] NOT NULL, [DatumHamtningUtlamning] [datetime] NOT NULL, [Undervisningstypnr] [int] NULL, [DatumVisningStart] [datetime] NULL, [TidVisningStart] [datetime] NULL, [DatumVisningSlut] [datetime] NULL, [TidVisningSlut] [datetime] NULL, [Amne] [nvarchar](50) COLLATE Finnish_Swedish_CI_AS NULL, [AntalLektioner] [nvarchar](50) COLLATE Finnish_Swedish_CI_AS NULL, [AntalPersoner] [nvarchar](50) COLLATE Finnish_Swedish_CI_AS NULL, [VisningInstalld] [bit] NULL, [DatumVisningInstalld] [datetime] NULL, [VisningUtford] [bit] NULL, [transkontaktnr] [int] NULL, [TransraderAnstalldGuideAnstalldnr] [int] NULL, [accessionsnummer] [nvarchar](20) COLLATE Finnish_Swedish_CI_AS NULL, PRIMARY KEY CLUSTERED ( [TransaktionsraderTransaktionsraderTransaktionsrad] ASC )WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] GO ALTER TABLE [dbo].[Transaktionsrader] WITH CHECK ADD CONSTRAINT [FK_Transaktionsrader_Master] FOREIGN KEY([accessionsnummer]) REFERENCES [dbo].[Master] ([MasterAccessionsnr]) GO ALTER TABLE [dbo].[Transaktionsrader] CHECK CONSTRAINT [FK_Transaktionsrader_Master] GO ALTER TABLE [dbo].[Transaktionsrader] WITH CHECK ADD CONSTRAINT [ITransaktionsrader] FOREIGN KEY([Artikelnummer]) REFERENCES [dbo].[Artiklar] ([Artikelnummer]) GO ALTER TABLE [dbo].[Transaktionsrader] CHECK CONSTRAINT [ITransaktionsrader] GO ALTER TABLE [dbo].[Transaktionsrader] WITH CHECK ADD CONSTRAINT [ITransaktionsrader10] FOREIGN KEY([transkontaktnr]) REFERENCES [dbo].[Kontakter] ([Kontaktnummer]) GO ALTER TABLE [dbo].[Transaktionsrader] CHECK CONSTRAINT [ITransaktionsrader10] GO ALTER TABLE [dbo].[Transaktionsrader] WITH CHECK ADD CONSTRAINT [ITransaktionsrader2] FOREIGN KEY([TransaktionsraderTransaktionsraderEmballagenr]) REFERENCES [dbo].[Emballage] ([Emballagenr]) GO ALTER TABLE [dbo].[Transaktionsrader] CHECK CONSTRAINT [ITransaktionsrader2] GO ALTER TABLE [dbo].[Transaktionsrader] WITH CHECK ADD CONSTRAINT [ITransaktionsrader3] FOREIGN KEY([TransaktionsraderTransaktionsraderAvgiftsnr]) REFERENCES [dbo].[Avgifter] ([Avgiftsnr]) GO ALTER TABLE [dbo].[Transaktionsrader] CHECK CONSTRAINT [ITransaktionsrader3] GO ALTER TABLE [dbo].[Transaktionsrader] WITH CHECK ADD CONSTRAINT [ITransaktionsrader4] FOREIGN KEY([TransaktionsraderTransaktionsraderAvgiftsnr2]) REFERENCES [dbo].[Avgifter] ([Avgiftsnr]) GO ALTER TABLE [dbo].[Transaktionsrader] CHECK CONSTRAINT [ITransaktionsrader4] GO ALTER TABLE [dbo].[Transaktionsrader] WITH CHECK ADD CONSTRAINT [ITransaktionsrader5] FOREIGN KEY([TransaktionsraderTransaktionsraderAvgiftsnr3]) REFERENCES [dbo].[Avgifter] ([Avgiftsnr]) GO ALTER TABLE [dbo].[Transaktionsrader] CHECK CONSTRAINT [ITransaktionsrader5] GO ALTER TABLE [dbo].[Transaktionsrader] WITH CHECK ADD CONSTRAINT [ITransaktionsrader6] FOREIGN KEY([TransaktionsraderTransaktionsraderAvgiftsnr4]) REFERENCES [dbo].[Avgifter] ([Avgiftsnr]) GO ALTER TABLE [dbo].[Transaktionsrader] CHECK CONSTRAINT [ITransaktionsrader6] GO ALTER TABLE [dbo].[Transaktionsrader] WITH CHECK ADD CONSTRAINT [ITransaktionsrader7] FOREIGN KEY([Undervisningstypnr]) REFERENCES [dbo].[UNDERVISNINGSTYP] ([Undervisningstypnr]) GO ALTER TABLE [dbo].[Transaktionsrader] CHECK CONSTRAINT [ITransaktionsrader7] GO ALTER TABLE [dbo].[Transaktionsrader] WITH CHECK ADD CONSTRAINT [ITransaktionsrader8] FOREIGN KEY([Bildnr]) REFERENCES [dbo].[Bilder] ([Bildnr]) GO ALTER TABLE [dbo].[Transaktionsrader] CHECK CONSTRAINT [ITransaktionsrader8] GO ALTER TABLE [dbo].[Transaktionsrader] WITH CHECK ADD CONSTRAINT [ITransaktionsrader9] FOREIGN KEY([TransraderAnstalldGuideAnstalldnr]) REFERENCES [dbo].[Anstallda] ([AnstalldaAnstalldnr]) GO ALTER TABLE [dbo].[Transaktionsrader] CHECK CONSTRAINT [ITransaktionsrader9] Show quote "Arnie Rowland" wrote: > Please include (copy and paste) the DDL in a post. > > -- > Arnie Rowland, Ph.D. > Westwood Consulting, Inc > > Most good judgment comes from experience. > Most experience comes from bad judgment. > - Anonymous > > > "Mattias" <Matt***@discussions.microsoft.com> wrote in message > news:14FF1450-A7AB-4D25-BE5C-4D75B50845F7@microsoft.com... > > Hi and thanks for your reply. > > > > I have the DDL for both tables ready here. > > > > Can it be attached to the post or shall I send it separatly somewhere? > > > > I tried to use sql code you recommend to generate inserts, sample data but > > I > > receive the error below > > > > "Could not find stored procedure sp_generate_inserts'." What do you > > recommend me to do? > > > > Mattias > > > > > > "Arnie Rowland" wrote: > > > >> It would help us better assist you if you could include table DDL for > >> both > >> tables; without it, we cannot help you. (For help with that refer to: > >> http://www.aspfaq.com/5006 and to > >> http://classicasp.aspfaq.com/general/how-do-i-make-sure-my-asp-question-gets-answered.html ) > >> > >> > >> > >> The less 'set up' work we have to do, the more likely you are going to > >> have > >> folks tackle your problem and help you. Without this effort from you, we > >> are > >> just playing guessing games. > >> > >> > >> -- > >> Arnie Rowland, Ph.D. > >> Westwood Consulting, Inc > >> > >> Most good judgment comes from experience. > >> Most experience comes from bad judgment. > >> - Anonymous > >> > >> > >> "Mattias" <Matt***@discussions.microsoft.com> wrote in message > >> news:3EAD7DFC-C005-4415-A17F-5FD29EF8D4A2@microsoft.com... > >> > Hi > >> > > >> > I am using Sqlserver 2005 and in management I created some relations. > >> > One of them fale with the below error. > >> > I have tried to look for unmatched data and dublicates etc, but still > >> > keep > >> > gettitng this error message. > >> > > >> > What do you recommend me to do? > >> > > >> > Thank you in advance > >> > > >> > - Unable to create relationship > >> > 'FK_Transaktionsrader_Transaktionhuvud'. > >> > The ALTER TABLE statement conflicted with the FOREIGN KEY constraint > >> > "FK_Transaktionsrader_Transaktionhuvud". > >> > The conflict occurred in database "MbaseMuseumServerNetSQL", table > >> > "dbo.Transaktionhuvud", column 'TransaktionhuvudTransaktionsnr'. > >> > >> > >> > > > Mattias,
Try this. Use your script and create the two tables on another test server or some test database. Then run the script to create the relationship you are having problems creating - or use Management Studio if that's how you were doing it. If you can create the relationship and don't get an error then that tells you it's likely related to the data in the two tables violating the constraint. If you can't create the relationship from Management Studio, hit the script button (hopefully there is one in the GUI end...don't use that much so I don't remember) and try just executing the script. If you still get an error using the script and with no data, then post the script here. -Sue On Mon, 9 Oct 2006 07:20:02 -0700, Mattias <Matt***@discussions.microsoft.com> wrote: Show quote >Ok here it comes! > >Mattias > >USE [MbaseMuseumServerNetSQL] >GO >/****** Objekt: Table [dbo].[Transaktionhuvud] Skriptdatum: 10/09/2006 >16:13:57 ******/ >SET ANSI_NULLS ON >GO >SET QUOTED_IDENTIFIER ON >GO >CREATE TABLE [dbo].[Transaktionhuvud]( > [TransaktionhuvudTransaktionsnr] [int] IDENTITY(1,1) NOT NULL, > [Transaktionskategorinummer] [int] NULL, > [TransaktionhuvudTransaktionhuvudKontaktnr] [int] NULL, > [ForetagsregisterGRUNDNR] [int] NULL, > [TransaktionhuvudTransaktionhuvudAnstalldHandlaggesnr] [int] NULL, > [TransaktionhuvudTransaktionhuvudAnstalldFramtagesnr] [int] NULL, > [TransaktionhuvudTransaktionhuvudAnstalldAvsynasnr] [int] NULL, > [TransaktionhuvudTransaktionhuvudAnstalldPackasnr] [int] NULL, > [TransaktionhuvudTransaktionhuvudAnstalldKurirnr] [int] NULL, > [UtskriftsstatusSTATUSNR] [int] NULL, > [BetalningsStatusSTATUSNR] [int] NULL, > [TransaktionhuvudRegistreringsdatum] [datetime] NULL, > [DatumPreliminarRetur] [datetime] NULL, > [UtstallningStartdatum] [datetime] NULL, > [UtstallningSlutdatum] [datetime] NULL, > [Utstallning] [nvarchar](70) COLLATE Finnish_Swedish_CI_AS NULL, > [TransaktionhuvudTransaktionhuvudKontaktTransportorAvhamtningnr] [int] NULL, > [TransaktionhuvudTransaktionhuvudKontaktTransportorReturnr] [int] NULL, > [TransaktionhuvudTransaktionhuvudTransportsattAvhamtningnr] [int] NULL, > [TransaktionhuvudTransaktionhuvudTransportsattReturnr] [int] NULL, > [TransaktionhuvudDefinitivRetur] [bit] NULL, > [TransaktionhuvudDatumDefinitivRetur] [datetime] NULL, > [TransaktionhuvudAnmarkningar] [nvarchar](max) COLLATE >Finnish_Swedish_CI_AS NULL, >PRIMARY KEY CLUSTERED >( > [TransaktionhuvudTransaktionsnr] ASC >)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY] >) ON [PRIMARY] > >GO >ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT >[ITransaktionhuvud] FOREIGN >KEY([TransaktionhuvudTransaktionhuvudKontaktTransportorAvhamtningnr]) >REFERENCES [dbo].[Kontakter] ([Kontaktnummer]) >GO >ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud] >GO >ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT >[ITransaktionhuvud1] FOREIGN >KEY([TransaktionhuvudTransaktionhuvudKontaktTransportorReturnr]) >REFERENCES [dbo].[Kontakter] ([Kontaktnummer]) >GO >ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud1] >GO >ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT >[ITransaktionhuvud10] FOREIGN >KEY([TransaktionhuvudTransaktionhuvudAnstalldAvsynasnr]) >REFERENCES [dbo].[Anstallda] ([AnstalldaAnstalldnr]) >GO >ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud10] >GO >ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT >[ITransaktionhuvud11] FOREIGN >KEY([TransaktionhuvudTransaktionhuvudAnstalldPackasnr]) >REFERENCES [dbo].[Anstallda] ([AnstalldaAnstalldnr]) >GO >ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud11] >GO >ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT >[ITransaktionhuvud12] FOREIGN >KEY([TransaktionhuvudTransaktionhuvudAnstalldKurirnr]) >REFERENCES [dbo].[Anstallda] ([AnstalldaAnstalldnr]) >GO >ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud12] >GO >ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT >[ITransaktionhuvud13] FOREIGN KEY([TransaktionhuvudTransaktionhuvudKontaktnr]) >REFERENCES [dbo].[Kontakter] ([Kontaktnummer]) >GO >ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud13] >GO >ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT >[ITransaktionhuvud2] FOREIGN KEY([BetalningsStatusSTATUSNR]) >REFERENCES [dbo].[BetalningsStatus] ([BetalningsStatusSTATUSNR]) >GO >ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud2] >GO >ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT >[ITransaktionhuvud3] FOREIGN KEY([UtskriftsstatusSTATUSNR]) >REFERENCES [dbo].[Utskriftsstatus] ([UtskriftsstatusSTATUSNR]) >GO >ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud3] >GO >ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT >[ITransaktionhuvud4] FOREIGN KEY([ForetagsregisterGRUNDNR]) >REFERENCES [dbo].[Foretagsregister] ([ForetagsregisterGRUNDNR]) >GO >ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud4] >GO >ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT >[ITransaktionhuvud5] FOREIGN KEY([Transaktionskategorinummer]) >REFERENCES [dbo].[Transaktionskategori] ([Transaktionskategorinummer]) >GO >ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud5] >GO >ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT >[ITransaktionhuvud6] FOREIGN >KEY([TransaktionhuvudTransaktionhuvudTransportsattAvhamtningnr]) >REFERENCES [dbo].[TRANSPORTSATT] ([TRANSPORTSATTNR]) >GO >ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud6] >GO >ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT >[ITransaktionhuvud7] FOREIGN >KEY([TransaktionhuvudTransaktionhuvudTransportsattReturnr]) >REFERENCES [dbo].[TRANSPORTSATT] ([TRANSPORTSATTNR]) >GO >ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud7] >GO >ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT >[ITransaktionhuvud8] FOREIGN >KEY([TransaktionhuvudTransaktionhuvudAnstalldHandlaggesnr]) >REFERENCES [dbo].[Anstallda] ([AnstalldaAnstalldnr]) >GO >ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud8] >GO >ALTER TABLE [dbo].[Transaktionhuvud] WITH CHECK ADD CONSTRAINT >[ITransaktionhuvud9] FOREIGN >KEY([TransaktionhuvudTransaktionhuvudAnstalldFramtagesnr]) >REFERENCES [dbo].[Anstallda] ([AnstalldaAnstalldnr]) >GO >ALTER TABLE [dbo].[Transaktionhuvud] CHECK CONSTRAINT [ITransaktionhuvud9] > > > >USE [MbaseMuseumServerNetSQL] >GO >/****** Objekt: Table [dbo].[Transaktionsrader] Skriptdatum: 10/09/2006 >16:17:38 ******/ >SET ANSI_NULLS ON >GO >SET QUOTED_IDENTIFIER ON >GO >CREATE TABLE [dbo].[Transaktionsrader]( > [TransaktionsraderTransaktionsraderTransaktionsrad] [int] IDENTITY(1,1) NOT >NULL, > [TransaktionsraderTransaktionsnr] [int] NULL, > [TransaktionsraderTransaktionsraderAvgiftsnr] [int] NULL, > [TransaktionsraderTransaktionsraderAvgiftsnr2] [int] NULL, > [TransaktionsraderTransaktionsraderAvgiftsnr3] [int] NULL, > [TransaktionsraderTransaktionsraderAvgiftsnr4] [int] NULL, > [TransaktionsraderTransaktionsraderEmballagenr] [int] NULL, > [Artikelnummer] [int] NULL, > [Bildnr] [int] NULL, > [TransaktionsraderForetagsnr] [int] NULL, > [TransaktionsraderAntal] [int] NULL, > [ExaktPlacering] [nvarchar](200) COLLATE Finnish_Swedish_CI_AS NULL, > [TillfalligRetur] [bit] NOT NULL, > [DatumTillfalligRetur] [datetime] NULL, > [TransaktionsraderForsakringsvarde] [decimal](17, 6) NULL, > [TransaktionsraderDefinitivRetur] [bit] NOT NULL, > [TransaktionsraderDatumDefinitivRetur] [datetime] NULL, > [AterDeposition] [bit] NOT NULL, > [DatumHamtningUtlamning] [datetime] NOT NULL, > [Undervisningstypnr] [int] NULL, > [DatumVisningStart] [datetime] NULL, > [TidVisningStart] [datetime] NULL, > [DatumVisningSlut] [datetime] NULL, > [TidVisningSlut] [datetime] NULL, > [Amne] [nvarchar](50) COLLATE Finnish_Swedish_CI_AS NULL, > [AntalLektioner] [nvarchar](50) COLLATE Finnish_Swedish_CI_AS NULL, > [AntalPersoner] [nvarchar](50) COLLATE Finnish_Swedish_CI_AS NULL, > [VisningInstalld] [bit] NULL, > [DatumVisningInstalld] [datetime] NULL, > [VisningUtford] [bit] NULL, > [transkontaktnr] [int] NULL, > [TransraderAnstalldGuideAnstalldnr] [int] NULL, > [accessionsnummer] [nvarchar](20) COLLATE Finnish_Swedish_CI_AS NULL, >PRIMARY KEY CLUSTERED >( > [TransaktionsraderTransaktionsraderTransaktionsrad] ASC >)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY] >) ON [PRIMARY] > >GO >ALTER TABLE [dbo].[Transaktionsrader] WITH CHECK ADD CONSTRAINT >[FK_Transaktionsrader_Master] FOREIGN KEY([accessionsnummer]) >REFERENCES [dbo].[Master] ([MasterAccessionsnr]) >GO >ALTER TABLE [dbo].[Transaktionsrader] CHECK CONSTRAINT >[FK_Transaktionsrader_Master] >GO >ALTER TABLE [dbo].[Transaktionsrader] WITH CHECK ADD CONSTRAINT >[ITransaktionsrader] FOREIGN KEY([Artikelnummer]) >REFERENCES [dbo].[Artiklar] ([Artikelnummer]) >GO >ALTER TABLE [dbo].[Transaktionsrader] CHECK CONSTRAINT [ITransaktionsrader] >GO >ALTER TABLE [dbo].[Transaktionsrader] WITH CHECK ADD CONSTRAINT >[ITransaktionsrader10] FOREIGN KEY([transkontaktnr]) >REFERENCES [dbo].[Kontakter] ([Kontaktnummer]) >GO >ALTER TABLE [dbo].[Transaktionsrader] CHECK CONSTRAINT [ITransaktionsrader10] >GO >ALTER TABLE [dbo].[Transaktionsrader] WITH CHECK ADD CONSTRAINT >[ITransaktionsrader2] FOREIGN >KEY([TransaktionsraderTransaktionsraderEmballagenr]) >REFERENCES [dbo].[Emballage] ([Emballagenr]) >GO >ALTER TABLE [dbo].[Transaktionsrader] CHECK CONSTRAINT [ITransaktionsrader2] >GO >ALTER TABLE [dbo].[Transaktionsrader] WITH CHECK ADD CONSTRAINT >[ITransaktionsrader3] FOREIGN >KEY([TransaktionsraderTransaktionsraderAvgiftsnr]) >REFERENCES [dbo].[Avgifter] ([Avgiftsnr]) >GO >ALTER TABLE [dbo].[Transaktionsrader] CHECK CONSTRAINT [ITransaktionsrader3] >GO >ALTER TABLE [dbo].[Transaktionsrader] WITH CHECK ADD CONSTRAINT >[ITransaktionsrader4] FOREIGN >KEY([TransaktionsraderTransaktionsraderAvgiftsnr2]) >REFERENCES [dbo].[Avgifter] ([Avgiftsnr]) >GO >ALTER TABLE [dbo].[Transaktionsrader] CHECK CONSTRAINT [ITransaktionsrader4] >GO >ALTER TABLE [dbo].[Transaktionsrader] WITH CHECK ADD CONSTRAINT >[ITransaktionsrader5] FOREIGN >KEY([TransaktionsraderTransaktionsraderAvgiftsnr3]) >REFERENCES [dbo].[Avgifter] ([Avgiftsnr]) >GO >ALTER TABLE [dbo].[Transaktionsrader] CHECK CONSTRAINT [ITransaktionsrader5] >GO >ALTER TABLE [dbo].[Transaktionsrader] WITH CHECK ADD CONSTRAINT >[ITransaktionsrader6] FOREIGN >KEY([TransaktionsraderTransaktionsraderAvgiftsnr4]) >REFERENCES [dbo].[Avgifter] ([Avgiftsnr]) >GO >ALTER TABLE [dbo].[Transaktionsrader] CHECK CONSTRAINT [ITransaktionsrader6] >GO >ALTER TABLE [dbo].[Transaktionsrader] WITH CHECK ADD CONSTRAINT >[ITransaktionsrader7] FOREIGN KEY([Undervisningstypnr]) >REFERENCES [dbo].[UNDERVISNINGSTYP] ([Undervisningstypnr]) >GO >ALTER TABLE [dbo].[Transaktionsrader] CHECK CONSTRAINT [ITransaktionsrader7] >GO >ALTER TABLE [dbo].[Transaktionsrader] WITH CHECK ADD CONSTRAINT >[ITransaktionsrader8] FOREIGN KEY([Bildnr]) >REFERENCES [dbo].[Bilder] ([Bildnr]) >GO >ALTER TABLE [dbo].[Transaktionsrader] CHECK CONSTRAINT [ITransaktionsrader8] >GO >ALTER TABLE [dbo].[Transaktionsrader] WITH CHECK ADD CONSTRAINT >[ITransaktionsrader9] FOREIGN KEY([TransraderAnstalldGuideAnstalldnr]) >REFERENCES [dbo].[Anstallda] ([AnstalldaAnstalldnr]) >GO >ALTER TABLE [dbo].[Transaktionsrader] CHECK CONSTRAINT [ITransaktionsrader9] >"Arnie Rowland" wrote: > >> Please include (copy and paste) the DDL in a post. >> >> -- >> Arnie Rowland, Ph.D. >> Westwood Consulting, Inc >> >> Most good judgment comes from experience. >> Most experience comes from bad judgment. >> - Anonymous >> >> >> "Mattias" <Matt***@discussions.microsoft.com> wrote in message >> news:14FF1450-A7AB-4D25-BE5C-4D75B50845F7@microsoft.com... >> > Hi and thanks for your reply. >> > >> > I have the DDL for both tables ready here. >> > >> > Can it be attached to the post or shall I send it separatly somewhere? >> > >> > I tried to use sql code you recommend to generate inserts, sample data but >> > I >> > receive the error below >> > >> > "Could not find stored procedure sp_generate_inserts'." What do you >> > recommend me to do? >> > >> > Mattias >> > >> > >> > "Arnie Rowland" wrote: >> > >> >> It would help us better assist you if you could include table DDL for >> >> both >> >> tables; without it, we cannot help you. (For help with that refer to: >> >> http://www.aspfaq.com/5006 and to >> >> http://classicasp.aspfaq.com/general/how-do-i-make-sure-my-asp-question-gets-answered.html ) >> >> >> >> >> >> >> >> The less 'set up' work we have to do, the more likely you are going to >> >> have >> >> folks tackle your problem and help you. Without this effort from you, we >> >> are >> >> just playing guessing games. >> >> >> >> >> >> -- >> >> Arnie Rowland, Ph.D. >> >> Westwood Consulting, Inc >> >> >> >> Most good judgment comes from experience. >> >> Most experience comes from bad judgment. >> >> - Anonymous >> >> >> >> >> >> "Mattias" <Matt***@discussions.microsoft.com> wrote in message >> >> news:3EAD7DFC-C005-4415-A17F-5FD29EF8D4A2@microsoft.com... >> >> > Hi >> >> > >> >> > I am using Sqlserver 2005 and in management I created some relations. >> >> > One of them fale with the below error. >> >> > I have tried to look for unmatched data and dublicates etc, but still >> >> > keep >> >> > gettitng this error message. >> >> > >> >> > What do you recommend me to do? >> >> > >> >> > Thank you in advance >> >> > >> >> > - Unable to create relationship >> >> > 'FK_Transaktionsrader_Transaktionhuvud'. >> >> > The ALTER TABLE statement conflicted with the FOREIGN KEY constraint >> >> > "FK_Transaktionsrader_Transaktionhuvud". >> >> > The conflict occurred in database "MbaseMuseumServerNetSQL", table >> >> > "dbo.Transaktionhuvud", column 'TransaktionhuvudTransaktionsnr'. >> >> >> >> >> >> >> >> >> |
|||||||||||||||||||||||