How to update the data from different table
Here is Sql Server Update statement
Update DestinationTable
Set Field = SourceTable.Field //if you have multiple field separated by comma
From DestinationTable
Inner Join SourceTable
On DestinationTable.CommonField = SourceTable.CommonField
Below live example of update of sql server
Destination Table
Source Table
Update DestinationTable
Set ProductPrice= SourceTable.ProductPrice //if you have multiple field separated by comma
From DestinationTable
Inner Join SourceTable
On DestinationTable.ProductID= SourceTable.ProductID
Here is Sql Server Update statement
Update DestinationTable
Set Field = SourceTable.Field //if you have multiple field separated by comma
From DestinationTable
Inner Join SourceTable
On DestinationTable.CommonField = SourceTable.CommonField
Below live example of update of sql server
Destination Table
ProudctID | Name | ProudctPrice |
100 | Glasses | $29.99 |
101 | Lens | $99.99 |
Source Table
ProudctID | Name | ProudctPrice |
100 | Glasses | $49.99 |
101 | Lens | $199.99 |
Update DestinationTable
Set ProductPrice= SourceTable.ProductPrice //if you have multiple field separated by comma
From DestinationTable
Inner Join SourceTable
On DestinationTable.ProductID= SourceTable.ProductID
Result after the update
Destination Table
ProudctID | Name | ProudctPrice |
100 | Glasses | $49.99 |
101 | Lens | $199.99 |
No comments :
Post a Comment