PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, August 10, 2022

[FIXED] How determine the scale of a decimal type column with SQL

 August 10, 2022     decimal, scale, sql, sql-server, tsql     No comments   

Issue

I need to change a decimal type column with precision 16 and scale 2 to precision 16 and scale 5, for which I would do the following:

ALTER TABLE dbo.my_table ALTER COLUMN my_column DECIMAL(16, 5)

But to avoid making this change every time the application runs, I would like to read the column scale and if it is different from 5, the line above would be executed.

Is there a way to get the scale of a column of decimal type?


Solution

Is there a way to get the scale of a column of decimal type?

You can query information_schema.columns:

select column_name, numeric_precision, numeric_scale 
from information_schema.columns
where table_schema = 'dbo' and table_name = 'my_table' and column_name = 'my_column'


Answered By - GMB
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © 2025 PHPFixing