Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4596630
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:08:32+00:00 2026-05-21T23:08:32+00:00

I am trying to update a column of type numeric(5,2) from decimal(10,2) but the

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T23:08:33+00:00Added an answer on May 21, 2026 at 11:08 pm

    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 OUTPUT clause to see the row(s) updated as illustrated below.

    CREATE TABLE #T
    (
    ID INT PRIMARY KEY,
    Duration NUMERIC(5,2),
    OtherColumn CHAR(1)
    )
    
    INSERT INTO #T VALUES (1,NULL,'T')
    
    DECLARE @ID INT = 1
    DECLARE @newDurationAsDec DECIMAL(10,2) = 2
    
    DECLARE @newDurationAsNum NUMERIC(5,2)
    SET @newDurationAsNum = CAST(@newDurationAsDec AS NUMERIC(5,2)) 
    SELECT @newDurationAsNum
    
    UPDATE #T
    SET Duration = @newDurationAsNum
    OUTPUT inserted.*, deleted.*
    WHERE ID = @ID AND
      Duration IS NULL AND
      OtherColumn = 'T'
    
    SELECT * FROM #T  
    
    DROP TABLE #T
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to update data into the column with data type decimal(18, 18).
I am trying to UPDATE a mysql TEXT data-type column with a string contains
I'm trying to update a column to a max value, but only when grouped
Since it's friday my brain must have malfunctioned. I'm trying to update a column
I have a table with a column called STREAM_TIME of DATE type. I'm trying
I'm trying to alter a bytea column to have type oid and still retain
I am trying to update a column in my table which was last inserted.
I'm trying to UPDATE a column for a user, so that they can only
I am trying to update a column based on another column in the same
I'm trying to update the comments column in one table (Entries), when a new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.