I know there has got to be a better way, but I haven't been able to figure out how to add two dollars to all the unit prices in the products table of the Northwind Database. The Column has the money datatype.
[Code]
-- Doesn't work, but I tried.
BEGIN TRANSACTION
UPDATE [Products]
SET UnitPrice = UnitPrice + 2 --Adds $2.00 to each Unit Price.
SAVE TRANSACTION Upd_UnitPriceBy2Dol
ROLLBACK TRANSACTION Upd_UnitPriceBy2Dol
[/Code]
I really tried to get this to work, but couldn't figure out how to add 2 dollars to the Northwind DB Products table in UnitPrice. I want to add 2 dollars to all of them in UnitPrice.
I get an error when I run it that says: Msg 8152, Level 16, State 2, Procedure trgProductsLog, Line 10 [Batch Start Line 177] String or binary data would be truncated.
how about doing this?
** updated **
use <databasename>
UPDATE [Products]
SET UnitPrice = isnull(UnitPrice,0) + 2