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
 add new column and do the calculation

Author  Topic 

goligol
Posting Yak Master

128 Posts

Posted - 2011-10-13 : 16:18:54
I have a table with one column, want to add a new column and map some information to this column from another table:

I dont know how to create this query:

select a.hs_code
,'' a.hs_code_desc -------this is the new column in table a

update a
set a.hs_code_desc = b.hs_code_desc
from transportation.dev.hsWithoutNaics a
inner join trade.dev.export_concord2 b
on a.hs_code = b.hs_code

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-14 : 01:33:54
it should be
ALTER TABLE  transportation.dev.hsWithoutNaics ADD hs_code_desc varchar(100) NULL


I've assumed datatype as varchar. make sure you use correct datatype instead

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -