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 |
|
moramoga
Starting Member
34 Posts |
Posted - 2006-12-11 : 19:55:29
|
| I have a table Products with their prices, and I have another table Sales, that have the prices of the products but they are null, I need to make an update that update the tables Sales, inserting the prices from the table Products |
|
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2006-12-11 : 20:24:46
|
| OK. You'll need to post your table design before we can help. You might also like to describe what rules you want to use to update the prices column (e.g. get price from most recent sale, average price of all sales etc etc)Better still, have a look at Books Online and have a stab at it yourself. If you're still stuck, post your attempt here and let us help you with it. Tim |
 |
|
|
moramoga
Starting Member
34 Posts |
Posted - 2006-12-11 : 20:41:30
|
| CREATE TABLE [dbo].[TProductos]( [TN_Cod_Producto] [int] NOT NULL, [TC_Nom_Producto] [varchar](50) NULL, [TN_Precio] [decimal](18, 0) NULL, CONSTRAINT [PK_TProductos] PRIMARY KEY CLUSTERED (CREATE TABLE [dbo].[TDetVenta]( [TN_Cod_Venta] [int] NOT NULL, [TN_Anno_Venta] [int] NOT NULL, [TN_Cod_Producto] [int] NOT NULL, [TN_Cantidad] [int] NULL, [TN_Precio] [decimal](18, 0) NULL, CONSTRAINT [PK_TDetVenta] PRIMARY KEY CLUSTERED (What I need to do is pass TN_Precio from TProdcuto to TN_Precio in TDetVEntas |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-12-12 : 05:55:38
|
| Assuming that TN_Precio is price column, this may workUpdate Sset TN_Precio=P.TN_Preciofrom Sales S inner join Products Pon S.TN_Cod_Producto=P.TN_Cod_ProductoMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|