Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Into

Status
Not open for further replies.

chester27

IS-IT--Management
Apr 29, 2002
208
0
0
GB
Hi

I have 2 tables, and need to append one column in table 1 with another column from table 2 where a certain columnID is the same.

Insert Into T1.C1
Select C2 from T2
WHERE T1.C3 = T2.C3

Getting could not be bound error? Any help please.
 
Probably need to join those

Insert Into T1 (C1)
Select C2
from T2
join T1
on T1.C3 = T2.C3

Simi
 
Getting Cannot insert the value NULL into column 'C4', table 'T1'; column does not allow nulls. INSERT fails.
 
C4 has a contraint that does not allow nulls. You did not provide any info about it so you may have to insert something in that field at the same time or take the constraint off.

Simi
 
I don't see a C4 in your script. Is there more of the script that you didn't post? Or is there a trigger on the table that updates C4 when other columns are updated?

-SQLBill

The following is part of my signature block and is only intended to be informational.
Posting advice: FAQ481-4875
 
Thanks all, C4 was not mentioned as I only want to merge data into a few columns C2. It's now sorted, slight typo, and a little more understanding around join.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top