October 6, 2004 at 7:51 am
I need to add a column to an existing table and then populate the column with data from another table. I need to write a script to do this. Eventually I will wirte a join to this table to grab data. Where do I start???
October 6, 2004 at 3:16 pm
Start with ALTER TABLE in BooksOnLine.
Greg
Greg
October 6, 2004 at 4:54 pm
Alter table1 add column1 datatype
Update t1
set Column1 = t2.Column1
From Table1 t1
JOIN Table2 t2 on t1.UniqueID = t2.UniqueID
Table1 is the table you're adding the column (column1) to. Datatype is the type of column it is (int, char(1), money, etc). The Join is occomplished between the tables using a key that exists in both (preferably unique for each row, otherwise you'll get duplicates in your join).
Hope this helps.
cl
Signature is NULL
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply