Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 T-SQL Insert data

Author  Topic 

christosds
Starting Member

10 Posts

Posted - 2011-02-17 : 08:25:14
Hello,
i have 2 tables
Table 1 MATERIAL
CODE, NAME, BARCODE

and Table 2 CCBAR
CODE, BARCODE

Table 1 contains items without barcode numbers, table 2 contains the items barcode numbers.
I want to insert in table 1 the items barcodes from the table 2 when the MATERIAL.CODE=CCBAR.CODE

How do i do this?

Also is it possible to import the table 2 data directly from an excel file in to table 1?

Thanks in advance.


khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-02-17 : 08:46:08
[code]
UPDATE m
SET BARCODE = c.BARCODE
FROM MATERIAL m
INNER JOIN CCBAR c ON m.CODE = c.CODE
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -