-
September 4th, 2020, 04:51 AM
#1
Why do I copy Table1 contents to Table with the error ?
I have 2 Tables: TABQUANHEGD: destination and TABNGUON: source
I implemented sql in SQL Server 2005 with an error
Code:
INSERT INTO TABQUANHEGD(IDQHGD, MASTT, NGUOITHAN, NGAYSINH, MAGT, MAQH, MAQT, OHIENTAI, NGHENGHIEP, NOILAM, DIENTHOAI, TRUGIACANH, NGAYBD, NGAYKT, LIENHE, DAMAT, ANH, GHICHU)
SELECT IDQHGD, MASTT, NGUOITHAN, NGAYSINH, MAGT, MAQH, MAQT, OHIENTAI, NGHENGHIEP, NOILAM, DIENTHOAI, TRUGIACANH, NGAYBD, NGAYKT, LIENHE, DAMAT, ANH, GHICHU FROM TABNGUON;
Msg 547, Level 16, State 0, Line 1
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_TABKHOKIEMKECT_TABKHOKIEMKE". The conflict occurred in database "NhanSu", table "dbo.TABQUANHEGDTT", column 'IDQH'.
The statement has been terminated.
In the database I don't have these 2 tables:
TABKHOKIEMKECT
TABKHOKIEMKE
I don't know where to get these 2 Tables to report an error
I want to copy the content from Table1 to Table2, how do I write an SQL query ?
-
September 4th, 2020, 05:10 AM
#2
Re: Why do I copy Table1 contents to Table with the error ?
What are the table definitions?
-
September 4th, 2020, 10:26 AM
#3
Re: Why do I copy Table1 contents to Table with the error ?
Originally Posted by dongtrien
I have 2 Tables: TABQUANHEGD: destination and TABNGUON: source
...
Msg 547, Level 16, State 0, Line 1
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_TABKHOKIEMKECT_TABKHOKIEMKE". The conflict occurred in database "NhanSu", table "dbo.TABQUANHEGDTT", column 'IDQH'.
The statement has been terminated.
...
In the database I don't have these 2 tables:
TABKHOKIEMKECT
TABKHOKIEMKE
You have to look at the table TABQUANHEGDTT as it is stated in the error message!
So as Arjay already asked you, please show us the definitions of the tables:
TABQUANHEGD
TABNGUON
TABQUANHEGDTT
Victor Nijegorodov
-
September 6th, 2020, 08:42 PM
#4
Re: Why do I copy Table1 contents to Table with the error ?
In my data there are no these 2 Tables: "FK_TABKHOKIEMKECT_TABKHOKIEMKE" and I have not created a relationship to the Table TABQUANHEGDTT, how to fix this? you see my database attachment.
http://www.mediafire.com/file/4a4fj4...seErr.rar/file
-
September 7th, 2020, 12:28 AM
#5
Re: Why do I copy Table1 contents to Table with the error ?
Originally Posted by dongtrien
Again, please attach files DIRECTLY to this site. If you put files in a 3rd party site we can't help you.
-
September 7th, 2020, 01:19 AM
#6
Re: Why do I copy Table1 contents to Table with the error ?
Originally Posted by dongtrien
In my data there are no these 2 Tables: "FK_TABKHOKIEMKECT_TABKHOKIEMKE" and I have not created a relationship to the Table TABQUANHEGDTT
"FK_TABKHOKIEMKECT_TABKHOKIEMKE" is not a table name. It is a key (relation) name.
Originally Posted by dongtrien
Please, attach it to your post in this Forum! Read the Announcement: Before you post.....
Victor Nijegorodov
-
September 7th, 2020, 08:17 PM
#7
Re: Why do I copy Table1 contents to Table with the error ?
Attached file 10MB website server cannot be uploaded, upload is suspended, so I use the 3rd service
-
September 8th, 2020, 01:50 AM
#8
Re: Why do I copy Table1 contents to Table with the error ?
Originally Posted by dongtrien
Attached file 10MB website server cannot be uploaded, upload is suspended, so I use the 3rd service
What did you try to upload? The whole database?
I have no idea how it was implemented in SQL Server 2005 (and why are you still using it!?)
In 2008 and later versions it is like:
Attachment 35899
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|