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.
| Author |
Topic |
|
dr223
Constraint Violating Yak Guru
444 Posts |
Posted - 2011-05-20 : 10:42:52
|
| Hi, I have a table called dbo.tblfruits as shown below A B 1 Orange2 Banana3 Apple4 PeasI want to add another column to dbo.tblfruits Column C, this column should come from another table dbo.tblprice, whereby COLUMN A on dbo.tblfruits = COLUMN A on dbo.tblprice..dbo.tblprice is as shown below; A B 1 2.002 3.003 4.004 4.00Therefore, my final results will be; A B C1 Orange 2.002 Banana 3.003 Apple 4.004 Peas 4.00Many thanks |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-05-20 : 11:40:14
|
| alter table tblfruits add C decimal(10,2) not null default 0update tblfruitsset C = p.Bfrom tblfruits fjoin tblprice pon f.A = p.A==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2011-05-20 : 14:21:06
|
| If it is already in another table, and there is a foreign key to it, then LEAVE IT ALONE. 1st Normal Form = good.http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxHow to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
|
|
|