I am trying to update a column of type numeric(5,2) from decimal(10,2) but the column is remaining null and I have no error messages.
DECLARE @newDurationAsDec decimal(10,2)
DECLARE @newDurationAsNum numeric(5,2)
--@newDurationAsDec is set by some logic from another table and holds the correct value e.g 2.00
set @newDurationAsNum = CAST(@newDurationAsDec AS numeric(5,2))
--selecting @newDurationAsNum contains the correct value e.g. 2.00
UPDATE table
SET Duration = @newDurationAsNum
WHERE ID = @ID AND
Duration IS NULL AND
OtherColumn = 'T'
No errors are retruned and the column is not updated. Changing the update to a select returns the correct row. can someone point out my mistake?
Thanks in advance.
Works fine for me below. Check there are no triggers that might be interfering with things.
If you are on at least SQL Server 2005 you can use the
OUTPUTclause to see the row(s) updated as illustrated below.