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
 How to copy data from one table to another

Author  Topic 

Abid

110 Posts

Posted - 2014-03-09 : 22:05:11
Hi. I have a table ProductBasicInfo, which has following fields:

ProdID (PK)
ProdName
Description
Manufacturer
Store
ProdPrice


Now i have another table TempPrice, having fields:


TempID (PK)
ProdID (FK)
TempProdPrice


TempPrice table has the original values, which are needed to copy into ProductBasicInfo column "ProdPrice" (which is entire NULL column so far). Please assist me that how to do this. Thanks in advance.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2014-03-09 : 23:36:14
[code]
UPDATE p
SET ProdPrice = t.TempProdPrice
FROM ProductBasicInfo p
INNER JOIN TempPrice t ON p.ProdID = t.ProdID
[/code]


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

Go to Top of Page

Abid

110 Posts

Posted - 2014-03-10 : 06:02:05
Thanks khtan, would you please tell me that what is P and what is t???
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2014-03-10 : 06:26:52
table alias


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

Go to Top of Page

Abid

110 Posts

Posted - 2014-03-10 : 07:11:17
quote:
Originally posted by khtan

table alias



Sorry, but what is table alias?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2014-03-10 : 07:18:10
alias is another name assigned to the table

http://www.w3schools.com/sql/sql_alias.asp


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

Go to Top of Page
   

- Advertisement -