Click here to Skip to main content
15,924,581 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Simple question but i can't seem to find what i need, as examples are giving me only where id=1 etc.

pseudo code of what i'm wanting to achieve but doesn't work (errors)

SQL
INSERT INTO tableB b
SELECT a.l_desc, a.s_desc FROM tableA a where on a.id = b.id


id's are same in both tables so insert the correct descriptions
Posted
Updated 19-Nov-14 1:15am
v2

your tableB have b.id values already so you can't use insert Query .your only option Update it

SQL
update   b set b.l_desc=a.l_desc,b.s_desc=a.s_desc
from tableB as b inner join tableA a where a.id = b.id
 
Share this answer
 
you should use update query instead of insert as you already have record in your tableB

SQL
update   b set l_desc=a.l_desc,s_desc=a.s_desc
from tableB , tableA a where a.id = b.id
 
Share this answer
 
Try this:
SQL
UPDATE tableB set l_desc=a.l_desc,s_desc=a.s_desc
FROM tableA a WHERE a.id=tableB.id
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900