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
 how to change forumula for computed column

Author  Topic 

whitebird
Starting Member

12 Posts

Posted - 2008-02-28 : 07:50:03
hi,
create table mytable
(
id int,
num int,
comp as id/num
)

now i want to change column comp to formula id/100.
please help me out.


Raghu sunkara.

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-02-28 : 07:54:24
[code]alter table dbo.mytable
drop column comp
GO

alter table dbo.mytable
add comp as id/100
GO[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-02-28 : 07:58:30
Also note that if id<100, then you would get 0. So better use id/100.0
http://sqlblogcasts.com/blogs/madhivanan/archive/2008/01/16/beware-of-implicit-conversions.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -