Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 alter view

Author  Topic 

Vack
Aged Yak Warrior

530 Posts

Posted - 2011-11-22 : 14:12:20
How do I change the datatype of a column in a view?

It is currently decimal(32,2)

I would like to change it to decimal(14,2)

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-11-22 : 14:13:51
You would change the underlying table.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Vack
Aged Yak Warrior

530 Posts

Posted - 2011-11-22 : 14:16:01
The The fields in the view are totals of a field. The field in the underlying table is decimal(14,2)
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-11-22 : 14:19:02
So what problem are you having? Did altering the underlying table not work? Are there conversions in the view or something?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2011-11-22 : 14:39:32
When you do math of NUMERIC/DECIMAL columns the resulting precision and scale can be changed. Given that, you probalby just need to CAST the result to the precision and scale you want (14,2).

For refernce, here is a link that describes when and how the precision and scale are changed:
http://msdn.microsoft.com/en-us/library/ms190476.aspx
Go to Top of Page
   

- Advertisement -