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 693683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:46:44+00:00 2026-05-14T02:46:44+00:00

I have a rather large database that has alot of decimal columns in alot

  • 0

I have a rather large database that has alot of decimal columns in alot of tables, the customer has now changed their mind and wants all the numbers (decimals) to have a precision of 3 d.p. instead of the original two. Is there any quick way of going through all the tables in a database and changing any decimal column in that table to have 3.d.p instead of 2 d.p?

The db is on sql 2005.

Any help would be great.

  • 1 1 Answer
  • 1 View
  • 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-14T02:46:45+00:00Added an answer on May 14, 2026 at 2:46 am

    Get the columns from information_schema based on type and scale, then alter them to have the desired scale.

    declare @col sysname
    declare @tbl sysname
    declare @sql nvarchar(256)
    
    declare crsFix cursor for
    select table_name, Column_name from information_schema.columns
    where data_type = 'decimal' and Numeric_Scale = 3
    open crsFix
    fetch next from crsFix into @tbl, @col
    while(@@Fetch_Status = 0)
    Begin
        set @sql = 'Alter table [' + @tbl + '] alter column [' + @col + '] decimal(38,2) '  
        print @sql
        exec sp_executesql @sql
        fetch next from crsFix into @tbl, @col
    End
    close crsFix
    deallocate crsFix
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rather large application that has literally a hundred DDLs with Yes
I'm working on an iOS app that has a rather large sqlite database that
I have rather large project that uses ICU regex classes. Basically it might run
I have a rather large amount of data (100 MB or so), that I
Here is my dilema, I have a rather large PHP script, that basically reads
I have a rather large database exposed to my application using LINQ-to-SQL. I need
I have a marklogic (4.2) database that contains tens of thousands of large-ish, complex-ish
I have a site that's growing large, and has very separate needs for different
I am working with a rather large database of information now and some queries
We've inherited a rather large Access DB that has some very strange (and unsettling)

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.