Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15772

Why do I copy Table1 contents to Table with the error ?

$
0
0
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 ?

Viewing all articles
Browse latest Browse all 15772

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>